a7520530 by 杨炀

init

0 parents
Showing 1000 changed files with 4968 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

<script>
import * as loginServer from '@/common/login.js';
import * as api from '@/common/api.js';
import config from '@/config.js';
let firstload = false
export default {
onLaunch: function() {
console.log('App Launch');
firstload = true
this.globalData.baseUrl = config.baseUrl;
this.globalData.baseUrl_api = config.baseUrl_api;
this.globalData.fileUrl = config.fileUrl;
new Promise((resolve, reject) => {
uni.checkSession({
success: res => {
loginServer
.getCurrUser(true)
.catch(() => {
return loginServer.pcLogin();
})
.then(user => {
resolve(user);
});
},
fail: res => {
loginServer
.wxLogin()
.then(loginRes => {
return loginServer.pcLogin(loginRes.code);
})
.then(user => {
resolve(user);
});
}
});
})
.then(()=>{
return loginServer.getNowOpenId()
})
.then(() => {
return loginServer.initData()
// console.log(22222222)
// const currUser = uni.getStorageSync('currUser');
// // console.log(currUser)
// return Promise.all([api.getVenue(), api.getOwnMemberInfo()]).then(res => {
// let ven = res[0].data;
// let men = res[1]?.data;
// if (ven.venuePic) {
// ven.venuePicArr = ven.venuePic.split(',');
// }
// if (ven.businessPeriod) {
// ven.startBus = ven.businessPeriod.split(',')[0];
// ven.endBus = ven.businessPeriod.split(',')[1];
// }
// ven.latitude = ven.lal.split(',')[0];
// ven.longitude = ven.lal.split(',')[1];
// this.globalData.venue = ven;
// this.globalData.isVip = men?.isVip;
// // this.globalData.relateProjectId = men.info.relateProjectId;
// this.globalData.relateProjectIdList = men?.info?.relateProjectIdList;
// this.globalData.relateVenueProjectIdList = men?.info?.relateVenueProjectIdList;
// this.globalData.venueConfig = {
// normalOverDay: ven.resSiteConfig?.normalOrderNum,
// normalPeriodStart: ven.resSiteConfig?.normalOrderPeriod.split(',')[0],
// normalPeriodEnd: ven.resSiteConfig?.normalOrderPeriod.split(',')[1]
// };
// if (men?.isVip) {
// this.globalData.venueConfig.memberOverDay = ven.resSiteConfig?.memberOrderNum;
// this.globalData.venueConfig.memberPeriodStart = ven.resSiteConfig?.memberOrderPeriod.split(',')[0];
// this.globalData.venueConfig.memberPeriodEnd = ven.resSiteConfig?.memberOrderPeriod.split(',')[1];
// }
// });
})
.then(() => {
this.globalData.isLogin = true;
let firstLoadCallback = getApp().firstLoadCallback;
if (firstLoadCallback) {
firstLoadCallback();
}
});
},
onShow: function() {
console.log('App Show');
// loginServer.getNowOpenId()
if (!firstload) {
loginServer.getCurrUser(true)
.catch(() => {
return loginServer.pcLogin().then(() => {
uni.redirectTo({
url: getCurrentPages()[getCurrentPages().length - 1].$page.fullPath
})
});
})
}
},
onHide: function() {
console.log('App Hide');
}
};
</script>
<style lang="scss">
/*每个页面公共css */
@import '/common/uni.css';
@import '/common/mystyle.scss';
@import '@/static/font/iconfont.css';
</style>
\ No newline at end of file
import request from './request.js'
import config from '@/config.js'
import * as loginServer from '@/common/login.js';
function getVenue() {
return request({
url: `/systemj/venue/appId`,
method: 'get'
})
}
function getOwnMemberInfo() {
// return loginServer.getNowOpenId().then(()=>{
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/systemj/member/getOwnMemberInfo?openId=${nowOpenId}`,
method: 'get'
})
// })
}
function getSiteList(projectId) {
return request({
url: `/systemj/site/getSiteList/${projectId}`,
method: 'get'
})
}
function getDateOrderInfo(params) {
return request({
url: `/systemj/reserve/getDateOrderInfo`,
method: 'get',
params: params
})
}
function maGetPrice(params) {
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/systemj/reserve/maGetPrice?openId=${nowOpenId}`,
method: 'get',
params: params
})
}
function userOrder(data) {
uni.showLoading({
title: '提交中...'
})
return request({
url: '/systemj/reserve/maReserveVenueWithInfoList',
method: 'post',
params: data
}).finally(() => {
uni.hideLoading();
});
}
/**
* 确定返订单信息
* @param {Object} data
*/
function maReserveVenueWithInfoList(data) {
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/systemj/reserve/maReserveVenueWithInfoList?openId=${nowOpenId}`,
method: 'post',
params: data
})
}
/**
* 订单付款
* @param {Object} id
* @param {Object} data
*/
function payForOrder(id, data) {
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/systemj/reserve/maPay/${id}?openId=${nowOpenId}`,
method: 'post',
params: data
})
}
function rechargeCard(params) {
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/systemj/member/maRecharge?openId=${nowOpenId}`,
method: 'post',
params: params
})
}
/**
* 获取余额
*/
function getMyBalance() {
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/systemj/member/getMyBalance?openId=${nowOpenId}`,
method: 'get'
})
}
function listCanUse() {
return request({
url: `/systemj/projectConfig/listCanUse`,
method: 'get'
})
}
// 订单列表
function getMalist(params) {
return request({
url: `/systemj/siteOrder/malist`,
method: 'get',
params: params
})
}
function getMaItemById(id) {
return request({
url: `/systemj/siteOrder/maGetInfo/${id}`,
method: 'get'
})
}
// 订单取消 id是orderId
function cancelOrder(id) {
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/systemj/reserve/unSubscribeOrderMa/${id}?openId=${nowOpenId}`,
method: 'post'
})
}
function scanQrCode(id) {
return request({
url: `/systemj/siteOrder/scanQrCode/${id}`,
method: 'post'
})
}
function xfList(params) {
return request({
url: `/systemj/memberBalanceFlow/maListConsume`,
method: 'get',
params: params
})
}
function czList(params) {
return request({
url: `/systemj/memberOrder/maList/recharge`,
method: 'get',
params: params
})
}
function getMaInfo(params) {
return request({
url: `/systemj/statisitcs/getMaInfo`,
method: 'get',
params: params
})
}
// 发送手机验证码
function getCaptchaSms(params) {
return request({
url: `/captchaSms`,
method: 'get',
params: params
})
}
function maRebindMemberCard(phonenumber,code) {
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/systemj/member/maRebindMemberCard/${phonenumber}/${code}?openId=${nowOpenId}`,
method: 'get'
})
}
// 订单取消 规则获取
function getCancelHint(orderId) {
return request({
url: `/systemj/reserve/getCancelHint/${orderId}`,
method: 'get'
})
}
//充值提示
function getMemberLevelTip(phonenumber,amount) {
return request({
url: `/systemj/member/generateMyMemberLevelRemian/${phonenumber}/${amount}`,
method: 'get'
})
}
// 充值反馈
function maRechargeConfirm(params) {
return request({
url: `/systemj/member/maRechargeConfirm`,
method: 'post',
params: params
})
}
function maPayConfirm(params) {
return request({
url: `/systemj/reserve/maPayConfirm`,
method: 'post',
params: params
})
}
// 反馈页面提交
function miniappData(params) {
return request({
url: `/systemj/miniappData`,
method: 'post',
params: params
})
}
export {
getVenue,
getOwnMemberInfo,
getSiteList,
getDateOrderInfo,
maGetPrice,
userOrder,
maReserveVenueWithInfoList,
payForOrder,
getMyBalance,cancelOrder,getMalist,getMaItemById,xfList,czList,getMaInfo,
listCanUse,rechargeCard,scanQrCode,
getCaptchaSms,maRebindMemberCard,getCancelHint,
maRechargeConfirm,maPayConfirm,
getMemberLevelTip,miniappData
}
import request from './request.js'
import config from '@/config.js'
function getTrainList(venueId) {
return request({
url: `/train/info/list`,
method: 'get'
})
}
function getActivityDetail(id) {
return request({
url: `/logex/activity/${id}`,
method: 'get',
params: id
})
}
function getActivityHotelList(params) {
return request({
url: `/logex/activityHotel/list`,
method: 'get',
params: params
})
}
function getHotelById(id) {
return request({
url: `/logex/hotel/${id}`,
method: 'get',
params: id
})
}
function getHotelRooms(id) {
return request({
url: `/logex/activityRoom/list?hotelId=${id}`,
method: 'get',
params: id
})
}
function getbilllist(userId,venueId) {
return request({
url: `/logex/order/list?createById=${userId}&venueId=${venueId}`,
method: 'get',
params: userId
})
}
function newbilllist(userId,venueId) {
return request({
url: `/logex/norder/list?createById=${userId}&venueId=${venueId}`,
method: 'get',
params: userId
})
}
function getCanInvoiceBills(params) {
return request({
url: `/logex/norder/list?activeId=${params.activeId}&createById=${params.userId}&invoiced=1&venueId=${params.venueId}`,
method: 'get'
})
}
function getbilldetailbyId(orderId) {
return request({
// url: `/logex/order/${orderId}`,
url: `/logex/norder/${orderId}`,
method: 'get',
params: orderId
})
}
function getFoodBilldetailbyId(orderId) {
return request({
url: `/logex/orderFood/getFoodOrderInfoByOrder?orderId=${orderId}`,
method: 'get'
})
}
function getRoomBilldetailbyId(orderId) {
return request({
url: `/logex/orderRoom/getRoomOrderInfoByOrderId?orderId=${orderId}`,
method: 'get'
})
}
function getCarBilldetailbyId(orderId) {
return request({
url: `/logex/norder/getOrderByOrderId?orderId=${orderId}`,
method: 'get'
})
}
function getInvoiceByActiveId(activeId,userId,venueId) {
return request({
url: `/logex/invoice/list?activeId=${activeId}&createById=${userId}&venueId=${venueId}`,
method: 'get'
})
}
function getInvoiceByUserId(userId,venueId) {
return request({
url: `/logex/invoice/list?createById=${userId}&venueId=${venueId}`,
method: 'get'
})
}
function getInvoiceDetailBills(invoiceId) {
return request({
url: `/logex/norder/list?invoiceId=${invoiceId}`,
method: 'get'
})
}
function getInvoiceDetail(invoiceId) {
return request({
url: `/logex/invoice/${invoiceId}`,
method: 'get'
})
}
function submitOrder(data) {
return request({
url: `/logex/order/submitOrder`,
method: 'post',
params: data
})
}
// 退款
function cancelOrder(orderId) {
return request({
// url: `/logex/norder/unSubscribeOrderBack/${orderId}`,
url: `/logex/norder/applyOrderBack/${orderId}`,
method: 'post',
params: orderId
})
}
// 取消
function cancelOrder2(orderId) {
return request({
url: `/logex/norder/cancelOrderBack//${orderId}`,
method: 'post',
params: orderId
})
}
function payForOrder(orderId) {
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
// url: `/logex/order/payForOrder?orderId=${orderId}&openId=${nowOpenId}`,
url: `/logex/norder/payForOrder?orderId=${orderId}&openId=${nowOpenId}`,
method: 'post',
params: orderId
})
}
function submitInvoice(form) {
return request({
url: `/logex/invoice`,
method: 'post',
params: form
})
}
function editInvoice(form) {
return request({
url: `/logex/invoice`,
method: 'put',
params: form
})
}
function addAddress(form) {
return request({
url: `/logex/invoiceInfo`,
method: 'post',
params: form
})
}
function checkResidueRoom(form) {
return request({
url: `/logex/orderRoom/checkResidueRoom`,
method: 'post',
params: form
})
}
function delAddress(ids) {
return request({
url: `/logex/invoiceInfo/${ids}`,
method: 'delete'
})
}
function regionsList() {
return request({
url: `/systemj/region/regionsList`,
method: 'get'
})
}
function addressList() {
const currUser = uni.getStorageSync('currUser');
return request({
url: `/logex/invoiceInfo/list?createById=${currUser.userId}`,
method: 'get'
})
}
function getActivityRestaurantList(params) {
return request({
url: `/logex/activityRestaurant/list`,
method: 'get',
params: params
})
}
function getActivityCarList(params) {
return request({
url: `/logex/activityVehicle/wxList`,
method: 'get',
params: params
})
}
function getMenuById(id) {
return request({
url: `/logex/activityFood/list?larId=${id}`,
method: 'get'
})
}
function submitOrderFood(form) {
return request({
url: `/logex/norder/submitOrderFood`,
method: 'post',
params: form
})
}
function submitOrderCar(form) {
return request({
url: `/logex/norder/submitOrderCar`,
method: 'post',
params: form
})
}
function newsSubmitOrderHotel(form) {
return request({
url: `/logex/norder/submitOrderRoom`,
method: 'post',
params: form
})
}
export {getTrainList,getActivityHotelList,getActivityDetail,getHotelById,getHotelRooms,submitOrder,getbilllist,getbilldetailbyId,
payForOrder,cancelOrder,getCanInvoiceBills,submitInvoice,getInvoiceByActiveId,getInvoiceDetailBills,
getInvoiceDetail,getInvoiceByUserId,editInvoice,addAddress,regionsList,addressList,delAddress,
checkResidueRoom,getActivityRestaurantList,getMenuById,
submitOrderFood,getActivityCarList,submitOrderCar,newsSubmitOrderHotel,newbilllist,
getFoodBilldetailbyId,getRoomBilldetailbyId,getCarBilldetailbyId,
cancelOrder2
}
\ No newline at end of file
int "-"?([0-9]|[1-9][0-9]+)
exp [eE][-+]?[0-9]+
frac "."[0-9]+
%%
\s+ /* skip whitespace */
{int}{frac}?{exp}?\b return 'NUMBER'
\"(?:'\\'[\\"bfnrt/]|'\\u'[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*\" yytext = yytext.substr(1,yyleng-2); return 'STRING'
"{" return '{'
"}" return '}'
"[" return '['
"]" return ']'
"," return ','
":" return ':'
"true" return 'TRUE'
"false" return 'FALSE'
"null" return 'NULL'
<<EOF>> return 'EOF'
. return 'INVALID'
%%
%start JSONText
/*
ECMA-262 5th Edition, 15.12.1 The JSON Grammar.
*/
%%
JSONString
: STRING
{ // replace escaped characters with actual character
$$ = yytext.replace(/\\(\\|")/g, "$"+"1")
.replace(/\\n/g,'\n')
.replace(/\\r/g,'\r')
.replace(/\\t/g,'\t')
.replace(/\\v/g,'\v')
.replace(/\\f/g,'\f')
.replace(/\\b/g,'\b');
}
;
JSONNumber
: NUMBER
{
//$$ = Number(yytext);
$$ = yytext == String(Number(yytext))? Number(yytext): yytext;
}
;
JSONNullLiteral
: NULL
{$$ = null;}
;
JSONBooleanLiteral
: TRUE
{$$ = true;}
| FALSE
{$$ = false;}
;
JSONText
: JSONValue EOF
{return $$ = $1;}
;
JSONValue
: JSONNullLiteral
| JSONBooleanLiteral
| JSONString
| JSONNumber
| JSONObject
| JSONArray
;
JSONObject
: '{' '}'
{{$$ = {};}}
| '{' JSONMemberList '}'
{$$ = $2;}
;
JSONMember
: JSONString ':' JSONValue
{$$ = [$1, $3];}
;
JSONMemberList
: JSONMember
{{$$ = {}; $$[$1[0]] = $1[1];}}
| JSONMemberList ',' JSONMember
{$$ = $1; $1[$3[0]] = $3[1];}
;
JSONArray
: '[' ']'
{$$ = [];}
| '[' JSONElementList ']'
{$$ = $2;}
;
JSONElementList
: JSONValue
{$$ = [$1];}
| JSONElementList ',' JSONValue
{$$ = $1; $1.push($3);}
;
import request from './request'
import * as api from '@/common/api.js';
let appId = ''
// #ifdef MP
const accountInfo = uni.getAccountInfoSync()
const appId = accountInfo.miniProgram.appId;
// #endif
function wxLogin() {
return new Promise((resolve, reject) => {
uni.login({
provider: 'weixin',
success: (res) => {
// console.log(res.code);
resolve(res)
},
fail: (res) => {
reject(res)
}
})
})
}
function pcLogin(code) {
if (code) {
return pcLoginByCode(code)
} else {
const currUser = uni.getStorageSync('currUser') || {}
if (currUser.openId) {
return pcLoginByOpenId(currUser.openId);
} else {
return wxLogin().then((loginRes) => {
return pcLoginByCode(loginRes.code)
})
}
}
}
function pcLoginByOpenId(openId) {
return request({
url: "/system/wx/loginByOpenId",
method: "POST",
params: {
appId: appId,
openId: openId
}
}).then((res) => {
let user = res.data;
// console.log("openId " + openId, user)
uni.setStorageSync('token', 'Bearer ' + user.token);
uni.setStorageSync('currUser', user);
return user;
}).catch(() => {
uni.removeStorageSync('currUser')
})
}
function pcLoginByCode(code) {
return request({
// url: "/weixin/api/login",
url: "/system/wx/loginByJsCode",
method: "POST",
params: {
appId: appId,
jsCode: code
}
}).then((res) => {
let user = res.data
// console.log("code: " + code, user)
// getNowOpenId()
uni.setStorageSync('token', 'Bearer ' + user.token);
uni.setStorageSync('currUser', user);
return user;
}).catch((err) => {
uni.removeStorageSync('currUser')
})
}
function getCurrUser(isAuto) {
return request({
url: "/system/wx/getUserInfo",
method: "GET",
opts: {
isAuto: isAuto
}
}).then((res) => {
let user = res.data;
uni.setStorageSync('currUser', user);
return user
})
}
function getWxUser() {
return new Promise((resolve, reject) => {
const currUser = uni.getStorageSync('currUser');
// getNowOpenId()
const nowOpenId = uni.getStorageSync('nowOpenId');
uni.getUserProfile({
desc: '用于完善用户信息',
success: function(infoRes) {
console.log(infoRes)
request({
url: `/system/wx/updateWxUser?openId=${nowOpenId}`,
method: "POST",
params: {
appId: appId,
openId: nowOpenId,
userId: currUser.id,
encryptedData: infoRes.encryptedData,
errMsg: infoRes.errMsg,
iv: infoRes.iv,
rawData: infoRes.rawData,
signature: infoRes.signature
}
}).then((res) => {
let user = res.data;
uni.setStorageSync('currUser', user);
resolve(user);
}).catch(() => {
reject()
})
},
fail: (res) => {
reject(res)
}
});
});
}
function getWxUserPhone(phoneRes) {
// console.log(phoneRes)
const currUser = uni.getStorageSync('currUser');
// getNowOpenId()
const nowOpenId = uni.getStorageSync('nowOpenId');
return request({
url: `/system/wx/updateMobile?openId=${nowOpenId}`,
method: "POST",
params: {
appId: appId,
userId: currUser.id,
encryptedData: phoneRes.encryptedData,
errMsg: phoneRes.errMsg,
iv: phoneRes.iv,
rawData: phoneRes.rawData,
signature: phoneRes.signature
}
}).then((res) => {
let user = res.data;
// uni.setStorageSync('token', 'Bearer '+ user.token);
uni.setStorageSync('token', user.token);
uni.setStorageSync('currUser', user);
return user
})
}
function checkUserAuth(path) {
const currUser = uni.getStorageSync('currUser')
if (currUser.phonenumber) {
// if (currUser.nickName) {
return true
} else {
uni.navigateTo({
url: '/pages/index/start?path=' + encodeURIComponent(path)
})
return false;
}
}
function getNowOpenId() {
console.log('getNowOpenId')
return request({
url: `/system/user/getMyOpenId/${appId}`,
method: 'get'
}).then((res) => {
uni.setStorageSync('nowOpenId', res.msg)
})
}
function initData() {
console.log('initData')
const currUser = uni.getStorageSync('currUser');
// console.log(currUser)
return Promise.all([api.getVenue(), api.getOwnMemberInfo()]).then(res => {
let ven = res[0].data;
let men = res[1]?.data;
const app = getApp();
if (ven.venuePic) {
ven.venuePicArr = ven.venuePic.split(',');
}
if (ven.businessPeriod) {
ven.startBus = ven.businessPeriod.split(',')[0];
ven.endBus = ven.businessPeriod.split(',')[1];
}
ven.latitude = ven.lal.split(',')[0];
ven.longitude = ven.lal.split(',')[1];
app.globalData.venue = ven;
app.globalData.isVip = men?.isVip;
// app.globalData.relateProjectId = men.info.relateProjectId;
app.globalData.relateProjectIdList = men?.info?.relateProjectIdList;
app.globalData.relateVenueProjectIdList = men?.info?.relateVenueProjectIdList;
app.globalData.venueConfig = {
normalOverDay: ven.resSiteConfig?.normalOrderNum,
normalPeriodStart: ven.resSiteConfig?.normalOrderPeriod.split(',')[0],
normalPeriodEnd: ven.resSiteConfig?.normalOrderPeriod.split(',')[1]
};
if (men?.isVip) {
app.globalData.venueConfig.memberOverDay = ven.resSiteConfig?.memberOrderNum;
app.globalData.venueConfig.memberPeriodStart = ven.resSiteConfig?.memberOrderPeriod.split(',')[0];
app.globalData.venueConfig.memberPeriodEnd = ven.resSiteConfig?.memberOrderPeriod.split(',')[1];
}
});
}
export {
getNowOpenId,
wxLogin,
pcLogin,
getCurrUser,
getWxUser,
getWxUserPhone,
checkUserAuth,
initData
}
\ No newline at end of file
import config from '@/config.js'
import {
pcLogin,
getNowOpenId,
initData
} from './login'
const excludeUrls = ['/system/wx/getUserInfo']
// 获取Token
function getToken() {
try {
const token = uni.getStorageSync('token');
if (token) {
return token
} else {
return ''
}
} catch (e) {
console.log(e)
}
}
// 获取请求头
function getHeaders() {
let token = getToken()
let header = {
"Authorization": token,
"Content-Type": "application/json", //根据自己的数据类型
// "Content-Type":"application/x-www-form-urlencoded",
}
return header
}
let request = function(req) {
req.method = req.method.toUpperCase()
if (!['GET', 'POST','PUT', 'DELETE'].includes(req.method)) {
uni.showToast({
title: `暂不支持的请求方式: ${req.method}`,
icon: 'none'
});
return
}
// if (req.method == 'POST' && !req.hideLoding) {
// uni.showLoading({
// title: '提交中...'
// })
// }
return new Promise((resolve, reject) => {
uni.request({
url: config.baseUrl_api + req.url,
method: req.method,
data: req.params,
header: getHeaders(),
}).then(res => {
switch (res.statusCode) {
case 200:
const data = res.data || {};
if (data.code == 200) {
resolve(data)
} else {
//登录超时
if (data.code == 60002 || data.code == 60001) {
if (req.url != '/system/wx/getUserInfo') {
reLogin();
}
}
else if (data.code == 401 && req.url != '/system/wx/getUserInfo') {
pcLogin()
.then(()=>{
return getNowOpenId()
})
.then(()=>{
return initData()
})
.then(()=>{
uni.hideLoading();
uni.redirectTo({
url:getCurrentPages()[getCurrentPages().length-1].$page.fullPath
})
})
}
else {
if (!excludeUrls.includes(req.url)) {
uni.showToast({
title: data.msg,
icon: 'none',
duration: 3000
})
}
}
reject(res)
}
break
default:
reject(res)
}
}).catch(res => {
reject(res)
}).finally(() => {
// if (req.method == 'POST' && !req.hideLoding) {
// uni.hideLoading()
// }
})
})
}
function reLogin() {
const currUser = uni.getStorageSync('currUser') || {}
if (currUser.openId) {
const accountInfo = uni.getAccountInfoSync()
pcLoginByOpenId(accountInfo.miniProgram.appId, currUser.openId)
.then((res) => {
let user = res.data;
uni.setStorageSync('token', 'Bearer ' + user.token);
uni.setStorageSync('currUser', user);
uni.showToast({
title: '一走神把您的操作遗漏了,请重试',
icon: 'none'
})
}).catch(() => {
uni.showToast({
title: '服务异常,请稍后重试',
icon: 'none'
})
})
}
}
function pcLoginByOpenId(appId, openId) {
return request({
url: "/system/wx/loginByOpenId",
method: "POST",
params: {
appId: appId,
openId: openId
}
})
}
export default request;
import request from './request.js'
const accountInfo = uni.getAccountInfoSync()
const appId = accountInfo.miniProgram.appId;
// 获取培训列表
function tainList(params) {
return request({
url: `/systemj/information/applets/trainsList`,
method: 'get',
params: params
})
}
// 查看培训项目
function trainParticulars(params) {
return request({
url: '/systemj/information/getTrainDetails',
method: 'get',
params: params
})
}
// 查看培训项目
function trainProjectList(params) {
return request({
url: '/systemj/information/projectList',
method: 'get',
params: params
})
}
// 查看报名费用(未支付前)
function searchTrainCost(params) {
return request({
url: '/systemj/signer/getEnrollBill',
method: 'get',
params: params
})
}
// 提交 用户资料
function trainNext(params) {
return request({
url: `/systemj/signer/signUp`,
method: 'post',
params,
})
}
// 生成订单
function createOrder(params) {
return request({
url: `/systemj/order/saveOrder`,
method: 'post',
params,
})
}
//会员支付
function pay(params) {
return request({
url: `/systemj/order/pay`,
method: 'post',
params,
})
}
// 线下支付银行信息
function bankSlip(params) {
return request({
url: `/systemj/order/bankInfo`,
method: 'get',
params,
})
}
function trainOrder(params) {
return request({
url: `/systemj/order/getMyOrders`,
method: 'get',
params,
})
}
// 修改报名
function trainUpdata(params) {
return request({
url: `/systemj/signer/updateSign`,
method: 'put',
params,
})
}
// 取消订单
function cancelOrder(params) {
return request({
url: `/systemj/order/cancelOrder`,
method: 'put',
params,
})
}
// 报项列表
function signList(params) {
return request({
url: `/systemj/signer/applets/signList`,
method: 'get',
params,
})
}
// 报项详情
function signDetail(params) {
return request({
url: `/systemj/signer/applets/signDetail`,
method: 'get',
params,
})
}
// 订单列表
function orderList(params) {
return request({
url: `/systemj/order/applets/orderList`,
method: 'get',
params,
})
}
// 订单详情
function getOrderDetail(params) {
return request({
url: `/systemj/order/getOrderDetail`,
method: 'get',
params,
})
}
export {
getOrderDetail,
orderList,
signDetail,
signList,
tainList,
trainParticulars,
trainProjectList,
searchTrainCost,
trainNext,
createOrder,
pay,
bankSlip,
trainOrder,
trainUpdata,
cancelOrder
}
\ No newline at end of file
<template>
<view class="content">
<swiper class="swiper"
:autoplay="autoplay"
:duration="duration">
<swiper-item>
<view class="swiper-item">
<view class="swiper-item-img"><image src="../../static/guide/title_01.png" mode="aspectFit"></image></view>
<view class="swiper-item-img"><image src="../../static/guide/icon_01.png" mode="aspectFit"></image></view>
</view>
<view class="jump-over" @tap="launchFlag()">{{jumpover}}</view>
</swiper-item>
<swiper-item>
<view class="swiper-item">
<view class="swiper-item-img"><image src="../../static/guide/title_02.png" mode="aspectFit"></image></view>
<view class="swiper-item-img"><image src="../../static/guide/icon_02.png" mode="aspectFit"></image></view>
</view>
<view class="jump-over" @tap="launchFlag()">{{jumpover}}</view>
</swiper-item>
<swiper-item>
<view class="swiper-item">
<view class="swiper-item-img"><image src="../../static/guide/title_03.png" mode="aspectFit"></image></view>
<view class="swiper-item-img"><image src="../../static/guide/icon_03.png" mode="aspectFit"></image></view>
</view>
<view class="jump-over" @tap="launchFlag()">{{jumpover}}</view>
</swiper-item>
<swiper-item>
<view class="swiper-item">
<view class="swiper-item-img"><image src="../../static/guide/title_04.png" mode="aspectFit"></image></view>
<view class="swiper-item-img"><image src="../../static/guide/icon_04.png" mode="aspectFit"></image></view>
</view>
<view class="experience" @tap="launchFlag()">{{experience}}</view>
</swiper-item>
</swiper>
<view class="uniapp-img"><image src="../../static/guide/uniapp4@2x.png" mode="aspectFit"></image></view>
</view>
</template>
<script>
export default {
data() {
return {
background: ['color1', 'color2', 'color3'],
autoplay: false,
duration: 500,
jumpover: '跳过',
experience: '立即体验'
}
},
methods: {
launchFlag: function(){
/**
* 向本地存储中设置launchFlag的值,即启动标识;
*/
uni.setStorage({
key: 'launchFlag',
data: true,
});
uni.switchTab({
url: '/pages/tabBar/component/component'
});
}
}
}
</script>
<style>
page,
.content{
width: 100%;
height: 100%;
background-size: 100% auto ;
padding: 0;
}
.swiper{
width: 100%;
height: 80%;
background: #FFFFFF;
}
.swiper-item {
width: 100%;
height: 100%;
text-align: center;
position: relative;
display: flex;
/* justify-content: center; */
align-items:flex-end;
flex-direction:column-reverse
}
.swiper-item-img{
width: 100%;
height: auto;
margin: 0 auto;
}
.swiper-item-img image{
width: 80%;
}
.uniapp-img{
height: 20%;
background: #FFFFFF;
display: flex;
justify-content: center;
align-items:center;
overflow: hidden;
}
.uniapp-img image{
width: 40%;
}
.jump-over,.experience{
position: absolute;
height: 60upx;
line-height: 60upx;
padding: 0 40upx;
border-radius: 30upx;
font-size: 32upx;
color: #454343;
border: 1px solid #454343;
z-index: 999;
}
.jump-over{
right: 45upx;
top: 125upx;
}
.experience{
right: 50%;
margin-right: -105upx;
bottom: 0;
}
</style>
# 引导页
### 基于uni-app框架的swiper组件打开的时候启动。
> 首次启动展示引导页,之后启动不再展示。那么就意味着,我们需要一个标识来确定,App是否已经启动过。
> 我们可以在本地存储一个key来做为已经启动过App的标识。那么,我们在入口这里,就可以读取这个key,来决定是否展示引导页。
> 因工作繁忙目前该程序金对安卓做了适配,IOS可根据环境自己适配。谢谢
## 目录结构
* /pages/index/index.vue //入口页
### 存储key
* 向本地存储中设置launchFlag的值,即启动标识;
### 获取key
* 向本地存储中设置launchFlag的值,即启动标识;
* 获取本地存储中launchFlag的值
* 若存在,说明不是首次启动,直接进入首页;
* 若不存在,说明是首次启动,进入引导页;
```html
<view class="main">
<code-elf-guide v-if="guidePages"></code-elf-guide>
</view>
```
```javascript
import codeElfGuide from '@/components/code-elf-guide/code-elf-guide.vue'
export default {
components: {
codeElfGuide
},
data() {
return {
guidePages:true
}
},
onLoad(){
this.loadExecution()
},
methods: {
loadExecution: function(){
/**
* 获取本地存储中launchFlag的值
* 若存在,说明不是首次启动,直接进入首页;
* 若不存在,说明是首次启动,进入引导页;
*/
try {
// 获取本地存储中launchFlag标识
const value = uni.getStorageSync('launchFlag');
if (value) {
// launchFlag=true直接跳转到首页
uni.switchTab({
url: '/pages/tabBar/component/component'
});
} else {
// launchFlag!=true显示引导页
this.guidePages = true
}
} catch(e) {
// error
uni.setStorage({
key: 'launchFlag',
data: true,
success: function () {
console.log('error时存储launchFlag');
}
});
this.guidePages = true
}
}
}
}
```
```css
page,.main{
width: 100%;
height: 100%;
}
```
### 首页清除key,进行测试
* 清除本地存储中设置launchFlag的值,即启动标识;
* 两秒后重启APP,进行测试
```javascript
uni.showModal({
title: '清除launchFlag值',
content: '确定要清除launchFlag值,进行重启测试?',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
// 清除缓存
uni.clearStorage();
uni.showToast({
icon: 'none',
duration:3000,
title: '清除成功2秒后重启'
});
// 两秒后重启
setTimeout(function() {
uni.hideToast();
plus.runtime.restart();
}, 2000);
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
```
\ No newline at end of file
# 日历组件 lx-calendar可选择周与月支持左右滑动切换
```
<template>
<view class="content">
<lxCalendar @change="change"></lxCalendar>
</view>
</template>
<script>
import lxCalendar from '../../components/lx-calendar/lx-calendar.vue'
export default {
components:{
lxCalendar,
},
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
change(e){
console.log(e);
}
}
}
</script>
```
事件 | 说明
---|---
change | 日期改变时执行
参数 | 类型 | 说明
---|---|---
value | 字符串 | 选中的日期
dot_lists | 数组 | 显示点的日期
# slider-range
uni-app 滑块区间选择组件
可根据具体需求,修改、自定义其他内容。
## 属性说明
|属性名|类型|默认值|说明|
| -- | -- | --|--|
| value | Array<Number, Number> | [0,100] |滑块已选中区间的值|
| min | Number| 0 | 滑块区间最小值 |
| max | Number | 100 | 滑块区间最大值 |
| step | Number | 1 | 拖动时的步长 |
| disabled | Boolean | false | 是否为禁用状态 |
| height | Number | 50 | 滑块容器高度 |
| barHeight | Number | 5 | 滑块进度条高度 |
| backgroundColor | String | #e9e9e9| 滑块进度条背景色|
| activeColor | String | #1aad19 | 已选中区间进度条颜色|
| blockSize | Number | 20 | 滑块大小 |
| blockColor | String | #fff | 滑块颜色 |
| decorationVisible | Boolean | false | 是否显示滑块内装饰元素|
| tipVisible | Boolean | true | 是否显示滑块值提示文本 |
| fomat| Function | | 滑块值提示文本格式化函数,**注意**:小程序中此属性必传,否则会报错,如果无需格式化,可以简单返回原始值: `format(val) { return val }`;H5中可以不传。|
## 使用示例
```html
<slider-range
:value="rangeValue"
:min="rangeMin"
:max="rangMax"
:step="5"
:bar-height="3"
:block-size="26"
background-color="#EEEEF6"
active-color="#FF6B00"
:format="format"
:decorationVisible="true"
@change="handleRangeChange"
></slider-range>
```
```javascript
import SliderRange from '../components/slider-range/index.vue'
export default {
components: {
SliderRange
},
data() {
return {
rangeMin: 5,
rangMax: 200,
rangeValue: [10, 50]
}
},
methods: {
format(val) {
return val + '%'
},
handleRangeChange(e) {
this.rangeValue = e
}
}
}
```
效果图
![](http://images.alisali.cn/img_20190715175325.png)
<template>
<view
class="slider-range"
:class="{ disabled: disabled }"
:style="{ paddingLeft: blockSize / 2 + 'px', paddingRight: blockSize / 2 + 'px' }"
>
<view class="slider-range-inner" :style="{ height: height + 'px' }">
<view
class="slider-bar"
:style="{
height: barHeight + 'px',
}"
>
<!-- 背景条 -->
<view
class="slider-bar-bg"
:style="{
backgroundColor: backgroundColor,
}"
></view>
<!-- 滑块实际区间 -->
<view
class="slider-bar-inner"
:style="{
width: ((values[1] - values[0]) / (max - min)) * 100 + '%',
left: lowerHandlePosition + '%',
backgroundColor: activeColor,
}"
></view>
</view>
<!-- 滑动块-左 -->
<view
class="slider-handle-block"
:class="{ decoration: decorationVisible }"
:style="{
backgroundColor: blockColor,
width: blockSize + 'px',
height: blockSize + 'px',
left: lowerHandlePosition + '%',
}"
@touchstart="_onTouchStart"
@touchmove="_onBlockTouchMove"
@touchend="_onBlockTouchEnd"
data-tag="lowerBlock"
></view>
<!-- 滑动块-右 -->
<view
class="slider-handle-block"
:class="{ decoration: decorationVisible }"
:style="{
backgroundColor: blockColor,
width: blockSize + 'px',
height: blockSize + 'px',
left: higherHandlePosition + '%',
}"
@touchstart="_onTouchStart"
@touchmove="_onBlockTouchMove"
@touchend="_onBlockTouchEnd"
data-tag="higherBlock"
></view>
<!-- 滑块值提示 -->
<view v-if="tipVisible" class="range-tip" :style="lowerTipStyle">{{ format(values[0]) }}</view>
<view v-if="tipVisible" class="range-tip" :style="higherTipStyle">{{ format(values[1]) }}</view>
</view>
</view>
</template>
<script>
export default {
components: {},
props: {
//滑块区间当前取值
value: {
type: Array,
default: function() {
return [0, 100]
},
},
//最小值
min: {
type: Number,
default: 0,
},
//最大值
max: {
type: Number,
default: 100,
},
step: {
type: Number,
default: 1,
},
format: {
type: Function,
default: function(val) {
return val
},
},
disabled: {
type: Boolean,
default: false,
},
//滑块容器高度
height: {
height: Number,
default: 50,
},
//区间进度条高度
barHeight: {
type: Number,
default: 5,
},
//背景条颜色
backgroundColor: {
type: String,
default: '#e9e9e9',
},
//已选择的颜色
activeColor: {
type: String,
default: '#1aad19',
},
//滑块大小
blockSize: {
type: Number,
default: 20,
},
blockColor: {
type: String,
default: '#fff',
},
tipVisible: {
type: Boolean,
default: true,
},
decorationVisible: {
type: Boolean,
default: false,
},
},
data() {
return {
values: [this.min, this.max],
startDragPos: 0, // 开始拖动时的坐标位置
startVal: 0, //开始拖动时较小点的值
}
},
computed: {
// 较小点滑块的坐标
lowerHandlePosition() {
return ((this.values[0] - this.min) / (this.max - this.min)) * 100
},
// 较大点滑块的坐标
higherHandlePosition() {
return ((this.values[1] - this.min) / (this.max - this.min)) * 100
},
lowerTipStyle() {
if (this.lowerHandlePosition < 90) {
return `left: ${this.lowerHandlePosition}%;`
}
return `right: ${100 - this.lowerHandlePosition}%;transform: translate(50%, -100%);`
},
higherTipStyle() {
if (this.higherHandlePosition < 90) {
return `left: ${this.higherHandlePosition}%;`
}
return `right: ${100 - this.higherHandlePosition}%;transform: translate(50%, -100%);`
},
},
created: function() {},
onLoad: function(option) {},
watch: {
//滑块当前值
value: {
immediate: true,
handler(newVal, oldVal) {
if (this._isValuesValid(newVal) && (newVal[0] !== this.values[0] || newVal[1] !== this.values[1])) {
this._updateValue(newVal)
}
},
},
},
methods: {
_updateValue(newVal) {
// 步长大于区间差,或者区间最大值和最小值相等情况
if (this.step >= this.max - this.min) {
throw new RangeError('Invalid slider step or slider range')
}
let newValues = []
if (Array.isArray(newVal)) {
newValues = [newVal[0], newVal[1]]
}
if (typeof newValues[0] !== 'number') {
newValues[0] = this.values[0]
} else {
newValues[0] = Math.round((newValues[0] - this.min) / this.step) * this.step + this.min
}
if (typeof newValues[1] !== 'number') {
newValues[1] = this.values[1]
} else {
newValues[1] = Math.round((newValues[1] - this.min) / this.step) * this.step + this.min
}
// 新值与原值相等,不做处理
if (this.values[0] === newValues[0] && this.values[1] === newValues[1]) {
return
}
// 左侧滑块值小于最小值时,设置为最小值
if (newValues[0] < this.min) {
newValues[0] = this.min
}
// 右侧滑块值大于最大值时,设置为最大值
if (newValues[1] > this.max) {
newValues[1] = this.max
}
// 两个滑块重叠或左右交错,使两个滑块保持最小步长的间距
if (newValues[0] >= newValues[1]) {
// 左侧未动,右侧滑块滑到左侧滑块之左
if (newValues[0] === this.values[0]) {
newValues[1] = newValues[0] + this.step
} else {
// 右侧未动, 左侧滑块滑到右侧之右
newValues[0] = newValues[1] - this.step
}
}
this.values = newValues
this.$emit('change', this.values)
},
_onTouchStart: function(event) {
if (this.disabled) {
return
}
this.isDragging = true
let tag = event.target.dataset.tag
//兼容h5平台及某版本微信
let e = event.changedTouches ? event.changedTouches[0] : event
this.startDragPos = e.pageX
this.startVal = tag === 'lowerBlock' ? this.values[0] : this.values[1]
},
_onBlockTouchMove: function(e) {
if (this.disabled) {
return
}
this._onDrag(e)
},
_onBlockTouchEnd: function(e) {
if (this.disabled) {
return
}
this.isDragging = false
this._onDrag(e)
},
_onDrag(event) {
if (!this.isDragging) {
return
}
let view = uni
.createSelectorQuery()
.in(this)
.select('.slider-range-inner')
view
.boundingClientRect(data => {
let sliderWidth = data.width
const tag = event.target.dataset.tag
let e = event.changedTouches ? event.changedTouches[0] : event
let diff = ((e.pageX - this.startDragPos) / sliderWidth) * (this.max - this.min)
let nextVal = this.startVal + diff
if (tag === 'lowerBlock') {
this._updateValue([nextVal, null])
} else {
this._updateValue([null, nextVal])
}
})
.exec()
},
_isValuesValid: function(values) {
return Array.isArray(values) && values.length == 2
},
},
}
</script>
<style scoped>
.slider-range {
position: relative;
padding-top: 40rpx;
}
.slider-range-inner {
position: relative;
width: 100%;
}
.slider-range.disabled .slider-bar-inner {
opacity: 0.35;
}
.slider-range.disabled .slider-handle-block {
cursor: not-allowed;
}
.slider-bar {
position: absolute;
top: 50%;
left: 0;
right: 0;
transform: translateY(-50%);
}
.slider-bar-bg {
position: absolute;
width: 100%;
height: 100%;
border-radius: 10000px;
z-index: 10;
}
.slider-bar-inner {
position: absolute;
width: 100%;
height: 100%;
border-radius: 10000px;
z-index: 11;
}
.slider-handle-block {
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
box-shadow: 0 0 3px 2px rgba(227, 229, 241, 0.5);
z-index: 12;
}
.slider-handle-block.decoration::before {
position: absolute;
content: '';
width: 6upx;
height: 24upx;
top: 50%;
left: 29%;
transform: translateY(-50%);
background: #eeedf2;
border-radius: 3upx;
z-index: 13;
}
.slider-handle-block.decoration::after {
position: absolute;
content: '';
width: 6upx;
height: 24upx;
top: 50%;
right: 29%;
transform: translateY(-50%);
background: #eeedf2;
border-radius: 3upx;
z-index: 13;
}
.range-tip {
position: absolute;
top: 0;
font-size: 24upx;
color: #666;
transform: translate(-50%, -100%);
}
</style>
<template>
<view class="demo-slider-range">
<view class="section-title">普通用法</view>
<view class="slider-item">
<slider-range
:value="slider1.rangeValue"
:min="slider1.min"
:max="slider1.max"
:step="slider1.step"
:bar-height="barHeight"
:block-size="blockSize"
:background-color="backgroundColor"
:format="format1"
@change="handleRangeChange"
></slider-range>
</view>
<view class="section-title">自定义</view>
<view class="slider-item">
<slider-range
:value="slider2.rangeValue"
:min="slider2.min"
:max="slider2.max"
:step="slider2.step"
:bar-height="barHeight"
:block-size="blockSize"
:background-color="backgroundColor"
:active-color="slider2.activeColor"
:format="format2"
:decorationVisible="slider2.decorationVisible"
@change="handleRangeChange"
></slider-range>
</view>
</view>
</template>
<script>
import SliderRange from '../../components/slider-range/index.vue'
export default {
components: {
SliderRange,
},
data() {
return {
barHeight: 3,
blockSize: 26,
backgroundColor: '#EEEEF6',
slider1: {
min: 50,
max: 200,
step: 10,
rangeValue: [50, 150],
},
slider2: {
rangeMin: 0,
rangMax: 100,
rangeValue: [8, 80],
step: 1,
activeColor: '#FF6B00',
decorationVisible: true,
},
}
},
methods: {
format1(val) {
return val
},
format2(val) {
return `${val}%`
},
handleRangeChange(e) {
this.rangeValue = e
},
},
}
</script>
<style>
.demo-slider-range {
background-color: #fff;
padding: 100rpx 40rpx 0;
}
.section-title {
padding: 0 0 20rpx;
color: #666;
}
.slider-item:not(:last-child) {
margin-bottom: 100rpx;
}
</style>
<template>
<view class="box">
<view class="box1">
<view class="title">
<view class="title-left">{{ porps.title }}</view>
<view class="title-icon" @click="changFN">
<uni-icons type="top" color="#95a1a6" v-if="show"></uni-icons>
<uni-icons type="bottom" color="#95a1a6" v-else></uni-icons>
</view>
</view>
<view class="conter-liner-cost">
<view class="liner-left">{{ porps.text }}&nbsp;&nbsp; 合计:</view>
<view class="liner-right">{{ porps.cost }}</view>
</view>
</view>
<view class="box2" v-show="show"><slot></slot></view>
</view>
</template>
<script setup>
import { ref } from 'vue';
const porps = defineProps({
title: String,
text: String,
cost: String
});
const show = ref(false);
function changFN() {
show.value = !show.value;
}
</script>
<style lang="scss" scoped>
.box {
margin: 0;
padding: 0 25rpx;
.box1 {
margin-bottom: 23rpx;
margin-top: 35rpx;
.title {
display: flex;
justify-content: space-between;
margin-bottom: 10rpx;
.title-left {
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 500;
color: #2b3133;
}
}
.conter-liner-cost {
display: flex;
.liner-left {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
color: #7b7f83;
}
.liner-right {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
color: #ff8124;
}
}
}
.box2 {
border-top: 1rpx solid #e6e6e6;
}
}
</style>
<template>
<view class=" conter-box">
<view class="box" v-if="props.trainProjectsList.length != 0">
<view class="text">培训科目</view>
<view class="box2">
<checkbox-group>
<view class="box-check" v-for="item in props.trainProjectsList" :key="item.id">
<view class="">
<view class="title">{{ item.projectName }}</view>
<view class="content">
{{ item.isNecessary == 1 ? '必选' : '非必选' }}&nbsp;&nbsp;合计:
<view class="span">{{ item.cost }}</view>
</view>
</view>
<view class="checkbox">
<checkbox
:disabled="item.isNecessary == 1"
:value="item.id"
@click="checkTrain(item)"
:checked="item.check"
/>
</view>
</view>
</checkbox-group>
</view>
</view>
<view class="box" v-if="props.examProjectsList.length != 0">
<view class="text">考试科目</view>
<view class="box2">
<checkbox-group>
<view class="box-check" v-for="item in props.examProjectsList" :key="item.id">
<view class="">
<view class="title">{{ item.projectName }}</view>
<view class="content">
{{ item.isNecessary == 1 ? '必选' : '非必选' }}&nbsp;&nbsp;合计:
<view class="span">{{ item.cost }}</view>
</view>
</view>
<view class="checkbox">
<checkbox
:disabled="item.isNecessary == 1"
:value="item.id"
@click="checkTrain(item)"
:checked="item.check"
/>
</view>
</view>
</checkbox-group>
</view>
</view>
</view>
<view class="foot">
<view class="button1" @click="upFN">上一步</view>
<view class="button" @click="nextFN">下一步</view>
</view>
<view class="nodata " v-if="props.examProjectsList.length == 0 && props.trainProjectsList.length == 0">
没有培训科目
</view>
</template>
<script setup>
import { forEach } from 'lodash';
import { ref, getCurrentInstance, reactive, toRefs } from 'vue';
const props = defineProps({
trainProjectsList: {},
examProjectsList: {},
hotelList: {},
id: {}
});
const data = reactive({
projectIdsArray: []
});
const examIdsArry = ref([]);
const { projectIdsArray } = toRefs(data);
const emit = defineEmits(['nextFN']);
const checkbox1 = ref([0]);
function checkTrain(item) {
if (item.isNecessary == 1) {
item.check = true;
} else {
item.check = !item.check;
}
}
// 上一步
function upFN() {
emit('nextFN', 0);
}
// 下一步
function nextFN() {
let falg = true;
let arr1 = [];
let arr2 = [];
props.examProjectsList.forEach(item => {
if (item.check) {
arr1.push(item.id);
}
});
props.trainProjectsList.forEach(item => {
if (item.check) {
arr2.push(item.id);
}
});
let examList = JSON.parse(JSON.stringify(props.examProjectsList));
let trainList = JSON.parse(JSON.stringify(props.trainProjectsList));
examList.concat(trainList).forEach(item => {
if (item.isNecessary == 1 && item.check == false) {
falg = false;
}
});
if (falg) {
examIdsArry.value = arr1;
projectIdsArray.value = arr2;
if (props.hotelList.length == 0) {
// 没有酒店直接报名
// 页面跳转
let path = `/pages/train/costBreakdown/costBreakdown?id=` + props.id;
wx.navigateTo({
url: path
});
} else {
emit('nextFN', 2, projectIdsArray.value, examIdsArry.value);
}
} else {
uni.showToast({
title: '请选择必选科目!',
duration: 2000,
icon: 'error'
});
return false;
}
}
</script>
<style scoped lang="scss">
.nodata {
background: url(/static/nodata.png) no-repeat;
background-size: 100%;
width: 100%;
height: 835rpx;
color: #aaa59f;
font-size: 50rpx;
}
.conter-box {
padding-bottom: 100rpx;
}
.box {
padding: 34rpx 25rpx;
background-color: #f4f6fa;
padding-bottom: 0;
.box2 {
background-color: #fff;
border-radius: 15rpx;
margin-top: 20rpx;
}
.text {
height: 29px;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 500;
color: #000000;
line-height: 62rpx;
}
.box-check {
padding: 40rpx;
display: flex;
justify-content: space-between;
border-bottom: 1rpx solid #e6e6e6;
padding-bottom: 20rpx;
:deep(.checkbox__inner) {
background-color: #d9d9d9 !important;
border-color: #d9d9d9 !important;
border-radius: 50% !important;
width: 45rpx !important;
height: 45rpx !important;
line-height: 40rpx;
}
.text {
font-size: 12px;
color: #666;
margin-top: 5px;
}
.title {
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 400;
color: #2b3133;
margin-bottom: 10rpx;
}
.content {
display: flex;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 400;
color: #2b3133;
.span {
color: #ff8124;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
}
}
}
:deep(.checkbox__inner-icon) {
position: absolute !important;
top: 4px !important;
left: 7px !important;
color: #000 !important;
}
:deep(.uni-data-checklist .checklist-group .checklist-box) {
margin-right: 0;
}
}
.conter-button {
position: absolute;
left: 0;
bottom: 10rpx;
width: 100%;
display: flex;
justify-content: center;
.button {
height: 80rpx;
width: 500rpx;
text-align: center;
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 500;
color: #ffffff;
line-height: 80rpx;
background: linear-gradient(270deg, #54e1b9, #00caa6);
border-radius: 40rpx;
}
}
.foot {
display: flex;
background-color: #ffffff;
padding: 20rpx 0;
position: absolute;
left: 0;
bottom: 0;
width: 100%;
.button {
margin: 0 auto;
height: 80rpx;
width: 300rpx;
text-align: center;
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 500;
color: #ffffff;
line-height: 80rpx;
background: linear-gradient(270deg, #54e1b9, #00caa6);
border-radius: 40rpx;
}
.button1 {
margin: 0 auto;
height: 80rpx;
width: 300rpx;
text-align: center;
font-size: 32rpx;
font-family: PingFang SC;
font-weight: 500;
line-height: 80rpx;
background: #fff;
border-radius: 40rpx;
border: 1px solid #2ed981;
color: #2ed981;
}
}
</style>
<template>
<view class="box">
<view class="liner" v-for="item in props.scheduleList" :key="item.id">
<view class="timer">
<uni-icons custom-prefix="iconfont" type="icon-ai253" color="#1ec886" size="20"></uni-icons>
&nbsp; {{ item.dayStr }} 10:00-12:00
</view>
<view class="conetr">{{ item.event }}</view>
<view class="data">
<uni-icons custom-prefix="iconfont" type="icon-loufangfangzi"></uni-icons>
{{ item.place }}
</view>
</view>
<view class="nodata" v-if="props?.scheduleList?.length == 0">你还没有日程安排</view>
</view>
</template>
<script setup>
import { ref, getCurrentInstance, reactive, toRefs } from 'vue';
const props = defineProps({
scheduleList: {}
});
</script>
<style scoped lang="scss">
.nodata {
background: url(/static/nodata.png) no-repeat;
background-size: 100%;
width: 100%;
height: 835rpx;
color: #aaa59f;
font-size: 50rpx;
}
.box {
padding-top: 25rpx;
.liner {
margin-bottom: 20rpx;
background-color: #fff;
border-radius: 15rpx;
padding: 20rpx;
}
.timer {
display: flex;
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
color: #1ec886;
}
.conetr {
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 400;
color: #2b3133;
margin: 25rpx 0;
}
.data {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: 400;
color: #7b7f83;
}
}
</style>
<template>
<view class="big-box">
<view class="list-box">
<view class="image">
<image class="img" referrer="no-referrer|origin|unsafe-url" :src="porps.pic" mode="aspectFill"></image>
</view>
<view class="text">
<view class="text-title">{{ porps.title }}</view>
<view class="text-card color" v-if="porps.card == '报名中'">{{ porps.card }}</view>
<view class="text-card color1" v-if="porps.card == '进行中'">{{ porps.card }}</view>
<view class="text-card color2" v-if="porps.card == '即将开始'">{{ porps.card }}</view>
<view class="text-card color3" v-if="porps.card == '已结束'">{{ porps.card }}</view>
<view class="text-card color4" v-if="porps.card == '培训未开始'">{{ porps.card }}</view>
<view class="text-card color4" v-if="porps.card == '报名未开始'">{{ porps.card }}</view>
<view class="text-timer ">报名截止:{{ porps.timer }}</view>
</view>
</view>
<view class="hr"></view>
</view>
</template>
<script setup>
const porps = defineProps({
pic: {
type: String
},
title: {
type: String
},
card: {
type: String
},
timer: {
type: String
}
});
</script>
<style lang="scss">
.big-box {
width: 100%;
padding: 25rpx 0;
.hr {
width: 100%;
border-bottom: 1rpx solid #e5e5e5;
padding-top: 25rpx;
}
.list-box {
width: 100%;
height: 180rpx;
display: flex;
.image {
width: 270rpx;
height: 180rpx;
padding-right: 25rpx;
.img {
width: 270rpx;
height: 180rpx;
border-radius: 15rpx;
}
}
.text {
margin-left: 20rpx;
.text-title {
text-align: left;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 400;
color: #000000;
}
.text-card {
font-size: 20rpx;
width: 110rpx;
height: 32rpx;
margin-top: 57rpx;
text-align: center;
font-family: PingFang SC;
font-weight: 400;
color: #ffffff;
border-radius: 16px 16px 16px 0px;
}
.color {
background: linear-gradient(270deg, #54e1b9, #00caa6);
}
.color1 {
background: linear-gradient(270deg, #be8efb, #a76df4);
}
.color2 {
background: linear-gradient(270deg, #fea449, #ffb95f);
}
.color3 {
background: linear-gradient(270deg, #d9d9d9, #bcbcbc);
}
.color4 {
background: linear-gradient(270deg, #40d8ee, #53a7f6);
}
.text-timer {
margin-top: 20rpx;
height: 23rpx;
font-size: 24rpx;
font-family: PingFang SC;
font-weight: 400;
color: #7b7f83;
}
}
}
}
</style>
\ No newline at end of file
<template>
<view class="big-box">
<view class="list-box">
<view class="image">
<image
class="img"
referrer="no-referrer|origin|unsafe-url"
:src="porps.item.cover"
mode="aspectFill"
></image>
</view>
<view class="text">
<view class="text-title">{{ porps.item.trainName }}</view>
<view class="text-card color1" v-if="porps.item.statusStr == '审核通过'">
{{ porps.item.statusStr }}
</view>
<view class="text-card color2" v-if="porps.item.statusStr == '待审核'">
{{
porps.item.status == '0' && porps.item.payStatus == '0'
? porps.item.payStatusStr
: porps.item.statusStr
}}
</view>
<view class="text-card color3" v-if="porps.item.statusStr == '报名失败'">
{{ porps.item.statusStr }}
</view>
<view class="text-card color3" v-if="porps.item.statusStr == '审核拒绝'">
{{ porps.item.statusStr }}
</view>
<view class="text-card color4" v-if="porps.item.statusStr == '待支付'">{{ porps.item.statusStr }}</view>
<view class="text-card color4" v-if="porps.item.statusStr == '待提交'">{{ porps.item.statusStr }}</view>
<view class="text-card color5" v-if="porps.item.statusStr == '已取消'">{{ porps.item.statusStr }}</view>
</view>
</view>
<view class="hr"></view>
</view>
</template>
<script setup>
const porps = defineProps({
pic: {
type: String
},
title: {
type: String
},
card: {
type: String
},
timer: {
type: String
},
item: {}
});
</script>
<style lang="scss">
.big-box {
width: 100%;
padding: 25rpx 0;
.hr {
width: 100%;
border-bottom: 1rpx solid #e5e5e5;
padding-top: 25rpx;
}
.list-box {
width: 100%;
height: 180rpx;
display: flex;
.image {
width: 270rpx;
height: 180rpx;
padding-right: 25rpx;
.img {
width: 270rpx;
height: 180rpx;
border-radius: 15rpx;
}
}
.text {
margin-left: 20rpx;
.text-title {
text-align: left;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 400;
color: #000000;
}
.text-card {
font-size: 20rpx;
width: 94rpx;
height: 32rpx;
margin-top: 57rpx;
text-align: center;
font-family: PingFang SC;
font-weight: 400;
color: #ffffff;
border-radius: 16px 16px 16px 0px;
}
.color1 {
background: linear-gradient(270deg, #54e1b9, #00caa6);
}
.color2 {
background: linear-gradient(270deg, #be8efb, #a76df4);
}
.color3 {
background: linear-gradient(90deg, #f83841, #f76d74);
}
.color4 {
background: linear-gradient(90deg, #fea449, #ffb95f);
}
.color5 {
background: linear-gradient(270deg, #d9d9d9, #bcbcbc);
}
}
}
}
</style>
// prod
// const baseUrl = 'https://research.wtwuxicenter.com/';
// const baseUrl_api=`${baseUrl}/prod-api`;
// uat
// const baseUrl = 'https://jxt.itechtop.cn';
const baseUrl = 'https://jxt.wtwuxicenter.com';
const baseUrl_api = `${baseUrl}/prod-api`;
// staging
// const baseUrl = 'https://5q5re1d432g2.ngrok2.xiaomiqiu123.top';
// const baseUrl = "http://192.168.1.118:8081";
// const baseUrl_api = `${baseUrl}`;
const fileUrl = "http://r.itechtop.cn";
export default {
baseUrl: baseUrl,
fileUrl: fileUrl,
baseUrl_api: baseUrl_api,
};
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
<style>
* {
box-sizing: border-box;
}
</style>
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>
import App from './App'
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import {
createSSRApp
} from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif
{
"name" : "miniP",
"appid" : "__UNI__580BCB0",
"description" : "",
"versionName" : "1.0.1",
"versionCode" : "100",
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* 模块配置 */
"modules" : {},
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
"android" : {
"permissions" : [],
"autoSdkPermissions" : true
},
/* ios打包配置 */
"ios" : {
"permissions" : [],
"autoSdkPermissions" : true
},
/* SDK配置 */
"sdkConfigs" : {}
}
},
/* 快应用特有相关 */
"quickapp" : {},
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "wx5d51e8ed31bbdbb7",//J系统
// "appid" : "wx70f16625f10de4fe",//新跆联
// "appid" : "wx5e2471ed6210c3a6",
"setting" : {
"urlCheck" : false,
"minified" : false,
"es6" : true
},
"usingComponents" : true,
"permission" : {},
"optimization":{"subPackages":true}
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "3"
}
../resolve/bin/resolve
\ No newline at end of file
../rollup/dist/bin/rollup
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/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.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
{"type":"module"}
\ No newline at end of file
{
"name": "@rollup/plugin-commonjs",
"version": "22.0.2",
"publishConfig": {
"access": "public"
},
"description": "Convert CommonJS modules to ES2015",
"license": "MIT",
"repository": {
"url": "rollup/plugins",
"directory": "packages/commonjs"
},
"author": "Rich Harris <richard.a.harris@gmail.com>",
"homepage": "https://github.com/rollup/plugins/tree/master/packages/commonjs/#readme",
"bugs": "https://github.com/rollup/plugins/issues",
"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
},
"engines": {
"node": ">= 12.0.0"
},
"scripts": {
"build": "rollup -c",
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
"ci:lint": "pnpm build && pnpm lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "pnpm test -- --verbose && pnpm test:ts",
"prebuild": "del-cli dist",
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prepublishOnly": "pnpm build",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
"files": [
"dist",
"types",
"README.md",
"LICENSE"
],
"keywords": [
"rollup",
"plugin",
"npm",
"modules",
"commonjs",
"require"
],
"peerDependencies": {
"rollup": "^2.68.0"
},
"dependencies": {
"@rollup/pluginutils": "^3.1.0",
"commondir": "^1.0.1",
"estree-walker": "^2.0.1",
"glob": "^7.1.6",
"is-reference": "^1.2.1",
"magic-string": "^0.25.7",
"resolve": "^1.17.0"
},
"devDependencies": {
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.0",
"locate-character": "^2.0.5",
"require-relative": "^0.8.7",
"rollup": "^2.68.0",
"shx": "^0.3.2",
"source-map": "^0.7.3",
"source-map-support": "^0.5.19",
"typescript": "^3.9.7"
},
"types": "types/index.d.ts",
"ava": {
"babel": {
"compileEnhancements": false
},
"files": [
"!**/fixtures/**",
"!**/helpers/**",
"!**/recipes/**",
"!**/types.ts"
]
}
}
# @rollup/pluginutils ChangeLog
## v3.1.0
_2020-06-05_
### Bugfixes
- fix: resolve relative paths starting with "./" (#180)
### Features
- feat: add native node es modules support (#419)
### Updates
- refactor: replace micromatch with picomatch. (#306)
- chore: Don't bundle micromatch (#220)
- chore: add missing typescript devDep (238b140)
- chore: Use readonly arrays, add TSDoc (#187)
- chore: Use typechecking (2ae08eb)
## v3.0.10
_2020-05-02_
### Bugfixes
- fix: resolve relative paths starting with "./" (#180)
### Updates
- refactor: replace micromatch with picomatch. (#306)
- chore: Don't bundle micromatch (#220)
- chore: add missing typescript devDep (238b140)
- chore: Use readonly arrays, add TSDoc (#187)
- chore: Use typechecking (2ae08eb)
## v3.0.9
_2020-04-12_
### Updates
- chore: support Rollup v2
## v3.0.8
_2020-02-01_
### Bugfixes
- fix: resolve relative paths starting with "./" (#180)
### Updates
- chore: add missing typescript devDep (238b140)
- chore: Use readonly arrays, add TSDoc (#187)
- chore: Use typechecking (2ae08eb)
## v3.0.7
_2020-02-01_
### Bugfixes
- fix: resolve relative paths starting with "./" (#180)
### Updates
- chore: Use readonly arrays, add TSDoc (#187)
- chore: Use typechecking (2ae08eb)
## v3.0.6
_2020-01-27_
### Bugfixes
- fix: resolve relative paths starting with "./" (#180)
## v3.0.5
_2020-01-25_
### Bugfixes
- fix: bring back named exports (#176)
## v3.0.4
_2020-01-10_
### Bugfixes
- fix: keep for(const..) out of scope (#151)
## v3.0.3
_2020-01-07_
### Bugfixes
- fix: createFilter Windows regression (#141)
### Updates
- test: fix windows path failure (0a0de65)
- chore: fix test script (5eae320)
## v3.0.2
_2020-01-04_
### Bugfixes
- fix: makeLegalIdentifier - potentially unsafe input for blacklisted identifier (#116)
### Updates
- docs: Fix documented type of createFilter's include/exclude (#123)
- chore: update minor linting correction (bcbf9d2)
## 3.0.1
- fix: Escape glob characters in folder (#84)
## 3.0.0
_2019-11-25_
- **Breaking:** Minimum compatible Rollup version is 1.20.0
- **Breaking:** Minimum supported Node version is 8.0.0
- Published as @rollup/plugins-image
## 2.8.2
_2019-09-13_
- Handle optional catch parameter in attachScopes ([#70](https://github.com/rollup/rollup-pluginutils/pulls/70))
## 2.8.1
_2019-06-04_
- Support serialization of many edge cases ([#64](https://github.com/rollup/rollup-pluginutils/issues/64))
## 2.8.0
_2019-05-30_
- Bundle updated micromatch dependency ([#60](https://github.com/rollup/rollup-pluginutils/issues/60))
## 2.7.1
_2019-05-17_
- Do not ignore files with a leading "." in createFilter ([#62](https://github.com/rollup/rollup-pluginutils/issues/62))
## 2.7.0
_2019-05-15_
- Add `resolve` option to createFilter ([#59](https://github.com/rollup/rollup-pluginutils/issues/59))
## 2.6.0
_2019-04-04_
- Add `extractAssignedNames` ([#59](https://github.com/rollup/rollup-pluginutils/issues/59))
- Provide dedicated TypeScript typings file ([#58](https://github.com/rollup/rollup-pluginutils/issues/58))
## 2.5.0
_2019-03-18_
- Generalize dataToEsm type ([#55](https://github.com/rollup/rollup-pluginutils/issues/55))
- Handle empty keys in dataToEsm ([#56](https://github.com/rollup/rollup-pluginutils/issues/56))
## 2.4.1
_2019-02-16_
- Remove unnecessary dependency
## 2.4.0
_2019-02-16_
Update dependencies to solve micromatch vulnerability ([#53](https://github.com/rollup/rollup-pluginutils/issues/53))
## 2.3.3
_2018-09-19_
- Revert micromatch update ([#43](https://github.com/rollup/rollup-pluginutils/issues/43))
## 2.3.2
_2018-09-18_
- Bumb micromatch dependency ([#36](https://github.com/rollup/rollup-pluginutils/issues/36))
- Bumb dependencies ([#41](https://github.com/rollup/rollup-pluginutils/issues/41))
- Split up tests ([#40](https://github.com/rollup/rollup-pluginutils/issues/40))
## 2.3.1
_2018-08-06_
- Fixed ObjectPattern scope in attachScopes to recognise { ...rest } syntax ([#37](https://github.com/rollup/rollup-pluginutils/issues/37))
## 2.3.0
_2018-05-21_
- Add option to not generate named exports ([#32](https://github.com/rollup/rollup-pluginutils/issues/32))
## 2.2.1
_2018-05-21_
- Support `null` serialization ([#34](https://github.com/rollup/rollup-pluginutils/issues/34))
## 2.2.0
_2018-05-11_
- Improve white-space handling in `dataToEsm` and add `prepare` script ([#31](https://github.com/rollup/rollup-pluginutils/issues/31))
## 2.1.1
_2018-05-09_
- Update dependencies
## 2.1.0
_2018-05-08_
- Add `dataToEsm` helper to create named exports from objects ([#29](https://github.com/rollup/rollup-pluginutils/issues/29))
- Support literal keys in object patterns ([#27](https://github.com/rollup/rollup-pluginutils/issues/27))
- Support function declarations without id in `attachScopes` ([#28](https://github.com/rollup/rollup-pluginutils/issues/28))
## 2.0.1
_2017-01-03_
- Don't add extension to file with trailing dot ([#14](https://github.com/rollup/rollup-pluginutils/issues/14))
## 2.0.0
_2017-01-03_
- Use `micromatch` instead of `minimatch` ([#19](https://github.com/rollup/rollup-pluginutils/issues/19))
- Allow `createFilter` to take regexes ([#5](https://github.com/rollup/rollup-pluginutils/issues/5))
## 1.5.2
_2016-08-29_
- Treat `arguments` as a reserved word ([#10](https://github.com/rollup/rollup-pluginutils/issues/10))
## 1.5.1
_2016-06-24_
- Add all declarators in a var declaration to scope, not just the first
## 1.5.0
_2016-06-07_
- Exclude IDs with null character (`\0`)
## 1.4.0
_2016-06-07_
- Workaround minimatch issue ([#6](https://github.com/rollup/rollup-pluginutils/pull/6))
- Exclude non-string IDs in `createFilter`
## 1.3.1
_2015-12-16_
- Build with Rollup directly, rather than via Gobble
## 1.3.0
_2015-12-16_
- Use correct path separator on Windows
## 1.2.0
_2015-11-02_
- Add `attachScopes` and `makeLegalIdentifier`
## 1.1.0
2015-10-24\*
- Add `addExtension` function
## 1.0.1
_2015-10-24_
- Include dist files in package
## 1.0.0
_2015-10-24_
- First release
The MIT License (MIT)
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/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.
[npm]: https://img.shields.io/npm/v/@rollup/pluginutils
[npm-url]: https://www.npmjs.com/package/@rollup/pluginutils
[size]: https://packagephobia.now.sh/badge?p=@rollup/pluginutils
[size-url]: https://packagephobia.now.sh/result?p=@rollup/pluginutils
[![npm][npm]][npm-url]
[![size][size]][size-url]
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)
# @rollup/pluginutils
A set of utility functions commonly used by 🍣 Rollup plugins.
## Requirements
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+.
## Install
Using npm:
```console
npm install @rollup/pluginutils --save-dev
```
## Usage
```js
import utils from '@rollup/pluginutils';
//...
```
## API
Available utility functions are listed below:
_Note: Parameter names immediately followed by a `?` indicate that the parameter is optional._
### addExtension
Adds an extension to a module ID if one does not exist.
Parameters: `(filename: String, ext?: String)`<br>
Returns: `String`
```js
import { addExtension } from '@rollup/pluginutils';
export default function myPlugin(options = {}) {
return {
resolveId(code, id) {
// only adds an extension if there isn't one already
id = addExtension(id); // `foo` -> `foo.js`, `foo.js -> foo.js`
id = addExtension(id, '.myext'); // `foo` -> `foo.myext`, `foo.js -> `foo.js`
}
};
}
```
### attachScopes
Attaches `Scope` objects to the relevant nodes of an AST. Each `Scope` object has a `scope.contains(name)` method that returns `true` if a given name is defined in the current scope or a parent scope.
Parameters: `(ast: Node, propertyName?: String)`<br>
Returns: `Object`
See [rollup-plugin-inject](https://github.com/rollup/rollup-plugin-inject) or [rollup-plugin-commonjs](https://github.com/rollup/rollup-plugin-commonjs) for an example of usage.
```js
import { attachScopes } from '@rollup/pluginutils';
import { walk } from 'estree-walker';
export default function myPlugin(options = {}) {
return {
transform(code) {
const ast = this.parse(code);
let scope = attachScopes(ast, 'scope');
walk(ast, {
enter(node) {
if (node.scope) scope = node.scope;
if (!scope.contains('foo')) {
// `foo` is not defined, so if we encounter it,
// we assume it's a global
}
},
leave(node) {
if (node.scope) scope = scope.parent;
}
});
}
};
}
```
### createFilter
Constructs a filter function which can be used to determine whether or not certain modules should be operated upon.
Parameters: `(include?: <minmatch>, exclude?: <minmatch>, options?: Object)`<br>
Returns: `String`
#### `include` and `exclude`
Type: `String | RegExp | Array[...String|RegExp]`<br>
A valid [`minimatch`](https://www.npmjs.com/package/minimatch) pattern, or array of patterns. If `options.include` is omitted or has zero length, filter will return `true` by default. Otherwise, an ID must match one or more of the `minimatch` patterns, and must not match any of the `options.exclude` patterns.
#### `options`
##### `resolve`
Type: `String | Boolean | null`
Optionally resolves the patterns against a directory other than `process.cwd()`. If a `String` is specified, then the value will be used as the base directory. Relative paths will be resolved against `process.cwd()` first. If `false`, then the patterns will not be resolved against any directory. This can be useful if you want to create a filter for virtual module names.
#### Usage
```js
import { createFilter } from '@rollup/pluginutils';
export default function myPlugin(options = {}) {
// assume that the myPlugin accepts options of `options.include` and `options.exclude`
var filter = createFilter(options.include, options.exclude, {
resolve: '/my/base/dir'
});
return {
transform(code, id) {
if (!filter(id)) return;
// proceed with the transformation...
}
};
}
```
### dataToEsm
Transforms objects into tree-shakable ES Module imports.
Parameters: `(data: Object)`<br>
Returns: `String`
#### `data`
Type: `Object`
An object to transform into an ES module.
#### Usage
```js
import { dataToEsm } from '@rollup/pluginutils';
const esModuleSource = dataToEsm(
{
custom: 'data',
to: ['treeshake']
},
{
compact: false,
indent: '\t',
preferConst: false,
objectShorthand: false,
namedExports: true
}
);
/*
Outputs the string ES module source:
export const custom = 'data';
export const to = ['treeshake'];
export default { custom, to };
*/
```
### extractAssignedNames
Extracts the names of all assignment targets based upon specified patterns.
Parameters: `(param: Node)`<br>
Returns: `Array[...String]`
#### `param`
Type: `Node`
An `acorn` AST Node.
#### Usage
```js
import { extractAssignedNames } from '@rollup/pluginutils';
import { walk } from 'estree-walker';
export default function myPlugin(options = {}) {
return {
transform(code) {
const ast = this.parse(code);
walk(ast, {
enter(node) {
if (node.type === 'VariableDeclarator') {
const declaredNames = extractAssignedNames(node.id);
// do something with the declared names
// e.g. for `const {x, y: z} = ... => declaredNames = ['x', 'z']
}
}
});
}
};
}
```
### makeLegalIdentifier
Constructs a bundle-safe identifier from a `String`.
Parameters: `(str: String)`<br>
Returns: `String`
#### Usage
```js
import { makeLegalIdentifier } from '@rollup/pluginutils';
makeLegalIdentifier('foo-bar'); // 'foo_bar'
makeLegalIdentifier('typeof'); // '_typeof'
```
## Meta
[CONTRIBUTING](/.github/CONTRIBUTING.md)
[LICENSE (MIT)](/LICENSE)
{"type":"module"}
\ No newline at end of file
# changelog
## 1.0.1
* Relax node type to `BaseNode` ([#17](https://github.com/Rich-Harris/estree-walker/pull/17))
## 1.0.0
* Don't cache child keys
## 0.9.0
* Add `this.remove()` method
## 0.8.1
* Fix pkg.files
## 0.8.0
* Adopt `estree` types
## 0.7.0
* Add a `this.replace(node)` method
## 0.6.1
* Only traverse nodes that exist and have a type ([#9](https://github.com/Rich-Harris/estree-walker/pull/9))
* Only cache keys for nodes with a type ([#8](https://github.com/Rich-Harris/estree-walker/pull/8))
## 0.6.0
* Fix walker context type
* Update deps, remove unncessary Bublé transformation
## 0.5.2
* Add types to package
## 0.5.1
* Prevent context corruption when `walk()` is called during a walk
## 0.5.0
* Export `childKeys`, for manually fixing in case of malformed ASTs
## 0.4.0
* Add TypeScript typings ([#3](https://github.com/Rich-Harris/estree-walker/pull/3))
## 0.3.1
* Include `pkg.repository` ([#2](https://github.com/Rich-Harris/estree-walker/pull/2))
## 0.3.0
* More predictable ordering
## 0.2.1
* Keep `context` shape
## 0.2.0
* Add ES6 build
## 0.1.3
* npm snafu
## 0.1.2
* Pass current prop and index to `enter`/`leave` callbacks
## 0.1.1
* First release
# estree-walker
Simple utility for walking an [ESTree](https://github.com/estree/estree)-compliant AST, such as one generated by [acorn](https://github.com/marijnh/acorn).
## Installation
```bash
npm i estree-walker
```
## Usage
```js
var walk = require( 'estree-walker' ).walk;
var acorn = require( 'acorn' );
ast = acorn.parse( sourceCode, options ); // https://github.com/acornjs/acorn
walk( ast, {
enter: function ( node, parent, prop, index ) {
// some code happens
},
leave: function ( node, parent, prop, index ) {
// some code happens
}
});
```
Inside the `enter` function, calling `this.skip()` will prevent the node's children being walked, or the `leave` function (which is optional) being called.
Call `this.replace(new_node)` in either `enter` or `leave` to replace the current node with a new one.
Call `this.remove()` in either `enter` or `leave` to remove the current node.
## Why not use estraverse?
The ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where [estraverse](https://github.com/estools/estraverse) was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys.
estree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.)
None of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful.
## License
MIT
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.estreeWalker = {})));
}(this, (function (exports) { 'use strict';
function walk(ast, { enter, leave }) {
return visit(ast, null, enter, leave);
}
let should_skip = false;
let should_remove = false;
let replacement = null;
const context = {
skip: () => should_skip = true,
remove: () => should_remove = true,
replace: (node) => replacement = node
};
function replace(parent, prop, index, node) {
if (parent) {
if (index !== null) {
parent[prop][index] = node;
} else {
parent[prop] = node;
}
}
}
function remove(parent, prop, index) {
if (parent) {
if (index !== null) {
parent[prop].splice(index, 1);
} else {
delete parent[prop];
}
}
}
function visit(
node,
parent,
enter,
leave,
prop,
index
) {
if (node) {
if (enter) {
const _should_skip = should_skip;
const _should_remove = should_remove;
const _replacement = replacement;
should_skip = false;
should_remove = false;
replacement = null;
enter.call(context, node, parent, prop, index);
if (replacement) {
node = replacement;
replace(parent, prop, index, node);
}
if (should_remove) {
remove(parent, prop, index);
}
const skipped = should_skip;
const removed = should_remove;
should_skip = _should_skip;
should_remove = _should_remove;
replacement = _replacement;
if (skipped) return node;
if (removed) return null;
}
for (const key in node) {
const value = (node )[key];
if (typeof value !== 'object') {
continue;
}
else if (Array.isArray(value)) {
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
if (value[j] !== null && typeof value[j].type === 'string') {
if (!visit(value[j], node, enter, leave, key, k)) {
// removed
j--;
}
}
}
}
else if (value !== null && typeof value.type === 'string') {
visit(value, node, enter, leave, key, null);
}
}
if (leave) {
const _replacement = replacement;
const _should_remove = should_remove;
replacement = null;
should_remove = false;
leave.call(context, node, parent, prop, index);
if (replacement) {
node = replacement;
replace(parent, prop, index, node);
}
if (should_remove) {
remove(parent, prop, index);
}
const removed = should_remove;
replacement = _replacement;
should_remove = _should_remove;
if (removed) return null;
}
}
return node;
}
exports.walk = walk;
Object.defineProperty(exports, '__esModule', { value: true });
})));
{"version":3,"file":"estree-walker.umd.js","sources":["../src/estree-walker.js"],"sourcesContent":["export function walk(ast, { enter, leave }) {\n\tvisit(ast, null, enter, leave);\n}\n\nlet shouldSkip = false;\nconst context = { skip: () => shouldSkip = true };\n\nexport const childKeys = {};\n\nconst toString = Object.prototype.toString;\n\nfunction isArray(thing) {\n\treturn toString.call(thing) === '[object Array]';\n}\n\nfunction visit(node, parent, enter, leave, prop, index) {\n\tif (!node) return;\n\n\tif (enter) {\n\t\tconst _shouldSkip = shouldSkip;\n\t\tshouldSkip = false;\n\t\tenter.call(context, node, parent, prop, index);\n\t\tconst skipped = shouldSkip;\n\t\tshouldSkip = _shouldSkip;\n\n\t\tif (skipped) return;\n\t}\n\n\tconst keys = childKeys[node.type] || (\n\t\tchildKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object')\n\t);\n\n\tfor (let i = 0; i < keys.length; i += 1) {\n\t\tconst key = keys[i];\n\t\tconst value = node[key];\n\n\t\tif (isArray(value)) {\n\t\t\tfor (let j = 0; j < value.length; j += 1) {\n\t\t\t\tvisit(value[j], node, enter, leave, key, j);\n\t\t\t}\n\t\t}\n\n\t\telse if (value && value.type) {\n\t\t\tvisit(value, node, enter, leave, key, null);\n\t\t}\n\t}\n\n\tif (leave) {\n\t\tleave(node, parent, prop, index);\n\t}\n}\n"],"names":[],"mappings":";;;;;;CAAO,SAAS,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;CAC5C,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;CAChC,CAAC;;CAED,IAAI,UAAU,GAAG,KAAK,CAAC;CACvB,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,GAAG,IAAI,EAAE,CAAC;;AAElD,AAAY,OAAC,SAAS,GAAG,EAAE,CAAC;;CAE5B,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;;CAE3C,SAAS,OAAO,CAAC,KAAK,EAAE;CACxB,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,gBAAgB,CAAC;CAClD,CAAC;;CAED,SAAS,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;CACxD,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO;;CAEnB,CAAC,IAAI,KAAK,EAAE;CACZ,EAAE,MAAM,WAAW,GAAG,UAAU,CAAC;CACjC,EAAE,UAAU,GAAG,KAAK,CAAC;CACrB,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;CACjD,EAAE,MAAM,OAAO,GAAG,UAAU,CAAC;CAC7B,EAAE,UAAU,GAAG,WAAW,CAAC;;CAE3B,EAAE,IAAI,OAAO,EAAE,OAAO;CACtB,EAAE;;CAEF,CAAC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;CAClC,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC;CACvF,EAAE,CAAC;;CAEH,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;CAC1C,EAAE,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CACtB,EAAE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;;CAE1B,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;CACtB,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;CAC7C,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;CAChD,IAAI;CACJ,GAAG;;CAEH,OAAO,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE;CAChC,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;CAC/C,GAAG;CACH,EAAE;;CAEF,CAAC,IAAI,KAAK,EAAE;CACZ,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;CACnC,EAAE;CACF,CAAC;;;;;;;;;;;;;"}
\ No newline at end of file
{
"name": "estree-walker",
"description": "Traverse an ESTree-compliant AST",
"version": "1.0.1",
"author": "Rich Harris",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/Rich-Harris/estree-walker"
},
"main": "dist/estree-walker.umd.js",
"module": "src/estree-walker.js",
"types": "types/index.d.ts",
"scripts": {
"prepublishOnly": "npm run build && npm test",
"build": "tsc && rollup -c",
"test": "mocha --opts mocha.opts"
},
"devDependencies": {
"@types/estree": "0.0.39",
"mocha": "^5.2.0",
"rollup": "^0.67.3",
"rollup-plugin-sucrase": "^2.1.0",
"typescript": "^3.6.3"
},
"files": [
"src",
"dist",
"types",
"README.md"
]
}
function walk(ast, { enter, leave }) {
return visit(ast, null, enter, leave);
}
let should_skip = false;
let should_remove = false;
let replacement = null;
const context = {
skip: () => should_skip = true,
remove: () => should_remove = true,
replace: (node) => replacement = node
};
function replace(parent, prop, index, node) {
if (parent) {
if (index !== null) {
parent[prop][index] = node;
} else {
parent[prop] = node;
}
}
}
function remove(parent, prop, index) {
if (parent) {
if (index !== null) {
parent[prop].splice(index, 1);
} else {
delete parent[prop];
}
}
}
function visit(
node,
parent,
enter,
leave,
prop,
index
) {
if (node) {
if (enter) {
const _should_skip = should_skip;
const _should_remove = should_remove;
const _replacement = replacement;
should_skip = false;
should_remove = false;
replacement = null;
enter.call(context, node, parent, prop, index);
if (replacement) {
node = replacement;
replace(parent, prop, index, node);
}
if (should_remove) {
remove(parent, prop, index);
}
const skipped = should_skip;
const removed = should_remove;
should_skip = _should_skip;
should_remove = _should_remove;
replacement = _replacement;
if (skipped) return node;
if (removed) return null;
}
for (const key in node) {
const value = (node )[key];
if (typeof value !== 'object') {
continue;
}
else if (Array.isArray(value)) {
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
if (value[j] !== null && typeof value[j].type === 'string') {
if (!visit(value[j], node, enter, leave, key, k)) {
// removed
j--;
}
}
}
}
else if (value !== null && typeof value.type === 'string') {
visit(value, node, enter, leave, key, null);
}
}
if (leave) {
const _replacement = replacement;
const _should_remove = should_remove;
replacement = null;
should_remove = false;
leave.call(context, node, parent, prop, index);
if (replacement) {
node = replacement;
replace(parent, prop, index, node);
}
if (should_remove) {
remove(parent, prop, index);
}
const removed = should_remove;
replacement = _replacement;
should_remove = _should_remove;
if (removed) return null;
}
}
return node;
}
export { walk };
import { BaseNode } from "estree";
type WalkerContext = {
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
};
type WalkerHandler = (
this: WalkerContext,
node: BaseNode,
parent: BaseNode,
key: string,
index: number
) => void
type Walker = {
enter?: WalkerHandler;
leave?: WalkerHandler;
}
export function walk(ast: BaseNode, { enter, leave }: Walker) {
return visit(ast, null, enter, leave);
}
let should_skip = false;
let should_remove = false;
let replacement: BaseNode = null;
const context: WalkerContext = {
skip: () => should_skip = true,
remove: () => should_remove = true,
replace: (node: BaseNode) => replacement = node
};
function replace(parent: any, prop: string, index: number, node: BaseNode) {
if (parent) {
if (index !== null) {
parent[prop][index] = node;
} else {
parent[prop] = node;
}
}
}
function remove(parent: any, prop: string, index: number) {
if (parent) {
if (index !== null) {
parent[prop].splice(index, 1);
} else {
delete parent[prop];
}
}
}
function visit(
node: BaseNode,
parent: BaseNode,
enter: WalkerHandler,
leave: WalkerHandler,
prop?: string,
index?: number
) {
if (node) {
if (enter) {
const _should_skip = should_skip;
const _should_remove = should_remove;
const _replacement = replacement;
should_skip = false;
should_remove = false;
replacement = null;
enter.call(context, node, parent, prop, index);
if (replacement) {
node = replacement;
replace(parent, prop, index, node);
}
if (should_remove) {
remove(parent, prop, index);
}
const skipped = should_skip;
const removed = should_remove;
should_skip = _should_skip;
should_remove = _should_remove;
replacement = _replacement;
if (skipped) return node;
if (removed) return null;
}
for (const key in node) {
const value = (node as any)[key];
if (typeof value !== 'object') {
continue;
}
else if (Array.isArray(value)) {
for (let j = 0, k = 0; j < value.length; j += 1, k += 1) {
if (value[j] !== null && typeof value[j].type === 'string') {
if (!visit(value[j], node, enter, leave, key, k)) {
// removed
j--;
}
}
}
}
else if (value !== null && typeof value.type === 'string') {
visit(value, node, enter, leave, key, null);
}
}
if (leave) {
const _replacement = replacement;
const _should_remove = should_remove;
replacement = null;
should_remove = false;
leave.call(context, node, parent, prop, index);
if (replacement) {
node = replacement;
replace(parent, prop, index, node);
}
if (should_remove) {
remove(parent, prop, index);
}
const removed = should_remove;
replacement = _replacement;
should_remove = _should_remove;
if (removed) return null;
}
}
return node;
}
import { BaseNode } from "estree";
declare type WalkerContext = {
skip: () => void;
remove: () => void;
replace: (node: BaseNode) => void;
};
declare type WalkerHandler = (this: WalkerContext, node: BaseNode, parent: BaseNode, key: string, index: number) => void;
declare type Walker = {
enter?: WalkerHandler;
leave?: WalkerHandler;
};
export declare function walk(ast: BaseNode, { enter, leave }: Walker): BaseNode;
export {};
{
"name": "@rollup/pluginutils",
"version": "3.1.0",
"publishConfig": {
"access": "public"
},
"description": "A set of utility functions commonly used by Rollup plugins",
"license": "MIT",
"repository": "rollup/plugins",
"author": "Rich Harris <richard.a.harris@gmail.com>",
"homepage": "https://github.com/rollup/plugins/tree/master/packages/pluginutils#readme",
"bugs": {
"url": "https://github.com/rollup/plugins/issues"
},
"main": "./dist/cjs/index.js",
"engines": {
"node": ">= 8.0.0"
},
"scripts": {
"build": "rollup -c",
"ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov",
"ci:lint": "pnpm run build && pnpm run lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test types --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
"prepublishOnly": "pnpm run lint && pnpm run build",
"pretest": "pnpm run build -- --sourcemap",
"test": "ava"
},
"files": [
"dist",
"types",
"README.md",
"LICENSE"
],
"keywords": [
"rollup",
"plugin",
"utils"
],
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0"
},
"dependencies": {
"@types/estree": "0.0.39",
"estree-walker": "^1.0.1",
"picomatch": "^2.2.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-typescript": "^3.0.0",
"@types/jest": "^24.9.0",
"@types/node": "^12.12.25",
"@types/picomatch": "^2.2.1",
"typescript": "^3.7.5"
},
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
],
"files": [
"!**/fixtures/**",
"!**/helpers/**",
"!**/recipes/**",
"!**/types.ts"
]
},
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
},
"module": "./dist/es/index.js",
"nyc": {
"extension": [
".js",
".ts"
]
},
"type": "commonjs",
"types": "types/index.d.ts"
}
// eslint-disable-next-line import/no-unresolved
import { BaseNode } from 'estree';
export interface AttachedScope {
parent?: AttachedScope;
isBlockScope: boolean;
declarations: { [key: string]: boolean };
addDeclaration(node: BaseNode, isBlockDeclaration: boolean, isVar: boolean): void;
contains(name: string): boolean;
}
export interface DataToEsmOptions {
compact?: boolean;
indent?: string;
namedExports?: boolean;
objectShorthand?: boolean;
preferConst?: boolean;
}
/**
* A valid `minimatch` pattern, or array of patterns.
*/
export type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
/**
* Adds an extension to a module ID if one does not exist.
*/
export function addExtension(filename: string, ext?: string): string;
/**
* Attaches `Scope` objects to the relevant nodes of an AST.
* Each `Scope` object has a `scope.contains(name)` method that returns `true`
* if a given name is defined in the current scope or a parent scope.
*/
export function attachScopes(ast: BaseNode, propertyName?: string): AttachedScope;
/**
* Constructs a filter function which can be used to determine whether or not
* certain modules should be operated upon.
* @param include If `include` is omitted or has zero length, filter will return `true` by default.
* @param exclude ID must not match any of the `exclude` patterns.
* @param options Optionally resolves the patterns against a directory other than `process.cwd()`.
* If a `string` is specified, then the value will be used as the base directory.
* Relative paths will be resolved against `process.cwd()` first.
* If `false`, then the patterns will not be resolved against any directory.
* This can be useful if you want to create a filter for virtual module names.
*/
export function createFilter(
include?: FilterPattern,
exclude?: FilterPattern,
options?: { resolve?: string | false | null }
): (id: string | unknown) => boolean;
/**
* Transforms objects into tree-shakable ES Module imports.
* @param data An object to transform into an ES module.
*/
export function dataToEsm(data: unknown, options?: DataToEsmOptions): string;
/**
* Extracts the names of all assignment targets based upon specified patterns.
* @param param An `acorn` AST Node.
*/
export function extractAssignedNames(param: BaseNode): string[];
/**
* Constructs a bundle-safe identifier from a `string`.
*/
export function makeLegalIdentifier(str: string): string;
export type AddExtension = typeof addExtension;
export type AttachScopes = typeof attachScopes;
export type CreateFilter = typeof createFilter;
export type ExtractAssignedNames = typeof extractAssignedNames;
export type MakeLegalIdentifier = typeof makeLegalIdentifier;
export type DataToEsm = typeof dataToEsm;
declare const defaultExport: {
addExtension: AddExtension;
attachScopes: AttachScopes;
createFilter: CreateFilter;
dataToEsm: DataToEsm;
extractAssignedNames: ExtractAssignedNames;
makeLegalIdentifier: MakeLegalIdentifier;
};
export default defaultExport;
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
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
# Installation
> `npm install --save @types/estree`
# Summary
This package contains type definitions for ESTree AST specification (https://github.com/estree/estree).
# Details
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree
Additional Details
* Last updated: Tue, 17 Apr 2018 20:22:09 GMT
* Dependencies: none
* Global values: none
# Credits
These definitions were written by RReverser <https://github.com/RReverser>.
{
"name": "@types/estree",
"version": "0.0.39",
"description": "TypeScript definitions for ESTree AST specification",
"license": "MIT",
"contributors": [
{
"name": "RReverser",
"url": "https://github.com/RReverser",
"githubUsername": "RReverser"
}
],
"main": "",
"repository": {
"type": "git",
"url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git"
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "427ba878ebb5570e15aab870f708720d146a1c4b272e4a9d9990db4d1d033170",
"typeScriptVersion": "2.0"
}
\ No newline at end of file
tidelift: "npm/balanced-match"
patreon: juliangruber
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
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.
# balanced-match
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
## Example
Get the first matching pair of braces:
```js
var balanced = require('balanced-match');
console.log(balanced('{', '}', 'pre{in{nested}}post'));
console.log(balanced('{', '}', 'pre{first}between{second}post'));
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
```
The matches are:
```bash
$ node example.js
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
{ start: 3,
end: 9,
pre: 'pre',
body: 'first',
post: 'between{second}post' }
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
```
## API
### var m = balanced(a, b, str)
For the first non-nested matching pair of `a` and `b` in `str`, return an
object with those keys:
* **start** the index of the first match of `a`
* **end** the index of the matching `b`
* **pre** the preamble, `a` and `b` not included
* **body** the match, `a` and `b` not included
* **post** the postscript, `a` and `b` not included
If there's no match, `undefined` will be returned.
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
### var r = balanced.range(a, b, str)
For the first non-nested matching pair of `a` and `b` in `str`, return an
array with indexes: `[ <a index>, <b index> ]`.
If there's no match, `undefined` will be returned.
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
## Installation
With [npm](https://npmjs.org) do:
```bash
npm install balanced-match
```
## Security contact information
To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
## License
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
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.
'use strict';
module.exports = balanced;
function balanced(a, b, str) {
if (a instanceof RegExp) a = maybeMatch(a, str);
if (b instanceof RegExp) b = maybeMatch(b, str);
var r = range(a, b, str);
return r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + a.length, r[1]),
post: str.slice(r[1] + b.length)
};
}
function maybeMatch(reg, str) {
var m = str.match(reg);
return m ? m[0] : null;
}
balanced.range = range;
function range(a, b, str) {
var begs, beg, left, right, result;
var ai = str.indexOf(a);
var bi = str.indexOf(b, ai + 1);
var i = ai;
if (ai >= 0 && bi > 0) {
if(a===b) {
return [ai, bi];
}
begs = [];
left = str.length;
while (i >= 0 && !result) {
if (i == ai) {
begs.push(i);
ai = str.indexOf(a, i + 1);
} else if (begs.length == 1) {
result = [ begs.pop(), bi ];
} else {
beg = begs.pop();
if (beg < left) {
left = beg;
right = bi;
}
bi = str.indexOf(b, i + 1);
}
i = ai < bi && ai >= 0 ? ai : bi;
}
if (begs.length) {
result = [ left, right ];
}
}
return result;
}
{
"name": "balanced-match",
"description": "Match balanced character pairs, like \"{\" and \"}\"",
"version": "1.0.2",
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/balanced-match.git"
},
"homepage": "https://github.com/juliangruber/balanced-match",
"main": "index.js",
"scripts": {
"test": "tape test/test.js",
"bench": "matcha test/bench.js"
},
"devDependencies": {
"matcha": "^0.7.0",
"tape": "^4.6.0"
},
"keywords": [
"match",
"regexp",
"test",
"balanced",
"parse"
],
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
"url": "http://juliangruber.com"
},
"license": "MIT",
"testling": {
"files": "test/*.js",
"browsers": [
"ie/8..latest",
"firefox/20..latest",
"firefox/nightly",
"chrome/25..latest",
"chrome/canary",
"opera/12..latest",
"opera/next",
"safari/5.1..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2..latest"
]
}
}
MIT License
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
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.
# brace-expansion
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
as known from sh/bash, in JavaScript.
[![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
[![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/)
[![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)
## Example
```js
var expand = require('brace-expansion');
expand('file-{a,b,c}.jpg')
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
expand('-v{,,}')
// => ['-v', '-v', '-v']
expand('file{0..2}.jpg')
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
expand('file-{a..c}.jpg')
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
expand('file{2..0}.jpg')
// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
expand('file{0..4..2}.jpg')
// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
expand('file-{a..e..2}.jpg')
// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
expand('file{00..10..5}.jpg')
// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
expand('{{A..C},{a..c}}')
// => ['A', 'B', 'C', 'a', 'b', 'c']
expand('ppp{,config,oe{,conf}}')
// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
```
## API
```js
var expand = require('brace-expansion');
```
### var expanded = expand(str)
Return an array of all possible and valid expansions of `str`. If none are
found, `[str]` is returned.
Valid expansions are:
```js
/^(.*,)+(.+)?$/
// {a,b,...}
```
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
```js
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
// {x..y[..incr]}
```
A numeric sequence from `x` to `y` inclusive, with optional increment.
If `x` or `y` start with a leading `0`, all the numbers will be padded
to have equal length. Negative numbers and backwards iteration work too.
```js
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
// {x..y[..incr]}
```
An alphabetic sequence from `x` to `y` inclusive, with optional increment.
`x` and `y` must be exactly one character, and if given, `incr` must be a
number.
For compatibility reasons, the string `${` is not eligible for brace expansion.
## Installation
With [npm](https://npmjs.org) do:
```bash
npm install brace-expansion
```
## Contributors
- [Julian Gruber](https://github.com/juliangruber)
- [Isaac Z. Schlueter](https://github.com/isaacs)
## Sponsors
This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
## License
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
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.
var concatMap = require('concat-map');
var balanced = require('balanced-match');
module.exports = expandTop;
var escSlash = '\0SLASH'+Math.random()+'\0';
var escOpen = '\0OPEN'+Math.random()+'\0';
var escClose = '\0CLOSE'+Math.random()+'\0';
var escComma = '\0COMMA'+Math.random()+'\0';
var escPeriod = '\0PERIOD'+Math.random()+'\0';
function numeric(str) {
return parseInt(str, 10) == str
? parseInt(str, 10)
: str.charCodeAt(0);
}
function escapeBraces(str) {
return str.split('\\\\').join(escSlash)
.split('\\{').join(escOpen)
.split('\\}').join(escClose)
.split('\\,').join(escComma)
.split('\\.').join(escPeriod);
}
function unescapeBraces(str) {
return str.split(escSlash).join('\\')
.split(escOpen).join('{')
.split(escClose).join('}')
.split(escComma).join(',')
.split(escPeriod).join('.');
}
// Basically just str.split(","), but handling cases
// where we have nested braced sections, which should be
// treated as individual members, like {a,{b,c},d}
function parseCommaParts(str) {
if (!str)
return [''];
var parts = [];
var m = balanced('{', '}', str);
if (!m)
return str.split(',');
var pre = m.pre;
var body = m.body;
var post = m.post;
var p = pre.split(',');
p[p.length-1] += '{' + body + '}';
var postParts = parseCommaParts(post);
if (post.length) {
p[p.length-1] += postParts.shift();
p.push.apply(p, postParts);
}
parts.push.apply(parts, p);
return parts;
}
function expandTop(str) {
if (!str)
return [];
// I don't know why Bash 4.3 does this, but it does.
// Anything starting with {} will have the first two bytes preserved
// but *only* at the top level, so {},a}b will not expand to anything,
// but a{},b}c will be expanded to [a}c,abc].
// One could argue that this is a bug in Bash, but since the goal of
// this module is to match Bash's rules, we escape a leading {}
if (str.substr(0, 2) === '{}') {
str = '\\{\\}' + str.substr(2);
}
return expand(escapeBraces(str), true).map(unescapeBraces);
}
function identity(e) {
return e;
}
function embrace(str) {
return '{' + str + '}';
}
function isPadded(el) {
return /^-?0\d/.test(el);
}
function lte(i, y) {
return i <= y;
}
function gte(i, y) {
return i >= y;
}
function expand(str, isTop) {
var expansions = [];
var m = balanced('{', '}', str);
if (!m || /\$$/.test(m.pre)) return [str];
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
var isSequence = isNumericSequence || isAlphaSequence;
var isOptions = m.body.indexOf(',') >= 0;
if (!isSequence && !isOptions) {
// {a},b}
if (m.post.match(/,.*\}/)) {
str = m.pre + '{' + m.body + escClose + m.post;
return expand(str);
}
return [str];
}
var n;
if (isSequence) {
n = m.body.split(/\.\./);
} else {
n = parseCommaParts(m.body);
if (n.length === 1) {
// x{{a,b}}y ==> x{a}y x{b}y
n = expand(n[0], false).map(embrace);
if (n.length === 1) {
var post = m.post.length
? expand(m.post, false)
: [''];
return post.map(function(p) {
return m.pre + n[0] + p;
});
}
}
}
// at this point, n is the parts, and we know it's not a comma set
// with a single entry.
// no need to expand pre, since it is guaranteed to be free of brace-sets
var pre = m.pre;
var post = m.post.length
? expand(m.post, false)
: [''];
var N;
if (isSequence) {
var x = numeric(n[0]);
var y = numeric(n[1]);
var width = Math.max(n[0].length, n[1].length)
var incr = n.length == 3
? Math.abs(numeric(n[2]))
: 1;
var test = lte;
var reverse = y < x;
if (reverse) {
incr *= -1;
test = gte;
}
var pad = n.some(isPadded);
N = [];
for (var i = x; test(i, y); i += incr) {
var c;
if (isAlphaSequence) {
c = String.fromCharCode(i);
if (c === '\\')
c = '';
} else {
c = String(i);
if (pad) {
var need = width - c.length;
if (need > 0) {
var z = new Array(need + 1).join('0');
if (i < 0)
c = '-' + z + c.slice(1);
else
c = z + c;
}
}
}
N.push(c);
}
} else {
N = concatMap(n, function(el) { return expand(el, false) });
}
for (var j = 0; j < N.length; j++) {
for (var k = 0; k < post.length; k++) {
var expansion = pre + N[j] + post[k];
if (!isTop || isSequence || expansion)
expansions.push(expansion);
}
}
return expansions;
}
No preview for this file type
This diff could not be displayed because it is too large.
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!