引入了deepseek
This commit is contained in:
parent
fde02b761f
commit
2191cf5569
16
App.vue
16
App.vue
|
@ -3,8 +3,20 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLaunch } from '@dcloudio/uni-app'
|
||||
//小程序加载的时候调用该方法
|
||||
import { onLaunch } from '@dcloudio/uni-app'
|
||||
import { reactive } from 'vue'
|
||||
//小程序加载的时候调用该方法
|
||||
const globalData = reactive({});
|
||||
onLaunch( async ()=>{
|
||||
if (!wx.cloud) {
|
||||
console.error('请使用 2.2.3 或以上的基础库以使用云能力');
|
||||
} else {
|
||||
wx.cloud.init({
|
||||
env: 'cloud1-0gilcf3m6c99906d'
|
||||
});
|
||||
console.log('微信云开发工具调用成功!');
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -6,4 +6,4 @@ export const domain = 'https://www.carboner.cn:8888/api'
|
|||
export const myIp = 'http://8.130.119.119:9092/api'
|
||||
export const nwct = 'https://winning-mouse-internally.ngrok-free.app/api'
|
||||
export const suiUrl = ''
|
||||
export const baseUrl = domain
|
||||
export const baseUrl = domain
|
||||
|
|
|
@ -8,7 +8,7 @@ export const getFonts =()=>{ //改为查询背景图片
|
|||
wx.getStorage({
|
||||
key: bkgCache,
|
||||
success: (res) => {
|
||||
console.log('缓存图片的路径--->',res.data);
|
||||
// console.log('缓存图片的路径--->',res.data);
|
||||
bkgPubilcPath.value = res.data
|
||||
},
|
||||
fail: ()=> {
|
||||
|
|
226
components/agent-ui/chatFile/index.vue
Normal file
226
components/agent-ui/chatFile/index.vue
Normal file
|
@ -0,0 +1,226 @@
|
|||
<template>
|
||||
<!-- components/agent-ui-new/chatFIle/chatFile.wxml -->
|
||||
<!-- <text>components/agent-ui-new/chatFIle/chatFile.wxml</text> -->
|
||||
<view class="chat_file">
|
||||
<view class="chat_file__content">
|
||||
<image class="chat_file__icon" :src="iconPath" />
|
||||
<view class="chat_file__info">
|
||||
<view class="chat_file__name">{{ fileData.fileName }}</view>
|
||||
<view class="chat_file__size">
|
||||
{{ formatSize }}
|
||||
<image v-if="!fileData.fileId" style="width: 20px; height: 20px" src="/static/components/agent-ui/imgs/loading.svg" mode="" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<image
|
||||
v-if="'enableDel'"
|
||||
@tap="removeFileFromParents"
|
||||
style="width: 15px; height: 15px; position: absolute; top: 0px; right: 0px"
|
||||
src="/static/components/agent-ui/imgs/close-filled.png"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// components/agent-ui-new/chatFIle/chatFile.js
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
formatSize: '',
|
||||
iconPath: '/static/components/agent-ui/imgs/file.svg'
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// 处理小程序 attached 生命周期
|
||||
this.attached();
|
||||
},
|
||||
|
||||
watch: {
|
||||
'fileData.fileId': function (fileId) {
|
||||
if (!fileId) {
|
||||
this.setData({
|
||||
formatSize: '解析中'
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
formatSize: this.transformSize(this.fileData.fileSize)
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
props: {
|
||||
enableDel: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
fileData: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
tempId: '',
|
||||
rawType: '',
|
||||
fileName: '',
|
||||
tempPath: '',
|
||||
fileSize: 0,
|
||||
fileUrl: '',
|
||||
fileId: ''
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 组件的方法列表,
|
||||
*/
|
||||
methods: {
|
||||
attached: function () {
|
||||
// const formatSize = this.transformSize(this.data.fileSize)
|
||||
const { fileName, tempPath, fileId } = this.fileData;
|
||||
const type = this.getFileType(fileName);
|
||||
console.log('type', type);
|
||||
if (fileId) {
|
||||
this.setData({
|
||||
formatSize: this.transformSize(this.fileData.fileSize),
|
||||
iconPath: '../imgs/' + type + '.svg'
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.setData({
|
||||
formatSize: '解析中',
|
||||
iconPath: '../imgs/' + type + '.svg'
|
||||
});
|
||||
|
||||
// 上传云存储获取 fileId
|
||||
uniCloud.uploadFile({
|
||||
cloudPath: fileName,
|
||||
|
||||
// 云上文件路径
|
||||
filePath: tempPath,
|
||||
|
||||
// 本地文件路径
|
||||
success: (res) => {
|
||||
console.log('上传成功,fileID为:', res.fileID);
|
||||
// 此时你可以使用res.fileID进行后续操作
|
||||
// this.setData({
|
||||
// fileData: {
|
||||
// ...this.data.fileData,
|
||||
// fileId: res.fileID
|
||||
// }
|
||||
// })
|
||||
this.$emit('changeChild', {
|
||||
detail: {
|
||||
tempId: this.fileData.tempId,
|
||||
fileId: res.fileID
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
fail: (err) => {
|
||||
console.error('上传失败:', err);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 提取文件后缀
|
||||
getFileType: function (fileName) {
|
||||
let index = fileName.lastIndexOf('.');
|
||||
const fileExt = fileName.substring(index + 1);
|
||||
if (fileExt === 'docx' || fileExt === 'doc') {
|
||||
return 'word';
|
||||
}
|
||||
if (fileExt === 'xlsx' || fileExt === 'xls') {
|
||||
return 'excel';
|
||||
}
|
||||
if (fileExt === 'png' || fileExt === 'jpg' || fileExt === 'jpeg' || fileExt === 'svg') {
|
||||
return 'image';
|
||||
}
|
||||
if (fileExt === 'pdf') {
|
||||
return 'pdf';
|
||||
}
|
||||
return 'file';
|
||||
},
|
||||
|
||||
// getFileIcon: function (fileName) {
|
||||
// const type = this.getFileType(fileName)
|
||||
// console.log('type', type)
|
||||
// if(type === 'pdf') {
|
||||
// return 'pdf.png'
|
||||
// }
|
||||
|
||||
// return 'image.png'
|
||||
// },
|
||||
// 转换文件大小(原始单位为B)
|
||||
transformSize: function (size) {
|
||||
if (size < 1024) {
|
||||
return size + 'B';
|
||||
} else if (size < 1048576) {
|
||||
return (size / 1024).toFixed(2) + 'KB';
|
||||
} else {
|
||||
return (size / 1024 / 1024).toFixed(2) + 'MB';
|
||||
}
|
||||
},
|
||||
|
||||
removeFileFromParents: function () {
|
||||
console.log('remove', this.fileData);
|
||||
this.$emit('removeChild', {
|
||||
detail: {
|
||||
tempId: this.fileData.tempId
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
created: function () {}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
/* components/agent-ui-new/chatFIle/chatFile.wxss */
|
||||
.chat_file {
|
||||
padding: 24rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 1px 8px rgba(0, 0, 0, 0.253);
|
||||
margin: 16rpx 5rpx;
|
||||
width: 130px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.chat_file:active {
|
||||
background: #f9f9f9;
|
||||
}
|
||||
|
||||
.chat_file__content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
.chat_file__icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.chat_file__info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.chat_file__name {
|
||||
font-size: 28rpx;
|
||||
color: #333333;
|
||||
margin-bottom: 8rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.chat_file__size {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
</style>
|
63
components/agent-ui/collapsibleCard/index.vue
Normal file
63
components/agent-ui/collapsibleCard/index.vue
Normal file
|
@ -0,0 +1,63 @@
|
|||
<template>
|
||||
<!-- components/agent-ui/collapsibleCard/index.wxml -->
|
||||
<view>
|
||||
<view @tap="changeCollapsedStatus" style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px">
|
||||
<slot name="title"></slot>
|
||||
<image
|
||||
src="/static/components/agent-ui/imgs/arrow.svg"
|
||||
mode="aspectFill"
|
||||
:style="'width: 16px;height: 16px;transform: rotate(' + (collapsedStatus ? 0 : 180) + 'deg);'"
|
||||
/>
|
||||
</view>
|
||||
<block v-if="collapsedStatus">
|
||||
<slot name="content"></slot>
|
||||
</block>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// components/agent-ui/collapsibleCard/index.js
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
collapsedStatus: false
|
||||
};
|
||||
},
|
||||
/**
|
||||
* 组件的属性列表
|
||||
*/
|
||||
props: {
|
||||
initStatus: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 处理小程序 attached 生命周期
|
||||
this.attached();
|
||||
},
|
||||
/**
|
||||
* 组件的方法列表
|
||||
*/
|
||||
methods: {
|
||||
attached() {
|
||||
this.setData({
|
||||
collapsedStatus: this.initStatus
|
||||
});
|
||||
},
|
||||
|
||||
changeCollapsedStatus: function () {
|
||||
this.setData({
|
||||
collapsedStatus: !this.collapsedStatus
|
||||
});
|
||||
}
|
||||
},
|
||||
options: {
|
||||
multipleSlots: true
|
||||
},
|
||||
created: function () {}
|
||||
};
|
||||
</script>
|
||||
<style>
|
||||
/* components/agent-ui/collapsibleCard/index.wxss */
|
||||
</style>
|
1447
components/agent-ui/index.vue
Normal file
1447
components/agent-ui/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
95
components/agent-ui/tools.js
Normal file
95
components/agent-ui/tools.js
Normal file
|
@ -0,0 +1,95 @@
|
|||
export const guide = `agent ui组件配置不正确,请参照使用说明进行配置。
|
||||
|
||||
## 使用说明
|
||||
|
||||
### 1、前置条件
|
||||
|
||||
#### 1.1、开通微信云开发
|
||||
agent ui 小程序组件依赖微信云开发 AI 服务,需要开通微信云开发服务。
|
||||
|
||||
开通方式
|
||||
|
||||

|
||||
|
||||
如已开通微信云开发服务,请跳转至云开发平台(\`https://tcb.cloud.tencent.com/dev\`)创建AI服务。
|
||||
|
||||
#### 1.2、创建AI服务
|
||||
- 方式一:直接使用agent智能体服务
|
||||

|
||||
|
||||
- 方式二:接入大模型
|
||||

|
||||
|
||||
### 2、配置 agent ui 小程序组件
|
||||
#### 2.1、配置云开发环境ID
|
||||
打开\`miniprogram/app.js\`文件,配置云开发环境ID。
|
||||
\`\`\`js
|
||||
App({
|
||||
onLaunch: function () {
|
||||
if (!wx.cloud) {
|
||||
console.error("请使用 2.2.3 或以上的基础库以使用云能力");
|
||||
} else {
|
||||
wx.cloud.init({
|
||||
env: "",// 环境id
|
||||
traceUser: true,
|
||||
});
|
||||
}
|
||||
|
||||
this.globalData = {};
|
||||
},
|
||||
});
|
||||
\`\`\`
|
||||
#### 2.1、 agent ui 小程序组件配置
|
||||
打开小程序\`miniprogram/pages/index/index.js\`文件,配置 agent ui 小程序组件。
|
||||
|
||||
组件参数说明如下:
|
||||
|
||||
| 参数名称 | 参数说明 | 参数类型 | 是否必填 | 默认值 |
|
||||
| --------- | ---------------- | -------- | -------- | ------ |
|
||||
| type | 对接ai服务类型 | String | 是 | - |
|
||||
| botId | agent ID | String | 否 | - |
|
||||
| modelName | ai大模型服务商 | String | 否 | - |
|
||||
| model | 具体使用的大模型 | String | 否 | - |
|
||||
| logo | 图标 | String | 否 | - |
|
||||
| welcomeMessage | 欢迎语 | String | 否 | - |
|
||||
|
||||
对接 agent 服务时,type 为 bot,botId 必填,配置如下:
|
||||
\`\`\`js
|
||||
agentConfig: {
|
||||
type: "bot",
|
||||
botId: "bot-e7d1e736",
|
||||
modelName: "",
|
||||
model:"",
|
||||
logo:"",
|
||||
welcomeMessage:""
|
||||
}
|
||||
\`\`\`
|
||||
对接 ai 大模型服务时,type 为 model,modelName 和 modelName必填,配置如下:
|
||||
\`\`\`js
|
||||
agentConfig: {
|
||||
type: "model",
|
||||
botId: "",
|
||||
modelName: "hunyuan",
|
||||
model:"hunyuan-lite",
|
||||
logo:"",
|
||||
welcomeMessage:""
|
||||
}
|
||||
\`\`\`
|
||||
`;
|
||||
export const checkConfig = (config) => {
|
||||
const { type, botId, modelName, model } = config;
|
||||
// 检测AI能力,不存在提示用户
|
||||
if (!wx.cloud.extend || !wx.cloud.extend.AI) {
|
||||
return [false, '使用AI能力需基础库为3.7.7及以上,请升级基础库版本'];
|
||||
}
|
||||
if (!['bot', 'model'].includes(type)) {
|
||||
return [false, 'type 不正确,值应为“bot”或“model”'];
|
||||
}
|
||||
if (type === 'bot' && !botId) {
|
||||
return [false, '当前type值为bot,请配置botId'];
|
||||
}
|
||||
if (type === 'model' && (!modelName || !model)) {
|
||||
return [false, '当前type值为model,请配置modelNam和model'];
|
||||
}
|
||||
return [true, ''];
|
||||
};
|
1
components/ua-markdown/lib/highlight/atom-one-dark.css
Normal file
1
components/ua-markdown/lib/highlight/atom-one-dark.css
Normal file
|
@ -0,0 +1 @@
|
|||
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#abb2bf;background:#282c34}.hljs-comment,.hljs-quote{color:#5c6370;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#c678dd}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#98c379}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#d19a66}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#61aeee}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#e6c07b}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}
|
1
components/ua-markdown/lib/highlight/atom-one-light.css
Normal file
1
components/ua-markdown/lib/highlight/atom-one-light.css
Normal file
|
@ -0,0 +1 @@
|
|||
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#383a42;background:#fafafa}.hljs-comment,.hljs-quote{color:#a0a1a7;font-style:italic}.hljs-doctag,.hljs-formula,.hljs-keyword{color:#a626a4}.hljs-deletion,.hljs-name,.hljs-section,.hljs-selector-tag,.hljs-subst{color:#e45649}.hljs-literal{color:#0184bb}.hljs-addition,.hljs-attribute,.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#50a14f}.hljs-attr,.hljs-number,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-pseudo,.hljs-template-variable,.hljs-type,.hljs-variable{color:#986801}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-selector-id,.hljs-symbol,.hljs-title{color:#4078f2}.hljs-built_in,.hljs-class .hljs-title,.hljs-title.class_{color:#c18401}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-link{text-decoration:underline}
|
10
components/ua-markdown/lib/highlight/github-dark.min.css
vendored
Normal file
10
components/ua-markdown/lib/highlight/github-dark.min.css
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
|
||||
Theme: GitHub Dark
|
||||
Description: Dark theme as seen on github.com
|
||||
Author: github.com
|
||||
Maintainer: @Hirse
|
||||
Updated: 2021-05-15
|
||||
|
||||
Outdated base version: https://github.com/primer/github-syntax-dark
|
||||
Current colors taken from GitHub's CSS
|
||||
*/.hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}
|
5254
components/ua-markdown/lib/highlight/uni-highlight.min.js
vendored
Normal file
5254
components/ua-markdown/lib/highlight/uni-highlight.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
352
components/ua-markdown/lib/html-parser.js
Normal file
352
components/ua-markdown/lib/html-parser.js
Normal file
|
@ -0,0 +1,352 @@
|
|||
/*
|
||||
* HTML5 Parser By Sam Blowes
|
||||
*
|
||||
* Designed for HTML5 documents
|
||||
*
|
||||
* Original code by John Resig (ejohn.org)
|
||||
* http://ejohn.org/blog/pure-javascript-html-parser/
|
||||
* Original code by Erik Arvidsson, Mozilla Public License
|
||||
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
|
||||
*
|
||||
* ----------------------------------------------------------------------------
|
||||
* License
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* This code is triple licensed using Apache Software License 2.0,
|
||||
* Mozilla Public License or GNU Public License
|
||||
*
|
||||
* ////////////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy
|
||||
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* ////////////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Simple HTML Parser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Erik Arvidsson.
|
||||
* Portions created by Erik Arvidssson are Copyright (C) 2004. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* ////////////////////////////////////////////////////////////////////////////
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* ----------------------------------------------------------------------------
|
||||
* Usage
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* // Use like so:
|
||||
* HTMLParser(htmlString, {
|
||||
* start: function(tag, attrs, unary) {},
|
||||
* end: function(tag) {},
|
||||
* chars: function(text) {},
|
||||
* comment: function(text) {}
|
||||
* });
|
||||
*
|
||||
* // or to get an XML string:
|
||||
* HTMLtoXML(htmlString);
|
||||
*
|
||||
* // or to get an XML DOM Document
|
||||
* HTMLtoDOM(htmlString);
|
||||
*
|
||||
* // or to inject into an existing document/DOM node
|
||||
* HTMLtoDOM(htmlString, document);
|
||||
* HTMLtoDOM(htmlString, document.body);
|
||||
*
|
||||
*/
|
||||
// Regular Expressions for parsing tags and attributes
|
||||
var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
|
||||
var endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/;
|
||||
var attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g; // Empty Elements - HTML 5
|
||||
|
||||
var empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr'); // Block Elements - HTML 5
|
||||
// fixed by xxx 将 ins 标签从块级名单中移除
|
||||
|
||||
var block = makeMap('a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); // Inline Elements - HTML 5
|
||||
|
||||
var inline = makeMap('abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); // Elements that you can, intentionally, leave open
|
||||
// (and which close themselves)
|
||||
|
||||
var closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); // Attributes that have their values filled in disabled="disabled"
|
||||
|
||||
var fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); // Special Elements (can contain anything)
|
||||
|
||||
var special = makeMap('script,style');
|
||||
function HTMLParser(html, handler) {
|
||||
var index;
|
||||
var chars;
|
||||
var match;
|
||||
var stack = [];
|
||||
var last = html;
|
||||
|
||||
stack.last = function () {
|
||||
return this[this.length - 1];
|
||||
};
|
||||
|
||||
while (html) {
|
||||
chars = true; // Make sure we're not in a script or style element
|
||||
|
||||
if (!stack.last() || !special[stack.last()]) {
|
||||
// Comment
|
||||
if (html.indexOf('<!--') == 0) {
|
||||
index = html.indexOf('-->');
|
||||
|
||||
if (index >= 0) {
|
||||
if (handler.comment) {
|
||||
handler.comment(html.substring(4, index));
|
||||
}
|
||||
|
||||
html = html.substring(index + 3);
|
||||
chars = false;
|
||||
} // end tag
|
||||
|
||||
} else if (html.indexOf('</') == 0) {
|
||||
match = html.match(endTag);
|
||||
|
||||
if (match) {
|
||||
html = html.substring(match[0].length);
|
||||
match[0].replace(endTag, parseEndTag);
|
||||
chars = false;
|
||||
} // start tag
|
||||
|
||||
} else if (html.indexOf('<') == 0) {
|
||||
match = html.match(startTag);
|
||||
|
||||
if (match) {
|
||||
html = html.substring(match[0].length);
|
||||
match[0].replace(startTag, parseStartTag);
|
||||
chars = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (chars) {
|
||||
index = html.indexOf('<');
|
||||
var text = index < 0 ? html : html.substring(0, index);
|
||||
html = index < 0 ? '' : html.substring(index);
|
||||
|
||||
if (handler.chars) {
|
||||
handler.chars(text);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
html = html.replace(new RegExp('([\\s\\S]*?)<\/' + stack.last() + '[^>]*>'), function (all, text) {
|
||||
text = text.replace(/<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g, '$1$2');
|
||||
|
||||
if (handler.chars) {
|
||||
handler.chars(text);
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
parseEndTag('', stack.last());
|
||||
}
|
||||
|
||||
if (html == last) {
|
||||
throw 'Parse Error: ' + html;
|
||||
}
|
||||
|
||||
last = html;
|
||||
} // Clean up any remaining tags
|
||||
|
||||
|
||||
parseEndTag();
|
||||
|
||||
function parseStartTag(tag, tagName, rest, unary) {
|
||||
tagName = tagName.toLowerCase();
|
||||
|
||||
if (block[tagName]) {
|
||||
while (stack.last() && inline[stack.last()]) {
|
||||
parseEndTag('', stack.last());
|
||||
}
|
||||
}
|
||||
|
||||
if (closeSelf[tagName] && stack.last() == tagName) {
|
||||
parseEndTag('', tagName);
|
||||
}
|
||||
|
||||
unary = empty[tagName] || !!unary;
|
||||
|
||||
if (!unary) {
|
||||
stack.push(tagName);
|
||||
}
|
||||
|
||||
if (handler.start) {
|
||||
var attrs = [];
|
||||
rest.replace(attr, function (match, name) {
|
||||
var value = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : fillAttrs[name] ? name : '';
|
||||
attrs.push({
|
||||
name: name,
|
||||
value: value,
|
||||
escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') // "
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
if (handler.start) {
|
||||
handler.start(tagName, attrs, unary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseEndTag(tag, tagName) {
|
||||
// If no tag name is provided, clean shop
|
||||
if (!tagName) {
|
||||
var pos = 0;
|
||||
} // Find the closest opened tag of the same type
|
||||
else {
|
||||
for (var pos = stack.length - 1; pos >= 0; pos--) {
|
||||
if (stack[pos] == tagName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pos >= 0) {
|
||||
// Close all the open elements, up the stack
|
||||
for (var i = stack.length - 1; i >= pos; i--) {
|
||||
if (handler.end) {
|
||||
handler.end(stack[i]);
|
||||
}
|
||||
} // Remove the open elements from the stack
|
||||
|
||||
|
||||
stack.length = pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function makeMap(str) {
|
||||
var obj = {};
|
||||
var items = str.split(',');
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
obj[items[i]] = true;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function removeDOCTYPE(html) {
|
||||
return html.replace(/<\?xml.*\?>\n/, '').replace(/<!doctype.*>\n/, '').replace(/<!DOCTYPE.*>\n/, '');
|
||||
}
|
||||
|
||||
function parseAttrs(attrs) {
|
||||
return attrs.reduce(function (pre, attr) {
|
||||
var value = attr.value;
|
||||
var name = attr.name;
|
||||
|
||||
if (pre[name]) {
|
||||
pre[name] = pre[name] + " " + value;
|
||||
} else {
|
||||
pre[name] = value;
|
||||
}
|
||||
|
||||
return pre;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function parseHtml(html) {
|
||||
html = removeDOCTYPE(html);
|
||||
var stacks = [];
|
||||
var results = {
|
||||
node: 'root',
|
||||
children: []
|
||||
};
|
||||
HTMLParser(html, {
|
||||
start: function start(tag, attrs, unary) {
|
||||
var node = {
|
||||
name: tag
|
||||
};
|
||||
|
||||
if (attrs.length !== 0) {
|
||||
node.attrs = parseAttrs(attrs);
|
||||
}
|
||||
|
||||
if (unary) {
|
||||
var parent = stacks[0] || results;
|
||||
|
||||
if (!parent.children) {
|
||||
parent.children = [];
|
||||
}
|
||||
|
||||
parent.children.push(node);
|
||||
} else {
|
||||
stacks.unshift(node);
|
||||
}
|
||||
},
|
||||
end: function end(tag) {
|
||||
var node = stacks.shift();
|
||||
if (node.name !== tag) console.error('invalid state: mismatch end tag');
|
||||
|
||||
if (stacks.length === 0) {
|
||||
results.children.push(node);
|
||||
} else {
|
||||
var parent = stacks[0];
|
||||
|
||||
if (!parent.children) {
|
||||
parent.children = [];
|
||||
}
|
||||
|
||||
parent.children.push(node);
|
||||
}
|
||||
},
|
||||
chars: function chars(text) {
|
||||
var node = {
|
||||
type: 'text',
|
||||
text: text
|
||||
};
|
||||
|
||||
if (stacks.length === 0) {
|
||||
results.children.push(node);
|
||||
} else {
|
||||
var parent = stacks[0];
|
||||
|
||||
if (!parent.children) {
|
||||
parent.children = [];
|
||||
}
|
||||
|
||||
parent.children.push(node);
|
||||
}
|
||||
},
|
||||
comment: function comment(text) {
|
||||
var node = {
|
||||
node: 'comment',
|
||||
text: text
|
||||
};
|
||||
var parent = stacks[0];
|
||||
|
||||
if (!parent.children) {
|
||||
parent.children = [];
|
||||
}
|
||||
|
||||
parent.children.push(node);
|
||||
}
|
||||
});
|
||||
return results.children;
|
||||
}
|
||||
|
||||
export default parseHtml;
|
2
components/ua-markdown/lib/markdown-it.min.js
vendored
Normal file
2
components/ua-markdown/lib/markdown-it.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
318
components/ua-markdown/ua-markdown.vue
Normal file
318
components/ua-markdown/ua-markdown.vue
Normal file
|
@ -0,0 +1,318 @@
|
|||
<!-- uniapp vue3 markdown解析 -->
|
||||
<template>
|
||||
<view class="ua__markdown"><rich-text space="nbsp" :nodes="parseNodes(source)" @itemclick="handleItemClick"></rich-text></view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import MarkdownIt from './lib/markdown-it.min.js'
|
||||
import hljs from './lib/highlight/uni-highlight.min.js'
|
||||
import './lib/highlight/atom-one-dark.css'
|
||||
import parseHtml from './lib/html-parser.js'
|
||||
const props = defineProps({
|
||||
// 解析内容
|
||||
source: String,
|
||||
showLine: { type: [Boolean, String], default: true }
|
||||
})
|
||||
|
||||
let copyCodeData = []
|
||||
const markdown = MarkdownIt({
|
||||
html: true,
|
||||
highlight: function(str, lang) {
|
||||
let preCode = ""
|
||||
try {
|
||||
preCode = hljs.highlightAuto(str).value
|
||||
} catch (err) {
|
||||
preCode = markdown.utils.escapeHtml(str);
|
||||
}
|
||||
const lines = preCode.split(/\n/).slice(0, -1)
|
||||
// 添加自定义行号
|
||||
let html = lines.map((item, index) => {
|
||||
if( item == ''){
|
||||
return ''
|
||||
}
|
||||
return '<li><span class="line-num" data-line="' + (index + 1) + '"></span>' + item +'</li>'
|
||||
}).join('')
|
||||
if(props.showLine) {
|
||||
html = '<ol style="padding: 0px 30px;">' + html + '</ol>'
|
||||
}else {
|
||||
html = '<ol style="padding: 0px 7px;list-style:none;">' + html + '</ol>'
|
||||
}
|
||||
copyCodeData.push(str)
|
||||
let htmlCode = `<div class="markdown-wrap">`
|
||||
// #ifndef MP-WEIXIN
|
||||
htmlCode += `<div style="color: #aaa;text-align: right;font-size: 12px;padding:8px;">`
|
||||
htmlCode += `${lang}<a class="copy-btn" code-data-index="${copyCodeData.length - 1}" style="margin-left: 8px;">复制代码</a>`
|
||||
htmlCode += `</div>`
|
||||
// #endif
|
||||
htmlCode += `<pre class="hljs" style="padding:10px 8px 0;margin-bottom:5px;overflow: auto;display: block;border-radius: 5px;"><code>${html}</code></pre>`;
|
||||
htmlCode += '</div>'
|
||||
return htmlCode
|
||||
}
|
||||
})
|
||||
const parseNodes = (value) => {
|
||||
if(!value) return
|
||||
// 解析<br />到\n
|
||||
value = value.replace(/<br>|<br\/>|<br \/>/g, "\n")
|
||||
value = value.replace(/ /g, " ")
|
||||
let htmlString = ''
|
||||
if (value.split("```").length % 2) {
|
||||
let mdtext = value
|
||||
if(mdtext[mdtext.length-1] != '\n'){
|
||||
mdtext += '\n'
|
||||
}
|
||||
htmlString = markdown.render(mdtext)
|
||||
} else {
|
||||
htmlString = markdown.render(value)
|
||||
}
|
||||
// 解决小程序表格边框型失效问题
|
||||
htmlString = htmlString.replace(/<table/g, `<table class="table"`)
|
||||
htmlString = htmlString.replace(/<tr/g, `<tr class="tr"`)
|
||||
htmlString = htmlString.replace(/<th>/g, `<th class="th">`)
|
||||
htmlString = htmlString.replace(/<td/g, `<td class="td"`)
|
||||
htmlString = htmlString.replace(/<hr>|<hr\/>|<hr \/>/g, `<hr class="hr">`)
|
||||
|
||||
// #ifndef APP-NVUE
|
||||
return htmlString
|
||||
// #endif
|
||||
|
||||
// 将htmlString转成htmlArray,反之使用rich-text解析
|
||||
// #ifdef APP-NVUE
|
||||
return parseHtml(htmlString)
|
||||
// #endif
|
||||
}
|
||||
|
||||
// 复制代码
|
||||
const handleItemClick = (e) => {
|
||||
let {attrs} = e.detail.node
|
||||
let {"code-data-index":codeDataIndex,"class":className} = attrs
|
||||
if(className == 'copy-btn'){
|
||||
uni.setClipboardData({
|
||||
data: copyCodeData[codeDataIndex],showToast: false,
|
||||
success() {
|
||||
uni.showToast({
|
||||
title: '复制成功',icon: 'none'
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.ua__markdown {
|
||||
font-size: 14px;line-height: 1.5; word-break: break-all;
|
||||
h1,h2,h3,h4,h5,h6 {
|
||||
font-family: inherit;font-weight: 500;line-height: 1.1;color: inherit;
|
||||
}
|
||||
h1,h2,h3 {margin-top: 20px;margin-bottom: 10px}
|
||||
h4,h5,h6 {margin-top: 10px;margin-bottom: 10px}
|
||||
.h1,h1 {font-size: 36px
|
||||
}
|
||||
.h2,h2 {font-size: 30px
|
||||
}
|
||||
.h3,h3 {font-size: 24px
|
||||
}
|
||||
.h4,h4 {font-size: 18px
|
||||
}
|
||||
.h5,h5 {font-size: 14px
|
||||
}
|
||||
.h6,h6 {font-size: 12px
|
||||
}
|
||||
a {
|
||||
background-color: transparent;color: #2196f3;
|
||||
text-decoration: none;
|
||||
}
|
||||
hr, ::v-deep .hr {
|
||||
margin-top: 20px;margin-bottom: 20px; border: 0; border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
img { max-width: 35%;
|
||||
}
|
||||
p {margin: 0 0 10px}
|
||||
em {
|
||||
font-style: italic; font-weight: inherit;
|
||||
}
|
||||
ol,ul {
|
||||
margin-top: 0; margin-bottom: 10px;padding-left: 40px;
|
||||
}
|
||||
ol ol,ol ul,ul ol,ul ul {margin-bottom: 0;
|
||||
}
|
||||
ol ol, ul ol {list-style-type: lower-roman;
|
||||
}
|
||||
ol ol ol, ul ul ol {list-style-type: lower-alpha;
|
||||
}
|
||||
dl {
|
||||
margin-top: 0;margin-bottom: 20px;
|
||||
}
|
||||
dt {font-weight: 600;
|
||||
}
|
||||
dt, dd {line-height: 1.4;
|
||||
}
|
||||
.task-list-item { list-style-type: none;
|
||||
}
|
||||
.task-list-item input {
|
||||
margin: 0 .2em .25em -1.6em;vertical-align: middle;
|
||||
}
|
||||
pre {
|
||||
position: relative; z-index: 11;
|
||||
}
|
||||
code,kbd,pre,samp { font-family: Menlo,Monaco,Consolas,"Courier New",monospace;}
|
||||
code:not(.hljs) {
|
||||
padding: 2px 4px;font-size: 90%;color: #c7254e;background-color: #ffe7ee;border-radius: 4px;
|
||||
}
|
||||
code:empty {display: none;
|
||||
}
|
||||
pre code.hljs {
|
||||
color: var(--vg__text-1); border-radius: 16px; background: var(--vg__bg-1);font-size: 12px;
|
||||
}
|
||||
.markdown-wrap {
|
||||
font-size: 12px;margin-bottom: 10px;
|
||||
}
|
||||
pre.code-block-wrapper {background: #2b2b2b;color: #f8f8f2;border-radius: 4px;overflow-x: auto;
|
||||
padding: 1em;
|
||||
position: relative;
|
||||
}
|
||||
pre.code-block-wrapper code {
|
||||
padding: auto;
|
||||
font-size: inherit;
|
||||
color: inherit;
|
||||
background-color: inherit;
|
||||
border-radius: 0;
|
||||
}
|
||||
.code-block-header__copy {
|
||||
font-size: 16px;margin-left: 5px;
|
||||
}
|
||||
abbr[data-original-title],abbr[title] {
|
||||
cursor: help;border-bottom: 1px dotted #777;
|
||||
}
|
||||
blockquote {
|
||||
padding: 10px 20px;margin: 0 0 20px;font-size: 17.5px;
|
||||
border-left: 5px solid #e5e5e5;
|
||||
}
|
||||
blockquote ol:last-child,blockquote p:last-child,blockquote ul:last-child {
|
||||
margin-bottom: 0
|
||||
}
|
||||
blockquote .small,blockquote footer,blockquote small {
|
||||
display: block;font-size: 80%;line-height: 1.42857143;color: #777
|
||||
}
|
||||
blockquote .small:before,blockquote footer:before,blockquote small:before {
|
||||
content: '\2014 \00A0'
|
||||
}
|
||||
.blockquote-reverse,blockquote.pull-right {
|
||||
padding-right: 15px; padding-left: 0;
|
||||
text-align: right;border-right: 5px solid #eee;border-left: 0
|
||||
}
|
||||
.blockquote-reverse .small:before,.blockquote-reverse footer:before,.blockquote-reverse small:before,blockquote.pull-right .small:before,blockquote.pull-right footer:before,blockquote.pull-right small:before {
|
||||
content: ''
|
||||
}
|
||||
.blockquote-reverse .small:after,.blockquote-reverse footer:after,.blockquote-reverse small:after,blockquote.pull-right .small:after,blockquote.pull-right footer:after,blockquote.pull-right small:after {
|
||||
content: '\00A0 \2014'
|
||||
}
|
||||
.footnotes {
|
||||
-moz-column-count: 2;
|
||||
-webkit-column-count: 2;
|
||||
column-count: 2
|
||||
}
|
||||
.footnotes-list {padding-left: 2em}
|
||||
table, ::v-deep .table {
|
||||
border-spacing: 0;border-collapse: collapse; width: 100%;max-width: 65em; overflow: auto;margin-top: 0;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
table tr, ::v-deep .table .tr {
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
table th, table td, ::v-deep .table .th, ::v-deep .table .td {
|
||||
padding: 6px 13px;border: 1px solid #e5e5e5;
|
||||
}
|
||||
table th, ::v-deep .table .th {
|
||||
font-weight: 600;background-color: #eee;
|
||||
}
|
||||
.hljs[class*=language-]:before {
|
||||
position: absolute; z-index: 3;top: .8em; right: 1em; font-size: .8em; color: #999;
|
||||
}
|
||||
.hljs[class~=language-js]:before {
|
||||
content: "js"
|
||||
}
|
||||
.hljs[class~=language-ts]:before {
|
||||
content: "ts"
|
||||
}
|
||||
.hljs[class~=language-html]:before {
|
||||
content: "html"
|
||||
}
|
||||
.hljs[class~=language-md]:before {
|
||||
content: "md"
|
||||
}
|
||||
.hljs[class~=language-vue]:before {
|
||||
content: "vue"
|
||||
}
|
||||
.hljs[class~=language-css]:before {
|
||||
content: "css"
|
||||
}
|
||||
.hljs[class~=language-sass]:before {
|
||||
content: "sass"
|
||||
}
|
||||
.hljs[class~=language-scss]:before {
|
||||
content: "scss"
|
||||
}
|
||||
.hljs[class~=language-less]:before {
|
||||
content: "less"
|
||||
}
|
||||
.hljs[class~=language-stylus]:before {
|
||||
content: "stylus"
|
||||
}
|
||||
.hljs[class~=language-go]:before {
|
||||
content: "go"
|
||||
}
|
||||
.hljs[class~=language-java]:before {
|
||||
content: "java"
|
||||
}
|
||||
.hljs[class~=language-c]:before {
|
||||
content: "c"
|
||||
}
|
||||
.hljs[class~=language-sh]:before {
|
||||
content: "sh"
|
||||
}
|
||||
.hljs[class~=language-yaml]:before {
|
||||
content: "yaml"
|
||||
}
|
||||
.hljs[class~=language-py]:before {
|
||||
content: "py"
|
||||
}
|
||||
.hljs[class~=language-docker]:before {
|
||||
content: "docker"
|
||||
}
|
||||
.hljs[class~=language-dockerfile]:before {
|
||||
content: "dockerfile"
|
||||
}
|
||||
.hljs[class~=language-makefile]:before {
|
||||
content: "makefile"
|
||||
}
|
||||
.hljs[class~=language-javascript]:before {
|
||||
content: "js"
|
||||
}
|
||||
.hljs[class~=language-typescript]:before {
|
||||
content: "ts"
|
||||
}
|
||||
.hljs[class~=language-markup]:before {
|
||||
content: "html"
|
||||
}
|
||||
.hljs[class~=language-markdown]:before {
|
||||
content: "md"
|
||||
}
|
||||
.hljs[class~=language-json]:before {
|
||||
content: "json"
|
||||
}
|
||||
.hljs[class~=language-ruby]:before {
|
||||
content: "rb"
|
||||
}
|
||||
.hljs[class~=language-python]:before {
|
||||
content: "py"
|
||||
}
|
||||
.hljs[class~=language-bash]:before {
|
||||
content: "sh"
|
||||
}
|
||||
.hljs[class~=language-php]:before {
|
||||
content: "php"
|
||||
}
|
||||
}
|
||||
</style>
|
19
main.js
19
main.js
|
@ -1,8 +1,10 @@
|
|||
import App from './App';
|
||||
import zpMixins from '@/uni_modules/zp-mixins/index.js';
|
||||
// #ifndef VUE3
|
||||
import setFonts from './common/setFonts.js'
|
||||
import Vue from 'vue'
|
||||
import App from './App'
|
||||
import setFonts from './common/setFonts.js';
|
||||
import Vue from 'vue';
|
||||
|
||||
Vue.use(zpMixins);
|
||||
Vue.config.productionTip = false
|
||||
App.mpType = 'app'
|
||||
|
||||
|
@ -10,17 +12,20 @@ const app = new Vue({
|
|||
...App
|
||||
})
|
||||
app.$mount()
|
||||
|
||||
// #endif
|
||||
|
||||
// #ifdef VUE3
|
||||
import pinia from './store'
|
||||
import { createSSRApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
// import App from './App.vue'
|
||||
|
||||
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App)
|
||||
app.use(pinia) //持久化
|
||||
app.mixin(zpMixins);
|
||||
return {
|
||||
app
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// #endif
|
|
@ -14,7 +14,7 @@
|
|||
"alwaysShowBeforeRender" : true,
|
||||
"waiting" : true,
|
||||
"autoclose" : true,
|
||||
"delay" : 0
|
||||
"delay" : 0
|
||||
},
|
||||
"modules" : {},
|
||||
/* 模块配置 */
|
||||
|
@ -53,14 +53,16 @@
|
|||
"appid" : "wx61b63e27bddf4ea2",
|
||||
"setting" : {
|
||||
"urlCheck" : false,
|
||||
"minified" : true
|
||||
"minified" : true,
|
||||
"es6" : true,
|
||||
"postcss" : true
|
||||
},
|
||||
"usingComponents" : true,
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "你的位置信息将用于小程序定位"
|
||||
}
|
||||
}
|
||||
"permission" : {
|
||||
"scope.userLocation" : {
|
||||
"desc" : "你的位置信息将用于小程序定位"
|
||||
}
|
||||
}
|
||||
},
|
||||
"vueVersion" : "3"
|
||||
}
|
||||
|
|
15
node_modules/.bin/jsesc
generated
vendored
Normal file
15
node_modules/.bin/jsesc
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../jsesc/bin/jsesc" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../jsesc/bin/jsesc" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
17
node_modules/.bin/jsesc.cmd
generated
vendored
Normal file
17
node_modules/.bin/jsesc.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\jsesc\bin\jsesc" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
18
node_modules/.bin/jsesc.ps1
generated
vendored
Normal file
18
node_modules/.bin/jsesc.ps1
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
& "$basedir/node$exe" "$basedir/../jsesc/bin/jsesc" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../jsesc/bin/jsesc" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
13
node_modules/.bin/mathjs
generated
vendored
13
node_modules/.bin/mathjs
generated
vendored
|
@ -2,15 +2,14 @@
|
|||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*)
|
||||
if command -v cygpath > /dev/null 2>&1; then
|
||||
basedir=`cygpath -w "$basedir"`
|
||||
fi
|
||||
;;
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
exec "$basedir/node" "$basedir/../mathjs/bin/cli.js" "$@"
|
||||
"$basedir/node" "$basedir/../mathjs/bin/cli.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
exec node "$basedir/../mathjs/bin/cli.js" "$@"
|
||||
node "$basedir/../mathjs/bin/cli.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
||||
|
|
12
node_modules/.bin/mathjs.cmd
generated
vendored
12
node_modules/.bin/mathjs.cmd
generated
vendored
|
@ -1,9 +1,4 @@
|
|||
@ECHO off
|
||||
GOTO start
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
:start
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
|
@ -14,4 +9,9 @@ IF EXIST "%dp0%\node.exe" (
|
|||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mathjs\bin\cli.js" %*
|
||||
"%_prog%" "%dp0%\..\mathjs\bin\cli.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
||||
|
|
14
node_modules/.bin/mathjs.ps1
generated
vendored
14
node_modules/.bin/mathjs.ps1
generated
vendored
|
@ -9,20 +9,10 @@ if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
|||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "$basedir/node$exe" "$basedir/../mathjs/bin/cli.js" $args
|
||||
} else {
|
||||
& "$basedir/node$exe" "$basedir/../mathjs/bin/cli.js" $args
|
||||
}
|
||||
& "$basedir/node$exe" "$basedir/../mathjs/bin/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
# Support pipeline input
|
||||
if ($MyInvocation.ExpectingInput) {
|
||||
$input | & "node$exe" "$basedir/../mathjs/bin/cli.js" $args
|
||||
} else {
|
||||
& "node$exe" "$basedir/../mathjs/bin/cli.js" $args
|
||||
}
|
||||
& "node$exe" "$basedir/../mathjs/bin/cli.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
||||
|
|
15
node_modules/.bin/parser
generated
vendored
Normal file
15
node_modules/.bin/parser
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../@babel/parser/bin/babel-parser.js" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../@babel/parser/bin/babel-parser.js" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
17
node_modules/.bin/parser.cmd
generated
vendored
Normal file
17
node_modules/.bin/parser.cmd
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
@ECHO off
|
||||
SETLOCAL
|
||||
CALL :find_dp0
|
||||
|
||||
IF EXIST "%dp0%\node.exe" (
|
||||
SET "_prog=%dp0%\node.exe"
|
||||
) ELSE (
|
||||
SET "_prog=node"
|
||||
SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
)
|
||||
|
||||
"%_prog%" "%dp0%\..\@babel\parser\bin\babel-parser.js" %*
|
||||
ENDLOCAL
|
||||
EXIT /b %errorlevel%
|
||||
:find_dp0
|
||||
SET dp0=%~dp0
|
||||
EXIT /b
|
18
node_modules/.bin/parser.ps1
generated
vendored
Normal file
18
node_modules/.bin/parser.ps1
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env pwsh
|
||||
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
||||
|
||||
$exe=""
|
||||
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
||||
# Fix case when both the Windows and Linux builds of Node
|
||||
# are installed in the same directory
|
||||
$exe=".exe"
|
||||
}
|
||||
$ret=0
|
||||
if (Test-Path "$basedir/node$exe") {
|
||||
& "$basedir/node$exe" "$basedir/../@babel/parser/bin/babel-parser.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
} else {
|
||||
& "node$exe" "$basedir/../@babel/parser/bin/babel-parser.js" $args
|
||||
$ret=$LASTEXITCODE
|
||||
}
|
||||
exit $ret
|
22
node_modules/@babel/code-frame/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/code-frame/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
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.
|
19
node_modules/@babel/code-frame/README.md
generated
vendored
Normal file
19
node_modules/@babel/code-frame/README.md
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# @babel/code-frame
|
||||
|
||||
> Generate errors that contain a code frame that point to source locations.
|
||||
|
||||
See our website [@babel/code-frame](https://babeljs.io/docs/babel-code-frame) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/code-frame
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/code-frame --dev
|
||||
```
|
216
node_modules/@babel/code-frame/lib/index.js
generated
vendored
Normal file
216
node_modules/@babel/code-frame/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,216 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var picocolors = require('picocolors');
|
||||
var jsTokens = require('js-tokens');
|
||||
var helperValidatorIdentifier = require('@babel/helper-validator-identifier');
|
||||
|
||||
function isColorSupported() {
|
||||
return (typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? false : picocolors.isColorSupported
|
||||
);
|
||||
}
|
||||
const compose = (f, g) => v => f(g(v));
|
||||
function buildDefs(colors) {
|
||||
return {
|
||||
keyword: colors.cyan,
|
||||
capitalized: colors.yellow,
|
||||
jsxIdentifier: colors.yellow,
|
||||
punctuator: colors.yellow,
|
||||
number: colors.magenta,
|
||||
string: colors.green,
|
||||
regex: colors.magenta,
|
||||
comment: colors.gray,
|
||||
invalid: compose(compose(colors.white, colors.bgRed), colors.bold),
|
||||
gutter: colors.gray,
|
||||
marker: compose(colors.red, colors.bold),
|
||||
message: compose(colors.red, colors.bold),
|
||||
reset: colors.reset
|
||||
};
|
||||
}
|
||||
const defsOn = buildDefs(picocolors.createColors(true));
|
||||
const defsOff = buildDefs(picocolors.createColors(false));
|
||||
function getDefs(enabled) {
|
||||
return enabled ? defsOn : defsOff;
|
||||
}
|
||||
|
||||
const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);
|
||||
const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
|
||||
const BRACKET = /^[()[\]{}]$/;
|
||||
let tokenize;
|
||||
{
|
||||
const JSX_TAG = /^[a-z][\w-]*$/i;
|
||||
const getTokenType = function (token, offset, text) {
|
||||
if (token.type === "name") {
|
||||
if (helperValidatorIdentifier.isKeyword(token.value) || helperValidatorIdentifier.isStrictReservedWord(token.value, true) || sometimesKeywords.has(token.value)) {
|
||||
return "keyword";
|
||||
}
|
||||
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) {
|
||||
return "jsxIdentifier";
|
||||
}
|
||||
if (token.value[0] !== token.value[0].toLowerCase()) {
|
||||
return "capitalized";
|
||||
}
|
||||
}
|
||||
if (token.type === "punctuator" && BRACKET.test(token.value)) {
|
||||
return "bracket";
|
||||
}
|
||||
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
|
||||
return "punctuator";
|
||||
}
|
||||
return token.type;
|
||||
};
|
||||
tokenize = function* (text) {
|
||||
let match;
|
||||
while (match = jsTokens.default.exec(text)) {
|
||||
const token = jsTokens.matchToToken(match);
|
||||
yield {
|
||||
type: getTokenType(token, match.index, text),
|
||||
value: token.value
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
function highlight(text) {
|
||||
if (text === "") return "";
|
||||
const defs = getDefs(true);
|
||||
let highlighted = "";
|
||||
for (const {
|
||||
type,
|
||||
value
|
||||
} of tokenize(text)) {
|
||||
if (type in defs) {
|
||||
highlighted += value.split(NEWLINE$1).map(str => defs[type](str)).join("\n");
|
||||
} else {
|
||||
highlighted += value;
|
||||
}
|
||||
}
|
||||
return highlighted;
|
||||
}
|
||||
|
||||
let deprecationWarningShown = false;
|
||||
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
||||
function getMarkerLines(loc, source, opts) {
|
||||
const startLoc = Object.assign({
|
||||
column: 0,
|
||||
line: -1
|
||||
}, loc.start);
|
||||
const endLoc = Object.assign({}, startLoc, loc.end);
|
||||
const {
|
||||
linesAbove = 2,
|
||||
linesBelow = 3
|
||||
} = opts || {};
|
||||
const startLine = startLoc.line;
|
||||
const startColumn = startLoc.column;
|
||||
const endLine = endLoc.line;
|
||||
const endColumn = endLoc.column;
|
||||
let start = Math.max(startLine - (linesAbove + 1), 0);
|
||||
let end = Math.min(source.length, endLine + linesBelow);
|
||||
if (startLine === -1) {
|
||||
start = 0;
|
||||
}
|
||||
if (endLine === -1) {
|
||||
end = source.length;
|
||||
}
|
||||
const lineDiff = endLine - startLine;
|
||||
const markerLines = {};
|
||||
if (lineDiff) {
|
||||
for (let i = 0; i <= lineDiff; i++) {
|
||||
const lineNumber = i + startLine;
|
||||
if (!startColumn) {
|
||||
markerLines[lineNumber] = true;
|
||||
} else if (i === 0) {
|
||||
const sourceLength = source[lineNumber - 1].length;
|
||||
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
|
||||
} else if (i === lineDiff) {
|
||||
markerLines[lineNumber] = [0, endColumn];
|
||||
} else {
|
||||
const sourceLength = source[lineNumber - i].length;
|
||||
markerLines[lineNumber] = [0, sourceLength];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (startColumn === endColumn) {
|
||||
if (startColumn) {
|
||||
markerLines[startLine] = [startColumn, 0];
|
||||
} else {
|
||||
markerLines[startLine] = true;
|
||||
}
|
||||
} else {
|
||||
markerLines[startLine] = [startColumn, endColumn - startColumn];
|
||||
}
|
||||
}
|
||||
return {
|
||||
start,
|
||||
end,
|
||||
markerLines
|
||||
};
|
||||
}
|
||||
function codeFrameColumns(rawLines, loc, opts = {}) {
|
||||
const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
|
||||
const defs = getDefs(shouldHighlight);
|
||||
const lines = rawLines.split(NEWLINE);
|
||||
const {
|
||||
start,
|
||||
end,
|
||||
markerLines
|
||||
} = getMarkerLines(loc, lines, opts);
|
||||
const hasColumns = loc.start && typeof loc.start.column === "number";
|
||||
const numberMaxWidth = String(end).length;
|
||||
const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines;
|
||||
let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index) => {
|
||||
const number = start + 1 + index;
|
||||
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
||||
const gutter = ` ${paddedNumber} |`;
|
||||
const hasMarker = markerLines[number];
|
||||
const lastMarkerLine = !markerLines[number + 1];
|
||||
if (hasMarker) {
|
||||
let markerLine = "";
|
||||
if (Array.isArray(hasMarker)) {
|
||||
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
|
||||
const numberOfMarkers = hasMarker[1] || 1;
|
||||
markerLine = ["\n ", defs.gutter(gutter.replace(/\d/g, " ")), " ", markerSpacing, defs.marker("^").repeat(numberOfMarkers)].join("");
|
||||
if (lastMarkerLine && opts.message) {
|
||||
markerLine += " " + defs.message(opts.message);
|
||||
}
|
||||
}
|
||||
return [defs.marker(">"), defs.gutter(gutter), line.length > 0 ? ` ${line}` : "", markerLine].join("");
|
||||
} else {
|
||||
return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
|
||||
}
|
||||
}).join("\n");
|
||||
if (opts.message && !hasColumns) {
|
||||
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
||||
}
|
||||
if (shouldHighlight) {
|
||||
return defs.reset(frame);
|
||||
} else {
|
||||
return frame;
|
||||
}
|
||||
}
|
||||
function index (rawLines, lineNumber, colNumber, opts = {}) {
|
||||
if (!deprecationWarningShown) {
|
||||
deprecationWarningShown = true;
|
||||
const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
|
||||
if (process.emitWarning) {
|
||||
process.emitWarning(message, "DeprecationWarning");
|
||||
} else {
|
||||
const deprecationError = new Error(message);
|
||||
deprecationError.name = "DeprecationWarning";
|
||||
console.warn(new Error(message));
|
||||
}
|
||||
}
|
||||
colNumber = Math.max(colNumber, 0);
|
||||
const location = {
|
||||
start: {
|
||||
column: colNumber,
|
||||
line: lineNumber
|
||||
}
|
||||
};
|
||||
return codeFrameColumns(rawLines, location, opts);
|
||||
}
|
||||
|
||||
exports.codeFrameColumns = codeFrameColumns;
|
||||
exports.default = index;
|
||||
exports.highlight = highlight;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@babel/code-frame/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/code-frame/lib/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
63
node_modules/@babel/code-frame/package.json
generated
vendored
Normal file
63
node_modules/@babel/code-frame/package.json
generated
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"_from": "@babel/code-frame@^7.26.2",
|
||||
"_id": "@babel/code-frame@7.26.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==",
|
||||
"_location": "/@babel/code-frame",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@babel/code-frame@^7.26.2",
|
||||
"name": "@babel/code-frame",
|
||||
"escapedName": "@babel%2fcode-frame",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "^7.26.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^7.26.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/template",
|
||||
"/@babel/traverse"
|
||||
],
|
||||
"_resolved": "https://registry.npmmirror.com/@babel/code-frame/-/code-frame-7.26.2.tgz",
|
||||
"_shasum": "4b5fab97d33338eff916235055f0ebc21e573a85",
|
||||
"_spec": "@babel/code-frame@^7.26.2",
|
||||
"_where": "D:\\jiangchengfeiyi-xiaochengxu\\node_modules\\@babel\\traverse",
|
||||
"author": {
|
||||
"name": "The Babel Team",
|
||||
"url": "https://babel.dev/team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/helper-validator-identifier": "^7.25.9",
|
||||
"js-tokens": "^4.0.0",
|
||||
"picocolors": "^1.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Generate errors that contain a code frame that point to source locations.",
|
||||
"devDependencies": {
|
||||
"import-meta-resolve": "^4.1.0",
|
||||
"strip-ansi": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-code-frame",
|
||||
"license": "MIT",
|
||||
"main": "./lib/index.js",
|
||||
"name": "@babel/code-frame",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-code-frame"
|
||||
},
|
||||
"type": "commonjs",
|
||||
"version": "7.26.2"
|
||||
}
|
22
node_modules/@babel/generator/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/generator/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
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.
|
19
node_modules/@babel/generator/README.md
generated
vendored
Normal file
19
node_modules/@babel/generator/README.md
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# @babel/generator
|
||||
|
||||
> Turns an AST into code.
|
||||
|
||||
See our website [@babel/generator](https://babeljs.io/docs/babel-generator) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20generator%22+is%3Aopen) associated with this package.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/generator
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/generator --dev
|
||||
```
|
317
node_modules/@babel/generator/lib/buffer.js
generated
vendored
Normal file
317
node_modules/@babel/generator/lib/buffer.js
generated
vendored
Normal file
|
@ -0,0 +1,317 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
class Buffer {
|
||||
constructor(map, indentChar) {
|
||||
this._map = null;
|
||||
this._buf = "";
|
||||
this._str = "";
|
||||
this._appendCount = 0;
|
||||
this._last = 0;
|
||||
this._queue = [];
|
||||
this._queueCursor = 0;
|
||||
this._canMarkIdName = true;
|
||||
this._indentChar = "";
|
||||
this._fastIndentations = [];
|
||||
this._position = {
|
||||
line: 1,
|
||||
column: 0
|
||||
};
|
||||
this._sourcePosition = {
|
||||
identifierName: undefined,
|
||||
identifierNamePos: undefined,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
filename: undefined
|
||||
};
|
||||
this._map = map;
|
||||
this._indentChar = indentChar;
|
||||
for (let i = 0; i < 64; i++) {
|
||||
this._fastIndentations.push(indentChar.repeat(i));
|
||||
}
|
||||
this._allocQueue();
|
||||
}
|
||||
_allocQueue() {
|
||||
const queue = this._queue;
|
||||
for (let i = 0; i < 16; i++) {
|
||||
queue.push({
|
||||
char: 0,
|
||||
repeat: 1,
|
||||
line: undefined,
|
||||
column: undefined,
|
||||
identifierName: undefined,
|
||||
identifierNamePos: undefined,
|
||||
filename: ""
|
||||
});
|
||||
}
|
||||
}
|
||||
_pushQueue(char, repeat, line, column, filename) {
|
||||
const cursor = this._queueCursor;
|
||||
if (cursor === this._queue.length) {
|
||||
this._allocQueue();
|
||||
}
|
||||
const item = this._queue[cursor];
|
||||
item.char = char;
|
||||
item.repeat = repeat;
|
||||
item.line = line;
|
||||
item.column = column;
|
||||
item.filename = filename;
|
||||
this._queueCursor++;
|
||||
}
|
||||
_popQueue() {
|
||||
if (this._queueCursor === 0) {
|
||||
throw new Error("Cannot pop from empty queue");
|
||||
}
|
||||
return this._queue[--this._queueCursor];
|
||||
}
|
||||
get() {
|
||||
this._flush();
|
||||
const map = this._map;
|
||||
const result = {
|
||||
code: (this._buf + this._str).trimRight(),
|
||||
decodedMap: map == null ? void 0 : map.getDecoded(),
|
||||
get __mergedMap() {
|
||||
return this.map;
|
||||
},
|
||||
get map() {
|
||||
const resultMap = map ? map.get() : null;
|
||||
result.map = resultMap;
|
||||
return resultMap;
|
||||
},
|
||||
set map(value) {
|
||||
Object.defineProperty(result, "map", {
|
||||
value,
|
||||
writable: true
|
||||
});
|
||||
},
|
||||
get rawMappings() {
|
||||
const mappings = map == null ? void 0 : map.getRawMappings();
|
||||
result.rawMappings = mappings;
|
||||
return mappings;
|
||||
},
|
||||
set rawMappings(value) {
|
||||
Object.defineProperty(result, "rawMappings", {
|
||||
value,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
append(str, maybeNewline) {
|
||||
this._flush();
|
||||
this._append(str, this._sourcePosition, maybeNewline);
|
||||
}
|
||||
appendChar(char) {
|
||||
this._flush();
|
||||
this._appendChar(char, 1, this._sourcePosition);
|
||||
}
|
||||
queue(char) {
|
||||
if (char === 10) {
|
||||
while (this._queueCursor !== 0) {
|
||||
const char = this._queue[this._queueCursor - 1].char;
|
||||
if (char !== 32 && char !== 9) {
|
||||
break;
|
||||
}
|
||||
this._queueCursor--;
|
||||
}
|
||||
}
|
||||
const sourcePosition = this._sourcePosition;
|
||||
this._pushQueue(char, 1, sourcePosition.line, sourcePosition.column, sourcePosition.filename);
|
||||
}
|
||||
queueIndentation(repeat) {
|
||||
if (repeat === 0) return;
|
||||
this._pushQueue(-1, repeat, undefined, undefined, undefined);
|
||||
}
|
||||
_flush() {
|
||||
const queueCursor = this._queueCursor;
|
||||
const queue = this._queue;
|
||||
for (let i = 0; i < queueCursor; i++) {
|
||||
const item = queue[i];
|
||||
this._appendChar(item.char, item.repeat, item);
|
||||
}
|
||||
this._queueCursor = 0;
|
||||
}
|
||||
_appendChar(char, repeat, sourcePos) {
|
||||
this._last = char;
|
||||
if (char === -1) {
|
||||
const fastIndentation = this._fastIndentations[repeat];
|
||||
if (fastIndentation !== undefined) {
|
||||
this._str += fastIndentation;
|
||||
} else {
|
||||
this._str += repeat > 1 ? this._indentChar.repeat(repeat) : this._indentChar;
|
||||
}
|
||||
} else {
|
||||
this._str += repeat > 1 ? String.fromCharCode(char).repeat(repeat) : String.fromCharCode(char);
|
||||
}
|
||||
if (char !== 10) {
|
||||
this._mark(sourcePos.line, sourcePos.column, sourcePos.identifierName, sourcePos.identifierNamePos, sourcePos.filename);
|
||||
this._position.column += repeat;
|
||||
} else {
|
||||
this._position.line++;
|
||||
this._position.column = 0;
|
||||
}
|
||||
if (this._canMarkIdName) {
|
||||
sourcePos.identifierName = undefined;
|
||||
sourcePos.identifierNamePos = undefined;
|
||||
}
|
||||
}
|
||||
_append(str, sourcePos, maybeNewline) {
|
||||
const len = str.length;
|
||||
const position = this._position;
|
||||
this._last = str.charCodeAt(len - 1);
|
||||
if (++this._appendCount > 4096) {
|
||||
+this._str;
|
||||
this._buf += this._str;
|
||||
this._str = str;
|
||||
this._appendCount = 0;
|
||||
} else {
|
||||
this._str += str;
|
||||
}
|
||||
if (!maybeNewline && !this._map) {
|
||||
position.column += len;
|
||||
return;
|
||||
}
|
||||
const {
|
||||
column,
|
||||
identifierName,
|
||||
identifierNamePos,
|
||||
filename
|
||||
} = sourcePos;
|
||||
let line = sourcePos.line;
|
||||
if ((identifierName != null || identifierNamePos != null) && this._canMarkIdName) {
|
||||
sourcePos.identifierName = undefined;
|
||||
sourcePos.identifierNamePos = undefined;
|
||||
}
|
||||
let i = str.indexOf("\n");
|
||||
let last = 0;
|
||||
if (i !== 0) {
|
||||
this._mark(line, column, identifierName, identifierNamePos, filename);
|
||||
}
|
||||
while (i !== -1) {
|
||||
position.line++;
|
||||
position.column = 0;
|
||||
last = i + 1;
|
||||
if (last < len && line !== undefined) {
|
||||
this._mark(++line, 0, null, null, filename);
|
||||
}
|
||||
i = str.indexOf("\n", last);
|
||||
}
|
||||
position.column += len - last;
|
||||
}
|
||||
_mark(line, column, identifierName, identifierNamePos, filename) {
|
||||
var _this$_map;
|
||||
(_this$_map = this._map) == null || _this$_map.mark(this._position, line, column, identifierName, identifierNamePos, filename);
|
||||
}
|
||||
removeTrailingNewline() {
|
||||
const queueCursor = this._queueCursor;
|
||||
if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 10) {
|
||||
this._queueCursor--;
|
||||
}
|
||||
}
|
||||
removeLastSemicolon() {
|
||||
const queueCursor = this._queueCursor;
|
||||
if (queueCursor !== 0 && this._queue[queueCursor - 1].char === 59) {
|
||||
this._queueCursor--;
|
||||
}
|
||||
}
|
||||
getLastChar() {
|
||||
const queueCursor = this._queueCursor;
|
||||
return queueCursor !== 0 ? this._queue[queueCursor - 1].char : this._last;
|
||||
}
|
||||
getNewlineCount() {
|
||||
const queueCursor = this._queueCursor;
|
||||
let count = 0;
|
||||
if (queueCursor === 0) return this._last === 10 ? 1 : 0;
|
||||
for (let i = queueCursor - 1; i >= 0; i--) {
|
||||
if (this._queue[i].char !== 10) {
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
return count === queueCursor && this._last === 10 ? count + 1 : count;
|
||||
}
|
||||
endsWithCharAndNewline() {
|
||||
const queue = this._queue;
|
||||
const queueCursor = this._queueCursor;
|
||||
if (queueCursor !== 0) {
|
||||
const lastCp = queue[queueCursor - 1].char;
|
||||
if (lastCp !== 10) return;
|
||||
if (queueCursor > 1) {
|
||||
return queue[queueCursor - 2].char;
|
||||
} else {
|
||||
return this._last;
|
||||
}
|
||||
}
|
||||
}
|
||||
hasContent() {
|
||||
return this._queueCursor !== 0 || !!this._last;
|
||||
}
|
||||
exactSource(loc, cb) {
|
||||
if (!this._map) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
this.source("start", loc);
|
||||
const identifierName = loc.identifierName;
|
||||
const sourcePos = this._sourcePosition;
|
||||
if (identifierName) {
|
||||
this._canMarkIdName = false;
|
||||
sourcePos.identifierName = identifierName;
|
||||
}
|
||||
cb();
|
||||
if (identifierName) {
|
||||
this._canMarkIdName = true;
|
||||
sourcePos.identifierName = undefined;
|
||||
sourcePos.identifierNamePos = undefined;
|
||||
}
|
||||
this.source("end", loc);
|
||||
}
|
||||
source(prop, loc) {
|
||||
if (!this._map) return;
|
||||
this._normalizePosition(prop, loc, 0);
|
||||
}
|
||||
sourceWithOffset(prop, loc, columnOffset) {
|
||||
if (!this._map) return;
|
||||
this._normalizePosition(prop, loc, columnOffset);
|
||||
}
|
||||
_normalizePosition(prop, loc, columnOffset) {
|
||||
const pos = loc[prop];
|
||||
const target = this._sourcePosition;
|
||||
if (pos) {
|
||||
target.line = pos.line;
|
||||
target.column = Math.max(pos.column + columnOffset, 0);
|
||||
target.filename = loc.filename;
|
||||
}
|
||||
}
|
||||
getCurrentColumn() {
|
||||
const queue = this._queue;
|
||||
const queueCursor = this._queueCursor;
|
||||
let lastIndex = -1;
|
||||
let len = 0;
|
||||
for (let i = 0; i < queueCursor; i++) {
|
||||
const item = queue[i];
|
||||
if (item.char === 10) {
|
||||
lastIndex = len;
|
||||
}
|
||||
len += item.repeat;
|
||||
}
|
||||
return lastIndex === -1 ? this._position.column + len : len - 1 - lastIndex;
|
||||
}
|
||||
getCurrentLine() {
|
||||
let count = 0;
|
||||
const queue = this._queue;
|
||||
for (let i = 0; i < this._queueCursor; i++) {
|
||||
if (queue[i].char === 10) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return this._position.line + count;
|
||||
}
|
||||
}
|
||||
exports.default = Buffer;
|
||||
|
||||
//# sourceMappingURL=buffer.js.map
|
1
node_modules/@babel/generator/lib/buffer.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/buffer.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
87
node_modules/@babel/generator/lib/generators/base.js
generated
vendored
Normal file
87
node_modules/@babel/generator/lib/generators/base.js
generated
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.BlockStatement = BlockStatement;
|
||||
exports.Directive = Directive;
|
||||
exports.DirectiveLiteral = DirectiveLiteral;
|
||||
exports.File = File;
|
||||
exports.InterpreterDirective = InterpreterDirective;
|
||||
exports.Placeholder = Placeholder;
|
||||
exports.Program = Program;
|
||||
function File(node) {
|
||||
if (node.program) {
|
||||
this.print(node.program.interpreter);
|
||||
}
|
||||
this.print(node.program);
|
||||
}
|
||||
function Program(node) {
|
||||
var _node$directives;
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.printInnerComments();
|
||||
const directivesLen = (_node$directives = node.directives) == null ? void 0 : _node$directives.length;
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai;
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, undefined, newline);
|
||||
if (!((_node$directives$trai = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai.length)) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
this.printSequence(node.body);
|
||||
}
|
||||
function BlockStatement(node) {
|
||||
var _node$directives2;
|
||||
this.tokenChar(123);
|
||||
const exit = this.enterDelimited();
|
||||
const directivesLen = (_node$directives2 = node.directives) == null ? void 0 : _node$directives2.length;
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai2;
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, true, newline);
|
||||
if (!((_node$directives$trai2 = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai2.length)) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
this.printSequence(node.body, true);
|
||||
exit();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function Directive(node) {
|
||||
this.print(node.value);
|
||||
this.semicolon();
|
||||
}
|
||||
const unescapedSingleQuoteRE = /(?:^|[^\\])(?:\\\\)*'/;
|
||||
const unescapedDoubleQuoteRE = /(?:^|[^\\])(?:\\\\)*"/;
|
||||
function DirectiveLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.token(raw);
|
||||
return;
|
||||
}
|
||||
const {
|
||||
value
|
||||
} = node;
|
||||
if (!unescapedDoubleQuoteRE.test(value)) {
|
||||
this.token(`"${value}"`);
|
||||
} else if (!unescapedSingleQuoteRE.test(value)) {
|
||||
this.token(`'${value}'`);
|
||||
} else {
|
||||
throw new Error("Malformed AST: it is not possible to print a directive containing" + " both unescaped single and double quotes.");
|
||||
}
|
||||
}
|
||||
function InterpreterDirective(node) {
|
||||
this.token(`#!${node.value}`);
|
||||
this.newline(1, true);
|
||||
}
|
||||
function Placeholder(node) {
|
||||
this.token("%%");
|
||||
this.print(node.name);
|
||||
this.token("%%");
|
||||
if (node.expectedNode === "Statement") {
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=base.js.map
|
1
node_modules/@babel/generator/lib/generators/base.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/base.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
212
node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
Normal file
212
node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
Normal file
|
@ -0,0 +1,212 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ClassAccessorProperty = ClassAccessorProperty;
|
||||
exports.ClassBody = ClassBody;
|
||||
exports.ClassExpression = exports.ClassDeclaration = ClassDeclaration;
|
||||
exports.ClassMethod = ClassMethod;
|
||||
exports.ClassPrivateMethod = ClassPrivateMethod;
|
||||
exports.ClassPrivateProperty = ClassPrivateProperty;
|
||||
exports.ClassProperty = ClassProperty;
|
||||
exports.StaticBlock = StaticBlock;
|
||||
exports._classMethodHead = _classMethodHead;
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
isExportDefaultDeclaration,
|
||||
isExportNamedDeclaration
|
||||
} = _t;
|
||||
function ClassDeclaration(node, parent) {
|
||||
const inExport = isExportDefaultDeclaration(parent) || isExportNamedDeclaration(parent);
|
||||
if (!inExport || !this._shouldPrintDecoratorsBeforeExport(parent)) {
|
||||
this.printJoin(node.decorators);
|
||||
}
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
this.word("class");
|
||||
if (node.id) {
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
}
|
||||
this.print(node.typeParameters);
|
||||
if (node.superClass) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.superClass);
|
||||
this.print(node.superTypeParameters);
|
||||
}
|
||||
if (node.implements) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ClassBody(node) {
|
||||
this.tokenChar(123);
|
||||
if (node.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
const separator = classBodyEmptySemicolonsPrinter(this, node);
|
||||
separator == null || separator(-1);
|
||||
const exit = this.enterDelimited();
|
||||
this.printJoin(node.body, true, true, separator, true);
|
||||
exit();
|
||||
if (!this.endsWith(10)) this.newline();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
}
|
||||
function classBodyEmptySemicolonsPrinter(printer, node) {
|
||||
if (!printer.tokenMap || node.start == null || node.end == null) {
|
||||
return null;
|
||||
}
|
||||
const indexes = printer.tokenMap.getIndexes(node);
|
||||
if (!indexes) return null;
|
||||
let k = 1;
|
||||
let occurrenceCount = 0;
|
||||
let nextLocIndex = 0;
|
||||
const advanceNextLocIndex = () => {
|
||||
while (nextLocIndex < node.body.length && node.body[nextLocIndex].start == null) {
|
||||
nextLocIndex++;
|
||||
}
|
||||
};
|
||||
advanceNextLocIndex();
|
||||
return i => {
|
||||
if (nextLocIndex <= i) {
|
||||
nextLocIndex = i + 1;
|
||||
advanceNextLocIndex();
|
||||
}
|
||||
const end = nextLocIndex === node.body.length ? node.end : node.body[nextLocIndex].start;
|
||||
let tok;
|
||||
while (k < indexes.length && printer.tokenMap.matchesOriginal(tok = printer._tokens[indexes[k]], ";") && tok.start < end) {
|
||||
printer.token(";", undefined, occurrenceCount++);
|
||||
k++;
|
||||
}
|
||||
};
|
||||
}
|
||||
function ClassProperty(node) {
|
||||
this.printJoin(node.decorators);
|
||||
if (!node.static && !this.format.preserveFormat) {
|
||||
var _node$key$loc;
|
||||
const endLine = (_node$key$loc = node.key.loc) == null || (_node$key$loc = _node$key$loc.end) == null ? void 0 : _node$key$loc.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
}
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this._variance(node);
|
||||
this.print(node.key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassAccessorProperty(node) {
|
||||
var _node$key$loc2;
|
||||
this.printJoin(node.decorators);
|
||||
const endLine = (_node$key$loc2 = node.key.loc) == null || (_node$key$loc2 = _node$key$loc2.end) == null ? void 0 : _node$key$loc2.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
this.word("accessor", true);
|
||||
this.space();
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this._variance(node);
|
||||
this.print(node.key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassPrivateProperty(node) {
|
||||
this.printJoin(node.decorators);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
this.print(node.key);
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ClassPrivateMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function _classMethodHead(node) {
|
||||
this.printJoin(node.decorators);
|
||||
if (!this.format.preserveFormat) {
|
||||
var _node$key$loc3;
|
||||
const endLine = (_node$key$loc3 = node.key.loc) == null || (_node$key$loc3 = _node$key$loc3.end) == null ? void 0 : _node$key$loc3.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
}
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
this._methodHead(node);
|
||||
}
|
||||
function StaticBlock(node) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
if (node.body.length === 0) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
this.printSequence(node.body, true);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=classes.js.map
|
1
node_modules/@babel/generator/lib/generators/classes.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/classes.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
28
node_modules/@babel/generator/lib/generators/deprecated.js
generated
vendored
Normal file
28
node_modules/@babel/generator/lib/generators/deprecated.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.addDeprecatedGenerators = addDeprecatedGenerators;
|
||||
function addDeprecatedGenerators(PrinterClass) {
|
||||
{
|
||||
const deprecatedBabel7Generators = {
|
||||
Noop() {},
|
||||
TSExpressionWithTypeArguments(node) {
|
||||
this.print(node.expression);
|
||||
this.print(node.typeParameters);
|
||||
},
|
||||
DecimalLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.word(raw);
|
||||
return;
|
||||
}
|
||||
this.word(node.value + "m");
|
||||
}
|
||||
};
|
||||
Object.assign(PrinterClass.prototype, deprecatedBabel7Generators);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=deprecated.js.map
|
1
node_modules/@babel/generator/lib/generators/deprecated.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/deprecated.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["addDeprecatedGenerators","PrinterClass","deprecatedBabel7Generators","Noop","TSExpressionWithTypeArguments","node","print","expression","typeParameters","DecimalLiteral","raw","getPossibleRaw","format","minified","undefined","word","value","Object","assign","prototype"],"sources":["../../src/generators/deprecated.ts"],"sourcesContent":["import type Printer from \"../printer\";\nimport type * as t from \"@babel/types\";\n\nexport type DeprecatedBabel7ASTTypes =\n | \"Noop\"\n | \"TSExpressionWithTypeArguments\"\n | \"DecimalLiteral\";\n\nexport function addDeprecatedGenerators(PrinterClass: typeof Printer) {\n // Add Babel 7 generator methods that is removed in Babel 8\n if (!process.env.BABEL_8_BREAKING) {\n const deprecatedBabel7Generators = {\n Noop(this: Printer) {},\n\n TSExpressionWithTypeArguments(\n this: Printer,\n // @ts-ignore(Babel 7 vs Babel 8) Babel 7 AST\n node: t.TSExpressionWithTypeArguments,\n ) {\n this.print(node.expression);\n this.print(node.typeParameters);\n },\n\n DecimalLiteral(this: Printer, node: any) {\n const raw = this.getPossibleRaw(node);\n if (!this.format.minified && raw !== undefined) {\n this.word(raw);\n return;\n }\n this.word(node.value + \"m\");\n },\n } satisfies Record<\n DeprecatedBabel7ASTTypes,\n (this: Printer, node: any) => void\n >;\n Object.assign(PrinterClass.prototype, deprecatedBabel7Generators);\n }\n}\n"],"mappings":";;;;;;AAQO,SAASA,uBAAuBA,CAACC,YAA4B,EAAE;EAEjC;IACjC,MAAMC,0BAA0B,GAAG;MACjCC,IAAIA,CAAA,EAAgB,CAAC,CAAC;MAEtBC,6BAA6BA,CAG3BC,IAAqC,EACrC;QACA,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,UAAU,CAAC;QAC3B,IAAI,CAACD,KAAK,CAACD,IAAI,CAACG,cAAc,CAAC;MACjC,CAAC;MAEDC,cAAcA,CAAgBJ,IAAS,EAAE;QACvC,MAAMK,GAAG,GAAG,IAAI,CAACC,cAAc,CAACN,IAAI,CAAC;QACrC,IAAI,CAAC,IAAI,CAACO,MAAM,CAACC,QAAQ,IAAIH,GAAG,KAAKI,SAAS,EAAE;UAC9C,IAAI,CAACC,IAAI,CAACL,GAAG,CAAC;UACd;QACF;QACA,IAAI,CAACK,IAAI,CAACV,IAAI,CAACW,KAAK,GAAG,GAAG,CAAC;MAC7B;IACF,CAGC;IACDC,MAAM,CAACC,MAAM,CAACjB,YAAY,CAACkB,SAAS,EAAEjB,0BAA0B,CAAC;EACnE;AACF","ignoreList":[]}
|
301
node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
Normal file
301
node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
Normal file
|
@ -0,0 +1,301 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.LogicalExpression = exports.BinaryExpression = exports.AssignmentExpression = AssignmentExpression;
|
||||
exports.AssignmentPattern = AssignmentPattern;
|
||||
exports.AwaitExpression = AwaitExpression;
|
||||
exports.BindExpression = BindExpression;
|
||||
exports.CallExpression = CallExpression;
|
||||
exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.Decorator = Decorator;
|
||||
exports.DoExpression = DoExpression;
|
||||
exports.EmptyStatement = EmptyStatement;
|
||||
exports.ExpressionStatement = ExpressionStatement;
|
||||
exports.Import = Import;
|
||||
exports.MemberExpression = MemberExpression;
|
||||
exports.MetaProperty = MetaProperty;
|
||||
exports.ModuleExpression = ModuleExpression;
|
||||
exports.NewExpression = NewExpression;
|
||||
exports.OptionalCallExpression = OptionalCallExpression;
|
||||
exports.OptionalMemberExpression = OptionalMemberExpression;
|
||||
exports.ParenthesizedExpression = ParenthesizedExpression;
|
||||
exports.PrivateName = PrivateName;
|
||||
exports.SequenceExpression = SequenceExpression;
|
||||
exports.Super = Super;
|
||||
exports.ThisExpression = ThisExpression;
|
||||
exports.UnaryExpression = UnaryExpression;
|
||||
exports.UpdateExpression = UpdateExpression;
|
||||
exports.V8IntrinsicIdentifier = V8IntrinsicIdentifier;
|
||||
exports.YieldExpression = YieldExpression;
|
||||
exports._shouldPrintDecoratorsBeforeExport = _shouldPrintDecoratorsBeforeExport;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isCallExpression,
|
||||
isLiteral,
|
||||
isMemberExpression,
|
||||
isNewExpression,
|
||||
isPattern
|
||||
} = _t;
|
||||
function UnaryExpression(node) {
|
||||
const {
|
||||
operator
|
||||
} = node;
|
||||
if (operator === "void" || operator === "delete" || operator === "typeof" || operator === "throw") {
|
||||
this.word(operator);
|
||||
this.space();
|
||||
} else {
|
||||
this.token(operator);
|
||||
}
|
||||
this.print(node.argument);
|
||||
}
|
||||
function DoExpression(node) {
|
||||
if (node.async) {
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ParenthesizedExpression(node) {
|
||||
this.tokenChar(40);
|
||||
const exit = this.enterDelimited();
|
||||
this.print(node.expression);
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
function UpdateExpression(node) {
|
||||
if (node.prefix) {
|
||||
this.token(node.operator);
|
||||
this.print(node.argument);
|
||||
} else {
|
||||
this.print(node.argument, true);
|
||||
this.token(node.operator);
|
||||
}
|
||||
}
|
||||
function ConditionalExpression(node) {
|
||||
this.print(node.test);
|
||||
this.space();
|
||||
this.tokenChar(63);
|
||||
this.space();
|
||||
this.print(node.consequent);
|
||||
this.space();
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.alternate);
|
||||
}
|
||||
function NewExpression(node, parent) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.print(node.callee);
|
||||
if (this.format.minified && node.arguments.length === 0 && !node.optional && !isCallExpression(parent, {
|
||||
callee: node
|
||||
}) && !isMemberExpression(parent) && !isNewExpression(parent)) {
|
||||
return;
|
||||
}
|
||||
this.print(node.typeArguments);
|
||||
{
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
if (node.arguments.length === 0 && this.tokenMap && !this.tokenMap.endMatches(node, ")")) {
|
||||
return;
|
||||
}
|
||||
this.tokenChar(40);
|
||||
const exit = this.enterDelimited();
|
||||
this.printList(node.arguments, this.shouldPrintTrailingComma(")"));
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
function SequenceExpression(node) {
|
||||
this.printList(node.expressions);
|
||||
}
|
||||
function ThisExpression() {
|
||||
this.word("this");
|
||||
}
|
||||
function Super() {
|
||||
this.word("super");
|
||||
}
|
||||
function _shouldPrintDecoratorsBeforeExport(node) {
|
||||
if (typeof this.format.decoratorsBeforeExport === "boolean") {
|
||||
return this.format.decoratorsBeforeExport;
|
||||
}
|
||||
return typeof node.start === "number" && node.start === node.declaration.start;
|
||||
}
|
||||
function Decorator(node) {
|
||||
this.tokenChar(64);
|
||||
this.print(node.expression);
|
||||
this.newline();
|
||||
}
|
||||
function OptionalMemberExpression(node) {
|
||||
let {
|
||||
computed
|
||||
} = node;
|
||||
const {
|
||||
optional,
|
||||
property
|
||||
} = node;
|
||||
this.print(node.object);
|
||||
if (!computed && isMemberExpression(property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
if (isLiteral(property) && typeof property.value === "number") {
|
||||
computed = true;
|
||||
}
|
||||
if (optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
if (computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(property);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (!optional) {
|
||||
this.tokenChar(46);
|
||||
}
|
||||
this.print(property);
|
||||
}
|
||||
}
|
||||
function OptionalCallExpression(node) {
|
||||
this.print(node.callee);
|
||||
{
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
this.print(node.typeArguments);
|
||||
this.tokenChar(40);
|
||||
const exit = this.enterDelimited();
|
||||
this.printList(node.arguments);
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
function CallExpression(node) {
|
||||
this.print(node.callee);
|
||||
this.print(node.typeArguments);
|
||||
{
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
this.tokenChar(40);
|
||||
const exit = this.enterDelimited();
|
||||
this.printList(node.arguments, this.shouldPrintTrailingComma(")"));
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
function Import() {
|
||||
this.word("import");
|
||||
}
|
||||
function AwaitExpression(node) {
|
||||
this.word("await");
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument);
|
||||
}
|
||||
}
|
||||
function YieldExpression(node) {
|
||||
this.word("yield", true);
|
||||
if (node.delegate) {
|
||||
this.tokenChar(42);
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.print(node.argument);
|
||||
}
|
||||
} else {
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
function EmptyStatement() {
|
||||
this.semicolon(true);
|
||||
}
|
||||
function ExpressionStatement(node) {
|
||||
this.tokenContext |= _index.TokenContext.expressionStatement;
|
||||
this.print(node.expression);
|
||||
this.semicolon();
|
||||
}
|
||||
function AssignmentPattern(node) {
|
||||
this.print(node.left);
|
||||
if (node.left.type === "Identifier" || isPattern(node.left)) {
|
||||
if (node.left.optional) this.tokenChar(63);
|
||||
this.print(node.left.typeAnnotation);
|
||||
}
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
}
|
||||
function AssignmentExpression(node) {
|
||||
this.print(node.left);
|
||||
this.space();
|
||||
if (node.operator === "in" || node.operator === "instanceof") {
|
||||
this.word(node.operator);
|
||||
} else {
|
||||
this.token(node.operator);
|
||||
this._endsWithDiv = node.operator === "/";
|
||||
}
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
}
|
||||
function BindExpression(node) {
|
||||
this.print(node.object);
|
||||
this.token("::");
|
||||
this.print(node.callee);
|
||||
}
|
||||
function MemberExpression(node) {
|
||||
this.print(node.object);
|
||||
if (!node.computed && isMemberExpression(node.property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
let computed = node.computed;
|
||||
if (isLiteral(node.property) && typeof node.property.value === "number") {
|
||||
computed = true;
|
||||
}
|
||||
if (computed) {
|
||||
const exit = this.enterDelimited();
|
||||
this.tokenChar(91);
|
||||
this.print(node.property);
|
||||
this.tokenChar(93);
|
||||
exit();
|
||||
} else {
|
||||
this.tokenChar(46);
|
||||
this.print(node.property);
|
||||
}
|
||||
}
|
||||
function MetaProperty(node) {
|
||||
this.print(node.meta);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property);
|
||||
}
|
||||
function PrivateName(node) {
|
||||
this.tokenChar(35);
|
||||
this.print(node.id);
|
||||
}
|
||||
function V8IntrinsicIdentifier(node) {
|
||||
this.tokenChar(37);
|
||||
this.word(node.name);
|
||||
}
|
||||
function ModuleExpression(node) {
|
||||
this.word("module", true);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.indent();
|
||||
const {
|
||||
body
|
||||
} = node;
|
||||
if (body.body.length || body.directives.length) {
|
||||
this.newline();
|
||||
}
|
||||
this.print(body);
|
||||
this.dedent();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=expressions.js.map
|
1
node_modules/@babel/generator/lib/generators/expressions.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/expressions.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
660
node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
Normal file
660
node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
Normal file
|
@ -0,0 +1,660 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.AnyTypeAnnotation = AnyTypeAnnotation;
|
||||
exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
|
||||
exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
|
||||
exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
|
||||
exports.DeclareClass = DeclareClass;
|
||||
exports.DeclareExportAllDeclaration = DeclareExportAllDeclaration;
|
||||
exports.DeclareExportDeclaration = DeclareExportDeclaration;
|
||||
exports.DeclareFunction = DeclareFunction;
|
||||
exports.DeclareInterface = DeclareInterface;
|
||||
exports.DeclareModule = DeclareModule;
|
||||
exports.DeclareModuleExports = DeclareModuleExports;
|
||||
exports.DeclareOpaqueType = DeclareOpaqueType;
|
||||
exports.DeclareTypeAlias = DeclareTypeAlias;
|
||||
exports.DeclareVariable = DeclareVariable;
|
||||
exports.DeclaredPredicate = DeclaredPredicate;
|
||||
exports.EmptyTypeAnnotation = EmptyTypeAnnotation;
|
||||
exports.EnumBooleanBody = EnumBooleanBody;
|
||||
exports.EnumBooleanMember = EnumBooleanMember;
|
||||
exports.EnumDeclaration = EnumDeclaration;
|
||||
exports.EnumDefaultedMember = EnumDefaultedMember;
|
||||
exports.EnumNumberBody = EnumNumberBody;
|
||||
exports.EnumNumberMember = EnumNumberMember;
|
||||
exports.EnumStringBody = EnumStringBody;
|
||||
exports.EnumStringMember = EnumStringMember;
|
||||
exports.EnumSymbolBody = EnumSymbolBody;
|
||||
exports.ExistsTypeAnnotation = ExistsTypeAnnotation;
|
||||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||||
exports.FunctionTypeParam = FunctionTypeParam;
|
||||
exports.IndexedAccessType = IndexedAccessType;
|
||||
exports.InferredPredicate = InferredPredicate;
|
||||
exports.InterfaceDeclaration = InterfaceDeclaration;
|
||||
exports.GenericTypeAnnotation = exports.ClassImplements = exports.InterfaceExtends = InterfaceExtends;
|
||||
exports.InterfaceTypeAnnotation = InterfaceTypeAnnotation;
|
||||
exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
|
||||
exports.MixedTypeAnnotation = MixedTypeAnnotation;
|
||||
exports.NullLiteralTypeAnnotation = NullLiteralTypeAnnotation;
|
||||
exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
||||
Object.defineProperty(exports, "NumberLiteralTypeAnnotation", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _types2.NumericLiteral;
|
||||
}
|
||||
});
|
||||
exports.NumberTypeAnnotation = NumberTypeAnnotation;
|
||||
exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
|
||||
exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
|
||||
exports.ObjectTypeIndexer = ObjectTypeIndexer;
|
||||
exports.ObjectTypeInternalSlot = ObjectTypeInternalSlot;
|
||||
exports.ObjectTypeProperty = ObjectTypeProperty;
|
||||
exports.ObjectTypeSpreadProperty = ObjectTypeSpreadProperty;
|
||||
exports.OpaqueType = OpaqueType;
|
||||
exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
|
||||
exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
|
||||
Object.defineProperty(exports, "StringLiteralTypeAnnotation", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _types2.StringLiteral;
|
||||
}
|
||||
});
|
||||
exports.StringTypeAnnotation = StringTypeAnnotation;
|
||||
exports.SymbolTypeAnnotation = SymbolTypeAnnotation;
|
||||
exports.ThisTypeAnnotation = ThisTypeAnnotation;
|
||||
exports.TupleTypeAnnotation = TupleTypeAnnotation;
|
||||
exports.TypeAlias = TypeAlias;
|
||||
exports.TypeAnnotation = TypeAnnotation;
|
||||
exports.TypeCastExpression = TypeCastExpression;
|
||||
exports.TypeParameter = TypeParameter;
|
||||
exports.TypeParameterDeclaration = exports.TypeParameterInstantiation = TypeParameterInstantiation;
|
||||
exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
|
||||
exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||||
exports.Variance = Variance;
|
||||
exports.VoidTypeAnnotation = VoidTypeAnnotation;
|
||||
exports._interfaceish = _interfaceish;
|
||||
exports._variance = _variance;
|
||||
var _t = require("@babel/types");
|
||||
var _modules = require("./modules.js");
|
||||
var _index = require("../node/index.js");
|
||||
var _types2 = require("./types.js");
|
||||
const {
|
||||
isDeclareExportDeclaration,
|
||||
isStatement
|
||||
} = _t;
|
||||
function AnyTypeAnnotation() {
|
||||
this.word("any");
|
||||
}
|
||||
function ArrayTypeAnnotation(node) {
|
||||
this.print(node.elementType, true);
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function BooleanTypeAnnotation() {
|
||||
this.word("boolean");
|
||||
}
|
||||
function BooleanLiteralTypeAnnotation(node) {
|
||||
this.word(node.value ? "true" : "false");
|
||||
}
|
||||
function NullLiteralTypeAnnotation() {
|
||||
this.word("null");
|
||||
}
|
||||
function DeclareClass(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("class");
|
||||
this.space();
|
||||
this._interfaceish(node);
|
||||
}
|
||||
function DeclareFunction(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("function");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.print(node.id.typeAnnotation.typeAnnotation);
|
||||
if (node.predicate) {
|
||||
this.space();
|
||||
this.print(node.predicate);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function InferredPredicate() {
|
||||
this.tokenChar(37);
|
||||
this.word("checks");
|
||||
}
|
||||
function DeclaredPredicate(node) {
|
||||
this.tokenChar(37);
|
||||
this.word("checks");
|
||||
this.tokenChar(40);
|
||||
this.print(node.value);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function DeclareInterface(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.InterfaceDeclaration(node);
|
||||
}
|
||||
function DeclareModule(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("module");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function DeclareModuleExports(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("module");
|
||||
this.tokenChar(46);
|
||||
this.word("exports");
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function DeclareTypeAlias(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.TypeAlias(node);
|
||||
}
|
||||
function DeclareOpaqueType(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.OpaqueType(node);
|
||||
}
|
||||
function DeclareVariable(node, parent) {
|
||||
if (!isDeclareExportDeclaration(parent)) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("var");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.print(node.id.typeAnnotation);
|
||||
this.semicolon();
|
||||
}
|
||||
function DeclareExportDeclaration(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
this.word("export");
|
||||
this.space();
|
||||
if (node.default) {
|
||||
this.word("default");
|
||||
this.space();
|
||||
}
|
||||
FlowExportDeclaration.call(this, node);
|
||||
}
|
||||
function DeclareExportAllDeclaration(node) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
_modules.ExportAllDeclaration.call(this, node);
|
||||
}
|
||||
function EnumDeclaration(node) {
|
||||
const {
|
||||
id,
|
||||
body
|
||||
} = node;
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id);
|
||||
this.print(body);
|
||||
}
|
||||
function enumExplicitType(context, name, hasExplicitType) {
|
||||
if (hasExplicitType) {
|
||||
context.space();
|
||||
context.word("of");
|
||||
context.space();
|
||||
context.word(name);
|
||||
}
|
||||
context.space();
|
||||
}
|
||||
function enumBody(context, node) {
|
||||
const {
|
||||
members
|
||||
} = node;
|
||||
context.token("{");
|
||||
context.indent();
|
||||
context.newline();
|
||||
for (const member of members) {
|
||||
context.print(member);
|
||||
context.newline();
|
||||
}
|
||||
if (node.hasUnknownMembers) {
|
||||
context.token("...");
|
||||
context.newline();
|
||||
}
|
||||
context.dedent();
|
||||
context.token("}");
|
||||
}
|
||||
function EnumBooleanBody(node) {
|
||||
const {
|
||||
explicitType
|
||||
} = node;
|
||||
enumExplicitType(this, "boolean", explicitType);
|
||||
enumBody(this, node);
|
||||
}
|
||||
function EnumNumberBody(node) {
|
||||
const {
|
||||
explicitType
|
||||
} = node;
|
||||
enumExplicitType(this, "number", explicitType);
|
||||
enumBody(this, node);
|
||||
}
|
||||
function EnumStringBody(node) {
|
||||
const {
|
||||
explicitType
|
||||
} = node;
|
||||
enumExplicitType(this, "string", explicitType);
|
||||
enumBody(this, node);
|
||||
}
|
||||
function EnumSymbolBody(node) {
|
||||
enumExplicitType(this, "symbol", true);
|
||||
enumBody(this, node);
|
||||
}
|
||||
function EnumDefaultedMember(node) {
|
||||
const {
|
||||
id
|
||||
} = node;
|
||||
this.print(id);
|
||||
this.tokenChar(44);
|
||||
}
|
||||
function enumInitializedMember(context, node) {
|
||||
context.print(node.id);
|
||||
context.space();
|
||||
context.token("=");
|
||||
context.space();
|
||||
context.print(node.init);
|
||||
context.token(",");
|
||||
}
|
||||
function EnumBooleanMember(node) {
|
||||
enumInitializedMember(this, node);
|
||||
}
|
||||
function EnumNumberMember(node) {
|
||||
enumInitializedMember(this, node);
|
||||
}
|
||||
function EnumStringMember(node) {
|
||||
enumInitializedMember(this, node);
|
||||
}
|
||||
function FlowExportDeclaration(node) {
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
this.tokenChar(123);
|
||||
if (node.specifiers.length) {
|
||||
this.space();
|
||||
this.printList(node.specifiers);
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(125);
|
||||
if (node.source) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
function ExistsTypeAnnotation() {
|
||||
this.tokenChar(42);
|
||||
}
|
||||
function FunctionTypeAnnotation(node, parent) {
|
||||
this.print(node.typeParameters);
|
||||
this.tokenChar(40);
|
||||
if (node.this) {
|
||||
this.word("this");
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.this.typeAnnotation);
|
||||
if (node.params.length || node.rest) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
this.printList(node.params);
|
||||
if (node.rest) {
|
||||
if (node.params.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
this.token("...");
|
||||
this.print(node.rest);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
const type = parent == null ? void 0 : parent.type;
|
||||
if (type != null && (type === "ObjectTypeCallProperty" || type === "ObjectTypeInternalSlot" || type === "DeclareFunction" || type === "ObjectTypeProperty" && parent.method)) {
|
||||
this.tokenChar(58);
|
||||
} else {
|
||||
this.space();
|
||||
this.token("=>");
|
||||
}
|
||||
this.space();
|
||||
this.print(node.returnType);
|
||||
}
|
||||
function FunctionTypeParam(node) {
|
||||
this.print(node.name);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
if (node.name) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function InterfaceExtends(node) {
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters, true);
|
||||
}
|
||||
function _interfaceish(node) {
|
||||
var _node$extends;
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters);
|
||||
if ((_node$extends = node.extends) != null && _node$extends.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends);
|
||||
}
|
||||
if (node.type === "DeclareClass") {
|
||||
var _node$mixins, _node$implements;
|
||||
if ((_node$mixins = node.mixins) != null && _node$mixins.length) {
|
||||
this.space();
|
||||
this.word("mixins");
|
||||
this.space();
|
||||
this.printList(node.mixins);
|
||||
}
|
||||
if ((_node$implements = node.implements) != null && _node$implements.length) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements);
|
||||
}
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function _variance(node) {
|
||||
var _node$variance;
|
||||
const kind = (_node$variance = node.variance) == null ? void 0 : _node$variance.kind;
|
||||
if (kind != null) {
|
||||
if (kind === "plus") {
|
||||
this.tokenChar(43);
|
||||
} else if (kind === "minus") {
|
||||
this.tokenChar(45);
|
||||
}
|
||||
}
|
||||
}
|
||||
function InterfaceDeclaration(node) {
|
||||
this.word("interface");
|
||||
this.space();
|
||||
this._interfaceish(node);
|
||||
}
|
||||
function andSeparator(occurrenceCount) {
|
||||
this.space();
|
||||
this.token("&", false, occurrenceCount);
|
||||
this.space();
|
||||
}
|
||||
function InterfaceTypeAnnotation(node) {
|
||||
var _node$extends2;
|
||||
this.word("interface");
|
||||
if ((_node$extends2 = node.extends) != null && _node$extends2.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function IntersectionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, undefined, undefined, andSeparator);
|
||||
}
|
||||
function MixedTypeAnnotation() {
|
||||
this.word("mixed");
|
||||
}
|
||||
function EmptyTypeAnnotation() {
|
||||
this.word("empty");
|
||||
}
|
||||
function NullableTypeAnnotation(node) {
|
||||
this.tokenChar(63);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function NumberTypeAnnotation() {
|
||||
this.word("number");
|
||||
}
|
||||
function StringTypeAnnotation() {
|
||||
this.word("string");
|
||||
}
|
||||
function ThisTypeAnnotation() {
|
||||
this.word("this");
|
||||
}
|
||||
function TupleTypeAnnotation(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.types);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TypeofTypeAnnotation(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.argument);
|
||||
}
|
||||
function TypeAlias(node) {
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
this.semicolon();
|
||||
}
|
||||
function TypeAnnotation(node, parent) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
if (parent.type === "ArrowFunctionExpression") {
|
||||
this.tokenContext |= _index.TokenContext.arrowFlowReturnType;
|
||||
} else if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TypeParameterInstantiation(node) {
|
||||
this.tokenChar(60);
|
||||
this.printList(node.params);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function TypeParameter(node) {
|
||||
this._variance(node);
|
||||
this.word(node.name);
|
||||
if (node.bound) {
|
||||
this.print(node.bound);
|
||||
}
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.default);
|
||||
}
|
||||
}
|
||||
function OpaqueType(node) {
|
||||
this.word("opaque");
|
||||
this.space();
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.print(node.typeParameters);
|
||||
if (node.supertype) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.supertype);
|
||||
}
|
||||
if (node.impltype) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.impltype);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ObjectTypeAnnotation(node) {
|
||||
if (node.exact) {
|
||||
this.token("{|");
|
||||
} else {
|
||||
this.tokenChar(123);
|
||||
}
|
||||
const props = [...node.properties, ...(node.callProperties || []), ...(node.indexers || []), ...(node.internalSlots || [])];
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
this.space();
|
||||
this.printJoin(props, true, true, undefined, undefined, function addNewlines(leading) {
|
||||
if (leading && !props[0]) return 1;
|
||||
}, () => {
|
||||
if (props.length !== 1 || node.inexact) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
if (node.inexact) {
|
||||
this.indent();
|
||||
this.token("...");
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
}
|
||||
this.dedent();
|
||||
}
|
||||
if (node.exact) {
|
||||
this.token("|}");
|
||||
} else {
|
||||
this.tokenChar(125);
|
||||
}
|
||||
}
|
||||
function ObjectTypeInternalSlot(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(91);
|
||||
this.print(node.id);
|
||||
this.tokenChar(93);
|
||||
this.tokenChar(93);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
if (!node.method) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeCallProperty(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeIndexer(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
this._variance(node);
|
||||
this.tokenChar(91);
|
||||
if (node.id) {
|
||||
this.print(node.id);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeProperty(node) {
|
||||
if (node.proto) {
|
||||
this.word("proto");
|
||||
this.space();
|
||||
}
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
if (node.kind === "get" || node.kind === "set") {
|
||||
this.word(node.kind);
|
||||
this.space();
|
||||
}
|
||||
this._variance(node);
|
||||
this.print(node.key);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
if (!node.method) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeSpreadProperty(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument);
|
||||
}
|
||||
function QualifiedTypeIdentifier(node) {
|
||||
this.print(node.qualification);
|
||||
this.tokenChar(46);
|
||||
this.print(node.id);
|
||||
}
|
||||
function SymbolTypeAnnotation() {
|
||||
this.word("symbol");
|
||||
}
|
||||
function orSeparator(occurrenceCount) {
|
||||
this.space();
|
||||
this.token("|", false, occurrenceCount);
|
||||
this.space();
|
||||
}
|
||||
function UnionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, undefined, undefined, orSeparator);
|
||||
}
|
||||
function TypeCastExpression(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.expression);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function Variance(node) {
|
||||
if (node.kind === "plus") {
|
||||
this.tokenChar(43);
|
||||
} else {
|
||||
this.tokenChar(45);
|
||||
}
|
||||
}
|
||||
function VoidTypeAnnotation() {
|
||||
this.word("void");
|
||||
}
|
||||
function IndexedAccessType(node) {
|
||||
this.print(node.objectType, true);
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function OptionalIndexedAccessType(node) {
|
||||
this.print(node.objectType);
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=flow.js.map
|
1
node_modules/@babel/generator/lib/generators/flow.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/flow.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
128
node_modules/@babel/generator/lib/generators/index.js
generated
vendored
Normal file
128
node_modules/@babel/generator/lib/generators/index.js
generated
vendored
Normal file
|
@ -0,0 +1,128 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
var _templateLiterals = require("./template-literals.js");
|
||||
Object.keys(_templateLiterals).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _templateLiterals[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _templateLiterals[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _expressions = require("./expressions.js");
|
||||
Object.keys(_expressions).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _expressions[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _expressions[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _statements = require("./statements.js");
|
||||
Object.keys(_statements).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _statements[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _statements[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _classes = require("./classes.js");
|
||||
Object.keys(_classes).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _classes[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _classes[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _methods = require("./methods.js");
|
||||
Object.keys(_methods).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _methods[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _methods[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _modules = require("./modules.js");
|
||||
Object.keys(_modules).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _modules[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _modules[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _types = require("./types.js");
|
||||
Object.keys(_types).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _types[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _types[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _flow = require("./flow.js");
|
||||
Object.keys(_flow).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _flow[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _flow[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _base = require("./base.js");
|
||||
Object.keys(_base).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _base[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _base[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _jsx = require("./jsx.js");
|
||||
Object.keys(_jsx).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _jsx[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _jsx[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
var _typescript = require("./typescript.js");
|
||||
Object.keys(_typescript).forEach(function (key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
if (key in exports && exports[key] === _typescript[key]) return;
|
||||
Object.defineProperty(exports, key, {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _typescript[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@babel/generator/lib/generators/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/index.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["_templateLiterals","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_expressions","_statements","_classes","_methods","_modules","_types","_flow","_base","_jsx","_typescript"],"sources":["../../src/generators/index.ts"],"sourcesContent":["export * from \"./template-literals.ts\";\nexport * from \"./expressions.ts\";\nexport * from \"./statements.ts\";\nexport * from \"./classes.ts\";\nexport * from \"./methods.ts\";\nexport * from \"./modules.ts\";\nexport * from \"./types.ts\";\nexport * from \"./flow.ts\";\nexport * from \"./base.ts\";\nexport * from \"./jsx.ts\";\nexport * from \"./typescript.ts\";\n"],"mappings":";;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,iBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,iBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,iBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,YAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,YAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,YAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,YAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,WAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,WAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,WAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,WAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,QAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,QAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,QAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,QAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,QAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,QAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,QAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,QAAA,CAAAR,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,QAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,QAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAS,QAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAK,QAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AACA,IAAAU,MAAA,GAAAd,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAY,MAAA,EAAAX,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAU,MAAA,CAAAV,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAM,MAAA,CAAAV,GAAA;IAAA;EAAA;AAAA;AACA,IAAAW,KAAA,GAAAf,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAa,KAAA,EAAAZ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAW,KAAA,CAAAX,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAO,KAAA,CAAAX,GAAA;IAAA;EAAA;AAAA;AACA,IAAAY,KAAA,GAAAhB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAc,KAAA,EAAAb,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAY,KAAA,CAAAZ,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAQ,KAAA,CAAAZ,GAAA;IAAA;EAAA;AAAA;AACA,IAAAa,IAAA,GAAAjB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAe,IAAA,EAAAd,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAa,IAAA,CAAAb,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAS,IAAA,CAAAb,GAAA;IAAA;EAAA;AAAA;AACA,IAAAc,WAAA,GAAAlB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAgB,WAAA,EAAAf,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAc,WAAA,CAAAd,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAU,WAAA,CAAAd,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
126
node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
Normal file
126
node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
Normal file
|
@ -0,0 +1,126 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.JSXAttribute = JSXAttribute;
|
||||
exports.JSXClosingElement = JSXClosingElement;
|
||||
exports.JSXClosingFragment = JSXClosingFragment;
|
||||
exports.JSXElement = JSXElement;
|
||||
exports.JSXEmptyExpression = JSXEmptyExpression;
|
||||
exports.JSXExpressionContainer = JSXExpressionContainer;
|
||||
exports.JSXFragment = JSXFragment;
|
||||
exports.JSXIdentifier = JSXIdentifier;
|
||||
exports.JSXMemberExpression = JSXMemberExpression;
|
||||
exports.JSXNamespacedName = JSXNamespacedName;
|
||||
exports.JSXOpeningElement = JSXOpeningElement;
|
||||
exports.JSXOpeningFragment = JSXOpeningFragment;
|
||||
exports.JSXSpreadAttribute = JSXSpreadAttribute;
|
||||
exports.JSXSpreadChild = JSXSpreadChild;
|
||||
exports.JSXText = JSXText;
|
||||
function JSXAttribute(node) {
|
||||
this.print(node.name);
|
||||
if (node.value) {
|
||||
this.tokenChar(61);
|
||||
this.print(node.value);
|
||||
}
|
||||
}
|
||||
function JSXIdentifier(node) {
|
||||
this.word(node.name);
|
||||
}
|
||||
function JSXNamespacedName(node) {
|
||||
this.print(node.namespace);
|
||||
this.tokenChar(58);
|
||||
this.print(node.name);
|
||||
}
|
||||
function JSXMemberExpression(node) {
|
||||
this.print(node.object);
|
||||
this.tokenChar(46);
|
||||
this.print(node.property);
|
||||
}
|
||||
function JSXSpreadAttribute(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.argument);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXExpressionContainer(node) {
|
||||
this.tokenChar(123);
|
||||
this.print(node.expression);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXSpreadChild(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.expression);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXText(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
if (raw !== undefined) {
|
||||
this.token(raw, true);
|
||||
} else {
|
||||
this.token(node.value, true);
|
||||
}
|
||||
}
|
||||
function JSXElement(node) {
|
||||
const open = node.openingElement;
|
||||
this.print(open);
|
||||
if (open.selfClosing) return;
|
||||
this.indent();
|
||||
for (const child of node.children) {
|
||||
this.print(child);
|
||||
}
|
||||
this.dedent();
|
||||
this.print(node.closingElement);
|
||||
}
|
||||
function spaceSeparator() {
|
||||
this.space();
|
||||
}
|
||||
function JSXOpeningElement(node) {
|
||||
this.tokenChar(60);
|
||||
this.print(node.name);
|
||||
{
|
||||
if (node.typeArguments) {
|
||||
this.print(node.typeArguments);
|
||||
}
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
if (node.attributes.length > 0) {
|
||||
this.space();
|
||||
this.printJoin(node.attributes, undefined, undefined, spaceSeparator);
|
||||
}
|
||||
if (node.selfClosing) {
|
||||
this.space();
|
||||
this.tokenChar(47);
|
||||
}
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXClosingElement(node) {
|
||||
this.tokenChar(60);
|
||||
this.tokenChar(47);
|
||||
this.print(node.name);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXEmptyExpression() {
|
||||
this.printInnerComments();
|
||||
}
|
||||
function JSXFragment(node) {
|
||||
this.print(node.openingFragment);
|
||||
this.indent();
|
||||
for (const child of node.children) {
|
||||
this.print(child);
|
||||
}
|
||||
this.dedent();
|
||||
this.print(node.closingFragment);
|
||||
}
|
||||
function JSXOpeningFragment() {
|
||||
this.tokenChar(60);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXClosingFragment() {
|
||||
this.token("</");
|
||||
this.tokenChar(62);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=jsx.js.map
|
1
node_modules/@babel/generator/lib/generators/jsx.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/jsx.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
198
node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
Normal file
198
node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
Normal file
|
@ -0,0 +1,198 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ArrowFunctionExpression = ArrowFunctionExpression;
|
||||
exports.FunctionDeclaration = exports.FunctionExpression = FunctionExpression;
|
||||
exports._functionHead = _functionHead;
|
||||
exports._methodHead = _methodHead;
|
||||
exports._param = _param;
|
||||
exports._parameters = _parameters;
|
||||
exports._params = _params;
|
||||
exports._predicate = _predicate;
|
||||
exports._shouldPrintArrowParamsParens = _shouldPrintArrowParamsParens;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isIdentifier
|
||||
} = _t;
|
||||
function _params(node, idNode, parentNode) {
|
||||
this.print(node.typeParameters);
|
||||
const nameInfo = _getFuncIdName.call(this, idNode, parentNode);
|
||||
if (nameInfo) {
|
||||
this.sourceIdentifierName(nameInfo.name, nameInfo.pos);
|
||||
}
|
||||
this.tokenChar(40);
|
||||
this._parameters(node.params, ")");
|
||||
const noLineTerminator = node.type === "ArrowFunctionExpression";
|
||||
this.print(node.returnType, noLineTerminator);
|
||||
this._noLineTerminator = noLineTerminator;
|
||||
}
|
||||
function _parameters(parameters, endToken) {
|
||||
const exit = this.enterDelimited();
|
||||
const trailingComma = this.shouldPrintTrailingComma(endToken);
|
||||
const paramLength = parameters.length;
|
||||
for (let i = 0; i < paramLength; i++) {
|
||||
this._param(parameters[i]);
|
||||
if (trailingComma || i < paramLength - 1) {
|
||||
this.token(",", null, i);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
this.token(endToken);
|
||||
exit();
|
||||
}
|
||||
function _param(parameter) {
|
||||
this.printJoin(parameter.decorators);
|
||||
this.print(parameter);
|
||||
if (parameter.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
this.print(parameter.typeAnnotation);
|
||||
}
|
||||
function _methodHead(node) {
|
||||
const kind = node.kind;
|
||||
const key = node.key;
|
||||
if (kind === "get" || kind === "set") {
|
||||
this.word(kind);
|
||||
this.space();
|
||||
}
|
||||
if (node.async) {
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
if (kind === "method" || kind === "init") {
|
||||
if (node.generator) {
|
||||
this.tokenChar(42);
|
||||
}
|
||||
}
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this.print(key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
this._params(node, node.computed && node.key.type !== "StringLiteral" ? undefined : node.key, undefined);
|
||||
}
|
||||
function _predicate(node, noLineTerminatorAfter) {
|
||||
if (node.predicate) {
|
||||
if (!node.returnType) {
|
||||
this.tokenChar(58);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.predicate, noLineTerminatorAfter);
|
||||
}
|
||||
}
|
||||
function _functionHead(node, parent) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
if (!this.format.preserveFormat) {
|
||||
this._endsWithInnerRaw = false;
|
||||
}
|
||||
this.space();
|
||||
}
|
||||
this.word("function");
|
||||
if (node.generator) {
|
||||
if (!this.format.preserveFormat) {
|
||||
this._endsWithInnerRaw = false;
|
||||
}
|
||||
this.tokenChar(42);
|
||||
}
|
||||
this.space();
|
||||
if (node.id) {
|
||||
this.print(node.id);
|
||||
}
|
||||
this._params(node, node.id, parent);
|
||||
if (node.type !== "TSDeclareFunction") {
|
||||
this._predicate(node);
|
||||
}
|
||||
}
|
||||
function FunctionExpression(node, parent) {
|
||||
this._functionHead(node, parent);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ArrowFunctionExpression(node, parent) {
|
||||
if (node.async) {
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
if (this._shouldPrintArrowParamsParens(node)) {
|
||||
this._params(node, undefined, parent);
|
||||
} else {
|
||||
this.print(node.params[0], true);
|
||||
}
|
||||
this._predicate(node, true);
|
||||
this.space();
|
||||
this.printInnerComments();
|
||||
this.token("=>");
|
||||
this.space();
|
||||
this.tokenContext |= _index.TokenContext.arrowBody;
|
||||
this.print(node.body);
|
||||
}
|
||||
function _shouldPrintArrowParamsParens(node) {
|
||||
var _firstParam$leadingCo, _firstParam$trailingC;
|
||||
if (node.params.length !== 1) return true;
|
||||
if (node.typeParameters || node.returnType || node.predicate) {
|
||||
return true;
|
||||
}
|
||||
const firstParam = node.params[0];
|
||||
if (!isIdentifier(firstParam) || firstParam.typeAnnotation || firstParam.optional || (_firstParam$leadingCo = firstParam.leadingComments) != null && _firstParam$leadingCo.length || (_firstParam$trailingC = firstParam.trailingComments) != null && _firstParam$trailingC.length) {
|
||||
return true;
|
||||
}
|
||||
if (this.tokenMap) {
|
||||
if (node.loc == null) return true;
|
||||
if (this.tokenMap.findMatching(node, "(") !== null) return true;
|
||||
const arrowToken = this.tokenMap.findMatching(node, "=>");
|
||||
if ((arrowToken == null ? void 0 : arrowToken.loc) == null) return true;
|
||||
return arrowToken.loc.start.line !== node.loc.start.line;
|
||||
}
|
||||
if (this.format.retainLines) return true;
|
||||
return false;
|
||||
}
|
||||
function _getFuncIdName(idNode, parent) {
|
||||
let id = idNode;
|
||||
if (!id && parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "VariableDeclarator") {
|
||||
id = parent.id;
|
||||
} else if (parentType === "AssignmentExpression" || parentType === "AssignmentPattern") {
|
||||
id = parent.left;
|
||||
} else if (parentType === "ObjectProperty" || parentType === "ClassProperty") {
|
||||
if (!parent.computed || parent.key.type === "StringLiteral") {
|
||||
id = parent.key;
|
||||
}
|
||||
} else if (parentType === "ClassPrivateProperty" || parentType === "ClassAccessorProperty") {
|
||||
id = parent.key;
|
||||
}
|
||||
}
|
||||
if (!id) return;
|
||||
let nameInfo;
|
||||
if (id.type === "Identifier") {
|
||||
var _id$loc, _id$loc2;
|
||||
nameInfo = {
|
||||
pos: (_id$loc = id.loc) == null ? void 0 : _id$loc.start,
|
||||
name: ((_id$loc2 = id.loc) == null ? void 0 : _id$loc2.identifierName) || id.name
|
||||
};
|
||||
} else if (id.type === "PrivateName") {
|
||||
var _id$loc3;
|
||||
nameInfo = {
|
||||
pos: (_id$loc3 = id.loc) == null ? void 0 : _id$loc3.start,
|
||||
name: "#" + id.id.name
|
||||
};
|
||||
} else if (id.type === "StringLiteral") {
|
||||
var _id$loc4;
|
||||
nameInfo = {
|
||||
pos: (_id$loc4 = id.loc) == null ? void 0 : _id$loc4.start,
|
||||
name: id.value
|
||||
};
|
||||
}
|
||||
return nameInfo;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=methods.js.map
|
1
node_modules/@babel/generator/lib/generators/methods.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/methods.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
283
node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
Normal file
283
node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
Normal file
|
@ -0,0 +1,283 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ExportAllDeclaration = ExportAllDeclaration;
|
||||
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
|
||||
exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
|
||||
exports.ExportNamedDeclaration = ExportNamedDeclaration;
|
||||
exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
|
||||
exports.ExportSpecifier = ExportSpecifier;
|
||||
exports.ImportAttribute = ImportAttribute;
|
||||
exports.ImportDeclaration = ImportDeclaration;
|
||||
exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
|
||||
exports.ImportExpression = ImportExpression;
|
||||
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
|
||||
exports.ImportSpecifier = ImportSpecifier;
|
||||
exports._printAttributes = _printAttributes;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isClassDeclaration,
|
||||
isExportDefaultSpecifier,
|
||||
isExportNamespaceSpecifier,
|
||||
isImportDefaultSpecifier,
|
||||
isImportNamespaceSpecifier,
|
||||
isStatement
|
||||
} = _t;
|
||||
function ImportSpecifier(node) {
|
||||
if (node.importKind === "type" || node.importKind === "typeof") {
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.imported);
|
||||
if (node.local && node.local.name !== node.imported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.local);
|
||||
}
|
||||
}
|
||||
function ImportDefaultSpecifier(node) {
|
||||
this.print(node.local);
|
||||
}
|
||||
function ExportDefaultSpecifier(node) {
|
||||
this.print(node.exported);
|
||||
}
|
||||
function ExportSpecifier(node) {
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.local);
|
||||
if (node.exported && node.local.name !== node.exported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported);
|
||||
}
|
||||
}
|
||||
function ExportNamespaceSpecifier(node) {
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported);
|
||||
}
|
||||
let warningShown = false;
|
||||
function _printAttributes(node, hasPreviousBrace) {
|
||||
var _node$extra;
|
||||
const {
|
||||
importAttributesKeyword
|
||||
} = this.format;
|
||||
const {
|
||||
attributes,
|
||||
assertions
|
||||
} = node;
|
||||
if (attributes && !importAttributesKeyword && node.extra && (node.extra.deprecatedAssertSyntax || node.extra.deprecatedWithLegacySyntax) && !warningShown) {
|
||||
warningShown = true;
|
||||
console.warn(`\
|
||||
You are using import attributes, without specifying the desired output syntax.
|
||||
Please specify the "importAttributesKeyword" generator option, whose value can be one of:
|
||||
- "with" : \`import { a } from "b" with { type: "json" };\`
|
||||
- "assert" : \`import { a } from "b" assert { type: "json" };\`
|
||||
- "with-legacy" : \`import { a } from "b" with type: "json";\`
|
||||
`);
|
||||
}
|
||||
const useAssertKeyword = importAttributesKeyword === "assert" || !importAttributesKeyword && assertions;
|
||||
this.word(useAssertKeyword ? "assert" : "with");
|
||||
this.space();
|
||||
if (!useAssertKeyword && (importAttributesKeyword === "with-legacy" || !importAttributesKeyword && (_node$extra = node.extra) != null && _node$extra.deprecatedWithLegacySyntax)) {
|
||||
this.printList(attributes || assertions);
|
||||
return;
|
||||
}
|
||||
const occurrenceCount = hasPreviousBrace ? 1 : 0;
|
||||
this.token("{", null, occurrenceCount);
|
||||
this.space();
|
||||
this.printList(attributes || assertions, this.shouldPrintTrailingComma("}"));
|
||||
this.space();
|
||||
this.token("}", null, occurrenceCount);
|
||||
}
|
||||
function ExportAllDeclaration(node) {
|
||||
var _node$attributes, _node$assertions;
|
||||
this.word("export");
|
||||
this.space();
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
if ((_node$attributes = node.attributes) != null && _node$attributes.length || (_node$assertions = node.assertions) != null && _node$assertions.length) {
|
||||
this.print(node.source, true);
|
||||
this.space();
|
||||
this._printAttributes(node, false);
|
||||
} else {
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function maybePrintDecoratorsBeforeExport(printer, node) {
|
||||
if (isClassDeclaration(node.declaration) && printer._shouldPrintDecoratorsBeforeExport(node)) {
|
||||
printer.printJoin(node.declaration.decorators);
|
||||
}
|
||||
}
|
||||
function ExportNamedDeclaration(node) {
|
||||
maybePrintDecoratorsBeforeExport(this, node);
|
||||
this.word("export");
|
||||
this.space();
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
const specifiers = node.specifiers.slice(0);
|
||||
let hasSpecial = false;
|
||||
for (;;) {
|
||||
const first = specifiers[0];
|
||||
if (isExportDefaultSpecifier(first) || isExportNamespaceSpecifier(first)) {
|
||||
hasSpecial = true;
|
||||
this.print(specifiers.shift());
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hasBrace = false;
|
||||
if (specifiers.length || !specifiers.length && !hasSpecial) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
if (specifiers.length) {
|
||||
this.space();
|
||||
this.printList(specifiers, this.shouldPrintTrailingComma("}"));
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(125);
|
||||
}
|
||||
if (node.source) {
|
||||
var _node$attributes2, _node$assertions2;
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
if ((_node$attributes2 = node.attributes) != null && _node$attributes2.length || (_node$assertions2 = node.assertions) != null && _node$assertions2.length) {
|
||||
this.print(node.source, true);
|
||||
this.space();
|
||||
this._printAttributes(node, hasBrace);
|
||||
} else {
|
||||
this.print(node.source);
|
||||
}
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
}
|
||||
function ExportDefaultDeclaration(node) {
|
||||
maybePrintDecoratorsBeforeExport(this, node);
|
||||
this.word("export");
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.space();
|
||||
this.word("default");
|
||||
this.space();
|
||||
this.tokenContext |= _index.TokenContext.exportDefault;
|
||||
const declar = node.declaration;
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
}
|
||||
function ImportDeclaration(node) {
|
||||
var _node$attributes3, _node$assertions3;
|
||||
this.word("import");
|
||||
this.space();
|
||||
const isTypeKind = node.importKind === "type" || node.importKind === "typeof";
|
||||
if (isTypeKind) {
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
} else if (node.module) {
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.word("module");
|
||||
this.space();
|
||||
} else if (node.phase) {
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.word(node.phase);
|
||||
this.space();
|
||||
}
|
||||
const specifiers = node.specifiers.slice(0);
|
||||
const hasSpecifiers = !!specifiers.length;
|
||||
while (hasSpecifiers) {
|
||||
const first = specifiers[0];
|
||||
if (isImportDefaultSpecifier(first) || isImportNamespaceSpecifier(first)) {
|
||||
this.print(specifiers.shift());
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hasBrace = false;
|
||||
if (specifiers.length) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
this.printList(specifiers, this.shouldPrintTrailingComma("}"));
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
} else if (isTypeKind && !hasSpecifiers) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
if (hasSpecifiers || isTypeKind) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
}
|
||||
if ((_node$attributes3 = node.attributes) != null && _node$attributes3.length || (_node$assertions3 = node.assertions) != null && _node$assertions3.length) {
|
||||
this.print(node.source, true);
|
||||
this.space();
|
||||
this._printAttributes(node, hasBrace);
|
||||
} else {
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ImportAttribute(node) {
|
||||
this.print(node.key);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
function ImportNamespaceSpecifier(node) {
|
||||
this.tokenChar(42);
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.local);
|
||||
}
|
||||
function ImportExpression(node) {
|
||||
this.word("import");
|
||||
if (node.phase) {
|
||||
this.tokenChar(46);
|
||||
this.word(node.phase);
|
||||
}
|
||||
this.tokenChar(40);
|
||||
this.print(node.source);
|
||||
if (node.options != null) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
this.print(node.options);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=modules.js.map
|
1
node_modules/@babel/generator/lib/generators/modules.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/modules.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
282
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
Normal file
282
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
Normal file
|
@ -0,0 +1,282 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.BreakStatement = BreakStatement;
|
||||
exports.CatchClause = CatchClause;
|
||||
exports.ContinueStatement = ContinueStatement;
|
||||
exports.DebuggerStatement = DebuggerStatement;
|
||||
exports.DoWhileStatement = DoWhileStatement;
|
||||
exports.ForOfStatement = exports.ForInStatement = void 0;
|
||||
exports.ForStatement = ForStatement;
|
||||
exports.IfStatement = IfStatement;
|
||||
exports.LabeledStatement = LabeledStatement;
|
||||
exports.ReturnStatement = ReturnStatement;
|
||||
exports.SwitchCase = SwitchCase;
|
||||
exports.SwitchStatement = SwitchStatement;
|
||||
exports.ThrowStatement = ThrowStatement;
|
||||
exports.TryStatement = TryStatement;
|
||||
exports.VariableDeclaration = VariableDeclaration;
|
||||
exports.VariableDeclarator = VariableDeclarator;
|
||||
exports.WhileStatement = WhileStatement;
|
||||
exports.WithStatement = WithStatement;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isFor,
|
||||
isForStatement,
|
||||
isIfStatement,
|
||||
isStatement
|
||||
} = _t;
|
||||
function WithStatement(node) {
|
||||
this.word("with");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.object);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
function IfStatement(node) {
|
||||
this.word("if");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
|
||||
if (needsBlock) {
|
||||
this.tokenChar(123);
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
this.printAndIndentOnComments(node.consequent);
|
||||
if (needsBlock) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
if (node.alternate) {
|
||||
if (this.endsWith(125)) this.space();
|
||||
this.word("else");
|
||||
this.space();
|
||||
this.printAndIndentOnComments(node.alternate);
|
||||
}
|
||||
}
|
||||
function getLastStatement(statement) {
|
||||
const {
|
||||
body
|
||||
} = statement;
|
||||
if (isStatement(body) === false) {
|
||||
return statement;
|
||||
}
|
||||
return getLastStatement(body);
|
||||
}
|
||||
function ForStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
{
|
||||
const exit = this.enterForStatementInit();
|
||||
this.tokenContext |= _index.TokenContext.forHead;
|
||||
this.print(node.init);
|
||||
exit();
|
||||
}
|
||||
this.tokenChar(59);
|
||||
if (node.test) {
|
||||
this.space();
|
||||
this.print(node.test);
|
||||
}
|
||||
this.token(";", false, 1);
|
||||
if (node.update) {
|
||||
this.space();
|
||||
this.print(node.update);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
function WhileStatement(node) {
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
function ForXStatement(node) {
|
||||
this.word("for");
|
||||
this.space();
|
||||
const isForOf = node.type === "ForOfStatement";
|
||||
if (isForOf && node.await) {
|
||||
this.word("await");
|
||||
this.space();
|
||||
}
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.tokenChar(40);
|
||||
{
|
||||
const exit = isForOf ? null : this.enterForStatementInit();
|
||||
this.tokenContext |= isForOf ? _index.TokenContext.forOfHead : _index.TokenContext.forInHead;
|
||||
this.print(node.left);
|
||||
exit == null || exit();
|
||||
}
|
||||
this.space();
|
||||
this.word(isForOf ? "of" : "in");
|
||||
this.space();
|
||||
this.print(node.right);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
const ForInStatement = exports.ForInStatement = ForXStatement;
|
||||
const ForOfStatement = exports.ForOfStatement = ForXStatement;
|
||||
function DoWhileStatement(node) {
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
this.space();
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.semicolon();
|
||||
}
|
||||
function printStatementAfterKeyword(printer, node) {
|
||||
if (node) {
|
||||
printer.space();
|
||||
printer.printTerminatorless(node);
|
||||
}
|
||||
printer.semicolon();
|
||||
}
|
||||
function BreakStatement(node) {
|
||||
this.word("break");
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ContinueStatement(node) {
|
||||
this.word("continue");
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ReturnStatement(node) {
|
||||
this.word("return");
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function ThrowStatement(node) {
|
||||
this.word("throw");
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function LabeledStatement(node) {
|
||||
this.print(node.label);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function TryStatement(node) {
|
||||
this.word("try");
|
||||
this.space();
|
||||
this.print(node.block);
|
||||
this.space();
|
||||
if (node.handlers) {
|
||||
this.print(node.handlers[0]);
|
||||
} else {
|
||||
this.print(node.handler);
|
||||
}
|
||||
if (node.finalizer) {
|
||||
this.space();
|
||||
this.word("finally");
|
||||
this.space();
|
||||
this.print(node.finalizer);
|
||||
}
|
||||
}
|
||||
function CatchClause(node) {
|
||||
this.word("catch");
|
||||
this.space();
|
||||
if (node.param) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.param);
|
||||
this.print(node.param.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.body);
|
||||
}
|
||||
function SwitchStatement(node) {
|
||||
this.word("switch");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.discriminant);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.printSequence(node.cases, true, undefined, function addNewlines(leading, cas) {
|
||||
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
|
||||
});
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function SwitchCase(node) {
|
||||
if (node.test) {
|
||||
this.word("case");
|
||||
this.space();
|
||||
this.print(node.test);
|
||||
this.tokenChar(58);
|
||||
} else {
|
||||
this.word("default");
|
||||
this.tokenChar(58);
|
||||
}
|
||||
if (node.consequent.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.consequent, true);
|
||||
}
|
||||
}
|
||||
function DebuggerStatement() {
|
||||
this.word("debugger");
|
||||
this.semicolon();
|
||||
}
|
||||
function VariableDeclaration(node, parent) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
const {
|
||||
kind
|
||||
} = node;
|
||||
if (kind === "await using") {
|
||||
this.word("await");
|
||||
this.space();
|
||||
this.word("using", true);
|
||||
} else {
|
||||
this.word(kind, kind === "using");
|
||||
}
|
||||
this.space();
|
||||
let hasInits = false;
|
||||
if (!isFor(parent)) {
|
||||
for (const declar of node.declarations) {
|
||||
if (declar.init) {
|
||||
hasInits = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.printList(node.declarations, undefined, undefined, node.declarations.length > 1, hasInits ? function (occurrenceCount) {
|
||||
this.token(",", false, occurrenceCount);
|
||||
this.newline();
|
||||
} : undefined);
|
||||
if (isFor(parent)) {
|
||||
if (isForStatement(parent)) {
|
||||
if (parent.init === node) return;
|
||||
} else {
|
||||
if (parent.left === node) return;
|
||||
}
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function VariableDeclarator(node) {
|
||||
this.print(node.id);
|
||||
if (node.definite) this.tokenChar(33);
|
||||
this.print(node.id.typeAnnotation);
|
||||
if (node.init) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.init);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=statements.js.map
|
1
node_modules/@babel/generator/lib/generators/statements.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/statements.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
40
node_modules/@babel/generator/lib/generators/template-literals.js
generated
vendored
Normal file
40
node_modules/@babel/generator/lib/generators/template-literals.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TaggedTemplateExpression = TaggedTemplateExpression;
|
||||
exports.TemplateElement = TemplateElement;
|
||||
exports.TemplateLiteral = TemplateLiteral;
|
||||
exports._printTemplate = _printTemplate;
|
||||
function TaggedTemplateExpression(node) {
|
||||
this.print(node.tag);
|
||||
{
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
this.print(node.quasi);
|
||||
}
|
||||
function TemplateElement() {
|
||||
throw new Error("TemplateElement printing is handled in TemplateLiteral");
|
||||
}
|
||||
function _printTemplate(node, substitutions) {
|
||||
const quasis = node.quasis;
|
||||
let partRaw = "`";
|
||||
for (let i = 0; i < quasis.length - 1; i++) {
|
||||
partRaw += quasis[i].value.raw;
|
||||
this.token(partRaw + "${", true);
|
||||
this.print(substitutions[i]);
|
||||
partRaw = "}";
|
||||
if (this.tokenMap) {
|
||||
const token = this.tokenMap.findMatching(node, "}", i);
|
||||
if (token) this._catchUpTo(token.loc.start);
|
||||
}
|
||||
}
|
||||
partRaw += quasis[quasis.length - 1].value.raw;
|
||||
this.token(partRaw + "`", true);
|
||||
}
|
||||
function TemplateLiteral(node) {
|
||||
this._printTemplate(node, node.expressions);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=template-literals.js.map
|
1
node_modules/@babel/generator/lib/generators/template-literals.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/template-literals.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["TaggedTemplateExpression","node","print","tag","typeParameters","quasi","TemplateElement","Error","_printTemplate","substitutions","quasis","partRaw","i","length","value","raw","token","tokenMap","findMatching","_catchUpTo","loc","start","TemplateLiteral","expressions"],"sources":["../../src/generators/template-literals.ts"],"sourcesContent":["import type Printer from \"../printer.ts\";\nimport type * as t from \"@babel/types\";\n\nexport function TaggedTemplateExpression(\n this: Printer,\n node: t.TaggedTemplateExpression,\n) {\n this.print(node.tag);\n if (process.env.BABEL_8_BREAKING) {\n // @ts-ignore(Babel 7 vs Babel 8) Babel 8 AST\n this.print(node.typeArguments);\n } else {\n // @ts-ignore(Babel 7 vs Babel 8) Babel 7 AST\n this.print(node.typeParameters);\n }\n this.print(node.quasi);\n}\n\nexport function TemplateElement(this: Printer) {\n throw new Error(\"TemplateElement printing is handled in TemplateLiteral\");\n}\n\nexport type TemplateLiteralBase = t.Node & {\n quasis: t.TemplateElement[];\n};\n\nexport function _printTemplate<T extends t.Node>(\n this: Printer,\n node: TemplateLiteralBase,\n substitutions: T[],\n) {\n const quasis = node.quasis;\n let partRaw = \"`\";\n for (let i = 0; i < quasis.length - 1; i++) {\n partRaw += quasis[i].value.raw;\n this.token(partRaw + \"${\", true);\n this.print(substitutions[i]);\n partRaw = \"}\";\n\n // In Babel 7 we have individual tokens for ${ and }, so the automatic\n // catchup logic does not work. Manually look for those tokens.\n if (!process.env.BABEL_8_BREAKING && this.tokenMap) {\n const token = this.tokenMap.findMatching(node, \"}\", i);\n if (token) this._catchUpTo(token.loc.start);\n }\n }\n partRaw += quasis[quasis.length - 1].value.raw;\n this.token(partRaw + \"`\", true);\n}\n\nexport function TemplateLiteral(this: Printer, node: t.TemplateLiteral) {\n this._printTemplate(node, node.expressions);\n}\n"],"mappings":";;;;;;;;;AAGO,SAASA,wBAAwBA,CAEtCC,IAAgC,EAChC;EACA,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,GAAG,CAAC;EAIb;IAEL,IAAI,CAACD,KAAK,CAACD,IAAI,CAACG,cAAc,CAAC;EACjC;EACA,IAAI,CAACF,KAAK,CAACD,IAAI,CAACI,KAAK,CAAC;AACxB;AAEO,SAASC,eAAeA,CAAA,EAAgB;EAC7C,MAAM,IAAIC,KAAK,CAAC,wDAAwD,CAAC;AAC3E;AAMO,SAASC,cAAcA,CAE5BP,IAAyB,EACzBQ,aAAkB,EAClB;EACA,MAAMC,MAAM,GAAGT,IAAI,CAACS,MAAM;EAC1B,IAAIC,OAAO,GAAG,GAAG;EACjB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,CAACG,MAAM,GAAG,CAAC,EAAED,CAAC,EAAE,EAAE;IAC1CD,OAAO,IAAID,MAAM,CAACE,CAAC,CAAC,CAACE,KAAK,CAACC,GAAG;IAC9B,IAAI,CAACC,KAAK,CAACL,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC;IAChC,IAAI,CAACT,KAAK,CAACO,aAAa,CAACG,CAAC,CAAC,CAAC;IAC5BD,OAAO,GAAG,GAAG;IAIb,IAAqC,IAAI,CAACM,QAAQ,EAAE;MAClD,MAAMD,KAAK,GAAG,IAAI,CAACC,QAAQ,CAACC,YAAY,CAACjB,IAAI,EAAE,GAAG,EAAEW,CAAC,CAAC;MACtD,IAAII,KAAK,EAAE,IAAI,CAACG,UAAU,CAACH,KAAK,CAACI,GAAG,CAACC,KAAK,CAAC;IAC7C;EACF;EACAV,OAAO,IAAID,MAAM,CAACA,MAAM,CAACG,MAAM,GAAG,CAAC,CAAC,CAACC,KAAK,CAACC,GAAG;EAC9C,IAAI,CAACC,KAAK,CAACL,OAAO,GAAG,GAAG,EAAE,IAAI,CAAC;AACjC;AAEO,SAASW,eAAeA,CAAgBrB,IAAuB,EAAE;EACtE,IAAI,CAACO,cAAc,CAACP,IAAI,EAAEA,IAAI,CAACsB,WAAW,CAAC;AAC7C","ignoreList":[]}
|
234
node_modules/@babel/generator/lib/generators/types.js
generated
vendored
Normal file
234
node_modules/@babel/generator/lib/generators/types.js
generated
vendored
Normal file
|
@ -0,0 +1,234 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.ArgumentPlaceholder = ArgumentPlaceholder;
|
||||
exports.ArrayPattern = exports.ArrayExpression = ArrayExpression;
|
||||
exports.BigIntLiteral = BigIntLiteral;
|
||||
exports.BooleanLiteral = BooleanLiteral;
|
||||
exports.Identifier = Identifier;
|
||||
exports.NullLiteral = NullLiteral;
|
||||
exports.NumericLiteral = NumericLiteral;
|
||||
exports.ObjectPattern = exports.ObjectExpression = ObjectExpression;
|
||||
exports.ObjectMethod = ObjectMethod;
|
||||
exports.ObjectProperty = ObjectProperty;
|
||||
exports.PipelineBareFunction = PipelineBareFunction;
|
||||
exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference;
|
||||
exports.PipelineTopicExpression = PipelineTopicExpression;
|
||||
exports.RecordExpression = RecordExpression;
|
||||
exports.RegExpLiteral = RegExpLiteral;
|
||||
exports.SpreadElement = exports.RestElement = RestElement;
|
||||
exports.StringLiteral = StringLiteral;
|
||||
exports.TopicReference = TopicReference;
|
||||
exports.TupleExpression = TupleExpression;
|
||||
exports._getRawIdentifier = _getRawIdentifier;
|
||||
var _t = require("@babel/types");
|
||||
var _jsesc = require("jsesc");
|
||||
const {
|
||||
isAssignmentPattern,
|
||||
isIdentifier
|
||||
} = _t;
|
||||
let lastRawIdentNode = null;
|
||||
let lastRawIdentResult = "";
|
||||
function _getRawIdentifier(node) {
|
||||
if (node === lastRawIdentNode) return lastRawIdentResult;
|
||||
lastRawIdentNode = node;
|
||||
const {
|
||||
name
|
||||
} = node;
|
||||
const token = this.tokenMap.find(node, tok => tok.value === name);
|
||||
if (token) {
|
||||
lastRawIdentResult = this._originalCode.slice(token.start, token.end);
|
||||
return lastRawIdentResult;
|
||||
}
|
||||
return lastRawIdentResult = node.name;
|
||||
}
|
||||
function Identifier(node) {
|
||||
var _node$loc;
|
||||
this.sourceIdentifierName(((_node$loc = node.loc) == null ? void 0 : _node$loc.identifierName) || node.name);
|
||||
this.word(this.tokenMap ? this._getRawIdentifier(node) : node.name);
|
||||
}
|
||||
function ArgumentPlaceholder() {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
function RestElement(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument);
|
||||
}
|
||||
function ObjectExpression(node) {
|
||||
const props = node.properties;
|
||||
this.tokenChar(123);
|
||||
if (props.length) {
|
||||
const exit = this.enterDelimited();
|
||||
this.space();
|
||||
this.printList(props, this.shouldPrintTrailingComma("}"), true, true);
|
||||
this.space();
|
||||
exit();
|
||||
}
|
||||
this.sourceWithOffset("end", node.loc, -1);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
function ObjectMethod(node) {
|
||||
this.printJoin(node.decorators);
|
||||
this._methodHead(node);
|
||||
this.space();
|
||||
this.print(node.body);
|
||||
}
|
||||
function ObjectProperty(node) {
|
||||
this.printJoin(node.decorators);
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(node.key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (isAssignmentPattern(node.value) && isIdentifier(node.key) && node.key.name === node.value.left.name) {
|
||||
this.print(node.value);
|
||||
return;
|
||||
}
|
||||
this.print(node.key);
|
||||
if (node.shorthand && isIdentifier(node.key) && isIdentifier(node.value) && node.key.name === node.value.name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value);
|
||||
}
|
||||
function ArrayExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
this.tokenChar(91);
|
||||
const exit = this.enterDelimited();
|
||||
for (let i = 0; i < elems.length; i++) {
|
||||
const elem = elems[i];
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem);
|
||||
if (i < len - 1 || this.shouldPrintTrailingComma("]")) {
|
||||
this.token(",", false, i);
|
||||
}
|
||||
} else {
|
||||
this.token(",", false, i);
|
||||
}
|
||||
}
|
||||
exit();
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function RecordExpression(node) {
|
||||
const props = node.properties;
|
||||
let startToken;
|
||||
let endToken;
|
||||
{
|
||||
if (this.format.recordAndTupleSyntaxType === "bar") {
|
||||
startToken = "{|";
|
||||
endToken = "|}";
|
||||
} else if (this.format.recordAndTupleSyntaxType !== "hash" && this.format.recordAndTupleSyntaxType != null) {
|
||||
throw new Error(`The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify(this.format.recordAndTupleSyntaxType)} received).`);
|
||||
} else {
|
||||
startToken = "#{";
|
||||
endToken = "}";
|
||||
}
|
||||
}
|
||||
this.token(startToken);
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printList(props, this.shouldPrintTrailingComma(endToken), true, true);
|
||||
this.space();
|
||||
}
|
||||
this.token(endToken);
|
||||
}
|
||||
function TupleExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
let startToken;
|
||||
let endToken;
|
||||
{
|
||||
if (this.format.recordAndTupleSyntaxType === "bar") {
|
||||
startToken = "[|";
|
||||
endToken = "|]";
|
||||
} else if (this.format.recordAndTupleSyntaxType === "hash") {
|
||||
startToken = "#[";
|
||||
endToken = "]";
|
||||
} else {
|
||||
throw new Error(`${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`);
|
||||
}
|
||||
}
|
||||
this.token(startToken);
|
||||
for (let i = 0; i < elems.length; i++) {
|
||||
const elem = elems[i];
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem);
|
||||
if (i < len - 1 || this.shouldPrintTrailingComma(endToken)) {
|
||||
this.token(",", false, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.token(endToken);
|
||||
}
|
||||
function RegExpLiteral(node) {
|
||||
this.word(`/${node.pattern}/${node.flags}`);
|
||||
}
|
||||
function BooleanLiteral(node) {
|
||||
this.word(node.value ? "true" : "false");
|
||||
}
|
||||
function NullLiteral() {
|
||||
this.word("null");
|
||||
}
|
||||
function NumericLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
const opts = this.format.jsescOption;
|
||||
const value = node.value;
|
||||
const str = value + "";
|
||||
if (opts.numbers) {
|
||||
this.number(_jsesc(value, opts), value);
|
||||
} else if (raw == null) {
|
||||
this.number(str, value);
|
||||
} else if (this.format.minified) {
|
||||
this.number(raw.length < str.length ? raw : str, value);
|
||||
} else {
|
||||
this.number(raw, value);
|
||||
}
|
||||
}
|
||||
function StringLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.token(raw);
|
||||
return;
|
||||
}
|
||||
const val = _jsesc(node.value, this.format.jsescOption);
|
||||
this.token(val);
|
||||
}
|
||||
function BigIntLiteral(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
if (!this.format.minified && raw !== undefined) {
|
||||
this.word(raw);
|
||||
return;
|
||||
}
|
||||
this.word(node.value + "n");
|
||||
}
|
||||
const validTopicTokenSet = new Set(["^^", "@@", "^", "%", "#"]);
|
||||
function TopicReference() {
|
||||
const {
|
||||
topicToken
|
||||
} = this.format;
|
||||
if (validTopicTokenSet.has(topicToken)) {
|
||||
this.token(topicToken);
|
||||
} else {
|
||||
const givenTopicTokenJSON = JSON.stringify(topicToken);
|
||||
const validTopics = Array.from(validTopicTokenSet, v => JSON.stringify(v));
|
||||
throw new Error(`The "topicToken" generator option must be one of ` + `${validTopics.join(", ")} (${givenTopicTokenJSON} received instead).`);
|
||||
}
|
||||
}
|
||||
function PipelineTopicExpression(node) {
|
||||
this.print(node.expression);
|
||||
}
|
||||
function PipelineBareFunction(node) {
|
||||
this.print(node.callee);
|
||||
}
|
||||
function PipelinePrimaryTopicReference() {
|
||||
this.tokenChar(35);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=types.js.map
|
1
node_modules/@babel/generator/lib/generators/types.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/types.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
720
node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
Normal file
720
node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
Normal file
|
@ -0,0 +1,720 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TSAnyKeyword = TSAnyKeyword;
|
||||
exports.TSArrayType = TSArrayType;
|
||||
exports.TSSatisfiesExpression = exports.TSAsExpression = TSTypeExpression;
|
||||
exports.TSBigIntKeyword = TSBigIntKeyword;
|
||||
exports.TSBooleanKeyword = TSBooleanKeyword;
|
||||
exports.TSCallSignatureDeclaration = TSCallSignatureDeclaration;
|
||||
exports.TSInterfaceHeritage = exports.TSClassImplements = TSClassImplements;
|
||||
exports.TSConditionalType = TSConditionalType;
|
||||
exports.TSConstructSignatureDeclaration = TSConstructSignatureDeclaration;
|
||||
exports.TSConstructorType = TSConstructorType;
|
||||
exports.TSDeclareFunction = TSDeclareFunction;
|
||||
exports.TSDeclareMethod = TSDeclareMethod;
|
||||
exports.TSEnumBody = TSEnumBody;
|
||||
exports.TSEnumDeclaration = TSEnumDeclaration;
|
||||
exports.TSEnumMember = TSEnumMember;
|
||||
exports.TSExportAssignment = TSExportAssignment;
|
||||
exports.TSExternalModuleReference = TSExternalModuleReference;
|
||||
exports.TSFunctionType = TSFunctionType;
|
||||
exports.TSImportEqualsDeclaration = TSImportEqualsDeclaration;
|
||||
exports.TSImportType = TSImportType;
|
||||
exports.TSIndexSignature = TSIndexSignature;
|
||||
exports.TSIndexedAccessType = TSIndexedAccessType;
|
||||
exports.TSInferType = TSInferType;
|
||||
exports.TSInstantiationExpression = TSInstantiationExpression;
|
||||
exports.TSInterfaceBody = TSInterfaceBody;
|
||||
exports.TSInterfaceDeclaration = TSInterfaceDeclaration;
|
||||
exports.TSIntersectionType = TSIntersectionType;
|
||||
exports.TSIntrinsicKeyword = TSIntrinsicKeyword;
|
||||
exports.TSLiteralType = TSLiteralType;
|
||||
exports.TSMappedType = TSMappedType;
|
||||
exports.TSMethodSignature = TSMethodSignature;
|
||||
exports.TSModuleBlock = TSModuleBlock;
|
||||
exports.TSModuleDeclaration = TSModuleDeclaration;
|
||||
exports.TSNamedTupleMember = TSNamedTupleMember;
|
||||
exports.TSNamespaceExportDeclaration = TSNamespaceExportDeclaration;
|
||||
exports.TSNeverKeyword = TSNeverKeyword;
|
||||
exports.TSNonNullExpression = TSNonNullExpression;
|
||||
exports.TSNullKeyword = TSNullKeyword;
|
||||
exports.TSNumberKeyword = TSNumberKeyword;
|
||||
exports.TSObjectKeyword = TSObjectKeyword;
|
||||
exports.TSOptionalType = TSOptionalType;
|
||||
exports.TSParameterProperty = TSParameterProperty;
|
||||
exports.TSParenthesizedType = TSParenthesizedType;
|
||||
exports.TSPropertySignature = TSPropertySignature;
|
||||
exports.TSQualifiedName = TSQualifiedName;
|
||||
exports.TSRestType = TSRestType;
|
||||
exports.TSStringKeyword = TSStringKeyword;
|
||||
exports.TSSymbolKeyword = TSSymbolKeyword;
|
||||
exports.TSTemplateLiteralType = TSTemplateLiteralType;
|
||||
exports.TSThisType = TSThisType;
|
||||
exports.TSTupleType = TSTupleType;
|
||||
exports.TSTypeAliasDeclaration = TSTypeAliasDeclaration;
|
||||
exports.TSTypeAnnotation = TSTypeAnnotation;
|
||||
exports.TSTypeAssertion = TSTypeAssertion;
|
||||
exports.TSTypeLiteral = TSTypeLiteral;
|
||||
exports.TSTypeOperator = TSTypeOperator;
|
||||
exports.TSTypeParameter = TSTypeParameter;
|
||||
exports.TSTypeParameterDeclaration = exports.TSTypeParameterInstantiation = TSTypeParameterInstantiation;
|
||||
exports.TSTypePredicate = TSTypePredicate;
|
||||
exports.TSTypeQuery = TSTypeQuery;
|
||||
exports.TSTypeReference = TSTypeReference;
|
||||
exports.TSUndefinedKeyword = TSUndefinedKeyword;
|
||||
exports.TSUnionType = TSUnionType;
|
||||
exports.TSUnknownKeyword = TSUnknownKeyword;
|
||||
exports.TSVoidKeyword = TSVoidKeyword;
|
||||
exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers;
|
||||
exports.tsPrintFunctionOrConstructorType = tsPrintFunctionOrConstructorType;
|
||||
exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName;
|
||||
exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase;
|
||||
function TSTypeAnnotation(node, parent) {
|
||||
this.token((parent.type === "TSFunctionType" || parent.type === "TSConstructorType") && parent.typeAnnotation === node ? "=>" : ":");
|
||||
this.space();
|
||||
if (node.optional) this.tokenChar(63);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSTypeParameterInstantiation(node, parent) {
|
||||
this.tokenChar(60);
|
||||
let printTrailingSeparator = parent.type === "ArrowFunctionExpression" && node.params.length === 1;
|
||||
if (this.tokenMap && node.start != null && node.end != null) {
|
||||
printTrailingSeparator && (printTrailingSeparator = !!this.tokenMap.find(node, t => this.tokenMap.matchesOriginal(t, ",")));
|
||||
printTrailingSeparator || (printTrailingSeparator = this.shouldPrintTrailingComma(">"));
|
||||
}
|
||||
this.printList(node.params, printTrailingSeparator);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function TSTypeParameter(node) {
|
||||
if (node.in) {
|
||||
this.word("in");
|
||||
this.space();
|
||||
}
|
||||
if (node.out) {
|
||||
this.word("out");
|
||||
this.space();
|
||||
}
|
||||
this.word(node.name);
|
||||
if (node.constraint) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.constraint);
|
||||
}
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.default);
|
||||
}
|
||||
}
|
||||
function TSParameterProperty(node) {
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
if (node.readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
this._param(node.parameter);
|
||||
}
|
||||
function TSDeclareFunction(node, parent) {
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this._functionHead(node, parent);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSDeclareMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSQualifiedName(node) {
|
||||
this.print(node.left);
|
||||
this.tokenChar(46);
|
||||
this.print(node.right);
|
||||
}
|
||||
function TSCallSignatureDeclaration(node) {
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function maybePrintTrailingCommaOrSemicolon(printer, node) {
|
||||
if (!printer.tokenMap || !node.start || !node.end) {
|
||||
printer.semicolon();
|
||||
return;
|
||||
}
|
||||
if (printer.tokenMap.endMatches(node, ",")) {
|
||||
printer.token(",");
|
||||
} else if (printer.tokenMap.endMatches(node, ";")) {
|
||||
printer.semicolon();
|
||||
}
|
||||
}
|
||||
function TSConstructSignatureDeclaration(node) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSPropertySignature(node) {
|
||||
const {
|
||||
readonly
|
||||
} = node;
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.print(node.typeAnnotation);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function tsPrintPropertyOrMethodName(node) {
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
}
|
||||
this.print(node.key);
|
||||
if (node.computed) {
|
||||
this.tokenChar(93);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
}
|
||||
function TSMethodSignature(node) {
|
||||
const {
|
||||
kind
|
||||
} = node;
|
||||
if (kind === "set" || kind === "get") {
|
||||
this.word(kind);
|
||||
this.space();
|
||||
}
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSIndexSignature(node) {
|
||||
const {
|
||||
readonly,
|
||||
static: isStatic
|
||||
} = node;
|
||||
if (isStatic) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
if (readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this._parameters(node.parameters, "]");
|
||||
this.print(node.typeAnnotation);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSAnyKeyword() {
|
||||
this.word("any");
|
||||
}
|
||||
function TSBigIntKeyword() {
|
||||
this.word("bigint");
|
||||
}
|
||||
function TSUnknownKeyword() {
|
||||
this.word("unknown");
|
||||
}
|
||||
function TSNumberKeyword() {
|
||||
this.word("number");
|
||||
}
|
||||
function TSObjectKeyword() {
|
||||
this.word("object");
|
||||
}
|
||||
function TSBooleanKeyword() {
|
||||
this.word("boolean");
|
||||
}
|
||||
function TSStringKeyword() {
|
||||
this.word("string");
|
||||
}
|
||||
function TSSymbolKeyword() {
|
||||
this.word("symbol");
|
||||
}
|
||||
function TSVoidKeyword() {
|
||||
this.word("void");
|
||||
}
|
||||
function TSUndefinedKeyword() {
|
||||
this.word("undefined");
|
||||
}
|
||||
function TSNullKeyword() {
|
||||
this.word("null");
|
||||
}
|
||||
function TSNeverKeyword() {
|
||||
this.word("never");
|
||||
}
|
||||
function TSIntrinsicKeyword() {
|
||||
this.word("intrinsic");
|
||||
}
|
||||
function TSThisType() {
|
||||
this.word("this");
|
||||
}
|
||||
function TSFunctionType(node) {
|
||||
this.tsPrintFunctionOrConstructorType(node);
|
||||
}
|
||||
function TSConstructorType(node) {
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintFunctionOrConstructorType(node);
|
||||
}
|
||||
function tsPrintFunctionOrConstructorType(node) {
|
||||
const {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters);
|
||||
this.tokenChar(40);
|
||||
this._parameters(parameters, ")");
|
||||
this.space();
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType);
|
||||
}
|
||||
function TSTypeReference(node) {
|
||||
const typeArguments = node.typeParameters;
|
||||
this.print(node.typeName, !!typeArguments);
|
||||
this.print(typeArguments);
|
||||
}
|
||||
function TSTypePredicate(node) {
|
||||
if (node.asserts) {
|
||||
this.word("asserts");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.parameterName);
|
||||
if (node.typeAnnotation) {
|
||||
this.space();
|
||||
this.word("is");
|
||||
this.space();
|
||||
this.print(node.typeAnnotation.typeAnnotation);
|
||||
}
|
||||
}
|
||||
function TSTypeQuery(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.exprName);
|
||||
const typeArguments = node.typeParameters;
|
||||
if (typeArguments) {
|
||||
this.print(typeArguments);
|
||||
}
|
||||
}
|
||||
function TSTypeLiteral(node) {
|
||||
printBraced(this, node, () => this.printJoin(node.members, true, true));
|
||||
}
|
||||
function TSArrayType(node) {
|
||||
this.print(node.elementType, true);
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSTupleType(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.elementTypes, this.shouldPrintTrailingComma("]"));
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSOptionalType(node) {
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(63);
|
||||
}
|
||||
function TSRestType(node) {
|
||||
this.token("...");
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSNamedTupleMember(node) {
|
||||
this.print(node.label);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.elementType);
|
||||
}
|
||||
function TSUnionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "|");
|
||||
}
|
||||
function TSIntersectionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "&");
|
||||
}
|
||||
function tsPrintUnionOrIntersectionType(printer, node, sep) {
|
||||
var _printer$tokenMap;
|
||||
let hasLeadingToken = 0;
|
||||
if ((_printer$tokenMap = printer.tokenMap) != null && _printer$tokenMap.startMatches(node, sep)) {
|
||||
hasLeadingToken = 1;
|
||||
printer.token(sep);
|
||||
}
|
||||
printer.printJoin(node.types, undefined, undefined, function (i) {
|
||||
this.space();
|
||||
this.token(sep, null, i + hasLeadingToken);
|
||||
this.space();
|
||||
});
|
||||
}
|
||||
function TSConditionalType(node) {
|
||||
this.print(node.checkType);
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.extendsType);
|
||||
this.space();
|
||||
this.tokenChar(63);
|
||||
this.space();
|
||||
this.print(node.trueType);
|
||||
this.space();
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.falseType);
|
||||
}
|
||||
function TSInferType(node) {
|
||||
this.word("infer");
|
||||
this.print(node.typeParameter);
|
||||
}
|
||||
function TSParenthesizedType(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function TSTypeOperator(node) {
|
||||
this.word(node.operator);
|
||||
this.space();
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSIndexedAccessType(node) {
|
||||
this.print(node.objectType, true);
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSMappedType(node) {
|
||||
const {
|
||||
nameType,
|
||||
optional,
|
||||
readonly,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
this.tokenChar(123);
|
||||
const exit = this.enterDelimited();
|
||||
this.space();
|
||||
if (readonly) {
|
||||
tokenIfPlusMinus(this, readonly);
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
{
|
||||
this.word(node.typeParameter.name);
|
||||
}
|
||||
this.space();
|
||||
this.word("in");
|
||||
this.space();
|
||||
{
|
||||
this.print(node.typeParameter.constraint);
|
||||
}
|
||||
if (nameType) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(nameType);
|
||||
}
|
||||
this.tokenChar(93);
|
||||
if (optional) {
|
||||
tokenIfPlusMinus(this, optional);
|
||||
this.tokenChar(63);
|
||||
}
|
||||
if (typeAnnotation) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(typeAnnotation);
|
||||
}
|
||||
this.space();
|
||||
exit();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
function tokenIfPlusMinus(self, tok) {
|
||||
if (tok !== true) {
|
||||
self.token(tok);
|
||||
}
|
||||
}
|
||||
function TSTemplateLiteralType(node) {
|
||||
this._printTemplate(node, node.types);
|
||||
}
|
||||
function TSLiteralType(node) {
|
||||
this.print(node.literal);
|
||||
}
|
||||
function TSClassImplements(node) {
|
||||
this.print(node.expression);
|
||||
this.print(node.typeArguments);
|
||||
}
|
||||
function TSInterfaceDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id,
|
||||
typeParameters,
|
||||
extends: extendz,
|
||||
body
|
||||
} = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("interface");
|
||||
this.space();
|
||||
this.print(id);
|
||||
this.print(typeParameters);
|
||||
if (extendz != null && extendz.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(extendz);
|
||||
}
|
||||
this.space();
|
||||
this.print(body);
|
||||
}
|
||||
function TSInterfaceBody(node) {
|
||||
printBraced(this, node, () => this.printJoin(node.body, true, true));
|
||||
}
|
||||
function TSTypeAliasDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id,
|
||||
typeParameters,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
this.word("type");
|
||||
this.space();
|
||||
this.print(id);
|
||||
this.print(typeParameters);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(typeAnnotation);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSTypeExpression(node) {
|
||||
const {
|
||||
type,
|
||||
expression,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
this.print(expression, true);
|
||||
this.space();
|
||||
this.word(type === "TSAsExpression" ? "as" : "satisfies");
|
||||
this.space();
|
||||
this.print(typeAnnotation);
|
||||
}
|
||||
function TSTypeAssertion(node) {
|
||||
const {
|
||||
typeAnnotation,
|
||||
expression
|
||||
} = node;
|
||||
this.tokenChar(60);
|
||||
this.print(typeAnnotation);
|
||||
this.tokenChar(62);
|
||||
this.space();
|
||||
this.print(expression);
|
||||
}
|
||||
function TSInstantiationExpression(node) {
|
||||
this.print(node.expression);
|
||||
{
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
}
|
||||
function TSEnumDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
const: isConst,
|
||||
id
|
||||
} = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (isConst) {
|
||||
this.word("const");
|
||||
this.space();
|
||||
}
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id);
|
||||
this.space();
|
||||
{
|
||||
TSEnumBody.call(this, node);
|
||||
}
|
||||
}
|
||||
function TSEnumBody(node) {
|
||||
printBraced(this, node, () => {
|
||||
var _this$shouldPrintTrai;
|
||||
return this.printList(node.members, (_this$shouldPrintTrai = this.shouldPrintTrailingComma("}")) != null ? _this$shouldPrintTrai : true, true, true);
|
||||
});
|
||||
}
|
||||
function TSEnumMember(node) {
|
||||
const {
|
||||
id,
|
||||
initializer
|
||||
} = node;
|
||||
this.print(id);
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(initializer);
|
||||
}
|
||||
}
|
||||
function TSModuleDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id,
|
||||
kind
|
||||
} = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
{
|
||||
if (!node.global) {
|
||||
this.word(kind != null ? kind : id.type === "Identifier" ? "namespace" : "module");
|
||||
this.space();
|
||||
}
|
||||
this.print(id);
|
||||
if (!node.body) {
|
||||
this.semicolon();
|
||||
return;
|
||||
}
|
||||
let body = node.body;
|
||||
while (body.type === "TSModuleDeclaration") {
|
||||
this.tokenChar(46);
|
||||
this.print(body.id);
|
||||
body = body.body;
|
||||
}
|
||||
this.space();
|
||||
this.print(body);
|
||||
}
|
||||
}
|
||||
function TSModuleBlock(node) {
|
||||
printBraced(this, node, () => this.printSequence(node.body, true));
|
||||
}
|
||||
function TSImportType(node) {
|
||||
const {
|
||||
argument,
|
||||
qualifier,
|
||||
options
|
||||
} = node;
|
||||
this.word("import");
|
||||
this.tokenChar(40);
|
||||
this.print(argument);
|
||||
if (options) {
|
||||
this.tokenChar(44);
|
||||
this.print(options);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
if (qualifier) {
|
||||
this.tokenChar(46);
|
||||
this.print(qualifier);
|
||||
}
|
||||
const typeArguments = node.typeParameters;
|
||||
if (typeArguments) {
|
||||
this.print(typeArguments);
|
||||
}
|
||||
}
|
||||
function TSImportEqualsDeclaration(node) {
|
||||
const {
|
||||
id,
|
||||
moduleReference
|
||||
} = node;
|
||||
if (node.isExport) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
}
|
||||
this.word("import");
|
||||
this.space();
|
||||
this.print(id);
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(moduleReference);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSExternalModuleReference(node) {
|
||||
this.token("require(");
|
||||
this.print(node.expression);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function TSNonNullExpression(node) {
|
||||
this.print(node.expression);
|
||||
this.tokenChar(33);
|
||||
}
|
||||
function TSExportAssignment(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.expression);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSNamespaceExportDeclaration(node) {
|
||||
this.word("export");
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.word("namespace");
|
||||
this.space();
|
||||
this.print(node.id);
|
||||
this.semicolon();
|
||||
}
|
||||
function tsPrintSignatureDeclarationBase(node) {
|
||||
const {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters);
|
||||
this.tokenChar(40);
|
||||
this._parameters(parameters, ")");
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType);
|
||||
}
|
||||
function tsPrintClassMemberModifiers(node) {
|
||||
const isPrivateField = node.type === "ClassPrivateProperty";
|
||||
const isPublicField = node.type === "ClassAccessorProperty" || node.type === "ClassProperty";
|
||||
printModifiersList(this, node, [isPublicField && node.declare && "declare", !isPrivateField && node.accessibility]);
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
printModifiersList(this, node, [!isPrivateField && node.abstract && "abstract", !isPrivateField && node.override && "override", (isPublicField || isPrivateField) && node.readonly && "readonly"]);
|
||||
}
|
||||
function printBraced(printer, node, cb) {
|
||||
printer.token("{");
|
||||
const exit = printer.enterDelimited();
|
||||
cb();
|
||||
exit();
|
||||
printer.rightBrace(node);
|
||||
}
|
||||
function printModifiersList(printer, node, modifiers) {
|
||||
var _printer$tokenMap2;
|
||||
const modifiersSet = new Set();
|
||||
for (const modifier of modifiers) {
|
||||
if (modifier) modifiersSet.add(modifier);
|
||||
}
|
||||
(_printer$tokenMap2 = printer.tokenMap) == null || _printer$tokenMap2.find(node, tok => {
|
||||
if (modifiersSet.has(tok.value)) {
|
||||
printer.token(tok.value);
|
||||
printer.space();
|
||||
modifiersSet.delete(tok.value);
|
||||
return modifiersSet.size === 0;
|
||||
}
|
||||
});
|
||||
for (const modifier of modifiersSet) {
|
||||
printer.word(modifier);
|
||||
printer.space();
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=typescript.js.map
|
1
node_modules/@babel/generator/lib/generators/typescript.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/generators/typescript.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
112
node_modules/@babel/generator/lib/index.js
generated
vendored
Normal file
112
node_modules/@babel/generator/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,112 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
exports.generate = generate;
|
||||
var _sourceMap = require("./source-map.js");
|
||||
var _printer = require("./printer.js");
|
||||
function normalizeOptions(code, opts, ast) {
|
||||
if (opts.experimental_preserveFormat) {
|
||||
if (typeof code !== "string") {
|
||||
throw new Error("`experimental_preserveFormat` requires the original `code` to be passed to @babel/generator as a string");
|
||||
}
|
||||
if (!opts.retainLines) {
|
||||
throw new Error("`experimental_preserveFormat` requires `retainLines` to be set to `true`");
|
||||
}
|
||||
if (opts.compact && opts.compact !== "auto") {
|
||||
throw new Error("`experimental_preserveFormat` is not compatible with the `compact` option");
|
||||
}
|
||||
if (opts.minified) {
|
||||
throw new Error("`experimental_preserveFormat` is not compatible with the `minified` option");
|
||||
}
|
||||
if (opts.jsescOption) {
|
||||
throw new Error("`experimental_preserveFormat` is not compatible with the `jsescOption` option");
|
||||
}
|
||||
if (!Array.isArray(ast.tokens)) {
|
||||
throw new Error("`experimental_preserveFormat` requires the AST to have attatched the token of the input code. Make sure to enable the `tokens: true` parser option.");
|
||||
}
|
||||
}
|
||||
const format = {
|
||||
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
|
||||
shouldPrintComment: opts.shouldPrintComment,
|
||||
preserveFormat: opts.experimental_preserveFormat,
|
||||
retainLines: opts.retainLines,
|
||||
retainFunctionParens: opts.retainFunctionParens,
|
||||
comments: opts.comments == null || opts.comments,
|
||||
compact: opts.compact,
|
||||
minified: opts.minified,
|
||||
concise: opts.concise,
|
||||
indent: {
|
||||
adjustMultilineComment: true,
|
||||
style: " "
|
||||
},
|
||||
jsescOption: Object.assign({
|
||||
quotes: "double",
|
||||
wrap: true,
|
||||
minimal: false
|
||||
}, opts.jsescOption),
|
||||
topicToken: opts.topicToken,
|
||||
importAttributesKeyword: opts.importAttributesKeyword
|
||||
};
|
||||
{
|
||||
var _opts$recordAndTupleS;
|
||||
format.decoratorsBeforeExport = opts.decoratorsBeforeExport;
|
||||
format.jsescOption.json = opts.jsonCompatibleStrings;
|
||||
format.recordAndTupleSyntaxType = (_opts$recordAndTupleS = opts.recordAndTupleSyntaxType) != null ? _opts$recordAndTupleS : "hash";
|
||||
}
|
||||
if (format.minified) {
|
||||
format.compact = true;
|
||||
format.shouldPrintComment = format.shouldPrintComment || (() => format.comments);
|
||||
} else {
|
||||
format.shouldPrintComment = format.shouldPrintComment || (value => format.comments || value.includes("@license") || value.includes("@preserve"));
|
||||
}
|
||||
if (format.compact === "auto") {
|
||||
format.compact = typeof code === "string" && code.length > 500000;
|
||||
if (format.compact) {
|
||||
console.error("[BABEL] Note: The code generator has deoptimised the styling of " + `${opts.filename} as it exceeds the max of ${"500KB"}.`);
|
||||
}
|
||||
}
|
||||
if (format.compact || format.preserveFormat) {
|
||||
format.indent.adjustMultilineComment = false;
|
||||
}
|
||||
const {
|
||||
auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter,
|
||||
shouldPrintComment
|
||||
} = format;
|
||||
if (auxiliaryCommentBefore && !shouldPrintComment(auxiliaryCommentBefore)) {
|
||||
format.auxiliaryCommentBefore = undefined;
|
||||
}
|
||||
if (auxiliaryCommentAfter && !shouldPrintComment(auxiliaryCommentAfter)) {
|
||||
format.auxiliaryCommentAfter = undefined;
|
||||
}
|
||||
return format;
|
||||
}
|
||||
{
|
||||
exports.CodeGenerator = class CodeGenerator {
|
||||
constructor(ast, opts = {}, code) {
|
||||
this._ast = void 0;
|
||||
this._format = void 0;
|
||||
this._map = void 0;
|
||||
this._ast = ast;
|
||||
this._format = normalizeOptions(code, opts, ast);
|
||||
this._map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||||
}
|
||||
generate() {
|
||||
const printer = new _printer.default(this._format, this._map);
|
||||
return printer.generate(this._ast);
|
||||
}
|
||||
};
|
||||
}
|
||||
function generate(ast, opts = {}, code) {
|
||||
const format = normalizeOptions(code, opts, ast);
|
||||
const map = opts.sourceMaps ? new _sourceMap.default(opts, code) : null;
|
||||
const printer = new _printer.default(format, map, ast.tokens, typeof code === "string" ? code : null);
|
||||
return printer.generate(ast);
|
||||
}
|
||||
var _default = exports.default = generate;
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@babel/generator/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
119
node_modules/@babel/generator/lib/node/index.js
generated
vendored
Normal file
119
node_modules/@babel/generator/lib/node/index.js
generated
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TokenContext = void 0;
|
||||
exports.isLastChild = isLastChild;
|
||||
exports.needsParens = needsParens;
|
||||
exports.needsWhitespace = needsWhitespace;
|
||||
exports.needsWhitespaceAfter = needsWhitespaceAfter;
|
||||
exports.needsWhitespaceBefore = needsWhitespaceBefore;
|
||||
var whitespace = require("./whitespace.js");
|
||||
var parens = require("./parentheses.js");
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
VISITOR_KEYS,
|
||||
isCallExpression,
|
||||
isDecorator,
|
||||
isExpressionStatement,
|
||||
isMemberExpression,
|
||||
isNewExpression,
|
||||
isParenthesizedExpression
|
||||
} = _t;
|
||||
const TokenContext = exports.TokenContext = {
|
||||
expressionStatement: 1,
|
||||
arrowBody: 2,
|
||||
exportDefault: 4,
|
||||
forHead: 8,
|
||||
forInHead: 16,
|
||||
forOfHead: 32,
|
||||
arrowFlowReturnType: 64
|
||||
};
|
||||
function expandAliases(obj) {
|
||||
const map = new Map();
|
||||
function add(type, func) {
|
||||
const fn = map.get(type);
|
||||
map.set(type, fn ? function (node, parent, stack, inForInit, getRawIdentifier) {
|
||||
var _fn;
|
||||
return (_fn = fn(node, parent, stack, inForInit, getRawIdentifier)) != null ? _fn : func(node, parent, stack, inForInit, getRawIdentifier);
|
||||
} : func);
|
||||
}
|
||||
for (const type of Object.keys(obj)) {
|
||||
const aliases = FLIPPED_ALIAS_KEYS[type];
|
||||
if (aliases) {
|
||||
for (const alias of aliases) {
|
||||
add(alias, obj[type]);
|
||||
}
|
||||
} else {
|
||||
add(type, obj[type]);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
const expandedParens = expandAliases(parens);
|
||||
const expandedWhitespaceNodes = expandAliases(whitespace.nodes);
|
||||
function isOrHasCallExpression(node) {
|
||||
if (isCallExpression(node)) {
|
||||
return true;
|
||||
}
|
||||
return isMemberExpression(node) && isOrHasCallExpression(node.object);
|
||||
}
|
||||
function needsWhitespace(node, parent, type) {
|
||||
var _expandedWhitespaceNo;
|
||||
if (!node) return false;
|
||||
if (isExpressionStatement(node)) {
|
||||
node = node.expression;
|
||||
}
|
||||
const flag = (_expandedWhitespaceNo = expandedWhitespaceNodes.get(node.type)) == null ? void 0 : _expandedWhitespaceNo(node, parent);
|
||||
if (typeof flag === "number") {
|
||||
return (flag & type) !== 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function needsWhitespaceBefore(node, parent) {
|
||||
return needsWhitespace(node, parent, 1);
|
||||
}
|
||||
function needsWhitespaceAfter(node, parent) {
|
||||
return needsWhitespace(node, parent, 2);
|
||||
}
|
||||
function needsParens(node, parent, tokenContext, inForInit, getRawIdentifier) {
|
||||
var _expandedParens$get;
|
||||
if (!parent) return false;
|
||||
if (isNewExpression(parent) && parent.callee === node) {
|
||||
if (isOrHasCallExpression(node)) return true;
|
||||
}
|
||||
if (isDecorator(parent)) {
|
||||
return !isDecoratorMemberExpression(node) && !(isCallExpression(node) && isDecoratorMemberExpression(node.callee)) && !isParenthesizedExpression(node);
|
||||
}
|
||||
return (_expandedParens$get = expandedParens.get(node.type)) == null ? void 0 : _expandedParens$get(node, parent, tokenContext, inForInit, getRawIdentifier);
|
||||
}
|
||||
function isDecoratorMemberExpression(node) {
|
||||
switch (node.type) {
|
||||
case "Identifier":
|
||||
return true;
|
||||
case "MemberExpression":
|
||||
return !node.computed && node.property.type === "Identifier" && isDecoratorMemberExpression(node.object);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function isLastChild(parent, child) {
|
||||
const visitorKeys = VISITOR_KEYS[parent.type];
|
||||
for (let i = visitorKeys.length - 1; i >= 0; i--) {
|
||||
const val = parent[visitorKeys[i]];
|
||||
if (val === child) {
|
||||
return true;
|
||||
} else if (Array.isArray(val)) {
|
||||
let j = val.length - 1;
|
||||
while (j >= 0 && val[j] === null) j--;
|
||||
return j >= 0 && val[j] === child;
|
||||
} else if (val) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@babel/generator/lib/node/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
262
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
Normal file
262
node_modules/@babel/generator/lib/node/parentheses.js
generated
vendored
Normal file
|
@ -0,0 +1,262 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.AssignmentExpression = AssignmentExpression;
|
||||
exports.Binary = Binary;
|
||||
exports.BinaryExpression = BinaryExpression;
|
||||
exports.ClassExpression = ClassExpression;
|
||||
exports.ArrowFunctionExpression = exports.ConditionalExpression = ConditionalExpression;
|
||||
exports.DoExpression = DoExpression;
|
||||
exports.FunctionExpression = FunctionExpression;
|
||||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
|
||||
exports.Identifier = Identifier;
|
||||
exports.LogicalExpression = LogicalExpression;
|
||||
exports.NullableTypeAnnotation = NullableTypeAnnotation;
|
||||
exports.ObjectExpression = ObjectExpression;
|
||||
exports.OptionalIndexedAccessType = OptionalIndexedAccessType;
|
||||
exports.OptionalCallExpression = exports.OptionalMemberExpression = OptionalMemberExpression;
|
||||
exports.SequenceExpression = SequenceExpression;
|
||||
exports.TSSatisfiesExpression = exports.TSAsExpression = TSAsExpression;
|
||||
exports.TSConditionalType = TSConditionalType;
|
||||
exports.TSConstructorType = exports.TSFunctionType = TSFunctionType;
|
||||
exports.TSInferType = TSInferType;
|
||||
exports.TSInstantiationExpression = TSInstantiationExpression;
|
||||
exports.TSIntersectionType = TSIntersectionType;
|
||||
exports.UnaryLike = exports.TSTypeAssertion = UnaryLike;
|
||||
exports.TSTypeOperator = TSTypeOperator;
|
||||
exports.TSUnionType = TSUnionType;
|
||||
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation;
|
||||
exports.UpdateExpression = UpdateExpression;
|
||||
exports.AwaitExpression = exports.YieldExpression = YieldExpression;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("./index.js");
|
||||
const {
|
||||
isArrayTypeAnnotation,
|
||||
isBinaryExpression,
|
||||
isCallExpression,
|
||||
isForOfStatement,
|
||||
isIndexedAccessType,
|
||||
isMemberExpression,
|
||||
isObjectPattern,
|
||||
isOptionalMemberExpression,
|
||||
isYieldExpression,
|
||||
isStatement
|
||||
} = _t;
|
||||
const PRECEDENCE = new Map([["||", 0], ["??", 0], ["|>", 0], ["&&", 1], ["|", 2], ["^", 3], ["&", 4], ["==", 5], ["===", 5], ["!=", 5], ["!==", 5], ["<", 6], [">", 6], ["<=", 6], [">=", 6], ["in", 6], ["instanceof", 6], [">>", 7], ["<<", 7], [">>>", 7], ["+", 8], ["-", 8], ["*", 9], ["/", 9], ["%", 9], ["**", 10]]);
|
||||
function getBinaryPrecedence(node, nodeType) {
|
||||
if (nodeType === "BinaryExpression" || nodeType === "LogicalExpression") {
|
||||
return PRECEDENCE.get(node.operator);
|
||||
}
|
||||
if (nodeType === "TSAsExpression" || nodeType === "TSSatisfiesExpression") {
|
||||
return PRECEDENCE.get("in");
|
||||
}
|
||||
}
|
||||
function isTSTypeExpression(nodeType) {
|
||||
return nodeType === "TSAsExpression" || nodeType === "TSSatisfiesExpression" || nodeType === "TSTypeAssertion";
|
||||
}
|
||||
const isClassExtendsClause = (node, parent) => {
|
||||
const parentType = parent.type;
|
||||
return (parentType === "ClassDeclaration" || parentType === "ClassExpression") && parent.superClass === node;
|
||||
};
|
||||
const hasPostfixPart = (node, parent) => {
|
||||
const parentType = parent.type;
|
||||
return (parentType === "MemberExpression" || parentType === "OptionalMemberExpression") && parent.object === node || (parentType === "CallExpression" || parentType === "OptionalCallExpression" || parentType === "NewExpression") && parent.callee === node || parentType === "TaggedTemplateExpression" && parent.tag === node || parentType === "TSNonNullExpression";
|
||||
};
|
||||
function NullableTypeAnnotation(node, parent) {
|
||||
return isArrayTypeAnnotation(parent);
|
||||
}
|
||||
function FunctionTypeAnnotation(node, parent, tokenContext) {
|
||||
const parentType = parent.type;
|
||||
return (parentType === "UnionTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "ArrayTypeAnnotation" || Boolean(tokenContext & _index.TokenContext.arrowFlowReturnType)
|
||||
);
|
||||
}
|
||||
function UpdateExpression(node, parent) {
|
||||
return hasPostfixPart(node, parent) || isClassExtendsClause(node, parent);
|
||||
}
|
||||
function needsParenBeforeExpressionBrace(tokenContext) {
|
||||
return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.arrowBody));
|
||||
}
|
||||
function ObjectExpression(node, parent, tokenContext) {
|
||||
return needsParenBeforeExpressionBrace(tokenContext);
|
||||
}
|
||||
function DoExpression(node, parent, tokenContext) {
|
||||
return !node.async && Boolean(tokenContext & _index.TokenContext.expressionStatement);
|
||||
}
|
||||
function Binary(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (node.type === "BinaryExpression" && node.operator === "**" && parentType === "BinaryExpression" && parent.operator === "**") {
|
||||
return parent.left === node;
|
||||
}
|
||||
if (isClassExtendsClause(node, parent)) {
|
||||
return true;
|
||||
}
|
||||
if (hasPostfixPart(node, parent) || parentType === "UnaryExpression" || parentType === "SpreadElement" || parentType === "AwaitExpression") {
|
||||
return true;
|
||||
}
|
||||
const parentPos = getBinaryPrecedence(parent, parentType);
|
||||
if (parentPos != null) {
|
||||
const nodePos = getBinaryPrecedence(node, node.type);
|
||||
if (parentPos === nodePos && parentType === "BinaryExpression" && parent.right === node || parentPos > nodePos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function UnionTypeAnnotation(node, parent) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "ArrayTypeAnnotation" || parentType === "NullableTypeAnnotation" || parentType === "IntersectionTypeAnnotation" || parentType === "UnionTypeAnnotation";
|
||||
}
|
||||
function OptionalIndexedAccessType(node, parent) {
|
||||
return isIndexedAccessType(parent) && parent.objectType === node;
|
||||
}
|
||||
function TSAsExpression(node, parent) {
|
||||
if ((parent.type === "AssignmentExpression" || parent.type === "AssignmentPattern") && parent.left === node) {
|
||||
return true;
|
||||
}
|
||||
if (parent.type === "BinaryExpression" && (parent.operator === "|" || parent.operator === "&") && node === parent.left) {
|
||||
return true;
|
||||
}
|
||||
return Binary(node, parent);
|
||||
}
|
||||
function TSConditionalType(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType" || parentType === "TSTypeOperator" || parentType === "TSTypeParameter") {
|
||||
return true;
|
||||
}
|
||||
if ((parentType === "TSIntersectionType" || parentType === "TSUnionType") && parent.types[0] === node) {
|
||||
return true;
|
||||
}
|
||||
if (parentType === "TSConditionalType" && (parent.checkType === node || parent.extendsType === node)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSUnionType(node, parent) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "TSIntersectionType" || parentType === "TSTypeOperator" || parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType";
|
||||
}
|
||||
function TSIntersectionType(node, parent) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "TSTypeOperator" || parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType";
|
||||
}
|
||||
function TSInferType(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType") {
|
||||
return true;
|
||||
}
|
||||
if (node.typeParameter.constraint) {
|
||||
if ((parentType === "TSIntersectionType" || parentType === "TSUnionType") && parent.types[0] === node) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function TSTypeOperator(node, parent) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSOptionalType";
|
||||
}
|
||||
function TSInstantiationExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
return (parentType === "CallExpression" || parentType === "OptionalCallExpression" || parentType === "NewExpression" || parentType === "TSInstantiationExpression") && !!parent.typeParameters;
|
||||
}
|
||||
function TSFunctionType(node, parent) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "TSIntersectionType" || parentType === "TSUnionType" || parentType === "TSTypeOperator" || parentType === "TSOptionalType" || parentType === "TSArrayType" || parentType === "TSIndexedAccessType" && parent.objectType === node || parentType === "TSConditionalType" && (parent.checkType === node || parent.extendsType === node);
|
||||
}
|
||||
function BinaryExpression(node, parent, tokenContext, inForStatementInit) {
|
||||
return node.operator === "in" && inForStatementInit;
|
||||
}
|
||||
function SequenceExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "SequenceExpression" || parentType === "ParenthesizedExpression" || parentType === "MemberExpression" && parent.property === node || parentType === "OptionalMemberExpression" && parent.property === node || parentType === "TemplateLiteral") {
|
||||
return false;
|
||||
}
|
||||
if (parentType === "ClassDeclaration") {
|
||||
return true;
|
||||
}
|
||||
if (parentType === "ForOfStatement") {
|
||||
return parent.right === node;
|
||||
}
|
||||
if (parentType === "ExportDefaultDeclaration") {
|
||||
return true;
|
||||
}
|
||||
return !isStatement(parent);
|
||||
}
|
||||
function YieldExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
return parentType === "BinaryExpression" || parentType === "LogicalExpression" || parentType === "UnaryExpression" || parentType === "SpreadElement" || hasPostfixPart(node, parent) || parentType === "AwaitExpression" && isYieldExpression(node) || parentType === "ConditionalExpression" && node === parent.test || isClassExtendsClause(node, parent) || isTSTypeExpression(parentType);
|
||||
}
|
||||
function ClassExpression(node, parent, tokenContext) {
|
||||
return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault));
|
||||
}
|
||||
function UnaryLike(node, parent) {
|
||||
return hasPostfixPart(node, parent) || isBinaryExpression(parent) && parent.operator === "**" && parent.left === node || isClassExtendsClause(node, parent);
|
||||
}
|
||||
function FunctionExpression(node, parent, tokenContext) {
|
||||
return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.exportDefault));
|
||||
}
|
||||
function ConditionalExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (parentType === "UnaryExpression" || parentType === "SpreadElement" || parentType === "BinaryExpression" || parentType === "LogicalExpression" || parentType === "ConditionalExpression" && parent.test === node || parentType === "AwaitExpression" || isTSTypeExpression(parentType)) {
|
||||
return true;
|
||||
}
|
||||
return UnaryLike(node, parent);
|
||||
}
|
||||
function OptionalMemberExpression(node, parent) {
|
||||
return isCallExpression(parent) && parent.callee === node || isMemberExpression(parent) && parent.object === node;
|
||||
}
|
||||
function AssignmentExpression(node, parent, tokenContext) {
|
||||
if (needsParenBeforeExpressionBrace(tokenContext) && isObjectPattern(node.left)) {
|
||||
return true;
|
||||
} else {
|
||||
return ConditionalExpression(node, parent);
|
||||
}
|
||||
}
|
||||
function LogicalExpression(node, parent) {
|
||||
const parentType = parent.type;
|
||||
if (isTSTypeExpression(parentType)) return true;
|
||||
if (parentType !== "LogicalExpression") return false;
|
||||
switch (node.operator) {
|
||||
case "||":
|
||||
return parent.operator === "??" || parent.operator === "&&";
|
||||
case "&&":
|
||||
return parent.operator === "??";
|
||||
case "??":
|
||||
return parent.operator !== "??";
|
||||
}
|
||||
}
|
||||
function Identifier(node, parent, tokenContext, _inForInit, getRawIdentifier) {
|
||||
var _node$extra;
|
||||
const parentType = parent.type;
|
||||
if ((_node$extra = node.extra) != null && _node$extra.parenthesized && parentType === "AssignmentExpression" && parent.left === node) {
|
||||
const rightType = parent.right.type;
|
||||
if ((rightType === "FunctionExpression" || rightType === "ClassExpression") && parent.right.id == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (getRawIdentifier && getRawIdentifier(node) !== node.name) {
|
||||
return false;
|
||||
}
|
||||
if (node.name === "let") {
|
||||
const isFollowedByBracket = isMemberExpression(parent, {
|
||||
object: node,
|
||||
computed: true
|
||||
}) || isOptionalMemberExpression(parent, {
|
||||
object: node,
|
||||
computed: true,
|
||||
optional: false
|
||||
});
|
||||
if (isFollowedByBracket && tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.forHead | _index.TokenContext.forInHead)) {
|
||||
return true;
|
||||
}
|
||||
return Boolean(tokenContext & _index.TokenContext.forOfHead);
|
||||
}
|
||||
return node.name === "async" && isForOfStatement(parent, {
|
||||
left: node,
|
||||
await: false
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parentheses.js.map
|
1
node_modules/@babel/generator/lib/node/parentheses.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/node/parentheses.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
145
node_modules/@babel/generator/lib/node/whitespace.js
generated
vendored
Normal file
145
node_modules/@babel/generator/lib/node/whitespace.js
generated
vendored
Normal file
|
@ -0,0 +1,145 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.nodes = void 0;
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
FLIPPED_ALIAS_KEYS,
|
||||
isArrayExpression,
|
||||
isAssignmentExpression,
|
||||
isBinary,
|
||||
isBlockStatement,
|
||||
isCallExpression,
|
||||
isFunction,
|
||||
isIdentifier,
|
||||
isLiteral,
|
||||
isMemberExpression,
|
||||
isObjectExpression,
|
||||
isOptionalCallExpression,
|
||||
isOptionalMemberExpression,
|
||||
isStringLiteral
|
||||
} = _t;
|
||||
function crawlInternal(node, state) {
|
||||
if (!node) return state;
|
||||
if (isMemberExpression(node) || isOptionalMemberExpression(node)) {
|
||||
crawlInternal(node.object, state);
|
||||
if (node.computed) crawlInternal(node.property, state);
|
||||
} else if (isBinary(node) || isAssignmentExpression(node)) {
|
||||
crawlInternal(node.left, state);
|
||||
crawlInternal(node.right, state);
|
||||
} else if (isCallExpression(node) || isOptionalCallExpression(node)) {
|
||||
state.hasCall = true;
|
||||
crawlInternal(node.callee, state);
|
||||
} else if (isFunction(node)) {
|
||||
state.hasFunction = true;
|
||||
} else if (isIdentifier(node)) {
|
||||
state.hasHelper = state.hasHelper || node.callee && isHelper(node.callee);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
function crawl(node) {
|
||||
return crawlInternal(node, {
|
||||
hasCall: false,
|
||||
hasFunction: false,
|
||||
hasHelper: false
|
||||
});
|
||||
}
|
||||
function isHelper(node) {
|
||||
if (!node) return false;
|
||||
if (isMemberExpression(node)) {
|
||||
return isHelper(node.object) || isHelper(node.property);
|
||||
} else if (isIdentifier(node)) {
|
||||
return node.name === "require" || node.name.charCodeAt(0) === 95;
|
||||
} else if (isCallExpression(node)) {
|
||||
return isHelper(node.callee);
|
||||
} else if (isBinary(node) || isAssignmentExpression(node)) {
|
||||
return isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function isType(node) {
|
||||
return isLiteral(node) || isObjectExpression(node) || isArrayExpression(node) || isIdentifier(node) || isMemberExpression(node);
|
||||
}
|
||||
const nodes = exports.nodes = {
|
||||
AssignmentExpression(node) {
|
||||
const state = crawl(node.right);
|
||||
if (state.hasCall && state.hasHelper || state.hasFunction) {
|
||||
return state.hasFunction ? 1 | 2 : 2;
|
||||
}
|
||||
},
|
||||
SwitchCase(node, parent) {
|
||||
return (!!node.consequent.length || parent.cases[0] === node ? 1 : 0) | (!node.consequent.length && parent.cases[parent.cases.length - 1] === node ? 2 : 0);
|
||||
},
|
||||
LogicalExpression(node) {
|
||||
if (isFunction(node.left) || isFunction(node.right)) {
|
||||
return 2;
|
||||
}
|
||||
},
|
||||
Literal(node) {
|
||||
if (isStringLiteral(node) && node.value === "use strict") {
|
||||
return 2;
|
||||
}
|
||||
},
|
||||
CallExpression(node) {
|
||||
if (isFunction(node.callee) || isHelper(node)) {
|
||||
return 1 | 2;
|
||||
}
|
||||
},
|
||||
OptionalCallExpression(node) {
|
||||
if (isFunction(node.callee)) {
|
||||
return 1 | 2;
|
||||
}
|
||||
},
|
||||
VariableDeclaration(node) {
|
||||
for (let i = 0; i < node.declarations.length; i++) {
|
||||
const declar = node.declarations[i];
|
||||
let enabled = isHelper(declar.id) && !isType(declar.init);
|
||||
if (!enabled && declar.init) {
|
||||
const state = crawl(declar.init);
|
||||
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
|
||||
}
|
||||
if (enabled) {
|
||||
return 1 | 2;
|
||||
}
|
||||
}
|
||||
},
|
||||
IfStatement(node) {
|
||||
if (isBlockStatement(node.consequent)) {
|
||||
return 1 | 2;
|
||||
}
|
||||
}
|
||||
};
|
||||
nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (node, parent) {
|
||||
if (parent.properties[0] === node) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
nodes.ObjectTypeCallProperty = function (node, parent) {
|
||||
var _parent$properties;
|
||||
if (parent.callProperties[0] === node && !((_parent$properties = parent.properties) != null && _parent$properties.length)) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
nodes.ObjectTypeIndexer = function (node, parent) {
|
||||
var _parent$properties2, _parent$callPropertie;
|
||||
if (parent.indexers[0] === node && !((_parent$properties2 = parent.properties) != null && _parent$properties2.length) && !((_parent$callPropertie = parent.callProperties) != null && _parent$callPropertie.length)) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
nodes.ObjectTypeInternalSlot = function (node, parent) {
|
||||
var _parent$properties3, _parent$callPropertie2, _parent$indexers;
|
||||
if (parent.internalSlots[0] === node && !((_parent$properties3 = parent.properties) != null && _parent$properties3.length) && !((_parent$callPropertie2 = parent.callProperties) != null && _parent$callPropertie2.length) && !((_parent$indexers = parent.indexers) != null && _parent$indexers.length)) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function ([type, amounts]) {
|
||||
[type].concat(FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) {
|
||||
const ret = amounts ? 1 | 2 : 0;
|
||||
nodes[type] = () => ret;
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=whitespace.js.map
|
1
node_modules/@babel/generator/lib/node/whitespace.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/node/whitespace.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
775
node_modules/@babel/generator/lib/printer.js
generated
vendored
Normal file
775
node_modules/@babel/generator/lib/printer.js
generated
vendored
Normal file
|
@ -0,0 +1,775 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _buffer = require("./buffer.js");
|
||||
var n = require("./node/index.js");
|
||||
var _t = require("@babel/types");
|
||||
var _tokenMap = require("./token-map.js");
|
||||
var generatorFunctions = require("./generators/index.js");
|
||||
var _deprecated = require("./generators/deprecated.js");
|
||||
const {
|
||||
isExpression,
|
||||
isFunction,
|
||||
isStatement,
|
||||
isClassBody,
|
||||
isTSInterfaceBody,
|
||||
isTSEnumMember
|
||||
} = _t;
|
||||
const SCIENTIFIC_NOTATION = /e/i;
|
||||
const ZERO_DECIMAL_INTEGER = /\.0+$/;
|
||||
const HAS_NEWLINE = /[\n\r\u2028\u2029]/;
|
||||
const HAS_NEWLINE_OR_BlOCK_COMMENT_END = /[\n\r\u2028\u2029]|\*\//;
|
||||
function commentIsNewline(c) {
|
||||
return c.type === "CommentLine" || HAS_NEWLINE.test(c.value);
|
||||
}
|
||||
const {
|
||||
needsParens
|
||||
} = n;
|
||||
class Printer {
|
||||
constructor(format, map, tokens, originalCode) {
|
||||
this.inForStatementInit = false;
|
||||
this.tokenContext = 0;
|
||||
this._tokens = null;
|
||||
this._originalCode = null;
|
||||
this._currentNode = null;
|
||||
this._indent = 0;
|
||||
this._indentRepeat = 0;
|
||||
this._insideAux = false;
|
||||
this._noLineTerminator = false;
|
||||
this._noLineTerminatorAfterNode = null;
|
||||
this._printAuxAfterOnNextUserNode = false;
|
||||
this._printedComments = new Set();
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithWord = false;
|
||||
this._endsWithDiv = false;
|
||||
this._lastCommentLine = 0;
|
||||
this._endsWithInnerRaw = false;
|
||||
this._indentInnerComments = true;
|
||||
this.tokenMap = null;
|
||||
this._boundGetRawIdentifier = this._getRawIdentifier.bind(this);
|
||||
this._printSemicolonBeforeNextNode = -1;
|
||||
this._printSemicolonBeforeNextToken = -1;
|
||||
this.format = format;
|
||||
this._tokens = tokens;
|
||||
this._originalCode = originalCode;
|
||||
this._indentRepeat = format.indent.style.length;
|
||||
this._inputMap = map == null ? void 0 : map._inputMap;
|
||||
this._buf = new _buffer.default(map, format.indent.style[0]);
|
||||
}
|
||||
enterForStatementInit() {
|
||||
if (this.inForStatementInit) return () => {};
|
||||
this.inForStatementInit = true;
|
||||
return () => {
|
||||
this.inForStatementInit = false;
|
||||
};
|
||||
}
|
||||
enterDelimited() {
|
||||
const oldInForStatementInit = this.inForStatementInit;
|
||||
const oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode;
|
||||
if (oldInForStatementInit === false && oldNoLineTerminatorAfterNode === null) {
|
||||
return () => {};
|
||||
}
|
||||
this.inForStatementInit = false;
|
||||
this._noLineTerminatorAfterNode = null;
|
||||
return () => {
|
||||
this.inForStatementInit = oldInForStatementInit;
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
};
|
||||
}
|
||||
generate(ast) {
|
||||
if (this.format.preserveFormat) {
|
||||
this.tokenMap = new _tokenMap.TokenMap(ast, this._tokens, this._originalCode);
|
||||
}
|
||||
this.print(ast);
|
||||
this._maybeAddAuxComment();
|
||||
return this._buf.get();
|
||||
}
|
||||
indent() {
|
||||
const {
|
||||
format
|
||||
} = this;
|
||||
if (format.preserveFormat || format.compact || format.concise) {
|
||||
return;
|
||||
}
|
||||
this._indent++;
|
||||
}
|
||||
dedent() {
|
||||
const {
|
||||
format
|
||||
} = this;
|
||||
if (format.preserveFormat || format.compact || format.concise) {
|
||||
return;
|
||||
}
|
||||
this._indent--;
|
||||
}
|
||||
semicolon(force = false) {
|
||||
this._maybeAddAuxComment();
|
||||
if (force) {
|
||||
this._appendChar(59);
|
||||
this._noLineTerminator = false;
|
||||
return;
|
||||
}
|
||||
if (this.tokenMap) {
|
||||
const node = this._currentNode;
|
||||
if (node.start != null && node.end != null) {
|
||||
if (!this.tokenMap.endMatches(node, ";")) {
|
||||
this._printSemicolonBeforeNextNode = this._buf.getCurrentLine();
|
||||
return;
|
||||
}
|
||||
const indexes = this.tokenMap.getIndexes(this._currentNode);
|
||||
this._catchUpTo(this._tokens[indexes[indexes.length - 1]].loc.start);
|
||||
}
|
||||
}
|
||||
this._queue(59);
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
rightBrace(node) {
|
||||
if (this.format.minified) {
|
||||
this._buf.removeLastSemicolon();
|
||||
}
|
||||
this.sourceWithOffset("end", node.loc, -1);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
rightParens(node) {
|
||||
this.sourceWithOffset("end", node.loc, -1);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
space(force = false) {
|
||||
const {
|
||||
format
|
||||
} = this;
|
||||
if (format.compact || format.preserveFormat) return;
|
||||
if (force) {
|
||||
this._space();
|
||||
} else if (this._buf.hasContent()) {
|
||||
const lastCp = this.getLastChar();
|
||||
if (lastCp !== 32 && lastCp !== 10) {
|
||||
this._space();
|
||||
}
|
||||
}
|
||||
}
|
||||
word(str, noLineTerminatorAfter = false) {
|
||||
this.tokenContext = 0;
|
||||
this._maybePrintInnerComments(str);
|
||||
this._maybeAddAuxComment();
|
||||
if (this.tokenMap) this._catchUpToCurrentToken(str);
|
||||
if (this._endsWithWord || this._endsWithDiv && str.charCodeAt(0) === 47) {
|
||||
this._space();
|
||||
}
|
||||
this._append(str, false);
|
||||
this._endsWithWord = true;
|
||||
this._noLineTerminator = noLineTerminatorAfter;
|
||||
}
|
||||
number(str, number) {
|
||||
function isNonDecimalLiteral(str) {
|
||||
if (str.length > 2 && str.charCodeAt(0) === 48) {
|
||||
const secondChar = str.charCodeAt(1);
|
||||
return secondChar === 98 || secondChar === 111 || secondChar === 120;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
this.word(str);
|
||||
this._endsWithInteger = Number.isInteger(number) && !isNonDecimalLiteral(str) && !SCIENTIFIC_NOTATION.test(str) && !ZERO_DECIMAL_INTEGER.test(str) && str.charCodeAt(str.length - 1) !== 46;
|
||||
}
|
||||
token(str, maybeNewline = false, occurrenceCount = 0) {
|
||||
this.tokenContext = 0;
|
||||
this._maybePrintInnerComments(str, occurrenceCount);
|
||||
this._maybeAddAuxComment();
|
||||
if (this.tokenMap) this._catchUpToCurrentToken(str, occurrenceCount);
|
||||
const lastChar = this.getLastChar();
|
||||
const strFirst = str.charCodeAt(0);
|
||||
if (lastChar === 33 && (str === "--" || strFirst === 61) || strFirst === 43 && lastChar === 43 || strFirst === 45 && lastChar === 45 || strFirst === 46 && this._endsWithInteger) {
|
||||
this._space();
|
||||
}
|
||||
this._append(str, maybeNewline);
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
tokenChar(char) {
|
||||
this.tokenContext = 0;
|
||||
const str = String.fromCharCode(char);
|
||||
this._maybePrintInnerComments(str);
|
||||
this._maybeAddAuxComment();
|
||||
if (this.tokenMap) this._catchUpToCurrentToken(str);
|
||||
const lastChar = this.getLastChar();
|
||||
if (char === 43 && lastChar === 43 || char === 45 && lastChar === 45 || char === 46 && this._endsWithInteger) {
|
||||
this._space();
|
||||
}
|
||||
this._appendChar(char);
|
||||
this._noLineTerminator = false;
|
||||
}
|
||||
newline(i = 1, force) {
|
||||
if (i <= 0) return;
|
||||
if (!force) {
|
||||
if (this.format.retainLines || this.format.compact) return;
|
||||
if (this.format.concise) {
|
||||
this.space();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (i > 2) i = 2;
|
||||
i -= this._buf.getNewlineCount();
|
||||
for (let j = 0; j < i; j++) {
|
||||
this._newline();
|
||||
}
|
||||
return;
|
||||
}
|
||||
endsWith(char) {
|
||||
return this.getLastChar() === char;
|
||||
}
|
||||
getLastChar() {
|
||||
return this._buf.getLastChar();
|
||||
}
|
||||
endsWithCharAndNewline() {
|
||||
return this._buf.endsWithCharAndNewline();
|
||||
}
|
||||
removeTrailingNewline() {
|
||||
this._buf.removeTrailingNewline();
|
||||
}
|
||||
exactSource(loc, cb) {
|
||||
if (!loc) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
this._catchUp("start", loc);
|
||||
this._buf.exactSource(loc, cb);
|
||||
}
|
||||
source(prop, loc) {
|
||||
if (!loc) return;
|
||||
this._catchUp(prop, loc);
|
||||
this._buf.source(prop, loc);
|
||||
}
|
||||
sourceWithOffset(prop, loc, columnOffset) {
|
||||
if (!loc || this.format.preserveFormat) return;
|
||||
this._catchUp(prop, loc);
|
||||
this._buf.sourceWithOffset(prop, loc, columnOffset);
|
||||
}
|
||||
sourceIdentifierName(identifierName, pos) {
|
||||
if (!this._buf._canMarkIdName) return;
|
||||
const sourcePosition = this._buf._sourcePosition;
|
||||
sourcePosition.identifierNamePos = pos;
|
||||
sourcePosition.identifierName = identifierName;
|
||||
}
|
||||
_space() {
|
||||
this._queue(32);
|
||||
}
|
||||
_newline() {
|
||||
this._queue(10);
|
||||
}
|
||||
_catchUpToCurrentToken(str, occurrenceCount = 0) {
|
||||
const token = this.tokenMap.findMatching(this._currentNode, str, occurrenceCount);
|
||||
if (token) this._catchUpTo(token.loc.start);
|
||||
if (this._printSemicolonBeforeNextToken !== -1 && this._printSemicolonBeforeNextToken === this._buf.getCurrentLine()) {
|
||||
this._buf.appendChar(59);
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithDiv = false;
|
||||
}
|
||||
this._printSemicolonBeforeNextToken = -1;
|
||||
this._printSemicolonBeforeNextNode = -1;
|
||||
}
|
||||
_append(str, maybeNewline) {
|
||||
this._maybeIndent(str.charCodeAt(0));
|
||||
this._buf.append(str, maybeNewline);
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithDiv = false;
|
||||
}
|
||||
_appendChar(char) {
|
||||
this._maybeIndent(char);
|
||||
this._buf.appendChar(char);
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
this._endsWithDiv = false;
|
||||
}
|
||||
_queue(char) {
|
||||
this._maybeIndent(char);
|
||||
this._buf.queue(char);
|
||||
this._endsWithWord = false;
|
||||
this._endsWithInteger = false;
|
||||
}
|
||||
_maybeIndent(firstChar) {
|
||||
if (this._indent && firstChar !== 10 && this.endsWith(10)) {
|
||||
this._buf.queueIndentation(this._getIndent());
|
||||
}
|
||||
}
|
||||
_shouldIndent(firstChar) {
|
||||
if (this._indent && firstChar !== 10 && this.endsWith(10)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catchUp(line) {
|
||||
if (!this.format.retainLines) return;
|
||||
const count = line - this._buf.getCurrentLine();
|
||||
for (let i = 0; i < count; i++) {
|
||||
this._newline();
|
||||
}
|
||||
}
|
||||
_catchUp(prop, loc) {
|
||||
const {
|
||||
format
|
||||
} = this;
|
||||
if (!format.preserveFormat) {
|
||||
if (format.retainLines && loc != null && loc[prop]) {
|
||||
this.catchUp(loc[prop].line);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const pos = loc == null ? void 0 : loc[prop];
|
||||
if (pos != null) this._catchUpTo(pos);
|
||||
}
|
||||
_catchUpTo({
|
||||
line,
|
||||
column,
|
||||
index
|
||||
}) {
|
||||
const count = line - this._buf.getCurrentLine();
|
||||
if (count > 0 && this._noLineTerminator) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < count; i++) {
|
||||
this._newline();
|
||||
}
|
||||
const spacesCount = count > 0 ? column : column - this._buf.getCurrentColumn();
|
||||
if (spacesCount > 0) {
|
||||
const spaces = this._originalCode ? this._originalCode.slice(index - spacesCount, index).replace(/[^\t\x0B\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]/gu, " ") : " ".repeat(spacesCount);
|
||||
this._append(spaces, false);
|
||||
}
|
||||
}
|
||||
_getIndent() {
|
||||
return this._indentRepeat * this._indent;
|
||||
}
|
||||
printTerminatorless(node) {
|
||||
this._noLineTerminator = true;
|
||||
this.print(node);
|
||||
}
|
||||
print(node, noLineTerminatorAfter, trailingCommentsLineOffset) {
|
||||
var _node$extra, _node$leadingComments, _node$leadingComments2;
|
||||
if (!node) return;
|
||||
this._endsWithInnerRaw = false;
|
||||
const nodeType = node.type;
|
||||
const format = this.format;
|
||||
const oldConcise = format.concise;
|
||||
if (node._compact) {
|
||||
format.concise = true;
|
||||
}
|
||||
const printMethod = this[nodeType];
|
||||
if (printMethod === undefined) {
|
||||
throw new ReferenceError(`unknown node of type ${JSON.stringify(nodeType)} with constructor ${JSON.stringify(node.constructor.name)}`);
|
||||
}
|
||||
const parent = this._currentNode;
|
||||
this._currentNode = node;
|
||||
if (this.tokenMap) {
|
||||
this._printSemicolonBeforeNextToken = this._printSemicolonBeforeNextNode;
|
||||
}
|
||||
const oldInAux = this._insideAux;
|
||||
this._insideAux = node.loc == null;
|
||||
this._maybeAddAuxComment(this._insideAux && !oldInAux);
|
||||
const parenthesized = (_node$extra = node.extra) == null ? void 0 : _node$extra.parenthesized;
|
||||
let shouldPrintParens = parenthesized && format.preserveFormat || parenthesized && format.retainFunctionParens && nodeType === "FunctionExpression" || needsParens(node, parent, this.tokenContext, this.inForStatementInit, format.preserveFormat ? this._boundGetRawIdentifier : undefined);
|
||||
if (!shouldPrintParens && parenthesized && (_node$leadingComments = node.leadingComments) != null && _node$leadingComments.length && node.leadingComments[0].type === "CommentBlock") {
|
||||
const parentType = parent == null ? void 0 : parent.type;
|
||||
switch (parentType) {
|
||||
case "ExpressionStatement":
|
||||
case "VariableDeclarator":
|
||||
case "AssignmentExpression":
|
||||
case "ReturnStatement":
|
||||
break;
|
||||
case "CallExpression":
|
||||
case "OptionalCallExpression":
|
||||
case "NewExpression":
|
||||
if (parent.callee !== node) break;
|
||||
default:
|
||||
shouldPrintParens = true;
|
||||
}
|
||||
}
|
||||
let indentParenthesized = false;
|
||||
if (!shouldPrintParens && this._noLineTerminator && ((_node$leadingComments2 = node.leadingComments) != null && _node$leadingComments2.some(commentIsNewline) || this.format.retainLines && node.loc && node.loc.start.line > this._buf.getCurrentLine())) {
|
||||
shouldPrintParens = true;
|
||||
indentParenthesized = true;
|
||||
}
|
||||
let oldNoLineTerminatorAfterNode;
|
||||
let oldInForStatementInitWasTrue;
|
||||
if (!shouldPrintParens) {
|
||||
noLineTerminatorAfter || (noLineTerminatorAfter = parent && this._noLineTerminatorAfterNode === parent && n.isLastChild(parent, node));
|
||||
if (noLineTerminatorAfter) {
|
||||
var _node$trailingComment;
|
||||
if ((_node$trailingComment = node.trailingComments) != null && _node$trailingComment.some(commentIsNewline)) {
|
||||
if (isExpression(node)) shouldPrintParens = true;
|
||||
} else {
|
||||
oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode;
|
||||
this._noLineTerminatorAfterNode = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shouldPrintParens) {
|
||||
this.tokenChar(40);
|
||||
if (indentParenthesized) this.indent();
|
||||
this._endsWithInnerRaw = false;
|
||||
if (this.inForStatementInit) {
|
||||
oldInForStatementInitWasTrue = true;
|
||||
this.inForStatementInit = false;
|
||||
}
|
||||
oldNoLineTerminatorAfterNode = this._noLineTerminatorAfterNode;
|
||||
this._noLineTerminatorAfterNode = null;
|
||||
}
|
||||
this._lastCommentLine = 0;
|
||||
this._printLeadingComments(node, parent);
|
||||
const loc = nodeType === "Program" || nodeType === "File" ? null : node.loc;
|
||||
this.exactSource(loc, printMethod.bind(this, node, parent));
|
||||
if (shouldPrintParens) {
|
||||
this._printTrailingComments(node, parent);
|
||||
if (indentParenthesized) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
}
|
||||
this.tokenChar(41);
|
||||
this._noLineTerminator = noLineTerminatorAfter;
|
||||
if (oldInForStatementInitWasTrue) this.inForStatementInit = true;
|
||||
} else if (noLineTerminatorAfter && !this._noLineTerminator) {
|
||||
this._noLineTerminator = true;
|
||||
this._printTrailingComments(node, parent);
|
||||
} else {
|
||||
this._printTrailingComments(node, parent, trailingCommentsLineOffset);
|
||||
}
|
||||
this._currentNode = parent;
|
||||
format.concise = oldConcise;
|
||||
this._insideAux = oldInAux;
|
||||
if (oldNoLineTerminatorAfterNode !== undefined) {
|
||||
this._noLineTerminatorAfterNode = oldNoLineTerminatorAfterNode;
|
||||
}
|
||||
this._endsWithInnerRaw = false;
|
||||
}
|
||||
_maybeAddAuxComment(enteredPositionlessNode) {
|
||||
if (enteredPositionlessNode) this._printAuxBeforeComment();
|
||||
if (!this._insideAux) this._printAuxAfterComment();
|
||||
}
|
||||
_printAuxBeforeComment() {
|
||||
if (this._printAuxAfterOnNextUserNode) return;
|
||||
this._printAuxAfterOnNextUserNode = true;
|
||||
const comment = this.format.auxiliaryCommentBefore;
|
||||
if (comment) {
|
||||
this._printComment({
|
||||
type: "CommentBlock",
|
||||
value: comment
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
_printAuxAfterComment() {
|
||||
if (!this._printAuxAfterOnNextUserNode) return;
|
||||
this._printAuxAfterOnNextUserNode = false;
|
||||
const comment = this.format.auxiliaryCommentAfter;
|
||||
if (comment) {
|
||||
this._printComment({
|
||||
type: "CommentBlock",
|
||||
value: comment
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
getPossibleRaw(node) {
|
||||
const extra = node.extra;
|
||||
if ((extra == null ? void 0 : extra.raw) != null && extra.rawValue != null && node.value === extra.rawValue) {
|
||||
return extra.raw;
|
||||
}
|
||||
}
|
||||
printJoin(nodes, statement, indent, separator, printTrailingSeparator, addNewlines, iterator, trailingCommentsLineOffset) {
|
||||
if (!(nodes != null && nodes.length)) return;
|
||||
if (indent == null && this.format.retainLines) {
|
||||
var _nodes$0$loc;
|
||||
const startLine = (_nodes$0$loc = nodes[0].loc) == null ? void 0 : _nodes$0$loc.start.line;
|
||||
if (startLine != null && startLine !== this._buf.getCurrentLine()) {
|
||||
indent = true;
|
||||
}
|
||||
}
|
||||
if (indent) this.indent();
|
||||
const newlineOpts = {
|
||||
addNewlines: addNewlines,
|
||||
nextNodeStartLine: 0
|
||||
};
|
||||
const boundSeparator = separator == null ? void 0 : separator.bind(this);
|
||||
const len = nodes.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
const node = nodes[i];
|
||||
if (!node) continue;
|
||||
if (statement) this._printNewline(i === 0, newlineOpts);
|
||||
this.print(node, undefined, trailingCommentsLineOffset || 0);
|
||||
iterator == null || iterator(node, i);
|
||||
if (boundSeparator != null) {
|
||||
if (i < len - 1) boundSeparator(i, false);else if (printTrailingSeparator) boundSeparator(i, true);
|
||||
}
|
||||
if (statement) {
|
||||
var _node$trailingComment2;
|
||||
if (!((_node$trailingComment2 = node.trailingComments) != null && _node$trailingComment2.length)) {
|
||||
this._lastCommentLine = 0;
|
||||
}
|
||||
if (i + 1 === len) {
|
||||
this.newline(1);
|
||||
} else {
|
||||
var _nextNode$loc;
|
||||
const nextNode = nodes[i + 1];
|
||||
newlineOpts.nextNodeStartLine = ((_nextNode$loc = nextNode.loc) == null ? void 0 : _nextNode$loc.start.line) || 0;
|
||||
this._printNewline(true, newlineOpts);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
printAndIndentOnComments(node) {
|
||||
const indent = node.leadingComments && node.leadingComments.length > 0;
|
||||
if (indent) this.indent();
|
||||
this.print(node);
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
printBlock(parent) {
|
||||
const node = parent.body;
|
||||
if (node.type !== "EmptyStatement") {
|
||||
this.space();
|
||||
}
|
||||
this.print(node);
|
||||
}
|
||||
_printTrailingComments(node, parent, lineOffset) {
|
||||
const {
|
||||
innerComments,
|
||||
trailingComments
|
||||
} = node;
|
||||
if (innerComments != null && innerComments.length) {
|
||||
this._printComments(2, innerComments, node, parent, lineOffset);
|
||||
}
|
||||
if (trailingComments != null && trailingComments.length) {
|
||||
this._printComments(2, trailingComments, node, parent, lineOffset);
|
||||
}
|
||||
}
|
||||
_printLeadingComments(node, parent) {
|
||||
const comments = node.leadingComments;
|
||||
if (!(comments != null && comments.length)) return;
|
||||
this._printComments(0, comments, node, parent);
|
||||
}
|
||||
_maybePrintInnerComments(nextTokenStr, nextTokenOccurrenceCount) {
|
||||
if (this._endsWithInnerRaw) {
|
||||
var _this$tokenMap;
|
||||
this.printInnerComments((_this$tokenMap = this.tokenMap) == null ? void 0 : _this$tokenMap.findMatching(this._currentNode, nextTokenStr, nextTokenOccurrenceCount));
|
||||
}
|
||||
this._endsWithInnerRaw = true;
|
||||
this._indentInnerComments = true;
|
||||
}
|
||||
printInnerComments(nextToken) {
|
||||
const node = this._currentNode;
|
||||
const comments = node.innerComments;
|
||||
if (!(comments != null && comments.length)) return;
|
||||
const hasSpace = this.endsWith(32);
|
||||
const indent = this._indentInnerComments;
|
||||
const printedCommentsCount = this._printedComments.size;
|
||||
if (indent) this.indent();
|
||||
this._printComments(1, comments, node, undefined, undefined, nextToken);
|
||||
if (hasSpace && printedCommentsCount !== this._printedComments.size) {
|
||||
this.space();
|
||||
}
|
||||
if (indent) this.dedent();
|
||||
}
|
||||
noIndentInnerCommentsHere() {
|
||||
this._indentInnerComments = false;
|
||||
}
|
||||
printSequence(nodes, indent, trailingCommentsLineOffset, addNewlines) {
|
||||
this.printJoin(nodes, true, indent != null ? indent : false, undefined, undefined, addNewlines, undefined, trailingCommentsLineOffset);
|
||||
}
|
||||
printList(items, printTrailingSeparator, statement, indent, separator, iterator) {
|
||||
this.printJoin(items, statement, indent, separator != null ? separator : commaSeparator, printTrailingSeparator, undefined, iterator);
|
||||
}
|
||||
shouldPrintTrailingComma(listEnd) {
|
||||
if (!this.tokenMap) return null;
|
||||
const listEndIndex = this.tokenMap.findLastIndex(this._currentNode, token => this.tokenMap.matchesOriginal(token, listEnd));
|
||||
if (listEndIndex <= 0) return null;
|
||||
return this.tokenMap.matchesOriginal(this._tokens[listEndIndex - 1], ",");
|
||||
}
|
||||
_printNewline(newLine, opts) {
|
||||
const format = this.format;
|
||||
if (format.retainLines || format.compact) return;
|
||||
if (format.concise) {
|
||||
this.space();
|
||||
return;
|
||||
}
|
||||
if (!newLine) {
|
||||
return;
|
||||
}
|
||||
const startLine = opts.nextNodeStartLine;
|
||||
const lastCommentLine = this._lastCommentLine;
|
||||
if (startLine > 0 && lastCommentLine > 0) {
|
||||
const offset = startLine - lastCommentLine;
|
||||
if (offset >= 0) {
|
||||
this.newline(offset || 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this._buf.hasContent()) {
|
||||
this.newline(1);
|
||||
}
|
||||
}
|
||||
_shouldPrintComment(comment, nextToken) {
|
||||
if (comment.ignore) return 0;
|
||||
if (this._printedComments.has(comment)) return 0;
|
||||
if (this._noLineTerminator && HAS_NEWLINE_OR_BlOCK_COMMENT_END.test(comment.value)) {
|
||||
return 2;
|
||||
}
|
||||
if (nextToken && this.tokenMap) {
|
||||
const commentTok = this.tokenMap.find(this._currentNode, token => token.value === comment.value);
|
||||
if (commentTok && commentTok.start > nextToken.start) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
this._printedComments.add(comment);
|
||||
if (!this.format.shouldPrintComment(comment.value)) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
_printComment(comment, skipNewLines) {
|
||||
const noLineTerminator = this._noLineTerminator;
|
||||
const isBlockComment = comment.type === "CommentBlock";
|
||||
const printNewLines = isBlockComment && skipNewLines !== 1 && !this._noLineTerminator;
|
||||
if (printNewLines && this._buf.hasContent() && skipNewLines !== 2) {
|
||||
this.newline(1);
|
||||
}
|
||||
const lastCharCode = this.getLastChar();
|
||||
if (lastCharCode !== 91 && lastCharCode !== 123 && lastCharCode !== 40) {
|
||||
this.space();
|
||||
}
|
||||
let val;
|
||||
if (isBlockComment) {
|
||||
val = `/*${comment.value}*/`;
|
||||
if (this.format.indent.adjustMultilineComment) {
|
||||
var _comment$loc;
|
||||
const offset = (_comment$loc = comment.loc) == null ? void 0 : _comment$loc.start.column;
|
||||
if (offset) {
|
||||
const newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
|
||||
val = val.replace(newlineRegex, "\n");
|
||||
}
|
||||
if (this.format.concise) {
|
||||
val = val.replace(/\n(?!$)/g, `\n`);
|
||||
} else {
|
||||
let indentSize = this.format.retainLines ? 0 : this._buf.getCurrentColumn();
|
||||
if (this._shouldIndent(47) || this.format.retainLines) {
|
||||
indentSize += this._getIndent();
|
||||
}
|
||||
val = val.replace(/\n(?!$)/g, `\n${" ".repeat(indentSize)}`);
|
||||
}
|
||||
}
|
||||
} else if (!noLineTerminator) {
|
||||
val = `//${comment.value}`;
|
||||
} else {
|
||||
val = `/*${comment.value}*/`;
|
||||
}
|
||||
if (this._endsWithDiv) this._space();
|
||||
if (this.tokenMap) {
|
||||
const {
|
||||
_printSemicolonBeforeNextToken,
|
||||
_printSemicolonBeforeNextNode
|
||||
} = this;
|
||||
this._printSemicolonBeforeNextToken = -1;
|
||||
this._printSemicolonBeforeNextNode = -1;
|
||||
this.source("start", comment.loc);
|
||||
this._append(val, isBlockComment);
|
||||
this._printSemicolonBeforeNextNode = _printSemicolonBeforeNextNode;
|
||||
this._printSemicolonBeforeNextToken = _printSemicolonBeforeNextToken;
|
||||
} else {
|
||||
this.source("start", comment.loc);
|
||||
this._append(val, isBlockComment);
|
||||
}
|
||||
if (!isBlockComment && !noLineTerminator) {
|
||||
this.newline(1, true);
|
||||
}
|
||||
if (printNewLines && skipNewLines !== 3) {
|
||||
this.newline(1);
|
||||
}
|
||||
}
|
||||
_printComments(type, comments, node, parent, lineOffset = 0, nextToken) {
|
||||
const nodeLoc = node.loc;
|
||||
const len = comments.length;
|
||||
let hasLoc = !!nodeLoc;
|
||||
const nodeStartLine = hasLoc ? nodeLoc.start.line : 0;
|
||||
const nodeEndLine = hasLoc ? nodeLoc.end.line : 0;
|
||||
let lastLine = 0;
|
||||
let leadingCommentNewline = 0;
|
||||
const maybeNewline = this._noLineTerminator ? function () {} : this.newline.bind(this);
|
||||
for (let i = 0; i < len; i++) {
|
||||
const comment = comments[i];
|
||||
const shouldPrint = this._shouldPrintComment(comment, nextToken);
|
||||
if (shouldPrint === 2) {
|
||||
hasLoc = false;
|
||||
break;
|
||||
}
|
||||
if (hasLoc && comment.loc && shouldPrint === 1) {
|
||||
const commentStartLine = comment.loc.start.line;
|
||||
const commentEndLine = comment.loc.end.line;
|
||||
if (type === 0) {
|
||||
let offset = 0;
|
||||
if (i === 0) {
|
||||
if (this._buf.hasContent() && (comment.type === "CommentLine" || commentStartLine !== commentEndLine)) {
|
||||
offset = leadingCommentNewline = 1;
|
||||
}
|
||||
} else {
|
||||
offset = commentStartLine - lastLine;
|
||||
}
|
||||
lastLine = commentEndLine;
|
||||
maybeNewline(offset);
|
||||
this._printComment(comment, 1);
|
||||
if (i + 1 === len) {
|
||||
maybeNewline(Math.max(nodeStartLine - lastLine, leadingCommentNewline));
|
||||
lastLine = nodeStartLine;
|
||||
}
|
||||
} else if (type === 1) {
|
||||
const offset = commentStartLine - (i === 0 ? nodeStartLine : lastLine);
|
||||
lastLine = commentEndLine;
|
||||
maybeNewline(offset);
|
||||
this._printComment(comment, 1);
|
||||
if (i + 1 === len) {
|
||||
maybeNewline(Math.min(1, nodeEndLine - lastLine));
|
||||
lastLine = nodeEndLine;
|
||||
}
|
||||
} else {
|
||||
const offset = commentStartLine - (i === 0 ? nodeEndLine - lineOffset : lastLine);
|
||||
lastLine = commentEndLine;
|
||||
maybeNewline(offset);
|
||||
this._printComment(comment, 1);
|
||||
}
|
||||
} else {
|
||||
hasLoc = false;
|
||||
if (shouldPrint !== 1) {
|
||||
continue;
|
||||
}
|
||||
if (len === 1) {
|
||||
const singleLine = comment.loc ? comment.loc.start.line === comment.loc.end.line : !HAS_NEWLINE.test(comment.value);
|
||||
const shouldSkipNewline = singleLine && !isStatement(node) && !isClassBody(parent) && !isTSInterfaceBody(parent) && !isTSEnumMember(node);
|
||||
if (type === 0) {
|
||||
this._printComment(comment, shouldSkipNewline && node.type !== "ObjectExpression" || singleLine && isFunction(parent, {
|
||||
body: node
|
||||
}) ? 1 : 0);
|
||||
} else if (shouldSkipNewline && type === 2) {
|
||||
this._printComment(comment, 1);
|
||||
} else {
|
||||
this._printComment(comment, 0);
|
||||
}
|
||||
} else if (type === 1 && !(node.type === "ObjectExpression" && node.properties.length > 1) && node.type !== "ClassBody" && node.type !== "TSInterfaceBody") {
|
||||
this._printComment(comment, i === 0 ? 2 : i === len - 1 ? 3 : 0);
|
||||
} else {
|
||||
this._printComment(comment, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type === 2 && hasLoc && lastLine) {
|
||||
this._lastCommentLine = lastLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.assign(Printer.prototype, generatorFunctions);
|
||||
{
|
||||
(0, _deprecated.addDeprecatedGenerators)(Printer);
|
||||
}
|
||||
var _default = exports.default = Printer;
|
||||
function commaSeparator(occurrenceCount, last) {
|
||||
this.token(",", false, occurrenceCount);
|
||||
if (!last) this.space();
|
||||
}
|
||||
|
||||
//# sourceMappingURL=printer.js.map
|
1
node_modules/@babel/generator/lib/printer.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/printer.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
85
node_modules/@babel/generator/lib/source-map.js
generated
vendored
Normal file
85
node_modules/@babel/generator/lib/source-map.js
generated
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _genMapping = require("@jridgewell/gen-mapping");
|
||||
var _traceMapping = require("@jridgewell/trace-mapping");
|
||||
class SourceMap {
|
||||
constructor(opts, code) {
|
||||
var _opts$sourceFileName;
|
||||
this._map = void 0;
|
||||
this._rawMappings = void 0;
|
||||
this._sourceFileName = void 0;
|
||||
this._lastGenLine = 0;
|
||||
this._lastSourceLine = 0;
|
||||
this._lastSourceColumn = 0;
|
||||
this._inputMap = void 0;
|
||||
const map = this._map = new _genMapping.GenMapping({
|
||||
sourceRoot: opts.sourceRoot
|
||||
});
|
||||
this._sourceFileName = (_opts$sourceFileName = opts.sourceFileName) == null ? void 0 : _opts$sourceFileName.replace(/\\/g, "/");
|
||||
this._rawMappings = undefined;
|
||||
if (opts.inputSourceMap) {
|
||||
this._inputMap = new _traceMapping.TraceMap(opts.inputSourceMap);
|
||||
const resolvedSources = this._inputMap.resolvedSources;
|
||||
if (resolvedSources.length) {
|
||||
for (let i = 0; i < resolvedSources.length; i++) {
|
||||
var _this$_inputMap$sourc;
|
||||
(0, _genMapping.setSourceContent)(map, resolvedSources[i], (_this$_inputMap$sourc = this._inputMap.sourcesContent) == null ? void 0 : _this$_inputMap$sourc[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof code === "string" && !opts.inputSourceMap) {
|
||||
(0, _genMapping.setSourceContent)(map, this._sourceFileName, code);
|
||||
} else if (typeof code === "object") {
|
||||
for (const sourceFileName of Object.keys(code)) {
|
||||
(0, _genMapping.setSourceContent)(map, sourceFileName.replace(/\\/g, "/"), code[sourceFileName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
get() {
|
||||
return (0, _genMapping.toEncodedMap)(this._map);
|
||||
}
|
||||
getDecoded() {
|
||||
return (0, _genMapping.toDecodedMap)(this._map);
|
||||
}
|
||||
getRawMappings() {
|
||||
return this._rawMappings || (this._rawMappings = (0, _genMapping.allMappings)(this._map));
|
||||
}
|
||||
mark(generated, line, column, identifierName, identifierNamePos, filename) {
|
||||
var _originalMapping;
|
||||
this._rawMappings = undefined;
|
||||
let originalMapping;
|
||||
if (line != null) {
|
||||
if (this._inputMap) {
|
||||
originalMapping = (0, _traceMapping.originalPositionFor)(this._inputMap, {
|
||||
line,
|
||||
column
|
||||
});
|
||||
if (!originalMapping.name && identifierNamePos) {
|
||||
const originalIdentifierMapping = (0, _traceMapping.originalPositionFor)(this._inputMap, identifierNamePos);
|
||||
if (originalIdentifierMapping.name) {
|
||||
identifierName = originalIdentifierMapping.name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
originalMapping = {
|
||||
source: (filename == null ? void 0 : filename.replace(/\\/g, "/")) || this._sourceFileName,
|
||||
line: line,
|
||||
column: column
|
||||
};
|
||||
}
|
||||
}
|
||||
(0, _genMapping.maybeAddMapping)(this._map, {
|
||||
name: identifierName,
|
||||
generated,
|
||||
source: (_originalMapping = originalMapping) == null ? void 0 : _originalMapping.source,
|
||||
original: originalMapping
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = SourceMap;
|
||||
|
||||
//# sourceMappingURL=source-map.js.map
|
1
node_modules/@babel/generator/lib/source-map.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/source-map.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
191
node_modules/@babel/generator/lib/token-map.js
generated
vendored
Normal file
191
node_modules/@babel/generator/lib/token-map.js
generated
vendored
Normal file
|
@ -0,0 +1,191 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.TokenMap = void 0;
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
traverseFast,
|
||||
VISITOR_KEYS
|
||||
} = _t;
|
||||
class TokenMap {
|
||||
constructor(ast, tokens, source) {
|
||||
this._tokens = void 0;
|
||||
this._source = void 0;
|
||||
this._nodesToTokenIndexes = new Map();
|
||||
this._nodesOccurrencesCountCache = new Map();
|
||||
this._tokensCache = new Map();
|
||||
this._tokens = tokens;
|
||||
this._source = source;
|
||||
traverseFast(ast, node => {
|
||||
const indexes = this._getTokensIndexesOfNode(node);
|
||||
if (indexes.length > 0) this._nodesToTokenIndexes.set(node, indexes);
|
||||
});
|
||||
this._tokensCache = null;
|
||||
}
|
||||
has(node) {
|
||||
return this._nodesToTokenIndexes.has(node);
|
||||
}
|
||||
getIndexes(node) {
|
||||
return this._nodesToTokenIndexes.get(node);
|
||||
}
|
||||
find(node, condition) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (indexes) {
|
||||
for (let k = 0; k < indexes.length; k++) {
|
||||
const index = indexes[k];
|
||||
const tok = this._tokens[index];
|
||||
if (condition(tok, index)) return tok;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
findLastIndex(node, condition) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (indexes) {
|
||||
for (let k = indexes.length - 1; k >= 0; k--) {
|
||||
const index = indexes[k];
|
||||
const tok = this._tokens[index];
|
||||
if (condition(tok, index)) return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
findMatching(node, test, occurrenceCount = 0) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (indexes) {
|
||||
let i = 0;
|
||||
const count = occurrenceCount;
|
||||
if (count > 1) {
|
||||
const cache = this._nodesOccurrencesCountCache.get(node);
|
||||
if (cache && cache.test === test && cache.count < count) {
|
||||
i = cache.i + 1;
|
||||
occurrenceCount -= cache.count + 1;
|
||||
}
|
||||
}
|
||||
for (; i < indexes.length; i++) {
|
||||
const tok = this._tokens[indexes[i]];
|
||||
if (this.matchesOriginal(tok, test)) {
|
||||
if (occurrenceCount === 0) {
|
||||
if (count > 0) {
|
||||
this._nodesOccurrencesCountCache.set(node, {
|
||||
test,
|
||||
count,
|
||||
i
|
||||
});
|
||||
}
|
||||
return tok;
|
||||
}
|
||||
occurrenceCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
matchesOriginal(token, test) {
|
||||
if (token.end - token.start !== test.length) return false;
|
||||
if (token.value != null) return token.value === test;
|
||||
return this._source.startsWith(test, token.start);
|
||||
}
|
||||
startMatches(node, test) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (!indexes) return false;
|
||||
const tok = this._tokens[indexes[0]];
|
||||
if (tok.start !== node.start) return false;
|
||||
return this.matchesOriginal(tok, test);
|
||||
}
|
||||
endMatches(node, test) {
|
||||
const indexes = this._nodesToTokenIndexes.get(node);
|
||||
if (!indexes) return false;
|
||||
const tok = this._tokens[indexes[indexes.length - 1]];
|
||||
if (tok.end !== node.end) return false;
|
||||
return this.matchesOriginal(tok, test);
|
||||
}
|
||||
_getTokensIndexesOfNode(node) {
|
||||
if (node.start == null || node.end == null) return [];
|
||||
const {
|
||||
first,
|
||||
last
|
||||
} = this._findTokensOfNode(node, 0, this._tokens.length - 1);
|
||||
let low = first;
|
||||
const children = childrenIterator(node);
|
||||
if ((node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") && node.declaration && node.declaration.type === "ClassDeclaration") {
|
||||
children.next();
|
||||
}
|
||||
const indexes = [];
|
||||
for (const child of children) {
|
||||
if (child == null) continue;
|
||||
if (child.start == null || child.end == null) continue;
|
||||
const childTok = this._findTokensOfNode(child, low, last);
|
||||
const high = childTok.first;
|
||||
for (let k = low; k < high; k++) indexes.push(k);
|
||||
low = childTok.last + 1;
|
||||
}
|
||||
for (let k = low; k <= last; k++) indexes.push(k);
|
||||
return indexes;
|
||||
}
|
||||
_findTokensOfNode(node, low, high) {
|
||||
const cached = this._tokensCache.get(node);
|
||||
if (cached) return cached;
|
||||
const first = this._findFirstTokenOfNode(node.start, low, high);
|
||||
const last = this._findLastTokenOfNode(node.end, first, high);
|
||||
this._tokensCache.set(node, {
|
||||
first,
|
||||
last
|
||||
});
|
||||
return {
|
||||
first,
|
||||
last
|
||||
};
|
||||
}
|
||||
_findFirstTokenOfNode(start, low, high) {
|
||||
while (low <= high) {
|
||||
const mid = high + low >> 1;
|
||||
if (start < this._tokens[mid].start) {
|
||||
high = mid - 1;
|
||||
} else if (start > this._tokens[mid].start) {
|
||||
low = mid + 1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
return low;
|
||||
}
|
||||
_findLastTokenOfNode(end, low, high) {
|
||||
while (low <= high) {
|
||||
const mid = high + low >> 1;
|
||||
if (end < this._tokens[mid].end) {
|
||||
high = mid - 1;
|
||||
} else if (end > this._tokens[mid].end) {
|
||||
low = mid + 1;
|
||||
} else {
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
return high;
|
||||
}
|
||||
}
|
||||
exports.TokenMap = TokenMap;
|
||||
function* childrenIterator(node) {
|
||||
if (node.type === "TemplateLiteral") {
|
||||
yield node.quasis[0];
|
||||
for (let i = 1; i < node.quasis.length; i++) {
|
||||
yield node.expressions[i - 1];
|
||||
yield node.quasis[i];
|
||||
}
|
||||
return;
|
||||
}
|
||||
const keys = VISITOR_KEYS[node.type];
|
||||
for (const key of keys) {
|
||||
const child = node[key];
|
||||
if (!child) continue;
|
||||
if (Array.isArray(child)) {
|
||||
yield* child;
|
||||
} else {
|
||||
yield child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=token-map.js.map
|
1
node_modules/@babel/generator/lib/token-map.js.map
generated
vendored
Normal file
1
node_modules/@babel/generator/lib/token-map.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
71
node_modules/@babel/generator/package.json
generated
vendored
Normal file
71
node_modules/@babel/generator/package.json
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
"_from": "@babel/generator@^7.27.0",
|
||||
"_id": "@babel/generator@7.27.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-VybsKvpiN1gU1sdMZIp7FcqphVVKEwcuj02x73uvcHE0PTihx1nlBcowYWhDwjpoAXRv43+gDzyggGnn1XZhVw==",
|
||||
"_location": "/@babel/generator",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@babel/generator@^7.27.0",
|
||||
"name": "@babel/generator",
|
||||
"escapedName": "@babel%2fgenerator",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "^7.27.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^7.27.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/traverse"
|
||||
],
|
||||
"_resolved": "https://registry.npmmirror.com/@babel/generator/-/generator-7.27.0.tgz",
|
||||
"_shasum": "764382b5392e5b9aff93cadb190d0745866cbc2c",
|
||||
"_spec": "@babel/generator@^7.27.0",
|
||||
"_where": "D:\\jiangchengfeiyi-xiaochengxu\\node_modules\\@babel\\traverse",
|
||||
"author": {
|
||||
"name": "The Babel Team",
|
||||
"url": "https://babel.dev/team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20generator%22+is%3Aopen"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.27.0",
|
||||
"@babel/types": "^7.27.0",
|
||||
"@jridgewell/gen-mapping": "^0.3.5",
|
||||
"@jridgewell/trace-mapping": "^0.3.25",
|
||||
"jsesc": "^3.0.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Turns an AST into code.",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.26.10",
|
||||
"@babel/helper-fixtures": "^7.26.0",
|
||||
"@babel/plugin-transform-typescript": "^7.27.0",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.15",
|
||||
"@types/jsesc": "^2.5.0",
|
||||
"charcodes": "^0.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-generator",
|
||||
"license": "MIT",
|
||||
"main": "./lib/index.js",
|
||||
"name": "@babel/generator",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-generator"
|
||||
},
|
||||
"type": "commonjs",
|
||||
"version": "7.27.0"
|
||||
}
|
22
node_modules/@babel/helper-module-imports/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/helper-module-imports/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
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.
|
19
node_modules/@babel/helper-module-imports/README.md
generated
vendored
Normal file
19
node_modules/@babel/helper-module-imports/README.md
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# @babel/helper-module-imports
|
||||
|
||||
> Babel helper functions for inserting module loads
|
||||
|
||||
See our website [@babel/helper-module-imports](https://babeljs.io/docs/babel-helper-module-imports) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-module-imports
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helper-module-imports
|
||||
```
|
122
node_modules/@babel/helper-module-imports/lib/import-builder.js
generated
vendored
Normal file
122
node_modules/@babel/helper-module-imports/lib/import-builder.js
generated
vendored
Normal file
|
@ -0,0 +1,122 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _assert = require("assert");
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
callExpression,
|
||||
cloneNode,
|
||||
expressionStatement,
|
||||
identifier,
|
||||
importDeclaration,
|
||||
importDefaultSpecifier,
|
||||
importNamespaceSpecifier,
|
||||
importSpecifier,
|
||||
memberExpression,
|
||||
stringLiteral,
|
||||
variableDeclaration,
|
||||
variableDeclarator
|
||||
} = _t;
|
||||
class ImportBuilder {
|
||||
constructor(importedSource, scope, hub) {
|
||||
this._statements = [];
|
||||
this._resultName = null;
|
||||
this._importedSource = void 0;
|
||||
this._scope = scope;
|
||||
this._hub = hub;
|
||||
this._importedSource = importedSource;
|
||||
}
|
||||
done() {
|
||||
return {
|
||||
statements: this._statements,
|
||||
resultName: this._resultName
|
||||
};
|
||||
}
|
||||
import() {
|
||||
this._statements.push(importDeclaration([], stringLiteral(this._importedSource)));
|
||||
return this;
|
||||
}
|
||||
require() {
|
||||
this._statements.push(expressionStatement(callExpression(identifier("require"), [stringLiteral(this._importedSource)])));
|
||||
return this;
|
||||
}
|
||||
namespace(name = "namespace") {
|
||||
const local = this._scope.generateUidIdentifier(name);
|
||||
const statement = this._statements[this._statements.length - 1];
|
||||
_assert(statement.type === "ImportDeclaration");
|
||||
_assert(statement.specifiers.length === 0);
|
||||
statement.specifiers = [importNamespaceSpecifier(local)];
|
||||
this._resultName = cloneNode(local);
|
||||
return this;
|
||||
}
|
||||
default(name) {
|
||||
const id = this._scope.generateUidIdentifier(name);
|
||||
const statement = this._statements[this._statements.length - 1];
|
||||
_assert(statement.type === "ImportDeclaration");
|
||||
_assert(statement.specifiers.length === 0);
|
||||
statement.specifiers = [importDefaultSpecifier(id)];
|
||||
this._resultName = cloneNode(id);
|
||||
return this;
|
||||
}
|
||||
named(name, importName) {
|
||||
if (importName === "default") return this.default(name);
|
||||
const id = this._scope.generateUidIdentifier(name);
|
||||
const statement = this._statements[this._statements.length - 1];
|
||||
_assert(statement.type === "ImportDeclaration");
|
||||
_assert(statement.specifiers.length === 0);
|
||||
statement.specifiers = [importSpecifier(id, identifier(importName))];
|
||||
this._resultName = cloneNode(id);
|
||||
return this;
|
||||
}
|
||||
var(name) {
|
||||
const id = this._scope.generateUidIdentifier(name);
|
||||
let statement = this._statements[this._statements.length - 1];
|
||||
if (statement.type !== "ExpressionStatement") {
|
||||
_assert(this._resultName);
|
||||
statement = expressionStatement(this._resultName);
|
||||
this._statements.push(statement);
|
||||
}
|
||||
this._statements[this._statements.length - 1] = variableDeclaration("var", [variableDeclarator(id, statement.expression)]);
|
||||
this._resultName = cloneNode(id);
|
||||
return this;
|
||||
}
|
||||
defaultInterop() {
|
||||
return this._interop(this._hub.addHelper("interopRequireDefault"));
|
||||
}
|
||||
wildcardInterop() {
|
||||
return this._interop(this._hub.addHelper("interopRequireWildcard"));
|
||||
}
|
||||
_interop(callee) {
|
||||
const statement = this._statements[this._statements.length - 1];
|
||||
if (statement.type === "ExpressionStatement") {
|
||||
statement.expression = callExpression(callee, [statement.expression]);
|
||||
} else if (statement.type === "VariableDeclaration") {
|
||||
_assert(statement.declarations.length === 1);
|
||||
statement.declarations[0].init = callExpression(callee, [statement.declarations[0].init]);
|
||||
} else {
|
||||
_assert.fail("Unexpected type.");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
prop(name) {
|
||||
const statement = this._statements[this._statements.length - 1];
|
||||
if (statement.type === "ExpressionStatement") {
|
||||
statement.expression = memberExpression(statement.expression, identifier(name));
|
||||
} else if (statement.type === "VariableDeclaration") {
|
||||
_assert(statement.declarations.length === 1);
|
||||
statement.declarations[0].init = memberExpression(statement.declarations[0].init, identifier(name));
|
||||
} else {
|
||||
_assert.fail("Unexpected type:" + statement.type);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
read(name) {
|
||||
this._resultName = memberExpression(this._resultName, identifier(name));
|
||||
}
|
||||
}
|
||||
exports.default = ImportBuilder;
|
||||
|
||||
//# sourceMappingURL=import-builder.js.map
|
1
node_modules/@babel/helper-module-imports/lib/import-builder.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-imports/lib/import-builder.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
304
node_modules/@babel/helper-module-imports/lib/import-injector.js
generated
vendored
Normal file
304
node_modules/@babel/helper-module-imports/lib/import-injector.js
generated
vendored
Normal file
|
@ -0,0 +1,304 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _assert = require("assert");
|
||||
var _t = require("@babel/types");
|
||||
var _importBuilder = require("./import-builder.js");
|
||||
var _isModule = require("./is-module.js");
|
||||
const {
|
||||
identifier,
|
||||
importSpecifier,
|
||||
numericLiteral,
|
||||
sequenceExpression,
|
||||
isImportDeclaration
|
||||
} = _t;
|
||||
class ImportInjector {
|
||||
constructor(path, importedSource, opts) {
|
||||
this._defaultOpts = {
|
||||
importedSource: null,
|
||||
importedType: "commonjs",
|
||||
importedInterop: "babel",
|
||||
importingInterop: "babel",
|
||||
ensureLiveReference: false,
|
||||
ensureNoContext: false,
|
||||
importPosition: "before"
|
||||
};
|
||||
const programPath = path.find(p => p.isProgram());
|
||||
this._programPath = programPath;
|
||||
this._programScope = programPath.scope;
|
||||
this._hub = programPath.hub;
|
||||
this._defaultOpts = this._applyDefaults(importedSource, opts, true);
|
||||
}
|
||||
addDefault(importedSourceIn, opts) {
|
||||
return this.addNamed("default", importedSourceIn, opts);
|
||||
}
|
||||
addNamed(importName, importedSourceIn, opts) {
|
||||
_assert(typeof importName === "string");
|
||||
return this._generateImport(this._applyDefaults(importedSourceIn, opts), importName);
|
||||
}
|
||||
addNamespace(importedSourceIn, opts) {
|
||||
return this._generateImport(this._applyDefaults(importedSourceIn, opts), null);
|
||||
}
|
||||
addSideEffect(importedSourceIn, opts) {
|
||||
return this._generateImport(this._applyDefaults(importedSourceIn, opts), void 0);
|
||||
}
|
||||
_applyDefaults(importedSource, opts, isInit = false) {
|
||||
let newOpts;
|
||||
if (typeof importedSource === "string") {
|
||||
newOpts = Object.assign({}, this._defaultOpts, {
|
||||
importedSource
|
||||
}, opts);
|
||||
} else {
|
||||
_assert(!opts, "Unexpected secondary arguments.");
|
||||
newOpts = Object.assign({}, this._defaultOpts, importedSource);
|
||||
}
|
||||
if (!isInit && opts) {
|
||||
if (opts.nameHint !== undefined) newOpts.nameHint = opts.nameHint;
|
||||
if (opts.blockHoist !== undefined) newOpts.blockHoist = opts.blockHoist;
|
||||
}
|
||||
return newOpts;
|
||||
}
|
||||
_generateImport(opts, importName) {
|
||||
const isDefault = importName === "default";
|
||||
const isNamed = !!importName && !isDefault;
|
||||
const isNamespace = importName === null;
|
||||
const {
|
||||
importedSource,
|
||||
importedType,
|
||||
importedInterop,
|
||||
importingInterop,
|
||||
ensureLiveReference,
|
||||
ensureNoContext,
|
||||
nameHint,
|
||||
importPosition,
|
||||
blockHoist
|
||||
} = opts;
|
||||
let name = nameHint || importName;
|
||||
const isMod = (0, _isModule.default)(this._programPath);
|
||||
const isModuleForNode = isMod && importingInterop === "node";
|
||||
const isModuleForBabel = isMod && importingInterop === "babel";
|
||||
if (importPosition === "after" && !isMod) {
|
||||
throw new Error(`"importPosition": "after" is only supported in modules`);
|
||||
}
|
||||
const builder = new _importBuilder.default(importedSource, this._programScope, this._hub);
|
||||
if (importedType === "es6") {
|
||||
if (!isModuleForNode && !isModuleForBabel) {
|
||||
throw new Error("Cannot import an ES6 module from CommonJS");
|
||||
}
|
||||
builder.import();
|
||||
if (isNamespace) {
|
||||
builder.namespace(nameHint || importedSource);
|
||||
} else if (isDefault || isNamed) {
|
||||
builder.named(name, importName);
|
||||
}
|
||||
} else if (importedType !== "commonjs") {
|
||||
throw new Error(`Unexpected interopType "${importedType}"`);
|
||||
} else if (importedInterop === "babel") {
|
||||
if (isModuleForNode) {
|
||||
name = name !== "default" ? name : importedSource;
|
||||
const es6Default = `${importedSource}$es6Default`;
|
||||
builder.import();
|
||||
if (isNamespace) {
|
||||
builder.default(es6Default).var(name || importedSource).wildcardInterop();
|
||||
} else if (isDefault) {
|
||||
if (ensureLiveReference) {
|
||||
builder.default(es6Default).var(name || importedSource).defaultInterop().read("default");
|
||||
} else {
|
||||
builder.default(es6Default).var(name).defaultInterop().prop(importName);
|
||||
}
|
||||
} else if (isNamed) {
|
||||
builder.default(es6Default).read(importName);
|
||||
}
|
||||
} else if (isModuleForBabel) {
|
||||
builder.import();
|
||||
if (isNamespace) {
|
||||
builder.namespace(name || importedSource);
|
||||
} else if (isDefault || isNamed) {
|
||||
builder.named(name, importName);
|
||||
}
|
||||
} else {
|
||||
builder.require();
|
||||
if (isNamespace) {
|
||||
builder.var(name || importedSource).wildcardInterop();
|
||||
} else if ((isDefault || isNamed) && ensureLiveReference) {
|
||||
if (isDefault) {
|
||||
name = name !== "default" ? name : importedSource;
|
||||
builder.var(name).read(importName);
|
||||
builder.defaultInterop();
|
||||
} else {
|
||||
builder.var(importedSource).read(importName);
|
||||
}
|
||||
} else if (isDefault) {
|
||||
builder.var(name).defaultInterop().prop(importName);
|
||||
} else if (isNamed) {
|
||||
builder.var(name).prop(importName);
|
||||
}
|
||||
}
|
||||
} else if (importedInterop === "compiled") {
|
||||
if (isModuleForNode) {
|
||||
builder.import();
|
||||
if (isNamespace) {
|
||||
builder.default(name || importedSource);
|
||||
} else if (isDefault || isNamed) {
|
||||
builder.default(importedSource).read(name);
|
||||
}
|
||||
} else if (isModuleForBabel) {
|
||||
builder.import();
|
||||
if (isNamespace) {
|
||||
builder.namespace(name || importedSource);
|
||||
} else if (isDefault || isNamed) {
|
||||
builder.named(name, importName);
|
||||
}
|
||||
} else {
|
||||
builder.require();
|
||||
if (isNamespace) {
|
||||
builder.var(name || importedSource);
|
||||
} else if (isDefault || isNamed) {
|
||||
if (ensureLiveReference) {
|
||||
builder.var(importedSource).read(name);
|
||||
} else {
|
||||
builder.prop(importName).var(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (importedInterop === "uncompiled") {
|
||||
if (isDefault && ensureLiveReference) {
|
||||
throw new Error("No live reference for commonjs default");
|
||||
}
|
||||
if (isModuleForNode) {
|
||||
builder.import();
|
||||
if (isNamespace) {
|
||||
builder.default(name || importedSource);
|
||||
} else if (isDefault) {
|
||||
builder.default(name);
|
||||
} else if (isNamed) {
|
||||
builder.default(importedSource).read(name);
|
||||
}
|
||||
} else if (isModuleForBabel) {
|
||||
builder.import();
|
||||
if (isNamespace) {
|
||||
builder.default(name || importedSource);
|
||||
} else if (isDefault) {
|
||||
builder.default(name);
|
||||
} else if (isNamed) {
|
||||
builder.named(name, importName);
|
||||
}
|
||||
} else {
|
||||
builder.require();
|
||||
if (isNamespace) {
|
||||
builder.var(name || importedSource);
|
||||
} else if (isDefault) {
|
||||
builder.var(name);
|
||||
} else if (isNamed) {
|
||||
if (ensureLiveReference) {
|
||||
builder.var(importedSource).read(name);
|
||||
} else {
|
||||
builder.var(name).prop(importName);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Unknown importedInterop "${importedInterop}".`);
|
||||
}
|
||||
const {
|
||||
statements,
|
||||
resultName
|
||||
} = builder.done();
|
||||
this._insertStatements(statements, importPosition, blockHoist);
|
||||
if ((isDefault || isNamed) && ensureNoContext && resultName.type !== "Identifier") {
|
||||
return sequenceExpression([numericLiteral(0), resultName]);
|
||||
}
|
||||
return resultName;
|
||||
}
|
||||
_insertStatements(statements, importPosition = "before", blockHoist = 3) {
|
||||
if (importPosition === "after") {
|
||||
if (this._insertStatementsAfter(statements)) return;
|
||||
} else {
|
||||
if (this._insertStatementsBefore(statements, blockHoist)) return;
|
||||
}
|
||||
this._programPath.unshiftContainer("body", statements);
|
||||
}
|
||||
_insertStatementsBefore(statements, blockHoist) {
|
||||
if (statements.length === 1 && isImportDeclaration(statements[0]) && isValueImport(statements[0])) {
|
||||
const firstImportDecl = this._programPath.get("body").find(p => {
|
||||
return p.isImportDeclaration() && isValueImport(p.node);
|
||||
});
|
||||
if ((firstImportDecl == null ? void 0 : firstImportDecl.node.source.value) === statements[0].source.value && maybeAppendImportSpecifiers(firstImportDecl.node, statements[0])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
statements.forEach(node => {
|
||||
node._blockHoist = blockHoist;
|
||||
});
|
||||
const targetPath = this._programPath.get("body").find(p => {
|
||||
const val = p.node._blockHoist;
|
||||
return Number.isFinite(val) && val < 4;
|
||||
});
|
||||
if (targetPath) {
|
||||
targetPath.insertBefore(statements);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_insertStatementsAfter(statements) {
|
||||
const statementsSet = new Set(statements);
|
||||
const importDeclarations = new Map();
|
||||
for (const statement of statements) {
|
||||
if (isImportDeclaration(statement) && isValueImport(statement)) {
|
||||
const source = statement.source.value;
|
||||
if (!importDeclarations.has(source)) importDeclarations.set(source, []);
|
||||
importDeclarations.get(source).push(statement);
|
||||
}
|
||||
}
|
||||
let lastImportPath = null;
|
||||
for (const bodyStmt of this._programPath.get("body")) {
|
||||
if (bodyStmt.isImportDeclaration() && isValueImport(bodyStmt.node)) {
|
||||
lastImportPath = bodyStmt;
|
||||
const source = bodyStmt.node.source.value;
|
||||
const newImports = importDeclarations.get(source);
|
||||
if (!newImports) continue;
|
||||
for (const decl of newImports) {
|
||||
if (!statementsSet.has(decl)) continue;
|
||||
if (maybeAppendImportSpecifiers(bodyStmt.node, decl)) {
|
||||
statementsSet.delete(decl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (statementsSet.size === 0) return true;
|
||||
if (lastImportPath) lastImportPath.insertAfter(Array.from(statementsSet));
|
||||
return !!lastImportPath;
|
||||
}
|
||||
}
|
||||
exports.default = ImportInjector;
|
||||
function isValueImport(node) {
|
||||
return node.importKind !== "type" && node.importKind !== "typeof";
|
||||
}
|
||||
function hasNamespaceImport(node) {
|
||||
return node.specifiers.length === 1 && node.specifiers[0].type === "ImportNamespaceSpecifier" || node.specifiers.length === 2 && node.specifiers[1].type === "ImportNamespaceSpecifier";
|
||||
}
|
||||
function hasDefaultImport(node) {
|
||||
return node.specifiers.length > 0 && node.specifiers[0].type === "ImportDefaultSpecifier";
|
||||
}
|
||||
function maybeAppendImportSpecifiers(target, source) {
|
||||
if (!target.specifiers.length) {
|
||||
target.specifiers = source.specifiers;
|
||||
return true;
|
||||
}
|
||||
if (!source.specifiers.length) return true;
|
||||
if (hasNamespaceImport(target) || hasNamespaceImport(source)) return false;
|
||||
if (hasDefaultImport(source)) {
|
||||
if (hasDefaultImport(target)) {
|
||||
source.specifiers[0] = importSpecifier(source.specifiers[0].local, identifier("default"));
|
||||
} else {
|
||||
target.specifiers.unshift(source.specifiers.shift());
|
||||
}
|
||||
}
|
||||
target.specifiers.push(...source.specifiers);
|
||||
return true;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=import-injector.js.map
|
1
node_modules/@babel/helper-module-imports/lib/import-injector.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-imports/lib/import-injector.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
37
node_modules/@babel/helper-module-imports/lib/index.js
generated
vendored
Normal file
37
node_modules/@babel/helper-module-imports/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "ImportInjector", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _importInjector.default;
|
||||
}
|
||||
});
|
||||
exports.addDefault = addDefault;
|
||||
exports.addNamed = addNamed;
|
||||
exports.addNamespace = addNamespace;
|
||||
exports.addSideEffect = addSideEffect;
|
||||
Object.defineProperty(exports, "isModule", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _isModule.default;
|
||||
}
|
||||
});
|
||||
var _importInjector = require("./import-injector.js");
|
||||
var _isModule = require("./is-module.js");
|
||||
function addDefault(path, importedSource, opts) {
|
||||
return new _importInjector.default(path).addDefault(importedSource, opts);
|
||||
}
|
||||
function addNamed(path, name, importedSource, opts) {
|
||||
return new _importInjector.default(path).addNamed(name, importedSource, opts);
|
||||
}
|
||||
function addNamespace(path, importedSource, opts) {
|
||||
return new _importInjector.default(path).addNamespace(importedSource, opts);
|
||||
}
|
||||
function addSideEffect(path, importedSource, opts) {
|
||||
return new _importInjector.default(path).addSideEffect(importedSource, opts);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@babel/helper-module-imports/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-imports/lib/index.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["_importInjector","require","_isModule","addDefault","path","importedSource","opts","ImportInjector","addNamed","name","addNamespace","addSideEffect"],"sources":["../src/index.ts"],"sourcesContent":["import ImportInjector, { type ImportOptions } from \"./import-injector.ts\";\nimport type { NodePath } from \"@babel/traverse\";\nimport type * as t from \"@babel/types\";\n\nexport { ImportInjector };\n\nexport { default as isModule } from \"./is-module.ts\";\n\nexport function addDefault(\n path: NodePath,\n importedSource: string,\n opts?: Partial<ImportOptions>,\n) {\n return new ImportInjector(path).addDefault(importedSource, opts);\n}\n\nfunction addNamed(\n path: NodePath,\n name: string,\n importedSource: string,\n opts?: Omit<\n Partial<ImportOptions>,\n \"ensureLiveReference\" | \"ensureNoContext\"\n >,\n): t.Identifier;\nfunction addNamed(\n path: NodePath,\n name: string,\n importedSource: string,\n opts?: Omit<Partial<ImportOptions>, \"ensureLiveReference\"> & {\n ensureLiveReference: true;\n },\n): t.MemberExpression;\nfunction addNamed(\n path: NodePath,\n name: string,\n importedSource: string,\n opts?: Omit<Partial<ImportOptions>, \"ensureNoContext\"> & {\n ensureNoContext: true;\n },\n): t.SequenceExpression;\n/**\n * add a named import to the program path of given path\n *\n * @export\n * @param {NodePath} path The starting path to find a program path\n * @param {string} name The name of the generated binding. Babel will prefix it with `_`\n * @param {string} importedSource The source of the import\n * @param {Partial<ImportOptions>} [opts]\n * @returns {t.Identifier | t.MemberExpression | t.SequenceExpression} If opts.ensureNoContext is true, returns a SequenceExpression,\n * else if opts.ensureLiveReference is true, returns a MemberExpression, else returns an Identifier\n */\nfunction addNamed(\n path: NodePath,\n name: string,\n importedSource: string,\n opts?: Partial<ImportOptions>,\n) {\n return new ImportInjector(path).addNamed(name, importedSource, opts);\n}\nexport { addNamed };\n\nexport function addNamespace(\n path: NodePath,\n importedSource: string,\n opts?: Partial<ImportOptions>,\n) {\n return new ImportInjector(path).addNamespace(importedSource, opts);\n}\n\nexport function addSideEffect(\n path: NodePath,\n importedSource: string,\n opts?: Partial<ImportOptions>,\n) {\n return new ImportInjector(path).addSideEffect(importedSource, opts);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAMA,IAAAC,SAAA,GAAAD,OAAA;AAEO,SAASE,UAAUA,CACxBC,IAAc,EACdC,cAAsB,EACtBC,IAA6B,EAC7B;EACA,OAAO,IAAIC,uBAAc,CAACH,IAAI,CAAC,CAACD,UAAU,CAACE,cAAc,EAAEC,IAAI,CAAC;AAClE;AAsCA,SAASE,QAAQA,CACfJ,IAAc,EACdK,IAAY,EACZJ,cAAsB,EACtBC,IAA6B,EAC7B;EACA,OAAO,IAAIC,uBAAc,CAACH,IAAI,CAAC,CAACI,QAAQ,CAACC,IAAI,EAAEJ,cAAc,EAAEC,IAAI,CAAC;AACtE;AAGO,SAASI,YAAYA,CAC1BN,IAAc,EACdC,cAAsB,EACtBC,IAA6B,EAC7B;EACA,OAAO,IAAIC,uBAAc,CAACH,IAAI,CAAC,CAACM,YAAY,CAACL,cAAc,EAAEC,IAAI,CAAC;AACpE;AAEO,SAASK,aAAaA,CAC3BP,IAAc,EACdC,cAAsB,EACtBC,IAA6B,EAC7B;EACA,OAAO,IAAIC,uBAAc,CAACH,IAAI,CAAC,CAACO,aAAa,CAACN,cAAc,EAAEC,IAAI,CAAC;AACrE","ignoreList":[]}
|
11
node_modules/@babel/helper-module-imports/lib/is-module.js
generated
vendored
Normal file
11
node_modules/@babel/helper-module-imports/lib/is-module.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isModule;
|
||||
function isModule(path) {
|
||||
return path.node.sourceType === "module";
|
||||
}
|
||||
|
||||
//# sourceMappingURL=is-module.js.map
|
1
node_modules/@babel/helper-module-imports/lib/is-module.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-imports/lib/is-module.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["isModule","path","node","sourceType"],"sources":["../src/is-module.ts"],"sourcesContent":["import type { NodePath } from \"@babel/traverse\";\nimport type * as t from \"@babel/types\";\n\n/**\n * A small utility to check if a file qualifies as a module.\n */\nexport default function isModule(path: NodePath<t.Program>) {\n return path.node.sourceType === \"module\";\n}\n"],"mappings":";;;;;;AAMe,SAASA,QAAQA,CAACC,IAAyB,EAAE;EAC1D,OAAOA,IAAI,CAACC,IAAI,CAACC,UAAU,KAAK,QAAQ;AAC1C","ignoreList":[]}
|
60
node_modules/@babel/helper-module-imports/package.json
generated
vendored
Normal file
60
node_modules/@babel/helper-module-imports/package.json
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"_from": "@babel/helper-module-imports@^7.25.9",
|
||||
"_id": "@babel/helper-module-imports@7.25.9",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==",
|
||||
"_location": "/@babel/helper-module-imports",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@babel/helper-module-imports@^7.25.9",
|
||||
"name": "@babel/helper-module-imports",
|
||||
"escapedName": "@babel%2fhelper-module-imports",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "^7.25.9",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^7.25.9"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/helper-module-transforms"
|
||||
],
|
||||
"_resolved": "https://registry.npmmirror.com/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz",
|
||||
"_shasum": "e7f8d20602ebdbf9ebbea0a0751fb0f2a4141715",
|
||||
"_spec": "@babel/helper-module-imports@^7.25.9",
|
||||
"_where": "D:\\jiangchengfeiyi-xiaochengxu\\node_modules\\@babel\\helper-module-transforms",
|
||||
"author": {
|
||||
"name": "The Babel Team",
|
||||
"url": "https://babel.dev/team"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/babel/babel/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/traverse": "^7.25.9",
|
||||
"@babel/types": "^7.25.9"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Babel helper functions for inserting module loads",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-helper-module-imports",
|
||||
"license": "MIT",
|
||||
"main": "./lib/index.js",
|
||||
"name": "@babel/helper-module-imports",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-helper-module-imports"
|
||||
},
|
||||
"type": "commonjs",
|
||||
"version": "7.25.9"
|
||||
}
|
22
node_modules/@babel/helper-module-transforms/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/helper-module-transforms/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
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.
|
19
node_modules/@babel/helper-module-transforms/README.md
generated
vendored
Normal file
19
node_modules/@babel/helper-module-transforms/README.md
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# @babel/helper-module-transforms
|
||||
|
||||
> Babel helper functions for implementing ES6 module transformations
|
||||
|
||||
See our website [@babel/helper-module-transforms](https://babeljs.io/docs/babel-helper-module-transforms) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save @babel/helper-module-transforms
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helper-module-transforms
|
||||
```
|
48
node_modules/@babel/helper-module-transforms/lib/dynamic-import.js
generated
vendored
Normal file
48
node_modules/@babel/helper-module-transforms/lib/dynamic-import.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildDynamicImport = buildDynamicImport;
|
||||
var _core = require("@babel/core");
|
||||
{
|
||||
exports.getDynamicImportSource = function getDynamicImportSource(node) {
|
||||
const [source] = node.arguments;
|
||||
return _core.types.isStringLiteral(source) || _core.types.isTemplateLiteral(source) ? source : _core.template.expression.ast`\`\${${source}}\``;
|
||||
};
|
||||
}
|
||||
function buildDynamicImport(node, deferToThen, wrapWithPromise, builder) {
|
||||
const specifier = _core.types.isCallExpression(node) ? node.arguments[0] : node.source;
|
||||
if (_core.types.isStringLiteral(specifier) || _core.types.isTemplateLiteral(specifier) && specifier.quasis.length === 0) {
|
||||
if (deferToThen) {
|
||||
return _core.template.expression.ast`
|
||||
Promise.resolve().then(() => ${builder(specifier)})
|
||||
`;
|
||||
} else return builder(specifier);
|
||||
}
|
||||
const specifierToString = _core.types.isTemplateLiteral(specifier) ? _core.types.identifier("specifier") : _core.types.templateLiteral([_core.types.templateElement({
|
||||
raw: ""
|
||||
}), _core.types.templateElement({
|
||||
raw: ""
|
||||
})], [_core.types.identifier("specifier")]);
|
||||
if (deferToThen) {
|
||||
return _core.template.expression.ast`
|
||||
(specifier =>
|
||||
new Promise(r => r(${specifierToString}))
|
||||
.then(s => ${builder(_core.types.identifier("s"))})
|
||||
)(${specifier})
|
||||
`;
|
||||
} else if (wrapWithPromise) {
|
||||
return _core.template.expression.ast`
|
||||
(specifier =>
|
||||
new Promise(r => r(${builder(specifierToString)}))
|
||||
)(${specifier})
|
||||
`;
|
||||
} else {
|
||||
return _core.template.expression.ast`
|
||||
(specifier => ${builder(specifierToString)})(${specifier})
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dynamic-import.js.map
|
1
node_modules/@babel/helper-module-transforms/lib/dynamic-import.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-transforms/lib/dynamic-import.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["_core","require","exports","getDynamicImportSource","node","source","arguments","t","isStringLiteral","isTemplateLiteral","template","expression","ast","buildDynamicImport","deferToThen","wrapWithPromise","builder","specifier","isCallExpression","quasis","length","specifierToString","identifier","templateLiteral","templateElement","raw"],"sources":["../src/dynamic-import.ts"],"sourcesContent":["// Heavily inspired by\n// https://github.com/airbnb/babel-plugin-dynamic-import-node/blob/master/src/utils.js\n\nimport { types as t, template } from \"@babel/core\";\n\nif (!process.env.BABEL_8_BREAKING && !USE_ESM && !IS_STANDALONE) {\n // eslint-disable-next-line no-restricted-globals\n exports.getDynamicImportSource = function getDynamicImportSource(\n node: t.CallExpression,\n ): t.StringLiteral | t.TemplateLiteral {\n const [source] = node.arguments;\n\n return t.isStringLiteral(source) || t.isTemplateLiteral(source)\n ? source\n : (template.expression.ast`\\`\\${${source}}\\`` as t.TemplateLiteral);\n };\n}\n\nexport function buildDynamicImport(\n node: t.CallExpression | t.ImportExpression,\n deferToThen: boolean,\n wrapWithPromise: boolean,\n builder: (specifier: t.Expression) => t.Expression,\n): t.Expression {\n const specifier = t.isCallExpression(node) ? node.arguments[0] : node.source;\n\n if (\n t.isStringLiteral(specifier) ||\n (t.isTemplateLiteral(specifier) && specifier.quasis.length === 0)\n ) {\n if (deferToThen) {\n return template.expression.ast`\n Promise.resolve().then(() => ${builder(specifier)})\n `;\n } else return builder(specifier);\n }\n\n const specifierToString = t.isTemplateLiteral(specifier)\n ? t.identifier(\"specifier\")\n : t.templateLiteral(\n [t.templateElement({ raw: \"\" }), t.templateElement({ raw: \"\" })],\n [t.identifier(\"specifier\")],\n );\n\n if (deferToThen) {\n return template.expression.ast`\n (specifier =>\n new Promise(r => r(${specifierToString}))\n .then(s => ${builder(t.identifier(\"s\"))})\n )(${specifier})\n `;\n } else if (wrapWithPromise) {\n return template.expression.ast`\n (specifier =>\n new Promise(r => r(${builder(specifierToString)}))\n )(${specifier})\n `;\n } else {\n return template.expression.ast`\n (specifier => ${builder(specifierToString)})(${specifier})\n `;\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAEiE;EAE/DC,OAAO,CAACC,sBAAsB,GAAG,SAASA,sBAAsBA,CAC9DC,IAAsB,EACe;IACrC,MAAM,CAACC,MAAM,CAAC,GAAGD,IAAI,CAACE,SAAS;IAE/B,OAAOC,WAAC,CAACC,eAAe,CAACH,MAAM,CAAC,IAAIE,WAAC,CAACE,iBAAiB,CAACJ,MAAM,CAAC,GAC3DA,MAAM,GACLK,cAAQ,CAACC,UAAU,CAACC,GAAG,QAAQP,MAAM,KAA2B;EACvE,CAAC;AACH;AAEO,SAASQ,kBAAkBA,CAChCT,IAA2C,EAC3CU,WAAoB,EACpBC,eAAwB,EACxBC,OAAkD,EACpC;EACd,MAAMC,SAAS,GAAGV,WAAC,CAACW,gBAAgB,CAACd,IAAI,CAAC,GAAGA,IAAI,CAACE,SAAS,CAAC,CAAC,CAAC,GAAGF,IAAI,CAACC,MAAM;EAE5E,IACEE,WAAC,CAACC,eAAe,CAACS,SAAS,CAAC,IAC3BV,WAAC,CAACE,iBAAiB,CAACQ,SAAS,CAAC,IAAIA,SAAS,CAACE,MAAM,CAACC,MAAM,KAAK,CAAE,EACjE;IACA,IAAIN,WAAW,EAAE;MACf,OAAOJ,cAAQ,CAACC,UAAU,CAACC,GAAG;AACpC,uCAAuCI,OAAO,CAACC,SAAS,CAAC;AACzD,OAAO;IACH,CAAC,MAAM,OAAOD,OAAO,CAACC,SAAS,CAAC;EAClC;EAEA,MAAMI,iBAAiB,GAAGd,WAAC,CAACE,iBAAiB,CAACQ,SAAS,CAAC,GACpDV,WAAC,CAACe,UAAU,CAAC,WAAW,CAAC,GACzBf,WAAC,CAACgB,eAAe,CACf,CAAChB,WAAC,CAACiB,eAAe,CAAC;IAAEC,GAAG,EAAE;EAAG,CAAC,CAAC,EAAElB,WAAC,CAACiB,eAAe,CAAC;IAAEC,GAAG,EAAE;EAAG,CAAC,CAAC,CAAC,EAChE,CAAClB,WAAC,CAACe,UAAU,CAAC,WAAW,CAAC,CAC5B,CAAC;EAEL,IAAIR,WAAW,EAAE;IACf,OAAOJ,cAAQ,CAACC,UAAU,CAACC,GAAG;AAClC;AACA,6BAA6BS,iBAAiB;AAC9C,uBAAuBL,OAAO,CAACT,WAAC,CAACe,UAAU,CAAC,GAAG,CAAC,CAAC;AACjD,UAAUL,SAAS;AACnB,KAAK;EACH,CAAC,MAAM,IAAIF,eAAe,EAAE;IAC1B,OAAOL,cAAQ,CAACC,UAAU,CAACC,GAAG;AAClC;AACA,6BAA6BI,OAAO,CAACK,iBAAiB,CAAC;AACvD,UAAUJ,SAAS;AACnB,KAAK;EACH,CAAC,MAAM;IACL,OAAOP,cAAQ,CAACC,UAAU,CAACC,GAAG;AAClC,sBAAsBI,OAAO,CAACK,iBAAiB,CAAC,KAAKJ,SAAS;AAC9D,KAAK;EACH;AACF","ignoreList":[]}
|
48
node_modules/@babel/helper-module-transforms/lib/get-module-name.js
generated
vendored
Normal file
48
node_modules/@babel/helper-module-transforms/lib/get-module-name.js
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = getModuleName;
|
||||
{
|
||||
const originalGetModuleName = getModuleName;
|
||||
exports.default = getModuleName = function getModuleName(rootOpts, pluginOpts) {
|
||||
var _pluginOpts$moduleId, _pluginOpts$moduleIds, _pluginOpts$getModule, _pluginOpts$moduleRoo;
|
||||
return originalGetModuleName(rootOpts, {
|
||||
moduleId: (_pluginOpts$moduleId = pluginOpts.moduleId) != null ? _pluginOpts$moduleId : rootOpts.moduleId,
|
||||
moduleIds: (_pluginOpts$moduleIds = pluginOpts.moduleIds) != null ? _pluginOpts$moduleIds : rootOpts.moduleIds,
|
||||
getModuleId: (_pluginOpts$getModule = pluginOpts.getModuleId) != null ? _pluginOpts$getModule : rootOpts.getModuleId,
|
||||
moduleRoot: (_pluginOpts$moduleRoo = pluginOpts.moduleRoot) != null ? _pluginOpts$moduleRoo : rootOpts.moduleRoot
|
||||
});
|
||||
};
|
||||
}
|
||||
function getModuleName(rootOpts, pluginOpts) {
|
||||
const {
|
||||
filename,
|
||||
filenameRelative = filename,
|
||||
sourceRoot = pluginOpts.moduleRoot
|
||||
} = rootOpts;
|
||||
const {
|
||||
moduleId,
|
||||
moduleIds = !!moduleId,
|
||||
getModuleId,
|
||||
moduleRoot = sourceRoot
|
||||
} = pluginOpts;
|
||||
if (!moduleIds) return null;
|
||||
if (moduleId != null && !getModuleId) {
|
||||
return moduleId;
|
||||
}
|
||||
let moduleName = moduleRoot != null ? moduleRoot + "/" : "";
|
||||
if (filenameRelative) {
|
||||
const sourceRootReplacer = sourceRoot != null ? new RegExp("^" + sourceRoot + "/?") : "";
|
||||
moduleName += filenameRelative.replace(sourceRootReplacer, "").replace(/\.\w*$/, "");
|
||||
}
|
||||
moduleName = moduleName.replace(/\\/g, "/");
|
||||
if (getModuleId) {
|
||||
return getModuleId(moduleName) || moduleName;
|
||||
} else {
|
||||
return moduleName;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-module-name.js.map
|
1
node_modules/@babel/helper-module-transforms/lib/get-module-name.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-transforms/lib/get-module-name.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["originalGetModuleName","getModuleName","exports","default","rootOpts","pluginOpts","_pluginOpts$moduleId","_pluginOpts$moduleIds","_pluginOpts$getModule","_pluginOpts$moduleRoo","moduleId","moduleIds","getModuleId","moduleRoot","filename","filenameRelative","sourceRoot","moduleName","sourceRootReplacer","RegExp","replace"],"sources":["../src/get-module-name.ts"],"sourcesContent":["type RootOptions = {\n filename?: string;\n filenameRelative?: string;\n sourceRoot?: string;\n};\n\nexport type PluginOptions = {\n moduleId?: string;\n moduleIds?: boolean;\n getModuleId?: (moduleName: string) => string | null | undefined;\n moduleRoot?: string;\n};\n\nif (!process.env.BABEL_8_BREAKING) {\n const originalGetModuleName = getModuleName;\n\n // @ts-expect-error TS doesn't like reassigning a function.\n getModuleName = function getModuleName(\n rootOpts: RootOptions & PluginOptions,\n pluginOpts: PluginOptions,\n ): string | null {\n return originalGetModuleName(rootOpts, {\n moduleId: pluginOpts.moduleId ?? rootOpts.moduleId,\n moduleIds: pluginOpts.moduleIds ?? rootOpts.moduleIds,\n getModuleId: pluginOpts.getModuleId ?? rootOpts.getModuleId,\n moduleRoot: pluginOpts.moduleRoot ?? rootOpts.moduleRoot,\n });\n };\n}\n\nexport default function getModuleName(\n rootOpts: RootOptions,\n pluginOpts: PluginOptions,\n): string | null {\n const {\n filename,\n filenameRelative = filename,\n sourceRoot = pluginOpts.moduleRoot,\n } = rootOpts;\n\n const {\n moduleId,\n moduleIds = !!moduleId,\n\n getModuleId,\n\n moduleRoot = sourceRoot,\n } = pluginOpts;\n\n if (!moduleIds) return null;\n\n // moduleId is n/a if a `getModuleId()` is provided\n if (moduleId != null && !getModuleId) {\n return moduleId;\n }\n\n let moduleName = moduleRoot != null ? moduleRoot + \"/\" : \"\";\n\n if (filenameRelative) {\n const sourceRootReplacer =\n sourceRoot != null ? new RegExp(\"^\" + sourceRoot + \"/?\") : \"\";\n\n moduleName += filenameRelative\n // remove sourceRoot from filename\n .replace(sourceRootReplacer, \"\")\n // remove extension\n .replace(/\\.\\w*$/, \"\");\n }\n\n // normalize path separators\n moduleName = moduleName.replace(/\\\\/g, \"/\");\n\n if (getModuleId) {\n // If return is falsy, assume they want us to use our generated default name\n return getModuleId(moduleName) || moduleName;\n } else {\n return moduleName;\n }\n}\n"],"mappings":";;;;;;AAamC;EACjC,MAAMA,qBAAqB,GAAGC,aAAa;EAG3CC,OAAA,CAAAC,OAAA,GAAAF,aAAa,GAAG,SAASA,aAAaA,CACpCG,QAAqC,EACrCC,UAAyB,EACV;IAAA,IAAAC,oBAAA,EAAAC,qBAAA,EAAAC,qBAAA,EAAAC,qBAAA;IACf,OAAOT,qBAAqB,CAACI,QAAQ,EAAE;MACrCM,QAAQ,GAAAJ,oBAAA,GAAED,UAAU,CAACK,QAAQ,YAAAJ,oBAAA,GAAIF,QAAQ,CAACM,QAAQ;MAClDC,SAAS,GAAAJ,qBAAA,GAAEF,UAAU,CAACM,SAAS,YAAAJ,qBAAA,GAAIH,QAAQ,CAACO,SAAS;MACrDC,WAAW,GAAAJ,qBAAA,GAAEH,UAAU,CAACO,WAAW,YAAAJ,qBAAA,GAAIJ,QAAQ,CAACQ,WAAW;MAC3DC,UAAU,GAAAJ,qBAAA,GAAEJ,UAAU,CAACQ,UAAU,YAAAJ,qBAAA,GAAIL,QAAQ,CAACS;IAChD,CAAC,CAAC;EACJ,CAAC;AACH;AAEe,SAASZ,aAAaA,CACnCG,QAAqB,EACrBC,UAAyB,EACV;EACf,MAAM;IACJS,QAAQ;IACRC,gBAAgB,GAAGD,QAAQ;IAC3BE,UAAU,GAAGX,UAAU,CAACQ;EAC1B,CAAC,GAAGT,QAAQ;EAEZ,MAAM;IACJM,QAAQ;IACRC,SAAS,GAAG,CAAC,CAACD,QAAQ;IAEtBE,WAAW;IAEXC,UAAU,GAAGG;EACf,CAAC,GAAGX,UAAU;EAEd,IAAI,CAACM,SAAS,EAAE,OAAO,IAAI;EAG3B,IAAID,QAAQ,IAAI,IAAI,IAAI,CAACE,WAAW,EAAE;IACpC,OAAOF,QAAQ;EACjB;EAEA,IAAIO,UAAU,GAAGJ,UAAU,IAAI,IAAI,GAAGA,UAAU,GAAG,GAAG,GAAG,EAAE;EAE3D,IAAIE,gBAAgB,EAAE;IACpB,MAAMG,kBAAkB,GACtBF,UAAU,IAAI,IAAI,GAAG,IAAIG,MAAM,CAAC,GAAG,GAAGH,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE;IAE/DC,UAAU,IAAIF,gBAAgB,CAE3BK,OAAO,CAACF,kBAAkB,EAAE,EAAE,CAAC,CAE/BE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;EAC1B;EAGAH,UAAU,GAAGA,UAAU,CAACG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;EAE3C,IAAIR,WAAW,EAAE;IAEf,OAAOA,WAAW,CAACK,UAAU,CAAC,IAAIA,UAAU;EAC9C,CAAC,MAAM;IACL,OAAOA,UAAU;EACnB;AACF","ignoreList":[]}
|
398
node_modules/@babel/helper-module-transforms/lib/index.js
generated
vendored
Normal file
398
node_modules/@babel/helper-module-transforms/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,398 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildDynamicImport", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _dynamicImport.buildDynamicImport;
|
||||
}
|
||||
});
|
||||
exports.buildNamespaceInitStatements = buildNamespaceInitStatements;
|
||||
exports.ensureStatementsHoisted = ensureStatementsHoisted;
|
||||
Object.defineProperty(exports, "getModuleName", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _getModuleName.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "hasExports", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _normalizeAndLoadMetadata.hasExports;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isModule", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _helperModuleImports.isModule;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "isSideEffectImport", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _normalizeAndLoadMetadata.isSideEffectImport;
|
||||
}
|
||||
});
|
||||
exports.rewriteModuleStatementsAndPrepareHeader = rewriteModuleStatementsAndPrepareHeader;
|
||||
Object.defineProperty(exports, "rewriteThis", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _rewriteThis.default;
|
||||
}
|
||||
});
|
||||
exports.wrapInterop = wrapInterop;
|
||||
var _assert = require("assert");
|
||||
var _core = require("@babel/core");
|
||||
var _helperModuleImports = require("@babel/helper-module-imports");
|
||||
var _rewriteThis = require("./rewrite-this.js");
|
||||
var _rewriteLiveReferences = require("./rewrite-live-references.js");
|
||||
var _normalizeAndLoadMetadata = require("./normalize-and-load-metadata.js");
|
||||
var Lazy = require("./lazy-modules.js");
|
||||
var _dynamicImport = require("./dynamic-import.js");
|
||||
var _getModuleName = require("./get-module-name.js");
|
||||
{
|
||||
exports.getDynamicImportSource = require("./dynamic-import").getDynamicImportSource;
|
||||
}
|
||||
function rewriteModuleStatementsAndPrepareHeader(path, {
|
||||
exportName,
|
||||
strict,
|
||||
allowTopLevelThis,
|
||||
strictMode,
|
||||
noInterop,
|
||||
importInterop = noInterop ? "none" : "babel",
|
||||
lazy,
|
||||
getWrapperPayload = Lazy.toGetWrapperPayload(lazy != null ? lazy : false),
|
||||
wrapReference = Lazy.wrapReference,
|
||||
esNamespaceOnly,
|
||||
filename,
|
||||
constantReexports = arguments[1].loose,
|
||||
enumerableModuleMeta = arguments[1].loose,
|
||||
noIncompleteNsImportDetection
|
||||
}) {
|
||||
(0, _normalizeAndLoadMetadata.validateImportInteropOption)(importInterop);
|
||||
_assert((0, _helperModuleImports.isModule)(path), "Cannot process module statements in a script");
|
||||
path.node.sourceType = "script";
|
||||
const meta = (0, _normalizeAndLoadMetadata.default)(path, exportName, {
|
||||
importInterop,
|
||||
initializeReexports: constantReexports,
|
||||
getWrapperPayload,
|
||||
esNamespaceOnly,
|
||||
filename
|
||||
});
|
||||
if (!allowTopLevelThis) {
|
||||
(0, _rewriteThis.default)(path);
|
||||
}
|
||||
(0, _rewriteLiveReferences.default)(path, meta, wrapReference);
|
||||
if (strictMode !== false) {
|
||||
const hasStrict = path.node.directives.some(directive => {
|
||||
return directive.value.value === "use strict";
|
||||
});
|
||||
if (!hasStrict) {
|
||||
path.unshiftContainer("directives", _core.types.directive(_core.types.directiveLiteral("use strict")));
|
||||
}
|
||||
}
|
||||
const headers = [];
|
||||
if ((0, _normalizeAndLoadMetadata.hasExports)(meta) && !strict) {
|
||||
headers.push(buildESModuleHeader(meta, enumerableModuleMeta));
|
||||
}
|
||||
const nameList = buildExportNameListDeclaration(path, meta);
|
||||
if (nameList) {
|
||||
meta.exportNameListName = nameList.name;
|
||||
headers.push(nameList.statement);
|
||||
}
|
||||
headers.push(...buildExportInitializationStatements(path, meta, wrapReference, constantReexports, noIncompleteNsImportDetection));
|
||||
return {
|
||||
meta,
|
||||
headers
|
||||
};
|
||||
}
|
||||
function ensureStatementsHoisted(statements) {
|
||||
statements.forEach(header => {
|
||||
header._blockHoist = 3;
|
||||
});
|
||||
}
|
||||
function wrapInterop(programPath, expr, type) {
|
||||
if (type === "none") {
|
||||
return null;
|
||||
}
|
||||
if (type === "node-namespace") {
|
||||
return _core.types.callExpression(programPath.hub.addHelper("interopRequireWildcard"), [expr, _core.types.booleanLiteral(true)]);
|
||||
} else if (type === "node-default") {
|
||||
return null;
|
||||
}
|
||||
let helper;
|
||||
if (type === "default") {
|
||||
helper = "interopRequireDefault";
|
||||
} else if (type === "namespace") {
|
||||
helper = "interopRequireWildcard";
|
||||
} else {
|
||||
throw new Error(`Unknown interop: ${type}`);
|
||||
}
|
||||
return _core.types.callExpression(programPath.hub.addHelper(helper), [expr]);
|
||||
}
|
||||
function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexports = false, wrapReference = Lazy.wrapReference) {
|
||||
var _wrapReference;
|
||||
const statements = [];
|
||||
const srcNamespaceId = _core.types.identifier(sourceMetadata.name);
|
||||
for (const localName of sourceMetadata.importsNamespace) {
|
||||
if (localName === sourceMetadata.name) continue;
|
||||
statements.push(_core.template.statement`var NAME = SOURCE;`({
|
||||
NAME: localName,
|
||||
SOURCE: _core.types.cloneNode(srcNamespaceId)
|
||||
}));
|
||||
}
|
||||
const srcNamespace = (_wrapReference = wrapReference(srcNamespaceId, sourceMetadata.wrap)) != null ? _wrapReference : srcNamespaceId;
|
||||
if (constantReexports) {
|
||||
statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, true, wrapReference));
|
||||
}
|
||||
for (const exportName of sourceMetadata.reexportNamespace) {
|
||||
statements.push((!_core.types.isIdentifier(srcNamespace) ? _core.template.statement`
|
||||
Object.defineProperty(EXPORTS, "NAME", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
});
|
||||
` : _core.template.statement`EXPORTS.NAME = NAMESPACE;`)({
|
||||
EXPORTS: metadata.exportName,
|
||||
NAME: exportName,
|
||||
NAMESPACE: _core.types.cloneNode(srcNamespace)
|
||||
}));
|
||||
}
|
||||
if (sourceMetadata.reexportAll) {
|
||||
const statement = buildNamespaceReexport(metadata, _core.types.cloneNode(srcNamespace), constantReexports);
|
||||
statement.loc = sourceMetadata.reexportAll.loc;
|
||||
statements.push(statement);
|
||||
}
|
||||
return statements;
|
||||
}
|
||||
const ReexportTemplate = {
|
||||
constant: ({
|
||||
exports,
|
||||
exportName,
|
||||
namespaceImport
|
||||
}) => _core.template.statement.ast`
|
||||
${exports}.${exportName} = ${namespaceImport};
|
||||
`,
|
||||
constantComputed: ({
|
||||
exports,
|
||||
exportName,
|
||||
namespaceImport
|
||||
}) => _core.template.statement.ast`
|
||||
${exports}["${exportName}"] = ${namespaceImport};
|
||||
`,
|
||||
spec: ({
|
||||
exports,
|
||||
exportName,
|
||||
namespaceImport
|
||||
}) => _core.template.statement.ast`
|
||||
Object.defineProperty(${exports}, "${exportName}", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return ${namespaceImport};
|
||||
},
|
||||
});
|
||||
`
|
||||
};
|
||||
function buildReexportsFromMeta(meta, metadata, constantReexports, wrapReference) {
|
||||
var _wrapReference2;
|
||||
let namespace = _core.types.identifier(metadata.name);
|
||||
namespace = (_wrapReference2 = wrapReference(namespace, metadata.wrap)) != null ? _wrapReference2 : namespace;
|
||||
const {
|
||||
stringSpecifiers
|
||||
} = meta;
|
||||
return Array.from(metadata.reexports, ([exportName, importName]) => {
|
||||
let namespaceImport = _core.types.cloneNode(namespace);
|
||||
if (importName === "default" && metadata.interop === "node-default") {} else if (stringSpecifiers.has(importName)) {
|
||||
namespaceImport = _core.types.memberExpression(namespaceImport, _core.types.stringLiteral(importName), true);
|
||||
} else {
|
||||
namespaceImport = _core.types.memberExpression(namespaceImport, _core.types.identifier(importName));
|
||||
}
|
||||
const astNodes = {
|
||||
exports: meta.exportName,
|
||||
exportName,
|
||||
namespaceImport
|
||||
};
|
||||
if (constantReexports || _core.types.isIdentifier(namespaceImport)) {
|
||||
if (stringSpecifiers.has(exportName)) {
|
||||
return ReexportTemplate.constantComputed(astNodes);
|
||||
} else {
|
||||
return ReexportTemplate.constant(astNodes);
|
||||
}
|
||||
} else {
|
||||
return ReexportTemplate.spec(astNodes);
|
||||
}
|
||||
});
|
||||
}
|
||||
function buildESModuleHeader(metadata, enumerableModuleMeta = false) {
|
||||
return (enumerableModuleMeta ? _core.template.statement`
|
||||
EXPORTS.__esModule = true;
|
||||
` : _core.template.statement`
|
||||
Object.defineProperty(EXPORTS, "__esModule", {
|
||||
value: true,
|
||||
});
|
||||
`)({
|
||||
EXPORTS: metadata.exportName
|
||||
});
|
||||
}
|
||||
function buildNamespaceReexport(metadata, namespace, constantReexports) {
|
||||
return (constantReexports ? _core.template.statement`
|
||||
Object.keys(NAMESPACE).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
VERIFY_NAME_LIST;
|
||||
if (key in EXPORTS && EXPORTS[key] === NAMESPACE[key]) return;
|
||||
|
||||
EXPORTS[key] = NAMESPACE[key];
|
||||
});
|
||||
` : _core.template.statement`
|
||||
Object.keys(NAMESPACE).forEach(function(key) {
|
||||
if (key === "default" || key === "__esModule") return;
|
||||
VERIFY_NAME_LIST;
|
||||
if (key in EXPORTS && EXPORTS[key] === NAMESPACE[key]) return;
|
||||
|
||||
Object.defineProperty(EXPORTS, key, {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return NAMESPACE[key];
|
||||
},
|
||||
});
|
||||
});
|
||||
`)({
|
||||
NAMESPACE: namespace,
|
||||
EXPORTS: metadata.exportName,
|
||||
VERIFY_NAME_LIST: metadata.exportNameListName ? (0, _core.template)`
|
||||
if (Object.prototype.hasOwnProperty.call(EXPORTS_LIST, key)) return;
|
||||
`({
|
||||
EXPORTS_LIST: metadata.exportNameListName
|
||||
}) : null
|
||||
});
|
||||
}
|
||||
function buildExportNameListDeclaration(programPath, metadata) {
|
||||
const exportedVars = Object.create(null);
|
||||
for (const data of metadata.local.values()) {
|
||||
for (const name of data.names) {
|
||||
exportedVars[name] = true;
|
||||
}
|
||||
}
|
||||
let hasReexport = false;
|
||||
for (const data of metadata.source.values()) {
|
||||
for (const exportName of data.reexports.keys()) {
|
||||
exportedVars[exportName] = true;
|
||||
}
|
||||
for (const exportName of data.reexportNamespace) {
|
||||
exportedVars[exportName] = true;
|
||||
}
|
||||
hasReexport = hasReexport || !!data.reexportAll;
|
||||
}
|
||||
if (!hasReexport || Object.keys(exportedVars).length === 0) return null;
|
||||
const name = programPath.scope.generateUidIdentifier("exportNames");
|
||||
delete exportedVars.default;
|
||||
return {
|
||||
name: name.name,
|
||||
statement: _core.types.variableDeclaration("var", [_core.types.variableDeclarator(name, _core.types.valueToNode(exportedVars))])
|
||||
};
|
||||
}
|
||||
function buildExportInitializationStatements(programPath, metadata, wrapReference, constantReexports = false, noIncompleteNsImportDetection = false) {
|
||||
const initStatements = [];
|
||||
for (const [localName, data] of metadata.local) {
|
||||
if (data.kind === "import") {} else if (data.kind === "hoisted") {
|
||||
initStatements.push([data.names[0], buildInitStatement(metadata, data.names, _core.types.identifier(localName))]);
|
||||
} else if (!noIncompleteNsImportDetection) {
|
||||
for (const exportName of data.names) {
|
||||
initStatements.push([exportName, null]);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const data of metadata.source.values()) {
|
||||
if (!constantReexports) {
|
||||
const reexportsStatements = buildReexportsFromMeta(metadata, data, false, wrapReference);
|
||||
const reexports = [...data.reexports.keys()];
|
||||
for (let i = 0; i < reexportsStatements.length; i++) {
|
||||
initStatements.push([reexports[i], reexportsStatements[i]]);
|
||||
}
|
||||
}
|
||||
if (!noIncompleteNsImportDetection) {
|
||||
for (const exportName of data.reexportNamespace) {
|
||||
initStatements.push([exportName, null]);
|
||||
}
|
||||
}
|
||||
}
|
||||
initStatements.sort(([a], [b]) => {
|
||||
if (a < b) return -1;
|
||||
if (b < a) return 1;
|
||||
return 0;
|
||||
});
|
||||
const results = [];
|
||||
if (noIncompleteNsImportDetection) {
|
||||
for (const [, initStatement] of initStatements) {
|
||||
results.push(initStatement);
|
||||
}
|
||||
} else {
|
||||
const chunkSize = 100;
|
||||
for (let i = 0; i < initStatements.length; i += chunkSize) {
|
||||
let uninitializedExportNames = [];
|
||||
for (let j = 0; j < chunkSize && i + j < initStatements.length; j++) {
|
||||
const [exportName, initStatement] = initStatements[i + j];
|
||||
if (initStatement !== null) {
|
||||
if (uninitializedExportNames.length > 0) {
|
||||
results.push(buildInitStatement(metadata, uninitializedExportNames, programPath.scope.buildUndefinedNode()));
|
||||
uninitializedExportNames = [];
|
||||
}
|
||||
results.push(initStatement);
|
||||
} else {
|
||||
uninitializedExportNames.push(exportName);
|
||||
}
|
||||
}
|
||||
if (uninitializedExportNames.length > 0) {
|
||||
results.push(buildInitStatement(metadata, uninitializedExportNames, programPath.scope.buildUndefinedNode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
const InitTemplate = {
|
||||
computed: ({
|
||||
exports,
|
||||
name,
|
||||
value
|
||||
}) => _core.template.expression.ast`${exports}["${name}"] = ${value}`,
|
||||
default: ({
|
||||
exports,
|
||||
name,
|
||||
value
|
||||
}) => _core.template.expression.ast`${exports}.${name} = ${value}`,
|
||||
define: ({
|
||||
exports,
|
||||
name,
|
||||
value
|
||||
}) => _core.template.expression.ast`
|
||||
Object.defineProperty(${exports}, "${name}", {
|
||||
enumerable: true,
|
||||
value: void 0,
|
||||
writable: true
|
||||
})["${name}"] = ${value}`
|
||||
};
|
||||
function buildInitStatement(metadata, exportNames, initExpr) {
|
||||
const {
|
||||
stringSpecifiers,
|
||||
exportName: exports
|
||||
} = metadata;
|
||||
return _core.types.expressionStatement(exportNames.reduce((value, name) => {
|
||||
const params = {
|
||||
exports,
|
||||
name,
|
||||
value
|
||||
};
|
||||
if (name === "__proto__") {
|
||||
return InitTemplate.define(params);
|
||||
}
|
||||
if (stringSpecifiers.has(name)) {
|
||||
return InitTemplate.computed(params);
|
||||
}
|
||||
return InitTemplate.default(params);
|
||||
}, initExpr));
|
||||
}
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@babel/helper-module-transforms/lib/index.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-transforms/lib/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
31
node_modules/@babel/helper-module-transforms/lib/lazy-modules.js
generated
vendored
Normal file
31
node_modules/@babel/helper-module-transforms/lib/lazy-modules.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.toGetWrapperPayload = toGetWrapperPayload;
|
||||
exports.wrapReference = wrapReference;
|
||||
var _core = require("@babel/core");
|
||||
var _normalizeAndLoadMetadata = require("./normalize-and-load-metadata.js");
|
||||
function toGetWrapperPayload(lazy) {
|
||||
return (source, metadata) => {
|
||||
if (lazy === false) return null;
|
||||
if ((0, _normalizeAndLoadMetadata.isSideEffectImport)(metadata) || metadata.reexportAll) return null;
|
||||
if (lazy === true) {
|
||||
return source.includes(".") ? null : "lazy";
|
||||
}
|
||||
if (Array.isArray(lazy)) {
|
||||
return !lazy.includes(source) ? null : "lazy";
|
||||
}
|
||||
if (typeof lazy === "function") {
|
||||
return lazy(source) ? "lazy" : null;
|
||||
}
|
||||
throw new Error(`.lazy must be a boolean, string array, or function`);
|
||||
};
|
||||
}
|
||||
function wrapReference(ref, payload) {
|
||||
if (payload === "lazy") return _core.types.callExpression(ref, []);
|
||||
return null;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=lazy-modules.js.map
|
1
node_modules/@babel/helper-module-transforms/lib/lazy-modules.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-transforms/lib/lazy-modules.js.map
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["_core","require","_normalizeAndLoadMetadata","toGetWrapperPayload","lazy","source","metadata","isSideEffectImport","reexportAll","includes","Array","isArray","Error","wrapReference","ref","payload","t","callExpression"],"sources":["../src/lazy-modules.ts"],"sourcesContent":["// TODO: Move `lazy` implementation logic into the CommonJS plugin, since other\n// modules systems do not support `lazy`.\n\nimport { types as t } from \"@babel/core\";\nimport {\n type SourceModuleMetadata,\n isSideEffectImport,\n} from \"./normalize-and-load-metadata.ts\";\n\nexport type Lazy = boolean | string[] | ((source: string) => boolean);\n\nexport function toGetWrapperPayload(lazy: Lazy) {\n return (source: string, metadata: SourceModuleMetadata): null | \"lazy\" => {\n if (lazy === false) return null;\n if (isSideEffectImport(metadata) || metadata.reexportAll) return null;\n if (lazy === true) {\n // 'true' means that local relative files are eagerly loaded and\n // dependency modules are loaded lazily.\n return source.includes(\".\") ? null : \"lazy\";\n }\n if (Array.isArray(lazy)) {\n return !lazy.includes(source) ? null : \"lazy\";\n }\n if (typeof lazy === \"function\") {\n return lazy(source) ? \"lazy\" : null;\n }\n throw new Error(`.lazy must be a boolean, string array, or function`);\n };\n}\n\nexport function wrapReference(\n ref: t.Identifier,\n payload: unknown,\n): t.Expression | null {\n if (payload === \"lazy\") return t.callExpression(ref, []);\n return null;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAD,OAAA;AAOO,SAASE,mBAAmBA,CAACC,IAAU,EAAE;EAC9C,OAAO,CAACC,MAAc,EAAEC,QAA8B,KAAoB;IACxE,IAAIF,IAAI,KAAK,KAAK,EAAE,OAAO,IAAI;IAC/B,IAAI,IAAAG,4CAAkB,EAACD,QAAQ,CAAC,IAAIA,QAAQ,CAACE,WAAW,EAAE,OAAO,IAAI;IACrE,IAAIJ,IAAI,KAAK,IAAI,EAAE;MAGjB,OAAOC,MAAM,CAACI,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,MAAM;IAC7C;IACA,IAAIC,KAAK,CAACC,OAAO,CAACP,IAAI,CAAC,EAAE;MACvB,OAAO,CAACA,IAAI,CAACK,QAAQ,CAACJ,MAAM,CAAC,GAAG,IAAI,GAAG,MAAM;IAC/C;IACA,IAAI,OAAOD,IAAI,KAAK,UAAU,EAAE;MAC9B,OAAOA,IAAI,CAACC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI;IACrC;IACA,MAAM,IAAIO,KAAK,CAAC,oDAAoD,CAAC;EACvE,CAAC;AACH;AAEO,SAASC,aAAaA,CAC3BC,GAAiB,EACjBC,OAAgB,EACK;EACrB,IAAIA,OAAO,KAAK,MAAM,EAAE,OAAOC,WAAC,CAACC,cAAc,CAACH,GAAG,EAAE,EAAE,CAAC;EACxD,OAAO,IAAI;AACb","ignoreList":[]}
|
361
node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js
generated
vendored
Normal file
361
node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js
generated
vendored
Normal file
|
@ -0,0 +1,361 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = normalizeModuleAndLoadMetadata;
|
||||
exports.hasExports = hasExports;
|
||||
exports.isSideEffectImport = isSideEffectImport;
|
||||
exports.validateImportInteropOption = validateImportInteropOption;
|
||||
var _path = require("path");
|
||||
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
|
||||
function hasExports(metadata) {
|
||||
return metadata.hasExports;
|
||||
}
|
||||
function isSideEffectImport(source) {
|
||||
return source.imports.size === 0 && source.importsNamespace.size === 0 && source.reexports.size === 0 && source.reexportNamespace.size === 0 && !source.reexportAll;
|
||||
}
|
||||
function validateImportInteropOption(importInterop) {
|
||||
if (typeof importInterop !== "function" && importInterop !== "none" && importInterop !== "babel" && importInterop !== "node") {
|
||||
throw new Error(`.importInterop must be one of "none", "babel", "node", or a function returning one of those values (received ${importInterop}).`);
|
||||
}
|
||||
return importInterop;
|
||||
}
|
||||
function resolveImportInterop(importInterop, source, filename) {
|
||||
if (typeof importInterop === "function") {
|
||||
return validateImportInteropOption(importInterop(source, filename));
|
||||
}
|
||||
return importInterop;
|
||||
}
|
||||
function normalizeModuleAndLoadMetadata(programPath, exportName, {
|
||||
importInterop,
|
||||
initializeReexports = false,
|
||||
getWrapperPayload,
|
||||
esNamespaceOnly = false,
|
||||
filename
|
||||
}) {
|
||||
if (!exportName) {
|
||||
exportName = programPath.scope.generateUidIdentifier("exports").name;
|
||||
}
|
||||
const stringSpecifiers = new Set();
|
||||
nameAnonymousExports(programPath);
|
||||
const {
|
||||
local,
|
||||
sources,
|
||||
hasExports
|
||||
} = getModuleMetadata(programPath, {
|
||||
initializeReexports,
|
||||
getWrapperPayload
|
||||
}, stringSpecifiers);
|
||||
removeImportExportDeclarations(programPath);
|
||||
for (const [source, metadata] of sources) {
|
||||
const {
|
||||
importsNamespace,
|
||||
imports
|
||||
} = metadata;
|
||||
if (importsNamespace.size > 0 && imports.size === 0) {
|
||||
const [nameOfnamespace] = importsNamespace;
|
||||
metadata.name = nameOfnamespace;
|
||||
}
|
||||
const resolvedInterop = resolveImportInterop(importInterop, source, filename);
|
||||
if (resolvedInterop === "none") {
|
||||
metadata.interop = "none";
|
||||
} else if (resolvedInterop === "node" && metadata.interop === "namespace") {
|
||||
metadata.interop = "node-namespace";
|
||||
} else if (resolvedInterop === "node" && metadata.interop === "default") {
|
||||
metadata.interop = "node-default";
|
||||
} else if (esNamespaceOnly && metadata.interop === "namespace") {
|
||||
metadata.interop = "default";
|
||||
}
|
||||
}
|
||||
return {
|
||||
exportName,
|
||||
exportNameListName: null,
|
||||
hasExports,
|
||||
local,
|
||||
source: sources,
|
||||
stringSpecifiers
|
||||
};
|
||||
}
|
||||
function getExportSpecifierName(path, stringSpecifiers) {
|
||||
if (path.isIdentifier()) {
|
||||
return path.node.name;
|
||||
} else if (path.isStringLiteral()) {
|
||||
const stringValue = path.node.value;
|
||||
if (!(0, _helperValidatorIdentifier.isIdentifierName)(stringValue)) {
|
||||
stringSpecifiers.add(stringValue);
|
||||
}
|
||||
return stringValue;
|
||||
} else {
|
||||
throw new Error(`Expected export specifier to be either Identifier or StringLiteral, got ${path.node.type}`);
|
||||
}
|
||||
}
|
||||
function assertExportSpecifier(path) {
|
||||
if (path.isExportSpecifier()) {
|
||||
return;
|
||||
} else if (path.isExportNamespaceSpecifier()) {
|
||||
throw path.buildCodeFrameError("Export namespace should be first transformed by `@babel/plugin-transform-export-namespace-from`.");
|
||||
} else {
|
||||
throw path.buildCodeFrameError("Unexpected export specifier type");
|
||||
}
|
||||
}
|
||||
function getModuleMetadata(programPath, {
|
||||
getWrapperPayload,
|
||||
initializeReexports
|
||||
}, stringSpecifiers) {
|
||||
const localData = getLocalExportMetadata(programPath, initializeReexports, stringSpecifiers);
|
||||
const importNodes = new Map();
|
||||
const sourceData = new Map();
|
||||
const getData = (sourceNode, node) => {
|
||||
const source = sourceNode.value;
|
||||
let data = sourceData.get(source);
|
||||
if (!data) {
|
||||
data = {
|
||||
name: programPath.scope.generateUidIdentifier((0, _path.basename)(source, (0, _path.extname)(source))).name,
|
||||
interop: "none",
|
||||
loc: null,
|
||||
imports: new Map(),
|
||||
importsNamespace: new Set(),
|
||||
reexports: new Map(),
|
||||
reexportNamespace: new Set(),
|
||||
reexportAll: null,
|
||||
wrap: null,
|
||||
get lazy() {
|
||||
return this.wrap === "lazy";
|
||||
},
|
||||
referenced: false
|
||||
};
|
||||
sourceData.set(source, data);
|
||||
importNodes.set(source, [node]);
|
||||
} else {
|
||||
importNodes.get(source).push(node);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
let hasExports = false;
|
||||
programPath.get("body").forEach(child => {
|
||||
if (child.isImportDeclaration()) {
|
||||
const data = getData(child.node.source, child.node);
|
||||
if (!data.loc) data.loc = child.node.loc;
|
||||
child.get("specifiers").forEach(spec => {
|
||||
if (spec.isImportDefaultSpecifier()) {
|
||||
const localName = spec.get("local").node.name;
|
||||
data.imports.set(localName, "default");
|
||||
const reexport = localData.get(localName);
|
||||
if (reexport) {
|
||||
localData.delete(localName);
|
||||
reexport.names.forEach(name => {
|
||||
data.reexports.set(name, "default");
|
||||
});
|
||||
data.referenced = true;
|
||||
}
|
||||
} else if (spec.isImportNamespaceSpecifier()) {
|
||||
const localName = spec.get("local").node.name;
|
||||
data.importsNamespace.add(localName);
|
||||
const reexport = localData.get(localName);
|
||||
if (reexport) {
|
||||
localData.delete(localName);
|
||||
reexport.names.forEach(name => {
|
||||
data.reexportNamespace.add(name);
|
||||
});
|
||||
data.referenced = true;
|
||||
}
|
||||
} else if (spec.isImportSpecifier()) {
|
||||
const importName = getExportSpecifierName(spec.get("imported"), stringSpecifiers);
|
||||
const localName = spec.get("local").node.name;
|
||||
data.imports.set(localName, importName);
|
||||
const reexport = localData.get(localName);
|
||||
if (reexport) {
|
||||
localData.delete(localName);
|
||||
reexport.names.forEach(name => {
|
||||
data.reexports.set(name, importName);
|
||||
});
|
||||
data.referenced = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (child.isExportAllDeclaration()) {
|
||||
hasExports = true;
|
||||
const data = getData(child.node.source, child.node);
|
||||
if (!data.loc) data.loc = child.node.loc;
|
||||
data.reexportAll = {
|
||||
loc: child.node.loc
|
||||
};
|
||||
data.referenced = true;
|
||||
} else if (child.isExportNamedDeclaration() && child.node.source) {
|
||||
hasExports = true;
|
||||
const data = getData(child.node.source, child.node);
|
||||
if (!data.loc) data.loc = child.node.loc;
|
||||
child.get("specifiers").forEach(spec => {
|
||||
assertExportSpecifier(spec);
|
||||
const importName = getExportSpecifierName(spec.get("local"), stringSpecifiers);
|
||||
const exportName = getExportSpecifierName(spec.get("exported"), stringSpecifiers);
|
||||
data.reexports.set(exportName, importName);
|
||||
data.referenced = true;
|
||||
if (exportName === "__esModule") {
|
||||
throw spec.get("exported").buildCodeFrameError('Illegal export "__esModule".');
|
||||
}
|
||||
});
|
||||
} else if (child.isExportNamedDeclaration() || child.isExportDefaultDeclaration()) {
|
||||
hasExports = true;
|
||||
}
|
||||
});
|
||||
for (const metadata of sourceData.values()) {
|
||||
let needsDefault = false;
|
||||
let needsNamed = false;
|
||||
if (metadata.importsNamespace.size > 0) {
|
||||
needsDefault = true;
|
||||
needsNamed = true;
|
||||
}
|
||||
if (metadata.reexportAll) {
|
||||
needsNamed = true;
|
||||
}
|
||||
for (const importName of metadata.imports.values()) {
|
||||
if (importName === "default") needsDefault = true;else needsNamed = true;
|
||||
}
|
||||
for (const importName of metadata.reexports.values()) {
|
||||
if (importName === "default") needsDefault = true;else needsNamed = true;
|
||||
}
|
||||
if (needsDefault && needsNamed) {
|
||||
metadata.interop = "namespace";
|
||||
} else if (needsDefault) {
|
||||
metadata.interop = "default";
|
||||
}
|
||||
}
|
||||
if (getWrapperPayload) {
|
||||
for (const [source, metadata] of sourceData) {
|
||||
metadata.wrap = getWrapperPayload(source, metadata, importNodes.get(source));
|
||||
}
|
||||
}
|
||||
return {
|
||||
hasExports,
|
||||
local: localData,
|
||||
sources: sourceData
|
||||
};
|
||||
}
|
||||
function getLocalExportMetadata(programPath, initializeReexports, stringSpecifiers) {
|
||||
const bindingKindLookup = new Map();
|
||||
programPath.get("body").forEach(child => {
|
||||
let kind;
|
||||
if (child.isImportDeclaration()) {
|
||||
kind = "import";
|
||||
} else {
|
||||
if (child.isExportDefaultDeclaration()) {
|
||||
child = child.get("declaration");
|
||||
}
|
||||
if (child.isExportNamedDeclaration()) {
|
||||
if (child.node.declaration) {
|
||||
child = child.get("declaration");
|
||||
} else if (initializeReexports && child.node.source && child.get("source").isStringLiteral()) {
|
||||
child.get("specifiers").forEach(spec => {
|
||||
assertExportSpecifier(spec);
|
||||
bindingKindLookup.set(spec.get("local").node.name, "block");
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (child.isFunctionDeclaration()) {
|
||||
kind = "hoisted";
|
||||
} else if (child.isClassDeclaration()) {
|
||||
kind = "block";
|
||||
} else if (child.isVariableDeclaration({
|
||||
kind: "var"
|
||||
})) {
|
||||
kind = "var";
|
||||
} else if (child.isVariableDeclaration()) {
|
||||
kind = "block";
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Object.keys(child.getOuterBindingIdentifiers()).forEach(name => {
|
||||
bindingKindLookup.set(name, kind);
|
||||
});
|
||||
});
|
||||
const localMetadata = new Map();
|
||||
const getLocalMetadata = idPath => {
|
||||
const localName = idPath.node.name;
|
||||
let metadata = localMetadata.get(localName);
|
||||
if (!metadata) {
|
||||
const kind = bindingKindLookup.get(localName);
|
||||
if (kind === undefined) {
|
||||
throw idPath.buildCodeFrameError(`Exporting local "${localName}", which is not declared.`);
|
||||
}
|
||||
metadata = {
|
||||
names: [],
|
||||
kind
|
||||
};
|
||||
localMetadata.set(localName, metadata);
|
||||
}
|
||||
return metadata;
|
||||
};
|
||||
programPath.get("body").forEach(child => {
|
||||
if (child.isExportNamedDeclaration() && (initializeReexports || !child.node.source)) {
|
||||
if (child.node.declaration) {
|
||||
const declaration = child.get("declaration");
|
||||
const ids = declaration.getOuterBindingIdentifierPaths();
|
||||
Object.keys(ids).forEach(name => {
|
||||
if (name === "__esModule") {
|
||||
throw declaration.buildCodeFrameError('Illegal export "__esModule".');
|
||||
}
|
||||
getLocalMetadata(ids[name]).names.push(name);
|
||||
});
|
||||
} else {
|
||||
child.get("specifiers").forEach(spec => {
|
||||
const local = spec.get("local");
|
||||
const exported = spec.get("exported");
|
||||
const localMetadata = getLocalMetadata(local);
|
||||
const exportName = getExportSpecifierName(exported, stringSpecifiers);
|
||||
if (exportName === "__esModule") {
|
||||
throw exported.buildCodeFrameError('Illegal export "__esModule".');
|
||||
}
|
||||
localMetadata.names.push(exportName);
|
||||
});
|
||||
}
|
||||
} else if (child.isExportDefaultDeclaration()) {
|
||||
const declaration = child.get("declaration");
|
||||
if (declaration.isFunctionDeclaration() || declaration.isClassDeclaration()) {
|
||||
getLocalMetadata(declaration.get("id")).names.push("default");
|
||||
} else {
|
||||
throw declaration.buildCodeFrameError("Unexpected default expression export.");
|
||||
}
|
||||
}
|
||||
});
|
||||
return localMetadata;
|
||||
}
|
||||
function nameAnonymousExports(programPath) {
|
||||
programPath.get("body").forEach(child => {
|
||||
if (!child.isExportDefaultDeclaration()) return;
|
||||
{
|
||||
var _child$splitExportDec;
|
||||
(_child$splitExportDec = child.splitExportDeclaration) != null ? _child$splitExportDec : child.splitExportDeclaration = require("@babel/traverse").NodePath.prototype.splitExportDeclaration;
|
||||
}
|
||||
child.splitExportDeclaration();
|
||||
});
|
||||
}
|
||||
function removeImportExportDeclarations(programPath) {
|
||||
programPath.get("body").forEach(child => {
|
||||
if (child.isImportDeclaration()) {
|
||||
child.remove();
|
||||
} else if (child.isExportNamedDeclaration()) {
|
||||
if (child.node.declaration) {
|
||||
child.node.declaration._blockHoist = child.node._blockHoist;
|
||||
child.replaceWith(child.node.declaration);
|
||||
} else {
|
||||
child.remove();
|
||||
}
|
||||
} else if (child.isExportDefaultDeclaration()) {
|
||||
const declaration = child.get("declaration");
|
||||
if (declaration.isFunctionDeclaration() || declaration.isClassDeclaration()) {
|
||||
declaration._blockHoist = child.node._blockHoist;
|
||||
child.replaceWith(declaration);
|
||||
} else {
|
||||
throw declaration.buildCodeFrameError("Unexpected default expression export.");
|
||||
}
|
||||
} else if (child.isExportAllDeclaration()) {
|
||||
child.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=normalize-and-load-metadata.js.map
|
1
node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-transforms/lib/normalize-and-load-metadata.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
360
node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js
generated
vendored
Normal file
360
node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js
generated
vendored
Normal file
|
@ -0,0 +1,360 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = rewriteLiveReferences;
|
||||
var _core = require("@babel/core");
|
||||
function isInType(path) {
|
||||
do {
|
||||
switch (path.parent.type) {
|
||||
case "TSTypeAnnotation":
|
||||
case "TSTypeAliasDeclaration":
|
||||
case "TSTypeReference":
|
||||
case "TypeAnnotation":
|
||||
case "TypeAlias":
|
||||
return true;
|
||||
case "ExportSpecifier":
|
||||
return path.parentPath.parent.exportKind === "type";
|
||||
default:
|
||||
if (path.parentPath.isStatement() || path.parentPath.isExpression()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} while (path = path.parentPath);
|
||||
}
|
||||
function rewriteLiveReferences(programPath, metadata, wrapReference) {
|
||||
const imported = new Map();
|
||||
const exported = new Map();
|
||||
const requeueInParent = path => {
|
||||
programPath.requeue(path);
|
||||
};
|
||||
for (const [source, data] of metadata.source) {
|
||||
for (const [localName, importName] of data.imports) {
|
||||
imported.set(localName, [source, importName, null]);
|
||||
}
|
||||
for (const localName of data.importsNamespace) {
|
||||
imported.set(localName, [source, null, localName]);
|
||||
}
|
||||
}
|
||||
for (const [local, data] of metadata.local) {
|
||||
let exportMeta = exported.get(local);
|
||||
if (!exportMeta) {
|
||||
exportMeta = [];
|
||||
exported.set(local, exportMeta);
|
||||
}
|
||||
exportMeta.push(...data.names);
|
||||
}
|
||||
const rewriteBindingInitVisitorState = {
|
||||
metadata,
|
||||
requeueInParent,
|
||||
scope: programPath.scope,
|
||||
exported
|
||||
};
|
||||
programPath.traverse(rewriteBindingInitVisitor, rewriteBindingInitVisitorState);
|
||||
const rewriteReferencesVisitorState = {
|
||||
seen: new WeakSet(),
|
||||
metadata,
|
||||
requeueInParent,
|
||||
scope: programPath.scope,
|
||||
imported,
|
||||
exported,
|
||||
buildImportReference([source, importName, localName], identNode) {
|
||||
const meta = metadata.source.get(source);
|
||||
meta.referenced = true;
|
||||
if (localName) {
|
||||
if (meta.wrap) {
|
||||
var _wrapReference;
|
||||
identNode = (_wrapReference = wrapReference(identNode, meta.wrap)) != null ? _wrapReference : identNode;
|
||||
}
|
||||
return identNode;
|
||||
}
|
||||
let namespace = _core.types.identifier(meta.name);
|
||||
if (meta.wrap) {
|
||||
var _wrapReference2;
|
||||
namespace = (_wrapReference2 = wrapReference(namespace, meta.wrap)) != null ? _wrapReference2 : namespace;
|
||||
}
|
||||
if (importName === "default" && meta.interop === "node-default") {
|
||||
return namespace;
|
||||
}
|
||||
const computed = metadata.stringSpecifiers.has(importName);
|
||||
return _core.types.memberExpression(namespace, computed ? _core.types.stringLiteral(importName) : _core.types.identifier(importName), computed);
|
||||
}
|
||||
};
|
||||
programPath.traverse(rewriteReferencesVisitor, rewriteReferencesVisitorState);
|
||||
}
|
||||
const rewriteBindingInitVisitor = {
|
||||
Scope(path) {
|
||||
path.skip();
|
||||
},
|
||||
ClassDeclaration(path) {
|
||||
const {
|
||||
requeueInParent,
|
||||
exported,
|
||||
metadata
|
||||
} = this;
|
||||
const {
|
||||
id
|
||||
} = path.node;
|
||||
if (!id) throw new Error("Expected class to have a name");
|
||||
const localName = id.name;
|
||||
const exportNames = exported.get(localName) || [];
|
||||
if (exportNames.length > 0) {
|
||||
const statement = _core.types.expressionStatement(buildBindingExportAssignmentExpression(metadata, exportNames, _core.types.identifier(localName), path.scope));
|
||||
statement._blockHoist = path.node._blockHoist;
|
||||
requeueInParent(path.insertAfter(statement)[0]);
|
||||
}
|
||||
},
|
||||
VariableDeclaration(path) {
|
||||
const {
|
||||
requeueInParent,
|
||||
exported,
|
||||
metadata
|
||||
} = this;
|
||||
const isVar = path.node.kind === "var";
|
||||
for (const decl of path.get("declarations")) {
|
||||
const {
|
||||
id
|
||||
} = decl.node;
|
||||
let {
|
||||
init
|
||||
} = decl.node;
|
||||
if (_core.types.isIdentifier(id) && exported.has(id.name) && !_core.types.isArrowFunctionExpression(init) && (!_core.types.isFunctionExpression(init) || init.id) && (!_core.types.isClassExpression(init) || init.id)) {
|
||||
if (!init) {
|
||||
if (isVar) {
|
||||
continue;
|
||||
} else {
|
||||
init = path.scope.buildUndefinedNode();
|
||||
}
|
||||
}
|
||||
decl.node.init = buildBindingExportAssignmentExpression(metadata, exported.get(id.name), init, path.scope);
|
||||
requeueInParent(decl.get("init"));
|
||||
} else {
|
||||
for (const localName of Object.keys(decl.getOuterBindingIdentifiers())) {
|
||||
if (exported.has(localName)) {
|
||||
const statement = _core.types.expressionStatement(buildBindingExportAssignmentExpression(metadata, exported.get(localName), _core.types.identifier(localName), path.scope));
|
||||
statement._blockHoist = path.node._blockHoist;
|
||||
requeueInParent(path.insertAfter(statement)[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const buildBindingExportAssignmentExpression = (metadata, exportNames, localExpr, scope) => {
|
||||
const exportsObjectName = metadata.exportName;
|
||||
for (let currentScope = scope; currentScope != null; currentScope = currentScope.parent) {
|
||||
if (currentScope.hasOwnBinding(exportsObjectName)) {
|
||||
currentScope.rename(exportsObjectName);
|
||||
}
|
||||
}
|
||||
return (exportNames || []).reduce((expr, exportName) => {
|
||||
const {
|
||||
stringSpecifiers
|
||||
} = metadata;
|
||||
const computed = stringSpecifiers.has(exportName);
|
||||
return _core.types.assignmentExpression("=", _core.types.memberExpression(_core.types.identifier(exportsObjectName), computed ? _core.types.stringLiteral(exportName) : _core.types.identifier(exportName), computed), expr);
|
||||
}, localExpr);
|
||||
};
|
||||
const buildImportThrow = localName => {
|
||||
return _core.template.expression.ast`
|
||||
(function() {
|
||||
throw new Error('"' + '${localName}' + '" is read-only.');
|
||||
})()
|
||||
`;
|
||||
};
|
||||
const rewriteReferencesVisitor = {
|
||||
ReferencedIdentifier(path) {
|
||||
const {
|
||||
seen,
|
||||
buildImportReference,
|
||||
scope,
|
||||
imported,
|
||||
requeueInParent
|
||||
} = this;
|
||||
if (seen.has(path.node)) return;
|
||||
seen.add(path.node);
|
||||
const localName = path.node.name;
|
||||
const importData = imported.get(localName);
|
||||
if (importData) {
|
||||
if (isInType(path)) {
|
||||
throw path.buildCodeFrameError(`Cannot transform the imported binding "${localName}" since it's also used in a type annotation. ` + `Please strip type annotations using @babel/preset-typescript or @babel/preset-flow.`);
|
||||
}
|
||||
const localBinding = path.scope.getBinding(localName);
|
||||
const rootBinding = scope.getBinding(localName);
|
||||
if (rootBinding !== localBinding) return;
|
||||
const ref = buildImportReference(importData, path.node);
|
||||
ref.loc = path.node.loc;
|
||||
if ((path.parentPath.isCallExpression({
|
||||
callee: path.node
|
||||
}) || path.parentPath.isOptionalCallExpression({
|
||||
callee: path.node
|
||||
}) || path.parentPath.isTaggedTemplateExpression({
|
||||
tag: path.node
|
||||
})) && _core.types.isMemberExpression(ref)) {
|
||||
path.replaceWith(_core.types.sequenceExpression([_core.types.numericLiteral(0), ref]));
|
||||
} else if (path.isJSXIdentifier() && _core.types.isMemberExpression(ref)) {
|
||||
const {
|
||||
object,
|
||||
property
|
||||
} = ref;
|
||||
path.replaceWith(_core.types.jsxMemberExpression(_core.types.jsxIdentifier(object.name), _core.types.jsxIdentifier(property.name)));
|
||||
} else {
|
||||
path.replaceWith(ref);
|
||||
}
|
||||
requeueInParent(path);
|
||||
path.skip();
|
||||
}
|
||||
},
|
||||
UpdateExpression(path) {
|
||||
const {
|
||||
scope,
|
||||
seen,
|
||||
imported,
|
||||
exported,
|
||||
requeueInParent,
|
||||
buildImportReference
|
||||
} = this;
|
||||
if (seen.has(path.node)) return;
|
||||
seen.add(path.node);
|
||||
const arg = path.get("argument");
|
||||
if (arg.isMemberExpression()) return;
|
||||
const update = path.node;
|
||||
if (arg.isIdentifier()) {
|
||||
const localName = arg.node.name;
|
||||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
||||
return;
|
||||
}
|
||||
const exportedNames = exported.get(localName);
|
||||
const importData = imported.get(localName);
|
||||
if ((exportedNames == null ? void 0 : exportedNames.length) > 0 || importData) {
|
||||
if (importData) {
|
||||
path.replaceWith(_core.types.assignmentExpression(update.operator[0] + "=", buildImportReference(importData, arg.node), buildImportThrow(localName)));
|
||||
} else if (update.prefix) {
|
||||
path.replaceWith(buildBindingExportAssignmentExpression(this.metadata, exportedNames, _core.types.cloneNode(update), path.scope));
|
||||
} else {
|
||||
const ref = scope.generateDeclaredUidIdentifier(localName);
|
||||
path.replaceWith(_core.types.sequenceExpression([_core.types.assignmentExpression("=", _core.types.cloneNode(ref), _core.types.cloneNode(update)), buildBindingExportAssignmentExpression(this.metadata, exportedNames, _core.types.identifier(localName), path.scope), _core.types.cloneNode(ref)]));
|
||||
}
|
||||
}
|
||||
}
|
||||
requeueInParent(path);
|
||||
path.skip();
|
||||
},
|
||||
AssignmentExpression: {
|
||||
exit(path) {
|
||||
const {
|
||||
scope,
|
||||
seen,
|
||||
imported,
|
||||
exported,
|
||||
requeueInParent,
|
||||
buildImportReference
|
||||
} = this;
|
||||
if (seen.has(path.node)) return;
|
||||
seen.add(path.node);
|
||||
const left = path.get("left");
|
||||
if (left.isMemberExpression()) return;
|
||||
if (left.isIdentifier()) {
|
||||
const localName = left.node.name;
|
||||
if (scope.getBinding(localName) !== path.scope.getBinding(localName)) {
|
||||
return;
|
||||
}
|
||||
const exportedNames = exported.get(localName);
|
||||
const importData = imported.get(localName);
|
||||
if ((exportedNames == null ? void 0 : exportedNames.length) > 0 || importData) {
|
||||
const assignment = path.node;
|
||||
if (importData) {
|
||||
assignment.left = buildImportReference(importData, left.node);
|
||||
assignment.right = _core.types.sequenceExpression([assignment.right, buildImportThrow(localName)]);
|
||||
}
|
||||
const {
|
||||
operator
|
||||
} = assignment;
|
||||
let newExpr;
|
||||
if (operator === "=") {
|
||||
newExpr = assignment;
|
||||
} else if (operator === "&&=" || operator === "||=" || operator === "??=") {
|
||||
newExpr = _core.types.assignmentExpression("=", assignment.left, _core.types.logicalExpression(operator.slice(0, -1), _core.types.cloneNode(assignment.left), assignment.right));
|
||||
} else {
|
||||
newExpr = _core.types.assignmentExpression("=", assignment.left, _core.types.binaryExpression(operator.slice(0, -1), _core.types.cloneNode(assignment.left), assignment.right));
|
||||
}
|
||||
path.replaceWith(buildBindingExportAssignmentExpression(this.metadata, exportedNames, newExpr, path.scope));
|
||||
requeueInParent(path);
|
||||
path.skip();
|
||||
}
|
||||
} else {
|
||||
const ids = left.getOuterBindingIdentifiers();
|
||||
const programScopeIds = Object.keys(ids).filter(localName => scope.getBinding(localName) === path.scope.getBinding(localName));
|
||||
const id = programScopeIds.find(localName => imported.has(localName));
|
||||
if (id) {
|
||||
path.node.right = _core.types.sequenceExpression([path.node.right, buildImportThrow(id)]);
|
||||
}
|
||||
const items = [];
|
||||
programScopeIds.forEach(localName => {
|
||||
const exportedNames = exported.get(localName) || [];
|
||||
if (exportedNames.length > 0) {
|
||||
items.push(buildBindingExportAssignmentExpression(this.metadata, exportedNames, _core.types.identifier(localName), path.scope));
|
||||
}
|
||||
});
|
||||
if (items.length > 0) {
|
||||
let node = _core.types.sequenceExpression(items);
|
||||
if (path.parentPath.isExpressionStatement()) {
|
||||
node = _core.types.expressionStatement(node);
|
||||
node._blockHoist = path.parentPath.node._blockHoist;
|
||||
}
|
||||
const statement = path.insertAfter(node)[0];
|
||||
requeueInParent(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
ForXStatement(path) {
|
||||
const {
|
||||
scope,
|
||||
node
|
||||
} = path;
|
||||
const {
|
||||
left
|
||||
} = node;
|
||||
const {
|
||||
exported,
|
||||
imported,
|
||||
scope: programScope
|
||||
} = this;
|
||||
if (!_core.types.isVariableDeclaration(left)) {
|
||||
let didTransformExport = false,
|
||||
importConstViolationName;
|
||||
const loopBodyScope = path.get("body").scope;
|
||||
for (const name of Object.keys(_core.types.getOuterBindingIdentifiers(left))) {
|
||||
if (programScope.getBinding(name) === scope.getBinding(name)) {
|
||||
if (exported.has(name)) {
|
||||
didTransformExport = true;
|
||||
if (loopBodyScope.hasOwnBinding(name)) {
|
||||
loopBodyScope.rename(name);
|
||||
}
|
||||
}
|
||||
if (imported.has(name) && !importConstViolationName) {
|
||||
importConstViolationName = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!didTransformExport && !importConstViolationName) {
|
||||
return;
|
||||
}
|
||||
path.ensureBlock();
|
||||
const bodyPath = path.get("body");
|
||||
const newLoopId = scope.generateUidIdentifierBasedOnNode(left);
|
||||
path.get("left").replaceWith(_core.types.variableDeclaration("let", [_core.types.variableDeclarator(_core.types.cloneNode(newLoopId))]));
|
||||
scope.registerDeclaration(path.get("left"));
|
||||
if (didTransformExport) {
|
||||
bodyPath.unshiftContainer("body", _core.types.expressionStatement(_core.types.assignmentExpression("=", left, newLoopId)));
|
||||
}
|
||||
if (importConstViolationName) {
|
||||
bodyPath.unshiftContainer("body", _core.types.expressionStatement(buildImportThrow(importConstViolationName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//# sourceMappingURL=rewrite-live-references.js.map
|
1
node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js.map
generated
vendored
Normal file
1
node_modules/@babel/helper-module-transforms/lib/rewrite-live-references.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user