basic
This commit is contained in:
commit
dc2847507b
|
|
@ -0,0 +1,55 @@
|
||||||
|
<script>
|
||||||
|
import Vue from 'vue'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
created() {
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
plus.navigator.closeSplashscreen();
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
onLaunch: function() {
|
||||||
|
|
||||||
|
console.log('App Launch')
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success: function(e) {
|
||||||
|
// #ifndef MP
|
||||||
|
Vue.prototype.StatusBar = e.statusBarHeight;
|
||||||
|
if (e.platform == 'android') {
|
||||||
|
Vue.prototype.CustomBar = e.statusBarHeight + 50;
|
||||||
|
} else {
|
||||||
|
Vue.prototype.CustomBar = e.statusBarHeight + 45;
|
||||||
|
};
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef MP-WEIXIN
|
||||||
|
Vue.prototype.StatusBar = e.statusBarHeight;
|
||||||
|
let custom = wx.getMenuButtonBoundingClientRect();
|
||||||
|
Vue.prototype.Custom = custom;
|
||||||
|
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef MP-ALIPAY
|
||||||
|
Vue.prototype.StatusBar = e.statusBarHeight;
|
||||||
|
Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onShow: function() {
|
||||||
|
console.log('App 开启')
|
||||||
|
},
|
||||||
|
onHide: function() {
|
||||||
|
console.log('App 关闭')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style >
|
||||||
|
page {
|
||||||
|
background-color: #f7f8fa;
|
||||||
|
}
|
||||||
|
body{
|
||||||
|
background: #f7f8fa !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
// AI伴侣
|
||||||
|
import {
|
||||||
|
get,
|
||||||
|
post
|
||||||
|
} from '@/config/api.js'
|
||||||
|
|
||||||
|
export const aiList = () => {
|
||||||
|
return get('/api/ai/list')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
aiList
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,152 @@
|
||||||
|
<template>
|
||||||
|
<!-- 底部导航 -->
|
||||||
|
<view class="tabbar" :style="{'padding-bottom': paddingBottomHeight + 'rpx'}">
|
||||||
|
<view class="tabbar-item" v-for="(item, index) in list" :key="index" @click="tabbarChange(item.path)">
|
||||||
|
<view class="image-wrap">
|
||||||
|
<image class="item-img" :src="item.iconPath" v-if="current == index"
|
||||||
|
:style="{width: item.width, height: item.height}"></image>
|
||||||
|
<image class="item-img" :src="item.icon" v-else :style="{width: item.width, height: item.height}">
|
||||||
|
</image>
|
||||||
|
<view class="name">
|
||||||
|
{{item.text}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
current: Number
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
paddingBottomHeight: 0, //苹果X以上手机底部适配高度
|
||||||
|
list: [{
|
||||||
|
text: '家人', //首页
|
||||||
|
icon: '/static/image/home.png',
|
||||||
|
iconPath: '/static/image/home-select.png',
|
||||||
|
path: "/pages/index/index",
|
||||||
|
width: "66rpx",
|
||||||
|
height: "66rpx"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '设备', //首页
|
||||||
|
icon: '/static/image/device.png',
|
||||||
|
iconPath: '/static/image/device-select.png',
|
||||||
|
path: "/pages/device/device",
|
||||||
|
width: "66rpx",
|
||||||
|
height: "66rpx"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '我的', //我的
|
||||||
|
icon: '/static/image/my.png',
|
||||||
|
iconPath: '/static/image/my-select.png',
|
||||||
|
path: "/pages/my/my",
|
||||||
|
width: "66rpx",
|
||||||
|
height: "66rpx"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
let that = this;
|
||||||
|
uni.getSystemInfo({
|
||||||
|
success: function(res) {
|
||||||
|
let model = ['X', 'XR', 'XS', '11', '12', '13', '14', '15'];
|
||||||
|
model.forEach(item => {
|
||||||
|
//适配iphoneX以上的底部,给tabbar一定高度的padding-bottom
|
||||||
|
if (res.model.indexOf(item) != -1 && res.model.indexOf('iPhone') != -1) {
|
||||||
|
that.paddingBottomHeight = 40;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
tabbarChange(path) {
|
||||||
|
uni.reLaunch({
|
||||||
|
url: path
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.tabbarActive {
|
||||||
|
color: #79D5AD !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabbar {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0rpx;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 180rpx;
|
||||||
|
background: #FFFFFF;
|
||||||
|
z-index: 999999;
|
||||||
|
border-radius: 80rpx 80rpx 0rpx 0rpx;
|
||||||
|
-webkit-box-shadow: 0 0 60rpx 0 rgba(43, 86, 112, .1);
|
||||||
|
box-shadow: 0 0 60rpx 0 rgba(43, 86, 112, .1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabbar-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-wrap {
|
||||||
|
width: 130rpx;
|
||||||
|
height: 110rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image-scan {
|
||||||
|
position: absolute;
|
||||||
|
top: -65rpx;
|
||||||
|
width: 180rpx;
|
||||||
|
height: 180rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: #fff;
|
||||||
|
|
||||||
|
.circle {
|
||||||
|
width: 160rpx;
|
||||||
|
height: 160rpx;
|
||||||
|
position: absolute;
|
||||||
|
top: 10rpx;
|
||||||
|
left: -50%;
|
||||||
|
right: -50%;
|
||||||
|
margin: 0 auto;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: #382daf;
|
||||||
|
}
|
||||||
|
|
||||||
|
image {
|
||||||
|
width: 100rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
position: absolute;
|
||||||
|
left: -50%;
|
||||||
|
right: -50%;
|
||||||
|
margin: 0 auto;
|
||||||
|
top: 40rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
font-size: 26rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-img {
|
||||||
|
width: 130rpx;
|
||||||
|
height: 130rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,134 @@
|
||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<!-- 按钮 -->
|
||||||
|
<button
|
||||||
|
:class="['buttonBorder',!_rotate?'dlbutton':'dlbutton_loading']"
|
||||||
|
:style="{'background':bgColor, 'color': fontColor}"
|
||||||
|
|
||||||
|
@click="$emit('click', $event)"
|
||||||
|
@contact="$emit('contact', $event)"
|
||||||
|
@error="$emit('error', $event)"
|
||||||
|
@getphonenumber="$emit('getphonenumber', $event)"
|
||||||
|
@getuserinfo="$emit('getuserinfo', $event)"
|
||||||
|
@launchapp="$emit('launchapp', $event)"
|
||||||
|
@longtap="$emit('longtap', $event)"
|
||||||
|
@opensetting="$emit('opensetting', $event)"
|
||||||
|
@touchcancel="$emit('touchcancel', $event)"
|
||||||
|
@touchend="$emit('touchend', $event)"
|
||||||
|
@touchmove="$emit('touchmove', $event)"
|
||||||
|
@touchstart="$emit('touchstart', $event)"
|
||||||
|
>
|
||||||
|
<view :class="_rotate?'rotate_loop':''">
|
||||||
|
<text v-if="_rotate" class="cuIcon cuIcon-loading1 "></text>
|
||||||
|
<view v-if="!_rotate"><slot name="text">{{ text }}</slot></view>
|
||||||
|
</view>
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default{
|
||||||
|
props:{
|
||||||
|
text: String, //显示文本
|
||||||
|
rotate:{
|
||||||
|
//是否启动加载
|
||||||
|
type: [Boolean,String],
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
bgColor:{
|
||||||
|
//按钮背景颜色
|
||||||
|
type: String,
|
||||||
|
default: "linear-gradient(to right, rgba(0,0,0,0.7), rgba(0,0,0,0.6))",
|
||||||
|
},
|
||||||
|
fontColor:{
|
||||||
|
//按钮字体颜色
|
||||||
|
type: String,
|
||||||
|
default: "#FFFFFF",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed:{
|
||||||
|
_rotate() {
|
||||||
|
//处理值
|
||||||
|
return String(this.rotate) !== 'false'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@import url("./css/icon.css");
|
||||||
|
|
||||||
|
button{
|
||||||
|
outline: none; /* 或者 outline: 0 */
|
||||||
|
}
|
||||||
|
button:after {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
button:focus{
|
||||||
|
outline: none; /* 或者 outline: 0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.dlbutton {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #FFFFFF;
|
||||||
|
font-size: 30rpx;
|
||||||
|
white-space:nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
width:601rpx;
|
||||||
|
height:100rpx;
|
||||||
|
background:linear-gradient(to right, rgba(0,0,0,0.7), rgba(0,0,0,0.6));
|
||||||
|
box-shadow:0rpx 0rpx 13rpx 0rpx rgba(164,217,228,0.4);
|
||||||
|
border-radius:2.5rem;
|
||||||
|
margin-top: 0rpx;
|
||||||
|
}
|
||||||
|
.dlbutton_loading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #FFFFFF;
|
||||||
|
font-size: 30rpx;
|
||||||
|
width:100rpx;
|
||||||
|
height:100rpx;
|
||||||
|
background:linear-gradient(to right, rgba(0,0,0,0.7), rgba(0,0,0,0.6));
|
||||||
|
box-shadow:0rpx 0rpx 13rpx 0rpx rgba(164,217,228,0.4);
|
||||||
|
border-radius:2.5rem;
|
||||||
|
margin-top: 0rpx;
|
||||||
|
}
|
||||||
|
.buttonBorder{
|
||||||
|
border: none ;
|
||||||
|
border-radius: 2.5rem ;
|
||||||
|
-webkit-box-shadow: 0 0 60rpx 0 rgba(0,0,0,.2) ;
|
||||||
|
box-shadow: 0 0 60rpx 0 rgba(0,0,0,.2) ;
|
||||||
|
-webkit-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
|
||||||
|
-moz-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
|
||||||
|
-ms-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
|
||||||
|
-o-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
|
||||||
|
transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 旋转动画 */
|
||||||
|
.rotate_loop{
|
||||||
|
-webkit-transition-property: -webkit-transform;
|
||||||
|
-webkit-transition-duration: 1s;
|
||||||
|
-moz-transition-property: -moz-transform;
|
||||||
|
-moz-transition-duration: 1s;
|
||||||
|
-webkit-animation: rotate 1s linear infinite;
|
||||||
|
-moz-animation: rotate 1s linear infinite;
|
||||||
|
-o-animation: rotate 1s linear infinite;
|
||||||
|
animation: rotate 1s linear infinite;
|
||||||
|
}
|
||||||
|
@-webkit-keyframes rotate{from{-webkit-transform: rotate(0deg)}
|
||||||
|
to{-webkit-transform: rotate(360deg)}
|
||||||
|
}
|
||||||
|
@-moz-keyframes rotate{from{-moz-transform: rotate(0deg)}
|
||||||
|
to{-moz-transform: rotate(359deg)}
|
||||||
|
}
|
||||||
|
@-o-keyframes rotate{from{-o-transform: rotate(0deg)}
|
||||||
|
to{-o-transform: rotate(359deg)}
|
||||||
|
}
|
||||||
|
@keyframes rotate{from{transform: rotate(0deg)}
|
||||||
|
to{transform: rotate(359deg)}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,217 @@
|
||||||
|
<template>
|
||||||
|
<view class="main-list oBorder">
|
||||||
|
<!-- 文本框 -->
|
||||||
|
<input
|
||||||
|
class="main-input"
|
||||||
|
:value="value"
|
||||||
|
:type="_type"
|
||||||
|
:focus="_focus"
|
||||||
|
:maxlength="maxlength"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
:password="type==='password'&&!showPassword"
|
||||||
|
@input="$emit('input', $event.detail.value)"
|
||||||
|
@blur="$emit('blur', $event)"
|
||||||
|
@focus="$emit('focus', $event)"
|
||||||
|
@longpress="$emit('longpress', $event)"
|
||||||
|
@confirm="$emit('confirm', $event)"
|
||||||
|
@click="$emit('click', $event)"
|
||||||
|
@longtap="$emit('longtap', $event)"
|
||||||
|
@touchcancel="$emit('touchcancel', $event)"
|
||||||
|
@touchend="$emit('touchend', $event)"
|
||||||
|
@touchmove="$emit('touchmove', $event)"
|
||||||
|
@touchstart="$emit('touchstart', $event)"
|
||||||
|
/>
|
||||||
|
<!-- 是否可见密码 -->
|
||||||
|
<image
|
||||||
|
v-if="_isShowPass&&type==='password'&&!_isShowCode"
|
||||||
|
class="img cuIcon"
|
||||||
|
:class="showPassword?'cuIcon-attention':'cuIcon-attentionforbid'"
|
||||||
|
@tap="showPass"
|
||||||
|
></image>
|
||||||
|
<!-- 倒计时 -->
|
||||||
|
<view
|
||||||
|
v-if="_isShowCode&&!_isShowPass"
|
||||||
|
:class="['vercode',{'vercode-run': second>0}]"
|
||||||
|
@click="setCode"
|
||||||
|
>{{ getVerCodeSecond }}</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let _this, countDown;
|
||||||
|
export default{
|
||||||
|
data(){
|
||||||
|
return{
|
||||||
|
showPassword: false, //是否显示明文
|
||||||
|
second: 0, //倒计时
|
||||||
|
isRunCode: false, //是否开始倒计时
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props:{
|
||||||
|
type: String, //类型
|
||||||
|
value: String, //值
|
||||||
|
placeholder: String, //框内提示
|
||||||
|
maxlength: {
|
||||||
|
//最大长度
|
||||||
|
type: [Number,String],
|
||||||
|
default: 20,
|
||||||
|
},
|
||||||
|
isShowPass:{
|
||||||
|
//是否显示密码图标(二选一)
|
||||||
|
type: [Boolean,String],
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
isShowCode:{
|
||||||
|
//是否显示获取验证码(二选一)
|
||||||
|
type: [Boolean,String],
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
codeText:{
|
||||||
|
type: String,
|
||||||
|
default: "获取验证码",
|
||||||
|
},
|
||||||
|
setTime:{
|
||||||
|
//倒计时时间设置
|
||||||
|
type: [Number,String],
|
||||||
|
default: 60,
|
||||||
|
},
|
||||||
|
focus:{
|
||||||
|
//是否聚焦
|
||||||
|
type: [Boolean,String],
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
model: {
|
||||||
|
prop: 'value',
|
||||||
|
event: 'input'
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
_this=this
|
||||||
|
//准备触发
|
||||||
|
this.$on('runCode',(val)=>{
|
||||||
|
this.runCode(val);
|
||||||
|
});
|
||||||
|
clearInterval(countDown);//先清理一次循环,避免缓存
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
showPass(){
|
||||||
|
//是否显示密码
|
||||||
|
this.showPassword = !this.showPassword
|
||||||
|
},
|
||||||
|
setCode(){
|
||||||
|
//设置获取验证码的事件
|
||||||
|
if(this.isRunCode){
|
||||||
|
//判断是否开始倒计时,避免重复点击
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.$emit('setCode')
|
||||||
|
},
|
||||||
|
runCode(val){
|
||||||
|
//开始倒计时
|
||||||
|
if(String(val)=="0"){
|
||||||
|
|
||||||
|
//判断是否需要终止循环
|
||||||
|
this.second = 0; //初始倒计时
|
||||||
|
clearInterval(countDown);//清理循环
|
||||||
|
this.isRunCode= false; //关闭循环状态
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(this.isRunCode){
|
||||||
|
//判断是否开始倒计时,避免重复点击
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.isRunCode= true
|
||||||
|
this.second = this._setTime //倒数秒数
|
||||||
|
|
||||||
|
let _this=this;
|
||||||
|
countDown = setInterval(function(){
|
||||||
|
_this.second--
|
||||||
|
if(_this.second==0){
|
||||||
|
_this.isRunCode= false
|
||||||
|
clearInterval(countDown)
|
||||||
|
}
|
||||||
|
},1000)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed:{
|
||||||
|
_type(){
|
||||||
|
//处理值
|
||||||
|
const type = this.type
|
||||||
|
return type == 'password' ? 'text' : type
|
||||||
|
},
|
||||||
|
_isShowPass() {
|
||||||
|
//处理值
|
||||||
|
return String(this.isShowPass) !== 'false'
|
||||||
|
},
|
||||||
|
_isShowCode() {
|
||||||
|
//处理值
|
||||||
|
return String(this.isShowCode) !== 'false'
|
||||||
|
},
|
||||||
|
_setTime() {
|
||||||
|
//处理值
|
||||||
|
const setTime = Number(this.setTime)
|
||||||
|
return setTime>0 ? setTime : 60
|
||||||
|
},
|
||||||
|
_focus() {
|
||||||
|
//处理值
|
||||||
|
return String(this.focus) !== 'false'
|
||||||
|
},
|
||||||
|
getVerCodeSecond(){
|
||||||
|
//验证码倒计时计算
|
||||||
|
if(this.second<=0){
|
||||||
|
return this.codeText;
|
||||||
|
}else{
|
||||||
|
if(this.second<10){
|
||||||
|
return '0'+this.second;
|
||||||
|
}else{
|
||||||
|
return this.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@import url("./css/icon.css");
|
||||||
|
|
||||||
|
.main-list{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
/* height: 36rpx; */ /* Input 高度 */
|
||||||
|
color: #333333;
|
||||||
|
padding: 40rpx 32rpx;
|
||||||
|
margin:32rpx 0;
|
||||||
|
}
|
||||||
|
.img{
|
||||||
|
width: 32rpx;
|
||||||
|
height: 32rpx;
|
||||||
|
font-size: 32rpx;
|
||||||
|
}
|
||||||
|
.main-input{
|
||||||
|
flex: 1;
|
||||||
|
text-align: left;
|
||||||
|
font-size: 28rpx;
|
||||||
|
/* line-height: 100rpx; */
|
||||||
|
padding-right: 10rpx;
|
||||||
|
margin-left: 20rpx;
|
||||||
|
}
|
||||||
|
.vercode {
|
||||||
|
color: rgba(0,0,0,0.7);
|
||||||
|
font-size: 24rpx;
|
||||||
|
/* line-height: 100rpx; */
|
||||||
|
}
|
||||||
|
.vercode-run {
|
||||||
|
color: rgba(0,0,0,0.4) !important;
|
||||||
|
}
|
||||||
|
.oBorder{
|
||||||
|
border: none;
|
||||||
|
border-radius: 2.5rem ;
|
||||||
|
-webkit-box-shadow: 0 0 60rpx 0 rgba(43,86,112,.1) ;
|
||||||
|
box-shadow: 0 0 60rpx 0 rgba(43,86,112,.1) ;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
// post请求,获取菜单
|
||||||
|
export const post = (url,params, config = {}) => uni.$u.http.post(url, params, config)
|
||||||
|
|
||||||
|
// get请求,获取菜单,注意:get请求的配置等,都在第二个参数中,详见前面解释
|
||||||
|
export const get = (url,data,toast,responseType = '') => uni.$u.http.get(url, {params: data,custom:{toast:toast||false},responseType:responseType})
|
||||||
|
|
||||||
|
// export const baseUrl = 'http://103.39.230.169:8085' // APP测试
|
||||||
|
export const baseUrl = 'http://bmsc.baimajingxuan.com'; // APP线上
|
||||||
|
|
@ -0,0 +1,152 @@
|
||||||
|
import store from "../store/index.js";
|
||||||
|
import { baseUrl } from "./api.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
doLogin
|
||||||
|
} from '@/common/api/login.js'
|
||||||
|
const HOST = location && location.origin
|
||||||
|
export default () => {
|
||||||
|
|
||||||
|
// 初始化请求配置
|
||||||
|
uni.$u.http.setConfig((config) => {
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
config.baseURL = baseUrl; // 测试地址
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef H5
|
||||||
|
config.baseURL = location.origin; /* 根域名 */
|
||||||
|
// #endif
|
||||||
|
return config
|
||||||
|
});
|
||||||
|
|
||||||
|
// 请求拦截
|
||||||
|
uni.$u.http.interceptors.request.use((config) => { // 可使用async await 做异步操作
|
||||||
|
config.data = config.data || {};
|
||||||
|
config.baseURL = 'http://103.39.230.169:8085'; // 不使用请求代理 上线记得注释掉 ***********************************************************
|
||||||
|
|
||||||
|
let apiToken = store.getters['api/getApiToken']
|
||||||
|
|
||||||
|
let serverTime = (parseInt(Date.now() /1000) - store.getters['api/getServerTime'])
|
||||||
|
|
||||||
|
config.header.ApiToken = apiToken
|
||||||
|
config.header.timestamp = serverTime
|
||||||
|
config.header.validate = store.getters['api/getValidate'] || ''
|
||||||
|
config.header.safeverify = store.getters['api/getSafeCode'] || ''
|
||||||
|
|
||||||
|
let ob = (config.method == 'GET'?config.params:config.data)
|
||||||
|
|
||||||
|
// config.header.token = utils.makeSign(ob,serverTime)
|
||||||
|
store.commit('api/setToken', config.header.token);
|
||||||
|
uni.showLoading({
|
||||||
|
mask: true,
|
||||||
|
title:"加载中..."
|
||||||
|
})
|
||||||
|
return config
|
||||||
|
}, config => { // 可使用async await 做异步操作
|
||||||
|
return Promise.reject(config)
|
||||||
|
})
|
||||||
|
|
||||||
|
// 响应拦截
|
||||||
|
uni.$u.http.interceptors.response.use((response) => {
|
||||||
|
// 判断高防接口第一次被拉拦截
|
||||||
|
if (response.data.data == undefined) {
|
||||||
|
uni.showToast({
|
||||||
|
mask: true,
|
||||||
|
title: '太火爆了,请点击右上角刷新重试',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.hideLoading({});
|
||||||
|
|
||||||
|
if (response.config.responseType == "arrayBuffer") {
|
||||||
|
let base64 = "data:image/png;base64," + uni.arrayBufferToBase64(response.data)
|
||||||
|
return base64
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 对响应成功做点什么 可使用async await 做异步操作*/
|
||||||
|
const data = response.data
|
||||||
|
const custom = response.config?.custom
|
||||||
|
if (data.code !== 200) {
|
||||||
|
// 机器验证
|
||||||
|
if (data.code === 8888) {
|
||||||
|
// 0 页内跳转 1 页外跳转
|
||||||
|
if (data.type == 0) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/user/robot`
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/user/pay_webview/pay_webview?title=跳转页&urlLink=${encodeURIComponent(data.path)}`
|
||||||
|
})
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef H5
|
||||||
|
window.location.href = data.path;
|
||||||
|
// #endif
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (data.code === 401) {
|
||||||
|
let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
|
||||||
|
let curRoute = routes[routes.length - 1].route //获取当前页面路由
|
||||||
|
// 在微信小程序或是app中,通过curPage.options
|
||||||
|
// 如果是H5,则需要curPage.$route.query(H5中的curPage.options为undefined)
|
||||||
|
let curParam = routes[routes.length - 1].options || routes[routes.length - 1].$route.query; //获取路由参数
|
||||||
|
// 拼接参数
|
||||||
|
let param = ''
|
||||||
|
let yqCode = ''
|
||||||
|
for (let key in curParam) {
|
||||||
|
param += '&' + key + '=' + curParam[key]
|
||||||
|
if (key == 'yq_code') {
|
||||||
|
yqCode = curParam[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let _thisUrl = ''
|
||||||
|
if (curRoute.indexOf('?') == -1) {
|
||||||
|
_thisUrl = curRoute + (param ? ('?' + param) : '')
|
||||||
|
} else {
|
||||||
|
_thisUrl = curRoute + (param ? ('&' + param) : '')
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showToast({
|
||||||
|
mask: true,
|
||||||
|
title:data.msg,
|
||||||
|
icon:'none'
|
||||||
|
})
|
||||||
|
setTimeout(e => {
|
||||||
|
utils.goPath('/pages/login/login');
|
||||||
|
},1000)
|
||||||
|
} else if (data.code === 400) {
|
||||||
|
uni.showToast({
|
||||||
|
mask: true,
|
||||||
|
title: data.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else if (data.code === 0) {
|
||||||
|
uni.showToast({
|
||||||
|
mask: true,
|
||||||
|
title: data.msg,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (custom.toast !== false) {
|
||||||
|
uni.$u.toast(data.msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(response.config.url)
|
||||||
|
return Promise.reject(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.data === undefined ? {} : data.data;
|
||||||
|
}, (response) => {
|
||||||
|
uni.showToast({
|
||||||
|
mask: true,
|
||||||
|
title: '服务器响应失败' + response.statusCode,
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return Promise.reject(response)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<script>
|
||||||
|
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
|
||||||
|
CSS.supports('top: constant(a)'))
|
||||||
|
document.write(
|
||||||
|
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
|
||||||
|
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
||||||
|
</script>
|
||||||
|
<title></title>
|
||||||
|
<!--preload-links-->
|
||||||
|
<!--app-context-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"><!--app-html--></div>
|
||||||
|
<script type="module" src="/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
import App from './App'
|
||||||
|
|
||||||
|
// #ifndef VUE3
|
||||||
|
import Vue from 'vue'
|
||||||
|
import './uni.promisify.adaptor'
|
||||||
|
import store from '@/store'
|
||||||
|
|
||||||
|
Vue.prototype.$store = store;
|
||||||
|
Vue.config.productionTip = false
|
||||||
|
App.mpType = 'app'
|
||||||
|
const app = new Vue({
|
||||||
|
...App
|
||||||
|
})
|
||||||
|
app.$mount()
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef VUE3
|
||||||
|
import { createSSRApp } from 'vue'
|
||||||
|
export function createApp() {
|
||||||
|
const app = createSSRApp(App)
|
||||||
|
app.use(store)
|
||||||
|
return {
|
||||||
|
app
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
{
|
||||||
|
"name" : "family-app",
|
||||||
|
"appid" : "__UNI__24DA8DD",
|
||||||
|
"description" : "",
|
||||||
|
"versionName" : "1.0.0",
|
||||||
|
"versionCode" : "100",
|
||||||
|
"transformPx" : false,
|
||||||
|
/* 5+App特有相关 */
|
||||||
|
"app-plus" : {
|
||||||
|
"usingComponents" : true,
|
||||||
|
"nvueStyleCompiler" : "uni-app",
|
||||||
|
"compilerVersion" : 3,
|
||||||
|
"splashscreen" : {
|
||||||
|
"alwaysShowBeforeRender" : true,
|
||||||
|
"waiting" : true,
|
||||||
|
"autoclose" : true,
|
||||||
|
"delay" : 0
|
||||||
|
},
|
||||||
|
/* 模块配置 */
|
||||||
|
"modules" : {},
|
||||||
|
/* 应用发布信息 */
|
||||||
|
"distribute" : {
|
||||||
|
/* android打包配置 */
|
||||||
|
"android" : {
|
||||||
|
"permissions" : [
|
||||||
|
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||||
|
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||||
|
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* ios打包配置 */
|
||||||
|
"ios" : {},
|
||||||
|
/* SDK配置 */
|
||||||
|
"sdkConfigs" : {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/* 快应用特有相关 */
|
||||||
|
"quickapp" : {},
|
||||||
|
/* 小程序特有相关 */
|
||||||
|
"mp-weixin" : {
|
||||||
|
"appid" : "",
|
||||||
|
"setting" : {
|
||||||
|
"urlCheck" : false
|
||||||
|
},
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"mp-alipay" : {
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"mp-baidu" : {
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"mp-toutiao" : {
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"uniStatistics" : {
|
||||||
|
"enable" : false
|
||||||
|
},
|
||||||
|
"vueVersion" : "2"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../nanoid/bin/nanoid.cjs
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../@babel/parser/bin/babel-parser.js
|
||||||
|
|
@ -0,0 +1,285 @@
|
||||||
|
{
|
||||||
|
"name": "family-app",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/@babel/parser": {
|
||||||
|
"version": "7.24.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.24.7.tgz",
|
||||||
|
"integrity": "sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw==",
|
||||||
|
"peer": true,
|
||||||
|
"bin": {
|
||||||
|
"parser": "bin/babel-parser.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/sourcemap-codec": {
|
||||||
|
"version": "1.4.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
|
||||||
|
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
|
"node_modules/@vue/compiler-core": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-skOiodXWTV3DxfDhB4rOf3OGalpITLlgCeOwb+Y9GJpfQ8ErigdBUHomBzvG78JoVE8MJoQsb+qhZiHfKeNeEg==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/parser": "^7.24.7",
|
||||||
|
"@vue/shared": "3.4.31",
|
||||||
|
"entities": "^4.5.0",
|
||||||
|
"estree-walker": "^2.0.2",
|
||||||
|
"source-map-js": "^1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vue/compiler-dom": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-wK424WMXsG1IGMyDGyLqB+TbmEBFM78hIsOJ9QwUVLGrcSk0ak6zYty7Pj8ftm7nEtdU/DGQxAXp0/lM/2cEpQ==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/compiler-core": "3.4.31",
|
||||||
|
"@vue/shared": "3.4.31"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vue/compiler-sfc": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-einJxqEw8IIJxzmnxmJBuK2usI+lJonl53foq+9etB2HAzlPjAS/wa7r0uUpXw5ByX3/0uswVSrjNb17vJm1kQ==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/parser": "^7.24.7",
|
||||||
|
"@vue/compiler-core": "3.4.31",
|
||||||
|
"@vue/compiler-dom": "3.4.31",
|
||||||
|
"@vue/compiler-ssr": "3.4.31",
|
||||||
|
"@vue/shared": "3.4.31",
|
||||||
|
"estree-walker": "^2.0.2",
|
||||||
|
"magic-string": "^0.30.10",
|
||||||
|
"postcss": "^8.4.38",
|
||||||
|
"source-map-js": "^1.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vue/compiler-ssr": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-RtefmITAje3fJ8FSg1gwgDhdKhZVntIVbwupdyZDSifZTRMiWxWehAOTCc8/KZDnBOcYQ4/9VWxsTbd3wT0hAA==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/compiler-dom": "3.4.31",
|
||||||
|
"@vue/shared": "3.4.31"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vue/devtools-api": {
|
||||||
|
"version": "6.6.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.3.tgz",
|
||||||
|
"integrity": "sha512-0MiMsFma/HqA6g3KLKn+AGpL1kgKhFWszC9U29NfpWK5LE7bjeXxySWJrOJ77hBz+TBrBQ7o4QJqbPbqbs8rJw==",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
|
"node_modules/@vue/reactivity": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-VGkTani8SOoVkZNds1PfJ/T1SlAIOf8E58PGAhIOUDYPC4GAmFA2u/E14TDAFcf3vVDKunc4QqCe/SHr8xC65Q==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/shared": "3.4.31"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vue/runtime-core": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-LDkztxeUPazxG/p8c5JDDKPfkCDBkkiNLVNf7XZIUnJ+66GVGkP+TIh34+8LtPisZ+HMWl2zqhIw0xN5MwU1cw==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/reactivity": "3.4.31",
|
||||||
|
"@vue/shared": "3.4.31"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vue/runtime-dom": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-2Auws3mB7+lHhTFCg8E9ZWopA6Q6L455EcU7bzcQ4x6Dn4cCPuqj6S2oBZgN2a8vJRS/LSYYxwFFq2Hlx3Fsaw==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/reactivity": "3.4.31",
|
||||||
|
"@vue/runtime-core": "3.4.31",
|
||||||
|
"@vue/shared": "3.4.31",
|
||||||
|
"csstype": "^3.1.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vue/server-renderer": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-D5BLbdvrlR9PE3by9GaUp1gQXlCNadIZytMIb8H2h3FMWJd4oUfkUTEH2wAr3qxoRz25uxbTcbqd3WKlm9EHQA==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/compiler-ssr": "3.4.31",
|
||||||
|
"@vue/shared": "3.4.31"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"vue": "3.4.31"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@vue/shared": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-Yp3wtJk//8cO4NItOPpi3QkLExAr/aLBGZMmTtW9WpdwBCJpRM6zj9WgWktXAl8IDIozwNMByT45JP3tO3ACWA==",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
|
"node_modules/csstype": {
|
||||||
|
"version": "3.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
|
||||||
|
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
|
"node_modules/deepmerge": {
|
||||||
|
"version": "4.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
|
||||||
|
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/entities": {
|
||||||
|
"version": "4.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
|
||||||
|
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
|
||||||
|
"peer": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/estree-walker": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
|
"node_modules/magic-string": {
|
||||||
|
"version": "0.30.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.10.tgz",
|
||||||
|
"integrity": "sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/sourcemap-codec": "^1.4.15"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/nanoid": {
|
||||||
|
"version": "3.3.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz",
|
||||||
|
"integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/ai"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"peer": true,
|
||||||
|
"bin": {
|
||||||
|
"nanoid": "bin/nanoid.cjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/picocolors": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
|
"node_modules/postcss": {
|
||||||
|
"version": "8.4.39",
|
||||||
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.39.tgz",
|
||||||
|
"integrity": "sha512-0vzE+lAiG7hZl1/9I8yzKLx3aR9Xbof3fBHKunvMfOCYAtMhrsnccJY2iTURb9EZd5+pLuiNV9/c/GZJOHsgIw==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/postcss/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "tidelift",
|
||||||
|
"url": "https://tidelift.com/funding/github/npm/postcss"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/ai"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"nanoid": "^3.3.7",
|
||||||
|
"picocolors": "^1.0.1",
|
||||||
|
"source-map-js": "^1.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^10 || ^12 || >=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/shvl": {
|
||||||
|
"version": "2.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/shvl/-/shvl-2.0.3.tgz",
|
||||||
|
"integrity": "sha512-V7C6S9Hlol6SzOJPnQ7qzOVEWUQImt3BNmmzh40wObhla3XOYMe4gGiYzLrJd5TFa+cI2f9LKIRJTTKZSTbWgw==",
|
||||||
|
"deprecated": "older versions vulnerable to prototype pollution"
|
||||||
|
},
|
||||||
|
"node_modules/source-map-js": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
|
||||||
|
"peer": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/vue": {
|
||||||
|
"version": "3.4.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue/-/vue-3.4.31.tgz",
|
||||||
|
"integrity": "sha512-njqRrOy7W3YLAlVqSKpBebtZpDVg21FPoaq1I7f/+qqBThK9ChAIjkRWgeP6Eat+8C+iia4P3OYqpATP21BCoQ==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/compiler-dom": "3.4.31",
|
||||||
|
"@vue/compiler-sfc": "3.4.31",
|
||||||
|
"@vue/runtime-dom": "3.4.31",
|
||||||
|
"@vue/server-renderer": "3.4.31",
|
||||||
|
"@vue/shared": "3.4.31"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"typescript": "*"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"typescript": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/vuex": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/vuex/-/vuex-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-hmV6UerDrPcgbSy9ORAtNXDr9M4wlNP4pEFKye4ujJF8oqgFFuxDCdOLS3eNoRTtq5O3hoBDh9Doj1bQMYHRbQ==",
|
||||||
|
"peer": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/devtools-api": "^6.0.0-beta.11"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"vue": "^3.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/vuex-persistedstate": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/vuex-persistedstate/-/vuex-persistedstate-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-3SkEj4NqwM69ikJdFVw6gObeB0NHyspRYMYkR/EbhR0hbvAKyR5gksVhtAfY1UYuWUOCCA0QNGwv9pOwdj+XUQ==",
|
||||||
|
"deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
|
||||||
|
"dependencies": {
|
||||||
|
"deepmerge": "^4.2.2",
|
||||||
|
"shvl": "^2.0.3"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"vuex": "^3.0 || ^4.0.0-rc"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright (C) 2012-2014 by various contributors (see AUTHORS)
|
||||||
|
|
||||||
|
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,19 @@
|
||||||
|
# @babel/parser
|
||||||
|
|
||||||
|
> A JavaScript parser
|
||||||
|
|
||||||
|
See our website [@babel/parser](https://babeljs.io/docs/babel-parser) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20parser%22+is%3Aopen) associated with this package.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Using npm:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install --save-dev @babel/parser
|
||||||
|
```
|
||||||
|
|
||||||
|
or using yarn:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn add @babel/parser --dev
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
/* eslint no-var: 0 */
|
||||||
|
|
||||||
|
var parser = require("..");
|
||||||
|
var fs = require("fs");
|
||||||
|
|
||||||
|
var filename = process.argv[2];
|
||||||
|
if (!filename) {
|
||||||
|
console.error("no filename specified");
|
||||||
|
} else {
|
||||||
|
var file = fs.readFileSync(filename, "utf8");
|
||||||
|
var ast = parser.parse(file);
|
||||||
|
|
||||||
|
console.log(JSON.stringify(ast, null, " "));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
try {
|
||||||
|
module.exports = require("./lib/index.cjs");
|
||||||
|
} catch {
|
||||||
|
module.exports = require("./lib/index.js");
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
"name": "@babel/parser",
|
||||||
|
"version": "7.24.7",
|
||||||
|
"description": "A JavaScript parser",
|
||||||
|
"author": "The Babel Team (https://babel.dev/team)",
|
||||||
|
"homepage": "https://babel.dev/docs/en/next/babel-parser",
|
||||||
|
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A+parser+%28babylon%29%22+is%3Aopen",
|
||||||
|
"license": "MIT",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"babel",
|
||||||
|
"javascript",
|
||||||
|
"parser",
|
||||||
|
"tc39",
|
||||||
|
"ecmascript",
|
||||||
|
"@babel/parser"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/babel/babel.git",
|
||||||
|
"directory": "packages/babel-parser"
|
||||||
|
},
|
||||||
|
"main": "./lib/index.js",
|
||||||
|
"types": "./typings/babel-parser.d.ts",
|
||||||
|
"files": [
|
||||||
|
"bin",
|
||||||
|
"lib",
|
||||||
|
"typings/babel-parser.d.ts",
|
||||||
|
"index.cjs"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/code-frame": "^7.24.7",
|
||||||
|
"@babel/helper-check-duplicate-nodes": "^7.24.7",
|
||||||
|
"@babel/helper-fixtures": "^7.24.7",
|
||||||
|
"@babel/helper-string-parser": "^7.24.7",
|
||||||
|
"@babel/helper-validator-identifier": "^7.24.7",
|
||||||
|
"@babel/types": "^7.24.7",
|
||||||
|
"charcodes": "^0.2.0"
|
||||||
|
},
|
||||||
|
"bin": "./bin/babel-parser.js",
|
||||||
|
"type": "commonjs"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,251 @@
|
||||||
|
// This file is auto-generated! Do not modify it directly.
|
||||||
|
/* eslint-disable @typescript-eslint/consistent-type-imports, prettier/prettier */
|
||||||
|
import * as _babel_types from '@babel/types';
|
||||||
|
|
||||||
|
type Plugin =
|
||||||
|
| "asyncDoExpressions"
|
||||||
|
| "asyncGenerators"
|
||||||
|
| "bigInt"
|
||||||
|
| "classPrivateMethods"
|
||||||
|
| "classPrivateProperties"
|
||||||
|
| "classProperties"
|
||||||
|
| "classStaticBlock" // Enabled by default
|
||||||
|
| "decimal"
|
||||||
|
| "decorators-legacy"
|
||||||
|
| "deferredImportEvaluation"
|
||||||
|
| "decoratorAutoAccessors"
|
||||||
|
| "destructuringPrivate"
|
||||||
|
| "doExpressions"
|
||||||
|
| "dynamicImport"
|
||||||
|
| "explicitResourceManagement"
|
||||||
|
| "exportDefaultFrom"
|
||||||
|
| "exportNamespaceFrom" // deprecated
|
||||||
|
| "flow"
|
||||||
|
| "flowComments"
|
||||||
|
| "functionBind"
|
||||||
|
| "functionSent"
|
||||||
|
| "importMeta"
|
||||||
|
| "jsx"
|
||||||
|
| "logicalAssignment"
|
||||||
|
| "importAssertions" // deprecated
|
||||||
|
| "importAttributes"
|
||||||
|
| "importReflection"
|
||||||
|
| "moduleBlocks"
|
||||||
|
| "moduleStringNames"
|
||||||
|
| "nullishCoalescingOperator"
|
||||||
|
| "numericSeparator"
|
||||||
|
| "objectRestSpread"
|
||||||
|
| "optionalCatchBinding"
|
||||||
|
| "optionalChaining"
|
||||||
|
| "partialApplication"
|
||||||
|
| "placeholders"
|
||||||
|
| "privateIn" // Enabled by default
|
||||||
|
| "regexpUnicodeSets" // Enabled by default
|
||||||
|
| "sourcePhaseImports"
|
||||||
|
| "throwExpressions"
|
||||||
|
| "topLevelAwait"
|
||||||
|
| "v8intrinsic"
|
||||||
|
| ParserPluginWithOptions[0];
|
||||||
|
|
||||||
|
type ParserPluginWithOptions =
|
||||||
|
| ["decorators", DecoratorsPluginOptions]
|
||||||
|
| ["estree", { classFeatures?: boolean }]
|
||||||
|
| ["importAttributes", { deprecatedAssertSyntax: boolean }]
|
||||||
|
// @deprecated
|
||||||
|
| ["moduleAttributes", { version: "may-2020" }]
|
||||||
|
| ["optionalChainingAssign", { version: "2023-07" }]
|
||||||
|
| ["pipelineOperator", PipelineOperatorPluginOptions]
|
||||||
|
| ["recordAndTuple", RecordAndTuplePluginOptions]
|
||||||
|
| ["flow", FlowPluginOptions]
|
||||||
|
| ["typescript", TypeScriptPluginOptions];
|
||||||
|
|
||||||
|
type PluginConfig = Plugin | ParserPluginWithOptions;
|
||||||
|
|
||||||
|
interface DecoratorsPluginOptions {
|
||||||
|
decoratorsBeforeExport?: boolean;
|
||||||
|
allowCallParenthesized?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PipelineOperatorPluginOptions {
|
||||||
|
proposal: "minimal" | "fsharp" | "hack" | "smart";
|
||||||
|
topicToken?: "%" | "#" | "@@" | "^^" | "^";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RecordAndTuplePluginOptions {
|
||||||
|
syntaxType: "bar" | "hash";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FlowPluginOptions {
|
||||||
|
all?: boolean;
|
||||||
|
enums?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TypeScriptPluginOptions {
|
||||||
|
dts?: boolean;
|
||||||
|
disallowAmbiguousJSXLike?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type definitions for @babel/parser
|
||||||
|
// Project: https://github.com/babel/babel/tree/main/packages/babel-parser
|
||||||
|
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||||
|
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||||
|
// Avi Vahl <https://github.com/AviVahl>
|
||||||
|
// TypeScript Version: 2.9
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the provided code as an entire ECMAScript program.
|
||||||
|
*/
|
||||||
|
declare function parse(
|
||||||
|
input: string,
|
||||||
|
options?: ParserOptions
|
||||||
|
): ParseResult<_babel_types.File>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the provided code as a single expression.
|
||||||
|
*/
|
||||||
|
declare function parseExpression(
|
||||||
|
input: string,
|
||||||
|
options?: ParserOptions
|
||||||
|
): ParseResult<_babel_types.Expression>;
|
||||||
|
|
||||||
|
interface ParserOptions {
|
||||||
|
/**
|
||||||
|
* By default, import and export declarations can only appear at a program's top level.
|
||||||
|
* Setting this option to true allows them anywhere where a statement is allowed.
|
||||||
|
*/
|
||||||
|
allowImportExportEverywhere?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, await use is not allowed outside of an async function.
|
||||||
|
* Set this to true to accept such code.
|
||||||
|
*/
|
||||||
|
allowAwaitOutsideFunction?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, a return statement at the top level raises an error.
|
||||||
|
* Set this to true to accept such code.
|
||||||
|
*/
|
||||||
|
allowReturnOutsideFunction?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, new.target use is not allowed outside of a function or class.
|
||||||
|
* Set this to true to accept such code.
|
||||||
|
*/
|
||||||
|
allowNewTargetOutsideFunction?: boolean;
|
||||||
|
|
||||||
|
allowSuperOutsideMethod?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, exported identifiers must refer to a declared variable.
|
||||||
|
* Set this to true to allow export statements to reference undeclared variables.
|
||||||
|
*/
|
||||||
|
allowUndeclaredExports?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, Babel parser JavaScript code according to Annex B syntax.
|
||||||
|
* Set this to `false` to disable such behavior.
|
||||||
|
*/
|
||||||
|
annexB?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, Babel attaches comments to adjacent AST nodes.
|
||||||
|
* When this option is set to false, comments are not attached.
|
||||||
|
* It can provide up to 30% performance improvement when the input code has many comments.
|
||||||
|
* @babel/eslint-parser will set it for you.
|
||||||
|
* It is not recommended to use attachComment: false with Babel transform,
|
||||||
|
* as doing so removes all the comments in output code, and renders annotations such as
|
||||||
|
* /* istanbul ignore next *\/ nonfunctional.
|
||||||
|
*/
|
||||||
|
attachComment?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, Babel always throws an error when it finds some invalid code.
|
||||||
|
* When this option is set to true, it will store the parsing error and
|
||||||
|
* try to continue parsing the invalid input file.
|
||||||
|
*/
|
||||||
|
errorRecovery?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate the mode the code should be parsed in.
|
||||||
|
* Can be one of "script", "module", or "unambiguous". Defaults to "script".
|
||||||
|
* "unambiguous" will make @babel/parser attempt to guess, based on the presence
|
||||||
|
* of ES6 import or export statements.
|
||||||
|
* Files with ES6 imports and exports are considered "module" and are otherwise "script".
|
||||||
|
*/
|
||||||
|
sourceType?: "script" | "module" | "unambiguous";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Correlate output AST nodes with their source filename.
|
||||||
|
* Useful when generating code and source maps from the ASTs of multiple input files.
|
||||||
|
*/
|
||||||
|
sourceFilename?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, the first line of code parsed is treated as line 1.
|
||||||
|
* You can provide a line number to alternatively start with.
|
||||||
|
* Useful for integration with other source tools.
|
||||||
|
*/
|
||||||
|
startLine?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, the parsed code is treated as if it starts from line 1, column 0.
|
||||||
|
* You can provide a column number to alternatively start with.
|
||||||
|
* Useful for integration with other source tools.
|
||||||
|
*/
|
||||||
|
startColumn?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array containing the plugins that you want to enable.
|
||||||
|
*/
|
||||||
|
plugins?: ParserPlugin[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the parser work in strict mode.
|
||||||
|
* Defaults to true if sourceType === 'module'. Otherwise, false.
|
||||||
|
*/
|
||||||
|
strictMode?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a ranges property to each node: [node.start, node.end]
|
||||||
|
*/
|
||||||
|
ranges?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds all parsed tokens to a tokens property on the File node.
|
||||||
|
*/
|
||||||
|
tokens?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, the parser adds information about parentheses by setting
|
||||||
|
* `extra.parenthesized` to `true` as needed.
|
||||||
|
* When this option is `true` the parser creates `ParenthesizedExpression`
|
||||||
|
* AST nodes instead of using the `extra` property.
|
||||||
|
*/
|
||||||
|
createParenthesizedExpressions?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default is false in Babel 7 and true in Babel 8
|
||||||
|
* Set this to true to parse it as an `ImportExpression` node.
|
||||||
|
* Otherwise `import(foo)` is parsed as `CallExpression(Import, [Identifier(foo)])`.
|
||||||
|
*/
|
||||||
|
createImportExpressions?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ParserPlugin = PluginConfig;
|
||||||
|
|
||||||
|
|
||||||
|
declare const tokTypes: {
|
||||||
|
// todo(flow->ts) real token type
|
||||||
|
[name: string]: any;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface ParseError {
|
||||||
|
code: string;
|
||||||
|
reasonCode: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ParseResult<Result> = Result & {
|
||||||
|
errors: ParseError[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParseResult, ParserOptions, ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse, parseExpression, tokTypes };
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2015 Rich Harris
|
||||||
|
|
||||||
|
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,200 @@
|
||||||
|
# @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Encode/decode the `mappings` property of a [sourcemap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit).
|
||||||
|
|
||||||
|
|
||||||
|
## Why?
|
||||||
|
|
||||||
|
Sourcemaps are difficult to generate and manipulate, because the `mappings` property – the part that actually links the generated code back to the original source – is encoded using an obscure method called [Variable-length quantity](https://en.wikipedia.org/wiki/Variable-length_quantity). On top of that, each segment in the mapping contains offsets rather than absolute indices, which means that you can't look at a segment in isolation – you have to understand the whole sourcemap.
|
||||||
|
|
||||||
|
This package makes the process slightly easier.
|
||||||
|
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @jridgewell/sourcemap-codec
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { encode, decode } from '@jridgewell/sourcemap-codec';
|
||||||
|
|
||||||
|
var decoded = decode( ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' );
|
||||||
|
|
||||||
|
assert.deepEqual( decoded, [
|
||||||
|
// the first line (of the generated code) has no mappings,
|
||||||
|
// as shown by the starting semi-colon (which separates lines)
|
||||||
|
[],
|
||||||
|
|
||||||
|
// the second line contains four (comma-separated) segments
|
||||||
|
[
|
||||||
|
// segments are encoded as you'd expect:
|
||||||
|
// [ generatedCodeColumn, sourceIndex, sourceCodeLine, sourceCodeColumn, nameIndex ]
|
||||||
|
|
||||||
|
// i.e. the first segment begins at column 2, and maps back to the second column
|
||||||
|
// of the second line (both zero-based) of the 0th source, and uses the 0th
|
||||||
|
// name in the `map.names` array
|
||||||
|
[ 2, 0, 2, 2, 0 ],
|
||||||
|
|
||||||
|
// the remaining segments are 4-length rather than 5-length,
|
||||||
|
// because they don't map a name
|
||||||
|
[ 4, 0, 2, 4 ],
|
||||||
|
[ 6, 0, 2, 5 ],
|
||||||
|
[ 7, 0, 2, 7 ]
|
||||||
|
],
|
||||||
|
|
||||||
|
// the final line contains two segments
|
||||||
|
[
|
||||||
|
[ 2, 1, 10, 19 ],
|
||||||
|
[ 12, 1, 11, 20 ]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
var encoded = encode( decoded );
|
||||||
|
assert.equal( encoded, ';EAEEA,EAAE,EAAC,CAAE;ECQY,UACC' );
|
||||||
|
```
|
||||||
|
|
||||||
|
## Benchmarks
|
||||||
|
|
||||||
|
```
|
||||||
|
node v18.0.0
|
||||||
|
|
||||||
|
amp.js.map - 45120 segments
|
||||||
|
|
||||||
|
Decode Memory Usage:
|
||||||
|
@jridgewell/sourcemap-codec 5479160 bytes
|
||||||
|
sourcemap-codec 5659336 bytes
|
||||||
|
source-map-0.6.1 17144440 bytes
|
||||||
|
source-map-0.8.0 6867424 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Decode speed:
|
||||||
|
decode: @jridgewell/sourcemap-codec x 502 ops/sec ±1.03% (90 runs sampled)
|
||||||
|
decode: sourcemap-codec x 445 ops/sec ±0.97% (92 runs sampled)
|
||||||
|
decode: source-map-0.6.1 x 36.01 ops/sec ±1.64% (49 runs sampled)
|
||||||
|
decode: source-map-0.8.0 x 367 ops/sec ±0.04% (95 runs sampled)
|
||||||
|
Fastest is decode: @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Encode Memory Usage:
|
||||||
|
@jridgewell/sourcemap-codec 1261620 bytes
|
||||||
|
sourcemap-codec 9119248 bytes
|
||||||
|
source-map-0.6.1 8968560 bytes
|
||||||
|
source-map-0.8.0 8952952 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Encode speed:
|
||||||
|
encode: @jridgewell/sourcemap-codec x 738 ops/sec ±0.42% (98 runs sampled)
|
||||||
|
encode: sourcemap-codec x 238 ops/sec ±0.73% (88 runs sampled)
|
||||||
|
encode: source-map-0.6.1 x 162 ops/sec ±0.43% (84 runs sampled)
|
||||||
|
encode: source-map-0.8.0 x 191 ops/sec ±0.34% (90 runs sampled)
|
||||||
|
Fastest is encode: @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
babel.min.js.map - 347793 segments
|
||||||
|
|
||||||
|
Decode Memory Usage:
|
||||||
|
@jridgewell/sourcemap-codec 35338184 bytes
|
||||||
|
sourcemap-codec 35922736 bytes
|
||||||
|
source-map-0.6.1 62366360 bytes
|
||||||
|
source-map-0.8.0 44337416 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Decode speed:
|
||||||
|
decode: @jridgewell/sourcemap-codec x 40.35 ops/sec ±4.47% (54 runs sampled)
|
||||||
|
decode: sourcemap-codec x 36.76 ops/sec ±3.67% (51 runs sampled)
|
||||||
|
decode: source-map-0.6.1 x 4.44 ops/sec ±2.15% (16 runs sampled)
|
||||||
|
decode: source-map-0.8.0 x 59.35 ops/sec ±0.05% (78 runs sampled)
|
||||||
|
Fastest is decode: source-map-0.8.0
|
||||||
|
|
||||||
|
Encode Memory Usage:
|
||||||
|
@jridgewell/sourcemap-codec 7212604 bytes
|
||||||
|
sourcemap-codec 21421456 bytes
|
||||||
|
source-map-0.6.1 25286888 bytes
|
||||||
|
source-map-0.8.0 25498744 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Encode speed:
|
||||||
|
encode: @jridgewell/sourcemap-codec x 112 ops/sec ±0.13% (84 runs sampled)
|
||||||
|
encode: sourcemap-codec x 30.23 ops/sec ±2.76% (53 runs sampled)
|
||||||
|
encode: source-map-0.6.1 x 19.43 ops/sec ±3.70% (37 runs sampled)
|
||||||
|
encode: source-map-0.8.0 x 19.40 ops/sec ±3.26% (37 runs sampled)
|
||||||
|
Fastest is encode: @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
preact.js.map - 1992 segments
|
||||||
|
|
||||||
|
Decode Memory Usage:
|
||||||
|
@jridgewell/sourcemap-codec 500272 bytes
|
||||||
|
sourcemap-codec 516864 bytes
|
||||||
|
source-map-0.6.1 1596672 bytes
|
||||||
|
source-map-0.8.0 517272 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Decode speed:
|
||||||
|
decode: @jridgewell/sourcemap-codec x 16,137 ops/sec ±0.17% (99 runs sampled)
|
||||||
|
decode: sourcemap-codec x 12,139 ops/sec ±0.13% (99 runs sampled)
|
||||||
|
decode: source-map-0.6.1 x 1,264 ops/sec ±0.12% (100 runs sampled)
|
||||||
|
decode: source-map-0.8.0 x 9,894 ops/sec ±0.08% (101 runs sampled)
|
||||||
|
Fastest is decode: @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Encode Memory Usage:
|
||||||
|
@jridgewell/sourcemap-codec 321026 bytes
|
||||||
|
sourcemap-codec 830832 bytes
|
||||||
|
source-map-0.6.1 586608 bytes
|
||||||
|
source-map-0.8.0 586680 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Encode speed:
|
||||||
|
encode: @jridgewell/sourcemap-codec x 19,876 ops/sec ±0.78% (95 runs sampled)
|
||||||
|
encode: sourcemap-codec x 6,983 ops/sec ±0.15% (100 runs sampled)
|
||||||
|
encode: source-map-0.6.1 x 5,070 ops/sec ±0.12% (102 runs sampled)
|
||||||
|
encode: source-map-0.8.0 x 5,641 ops/sec ±0.17% (100 runs sampled)
|
||||||
|
Fastest is encode: @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
|
||||||
|
react.js.map - 5726 segments
|
||||||
|
|
||||||
|
Decode Memory Usage:
|
||||||
|
@jridgewell/sourcemap-codec 734848 bytes
|
||||||
|
sourcemap-codec 954200 bytes
|
||||||
|
source-map-0.6.1 2276432 bytes
|
||||||
|
source-map-0.8.0 955488 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Decode speed:
|
||||||
|
decode: @jridgewell/sourcemap-codec x 5,723 ops/sec ±0.12% (98 runs sampled)
|
||||||
|
decode: sourcemap-codec x 4,555 ops/sec ±0.09% (101 runs sampled)
|
||||||
|
decode: source-map-0.6.1 x 437 ops/sec ±0.11% (93 runs sampled)
|
||||||
|
decode: source-map-0.8.0 x 3,441 ops/sec ±0.15% (100 runs sampled)
|
||||||
|
Fastest is decode: @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Encode Memory Usage:
|
||||||
|
@jridgewell/sourcemap-codec 638672 bytes
|
||||||
|
sourcemap-codec 1109840 bytes
|
||||||
|
source-map-0.6.1 1321224 bytes
|
||||||
|
source-map-0.8.0 1324448 bytes
|
||||||
|
Smallest memory usage is @jridgewell/sourcemap-codec
|
||||||
|
|
||||||
|
Encode speed:
|
||||||
|
encode: @jridgewell/sourcemap-codec x 6,801 ops/sec ±0.48% (98 runs sampled)
|
||||||
|
encode: sourcemap-codec x 2,533 ops/sec ±0.13% (101 runs sampled)
|
||||||
|
encode: source-map-0.6.1 x 2,248 ops/sec ±0.08% (100 runs sampled)
|
||||||
|
encode: source-map-0.8.0 x 2,303 ops/sec ±0.15% (100 runs sampled)
|
||||||
|
Fastest is encode: @jridgewell/sourcemap-codec
|
||||||
|
```
|
||||||
|
|
||||||
|
# License
|
||||||
|
|
||||||
|
MIT
|
||||||
164
node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
generated
vendored
Normal file
164
node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,164 @@
|
||||||
|
const comma = ','.charCodeAt(0);
|
||||||
|
const semicolon = ';'.charCodeAt(0);
|
||||||
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||||
|
const intToChar = new Uint8Array(64); // 64 possible chars.
|
||||||
|
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
||||||
|
for (let i = 0; i < chars.length; i++) {
|
||||||
|
const c = chars.charCodeAt(i);
|
||||||
|
intToChar[i] = c;
|
||||||
|
charToInt[c] = i;
|
||||||
|
}
|
||||||
|
// Provide a fallback for older environments.
|
||||||
|
const td = typeof TextDecoder !== 'undefined'
|
||||||
|
? /* #__PURE__ */ new TextDecoder()
|
||||||
|
: typeof Buffer !== 'undefined'
|
||||||
|
? {
|
||||||
|
decode(buf) {
|
||||||
|
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
||||||
|
return out.toString();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
decode(buf) {
|
||||||
|
let out = '';
|
||||||
|
for (let i = 0; i < buf.length; i++) {
|
||||||
|
out += String.fromCharCode(buf[i]);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
function decode(mappings) {
|
||||||
|
const state = new Int32Array(5);
|
||||||
|
const decoded = [];
|
||||||
|
let index = 0;
|
||||||
|
do {
|
||||||
|
const semi = indexOf(mappings, index);
|
||||||
|
const line = [];
|
||||||
|
let sorted = true;
|
||||||
|
let lastCol = 0;
|
||||||
|
state[0] = 0;
|
||||||
|
for (let i = index; i < semi; i++) {
|
||||||
|
let seg;
|
||||||
|
i = decodeInteger(mappings, i, state, 0); // genColumn
|
||||||
|
const col = state[0];
|
||||||
|
if (col < lastCol)
|
||||||
|
sorted = false;
|
||||||
|
lastCol = col;
|
||||||
|
if (hasMoreVlq(mappings, i, semi)) {
|
||||||
|
i = decodeInteger(mappings, i, state, 1); // sourcesIndex
|
||||||
|
i = decodeInteger(mappings, i, state, 2); // sourceLine
|
||||||
|
i = decodeInteger(mappings, i, state, 3); // sourceColumn
|
||||||
|
if (hasMoreVlq(mappings, i, semi)) {
|
||||||
|
i = decodeInteger(mappings, i, state, 4); // namesIndex
|
||||||
|
seg = [col, state[1], state[2], state[3], state[4]];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
seg = [col, state[1], state[2], state[3]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
seg = [col];
|
||||||
|
}
|
||||||
|
line.push(seg);
|
||||||
|
}
|
||||||
|
if (!sorted)
|
||||||
|
sort(line);
|
||||||
|
decoded.push(line);
|
||||||
|
index = semi + 1;
|
||||||
|
} while (index <= mappings.length);
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
function indexOf(mappings, index) {
|
||||||
|
const idx = mappings.indexOf(';', index);
|
||||||
|
return idx === -1 ? mappings.length : idx;
|
||||||
|
}
|
||||||
|
function decodeInteger(mappings, pos, state, j) {
|
||||||
|
let value = 0;
|
||||||
|
let shift = 0;
|
||||||
|
let integer = 0;
|
||||||
|
do {
|
||||||
|
const c = mappings.charCodeAt(pos++);
|
||||||
|
integer = charToInt[c];
|
||||||
|
value |= (integer & 31) << shift;
|
||||||
|
shift += 5;
|
||||||
|
} while (integer & 32);
|
||||||
|
const shouldNegate = value & 1;
|
||||||
|
value >>>= 1;
|
||||||
|
if (shouldNegate) {
|
||||||
|
value = -0x80000000 | -value;
|
||||||
|
}
|
||||||
|
state[j] += value;
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
function hasMoreVlq(mappings, i, length) {
|
||||||
|
if (i >= length)
|
||||||
|
return false;
|
||||||
|
return mappings.charCodeAt(i) !== comma;
|
||||||
|
}
|
||||||
|
function sort(line) {
|
||||||
|
line.sort(sortComparator);
|
||||||
|
}
|
||||||
|
function sortComparator(a, b) {
|
||||||
|
return a[0] - b[0];
|
||||||
|
}
|
||||||
|
function encode(decoded) {
|
||||||
|
const state = new Int32Array(5);
|
||||||
|
const bufLength = 1024 * 16;
|
||||||
|
const subLength = bufLength - 36;
|
||||||
|
const buf = new Uint8Array(bufLength);
|
||||||
|
const sub = buf.subarray(0, subLength);
|
||||||
|
let pos = 0;
|
||||||
|
let out = '';
|
||||||
|
for (let i = 0; i < decoded.length; i++) {
|
||||||
|
const line = decoded[i];
|
||||||
|
if (i > 0) {
|
||||||
|
if (pos === bufLength) {
|
||||||
|
out += td.decode(buf);
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
buf[pos++] = semicolon;
|
||||||
|
}
|
||||||
|
if (line.length === 0)
|
||||||
|
continue;
|
||||||
|
state[0] = 0;
|
||||||
|
for (let j = 0; j < line.length; j++) {
|
||||||
|
const segment = line[j];
|
||||||
|
// We can push up to 5 ints, each int can take at most 7 chars, and we
|
||||||
|
// may push a comma.
|
||||||
|
if (pos > subLength) {
|
||||||
|
out += td.decode(sub);
|
||||||
|
buf.copyWithin(0, subLength, pos);
|
||||||
|
pos -= subLength;
|
||||||
|
}
|
||||||
|
if (j > 0)
|
||||||
|
buf[pos++] = comma;
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
|
||||||
|
if (segment.length === 1)
|
||||||
|
continue;
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
|
||||||
|
if (segment.length === 4)
|
||||||
|
continue;
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out + td.decode(buf.subarray(0, pos));
|
||||||
|
}
|
||||||
|
function encodeInteger(buf, pos, state, segment, j) {
|
||||||
|
const next = segment[j];
|
||||||
|
let num = next - state[j];
|
||||||
|
state[j] = next;
|
||||||
|
num = num < 0 ? (-num << 1) | 1 : num << 1;
|
||||||
|
do {
|
||||||
|
let clamped = num & 0b011111;
|
||||||
|
num >>>= 5;
|
||||||
|
if (num > 0)
|
||||||
|
clamped |= 0b100000;
|
||||||
|
buf[pos++] = intToChar[clamped];
|
||||||
|
} while (num > 0);
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { decode, encode };
|
||||||
|
//# sourceMappingURL=sourcemap-codec.mjs.map
|
||||||
1
node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map
generated
vendored
Normal file
1
node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
175
node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js
generated
vendored
Normal file
175
node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js
generated
vendored
Normal file
|
|
@ -0,0 +1,175 @@
|
||||||
|
(function (global, factory) {
|
||||||
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||||
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||||
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.sourcemapCodec = {}));
|
||||||
|
})(this, (function (exports) { 'use strict';
|
||||||
|
|
||||||
|
const comma = ','.charCodeAt(0);
|
||||||
|
const semicolon = ';'.charCodeAt(0);
|
||||||
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||||
|
const intToChar = new Uint8Array(64); // 64 possible chars.
|
||||||
|
const charToInt = new Uint8Array(128); // z is 122 in ASCII
|
||||||
|
for (let i = 0; i < chars.length; i++) {
|
||||||
|
const c = chars.charCodeAt(i);
|
||||||
|
intToChar[i] = c;
|
||||||
|
charToInt[c] = i;
|
||||||
|
}
|
||||||
|
// Provide a fallback for older environments.
|
||||||
|
const td = typeof TextDecoder !== 'undefined'
|
||||||
|
? /* #__PURE__ */ new TextDecoder()
|
||||||
|
: typeof Buffer !== 'undefined'
|
||||||
|
? {
|
||||||
|
decode(buf) {
|
||||||
|
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
||||||
|
return out.toString();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
decode(buf) {
|
||||||
|
let out = '';
|
||||||
|
for (let i = 0; i < buf.length; i++) {
|
||||||
|
out += String.fromCharCode(buf[i]);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
function decode(mappings) {
|
||||||
|
const state = new Int32Array(5);
|
||||||
|
const decoded = [];
|
||||||
|
let index = 0;
|
||||||
|
do {
|
||||||
|
const semi = indexOf(mappings, index);
|
||||||
|
const line = [];
|
||||||
|
let sorted = true;
|
||||||
|
let lastCol = 0;
|
||||||
|
state[0] = 0;
|
||||||
|
for (let i = index; i < semi; i++) {
|
||||||
|
let seg;
|
||||||
|
i = decodeInteger(mappings, i, state, 0); // genColumn
|
||||||
|
const col = state[0];
|
||||||
|
if (col < lastCol)
|
||||||
|
sorted = false;
|
||||||
|
lastCol = col;
|
||||||
|
if (hasMoreVlq(mappings, i, semi)) {
|
||||||
|
i = decodeInteger(mappings, i, state, 1); // sourcesIndex
|
||||||
|
i = decodeInteger(mappings, i, state, 2); // sourceLine
|
||||||
|
i = decodeInteger(mappings, i, state, 3); // sourceColumn
|
||||||
|
if (hasMoreVlq(mappings, i, semi)) {
|
||||||
|
i = decodeInteger(mappings, i, state, 4); // namesIndex
|
||||||
|
seg = [col, state[1], state[2], state[3], state[4]];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
seg = [col, state[1], state[2], state[3]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
seg = [col];
|
||||||
|
}
|
||||||
|
line.push(seg);
|
||||||
|
}
|
||||||
|
if (!sorted)
|
||||||
|
sort(line);
|
||||||
|
decoded.push(line);
|
||||||
|
index = semi + 1;
|
||||||
|
} while (index <= mappings.length);
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
function indexOf(mappings, index) {
|
||||||
|
const idx = mappings.indexOf(';', index);
|
||||||
|
return idx === -1 ? mappings.length : idx;
|
||||||
|
}
|
||||||
|
function decodeInteger(mappings, pos, state, j) {
|
||||||
|
let value = 0;
|
||||||
|
let shift = 0;
|
||||||
|
let integer = 0;
|
||||||
|
do {
|
||||||
|
const c = mappings.charCodeAt(pos++);
|
||||||
|
integer = charToInt[c];
|
||||||
|
value |= (integer & 31) << shift;
|
||||||
|
shift += 5;
|
||||||
|
} while (integer & 32);
|
||||||
|
const shouldNegate = value & 1;
|
||||||
|
value >>>= 1;
|
||||||
|
if (shouldNegate) {
|
||||||
|
value = -0x80000000 | -value;
|
||||||
|
}
|
||||||
|
state[j] += value;
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
function hasMoreVlq(mappings, i, length) {
|
||||||
|
if (i >= length)
|
||||||
|
return false;
|
||||||
|
return mappings.charCodeAt(i) !== comma;
|
||||||
|
}
|
||||||
|
function sort(line) {
|
||||||
|
line.sort(sortComparator);
|
||||||
|
}
|
||||||
|
function sortComparator(a, b) {
|
||||||
|
return a[0] - b[0];
|
||||||
|
}
|
||||||
|
function encode(decoded) {
|
||||||
|
const state = new Int32Array(5);
|
||||||
|
const bufLength = 1024 * 16;
|
||||||
|
const subLength = bufLength - 36;
|
||||||
|
const buf = new Uint8Array(bufLength);
|
||||||
|
const sub = buf.subarray(0, subLength);
|
||||||
|
let pos = 0;
|
||||||
|
let out = '';
|
||||||
|
for (let i = 0; i < decoded.length; i++) {
|
||||||
|
const line = decoded[i];
|
||||||
|
if (i > 0) {
|
||||||
|
if (pos === bufLength) {
|
||||||
|
out += td.decode(buf);
|
||||||
|
pos = 0;
|
||||||
|
}
|
||||||
|
buf[pos++] = semicolon;
|
||||||
|
}
|
||||||
|
if (line.length === 0)
|
||||||
|
continue;
|
||||||
|
state[0] = 0;
|
||||||
|
for (let j = 0; j < line.length; j++) {
|
||||||
|
const segment = line[j];
|
||||||
|
// We can push up to 5 ints, each int can take at most 7 chars, and we
|
||||||
|
// may push a comma.
|
||||||
|
if (pos > subLength) {
|
||||||
|
out += td.decode(sub);
|
||||||
|
buf.copyWithin(0, subLength, pos);
|
||||||
|
pos -= subLength;
|
||||||
|
}
|
||||||
|
if (j > 0)
|
||||||
|
buf[pos++] = comma;
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 0); // genColumn
|
||||||
|
if (segment.length === 1)
|
||||||
|
continue;
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 1); // sourcesIndex
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 2); // sourceLine
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 3); // sourceColumn
|
||||||
|
if (segment.length === 4)
|
||||||
|
continue;
|
||||||
|
pos = encodeInteger(buf, pos, state, segment, 4); // namesIndex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out + td.decode(buf.subarray(0, pos));
|
||||||
|
}
|
||||||
|
function encodeInteger(buf, pos, state, segment, j) {
|
||||||
|
const next = segment[j];
|
||||||
|
let num = next - state[j];
|
||||||
|
state[j] = next;
|
||||||
|
num = num < 0 ? (-num << 1) | 1 : num << 1;
|
||||||
|
do {
|
||||||
|
let clamped = num & 0b011111;
|
||||||
|
num >>>= 5;
|
||||||
|
if (num > 0)
|
||||||
|
clamped |= 0b100000;
|
||||||
|
buf[pos++] = intToChar[clamped];
|
||||||
|
} while (num > 0);
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.decode = decode;
|
||||||
|
exports.encode = encode;
|
||||||
|
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
}));
|
||||||
|
//# sourceMappingURL=sourcemap-codec.umd.js.map
|
||||||
1
node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map
generated
vendored
Normal file
1
node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts
generated
vendored
Normal file
6
node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
export declare type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number];
|
||||||
|
export declare type SourceMapLine = SourceMapSegment[];
|
||||||
|
export declare type SourceMapMappings = SourceMapLine[];
|
||||||
|
export declare function decode(mappings: string): SourceMapMappings;
|
||||||
|
export declare function encode(decoded: SourceMapMappings): string;
|
||||||
|
export declare function encode(decoded: Readonly<SourceMapMappings>): string;
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
{
|
||||||
|
"name": "@jridgewell/sourcemap-codec",
|
||||||
|
"version": "1.4.15",
|
||||||
|
"description": "Encode/decode sourcemap mappings",
|
||||||
|
"keywords": [
|
||||||
|
"sourcemap",
|
||||||
|
"vlq"
|
||||||
|
],
|
||||||
|
"main": "dist/sourcemap-codec.umd.js",
|
||||||
|
"module": "dist/sourcemap-codec.mjs",
|
||||||
|
"types": "dist/types/sourcemap-codec.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": [
|
||||||
|
{
|
||||||
|
"types": "./dist/types/sourcemap-codec.d.ts",
|
||||||
|
"browser": "./dist/sourcemap-codec.umd.js",
|
||||||
|
"require": "./dist/sourcemap-codec.umd.js",
|
||||||
|
"import": "./dist/sourcemap-codec.mjs"
|
||||||
|
},
|
||||||
|
"./dist/sourcemap-codec.umd.js"
|
||||||
|
],
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"benchmark": "run-s build:rollup benchmark:*",
|
||||||
|
"benchmark:install": "cd benchmark && npm install",
|
||||||
|
"benchmark:only": "node --expose-gc benchmark/index.js",
|
||||||
|
"build": "run-s -n build:*",
|
||||||
|
"build:rollup": "rollup -c rollup.config.js",
|
||||||
|
"build:ts": "tsc --project tsconfig.build.json",
|
||||||
|
"lint": "run-s -n lint:*",
|
||||||
|
"lint:prettier": "npm run test:lint:prettier -- --write",
|
||||||
|
"lint:ts": "npm run test:lint:ts -- --fix",
|
||||||
|
"prebuild": "rm -rf dist",
|
||||||
|
"prepublishOnly": "npm run preversion",
|
||||||
|
"preversion": "run-s test build",
|
||||||
|
"pretest": "run-s build:rollup",
|
||||||
|
"test": "run-s -n test:lint test:only",
|
||||||
|
"test:debug": "mocha --inspect-brk",
|
||||||
|
"test:lint": "run-s -n test:lint:*",
|
||||||
|
"test:lint:prettier": "prettier --check '{src,test}/**/*.ts'",
|
||||||
|
"test:lint:ts": "eslint '{src,test}/**/*.ts'",
|
||||||
|
"test:only": "mocha",
|
||||||
|
"test:coverage": "c8 mocha",
|
||||||
|
"test:watch": "mocha --watch"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/jridgewell/sourcemap-codec.git"
|
||||||
|
},
|
||||||
|
"author": "Rich Harris",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-typescript": "8.3.0",
|
||||||
|
"@types/node": "17.0.15",
|
||||||
|
"@typescript-eslint/eslint-plugin": "5.10.0",
|
||||||
|
"@typescript-eslint/parser": "5.10.0",
|
||||||
|
"benchmark": "2.1.4",
|
||||||
|
"c8": "7.11.2",
|
||||||
|
"eslint": "8.7.0",
|
||||||
|
"eslint-config-prettier": "8.3.0",
|
||||||
|
"mocha": "9.2.0",
|
||||||
|
"npm-run-all": "4.1.5",
|
||||||
|
"prettier": "2.5.1",
|
||||||
|
"rollup": "2.64.0",
|
||||||
|
"source-map": "0.6.1",
|
||||||
|
"source-map-js": "1.0.2",
|
||||||
|
"sourcemap-codec": "1.4.8",
|
||||||
|
"typescript": "4.5.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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/compiler-core
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
5666
node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js
generated
vendored
Normal file
5666
node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
module.exports = require('./dist/compiler-core.cjs.prod.js')
|
||||||
|
} else {
|
||||||
|
module.exports = require('./dist/compiler-core.cjs.js')
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
"name": "@vue/compiler-core",
|
||||||
|
"version": "3.4.31",
|
||||||
|
"description": "@vue/compiler-core",
|
||||||
|
"main": "index.js",
|
||||||
|
"module": "dist/compiler-core.esm-bundler.js",
|
||||||
|
"types": "dist/compiler-core.d.ts",
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/compiler-core.d.ts",
|
||||||
|
"node": {
|
||||||
|
"production": "./dist/compiler-core.cjs.prod.js",
|
||||||
|
"development": "./dist/compiler-core.cjs.js",
|
||||||
|
"default": "./index.js"
|
||||||
|
},
|
||||||
|
"module": "./dist/compiler-core.esm-bundler.js",
|
||||||
|
"import": "./dist/compiler-core.esm-bundler.js",
|
||||||
|
"require": "./index.js"
|
||||||
|
},
|
||||||
|
"./*": "./*"
|
||||||
|
},
|
||||||
|
"buildOptions": {
|
||||||
|
"name": "VueCompilerCore",
|
||||||
|
"compat": true,
|
||||||
|
"formats": [
|
||||||
|
"esm-bundler",
|
||||||
|
"cjs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/vuejs/core.git",
|
||||||
|
"directory": "packages/compiler-core"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
|
"author": "Evan You",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/vuejs/core/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/parser": "^7.24.7",
|
||||||
|
"entities": "^4.5.0",
|
||||||
|
"estree-walker": "^2.0.2",
|
||||||
|
"source-map-js": "^1.2.0",
|
||||||
|
"@vue/shared": "3.4.31"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/types": "^7.24.7"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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/compiler-dom
|
||||||
|
|
@ -0,0 +1,730 @@
|
||||||
|
/**
|
||||||
|
* @vue/compiler-dom v3.4.31
|
||||||
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
||||||
|
* @license MIT
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
var compilerCore = require('@vue/compiler-core');
|
||||||
|
var shared = require('@vue/shared');
|
||||||
|
|
||||||
|
const V_MODEL_RADIO = Symbol(`vModelRadio` );
|
||||||
|
const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
|
||||||
|
const V_MODEL_TEXT = Symbol(`vModelText` );
|
||||||
|
const V_MODEL_SELECT = Symbol(`vModelSelect` );
|
||||||
|
const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
|
||||||
|
const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
|
||||||
|
const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
|
||||||
|
const V_SHOW = Symbol(`vShow` );
|
||||||
|
const TRANSITION = Symbol(`Transition` );
|
||||||
|
const TRANSITION_GROUP = Symbol(`TransitionGroup` );
|
||||||
|
compilerCore.registerRuntimeHelpers({
|
||||||
|
[V_MODEL_RADIO]: `vModelRadio`,
|
||||||
|
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
||||||
|
[V_MODEL_TEXT]: `vModelText`,
|
||||||
|
[V_MODEL_SELECT]: `vModelSelect`,
|
||||||
|
[V_MODEL_DYNAMIC]: `vModelDynamic`,
|
||||||
|
[V_ON_WITH_MODIFIERS]: `withModifiers`,
|
||||||
|
[V_ON_WITH_KEYS]: `withKeys`,
|
||||||
|
[V_SHOW]: `vShow`,
|
||||||
|
[TRANSITION]: `Transition`,
|
||||||
|
[TRANSITION_GROUP]: `TransitionGroup`
|
||||||
|
});
|
||||||
|
|
||||||
|
const parserOptions = {
|
||||||
|
parseMode: "html",
|
||||||
|
isVoidTag: shared.isVoidTag,
|
||||||
|
isNativeTag: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
|
||||||
|
isPreTag: (tag) => tag === "pre",
|
||||||
|
decodeEntities: void 0,
|
||||||
|
isBuiltInComponent: (tag) => {
|
||||||
|
if (tag === "Transition" || tag === "transition") {
|
||||||
|
return TRANSITION;
|
||||||
|
} else if (tag === "TransitionGroup" || tag === "transition-group") {
|
||||||
|
return TRANSITION_GROUP;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
||||||
|
getNamespace(tag, parent, rootNamespace) {
|
||||||
|
let ns = parent ? parent.ns : rootNamespace;
|
||||||
|
if (parent && ns === 2) {
|
||||||
|
if (parent.tag === "annotation-xml") {
|
||||||
|
if (tag === "svg") {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (parent.props.some(
|
||||||
|
(a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
|
||||||
|
)) {
|
||||||
|
ns = 0;
|
||||||
|
}
|
||||||
|
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
|
||||||
|
ns = 0;
|
||||||
|
}
|
||||||
|
} else if (parent && ns === 1) {
|
||||||
|
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
|
||||||
|
ns = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ns === 0) {
|
||||||
|
if (tag === "svg") {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (tag === "math") {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ns;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformStyle = (node) => {
|
||||||
|
if (node.type === 1) {
|
||||||
|
node.props.forEach((p, i) => {
|
||||||
|
if (p.type === 6 && p.name === "style" && p.value) {
|
||||||
|
node.props[i] = {
|
||||||
|
type: 7,
|
||||||
|
name: `bind`,
|
||||||
|
arg: compilerCore.createSimpleExpression(`style`, true, p.loc),
|
||||||
|
exp: parseInlineCSS(p.value.content, p.loc),
|
||||||
|
modifiers: [],
|
||||||
|
loc: p.loc
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const parseInlineCSS = (cssText, loc) => {
|
||||||
|
const normalized = shared.parseStringStyle(cssText);
|
||||||
|
return compilerCore.createSimpleExpression(
|
||||||
|
JSON.stringify(normalized),
|
||||||
|
false,
|
||||||
|
loc,
|
||||||
|
3
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
function createDOMCompilerError(code, loc) {
|
||||||
|
return compilerCore.createCompilerError(
|
||||||
|
code,
|
||||||
|
loc,
|
||||||
|
DOMErrorMessages
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const DOMErrorCodes = {
|
||||||
|
"X_V_HTML_NO_EXPRESSION": 53,
|
||||||
|
"53": "X_V_HTML_NO_EXPRESSION",
|
||||||
|
"X_V_HTML_WITH_CHILDREN": 54,
|
||||||
|
"54": "X_V_HTML_WITH_CHILDREN",
|
||||||
|
"X_V_TEXT_NO_EXPRESSION": 55,
|
||||||
|
"55": "X_V_TEXT_NO_EXPRESSION",
|
||||||
|
"X_V_TEXT_WITH_CHILDREN": 56,
|
||||||
|
"56": "X_V_TEXT_WITH_CHILDREN",
|
||||||
|
"X_V_MODEL_ON_INVALID_ELEMENT": 57,
|
||||||
|
"57": "X_V_MODEL_ON_INVALID_ELEMENT",
|
||||||
|
"X_V_MODEL_ARG_ON_ELEMENT": 58,
|
||||||
|
"58": "X_V_MODEL_ARG_ON_ELEMENT",
|
||||||
|
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
|
||||||
|
"59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
|
||||||
|
"X_V_MODEL_UNNECESSARY_VALUE": 60,
|
||||||
|
"60": "X_V_MODEL_UNNECESSARY_VALUE",
|
||||||
|
"X_V_SHOW_NO_EXPRESSION": 61,
|
||||||
|
"61": "X_V_SHOW_NO_EXPRESSION",
|
||||||
|
"X_TRANSITION_INVALID_CHILDREN": 62,
|
||||||
|
"62": "X_TRANSITION_INVALID_CHILDREN",
|
||||||
|
"X_IGNORED_SIDE_EFFECT_TAG": 63,
|
||||||
|
"63": "X_IGNORED_SIDE_EFFECT_TAG",
|
||||||
|
"__EXTEND_POINT__": 64,
|
||||||
|
"64": "__EXTEND_POINT__"
|
||||||
|
};
|
||||||
|
const DOMErrorMessages = {
|
||||||
|
[53]: `v-html is missing expression.`,
|
||||||
|
[54]: `v-html will override element children.`,
|
||||||
|
[55]: `v-text is missing expression.`,
|
||||||
|
[56]: `v-text will override element children.`,
|
||||||
|
[57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
||||||
|
[58]: `v-model argument is not supported on plain elements.`,
|
||||||
|
[59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
||||||
|
[60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
||||||
|
[61]: `v-show is missing expression.`,
|
||||||
|
[62]: `<Transition> expects exactly one child element or component.`,
|
||||||
|
[63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformVHtml = (dir, node, context) => {
|
||||||
|
const { exp, loc } = dir;
|
||||||
|
if (!exp) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(53, loc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (node.children.length) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(54, loc)
|
||||||
|
);
|
||||||
|
node.children.length = 0;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [
|
||||||
|
compilerCore.createObjectProperty(
|
||||||
|
compilerCore.createSimpleExpression(`innerHTML`, true, loc),
|
||||||
|
exp || compilerCore.createSimpleExpression("", true)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformVText = (dir, node, context) => {
|
||||||
|
const { exp, loc } = dir;
|
||||||
|
if (!exp) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(55, loc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (node.children.length) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(56, loc)
|
||||||
|
);
|
||||||
|
node.children.length = 0;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [
|
||||||
|
compilerCore.createObjectProperty(
|
||||||
|
compilerCore.createSimpleExpression(`textContent`, true),
|
||||||
|
exp ? compilerCore.getConstantType(exp, context) > 0 ? exp : compilerCore.createCallExpression(
|
||||||
|
context.helperString(compilerCore.TO_DISPLAY_STRING),
|
||||||
|
[exp],
|
||||||
|
loc
|
||||||
|
) : compilerCore.createSimpleExpression("", true)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformModel = (dir, node, context) => {
|
||||||
|
const baseResult = compilerCore.transformModel(dir, node, context);
|
||||||
|
if (!baseResult.props.length || node.tagType === 1) {
|
||||||
|
return baseResult;
|
||||||
|
}
|
||||||
|
if (dir.arg) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
58,
|
||||||
|
dir.arg.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function checkDuplicatedValue() {
|
||||||
|
const value = compilerCore.findDir(node, "bind");
|
||||||
|
if (value && compilerCore.isStaticArgOf(value.arg, "value")) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
60,
|
||||||
|
value.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const { tag } = node;
|
||||||
|
const isCustomElement = context.isCustomElement(tag);
|
||||||
|
if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
|
||||||
|
let directiveToUse = V_MODEL_TEXT;
|
||||||
|
let isInvalidType = false;
|
||||||
|
if (tag === "input" || isCustomElement) {
|
||||||
|
const type = compilerCore.findProp(node, `type`);
|
||||||
|
if (type) {
|
||||||
|
if (type.type === 7) {
|
||||||
|
directiveToUse = V_MODEL_DYNAMIC;
|
||||||
|
} else if (type.value) {
|
||||||
|
switch (type.value.content) {
|
||||||
|
case "radio":
|
||||||
|
directiveToUse = V_MODEL_RADIO;
|
||||||
|
break;
|
||||||
|
case "checkbox":
|
||||||
|
directiveToUse = V_MODEL_CHECKBOX;
|
||||||
|
break;
|
||||||
|
case "file":
|
||||||
|
isInvalidType = true;
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
59,
|
||||||
|
dir.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
checkDuplicatedValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (compilerCore.hasDynamicKeyVBind(node)) {
|
||||||
|
directiveToUse = V_MODEL_DYNAMIC;
|
||||||
|
} else {
|
||||||
|
checkDuplicatedValue();
|
||||||
|
}
|
||||||
|
} else if (tag === "select") {
|
||||||
|
directiveToUse = V_MODEL_SELECT;
|
||||||
|
} else {
|
||||||
|
checkDuplicatedValue();
|
||||||
|
}
|
||||||
|
if (!isInvalidType) {
|
||||||
|
baseResult.needRuntime = context.helper(directiveToUse);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
57,
|
||||||
|
dir.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
baseResult.props = baseResult.props.filter(
|
||||||
|
(p) => !(p.key.type === 4 && p.key.content === "modelValue")
|
||||||
|
);
|
||||||
|
return baseResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isEventOptionModifier = /* @__PURE__ */ shared.makeMap(`passive,once,capture`);
|
||||||
|
const isNonKeyModifier = /* @__PURE__ */ shared.makeMap(
|
||||||
|
// event propagation management
|
||||||
|
`stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
|
||||||
|
);
|
||||||
|
const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
|
||||||
|
const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(
|
||||||
|
`onkeyup,onkeydown,onkeypress`,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
const resolveModifiers = (key, modifiers, context, loc) => {
|
||||||
|
const keyModifiers = [];
|
||||||
|
const nonKeyModifiers = [];
|
||||||
|
const eventOptionModifiers = [];
|
||||||
|
for (let i = 0; i < modifiers.length; i++) {
|
||||||
|
const modifier = modifiers[i];
|
||||||
|
if (modifier === "native" && compilerCore.checkCompatEnabled(
|
||||||
|
"COMPILER_V_ON_NATIVE",
|
||||||
|
context,
|
||||||
|
loc
|
||||||
|
)) {
|
||||||
|
eventOptionModifiers.push(modifier);
|
||||||
|
} else if (isEventOptionModifier(modifier)) {
|
||||||
|
eventOptionModifiers.push(modifier);
|
||||||
|
} else {
|
||||||
|
if (maybeKeyModifier(modifier)) {
|
||||||
|
if (compilerCore.isStaticExp(key)) {
|
||||||
|
if (isKeyboardEvent(key.content)) {
|
||||||
|
keyModifiers.push(modifier);
|
||||||
|
} else {
|
||||||
|
nonKeyModifiers.push(modifier);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
keyModifiers.push(modifier);
|
||||||
|
nonKeyModifiers.push(modifier);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isNonKeyModifier(modifier)) {
|
||||||
|
nonKeyModifiers.push(modifier);
|
||||||
|
} else {
|
||||||
|
keyModifiers.push(modifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
keyModifiers,
|
||||||
|
nonKeyModifiers,
|
||||||
|
eventOptionModifiers
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const transformClick = (key, event) => {
|
||||||
|
const isStaticClick = compilerCore.isStaticExp(key) && key.content.toLowerCase() === "onclick";
|
||||||
|
return isStaticClick ? compilerCore.createSimpleExpression(event, true) : key.type !== 4 ? compilerCore.createCompoundExpression([
|
||||||
|
`(`,
|
||||||
|
key,
|
||||||
|
`) === "onClick" ? "${event}" : (`,
|
||||||
|
key,
|
||||||
|
`)`
|
||||||
|
]) : key;
|
||||||
|
};
|
||||||
|
const transformOn = (dir, node, context) => {
|
||||||
|
return compilerCore.transformOn(dir, node, context, (baseResult) => {
|
||||||
|
const { modifiers } = dir;
|
||||||
|
if (!modifiers.length) return baseResult;
|
||||||
|
let { key, value: handlerExp } = baseResult.props[0];
|
||||||
|
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
||||||
|
if (nonKeyModifiers.includes("right")) {
|
||||||
|
key = transformClick(key, `onContextmenu`);
|
||||||
|
}
|
||||||
|
if (nonKeyModifiers.includes("middle")) {
|
||||||
|
key = transformClick(key, `onMouseup`);
|
||||||
|
}
|
||||||
|
if (nonKeyModifiers.length) {
|
||||||
|
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
|
||||||
|
handlerExp,
|
||||||
|
JSON.stringify(nonKeyModifiers)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
|
||||||
|
(!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content))) {
|
||||||
|
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
||||||
|
handlerExp,
|
||||||
|
JSON.stringify(keyModifiers)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (eventOptionModifiers.length) {
|
||||||
|
const modifierPostfix = eventOptionModifiers.map(shared.capitalize).join("");
|
||||||
|
key = compilerCore.isStaticExp(key) ? compilerCore.createSimpleExpression(`${key.content}${modifierPostfix}`, true) : compilerCore.createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [compilerCore.createObjectProperty(key, handlerExp)]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformShow = (dir, node, context) => {
|
||||||
|
const { exp, loc } = dir;
|
||||||
|
if (!exp) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(61, loc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [],
|
||||||
|
needRuntime: context.helper(V_SHOW)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformTransition = (node, context) => {
|
||||||
|
if (node.type === 1 && node.tagType === 1) {
|
||||||
|
const component = context.isBuiltInComponent(node.tag);
|
||||||
|
if (component === TRANSITION) {
|
||||||
|
return () => {
|
||||||
|
if (!node.children.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (hasMultipleChildren(node)) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
62,
|
||||||
|
{
|
||||||
|
start: node.children[0].loc.start,
|
||||||
|
end: node.children[node.children.length - 1].loc.end,
|
||||||
|
source: ""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const child = node.children[0];
|
||||||
|
if (child.type === 1) {
|
||||||
|
for (const p of child.props) {
|
||||||
|
if (p.type === 7 && p.name === "show") {
|
||||||
|
node.props.push({
|
||||||
|
type: 6,
|
||||||
|
name: "persisted",
|
||||||
|
nameLoc: node.loc,
|
||||||
|
value: void 0,
|
||||||
|
loc: node.loc
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function hasMultipleChildren(node) {
|
||||||
|
const children = node.children = node.children.filter(
|
||||||
|
(c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
|
||||||
|
);
|
||||||
|
const child = children[0];
|
||||||
|
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
|
||||||
|
}
|
||||||
|
|
||||||
|
const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
|
||||||
|
const stringifyStatic = (children, context, parent) => {
|
||||||
|
if (context.scopes.vSlot > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let nc = 0;
|
||||||
|
let ec = 0;
|
||||||
|
const currentChunk = [];
|
||||||
|
const stringifyCurrentChunk = (currentIndex) => {
|
||||||
|
if (nc >= 20 || ec >= 5) {
|
||||||
|
const staticCall = compilerCore.createCallExpression(context.helper(compilerCore.CREATE_STATIC), [
|
||||||
|
JSON.stringify(
|
||||||
|
currentChunk.map((node) => stringifyNode(node, context)).join("")
|
||||||
|
).replace(expReplaceRE, `" + $1 + "`),
|
||||||
|
// the 2nd argument indicates the number of DOM nodes this static vnode
|
||||||
|
// will insert / hydrate
|
||||||
|
String(currentChunk.length)
|
||||||
|
]);
|
||||||
|
replaceHoist(currentChunk[0], staticCall, context);
|
||||||
|
if (currentChunk.length > 1) {
|
||||||
|
for (let i2 = 1; i2 < currentChunk.length; i2++) {
|
||||||
|
replaceHoist(currentChunk[i2], null, context);
|
||||||
|
}
|
||||||
|
const deleteCount = currentChunk.length - 1;
|
||||||
|
children.splice(currentIndex - currentChunk.length + 1, deleteCount);
|
||||||
|
return deleteCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
let i = 0;
|
||||||
|
for (; i < children.length; i++) {
|
||||||
|
const child = children[i];
|
||||||
|
const hoisted = getHoistedNode(child);
|
||||||
|
if (hoisted) {
|
||||||
|
const node = child;
|
||||||
|
const result = analyzeNode(node);
|
||||||
|
if (result) {
|
||||||
|
nc += result[0];
|
||||||
|
ec += result[1];
|
||||||
|
currentChunk.push(node);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i -= stringifyCurrentChunk(i);
|
||||||
|
nc = 0;
|
||||||
|
ec = 0;
|
||||||
|
currentChunk.length = 0;
|
||||||
|
}
|
||||||
|
stringifyCurrentChunk(i);
|
||||||
|
};
|
||||||
|
const getHoistedNode = (node) => (node.type === 1 && node.tagType === 0 || node.type == 12) && node.codegenNode && node.codegenNode.type === 4 && node.codegenNode.hoisted;
|
||||||
|
const dataAriaRE = /^(data|aria)-/;
|
||||||
|
const isStringifiableAttr = (name, ns) => {
|
||||||
|
return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : false) || dataAriaRE.test(name);
|
||||||
|
};
|
||||||
|
const replaceHoist = (node, replacement, context) => {
|
||||||
|
const hoistToReplace = node.codegenNode.hoisted;
|
||||||
|
context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement;
|
||||||
|
};
|
||||||
|
const isNonStringifiable = /* @__PURE__ */ shared.makeMap(
|
||||||
|
`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
|
||||||
|
);
|
||||||
|
function analyzeNode(node) {
|
||||||
|
if (node.type === 1 && isNonStringifiable(node.tag)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (node.type === 12) {
|
||||||
|
return [1, 0];
|
||||||
|
}
|
||||||
|
let nc = 1;
|
||||||
|
let ec = node.props.length > 0 ? 1 : 0;
|
||||||
|
let bailed = false;
|
||||||
|
const bail = () => {
|
||||||
|
bailed = true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
function walk(node2) {
|
||||||
|
const isOptionTag = node2.tag === "option" && node2.ns === 0;
|
||||||
|
for (let i = 0; i < node2.props.length; i++) {
|
||||||
|
const p = node2.props[i];
|
||||||
|
if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
|
||||||
|
return bail();
|
||||||
|
}
|
||||||
|
if (p.type === 7 && p.name === "bind") {
|
||||||
|
if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
|
||||||
|
return bail();
|
||||||
|
}
|
||||||
|
if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
|
||||||
|
return bail();
|
||||||
|
}
|
||||||
|
if (isOptionTag && compilerCore.isStaticArgOf(p.arg, "value") && p.exp && p.exp.ast && p.exp.ast.type !== "StringLiteral") {
|
||||||
|
return bail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let i = 0; i < node2.children.length; i++) {
|
||||||
|
nc++;
|
||||||
|
const child = node2.children[i];
|
||||||
|
if (child.type === 1) {
|
||||||
|
if (child.props.length > 0) {
|
||||||
|
ec++;
|
||||||
|
}
|
||||||
|
walk(child);
|
||||||
|
if (bailed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return walk(node) ? [nc, ec] : false;
|
||||||
|
}
|
||||||
|
function stringifyNode(node, context) {
|
||||||
|
if (shared.isString(node)) {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
if (shared.isSymbol(node)) {
|
||||||
|
return ``;
|
||||||
|
}
|
||||||
|
switch (node.type) {
|
||||||
|
case 1:
|
||||||
|
return stringifyElement(node, context);
|
||||||
|
case 2:
|
||||||
|
return shared.escapeHtml(node.content);
|
||||||
|
case 3:
|
||||||
|
return `<!--${shared.escapeHtml(node.content)}-->`;
|
||||||
|
case 5:
|
||||||
|
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
|
||||||
|
case 8:
|
||||||
|
return shared.escapeHtml(evaluateConstant(node));
|
||||||
|
case 12:
|
||||||
|
return stringifyNode(node.content, context);
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function stringifyElement(node, context) {
|
||||||
|
let res = `<${node.tag}`;
|
||||||
|
let innerHTML = "";
|
||||||
|
for (let i = 0; i < node.props.length; i++) {
|
||||||
|
const p = node.props[i];
|
||||||
|
if (p.type === 6) {
|
||||||
|
res += ` ${p.name}`;
|
||||||
|
if (p.value) {
|
||||||
|
res += `="${shared.escapeHtml(p.value.content)}"`;
|
||||||
|
}
|
||||||
|
} else if (p.type === 7) {
|
||||||
|
if (p.name === "bind") {
|
||||||
|
const exp = p.exp;
|
||||||
|
if (exp.content[0] === "_") {
|
||||||
|
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (shared.isBooleanAttr(p.arg.content) && exp.content === "false") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let evaluated = evaluateConstant(exp);
|
||||||
|
if (evaluated != null) {
|
||||||
|
const arg = p.arg && p.arg.content;
|
||||||
|
if (arg === "class") {
|
||||||
|
evaluated = shared.normalizeClass(evaluated);
|
||||||
|
} else if (arg === "style") {
|
||||||
|
evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
|
||||||
|
}
|
||||||
|
res += ` ${p.arg.content}="${shared.escapeHtml(
|
||||||
|
evaluated
|
||||||
|
)}"`;
|
||||||
|
}
|
||||||
|
} else if (p.name === "html") {
|
||||||
|
innerHTML = evaluateConstant(p.exp);
|
||||||
|
} else if (p.name === "text") {
|
||||||
|
innerHTML = shared.escapeHtml(
|
||||||
|
shared.toDisplayString(evaluateConstant(p.exp))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (context.scopeId) {
|
||||||
|
res += ` ${context.scopeId}`;
|
||||||
|
}
|
||||||
|
res += `>`;
|
||||||
|
if (innerHTML) {
|
||||||
|
res += innerHTML;
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < node.children.length; i++) {
|
||||||
|
res += stringifyNode(node.children[i], context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!shared.isVoidTag(node.tag)) {
|
||||||
|
res += `</${node.tag}>`;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
function evaluateConstant(exp) {
|
||||||
|
if (exp.type === 4) {
|
||||||
|
return new Function(`return (${exp.content})`)();
|
||||||
|
} else {
|
||||||
|
let res = ``;
|
||||||
|
exp.children.forEach((c) => {
|
||||||
|
if (shared.isString(c) || shared.isSymbol(c)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (c.type === 2) {
|
||||||
|
res += c.content;
|
||||||
|
} else if (c.type === 5) {
|
||||||
|
res += shared.toDisplayString(evaluateConstant(c.content));
|
||||||
|
} else {
|
||||||
|
res += evaluateConstant(c);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ignoreSideEffectTags = (node, context) => {
|
||||||
|
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
63,
|
||||||
|
node.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
context.removeNode();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const DOMNodeTransforms = [
|
||||||
|
transformStyle,
|
||||||
|
...[transformTransition]
|
||||||
|
];
|
||||||
|
const DOMDirectiveTransforms = {
|
||||||
|
cloak: compilerCore.noopDirectiveTransform,
|
||||||
|
html: transformVHtml,
|
||||||
|
text: transformVText,
|
||||||
|
model: transformModel,
|
||||||
|
// override compiler-core
|
||||||
|
on: transformOn,
|
||||||
|
// override compiler-core
|
||||||
|
show: transformShow
|
||||||
|
};
|
||||||
|
function compile(src, options = {}) {
|
||||||
|
return compilerCore.baseCompile(
|
||||||
|
src,
|
||||||
|
shared.extend({}, parserOptions, options, {
|
||||||
|
nodeTransforms: [
|
||||||
|
// ignore <script> and <tag>
|
||||||
|
// this is not put inside DOMNodeTransforms because that list is used
|
||||||
|
// by compiler-ssr to generate vnode fallback branches
|
||||||
|
ignoreSideEffectTags,
|
||||||
|
...DOMNodeTransforms,
|
||||||
|
...options.nodeTransforms || []
|
||||||
|
],
|
||||||
|
directiveTransforms: shared.extend(
|
||||||
|
{},
|
||||||
|
DOMDirectiveTransforms,
|
||||||
|
options.directiveTransforms || {}
|
||||||
|
),
|
||||||
|
transformHoist: stringifyStatic
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function parse(template, options = {}) {
|
||||||
|
return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.DOMDirectiveTransforms = DOMDirectiveTransforms;
|
||||||
|
exports.DOMErrorCodes = DOMErrorCodes;
|
||||||
|
exports.DOMErrorMessages = DOMErrorMessages;
|
||||||
|
exports.DOMNodeTransforms = DOMNodeTransforms;
|
||||||
|
exports.TRANSITION = TRANSITION;
|
||||||
|
exports.TRANSITION_GROUP = TRANSITION_GROUP;
|
||||||
|
exports.V_MODEL_CHECKBOX = V_MODEL_CHECKBOX;
|
||||||
|
exports.V_MODEL_DYNAMIC = V_MODEL_DYNAMIC;
|
||||||
|
exports.V_MODEL_RADIO = V_MODEL_RADIO;
|
||||||
|
exports.V_MODEL_SELECT = V_MODEL_SELECT;
|
||||||
|
exports.V_MODEL_TEXT = V_MODEL_TEXT;
|
||||||
|
exports.V_ON_WITH_KEYS = V_ON_WITH_KEYS;
|
||||||
|
exports.V_ON_WITH_MODIFIERS = V_ON_WITH_MODIFIERS;
|
||||||
|
exports.V_SHOW = V_SHOW;
|
||||||
|
exports.compile = compile;
|
||||||
|
exports.createDOMCompilerError = createDOMCompilerError;
|
||||||
|
exports.parse = parse;
|
||||||
|
exports.parserOptions = parserOptions;
|
||||||
|
exports.transformStyle = transformStyle;
|
||||||
|
Object.keys(compilerCore).forEach(function (k) {
|
||||||
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = compilerCore[k];
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,660 @@
|
||||||
|
/**
|
||||||
|
* @vue/compiler-dom v3.4.31
|
||||||
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
||||||
|
* @license MIT
|
||||||
|
**/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
var compilerCore = require('@vue/compiler-core');
|
||||||
|
var shared = require('@vue/shared');
|
||||||
|
|
||||||
|
const V_MODEL_RADIO = Symbol(``);
|
||||||
|
const V_MODEL_CHECKBOX = Symbol(``);
|
||||||
|
const V_MODEL_TEXT = Symbol(``);
|
||||||
|
const V_MODEL_SELECT = Symbol(``);
|
||||||
|
const V_MODEL_DYNAMIC = Symbol(``);
|
||||||
|
const V_ON_WITH_MODIFIERS = Symbol(``);
|
||||||
|
const V_ON_WITH_KEYS = Symbol(``);
|
||||||
|
const V_SHOW = Symbol(``);
|
||||||
|
const TRANSITION = Symbol(``);
|
||||||
|
const TRANSITION_GROUP = Symbol(``);
|
||||||
|
compilerCore.registerRuntimeHelpers({
|
||||||
|
[V_MODEL_RADIO]: `vModelRadio`,
|
||||||
|
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
||||||
|
[V_MODEL_TEXT]: `vModelText`,
|
||||||
|
[V_MODEL_SELECT]: `vModelSelect`,
|
||||||
|
[V_MODEL_DYNAMIC]: `vModelDynamic`,
|
||||||
|
[V_ON_WITH_MODIFIERS]: `withModifiers`,
|
||||||
|
[V_ON_WITH_KEYS]: `withKeys`,
|
||||||
|
[V_SHOW]: `vShow`,
|
||||||
|
[TRANSITION]: `Transition`,
|
||||||
|
[TRANSITION_GROUP]: `TransitionGroup`
|
||||||
|
});
|
||||||
|
|
||||||
|
const parserOptions = {
|
||||||
|
parseMode: "html",
|
||||||
|
isVoidTag: shared.isVoidTag,
|
||||||
|
isNativeTag: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
|
||||||
|
isPreTag: (tag) => tag === "pre",
|
||||||
|
decodeEntities: void 0,
|
||||||
|
isBuiltInComponent: (tag) => {
|
||||||
|
if (tag === "Transition" || tag === "transition") {
|
||||||
|
return TRANSITION;
|
||||||
|
} else if (tag === "TransitionGroup" || tag === "transition-group") {
|
||||||
|
return TRANSITION_GROUP;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
||||||
|
getNamespace(tag, parent, rootNamespace) {
|
||||||
|
let ns = parent ? parent.ns : rootNamespace;
|
||||||
|
if (parent && ns === 2) {
|
||||||
|
if (parent.tag === "annotation-xml") {
|
||||||
|
if (tag === "svg") {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (parent.props.some(
|
||||||
|
(a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
|
||||||
|
)) {
|
||||||
|
ns = 0;
|
||||||
|
}
|
||||||
|
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
|
||||||
|
ns = 0;
|
||||||
|
}
|
||||||
|
} else if (parent && ns === 1) {
|
||||||
|
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
|
||||||
|
ns = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ns === 0) {
|
||||||
|
if (tag === "svg") {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (tag === "math") {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ns;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformStyle = (node) => {
|
||||||
|
if (node.type === 1) {
|
||||||
|
node.props.forEach((p, i) => {
|
||||||
|
if (p.type === 6 && p.name === "style" && p.value) {
|
||||||
|
node.props[i] = {
|
||||||
|
type: 7,
|
||||||
|
name: `bind`,
|
||||||
|
arg: compilerCore.createSimpleExpression(`style`, true, p.loc),
|
||||||
|
exp: parseInlineCSS(p.value.content, p.loc),
|
||||||
|
modifiers: [],
|
||||||
|
loc: p.loc
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const parseInlineCSS = (cssText, loc) => {
|
||||||
|
const normalized = shared.parseStringStyle(cssText);
|
||||||
|
return compilerCore.createSimpleExpression(
|
||||||
|
JSON.stringify(normalized),
|
||||||
|
false,
|
||||||
|
loc,
|
||||||
|
3
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
function createDOMCompilerError(code, loc) {
|
||||||
|
return compilerCore.createCompilerError(
|
||||||
|
code,
|
||||||
|
loc,
|
||||||
|
DOMErrorMessages
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const DOMErrorCodes = {
|
||||||
|
"X_V_HTML_NO_EXPRESSION": 53,
|
||||||
|
"53": "X_V_HTML_NO_EXPRESSION",
|
||||||
|
"X_V_HTML_WITH_CHILDREN": 54,
|
||||||
|
"54": "X_V_HTML_WITH_CHILDREN",
|
||||||
|
"X_V_TEXT_NO_EXPRESSION": 55,
|
||||||
|
"55": "X_V_TEXT_NO_EXPRESSION",
|
||||||
|
"X_V_TEXT_WITH_CHILDREN": 56,
|
||||||
|
"56": "X_V_TEXT_WITH_CHILDREN",
|
||||||
|
"X_V_MODEL_ON_INVALID_ELEMENT": 57,
|
||||||
|
"57": "X_V_MODEL_ON_INVALID_ELEMENT",
|
||||||
|
"X_V_MODEL_ARG_ON_ELEMENT": 58,
|
||||||
|
"58": "X_V_MODEL_ARG_ON_ELEMENT",
|
||||||
|
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
|
||||||
|
"59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
|
||||||
|
"X_V_MODEL_UNNECESSARY_VALUE": 60,
|
||||||
|
"60": "X_V_MODEL_UNNECESSARY_VALUE",
|
||||||
|
"X_V_SHOW_NO_EXPRESSION": 61,
|
||||||
|
"61": "X_V_SHOW_NO_EXPRESSION",
|
||||||
|
"X_TRANSITION_INVALID_CHILDREN": 62,
|
||||||
|
"62": "X_TRANSITION_INVALID_CHILDREN",
|
||||||
|
"X_IGNORED_SIDE_EFFECT_TAG": 63,
|
||||||
|
"63": "X_IGNORED_SIDE_EFFECT_TAG",
|
||||||
|
"__EXTEND_POINT__": 64,
|
||||||
|
"64": "__EXTEND_POINT__"
|
||||||
|
};
|
||||||
|
const DOMErrorMessages = {
|
||||||
|
[53]: `v-html is missing expression.`,
|
||||||
|
[54]: `v-html will override element children.`,
|
||||||
|
[55]: `v-text is missing expression.`,
|
||||||
|
[56]: `v-text will override element children.`,
|
||||||
|
[57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
||||||
|
[58]: `v-model argument is not supported on plain elements.`,
|
||||||
|
[59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
||||||
|
[60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
||||||
|
[61]: `v-show is missing expression.`,
|
||||||
|
[62]: `<Transition> expects exactly one child element or component.`,
|
||||||
|
[63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformVHtml = (dir, node, context) => {
|
||||||
|
const { exp, loc } = dir;
|
||||||
|
if (!exp) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(53, loc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (node.children.length) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(54, loc)
|
||||||
|
);
|
||||||
|
node.children.length = 0;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [
|
||||||
|
compilerCore.createObjectProperty(
|
||||||
|
compilerCore.createSimpleExpression(`innerHTML`, true, loc),
|
||||||
|
exp || compilerCore.createSimpleExpression("", true)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformVText = (dir, node, context) => {
|
||||||
|
const { exp, loc } = dir;
|
||||||
|
if (!exp) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(55, loc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (node.children.length) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(56, loc)
|
||||||
|
);
|
||||||
|
node.children.length = 0;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [
|
||||||
|
compilerCore.createObjectProperty(
|
||||||
|
compilerCore.createSimpleExpression(`textContent`, true),
|
||||||
|
exp ? compilerCore.getConstantType(exp, context) > 0 ? exp : compilerCore.createCallExpression(
|
||||||
|
context.helperString(compilerCore.TO_DISPLAY_STRING),
|
||||||
|
[exp],
|
||||||
|
loc
|
||||||
|
) : compilerCore.createSimpleExpression("", true)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformModel = (dir, node, context) => {
|
||||||
|
const baseResult = compilerCore.transformModel(dir, node, context);
|
||||||
|
if (!baseResult.props.length || node.tagType === 1) {
|
||||||
|
return baseResult;
|
||||||
|
}
|
||||||
|
if (dir.arg) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
58,
|
||||||
|
dir.arg.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const { tag } = node;
|
||||||
|
const isCustomElement = context.isCustomElement(tag);
|
||||||
|
if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
|
||||||
|
let directiveToUse = V_MODEL_TEXT;
|
||||||
|
let isInvalidType = false;
|
||||||
|
if (tag === "input" || isCustomElement) {
|
||||||
|
const type = compilerCore.findProp(node, `type`);
|
||||||
|
if (type) {
|
||||||
|
if (type.type === 7) {
|
||||||
|
directiveToUse = V_MODEL_DYNAMIC;
|
||||||
|
} else if (type.value) {
|
||||||
|
switch (type.value.content) {
|
||||||
|
case "radio":
|
||||||
|
directiveToUse = V_MODEL_RADIO;
|
||||||
|
break;
|
||||||
|
case "checkbox":
|
||||||
|
directiveToUse = V_MODEL_CHECKBOX;
|
||||||
|
break;
|
||||||
|
case "file":
|
||||||
|
isInvalidType = true;
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
59,
|
||||||
|
dir.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (compilerCore.hasDynamicKeyVBind(node)) {
|
||||||
|
directiveToUse = V_MODEL_DYNAMIC;
|
||||||
|
} else ;
|
||||||
|
} else if (tag === "select") {
|
||||||
|
directiveToUse = V_MODEL_SELECT;
|
||||||
|
} else ;
|
||||||
|
if (!isInvalidType) {
|
||||||
|
baseResult.needRuntime = context.helper(directiveToUse);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
57,
|
||||||
|
dir.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
baseResult.props = baseResult.props.filter(
|
||||||
|
(p) => !(p.key.type === 4 && p.key.content === "modelValue")
|
||||||
|
);
|
||||||
|
return baseResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isEventOptionModifier = /* @__PURE__ */ shared.makeMap(`passive,once,capture`);
|
||||||
|
const isNonKeyModifier = /* @__PURE__ */ shared.makeMap(
|
||||||
|
// event propagation management
|
||||||
|
`stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
|
||||||
|
);
|
||||||
|
const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
|
||||||
|
const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(
|
||||||
|
`onkeyup,onkeydown,onkeypress`,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
const resolveModifiers = (key, modifiers, context, loc) => {
|
||||||
|
const keyModifiers = [];
|
||||||
|
const nonKeyModifiers = [];
|
||||||
|
const eventOptionModifiers = [];
|
||||||
|
for (let i = 0; i < modifiers.length; i++) {
|
||||||
|
const modifier = modifiers[i];
|
||||||
|
if (modifier === "native" && compilerCore.checkCompatEnabled(
|
||||||
|
"COMPILER_V_ON_NATIVE",
|
||||||
|
context,
|
||||||
|
loc
|
||||||
|
)) {
|
||||||
|
eventOptionModifiers.push(modifier);
|
||||||
|
} else if (isEventOptionModifier(modifier)) {
|
||||||
|
eventOptionModifiers.push(modifier);
|
||||||
|
} else {
|
||||||
|
if (maybeKeyModifier(modifier)) {
|
||||||
|
if (compilerCore.isStaticExp(key)) {
|
||||||
|
if (isKeyboardEvent(key.content)) {
|
||||||
|
keyModifiers.push(modifier);
|
||||||
|
} else {
|
||||||
|
nonKeyModifiers.push(modifier);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
keyModifiers.push(modifier);
|
||||||
|
nonKeyModifiers.push(modifier);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isNonKeyModifier(modifier)) {
|
||||||
|
nonKeyModifiers.push(modifier);
|
||||||
|
} else {
|
||||||
|
keyModifiers.push(modifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
keyModifiers,
|
||||||
|
nonKeyModifiers,
|
||||||
|
eventOptionModifiers
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const transformClick = (key, event) => {
|
||||||
|
const isStaticClick = compilerCore.isStaticExp(key) && key.content.toLowerCase() === "onclick";
|
||||||
|
return isStaticClick ? compilerCore.createSimpleExpression(event, true) : key.type !== 4 ? compilerCore.createCompoundExpression([
|
||||||
|
`(`,
|
||||||
|
key,
|
||||||
|
`) === "onClick" ? "${event}" : (`,
|
||||||
|
key,
|
||||||
|
`)`
|
||||||
|
]) : key;
|
||||||
|
};
|
||||||
|
const transformOn = (dir, node, context) => {
|
||||||
|
return compilerCore.transformOn(dir, node, context, (baseResult) => {
|
||||||
|
const { modifiers } = dir;
|
||||||
|
if (!modifiers.length) return baseResult;
|
||||||
|
let { key, value: handlerExp } = baseResult.props[0];
|
||||||
|
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
||||||
|
if (nonKeyModifiers.includes("right")) {
|
||||||
|
key = transformClick(key, `onContextmenu`);
|
||||||
|
}
|
||||||
|
if (nonKeyModifiers.includes("middle")) {
|
||||||
|
key = transformClick(key, `onMouseup`);
|
||||||
|
}
|
||||||
|
if (nonKeyModifiers.length) {
|
||||||
|
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
|
||||||
|
handlerExp,
|
||||||
|
JSON.stringify(nonKeyModifiers)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
|
||||||
|
(!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content))) {
|
||||||
|
handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
||||||
|
handlerExp,
|
||||||
|
JSON.stringify(keyModifiers)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (eventOptionModifiers.length) {
|
||||||
|
const modifierPostfix = eventOptionModifiers.map(shared.capitalize).join("");
|
||||||
|
key = compilerCore.isStaticExp(key) ? compilerCore.createSimpleExpression(`${key.content}${modifierPostfix}`, true) : compilerCore.createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [compilerCore.createObjectProperty(key, handlerExp)]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformShow = (dir, node, context) => {
|
||||||
|
const { exp, loc } = dir;
|
||||||
|
if (!exp) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(61, loc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [],
|
||||||
|
needRuntime: context.helper(V_SHOW)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
|
||||||
|
const stringifyStatic = (children, context, parent) => {
|
||||||
|
if (context.scopes.vSlot > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let nc = 0;
|
||||||
|
let ec = 0;
|
||||||
|
const currentChunk = [];
|
||||||
|
const stringifyCurrentChunk = (currentIndex) => {
|
||||||
|
if (nc >= 20 || ec >= 5) {
|
||||||
|
const staticCall = compilerCore.createCallExpression(context.helper(compilerCore.CREATE_STATIC), [
|
||||||
|
JSON.stringify(
|
||||||
|
currentChunk.map((node) => stringifyNode(node, context)).join("")
|
||||||
|
).replace(expReplaceRE, `" + $1 + "`),
|
||||||
|
// the 2nd argument indicates the number of DOM nodes this static vnode
|
||||||
|
// will insert / hydrate
|
||||||
|
String(currentChunk.length)
|
||||||
|
]);
|
||||||
|
replaceHoist(currentChunk[0], staticCall, context);
|
||||||
|
if (currentChunk.length > 1) {
|
||||||
|
for (let i2 = 1; i2 < currentChunk.length; i2++) {
|
||||||
|
replaceHoist(currentChunk[i2], null, context);
|
||||||
|
}
|
||||||
|
const deleteCount = currentChunk.length - 1;
|
||||||
|
children.splice(currentIndex - currentChunk.length + 1, deleteCount);
|
||||||
|
return deleteCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
let i = 0;
|
||||||
|
for (; i < children.length; i++) {
|
||||||
|
const child = children[i];
|
||||||
|
const hoisted = getHoistedNode(child);
|
||||||
|
if (hoisted) {
|
||||||
|
const node = child;
|
||||||
|
const result = analyzeNode(node);
|
||||||
|
if (result) {
|
||||||
|
nc += result[0];
|
||||||
|
ec += result[1];
|
||||||
|
currentChunk.push(node);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i -= stringifyCurrentChunk(i);
|
||||||
|
nc = 0;
|
||||||
|
ec = 0;
|
||||||
|
currentChunk.length = 0;
|
||||||
|
}
|
||||||
|
stringifyCurrentChunk(i);
|
||||||
|
};
|
||||||
|
const getHoistedNode = (node) => (node.type === 1 && node.tagType === 0 || node.type == 12) && node.codegenNode && node.codegenNode.type === 4 && node.codegenNode.hoisted;
|
||||||
|
const dataAriaRE = /^(data|aria)-/;
|
||||||
|
const isStringifiableAttr = (name, ns) => {
|
||||||
|
return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : false) || dataAriaRE.test(name);
|
||||||
|
};
|
||||||
|
const replaceHoist = (node, replacement, context) => {
|
||||||
|
const hoistToReplace = node.codegenNode.hoisted;
|
||||||
|
context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement;
|
||||||
|
};
|
||||||
|
const isNonStringifiable = /* @__PURE__ */ shared.makeMap(
|
||||||
|
`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
|
||||||
|
);
|
||||||
|
function analyzeNode(node) {
|
||||||
|
if (node.type === 1 && isNonStringifiable(node.tag)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (node.type === 12) {
|
||||||
|
return [1, 0];
|
||||||
|
}
|
||||||
|
let nc = 1;
|
||||||
|
let ec = node.props.length > 0 ? 1 : 0;
|
||||||
|
let bailed = false;
|
||||||
|
const bail = () => {
|
||||||
|
bailed = true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
function walk(node2) {
|
||||||
|
const isOptionTag = node2.tag === "option" && node2.ns === 0;
|
||||||
|
for (let i = 0; i < node2.props.length; i++) {
|
||||||
|
const p = node2.props[i];
|
||||||
|
if (p.type === 6 && !isStringifiableAttr(p.name, node2.ns)) {
|
||||||
|
return bail();
|
||||||
|
}
|
||||||
|
if (p.type === 7 && p.name === "bind") {
|
||||||
|
if (p.arg && (p.arg.type === 8 || p.arg.isStatic && !isStringifiableAttr(p.arg.content, node2.ns))) {
|
||||||
|
return bail();
|
||||||
|
}
|
||||||
|
if (p.exp && (p.exp.type === 8 || p.exp.constType < 3)) {
|
||||||
|
return bail();
|
||||||
|
}
|
||||||
|
if (isOptionTag && compilerCore.isStaticArgOf(p.arg, "value") && p.exp && p.exp.ast && p.exp.ast.type !== "StringLiteral") {
|
||||||
|
return bail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let i = 0; i < node2.children.length; i++) {
|
||||||
|
nc++;
|
||||||
|
const child = node2.children[i];
|
||||||
|
if (child.type === 1) {
|
||||||
|
if (child.props.length > 0) {
|
||||||
|
ec++;
|
||||||
|
}
|
||||||
|
walk(child);
|
||||||
|
if (bailed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return walk(node) ? [nc, ec] : false;
|
||||||
|
}
|
||||||
|
function stringifyNode(node, context) {
|
||||||
|
if (shared.isString(node)) {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
if (shared.isSymbol(node)) {
|
||||||
|
return ``;
|
||||||
|
}
|
||||||
|
switch (node.type) {
|
||||||
|
case 1:
|
||||||
|
return stringifyElement(node, context);
|
||||||
|
case 2:
|
||||||
|
return shared.escapeHtml(node.content);
|
||||||
|
case 3:
|
||||||
|
return `<!--${shared.escapeHtml(node.content)}-->`;
|
||||||
|
case 5:
|
||||||
|
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
|
||||||
|
case 8:
|
||||||
|
return shared.escapeHtml(evaluateConstant(node));
|
||||||
|
case 12:
|
||||||
|
return stringifyNode(node.content, context);
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function stringifyElement(node, context) {
|
||||||
|
let res = `<${node.tag}`;
|
||||||
|
let innerHTML = "";
|
||||||
|
for (let i = 0; i < node.props.length; i++) {
|
||||||
|
const p = node.props[i];
|
||||||
|
if (p.type === 6) {
|
||||||
|
res += ` ${p.name}`;
|
||||||
|
if (p.value) {
|
||||||
|
res += `="${shared.escapeHtml(p.value.content)}"`;
|
||||||
|
}
|
||||||
|
} else if (p.type === 7) {
|
||||||
|
if (p.name === "bind") {
|
||||||
|
const exp = p.exp;
|
||||||
|
if (exp.content[0] === "_") {
|
||||||
|
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (shared.isBooleanAttr(p.arg.content) && exp.content === "false") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let evaluated = evaluateConstant(exp);
|
||||||
|
if (evaluated != null) {
|
||||||
|
const arg = p.arg && p.arg.content;
|
||||||
|
if (arg === "class") {
|
||||||
|
evaluated = shared.normalizeClass(evaluated);
|
||||||
|
} else if (arg === "style") {
|
||||||
|
evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
|
||||||
|
}
|
||||||
|
res += ` ${p.arg.content}="${shared.escapeHtml(
|
||||||
|
evaluated
|
||||||
|
)}"`;
|
||||||
|
}
|
||||||
|
} else if (p.name === "html") {
|
||||||
|
innerHTML = evaluateConstant(p.exp);
|
||||||
|
} else if (p.name === "text") {
|
||||||
|
innerHTML = shared.escapeHtml(
|
||||||
|
shared.toDisplayString(evaluateConstant(p.exp))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (context.scopeId) {
|
||||||
|
res += ` ${context.scopeId}`;
|
||||||
|
}
|
||||||
|
res += `>`;
|
||||||
|
if (innerHTML) {
|
||||||
|
res += innerHTML;
|
||||||
|
} else {
|
||||||
|
for (let i = 0; i < node.children.length; i++) {
|
||||||
|
res += stringifyNode(node.children[i], context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!shared.isVoidTag(node.tag)) {
|
||||||
|
res += `</${node.tag}>`;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
function evaluateConstant(exp) {
|
||||||
|
if (exp.type === 4) {
|
||||||
|
return new Function(`return (${exp.content})`)();
|
||||||
|
} else {
|
||||||
|
let res = ``;
|
||||||
|
exp.children.forEach((c) => {
|
||||||
|
if (shared.isString(c) || shared.isSymbol(c)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (c.type === 2) {
|
||||||
|
res += c.content;
|
||||||
|
} else if (c.type === 5) {
|
||||||
|
res += shared.toDisplayString(evaluateConstant(c.content));
|
||||||
|
} else {
|
||||||
|
res += evaluateConstant(c);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ignoreSideEffectTags = (node, context) => {
|
||||||
|
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
||||||
|
context.removeNode();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const DOMNodeTransforms = [
|
||||||
|
transformStyle,
|
||||||
|
...[]
|
||||||
|
];
|
||||||
|
const DOMDirectiveTransforms = {
|
||||||
|
cloak: compilerCore.noopDirectiveTransform,
|
||||||
|
html: transformVHtml,
|
||||||
|
text: transformVText,
|
||||||
|
model: transformModel,
|
||||||
|
// override compiler-core
|
||||||
|
on: transformOn,
|
||||||
|
// override compiler-core
|
||||||
|
show: transformShow
|
||||||
|
};
|
||||||
|
function compile(src, options = {}) {
|
||||||
|
return compilerCore.baseCompile(
|
||||||
|
src,
|
||||||
|
shared.extend({}, parserOptions, options, {
|
||||||
|
nodeTransforms: [
|
||||||
|
// ignore <script> and <tag>
|
||||||
|
// this is not put inside DOMNodeTransforms because that list is used
|
||||||
|
// by compiler-ssr to generate vnode fallback branches
|
||||||
|
ignoreSideEffectTags,
|
||||||
|
...DOMNodeTransforms,
|
||||||
|
...options.nodeTransforms || []
|
||||||
|
],
|
||||||
|
directiveTransforms: shared.extend(
|
||||||
|
{},
|
||||||
|
DOMDirectiveTransforms,
|
||||||
|
options.directiveTransforms || {}
|
||||||
|
),
|
||||||
|
transformHoist: stringifyStatic
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function parse(template, options = {}) {
|
||||||
|
return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.DOMDirectiveTransforms = DOMDirectiveTransforms;
|
||||||
|
exports.DOMErrorCodes = DOMErrorCodes;
|
||||||
|
exports.DOMErrorMessages = DOMErrorMessages;
|
||||||
|
exports.DOMNodeTransforms = DOMNodeTransforms;
|
||||||
|
exports.TRANSITION = TRANSITION;
|
||||||
|
exports.TRANSITION_GROUP = TRANSITION_GROUP;
|
||||||
|
exports.V_MODEL_CHECKBOX = V_MODEL_CHECKBOX;
|
||||||
|
exports.V_MODEL_DYNAMIC = V_MODEL_DYNAMIC;
|
||||||
|
exports.V_MODEL_RADIO = V_MODEL_RADIO;
|
||||||
|
exports.V_MODEL_SELECT = V_MODEL_SELECT;
|
||||||
|
exports.V_MODEL_TEXT = V_MODEL_TEXT;
|
||||||
|
exports.V_ON_WITH_KEYS = V_ON_WITH_KEYS;
|
||||||
|
exports.V_ON_WITH_MODIFIERS = V_ON_WITH_MODIFIERS;
|
||||||
|
exports.V_SHOW = V_SHOW;
|
||||||
|
exports.compile = compile;
|
||||||
|
exports.createDOMCompilerError = createDOMCompilerError;
|
||||||
|
exports.parse = parse;
|
||||||
|
exports.parserOptions = parserOptions;
|
||||||
|
exports.transformStyle = transformStyle;
|
||||||
|
Object.keys(compilerCore).forEach(function (k) {
|
||||||
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = compilerCore[k];
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
import { ParserOptions, NodeTransform, SourceLocation, CompilerError, DirectiveTransform, RootNode, CompilerOptions, CodegenResult } from '@vue/compiler-core';
|
||||||
|
export * from '@vue/compiler-core';
|
||||||
|
|
||||||
|
export declare const parserOptions: ParserOptions;
|
||||||
|
|
||||||
|
export declare const V_MODEL_RADIO: unique symbol;
|
||||||
|
export declare const V_MODEL_CHECKBOX: unique symbol;
|
||||||
|
export declare const V_MODEL_TEXT: unique symbol;
|
||||||
|
export declare const V_MODEL_SELECT: unique symbol;
|
||||||
|
export declare const V_MODEL_DYNAMIC: unique symbol;
|
||||||
|
export declare const V_ON_WITH_MODIFIERS: unique symbol;
|
||||||
|
export declare const V_ON_WITH_KEYS: unique symbol;
|
||||||
|
export declare const V_SHOW: unique symbol;
|
||||||
|
export declare const TRANSITION: unique symbol;
|
||||||
|
export declare const TRANSITION_GROUP: unique symbol;
|
||||||
|
|
||||||
|
export declare const transformStyle: NodeTransform;
|
||||||
|
|
||||||
|
interface DOMCompilerError extends CompilerError {
|
||||||
|
code: DOMErrorCodes;
|
||||||
|
}
|
||||||
|
export declare function createDOMCompilerError(code: DOMErrorCodes, loc?: SourceLocation): DOMCompilerError;
|
||||||
|
export declare enum DOMErrorCodes {
|
||||||
|
X_V_HTML_NO_EXPRESSION = 53,
|
||||||
|
X_V_HTML_WITH_CHILDREN = 54,
|
||||||
|
X_V_TEXT_NO_EXPRESSION = 55,
|
||||||
|
X_V_TEXT_WITH_CHILDREN = 56,
|
||||||
|
X_V_MODEL_ON_INVALID_ELEMENT = 57,
|
||||||
|
X_V_MODEL_ARG_ON_ELEMENT = 58,
|
||||||
|
X_V_MODEL_ON_FILE_INPUT_ELEMENT = 59,
|
||||||
|
X_V_MODEL_UNNECESSARY_VALUE = 60,
|
||||||
|
X_V_SHOW_NO_EXPRESSION = 61,
|
||||||
|
X_TRANSITION_INVALID_CHILDREN = 62,
|
||||||
|
X_IGNORED_SIDE_EFFECT_TAG = 63,
|
||||||
|
__EXTEND_POINT__ = 64
|
||||||
|
}
|
||||||
|
export declare const DOMErrorMessages: {
|
||||||
|
[code: number]: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare const DOMNodeTransforms: NodeTransform[];
|
||||||
|
export declare const DOMDirectiveTransforms: Record<string, DirectiveTransform>;
|
||||||
|
export declare function compile(src: string | RootNode, options?: CompilerOptions): CodegenResult;
|
||||||
|
export declare function parse(template: string, options?: ParserOptions): RootNode;
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
11
node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js
generated
vendored
Normal file
11
node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,505 @@
|
||||||
|
/**
|
||||||
|
* @vue/compiler-dom v3.4.31
|
||||||
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
||||||
|
* @license MIT
|
||||||
|
**/
|
||||||
|
import { registerRuntimeHelpers, createSimpleExpression, createCompilerError, createObjectProperty, getConstantType, createCallExpression, TO_DISPLAY_STRING, transformModel as transformModel$1, findProp, hasDynamicKeyVBind, findDir, isStaticArgOf, transformOn as transformOn$1, isStaticExp, createCompoundExpression, checkCompatEnabled, noopDirectiveTransform, baseCompile, baseParse } from '@vue/compiler-core';
|
||||||
|
export * from '@vue/compiler-core';
|
||||||
|
import { isVoidTag, isHTMLTag, isSVGTag, isMathMLTag, parseStringStyle, capitalize, makeMap, extend } from '@vue/shared';
|
||||||
|
|
||||||
|
const V_MODEL_RADIO = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelRadio` : ``);
|
||||||
|
const V_MODEL_CHECKBOX = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelCheckbox` : ``);
|
||||||
|
const V_MODEL_TEXT = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelText` : ``);
|
||||||
|
const V_MODEL_SELECT = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelSelect` : ``);
|
||||||
|
const V_MODEL_DYNAMIC = Symbol(!!(process.env.NODE_ENV !== "production") ? `vModelDynamic` : ``);
|
||||||
|
const V_ON_WITH_MODIFIERS = Symbol(!!(process.env.NODE_ENV !== "production") ? `vOnModifiersGuard` : ``);
|
||||||
|
const V_ON_WITH_KEYS = Symbol(!!(process.env.NODE_ENV !== "production") ? `vOnKeysGuard` : ``);
|
||||||
|
const V_SHOW = Symbol(!!(process.env.NODE_ENV !== "production") ? `vShow` : ``);
|
||||||
|
const TRANSITION = Symbol(!!(process.env.NODE_ENV !== "production") ? `Transition` : ``);
|
||||||
|
const TRANSITION_GROUP = Symbol(!!(process.env.NODE_ENV !== "production") ? `TransitionGroup` : ``);
|
||||||
|
registerRuntimeHelpers({
|
||||||
|
[V_MODEL_RADIO]: `vModelRadio`,
|
||||||
|
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
|
||||||
|
[V_MODEL_TEXT]: `vModelText`,
|
||||||
|
[V_MODEL_SELECT]: `vModelSelect`,
|
||||||
|
[V_MODEL_DYNAMIC]: `vModelDynamic`,
|
||||||
|
[V_ON_WITH_MODIFIERS]: `withModifiers`,
|
||||||
|
[V_ON_WITH_KEYS]: `withKeys`,
|
||||||
|
[V_SHOW]: `vShow`,
|
||||||
|
[TRANSITION]: `Transition`,
|
||||||
|
[TRANSITION_GROUP]: `TransitionGroup`
|
||||||
|
});
|
||||||
|
|
||||||
|
let decoder;
|
||||||
|
function decodeHtmlBrowser(raw, asAttr = false) {
|
||||||
|
if (!decoder) {
|
||||||
|
decoder = document.createElement("div");
|
||||||
|
}
|
||||||
|
if (asAttr) {
|
||||||
|
decoder.innerHTML = `<div foo="${raw.replace(/"/g, """)}">`;
|
||||||
|
return decoder.children[0].getAttribute("foo");
|
||||||
|
} else {
|
||||||
|
decoder.innerHTML = raw;
|
||||||
|
return decoder.textContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const parserOptions = {
|
||||||
|
parseMode: "html",
|
||||||
|
isVoidTag,
|
||||||
|
isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
|
||||||
|
isPreTag: (tag) => tag === "pre",
|
||||||
|
decodeEntities: decodeHtmlBrowser ,
|
||||||
|
isBuiltInComponent: (tag) => {
|
||||||
|
if (tag === "Transition" || tag === "transition") {
|
||||||
|
return TRANSITION;
|
||||||
|
} else if (tag === "TransitionGroup" || tag === "transition-group") {
|
||||||
|
return TRANSITION_GROUP;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
||||||
|
getNamespace(tag, parent, rootNamespace) {
|
||||||
|
let ns = parent ? parent.ns : rootNamespace;
|
||||||
|
if (parent && ns === 2) {
|
||||||
|
if (parent.tag === "annotation-xml") {
|
||||||
|
if (tag === "svg") {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (parent.props.some(
|
||||||
|
(a) => a.type === 6 && a.name === "encoding" && a.value != null && (a.value.content === "text/html" || a.value.content === "application/xhtml+xml")
|
||||||
|
)) {
|
||||||
|
ns = 0;
|
||||||
|
}
|
||||||
|
} else if (/^m(?:[ions]|text)$/.test(parent.tag) && tag !== "mglyph" && tag !== "malignmark") {
|
||||||
|
ns = 0;
|
||||||
|
}
|
||||||
|
} else if (parent && ns === 1) {
|
||||||
|
if (parent.tag === "foreignObject" || parent.tag === "desc" || parent.tag === "title") {
|
||||||
|
ns = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ns === 0) {
|
||||||
|
if (tag === "svg") {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (tag === "math") {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ns;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformStyle = (node) => {
|
||||||
|
if (node.type === 1) {
|
||||||
|
node.props.forEach((p, i) => {
|
||||||
|
if (p.type === 6 && p.name === "style" && p.value) {
|
||||||
|
node.props[i] = {
|
||||||
|
type: 7,
|
||||||
|
name: `bind`,
|
||||||
|
arg: createSimpleExpression(`style`, true, p.loc),
|
||||||
|
exp: parseInlineCSS(p.value.content, p.loc),
|
||||||
|
modifiers: [],
|
||||||
|
loc: p.loc
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const parseInlineCSS = (cssText, loc) => {
|
||||||
|
const normalized = parseStringStyle(cssText);
|
||||||
|
return createSimpleExpression(
|
||||||
|
JSON.stringify(normalized),
|
||||||
|
false,
|
||||||
|
loc,
|
||||||
|
3
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
function createDOMCompilerError(code, loc) {
|
||||||
|
return createCompilerError(
|
||||||
|
code,
|
||||||
|
loc,
|
||||||
|
!!(process.env.NODE_ENV !== "production") || false ? DOMErrorMessages : void 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const DOMErrorCodes = {
|
||||||
|
"X_V_HTML_NO_EXPRESSION": 53,
|
||||||
|
"53": "X_V_HTML_NO_EXPRESSION",
|
||||||
|
"X_V_HTML_WITH_CHILDREN": 54,
|
||||||
|
"54": "X_V_HTML_WITH_CHILDREN",
|
||||||
|
"X_V_TEXT_NO_EXPRESSION": 55,
|
||||||
|
"55": "X_V_TEXT_NO_EXPRESSION",
|
||||||
|
"X_V_TEXT_WITH_CHILDREN": 56,
|
||||||
|
"56": "X_V_TEXT_WITH_CHILDREN",
|
||||||
|
"X_V_MODEL_ON_INVALID_ELEMENT": 57,
|
||||||
|
"57": "X_V_MODEL_ON_INVALID_ELEMENT",
|
||||||
|
"X_V_MODEL_ARG_ON_ELEMENT": 58,
|
||||||
|
"58": "X_V_MODEL_ARG_ON_ELEMENT",
|
||||||
|
"X_V_MODEL_ON_FILE_INPUT_ELEMENT": 59,
|
||||||
|
"59": "X_V_MODEL_ON_FILE_INPUT_ELEMENT",
|
||||||
|
"X_V_MODEL_UNNECESSARY_VALUE": 60,
|
||||||
|
"60": "X_V_MODEL_UNNECESSARY_VALUE",
|
||||||
|
"X_V_SHOW_NO_EXPRESSION": 61,
|
||||||
|
"61": "X_V_SHOW_NO_EXPRESSION",
|
||||||
|
"X_TRANSITION_INVALID_CHILDREN": 62,
|
||||||
|
"62": "X_TRANSITION_INVALID_CHILDREN",
|
||||||
|
"X_IGNORED_SIDE_EFFECT_TAG": 63,
|
||||||
|
"63": "X_IGNORED_SIDE_EFFECT_TAG",
|
||||||
|
"__EXTEND_POINT__": 64,
|
||||||
|
"64": "__EXTEND_POINT__"
|
||||||
|
};
|
||||||
|
const DOMErrorMessages = {
|
||||||
|
[53]: `v-html is missing expression.`,
|
||||||
|
[54]: `v-html will override element children.`,
|
||||||
|
[55]: `v-text is missing expression.`,
|
||||||
|
[56]: `v-text will override element children.`,
|
||||||
|
[57]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
|
||||||
|
[58]: `v-model argument is not supported on plain elements.`,
|
||||||
|
[59]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
|
||||||
|
[60]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
|
||||||
|
[61]: `v-show is missing expression.`,
|
||||||
|
[62]: `<Transition> expects exactly one child element or component.`,
|
||||||
|
[63]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformVHtml = (dir, node, context) => {
|
||||||
|
const { exp, loc } = dir;
|
||||||
|
if (!exp) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(53, loc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (node.children.length) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(54, loc)
|
||||||
|
);
|
||||||
|
node.children.length = 0;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [
|
||||||
|
createObjectProperty(
|
||||||
|
createSimpleExpression(`innerHTML`, true, loc),
|
||||||
|
exp || createSimpleExpression("", true)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformVText = (dir, node, context) => {
|
||||||
|
const { exp, loc } = dir;
|
||||||
|
if (!exp) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(55, loc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (node.children.length) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(56, loc)
|
||||||
|
);
|
||||||
|
node.children.length = 0;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [
|
||||||
|
createObjectProperty(
|
||||||
|
createSimpleExpression(`textContent`, true),
|
||||||
|
exp ? getConstantType(exp, context) > 0 ? exp : createCallExpression(
|
||||||
|
context.helperString(TO_DISPLAY_STRING),
|
||||||
|
[exp],
|
||||||
|
loc
|
||||||
|
) : createSimpleExpression("", true)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformModel = (dir, node, context) => {
|
||||||
|
const baseResult = transformModel$1(dir, node, context);
|
||||||
|
if (!baseResult.props.length || node.tagType === 1) {
|
||||||
|
return baseResult;
|
||||||
|
}
|
||||||
|
if (dir.arg) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
58,
|
||||||
|
dir.arg.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function checkDuplicatedValue() {
|
||||||
|
const value = findDir(node, "bind");
|
||||||
|
if (value && isStaticArgOf(value.arg, "value")) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
60,
|
||||||
|
value.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const { tag } = node;
|
||||||
|
const isCustomElement = context.isCustomElement(tag);
|
||||||
|
if (tag === "input" || tag === "textarea" || tag === "select" || isCustomElement) {
|
||||||
|
let directiveToUse = V_MODEL_TEXT;
|
||||||
|
let isInvalidType = false;
|
||||||
|
if (tag === "input" || isCustomElement) {
|
||||||
|
const type = findProp(node, `type`);
|
||||||
|
if (type) {
|
||||||
|
if (type.type === 7) {
|
||||||
|
directiveToUse = V_MODEL_DYNAMIC;
|
||||||
|
} else if (type.value) {
|
||||||
|
switch (type.value.content) {
|
||||||
|
case "radio":
|
||||||
|
directiveToUse = V_MODEL_RADIO;
|
||||||
|
break;
|
||||||
|
case "checkbox":
|
||||||
|
directiveToUse = V_MODEL_CHECKBOX;
|
||||||
|
break;
|
||||||
|
case "file":
|
||||||
|
isInvalidType = true;
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
59,
|
||||||
|
dir.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
!!(process.env.NODE_ENV !== "production") && checkDuplicatedValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (hasDynamicKeyVBind(node)) {
|
||||||
|
directiveToUse = V_MODEL_DYNAMIC;
|
||||||
|
} else {
|
||||||
|
!!(process.env.NODE_ENV !== "production") && checkDuplicatedValue();
|
||||||
|
}
|
||||||
|
} else if (tag === "select") {
|
||||||
|
directiveToUse = V_MODEL_SELECT;
|
||||||
|
} else {
|
||||||
|
!!(process.env.NODE_ENV !== "production") && checkDuplicatedValue();
|
||||||
|
}
|
||||||
|
if (!isInvalidType) {
|
||||||
|
baseResult.needRuntime = context.helper(directiveToUse);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
57,
|
||||||
|
dir.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
baseResult.props = baseResult.props.filter(
|
||||||
|
(p) => !(p.key.type === 4 && p.key.content === "modelValue")
|
||||||
|
);
|
||||||
|
return baseResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
|
||||||
|
const isNonKeyModifier = /* @__PURE__ */ makeMap(
|
||||||
|
// event propagation management
|
||||||
|
`stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
|
||||||
|
);
|
||||||
|
const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
|
||||||
|
const isKeyboardEvent = /* @__PURE__ */ makeMap(
|
||||||
|
`onkeyup,onkeydown,onkeypress`,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
const resolveModifiers = (key, modifiers, context, loc) => {
|
||||||
|
const keyModifiers = [];
|
||||||
|
const nonKeyModifiers = [];
|
||||||
|
const eventOptionModifiers = [];
|
||||||
|
for (let i = 0; i < modifiers.length; i++) {
|
||||||
|
const modifier = modifiers[i];
|
||||||
|
if (modifier === "native" && checkCompatEnabled(
|
||||||
|
"COMPILER_V_ON_NATIVE",
|
||||||
|
context,
|
||||||
|
loc
|
||||||
|
)) {
|
||||||
|
eventOptionModifiers.push(modifier);
|
||||||
|
} else if (isEventOptionModifier(modifier)) {
|
||||||
|
eventOptionModifiers.push(modifier);
|
||||||
|
} else {
|
||||||
|
if (maybeKeyModifier(modifier)) {
|
||||||
|
if (isStaticExp(key)) {
|
||||||
|
if (isKeyboardEvent(key.content)) {
|
||||||
|
keyModifiers.push(modifier);
|
||||||
|
} else {
|
||||||
|
nonKeyModifiers.push(modifier);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
keyModifiers.push(modifier);
|
||||||
|
nonKeyModifiers.push(modifier);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isNonKeyModifier(modifier)) {
|
||||||
|
nonKeyModifiers.push(modifier);
|
||||||
|
} else {
|
||||||
|
keyModifiers.push(modifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
keyModifiers,
|
||||||
|
nonKeyModifiers,
|
||||||
|
eventOptionModifiers
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const transformClick = (key, event) => {
|
||||||
|
const isStaticClick = isStaticExp(key) && key.content.toLowerCase() === "onclick";
|
||||||
|
return isStaticClick ? createSimpleExpression(event, true) : key.type !== 4 ? createCompoundExpression([
|
||||||
|
`(`,
|
||||||
|
key,
|
||||||
|
`) === "onClick" ? "${event}" : (`,
|
||||||
|
key,
|
||||||
|
`)`
|
||||||
|
]) : key;
|
||||||
|
};
|
||||||
|
const transformOn = (dir, node, context) => {
|
||||||
|
return transformOn$1(dir, node, context, (baseResult) => {
|
||||||
|
const { modifiers } = dir;
|
||||||
|
if (!modifiers.length) return baseResult;
|
||||||
|
let { key, value: handlerExp } = baseResult.props[0];
|
||||||
|
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = resolveModifiers(key, modifiers, context, dir.loc);
|
||||||
|
if (nonKeyModifiers.includes("right")) {
|
||||||
|
key = transformClick(key, `onContextmenu`);
|
||||||
|
}
|
||||||
|
if (nonKeyModifiers.includes("middle")) {
|
||||||
|
key = transformClick(key, `onMouseup`);
|
||||||
|
}
|
||||||
|
if (nonKeyModifiers.length) {
|
||||||
|
handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
|
||||||
|
handlerExp,
|
||||||
|
JSON.stringify(nonKeyModifiers)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
|
||||||
|
(!isStaticExp(key) || isKeyboardEvent(key.content))) {
|
||||||
|
handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
|
||||||
|
handlerExp,
|
||||||
|
JSON.stringify(keyModifiers)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (eventOptionModifiers.length) {
|
||||||
|
const modifierPostfix = eventOptionModifiers.map(capitalize).join("");
|
||||||
|
key = isStaticExp(key) ? createSimpleExpression(`${key.content}${modifierPostfix}`, true) : createCompoundExpression([`(`, key, `) + "${modifierPostfix}"`]);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [createObjectProperty(key, handlerExp)]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformShow = (dir, node, context) => {
|
||||||
|
const { exp, loc } = dir;
|
||||||
|
if (!exp) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(61, loc)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: [],
|
||||||
|
needRuntime: context.helper(V_SHOW)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformTransition = (node, context) => {
|
||||||
|
if (node.type === 1 && node.tagType === 1) {
|
||||||
|
const component = context.isBuiltInComponent(node.tag);
|
||||||
|
if (component === TRANSITION) {
|
||||||
|
return () => {
|
||||||
|
if (!node.children.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (hasMultipleChildren(node)) {
|
||||||
|
context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
62,
|
||||||
|
{
|
||||||
|
start: node.children[0].loc.start,
|
||||||
|
end: node.children[node.children.length - 1].loc.end,
|
||||||
|
source: ""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const child = node.children[0];
|
||||||
|
if (child.type === 1) {
|
||||||
|
for (const p of child.props) {
|
||||||
|
if (p.type === 7 && p.name === "show") {
|
||||||
|
node.props.push({
|
||||||
|
type: 6,
|
||||||
|
name: "persisted",
|
||||||
|
nameLoc: node.loc,
|
||||||
|
value: void 0,
|
||||||
|
loc: node.loc
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
function hasMultipleChildren(node) {
|
||||||
|
const children = node.children = node.children.filter(
|
||||||
|
(c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
|
||||||
|
);
|
||||||
|
const child = children[0];
|
||||||
|
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ignoreSideEffectTags = (node, context) => {
|
||||||
|
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
||||||
|
!!(process.env.NODE_ENV !== "production") && context.onError(
|
||||||
|
createDOMCompilerError(
|
||||||
|
63,
|
||||||
|
node.loc
|
||||||
|
)
|
||||||
|
);
|
||||||
|
context.removeNode();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const DOMNodeTransforms = [
|
||||||
|
transformStyle,
|
||||||
|
...!!(process.env.NODE_ENV !== "production") ? [transformTransition] : []
|
||||||
|
];
|
||||||
|
const DOMDirectiveTransforms = {
|
||||||
|
cloak: noopDirectiveTransform,
|
||||||
|
html: transformVHtml,
|
||||||
|
text: transformVText,
|
||||||
|
model: transformModel,
|
||||||
|
// override compiler-core
|
||||||
|
on: transformOn,
|
||||||
|
// override compiler-core
|
||||||
|
show: transformShow
|
||||||
|
};
|
||||||
|
function compile(src, options = {}) {
|
||||||
|
return baseCompile(
|
||||||
|
src,
|
||||||
|
extend({}, parserOptions, options, {
|
||||||
|
nodeTransforms: [
|
||||||
|
// ignore <script> and <tag>
|
||||||
|
// this is not put inside DOMNodeTransforms because that list is used
|
||||||
|
// by compiler-ssr to generate vnode fallback branches
|
||||||
|
ignoreSideEffectTags,
|
||||||
|
...DOMNodeTransforms,
|
||||||
|
...options.nodeTransforms || []
|
||||||
|
],
|
||||||
|
directiveTransforms: extend(
|
||||||
|
{},
|
||||||
|
DOMDirectiveTransforms,
|
||||||
|
options.directiveTransforms || {}
|
||||||
|
),
|
||||||
|
transformHoist: null
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function parse(template, options = {}) {
|
||||||
|
return baseParse(template, extend({}, parserOptions, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
export { DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, TRANSITION, TRANSITION_GROUP, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, compile, createDOMCompilerError, parse, parserOptions, transformStyle };
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,7 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
module.exports = require('./dist/compiler-dom.cjs.prod.js')
|
||||||
|
} else {
|
||||||
|
module.exports = require('./dist/compiler-dom.cjs.js')
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
"name": "@vue/compiler-dom",
|
||||||
|
"version": "3.4.31",
|
||||||
|
"description": "@vue/compiler-dom",
|
||||||
|
"main": "index.js",
|
||||||
|
"module": "dist/compiler-dom.esm-bundler.js",
|
||||||
|
"types": "dist/compiler-dom.d.ts",
|
||||||
|
"unpkg": "dist/compiler-dom.global.js",
|
||||||
|
"jsdelivr": "dist/compiler-dom.global.js",
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/compiler-dom.d.ts",
|
||||||
|
"node": {
|
||||||
|
"production": "./dist/compiler-dom.cjs.prod.js",
|
||||||
|
"development": "./dist/compiler-dom.cjs.js",
|
||||||
|
"default": "./index.js"
|
||||||
|
},
|
||||||
|
"module": "./dist/compiler-dom.esm-bundler.js",
|
||||||
|
"import": "./dist/compiler-dom.esm-bundler.js",
|
||||||
|
"require": "./index.js"
|
||||||
|
},
|
||||||
|
"./*": "./*"
|
||||||
|
},
|
||||||
|
"sideEffects": false,
|
||||||
|
"buildOptions": {
|
||||||
|
"name": "VueCompilerDOM",
|
||||||
|
"compat": true,
|
||||||
|
"formats": [
|
||||||
|
"esm-bundler",
|
||||||
|
"esm-browser",
|
||||||
|
"cjs",
|
||||||
|
"global"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/vuejs/core.git",
|
||||||
|
"directory": "packages/compiler-dom"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
|
"author": "Evan You",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/vuejs/core/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-dom#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/shared": "3.4.31",
|
||||||
|
"@vue/compiler-core": "3.4.31"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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,80 @@
|
||||||
|
# @vue/compiler-sfc
|
||||||
|
|
||||||
|
> Lower level utilities for compiling Vue Single File Components
|
||||||
|
|
||||||
|
**Note: as of 3.2.13+, this package is included as a dependency of the main `vue` package and can be accessed as `vue/compiler-sfc`. This means you no longer need to explicitly install this package and ensure its version match that of `vue`'s. Just use the main `vue/compiler-sfc` deep import instead.**
|
||||||
|
|
||||||
|
This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader) and [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue).
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
The API is intentionally low-level due to the various considerations when integrating Vue SFCs in a build system:
|
||||||
|
|
||||||
|
- Separate hot-module replacement (HMR) for script, template and styles
|
||||||
|
|
||||||
|
- template updates should not reset component state
|
||||||
|
- style updates should be performed without component re-render
|
||||||
|
|
||||||
|
- Leveraging the tool's plugin system for pre-processor handling. e.g. `<style lang="scss">` should be processed by the corresponding webpack loader.
|
||||||
|
|
||||||
|
- In some cases, transformers of each block in an SFC do not share the same execution context. For example, when used with `thread-loader` or other parallelized configurations, the template sub-loader in `vue-loader` may not have access to the full SFC and its descriptor.
|
||||||
|
|
||||||
|
The general idea is to generate a facade module that imports the individual blocks of the component. The trick is the module imports itself with different query strings so that the build system can handle each request as "virtual" modules:
|
||||||
|
|
||||||
|
```
|
||||||
|
+--------------------+
|
||||||
|
| |
|
||||||
|
| script transform |
|
||||||
|
+----->+ |
|
||||||
|
| +--------------------+
|
||||||
|
|
|
||||||
|
+--------------------+ | +--------------------+
|
||||||
|
| | | | |
|
||||||
|
| facade transform +----------->+ template transform |
|
||||||
|
| | | | |
|
||||||
|
+--------------------+ | +--------------------+
|
||||||
|
|
|
||||||
|
| +--------------------+
|
||||||
|
+----->+ |
|
||||||
|
| style transform |
|
||||||
|
| |
|
||||||
|
+--------------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
Where the facade module looks like this:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// main script
|
||||||
|
import script from '/project/foo.vue?vue&type=script'
|
||||||
|
// template compiled to render function
|
||||||
|
import { render } from '/project/foo.vue?vue&type=template&id=xxxxxx'
|
||||||
|
// css
|
||||||
|
import '/project/foo.vue?vue&type=style&index=0&id=xxxxxx'
|
||||||
|
|
||||||
|
// attach render function to script
|
||||||
|
script.render = render
|
||||||
|
|
||||||
|
// attach additional metadata
|
||||||
|
// some of these should be dev only
|
||||||
|
script.__file = 'example.vue'
|
||||||
|
script.__scopeId = 'xxxxxx'
|
||||||
|
|
||||||
|
// additional tooling-specific HMR handling code
|
||||||
|
// using __VUE_HMR_API__ global
|
||||||
|
|
||||||
|
export default script
|
||||||
|
```
|
||||||
|
|
||||||
|
### High Level Workflow
|
||||||
|
|
||||||
|
1. In facade transform, parse the source into descriptor with the `parse` API and generate the above facade module code based on the descriptor;
|
||||||
|
|
||||||
|
2. In script transform, use `compileScript` to process the script. This handles features like `<script setup>` and CSS variable injection. Alternatively, this can be done directly in the facade module (with the code inlined instead of imported), but it will require rewriting `export default` to a temp variable (a `rewriteDefault` convenience API is provided for this purpose) so additional options can be attached to the exported object.
|
||||||
|
|
||||||
|
3. In template transform, use `compileTemplate` to compile the raw template into render function code.
|
||||||
|
|
||||||
|
4. In style transform, use `compileStyle` to compile raw CSS to handle `<style scoped>`, `<style module>` and CSS variable injection.
|
||||||
|
|
||||||
|
Options needed for these APIs can be passed via the query string.
|
||||||
|
|
||||||
|
For detailed API references and options, check out the source type definitions. For actual usage of these APIs, check out [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) or [vue-loader](https://github.com/vuejs/vue-loader/tree/next).
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,542 @@
|
||||||
|
import * as _babel_types from '@babel/types';
|
||||||
|
import { Statement, Expression, TSType, Node, Program, CallExpression, ObjectPattern, TSModuleDeclaration, TSPropertySignature, TSMethodSignature, TSCallSignatureDeclaration, TSFunctionType } from '@babel/types';
|
||||||
|
import { RootNode, CompilerOptions, CodegenResult, ParserOptions, CompilerError, RawSourceMap, SourceLocation, BindingMetadata as BindingMetadata$1 } from '@vue/compiler-core';
|
||||||
|
export { BindingMetadata, CompilerError, CompilerOptions, extractIdentifiers, generateCodeFrame, isInDestructureAssignment, isStaticProperty, walkIdentifiers } from '@vue/compiler-core';
|
||||||
|
import { ParserPlugin } from '@babel/parser';
|
||||||
|
export { parse as babelParse } from '@babel/parser';
|
||||||
|
import { Result, LazyResult } from 'postcss';
|
||||||
|
import MagicString from 'magic-string';
|
||||||
|
export { default as MagicString } from 'magic-string';
|
||||||
|
import TS from 'typescript';
|
||||||
|
|
||||||
|
export interface AssetURLTagConfig {
|
||||||
|
[name: string]: string[];
|
||||||
|
}
|
||||||
|
export interface AssetURLOptions {
|
||||||
|
/**
|
||||||
|
* If base is provided, instead of transforming relative asset urls into
|
||||||
|
* imports, they will be directly rewritten to absolute urls.
|
||||||
|
*/
|
||||||
|
base?: string | null;
|
||||||
|
/**
|
||||||
|
* If true, also processes absolute urls.
|
||||||
|
*/
|
||||||
|
includeAbsolute?: boolean;
|
||||||
|
tags?: AssetURLTagConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TemplateCompiler {
|
||||||
|
compile(source: string | RootNode, options: CompilerOptions): CodegenResult;
|
||||||
|
parse(template: string, options: ParserOptions): RootNode;
|
||||||
|
}
|
||||||
|
export interface SFCTemplateCompileResults {
|
||||||
|
code: string;
|
||||||
|
ast?: RootNode;
|
||||||
|
preamble?: string;
|
||||||
|
source: string;
|
||||||
|
tips: string[];
|
||||||
|
errors: (string | CompilerError)[];
|
||||||
|
map?: RawSourceMap;
|
||||||
|
}
|
||||||
|
export interface SFCTemplateCompileOptions {
|
||||||
|
source: string;
|
||||||
|
ast?: RootNode;
|
||||||
|
filename: string;
|
||||||
|
id: string;
|
||||||
|
scoped?: boolean;
|
||||||
|
slotted?: boolean;
|
||||||
|
isProd?: boolean;
|
||||||
|
ssr?: boolean;
|
||||||
|
ssrCssVars?: string[];
|
||||||
|
inMap?: RawSourceMap;
|
||||||
|
compiler?: TemplateCompiler;
|
||||||
|
compilerOptions?: CompilerOptions;
|
||||||
|
preprocessLang?: string;
|
||||||
|
preprocessOptions?: any;
|
||||||
|
/**
|
||||||
|
* In some cases, compiler-sfc may not be inside the project root (e.g. when
|
||||||
|
* linked or globally installed). In such cases a custom `require` can be
|
||||||
|
* passed to correctly resolve the preprocessors.
|
||||||
|
*/
|
||||||
|
preprocessCustomRequire?: (id: string) => any;
|
||||||
|
/**
|
||||||
|
* Configure what tags/attributes to transform into asset url imports,
|
||||||
|
* or disable the transform altogether with `false`.
|
||||||
|
*/
|
||||||
|
transformAssetUrls?: AssetURLOptions | AssetURLTagConfig | boolean;
|
||||||
|
}
|
||||||
|
export declare function compileTemplate(options: SFCTemplateCompileOptions): SFCTemplateCompileResults;
|
||||||
|
|
||||||
|
export interface SFCScriptCompileOptions {
|
||||||
|
/**
|
||||||
|
* Scope ID for prefixing injected CSS variables.
|
||||||
|
* This must be consistent with the `id` passed to `compileStyle`.
|
||||||
|
*/
|
||||||
|
id: string;
|
||||||
|
/**
|
||||||
|
* Production mode. Used to determine whether to generate hashed CSS variables
|
||||||
|
*/
|
||||||
|
isProd?: boolean;
|
||||||
|
/**
|
||||||
|
* Enable/disable source map. Defaults to true.
|
||||||
|
*/
|
||||||
|
sourceMap?: boolean;
|
||||||
|
/**
|
||||||
|
* https://babeljs.io/docs/en/babel-parser#plugins
|
||||||
|
*/
|
||||||
|
babelParserPlugins?: ParserPlugin[];
|
||||||
|
/**
|
||||||
|
* A list of files to parse for global types to be made available for type
|
||||||
|
* resolving in SFC macros. The list must be fully resolved file system paths.
|
||||||
|
*/
|
||||||
|
globalTypeFiles?: string[];
|
||||||
|
/**
|
||||||
|
* Compile the template and inline the resulting render function
|
||||||
|
* directly inside setup().
|
||||||
|
* - Only affects `<script setup>`
|
||||||
|
* - This should only be used in production because it prevents the template
|
||||||
|
* from being hot-reloaded separately from component state.
|
||||||
|
*/
|
||||||
|
inlineTemplate?: boolean;
|
||||||
|
/**
|
||||||
|
* Generate the final component as a variable instead of default export.
|
||||||
|
* This is useful in e.g. @vitejs/plugin-vue where the script needs to be
|
||||||
|
* placed inside the main module.
|
||||||
|
*/
|
||||||
|
genDefaultAs?: string;
|
||||||
|
/**
|
||||||
|
* Options for template compilation when inlining. Note these are options that
|
||||||
|
* would normally be passed to `compiler-sfc`'s own `compileTemplate()`, not
|
||||||
|
* options passed to `compiler-dom`.
|
||||||
|
*/
|
||||||
|
templateOptions?: Partial<SFCTemplateCompileOptions>;
|
||||||
|
/**
|
||||||
|
* Hoist <script setup> static constants.
|
||||||
|
* - Only enables when one `<script setup>` exists.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
hoistStatic?: boolean;
|
||||||
|
/**
|
||||||
|
* (**Experimental**) Enable reactive destructure for `defineProps`
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
propsDestructure?: boolean;
|
||||||
|
/**
|
||||||
|
* File system access methods to be used when resolving types
|
||||||
|
* imported in SFC macros. Defaults to ts.sys in Node.js, can be overwritten
|
||||||
|
* to use a virtual file system for use in browsers (e.g. in REPLs)
|
||||||
|
*/
|
||||||
|
fs?: {
|
||||||
|
fileExists(file: string): boolean;
|
||||||
|
readFile(file: string): string | undefined;
|
||||||
|
realpath?(file: string): string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Transform Vue SFCs into custom elements.
|
||||||
|
*/
|
||||||
|
customElement?: boolean | ((filename: string) => boolean);
|
||||||
|
}
|
||||||
|
interface ImportBinding {
|
||||||
|
isType: boolean;
|
||||||
|
imported: string;
|
||||||
|
local: string;
|
||||||
|
source: string;
|
||||||
|
isFromSetup: boolean;
|
||||||
|
isUsedInTemplate: boolean;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Compile `<script setup>`
|
||||||
|
* It requires the whole SFC descriptor because we need to handle and merge
|
||||||
|
* normal `<script>` + `<script setup>` if both are present.
|
||||||
|
*/
|
||||||
|
export declare function compileScript(sfc: SFCDescriptor, options: SFCScriptCompileOptions): SFCScriptBlock;
|
||||||
|
|
||||||
|
export interface SFCParseOptions {
|
||||||
|
filename?: string;
|
||||||
|
sourceMap?: boolean;
|
||||||
|
sourceRoot?: string;
|
||||||
|
pad?: boolean | 'line' | 'space';
|
||||||
|
ignoreEmpty?: boolean;
|
||||||
|
compiler?: TemplateCompiler;
|
||||||
|
templateParseOptions?: ParserOptions;
|
||||||
|
/**
|
||||||
|
* TODO remove in 3.5
|
||||||
|
* @deprecated use `templateParseOptions: { prefixIdentifiers: false }` instead
|
||||||
|
*/
|
||||||
|
parseExpressions?: boolean;
|
||||||
|
}
|
||||||
|
export interface SFCBlock {
|
||||||
|
type: string;
|
||||||
|
content: string;
|
||||||
|
attrs: Record<string, string | true>;
|
||||||
|
loc: SourceLocation;
|
||||||
|
map?: RawSourceMap;
|
||||||
|
lang?: string;
|
||||||
|
src?: string;
|
||||||
|
}
|
||||||
|
export interface SFCTemplateBlock extends SFCBlock {
|
||||||
|
type: 'template';
|
||||||
|
ast?: RootNode;
|
||||||
|
}
|
||||||
|
export interface SFCScriptBlock extends SFCBlock {
|
||||||
|
type: 'script';
|
||||||
|
setup?: string | boolean;
|
||||||
|
bindings?: BindingMetadata$1;
|
||||||
|
imports?: Record<string, ImportBinding>;
|
||||||
|
scriptAst?: _babel_types.Statement[];
|
||||||
|
scriptSetupAst?: _babel_types.Statement[];
|
||||||
|
warnings?: string[];
|
||||||
|
/**
|
||||||
|
* Fully resolved dependency file paths (unix slashes) with imported types
|
||||||
|
* used in macros, used for HMR cache busting in @vitejs/plugin-vue and
|
||||||
|
* vue-loader.
|
||||||
|
*/
|
||||||
|
deps?: string[];
|
||||||
|
}
|
||||||
|
export interface SFCStyleBlock extends SFCBlock {
|
||||||
|
type: 'style';
|
||||||
|
scoped?: boolean;
|
||||||
|
module?: string | boolean;
|
||||||
|
}
|
||||||
|
export interface SFCDescriptor {
|
||||||
|
filename: string;
|
||||||
|
source: string;
|
||||||
|
template: SFCTemplateBlock | null;
|
||||||
|
script: SFCScriptBlock | null;
|
||||||
|
scriptSetup: SFCScriptBlock | null;
|
||||||
|
styles: SFCStyleBlock[];
|
||||||
|
customBlocks: SFCBlock[];
|
||||||
|
cssVars: string[];
|
||||||
|
/**
|
||||||
|
* whether the SFC uses :slotted() modifier.
|
||||||
|
* this is used as a compiler optimization hint.
|
||||||
|
*/
|
||||||
|
slotted: boolean;
|
||||||
|
/**
|
||||||
|
* compare with an existing descriptor to determine whether HMR should perform
|
||||||
|
* a reload vs. re-render.
|
||||||
|
*
|
||||||
|
* Note: this comparison assumes the prev/next script are already identical,
|
||||||
|
* and only checks the special case where <script setup lang="ts"> unused import
|
||||||
|
* pruning result changes due to template changes.
|
||||||
|
*/
|
||||||
|
shouldForceReload: (prevImports: Record<string, ImportBinding>) => boolean;
|
||||||
|
}
|
||||||
|
export interface SFCParseResult {
|
||||||
|
descriptor: SFCDescriptor;
|
||||||
|
errors: (CompilerError | SyntaxError)[];
|
||||||
|
}
|
||||||
|
export declare function parse(source: string, options?: SFCParseOptions): SFCParseResult;
|
||||||
|
|
||||||
|
type PreprocessLang = 'less' | 'sass' | 'scss' | 'styl' | 'stylus';
|
||||||
|
|
||||||
|
export interface SFCStyleCompileOptions {
|
||||||
|
source: string;
|
||||||
|
filename: string;
|
||||||
|
id: string;
|
||||||
|
scoped?: boolean;
|
||||||
|
trim?: boolean;
|
||||||
|
isProd?: boolean;
|
||||||
|
inMap?: RawSourceMap;
|
||||||
|
preprocessLang?: PreprocessLang;
|
||||||
|
preprocessOptions?: any;
|
||||||
|
preprocessCustomRequire?: (id: string) => any;
|
||||||
|
postcssOptions?: any;
|
||||||
|
postcssPlugins?: any[];
|
||||||
|
/**
|
||||||
|
* @deprecated use `inMap` instead.
|
||||||
|
*/
|
||||||
|
map?: RawSourceMap;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Aligns with postcss-modules
|
||||||
|
* https://github.com/css-modules/postcss-modules
|
||||||
|
*/
|
||||||
|
interface CSSModulesOptions {
|
||||||
|
scopeBehaviour?: 'global' | 'local';
|
||||||
|
generateScopedName?: string | ((name: string, filename: string, css: string) => string);
|
||||||
|
hashPrefix?: string;
|
||||||
|
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
||||||
|
exportGlobals?: boolean;
|
||||||
|
globalModulePaths?: RegExp[];
|
||||||
|
}
|
||||||
|
export interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
|
||||||
|
isAsync?: boolean;
|
||||||
|
modules?: boolean;
|
||||||
|
modulesOptions?: CSSModulesOptions;
|
||||||
|
}
|
||||||
|
export interface SFCStyleCompileResults {
|
||||||
|
code: string;
|
||||||
|
map: RawSourceMap | undefined;
|
||||||
|
rawResult: Result | LazyResult | undefined;
|
||||||
|
errors: Error[];
|
||||||
|
modules?: Record<string, string>;
|
||||||
|
dependencies: Set<string>;
|
||||||
|
}
|
||||||
|
export declare function compileStyle(options: SFCStyleCompileOptions): SFCStyleCompileResults;
|
||||||
|
export declare function compileStyleAsync(options: SFCAsyncStyleCompileOptions): Promise<SFCStyleCompileResults>;
|
||||||
|
|
||||||
|
export declare function rewriteDefault(input: string, as: string, parserPlugins?: ParserPlugin[]): string;
|
||||||
|
/**
|
||||||
|
* Utility for rewriting `export default` in a script block into a variable
|
||||||
|
* declaration so that we can inject things into it
|
||||||
|
*/
|
||||||
|
export declare function rewriteDefaultAST(ast: Statement[], s: MagicString, as: string): void;
|
||||||
|
|
||||||
|
type PropsDestructureBindings = Record<string, // public prop key
|
||||||
|
{
|
||||||
|
local: string;
|
||||||
|
default?: Expression;
|
||||||
|
}>;
|
||||||
|
export declare function extractRuntimeProps(ctx: TypeResolveContext): string | undefined;
|
||||||
|
|
||||||
|
interface ModelDecl {
|
||||||
|
type: TSType | undefined;
|
||||||
|
options: string | undefined;
|
||||||
|
identifier: string | undefined;
|
||||||
|
runtimeOptionNodes: Node[];
|
||||||
|
}
|
||||||
|
|
||||||
|
declare enum BindingTypes {
|
||||||
|
/**
|
||||||
|
* returned from data()
|
||||||
|
*/
|
||||||
|
DATA = "data",
|
||||||
|
/**
|
||||||
|
* declared as a prop
|
||||||
|
*/
|
||||||
|
PROPS = "props",
|
||||||
|
/**
|
||||||
|
* a local alias of a `<script setup>` destructured prop.
|
||||||
|
* the original is stored in __propsAliases of the bindingMetadata object.
|
||||||
|
*/
|
||||||
|
PROPS_ALIASED = "props-aliased",
|
||||||
|
/**
|
||||||
|
* a let binding (may or may not be a ref)
|
||||||
|
*/
|
||||||
|
SETUP_LET = "setup-let",
|
||||||
|
/**
|
||||||
|
* a const binding that can never be a ref.
|
||||||
|
* these bindings don't need `unref()` calls when processed in inlined
|
||||||
|
* template expressions.
|
||||||
|
*/
|
||||||
|
SETUP_CONST = "setup-const",
|
||||||
|
/**
|
||||||
|
* a const binding that does not need `unref()`, but may be mutated.
|
||||||
|
*/
|
||||||
|
SETUP_REACTIVE_CONST = "setup-reactive-const",
|
||||||
|
/**
|
||||||
|
* a const binding that may be a ref.
|
||||||
|
*/
|
||||||
|
SETUP_MAYBE_REF = "setup-maybe-ref",
|
||||||
|
/**
|
||||||
|
* bindings that are guaranteed to be refs
|
||||||
|
*/
|
||||||
|
SETUP_REF = "setup-ref",
|
||||||
|
/**
|
||||||
|
* declared by other options, e.g. computed, inject
|
||||||
|
*/
|
||||||
|
OPTIONS = "options",
|
||||||
|
/**
|
||||||
|
* a literal constant, e.g. 'foo', 1, true
|
||||||
|
*/
|
||||||
|
LITERAL_CONST = "literal-const"
|
||||||
|
}
|
||||||
|
type BindingMetadata = {
|
||||||
|
[key: string]: BindingTypes | undefined;
|
||||||
|
} & {
|
||||||
|
__isScriptSetup?: boolean;
|
||||||
|
__propsAliases?: Record<string, string>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare class ScriptCompileContext {
|
||||||
|
descriptor: SFCDescriptor;
|
||||||
|
options: Partial<SFCScriptCompileOptions>;
|
||||||
|
isJS: boolean;
|
||||||
|
isTS: boolean;
|
||||||
|
isCE: boolean;
|
||||||
|
scriptAst: Program | null;
|
||||||
|
scriptSetupAst: Program | null;
|
||||||
|
source: string;
|
||||||
|
filename: string;
|
||||||
|
s: MagicString;
|
||||||
|
startOffset: number | undefined;
|
||||||
|
endOffset: number | undefined;
|
||||||
|
scope?: TypeScope;
|
||||||
|
globalScopes?: TypeScope[];
|
||||||
|
userImports: Record<string, ImportBinding>;
|
||||||
|
hasDefinePropsCall: boolean;
|
||||||
|
hasDefineEmitCall: boolean;
|
||||||
|
hasDefineExposeCall: boolean;
|
||||||
|
hasDefaultExportName: boolean;
|
||||||
|
hasDefaultExportRender: boolean;
|
||||||
|
hasDefineOptionsCall: boolean;
|
||||||
|
hasDefineSlotsCall: boolean;
|
||||||
|
hasDefineModelCall: boolean;
|
||||||
|
propsCall: CallExpression | undefined;
|
||||||
|
propsDecl: Node | undefined;
|
||||||
|
propsRuntimeDecl: Node | undefined;
|
||||||
|
propsTypeDecl: Node | undefined;
|
||||||
|
propsDestructureDecl: ObjectPattern | undefined;
|
||||||
|
propsDestructuredBindings: PropsDestructureBindings;
|
||||||
|
propsDestructureRestId: string | undefined;
|
||||||
|
propsRuntimeDefaults: Node | undefined;
|
||||||
|
emitsRuntimeDecl: Node | undefined;
|
||||||
|
emitsTypeDecl: Node | undefined;
|
||||||
|
emitDecl: Node | undefined;
|
||||||
|
modelDecls: Record<string, ModelDecl>;
|
||||||
|
optionsRuntimeDecl: Node | undefined;
|
||||||
|
bindingMetadata: BindingMetadata;
|
||||||
|
helperImports: Set<string>;
|
||||||
|
helper(key: string): string;
|
||||||
|
/**
|
||||||
|
* to be exposed on compiled script block for HMR cache busting
|
||||||
|
*/
|
||||||
|
deps?: Set<string>;
|
||||||
|
/**
|
||||||
|
* cache for resolved fs
|
||||||
|
*/
|
||||||
|
fs?: NonNullable<SFCScriptCompileOptions['fs']>;
|
||||||
|
constructor(descriptor: SFCDescriptor, options: Partial<SFCScriptCompileOptions>);
|
||||||
|
getString(node: Node, scriptSetup?: boolean): string;
|
||||||
|
error(msg: string, node: Node, scope?: TypeScope): never;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SimpleTypeResolveOptions = Partial<Pick<SFCScriptCompileOptions, 'globalTypeFiles' | 'fs' | 'babelParserPlugins' | 'isProd'>>;
|
||||||
|
/**
|
||||||
|
* TypeResolveContext is compatible with ScriptCompileContext
|
||||||
|
* but also allows a simpler version of it with minimal required properties
|
||||||
|
* when resolveType needs to be used in a non-SFC context, e.g. in a babel
|
||||||
|
* plugin. The simplest context can be just:
|
||||||
|
* ```ts
|
||||||
|
* const ctx: SimpleTypeResolveContext = {
|
||||||
|
* filename: '...',
|
||||||
|
* source: '...',
|
||||||
|
* options: {},
|
||||||
|
* error() {},
|
||||||
|
* ast: []
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export type SimpleTypeResolveContext = Pick<ScriptCompileContext, 'source' | 'filename' | 'error' | 'helper' | 'getString' | 'propsTypeDecl' | 'propsRuntimeDefaults' | 'propsDestructuredBindings' | 'emitsTypeDecl' | 'isCE'> & Partial<Pick<ScriptCompileContext, 'scope' | 'globalScopes' | 'deps' | 'fs'>> & {
|
||||||
|
ast: Statement[];
|
||||||
|
options: SimpleTypeResolveOptions;
|
||||||
|
};
|
||||||
|
export type TypeResolveContext = ScriptCompileContext | SimpleTypeResolveContext;
|
||||||
|
type Import = Pick<ImportBinding, 'source' | 'imported'>;
|
||||||
|
interface WithScope {
|
||||||
|
_ownerScope: TypeScope;
|
||||||
|
}
|
||||||
|
type ScopeTypeNode = Node & WithScope & {
|
||||||
|
_ns?: TSModuleDeclaration & WithScope;
|
||||||
|
};
|
||||||
|
declare class TypeScope {
|
||||||
|
filename: string;
|
||||||
|
source: string;
|
||||||
|
offset: number;
|
||||||
|
imports: Record<string, Import>;
|
||||||
|
types: Record<string, ScopeTypeNode>;
|
||||||
|
declares: Record<string, ScopeTypeNode>;
|
||||||
|
constructor(filename: string, source: string, offset?: number, imports?: Record<string, Import>, types?: Record<string, ScopeTypeNode>, declares?: Record<string, ScopeTypeNode>);
|
||||||
|
isGenericScope: boolean;
|
||||||
|
resolvedImportSources: Record<string, string>;
|
||||||
|
exportedTypes: Record<string, ScopeTypeNode>;
|
||||||
|
exportedDeclares: Record<string, ScopeTypeNode>;
|
||||||
|
}
|
||||||
|
interface MaybeWithScope {
|
||||||
|
_ownerScope?: TypeScope;
|
||||||
|
}
|
||||||
|
interface ResolvedElements {
|
||||||
|
props: Record<string, (TSPropertySignature | TSMethodSignature) & {
|
||||||
|
_ownerScope: TypeScope;
|
||||||
|
}>;
|
||||||
|
calls?: (TSCallSignatureDeclaration | TSFunctionType)[];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Resolve arbitrary type node to a list of type elements that can be then
|
||||||
|
* mapped to runtime props or emits.
|
||||||
|
*/
|
||||||
|
export declare function resolveTypeElements(ctx: TypeResolveContext, node: Node & MaybeWithScope & {
|
||||||
|
_resolvedElements?: ResolvedElements;
|
||||||
|
}, scope?: TypeScope, typeParameters?: Record<string, Node>): ResolvedElements;
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export declare function registerTS(_loadTS: () => typeof TS): void;
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
export declare function invalidateTypeCache(filename: string): void;
|
||||||
|
export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & MaybeWithScope, scope?: TypeScope, isKeyOf?: boolean): string[];
|
||||||
|
|
||||||
|
export declare function extractRuntimeEmits(ctx: TypeResolveContext): Set<string>;
|
||||||
|
|
||||||
|
export declare const version: string;
|
||||||
|
|
||||||
|
export declare const parseCache: Map<string, SFCParseResult>;
|
||||||
|
export declare const errorMessages: {
|
||||||
|
0: string;
|
||||||
|
1: string;
|
||||||
|
2: string;
|
||||||
|
3: string;
|
||||||
|
4: string;
|
||||||
|
5: string;
|
||||||
|
6: string;
|
||||||
|
7: string;
|
||||||
|
8: string;
|
||||||
|
9: string;
|
||||||
|
10: string;
|
||||||
|
11: string;
|
||||||
|
12: string;
|
||||||
|
13: string;
|
||||||
|
14: string;
|
||||||
|
15: string;
|
||||||
|
16: string;
|
||||||
|
17: string;
|
||||||
|
18: string;
|
||||||
|
19: string;
|
||||||
|
20: string;
|
||||||
|
21: string;
|
||||||
|
22: string;
|
||||||
|
23: string;
|
||||||
|
24: string;
|
||||||
|
25: string;
|
||||||
|
26: string;
|
||||||
|
27: string;
|
||||||
|
28: string;
|
||||||
|
29: string;
|
||||||
|
30: string;
|
||||||
|
31: string;
|
||||||
|
32: string;
|
||||||
|
33: string;
|
||||||
|
34: string;
|
||||||
|
35: string;
|
||||||
|
36: string;
|
||||||
|
37: string;
|
||||||
|
38: string;
|
||||||
|
39: string;
|
||||||
|
40: string;
|
||||||
|
41: string;
|
||||||
|
42: string;
|
||||||
|
43: string;
|
||||||
|
44: string;
|
||||||
|
45: string;
|
||||||
|
46: string;
|
||||||
|
47: string;
|
||||||
|
48: string;
|
||||||
|
49: string;
|
||||||
|
50: string;
|
||||||
|
51: string;
|
||||||
|
52: string;
|
||||||
|
53: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare const walk: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated this is preserved to avoid breaking vite-plugin-vue < 5.0
|
||||||
|
* with reactivityTransform: true. The desired behavior should be silently
|
||||||
|
* ignoring the option instead of breaking.
|
||||||
|
*/
|
||||||
|
export declare const shouldTransformRef: () => boolean;
|
||||||
|
|
||||||
48447
node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js
generated
vendored
Normal file
48447
node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,67 @@
|
||||||
|
{
|
||||||
|
"name": "@vue/compiler-sfc",
|
||||||
|
"version": "3.4.31",
|
||||||
|
"description": "@vue/compiler-sfc",
|
||||||
|
"main": "dist/compiler-sfc.cjs.js",
|
||||||
|
"module": "dist/compiler-sfc.esm-browser.js",
|
||||||
|
"types": "dist/compiler-sfc.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/compiler-sfc.d.ts",
|
||||||
|
"node": "./dist/compiler-sfc.cjs.js",
|
||||||
|
"module": "./dist/compiler-sfc.esm-browser.js",
|
||||||
|
"import": "./dist/compiler-sfc.esm-browser.js",
|
||||||
|
"require": "./dist/compiler-sfc.cjs.js"
|
||||||
|
},
|
||||||
|
"./*": "./*"
|
||||||
|
},
|
||||||
|
"buildOptions": {
|
||||||
|
"name": "VueCompilerSFC",
|
||||||
|
"formats": [
|
||||||
|
"cjs",
|
||||||
|
"esm-browser"
|
||||||
|
],
|
||||||
|
"prod": false,
|
||||||
|
"enableNonBrowserBranches": true
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/vuejs/core.git",
|
||||||
|
"directory": "packages/compiler-sfc"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
|
"author": "Evan You",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/vuejs/core/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/parser": "^7.24.7",
|
||||||
|
"estree-walker": "^2.0.2",
|
||||||
|
"magic-string": "^0.30.10",
|
||||||
|
"postcss": "^8.4.38",
|
||||||
|
"source-map-js": "^1.2.0",
|
||||||
|
"@vue/compiler-core": "3.4.31",
|
||||||
|
"@vue/compiler-ssr": "3.4.31",
|
||||||
|
"@vue/compiler-dom": "3.4.31",
|
||||||
|
"@vue/shared": "3.4.31"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/types": "^7.24.7",
|
||||||
|
"@vue/consolidate": "^1.0.0",
|
||||||
|
"hash-sum": "^2.0.0",
|
||||||
|
"lru-cache": "10.1.0",
|
||||||
|
"merge-source-map": "^1.1.0",
|
||||||
|
"minimatch": "^9.0.4",
|
||||||
|
"postcss-modules": "^6.0.0",
|
||||||
|
"postcss-selector-parser": "^6.1.0",
|
||||||
|
"pug": "^3.0.3",
|
||||||
|
"sass": "^1.77.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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/compiler-ssr
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,4 @@
|
||||||
|
import { RootNode, CompilerOptions, CodegenResult } from '@vue/compiler-dom';
|
||||||
|
|
||||||
|
export declare function compile(source: string | RootNode, options?: CompilerOptions): CodegenResult;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"name": "@vue/compiler-ssr",
|
||||||
|
"version": "3.4.31",
|
||||||
|
"description": "@vue/compiler-ssr",
|
||||||
|
"main": "dist/compiler-ssr.cjs.js",
|
||||||
|
"types": "dist/compiler-ssr.d.ts",
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"buildOptions": {
|
||||||
|
"prod": false,
|
||||||
|
"formats": [
|
||||||
|
"cjs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/vuejs/core.git",
|
||||||
|
"directory": "packages/compiler-ssr"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"vue"
|
||||||
|
],
|
||||||
|
"author": "Evan You",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/vuejs/core/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-ssr#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"@vue/shared": "3.4.31",
|
||||||
|
"@vue/compiler-dom": "3.4.31"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||||
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
__exportStar(require("./api.js"), exports);
|
||||||
|
__exportStar(require("./app.js"), exports);
|
||||||
|
__exportStar(require("./component.js"), exports);
|
||||||
|
__exportStar(require("./context.js"), exports);
|
||||||
|
__exportStar(require("./hooks.js"), exports);
|
||||||
|
__exportStar(require("./util.js"), exports);
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.HOOK_PLUGIN_SETTINGS_SET = exports.HOOK_SETUP = void 0;
|
||||||
|
exports.HOOK_SETUP = 'devtools-plugin:setup';
|
||||||
|
exports.HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set';
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.isProxyAvailable = exports.getTarget = exports.getDevtoolsGlobalHook = void 0;
|
||||||
|
function getDevtoolsGlobalHook() {
|
||||||
|
return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
||||||
|
}
|
||||||
|
exports.getDevtoolsGlobalHook = getDevtoolsGlobalHook;
|
||||||
|
function getTarget() {
|
||||||
|
// @ts-expect-error navigator and windows are not available in all environments
|
||||||
|
return (typeof navigator !== 'undefined' && typeof window !== 'undefined')
|
||||||
|
? window
|
||||||
|
: typeof globalThis !== 'undefined'
|
||||||
|
? globalThis
|
||||||
|
: {};
|
||||||
|
}
|
||||||
|
exports.getTarget = getTarget;
|
||||||
|
exports.isProxyAvailable = typeof Proxy === 'function';
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||||
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.setupDevtoolsPlugin = void 0;
|
||||||
|
const env_js_1 = require("./env.js");
|
||||||
|
const const_js_1 = require("./const.js");
|
||||||
|
const proxy_js_1 = require("./proxy.js");
|
||||||
|
__exportStar(require("./api/index.js"), exports);
|
||||||
|
__exportStar(require("./plugin.js"), exports);
|
||||||
|
__exportStar(require("./time.js"), exports);
|
||||||
|
function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
|
||||||
|
const descriptor = pluginDescriptor;
|
||||||
|
const target = (0, env_js_1.getTarget)();
|
||||||
|
const hook = (0, env_js_1.getDevtoolsGlobalHook)();
|
||||||
|
const enableProxy = env_js_1.isProxyAvailable && descriptor.enableEarlyProxy;
|
||||||
|
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
|
||||||
|
hook.emit(const_js_1.HOOK_SETUP, pluginDescriptor, setupFn);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const proxy = enableProxy ? new proxy_js_1.ApiProxy(descriptor, hook) : null;
|
||||||
|
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
|
||||||
|
list.push({
|
||||||
|
pluginDescriptor: descriptor,
|
||||||
|
setupFn,
|
||||||
|
proxy,
|
||||||
|
});
|
||||||
|
if (proxy) {
|
||||||
|
setupFn(proxy.proxiedTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.setupDevtoolsPlugin = setupDevtoolsPlugin;
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.ApiProxy = void 0;
|
||||||
|
const const_js_1 = require("./const.js");
|
||||||
|
const time_js_1 = require("./time.js");
|
||||||
|
class ApiProxy {
|
||||||
|
constructor(plugin, hook) {
|
||||||
|
this.target = null;
|
||||||
|
this.targetQueue = [];
|
||||||
|
this.onQueue = [];
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.hook = hook;
|
||||||
|
const defaultSettings = {};
|
||||||
|
if (plugin.settings) {
|
||||||
|
for (const id in plugin.settings) {
|
||||||
|
const item = plugin.settings[id];
|
||||||
|
defaultSettings[id] = item.defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`;
|
||||||
|
let currentSettings = Object.assign({}, defaultSettings);
|
||||||
|
try {
|
||||||
|
const raw = localStorage.getItem(localSettingsSaveId);
|
||||||
|
const data = JSON.parse(raw);
|
||||||
|
Object.assign(currentSettings, data);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
this.fallbacks = {
|
||||||
|
getSettings() {
|
||||||
|
return currentSettings;
|
||||||
|
},
|
||||||
|
setSettings(value) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(localSettingsSaveId, JSON.stringify(value));
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
currentSettings = value;
|
||||||
|
},
|
||||||
|
now() {
|
||||||
|
return (0, time_js_1.now)();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (hook) {
|
||||||
|
hook.on(const_js_1.HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => {
|
||||||
|
if (pluginId === this.plugin.id) {
|
||||||
|
this.fallbacks.setSettings(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.proxiedOn = new Proxy({}, {
|
||||||
|
get: (_target, prop) => {
|
||||||
|
if (this.target) {
|
||||||
|
return this.target.on[prop];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (...args) => {
|
||||||
|
this.onQueue.push({
|
||||||
|
method: prop,
|
||||||
|
args,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.proxiedTarget = new Proxy({}, {
|
||||||
|
get: (_target, prop) => {
|
||||||
|
if (this.target) {
|
||||||
|
return this.target[prop];
|
||||||
|
}
|
||||||
|
else if (prop === 'on') {
|
||||||
|
return this.proxiedOn;
|
||||||
|
}
|
||||||
|
else if (Object.keys(this.fallbacks).includes(prop)) {
|
||||||
|
return (...args) => {
|
||||||
|
this.targetQueue.push({
|
||||||
|
method: prop,
|
||||||
|
args,
|
||||||
|
resolve: () => { },
|
||||||
|
});
|
||||||
|
return this.fallbacks[prop](...args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (...args) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
this.targetQueue.push({
|
||||||
|
method: prop,
|
||||||
|
args,
|
||||||
|
resolve,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async setRealTarget(target) {
|
||||||
|
this.target = target;
|
||||||
|
for (const item of this.onQueue) {
|
||||||
|
this.target.on[item.method](...item.args);
|
||||||
|
}
|
||||||
|
for (const item of this.targetQueue) {
|
||||||
|
item.resolve(await this.target[item.method](...item.args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.ApiProxy = ApiProxy;
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.now = exports.isPerformanceSupported = void 0;
|
||||||
|
let supported;
|
||||||
|
let perf;
|
||||||
|
function isPerformanceSupported() {
|
||||||
|
var _a;
|
||||||
|
if (supported !== undefined) {
|
||||||
|
return supported;
|
||||||
|
}
|
||||||
|
if (typeof window !== 'undefined' && window.performance) {
|
||||||
|
supported = true;
|
||||||
|
perf = window.performance;
|
||||||
|
}
|
||||||
|
else if (typeof globalThis !== 'undefined' && ((_a = globalThis.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) {
|
||||||
|
supported = true;
|
||||||
|
perf = globalThis.perf_hooks.performance;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
supported = false;
|
||||||
|
}
|
||||||
|
return supported;
|
||||||
|
}
|
||||||
|
exports.isPerformanceSupported = isPerformanceSupported;
|
||||||
|
function now() {
|
||||||
|
return isPerformanceSupported() ? perf.now() : Date.now();
|
||||||
|
}
|
||||||
|
exports.now = now;
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
import type { ComponentBounds, Hookable } from './hooks.js';
|
||||||
|
import type { Context } from './context.js';
|
||||||
|
import type { ComponentInstance, ComponentState, StateBase } from './component.js';
|
||||||
|
import type { App } from './app.js';
|
||||||
|
import type { ID } from './util.js';
|
||||||
|
export interface DevtoolsPluginApi<TSettings> {
|
||||||
|
on: Hookable<Context>;
|
||||||
|
notifyComponentUpdate: (instance?: ComponentInstance) => void;
|
||||||
|
addTimelineLayer: (options: TimelineLayerOptions) => void;
|
||||||
|
addTimelineEvent: (options: TimelineEventOptions) => void;
|
||||||
|
addInspector: (options: CustomInspectorOptions) => void;
|
||||||
|
sendInspectorTree: (inspectorId: string) => void;
|
||||||
|
sendInspectorState: (inspectorId: string) => void;
|
||||||
|
selectInspectorNode: (inspectorId: string, nodeId: string) => void;
|
||||||
|
getComponentBounds: (instance: ComponentInstance) => Promise<ComponentBounds>;
|
||||||
|
getComponentName: (instance: ComponentInstance) => Promise<string>;
|
||||||
|
getComponentInstances: (app: App) => Promise<ComponentInstance[]>;
|
||||||
|
highlightElement: (instance: ComponentInstance) => void;
|
||||||
|
unhighlightElement: () => void;
|
||||||
|
getSettings: (pluginId?: string) => TSettings;
|
||||||
|
now: () => number;
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
setSettings: (values: TSettings) => void;
|
||||||
|
}
|
||||||
|
export interface AppRecord {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
instanceMap: Map<string, ComponentInstance>;
|
||||||
|
rootInstance: ComponentInstance;
|
||||||
|
}
|
||||||
|
export interface TimelineLayerOptions<TData = any, TMeta = any> {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
color: number;
|
||||||
|
skipScreenshots?: boolean;
|
||||||
|
groupsOnly?: boolean;
|
||||||
|
ignoreNoDurationGroups?: boolean;
|
||||||
|
screenshotOverlayRender?: (event: TimelineEvent<TData, TMeta> & ScreenshotOverlayEvent, ctx: ScreenshotOverlayRenderContext) => ScreenshotOverlayRenderResult | Promise<ScreenshotOverlayRenderResult>;
|
||||||
|
}
|
||||||
|
export interface ScreenshotOverlayEvent {
|
||||||
|
layerId: string;
|
||||||
|
renderMeta: any;
|
||||||
|
}
|
||||||
|
export interface ScreenshotOverlayRenderContext<TData = any, TMeta = any> {
|
||||||
|
screenshot: ScreenshotData;
|
||||||
|
events: (TimelineEvent<TData, TMeta> & ScreenshotOverlayEvent)[];
|
||||||
|
index: number;
|
||||||
|
}
|
||||||
|
export type ScreenshotOverlayRenderResult = HTMLElement | string | false;
|
||||||
|
export interface ScreenshotData {
|
||||||
|
time: number;
|
||||||
|
}
|
||||||
|
export interface TimelineEventOptions {
|
||||||
|
layerId: string;
|
||||||
|
event: TimelineEvent;
|
||||||
|
all?: boolean;
|
||||||
|
}
|
||||||
|
export interface TimelineEvent<TData = any, TMeta = any> {
|
||||||
|
time: number;
|
||||||
|
data: TData;
|
||||||
|
logType?: 'default' | 'warning' | 'error';
|
||||||
|
meta?: TMeta;
|
||||||
|
groupId?: ID;
|
||||||
|
title?: string;
|
||||||
|
subtitle?: string;
|
||||||
|
}
|
||||||
|
export interface TimelineMarkerOptions {
|
||||||
|
id: string;
|
||||||
|
time: number;
|
||||||
|
color: number;
|
||||||
|
label: string;
|
||||||
|
all?: boolean;
|
||||||
|
}
|
||||||
|
export interface CustomInspectorOptions {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
icon?: string;
|
||||||
|
treeFilterPlaceholder?: string;
|
||||||
|
stateFilterPlaceholder?: string;
|
||||||
|
noSelectionText?: string;
|
||||||
|
actions?: {
|
||||||
|
icon: string;
|
||||||
|
tooltip?: string;
|
||||||
|
action: () => void | Promise<void>;
|
||||||
|
}[];
|
||||||
|
nodeActions?: {
|
||||||
|
icon: string;
|
||||||
|
tooltip?: string;
|
||||||
|
action: (nodeId: string) => void | Promise<void>;
|
||||||
|
}[];
|
||||||
|
}
|
||||||
|
export interface CustomInspectorNode {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
children?: CustomInspectorNode[];
|
||||||
|
tags?: InspectorNodeTag[];
|
||||||
|
}
|
||||||
|
export interface InspectorNodeTag {
|
||||||
|
label: string;
|
||||||
|
textColor: number;
|
||||||
|
backgroundColor: number;
|
||||||
|
tooltip?: string;
|
||||||
|
}
|
||||||
|
export interface CustomInspectorState {
|
||||||
|
[key: string]: (StateBase | Omit<ComponentState, 'type'>)[];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export type App = any;
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
import type { InspectorNodeTag } from './api.js';
|
||||||
|
import type { ID } from './util.js';
|
||||||
|
export type ComponentInstance = any;
|
||||||
|
export interface ComponentTreeNode {
|
||||||
|
uid: ID;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
renderKey: string | number;
|
||||||
|
inactive: boolean;
|
||||||
|
isFragment: boolean;
|
||||||
|
hasChildren: boolean;
|
||||||
|
children: ComponentTreeNode[];
|
||||||
|
domOrder?: number[];
|
||||||
|
consoleId?: string;
|
||||||
|
isRouterView?: boolean;
|
||||||
|
macthedRouteSegment?: string;
|
||||||
|
tags: InspectorNodeTag[];
|
||||||
|
autoOpen: boolean;
|
||||||
|
meta?: any;
|
||||||
|
}
|
||||||
|
export interface InspectedComponentData {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
file: string;
|
||||||
|
state: ComponentState[];
|
||||||
|
functional?: boolean;
|
||||||
|
}
|
||||||
|
export interface StateBase {
|
||||||
|
key: string;
|
||||||
|
value: any;
|
||||||
|
editable?: boolean;
|
||||||
|
objectType?: 'ref' | 'reactive' | 'computed' | 'other';
|
||||||
|
raw?: string;
|
||||||
|
}
|
||||||
|
export interface ComponentStateBase extends StateBase {
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
|
export interface ComponentPropState extends ComponentStateBase {
|
||||||
|
meta?: {
|
||||||
|
type: string;
|
||||||
|
required: boolean;
|
||||||
|
/** Vue 1 only */
|
||||||
|
mode?: 'default' | 'sync' | 'once';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export type ComponentBuiltinCustomStateTypes = 'function' | 'map' | 'set' | 'reference' | 'component' | 'component-definition' | 'router' | 'store';
|
||||||
|
export interface ComponentCustomState extends ComponentStateBase {
|
||||||
|
value: CustomState;
|
||||||
|
}
|
||||||
|
export interface CustomState {
|
||||||
|
_custom: {
|
||||||
|
type: ComponentBuiltinCustomStateTypes | string;
|
||||||
|
objectType?: string;
|
||||||
|
display?: string;
|
||||||
|
tooltip?: string;
|
||||||
|
value?: any;
|
||||||
|
abstract?: boolean;
|
||||||
|
file?: string;
|
||||||
|
uid?: number;
|
||||||
|
readOnly?: boolean;
|
||||||
|
/** Configure immediate child fields */
|
||||||
|
fields?: {
|
||||||
|
abstract?: boolean;
|
||||||
|
};
|
||||||
|
id?: any;
|
||||||
|
actions?: {
|
||||||
|
icon: string;
|
||||||
|
tooltip?: string;
|
||||||
|
action: () => void | Promise<void>;
|
||||||
|
}[];
|
||||||
|
/** internal */
|
||||||
|
_reviveId?: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export type ComponentState = ComponentStateBase | ComponentPropState | ComponentCustomState;
|
||||||
|
export interface ComponentDevtoolsOptions {
|
||||||
|
hide?: boolean;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import type { AppRecord } from './api.js';
|
||||||
|
export interface Context {
|
||||||
|
currentTab: string;
|
||||||
|
currentAppRecord: AppRecord;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,180 @@
|
||||||
|
import type { ComponentDevtoolsOptions, ComponentInstance, ComponentTreeNode, InspectedComponentData } from './component.js';
|
||||||
|
import type { App } from './app.js';
|
||||||
|
import type { CustomInspectorNode, CustomInspectorState, TimelineEvent } from './api.js';
|
||||||
|
export declare const enum Hooks {
|
||||||
|
TRANSFORM_CALL = "transformCall",
|
||||||
|
GET_APP_RECORD_NAME = "getAppRecordName",
|
||||||
|
GET_APP_ROOT_INSTANCE = "getAppRootInstance",
|
||||||
|
REGISTER_APPLICATION = "registerApplication",
|
||||||
|
WALK_COMPONENT_TREE = "walkComponentTree",
|
||||||
|
VISIT_COMPONENT_TREE = "visitComponentTree",
|
||||||
|
WALK_COMPONENT_PARENTS = "walkComponentParents",
|
||||||
|
INSPECT_COMPONENT = "inspectComponent",
|
||||||
|
GET_COMPONENT_BOUNDS = "getComponentBounds",
|
||||||
|
GET_COMPONENT_NAME = "getComponentName",
|
||||||
|
GET_COMPONENT_INSTANCES = "getComponentInstances",
|
||||||
|
GET_ELEMENT_COMPONENT = "getElementComponent",
|
||||||
|
GET_COMPONENT_ROOT_ELEMENTS = "getComponentRootElements",
|
||||||
|
EDIT_COMPONENT_STATE = "editComponentState",
|
||||||
|
GET_COMPONENT_DEVTOOLS_OPTIONS = "getAppDevtoolsOptions",
|
||||||
|
GET_COMPONENT_RENDER_CODE = "getComponentRenderCode",
|
||||||
|
INSPECT_TIMELINE_EVENT = "inspectTimelineEvent",
|
||||||
|
TIMELINE_CLEARED = "timelineCleared",
|
||||||
|
GET_INSPECTOR_TREE = "getInspectorTree",
|
||||||
|
GET_INSPECTOR_STATE = "getInspectorState",
|
||||||
|
EDIT_INSPECTOR_STATE = "editInspectorState",
|
||||||
|
SET_PLUGIN_SETTINGS = "setPluginSettings"
|
||||||
|
}
|
||||||
|
export interface ComponentBounds {
|
||||||
|
left: number;
|
||||||
|
top: number;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
}
|
||||||
|
export interface HookPayloads {
|
||||||
|
[Hooks.TRANSFORM_CALL]: {
|
||||||
|
callName: string;
|
||||||
|
inArgs: any[];
|
||||||
|
outArgs: any[];
|
||||||
|
};
|
||||||
|
[Hooks.GET_APP_RECORD_NAME]: {
|
||||||
|
app: App;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
[Hooks.GET_APP_ROOT_INSTANCE]: {
|
||||||
|
app: App;
|
||||||
|
root: ComponentInstance;
|
||||||
|
};
|
||||||
|
[Hooks.REGISTER_APPLICATION]: {
|
||||||
|
app: App;
|
||||||
|
};
|
||||||
|
[Hooks.WALK_COMPONENT_TREE]: {
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
componentTreeData: ComponentTreeNode[];
|
||||||
|
maxDepth: number;
|
||||||
|
filter: string;
|
||||||
|
recursively: boolean;
|
||||||
|
};
|
||||||
|
[Hooks.VISIT_COMPONENT_TREE]: {
|
||||||
|
app: App;
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
treeNode: ComponentTreeNode;
|
||||||
|
filter: string;
|
||||||
|
};
|
||||||
|
[Hooks.WALK_COMPONENT_PARENTS]: {
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
parentInstances: ComponentInstance[];
|
||||||
|
};
|
||||||
|
[Hooks.INSPECT_COMPONENT]: {
|
||||||
|
app: App;
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
instanceData: InspectedComponentData;
|
||||||
|
};
|
||||||
|
[Hooks.GET_COMPONENT_BOUNDS]: {
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
bounds: ComponentBounds;
|
||||||
|
};
|
||||||
|
[Hooks.GET_COMPONENT_NAME]: {
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
|
[Hooks.GET_COMPONENT_INSTANCES]: {
|
||||||
|
app: App;
|
||||||
|
componentInstances: ComponentInstance[];
|
||||||
|
};
|
||||||
|
[Hooks.GET_ELEMENT_COMPONENT]: {
|
||||||
|
element: HTMLElement | any;
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
};
|
||||||
|
[Hooks.GET_COMPONENT_ROOT_ELEMENTS]: {
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
rootElements: (HTMLElement | any)[];
|
||||||
|
};
|
||||||
|
[Hooks.EDIT_COMPONENT_STATE]: {
|
||||||
|
app: App;
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
path: string[];
|
||||||
|
type: string;
|
||||||
|
state: EditStatePayload;
|
||||||
|
set: (object: any, path?: string | (string[]), value?: any, cb?: (object: any, field: string, value: any) => void) => void;
|
||||||
|
};
|
||||||
|
[Hooks.GET_COMPONENT_DEVTOOLS_OPTIONS]: {
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
options: ComponentDevtoolsOptions;
|
||||||
|
};
|
||||||
|
[Hooks.GET_COMPONENT_RENDER_CODE]: {
|
||||||
|
componentInstance: ComponentInstance;
|
||||||
|
code: string;
|
||||||
|
};
|
||||||
|
[Hooks.INSPECT_TIMELINE_EVENT]: {
|
||||||
|
app: App;
|
||||||
|
layerId: string;
|
||||||
|
event: TimelineEvent;
|
||||||
|
all?: boolean;
|
||||||
|
data: any;
|
||||||
|
};
|
||||||
|
[Hooks.TIMELINE_CLEARED]: Record<string, never>;
|
||||||
|
[Hooks.GET_INSPECTOR_TREE]: {
|
||||||
|
app: App;
|
||||||
|
inspectorId: string;
|
||||||
|
filter: string;
|
||||||
|
rootNodes: CustomInspectorNode[];
|
||||||
|
};
|
||||||
|
[Hooks.GET_INSPECTOR_STATE]: {
|
||||||
|
app: App;
|
||||||
|
inspectorId: string;
|
||||||
|
nodeId: string;
|
||||||
|
state: CustomInspectorState;
|
||||||
|
};
|
||||||
|
[Hooks.EDIT_INSPECTOR_STATE]: {
|
||||||
|
app: App;
|
||||||
|
inspectorId: string;
|
||||||
|
nodeId: string;
|
||||||
|
path: string[];
|
||||||
|
type: string;
|
||||||
|
state: EditStatePayload;
|
||||||
|
set: (object: any, path?: string | (string[]), value?: any, cb?: (object: any, field: string, value: any) => void) => void;
|
||||||
|
};
|
||||||
|
[Hooks.SET_PLUGIN_SETTINGS]: {
|
||||||
|
app: App;
|
||||||
|
pluginId: string;
|
||||||
|
key: string;
|
||||||
|
newValue: any;
|
||||||
|
oldValue: any;
|
||||||
|
settings: any;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export type EditStatePayload = {
|
||||||
|
value: any;
|
||||||
|
newKey?: string | null;
|
||||||
|
remove?: undefined | false;
|
||||||
|
} | {
|
||||||
|
value?: undefined;
|
||||||
|
newKey?: undefined;
|
||||||
|
remove: true;
|
||||||
|
};
|
||||||
|
export type HookHandler<TPayload, TContext> = (payload: TPayload, ctx: TContext) => void | Promise<void>;
|
||||||
|
export interface Hookable<TContext> {
|
||||||
|
transformCall: (handler: HookHandler<HookPayloads[Hooks.TRANSFORM_CALL], TContext>) => any;
|
||||||
|
getAppRecordName: (handler: HookHandler<HookPayloads[Hooks.GET_APP_RECORD_NAME], TContext>) => any;
|
||||||
|
getAppRootInstance: (handler: HookHandler<HookPayloads[Hooks.GET_APP_ROOT_INSTANCE], TContext>) => any;
|
||||||
|
registerApplication: (handler: HookHandler<HookPayloads[Hooks.REGISTER_APPLICATION], TContext>) => any;
|
||||||
|
walkComponentTree: (handler: HookHandler<HookPayloads[Hooks.WALK_COMPONENT_TREE], TContext>) => any;
|
||||||
|
visitComponentTree: (handler: HookHandler<HookPayloads[Hooks.VISIT_COMPONENT_TREE], TContext>) => any;
|
||||||
|
walkComponentParents: (handler: HookHandler<HookPayloads[Hooks.WALK_COMPONENT_PARENTS], TContext>) => any;
|
||||||
|
inspectComponent: (handler: HookHandler<HookPayloads[Hooks.INSPECT_COMPONENT], TContext>) => any;
|
||||||
|
getComponentBounds: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_BOUNDS], TContext>) => any;
|
||||||
|
getComponentName: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_NAME], TContext>) => any;
|
||||||
|
getComponentInstances: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_INSTANCES], TContext>) => any;
|
||||||
|
getElementComponent: (handler: HookHandler<HookPayloads[Hooks.GET_ELEMENT_COMPONENT], TContext>) => any;
|
||||||
|
getComponentRootElements: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_ROOT_ELEMENTS], TContext>) => any;
|
||||||
|
editComponentState: (handler: HookHandler<HookPayloads[Hooks.EDIT_COMPONENT_STATE], TContext>) => any;
|
||||||
|
getComponentDevtoolsOptions: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_DEVTOOLS_OPTIONS], TContext>) => any;
|
||||||
|
getComponentRenderCode: (handler: HookHandler<HookPayloads[Hooks.GET_COMPONENT_RENDER_CODE], TContext>) => any;
|
||||||
|
inspectTimelineEvent: (handler: HookHandler<HookPayloads[Hooks.INSPECT_TIMELINE_EVENT], TContext>) => any;
|
||||||
|
timelineCleared: (handler: HookHandler<HookPayloads[Hooks.TIMELINE_CLEARED], TContext>) => any;
|
||||||
|
getInspectorTree: (handler: HookHandler<HookPayloads[Hooks.GET_INSPECTOR_TREE], TContext>) => any;
|
||||||
|
getInspectorState: (handler: HookHandler<HookPayloads[Hooks.GET_INSPECTOR_STATE], TContext>) => any;
|
||||||
|
editInspectorState: (handler: HookHandler<HookPayloads[Hooks.EDIT_INSPECTOR_STATE], TContext>) => any;
|
||||||
|
setPluginSettings: (handler: HookHandler<HookPayloads[Hooks.SET_PLUGIN_SETTINGS], TContext>) => any;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
export * from './api.js';
|
||||||
|
export * from './app.js';
|
||||||
|
export * from './component.js';
|
||||||
|
export * from './context.js';
|
||||||
|
export * from './hooks.js';
|
||||||
|
export * from './util.js';
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
export * from './api.js';
|
||||||
|
export * from './app.js';
|
||||||
|
export * from './component.js';
|
||||||
|
export * from './context.js';
|
||||||
|
export * from './hooks.js';
|
||||||
|
export * from './util.js';
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
export type ID = number | string;
|
||||||
|
export interface WithId {
|
||||||
|
id: ID;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare const HOOK_SETUP = "devtools-plugin:setup";
|
||||||
|
export declare const HOOK_PLUGIN_SETTINGS_SET = "plugin:settings:set";
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
export const HOOK_SETUP = 'devtools-plugin:setup';
|
||||||
|
export const HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set';
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
import type { ApiProxy } from './proxy.js';
|
||||||
|
import type { PluginDescriptor, SetupFunction } from './index.js';
|
||||||
|
export interface PluginQueueItem {
|
||||||
|
pluginDescriptor: PluginDescriptor;
|
||||||
|
setupFn: SetupFunction;
|
||||||
|
proxy?: ApiProxy;
|
||||||
|
}
|
||||||
|
interface GlobalTarget {
|
||||||
|
__VUE_DEVTOOLS_PLUGINS__?: PluginQueueItem[];
|
||||||
|
__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__?: boolean;
|
||||||
|
}
|
||||||
|
export declare function getDevtoolsGlobalHook(): any;
|
||||||
|
export declare function getTarget(): GlobalTarget;
|
||||||
|
export declare const isProxyAvailable: boolean;
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
export function getDevtoolsGlobalHook() {
|
||||||
|
return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
||||||
|
}
|
||||||
|
export function getTarget() {
|
||||||
|
// @ts-expect-error navigator and windows are not available in all environments
|
||||||
|
return (typeof navigator !== 'undefined' && typeof window !== 'undefined')
|
||||||
|
? window
|
||||||
|
: typeof globalThis !== 'undefined'
|
||||||
|
? globalThis
|
||||||
|
: {};
|
||||||
|
}
|
||||||
|
export const isProxyAvailable = typeof Proxy === 'function';
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import type { DevtoolsPluginApi } from './api/index.js';
|
||||||
|
import type { ExtractSettingsTypes, PluginDescriptor, PluginSettingsItem } from './plugin.js';
|
||||||
|
export * from './api/index.js';
|
||||||
|
export * from './plugin.js';
|
||||||
|
export * from './time.js';
|
||||||
|
export { PluginQueueItem } from './env.js';
|
||||||
|
type Cast<A, B> = A extends B ? A : B;
|
||||||
|
type Narrowable = string | number | bigint | boolean;
|
||||||
|
type Narrow<A> = Cast<A, [] | (A extends Narrowable ? A : never) | ({
|
||||||
|
[K in keyof A]: Narrow<A[K]>;
|
||||||
|
})>;
|
||||||
|
type Exact<C, T> = {
|
||||||
|
[K in keyof C]: K extends keyof T ? T[K] : never;
|
||||||
|
};
|
||||||
|
export type SetupFunction<TSettings = any> = (api: DevtoolsPluginApi<TSettings>) => void;
|
||||||
|
export declare function setupDevtoolsPlugin<TDescriptor extends Exact<TDescriptor, PluginDescriptor>, TSettings = ExtractSettingsTypes<TDescriptor extends {
|
||||||
|
settings: infer S;
|
||||||
|
} ? S extends Record<string, PluginSettingsItem> ? S : Record<string, PluginSettingsItem> : Record<string, PluginSettingsItem>>>(pluginDescriptor: Narrow<TDescriptor>, setupFn: SetupFunction<TSettings>): void;
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { getDevtoolsGlobalHook, getTarget, isProxyAvailable } from './env.js';
|
||||||
|
import { HOOK_SETUP } from './const.js';
|
||||||
|
import { ApiProxy } from './proxy.js';
|
||||||
|
export * from './api/index.js';
|
||||||
|
export * from './plugin.js';
|
||||||
|
export * from './time.js';
|
||||||
|
export function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
|
||||||
|
const descriptor = pluginDescriptor;
|
||||||
|
const target = getTarget();
|
||||||
|
const hook = getDevtoolsGlobalHook();
|
||||||
|
const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy;
|
||||||
|
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
|
||||||
|
hook.emit(HOOK_SETUP, pluginDescriptor, setupFn);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null;
|
||||||
|
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
|
||||||
|
list.push({
|
||||||
|
pluginDescriptor: descriptor,
|
||||||
|
setupFn,
|
||||||
|
proxy,
|
||||||
|
});
|
||||||
|
if (proxy) {
|
||||||
|
setupFn(proxy.proxiedTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
import type { App } from './api/index.js';
|
||||||
|
export interface PluginDescriptor {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
app: App;
|
||||||
|
packageName?: string;
|
||||||
|
homepage?: string;
|
||||||
|
componentStateTypes?: string[];
|
||||||
|
logo?: string;
|
||||||
|
disableAppScope?: boolean;
|
||||||
|
disablePluginScope?: boolean;
|
||||||
|
/**
|
||||||
|
* Run the plugin setup and expose the api even if the devtools is not opened yet.
|
||||||
|
* Useful to record timeline events early.
|
||||||
|
*/
|
||||||
|
enableEarlyProxy?: boolean;
|
||||||
|
settings?: Record<string, PluginSettingsItem>;
|
||||||
|
}
|
||||||
|
export type PluginSettingsItem = {
|
||||||
|
label: string;
|
||||||
|
description?: string;
|
||||||
|
} & ({
|
||||||
|
type: 'boolean';
|
||||||
|
defaultValue: boolean;
|
||||||
|
} | {
|
||||||
|
type: 'choice';
|
||||||
|
defaultValue: string | number;
|
||||||
|
options: {
|
||||||
|
value: string | number;
|
||||||
|
label: string;
|
||||||
|
}[];
|
||||||
|
component?: 'select' | 'button-group';
|
||||||
|
} | {
|
||||||
|
type: 'text';
|
||||||
|
defaultValue: string;
|
||||||
|
});
|
||||||
|
type InferSettingsType<T extends PluginSettingsItem> = [T] extends [{
|
||||||
|
type: 'boolean';
|
||||||
|
}] ? boolean : [T] extends [{
|
||||||
|
type: 'choice';
|
||||||
|
}] ? T['options'][number]['value'] : [T] extends [{
|
||||||
|
type: 'text';
|
||||||
|
}] ? string : unknown;
|
||||||
|
export type ExtractSettingsTypes<O extends Record<string, PluginSettingsItem>> = {
|
||||||
|
[K in keyof O]: InferSettingsType<O[K]>;
|
||||||
|
};
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import type { Context, DevtoolsPluginApi, Hookable } from './api/index.js';
|
||||||
|
import type { PluginDescriptor } from './plugin.js';
|
||||||
|
interface QueueItem {
|
||||||
|
method: string;
|
||||||
|
args: any[];
|
||||||
|
resolve?: (value?: any) => void;
|
||||||
|
}
|
||||||
|
export declare class ApiProxy<TTarget extends DevtoolsPluginApi<any> = DevtoolsPluginApi<any>> {
|
||||||
|
target: TTarget | null;
|
||||||
|
targetQueue: QueueItem[];
|
||||||
|
proxiedTarget: TTarget;
|
||||||
|
onQueue: QueueItem[];
|
||||||
|
proxiedOn: Hookable<Context>;
|
||||||
|
plugin: PluginDescriptor;
|
||||||
|
hook: any;
|
||||||
|
fallbacks: Record<string, any>;
|
||||||
|
constructor(plugin: PluginDescriptor, hook: any);
|
||||||
|
setRealTarget(target: TTarget): Promise<void>;
|
||||||
|
}
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,107 @@
|
||||||
|
import { HOOK_PLUGIN_SETTINGS_SET } from './const.js';
|
||||||
|
import { now } from './time.js';
|
||||||
|
export class ApiProxy {
|
||||||
|
constructor(plugin, hook) {
|
||||||
|
this.target = null;
|
||||||
|
this.targetQueue = [];
|
||||||
|
this.onQueue = [];
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.hook = hook;
|
||||||
|
const defaultSettings = {};
|
||||||
|
if (plugin.settings) {
|
||||||
|
for (const id in plugin.settings) {
|
||||||
|
const item = plugin.settings[id];
|
||||||
|
defaultSettings[id] = item.defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`;
|
||||||
|
let currentSettings = Object.assign({}, defaultSettings);
|
||||||
|
try {
|
||||||
|
const raw = localStorage.getItem(localSettingsSaveId);
|
||||||
|
const data = JSON.parse(raw);
|
||||||
|
Object.assign(currentSettings, data);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
this.fallbacks = {
|
||||||
|
getSettings() {
|
||||||
|
return currentSettings;
|
||||||
|
},
|
||||||
|
setSettings(value) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(localSettingsSaveId, JSON.stringify(value));
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
currentSettings = value;
|
||||||
|
},
|
||||||
|
now() {
|
||||||
|
return now();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (hook) {
|
||||||
|
hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => {
|
||||||
|
if (pluginId === this.plugin.id) {
|
||||||
|
this.fallbacks.setSettings(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.proxiedOn = new Proxy({}, {
|
||||||
|
get: (_target, prop) => {
|
||||||
|
if (this.target) {
|
||||||
|
return this.target.on[prop];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (...args) => {
|
||||||
|
this.onQueue.push({
|
||||||
|
method: prop,
|
||||||
|
args,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.proxiedTarget = new Proxy({}, {
|
||||||
|
get: (_target, prop) => {
|
||||||
|
if (this.target) {
|
||||||
|
return this.target[prop];
|
||||||
|
}
|
||||||
|
else if (prop === 'on') {
|
||||||
|
return this.proxiedOn;
|
||||||
|
}
|
||||||
|
else if (Object.keys(this.fallbacks).includes(prop)) {
|
||||||
|
return (...args) => {
|
||||||
|
this.targetQueue.push({
|
||||||
|
method: prop,
|
||||||
|
args,
|
||||||
|
resolve: () => { },
|
||||||
|
});
|
||||||
|
return this.fallbacks[prop](...args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return (...args) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
this.targetQueue.push({
|
||||||
|
method: prop,
|
||||||
|
args,
|
||||||
|
resolve,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async setRealTarget(target) {
|
||||||
|
this.target = target;
|
||||||
|
for (const item of this.onQueue) {
|
||||||
|
this.target.on[item.method](...item.args);
|
||||||
|
}
|
||||||
|
for (const item of this.targetQueue) {
|
||||||
|
item.resolve(await this.target[item.method](...item.args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare function isPerformanceSupported(): boolean;
|
||||||
|
export declare function now(): number;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue