feat: init omix typescript version

This commit is contained in:
dntzhang 2019-10-04 09:56:50 +08:00
parent d0aac946eb
commit 51720771aa
28 changed files with 20436 additions and 0 deletions

View File

@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
App({
onLaunch: function () {
var _this = this;
var logs = wx.getStorageSync('logs') || [];
logs.unshift(Date.now());
wx.setStorageSync('logs', logs);
wx.login({
success: function (_res) {
}
});
wx.getSetting({
success: function (res) {
if (res.authSetting['scope.userInfo']) {
wx.getUserInfo({
success: function (res) {
_this.globalData.userInfo = res.userInfo;
if (_this.userInfoReadyCallback) {
_this.userInfoReadyCallback(res.userInfo);
}
}
});
}
}
});
},
globalData: {}
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiYXBwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBUUEsR0FBRyxDQUFTO0lBQ1YsUUFBUTtRQUFSLGlCQWdDQztRQTlCQyxJQUFJLElBQUksR0FBYSxFQUFFLENBQUMsY0FBYyxDQUFDLE1BQU0sQ0FBQyxJQUFJLEVBQUUsQ0FBQTtRQUNwRCxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUUsQ0FBQyxDQUFBO1FBQ3hCLEVBQUUsQ0FBQyxjQUFjLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxDQUFBO1FBRy9CLEVBQUUsQ0FBQyxLQUFLLENBQUM7WUFDUCxPQUFPLFlBQUMsSUFBSTtZQUdaLENBQUM7U0FDRixDQUFDLENBQUE7UUFFRixFQUFFLENBQUMsVUFBVSxDQUFDO1lBQ1osT0FBTyxFQUFFLFVBQUMsR0FBRztnQkFDWCxJQUFJLEdBQUcsQ0FBQyxXQUFXLENBQUMsZ0JBQWdCLENBQUMsRUFBRTtvQkFFckMsRUFBRSxDQUFDLFdBQVcsQ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biAgICAvLyDojrflj5bnlKjmiLfkv6Hmga9cbiAgICB3eC5nZXRTZXR0aW5nKHtcbiAgICAgIHN1Y2Nlc3M6IChyZXMpID0+IHtcbiAgICAgICAgaWYgKHJlcy5hdXRoU2V0dGluZ1snc2NvcGUudXNlckluZm8nXSkge1xuICAgICAgICAgIC8vIOW3sue7j+aOiOadg++8jOWPr+S7peebtOaOpeiwg+eUqCBnZXRVc2VySW5mbyDojrflj5blpLTlg4/mmLXnp7DvvIzkuI3kvJrlvLnmoYZcbiAgICAgICAgICB3eC5nZXRVc2VySW5mbyh7XG4gICAgICAgICAgICBzdWNjZXNzOiByZXMgPT4ge1xuICAgICAgICAgICAgICAvLyDlj6/ku6XlsIYgcmVzIOWPkemAgee7meWQjuWPsOino+eggeWHuiB1bmlvbklkXG4gICAgICAgICAgICAgIHRoaXMuZ2xvYmFsRGF0YS51c2VySW5mbyA9IHJlcy51c2VySW5mb1xuICAgICAgICAgICAgICAvLyDnlLHkuo4gZ2V0VXNlckluZm8g5piv572R57uc6K+35rGC77yM5Y+v6IO95Lya5ZyoIFBhZ2Uub25Mb2FkIOS5i+WQjuaJjei/lOWbnlxuICAgICAgICAgICAgICAvLyDmiYDku6XmraTlpITliqDlhaUgY2FsbGJhY2sg5Lul6Ziy5q2i6L+Z56eN5oOF5Ya1XG4gICAgICAgICAgICAgIGlmICh0aGlzLnVzZXJJbmZvUmVhZHlDYWxsYmFjaykge1xuICAgICAgICAgICAgICAgIHRoaXMudXNlckluZm9SZWFkeUNhbGxiYWNrKHJlcy51c2VySW5mbylcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9KVxuICB9LFxuICBnbG9iYWxEYXRhOiB7XG4gIH1cbn0pIl19

View File

@ -0,0 +1,13 @@
{
"pages": [
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json"
}

View File

@ -0,0 +1,45 @@
//app.ts
export interface IMyApp {
userInfoReadyCallback?(res: wx.UserInfo): void
globalData: {
userInfo?: wx.UserInfo
}
}
App<IMyApp>({
onLaunch() {
// 展示本地存储能力
var logs: number[] = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success(_res) {
// console.log(_res.code)
// 发送 _res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: (res) => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res.userInfo)
}
}
})
}
}
})
},
globalData: {
}
})

View File

@ -0,0 +1,10 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}

View File

@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var app = getApp();
Page({
data: {
motto: '点击 “编译” 以构建',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
},
bindViewTap: function () {
wx.navigateTo({
url: '../logs/logs'
});
},
onLoad: function () {
var _this = this;
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true,
});
}
else if (this.data.canIUse) {
app.userInfoReadyCallback = function (res) {
_this.setData({
userInfo: res,
hasUserInfo: true
});
};
}
else {
wx.getUserInfo({
success: function (res) {
app.globalData.userInfo = res.userInfo;
_this.setData({
userInfo: res.userInfo,
hasUserInfo: true
});
}
});
}
},
getUserInfo: function (e) {
console.log(e);
app.globalData.userInfo = e.detail.userInfo;
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
});
}
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUlBLElBQU0sR0FBRyxHQUFHLE1BQU0sRUFBVSxDQUFBO0FBRTVCLElBQUksQ0FBQztJQUNILElBQUksRUFBRTtRQUNKLEtBQUssRUFBRSxhQUFhO1FBQ3BCLFFBQVEsRUFBRSxFQUFFO1FBQ1osV0FBVyxFQUFFLEtBQUs7UUFDbEIsT0FBTyxFQUFFLEVBQUUsQ0FBQyxPQUFPLENBQUMsOEJBQThCLENBQUM7S0FDcEQ7SUFFRCxXQUFXO1FBQ1QsRUFBRSxDQUFDLFVBQVUsQ0FBQztZQUNaLEdBQUcsRUFBRSxjQUFjO1NBQ3BCLENBQUMsQ0FBQTtJQUNKLENBQUM7SUFDRCxNQUFNO1FBQU4saUJBMkJDO1FBMUJDLElBQUksR0FBRyxDQUFDLFVBQVUsQ0FBQyxRQUFRLEVBQUU7WUFDM0IsSUFBSSxDQUFDLE9BQVEsQ0FBQztnQkFDWixRQUFRLEVBQUUsR0FBRyxDQUFDLFVBQVUsQ0FBQyxRQUFRO2dCQUNqQyxXQUFXLEVBQUUsSUFBSTthQUNsQixDQUFDLENBQUE7U0FDSDthQUFNLElBQUksSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUM7WUFHM0IsR0FBRyxDQUFDLHFCQUFxQixHQUFHLFVBQUMsR0FBRztnQkFDOUIsS0FBSSxDQUFDLE9BQVEsQ0FBQztvQkFDWixRQUFRLEVBQUUsR0FBRztvQkFDYixXQUFXLEVBQUUsSUFBSTtpQkFDbEIsQ0FBQyxDQUFBO1lBQ0osQ0FBQyxDQUFBO1NBQ0Y7YUFBTTtZQU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ICBoYXNVc2VySW5mbzogdHJ1ZVxuICAgICAgICAgIH0pXG4gICAgICAgIH1cbiAgICAgIH0pXG4gICAgfVxuICB9LFxuXG4gIGdldFVzZXJJbmZvKGU6IGFueSkge1xuICAgIGNvbnNvbGUubG9nKGUpXG4gICAgYXBwLmdsb2JhbERhdGEudXNlckluZm8gPSBlLmRldGFpbC51c2VySW5mb1xuICAgIHRoaXMuc2V0RGF0YSEoe1xuICAgICAgdXNlckluZm86IGUuZGV0YWlsLnVzZXJJbmZvLFxuICAgICAgaGFzVXNlckluZm86IHRydWVcbiAgICB9KVxuICB9XG59KVxuIl19

View File

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

View File

@ -0,0 +1,57 @@
//index.js
//获取应用实例
import { IMyApp } from '../../app'
const app = getApp<IMyApp>()
Page({
data: {
motto: '点击 “编译” 以构建',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
},
//事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad() {
if (app.globalData.userInfo) {
this.setData!({
userInfo: app.globalData.userInfo,
hasUserInfo: true,
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = (res) => {
this.setData!({
userInfo: res,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData!({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
},
getUserInfo(e: any) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData!({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

View File

@ -0,0 +1,13 @@
<!--index.wxml-->
<view class="container">
<view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>

View File

@ -0,0 +1,21 @@
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
}
.usermotto {
margin-top: 200px;
}

View File

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var util_1 = require("../../utils/util");
Page({
data: {
logs: []
},
onLoad: function () {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(function (log) {
return util_1.formatTime(new Date(log));
})
});
},
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9ncy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImxvZ3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFDQSx5Q0FBNkM7QUFFN0MsSUFBSSxDQUFDO0lBQ0gsSUFBSSxFQUFFO1FBQ0osSUFBSSxFQUFFLEVBQWM7S0FDckI7SUFDRCxNQUFNO1FBQ0osSUFBSSxDQUFDLE9BQVEsQ0FBQztZQUNaLElBQUksRUFBRSxDQUFDLEVBQUUsQ0FBQyxjQUFjLENBQUMsTUFBTSxDQUFDLElBQUksRUFBRSxDQUFDLENBQUMsR0FBRyxDQUFDLFVBQUMsR0FBVztnQkFDdEQsT0FBTyxpQkFBVSxDQUFDLElBQUksSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDLENBQUE7WUFDbEMsQ0FBQyxDQUFDO1NBQ0gsQ0FBQyxDQUFBO0lBQ0osQ0FBQztDQUNGLENBQUMsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbIi8vbG9ncy5qc1xuaW1wb3J0IHsgZm9ybWF0VGltZSB9IGZyb20gJy4uLy4uL3V0aWxzL3V0aWwnXG5cblBhZ2Uoe1xuICBkYXRhOiB7XG4gICAgbG9nczogW10gYXMgc3RyaW5nW11cbiAgfSxcbiAgb25Mb2FkKCkge1xuICAgIHRoaXMuc2V0RGF0YSEoe1xuICAgICAgbG9nczogKHd4LmdldFN0b3JhZ2VTeW5jKCdsb2dzJykgfHwgW10pLm1hcCgobG9nOiBudW1iZXIpID0+IHtcbiAgICAgICAgcmV0dXJuIGZvcm1hdFRpbWUobmV3IERhdGUobG9nKSlcbiAgICAgIH0pXG4gICAgfSlcbiAgfSxcbn0pXG4iXX0=

View File

@ -0,0 +1,4 @@
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}

View File

@ -0,0 +1,15 @@
//logs.js
import { formatTime } from '../../utils/util'
Page({
data: {
logs: [] as string[]
},
onLoad() {
this.setData!({
logs: (wx.getStorageSync('logs') || []).map((log: number) => {
return formatTime(new Date(log))
})
})
},
})

View File

@ -0,0 +1,6 @@
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
</view>

View File

@ -0,0 +1,8 @@
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}

View File

@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}

View File

@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function formatTime(date) {
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':');
}
exports.formatTime = formatTime;
var formatNumber = function (n) {
var str = n.toString();
return str[1] ? str : '0' + str;
};
//# sourceMappingURL=data:application/json;base64,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yxDQUFBO0FBQ2pDLENBQUMsQ0FBQSIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBmb3JtYXRUaW1lKGRhdGU6IERhdGUpOiBzdHJpbmcge1xuICBjb25zdCB5ZWFyID0gZGF0ZS5nZXRGdWxsWWVhcigpXG4gIGNvbnN0IG1vbnRoID0gZGF0ZS5nZXRNb250aCgpICsgMVxuICBjb25zdCBkYXkgPSBkYXRlLmdldERhdGUoKVxuICBjb25zdCBob3VyID0gZGF0ZS5nZXRIb3VycygpXG4gIGNvbnN0IG1pbnV0ZSA9IGRhdGUuZ2V0TWludXRlcygpXG4gIGNvbnN0IHNlY29uZCA9IGRhdGUuZ2V0U2Vjb25kcygpXG5cbiAgcmV0dXJuIFt5ZWFyLCBtb250aCwgZGF5XS5tYXAoZm9ybWF0TnVtYmVyKS5qb2luKCcvJykgKyAnICcgKyBbaG91ciwgbWludXRlLCBzZWNvbmRdLm1hcChmb3JtYXROdW1iZXIpLmpvaW4oJzonKVxufVxuXG5jb25zdCBmb3JtYXROdW1iZXIgPSAobjogbnVtYmVyKSA9PiB7XG4gIGNvbnN0IHN0ciA9IG4udG9TdHJpbmcoKVxuICByZXR1cm4gc3RyWzFdID8gc3RyIDogJzAnICsgc3RyXG59XG4iXX0=

View File

@ -0,0 +1,15 @@
export function formatTime(date: Date): string {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatNumber = (n: number) => {
const str = n.toString()
return str[1] ? str : '0' + str
}

View File

@ -0,0 +1,11 @@
{
"name": "demo",
"version": "1.0.1",
"scripts": {
"compile": "./node_modules/typescript/bin/tsc",
"tsc": "node ./node_modules/typescript/lib/tsc.js"
},
"devDependencies": {
"typescript": "^3.3.3333"
}
}

View File

@ -0,0 +1,20 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"miniprogramRoot": "miniprogram/",
"compileType": "miniprogram",
"libVersion": "2.4.0",
"projectname": "omix-ts",
"scripts": {
"beforeCompile": "npm run tsc",
"beforePreview": "npm run tsc",
"beforeUpload": "npm run tsc"
},
"setting": {},
"appid": "wxfaf6dad43f57c6bd",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {}
}

View File

@ -0,0 +1,33 @@
{
"compilerOptions": {
"strictNullChecks": true,
"noImplicitAny": true,
"module": "CommonJS",
"target": "ES5",
"allowJs": false,
"experimentalDecorators": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"inlineSourceMap": true,
"inlineSources": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"removeComments": true,
"pretty": true,
"strictPropertyInitialization": true,
"typeRoots": [
"./typings"
]
},
"include": [
"./miniprogram/**/*.ts"
],
"exclude": [
"node_modules",
"miniprogram_dist",
"**/*.spec.ts"
]
}

12
packages/omix-ts/typings/index.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
/*! *****************************************************************************
Copyright (c) 2018 Tencent, Inc. 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.
***************************************************************************** */
/// <reference path="./lib.wa.es6.d.ts" />
/// <reference path="./wx/index.d.ts" />

5881
packages/omix-ts/typings/lib.wa.es6.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

29
packages/omix-ts/typings/wx/index.d.ts vendored Normal file
View File

@ -0,0 +1,29 @@
/*! *****************************************************************************
Copyright (c) 2018 Tencent, Inc. 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.
***************************************************************************** */
/// <reference path="./lib.wx.app.d.ts" />
/// <reference path="./lib.wx.page.d.ts" />
/// <reference path="./lib.wx.api.d.ts" />
/// <reference path="./lib.wx.cloud.d.ts" />
/// <reference path="./lib.wx.component.d.ts" />
declare type IAnyObject = Record<string, any>
declare type KVInfer<T> = {
[K in keyof T]: T[K]
}
declare type Void<T> = T | undefined | null
type PartialOptional<T, K extends keyof T> = Partial<Pick<T, K>> & Pick<T, Exclude<keyof T, K>>
type Optional<T> = {
[K in keyof T]+?: T[K]
}

12756
packages/omix-ts/typings/wx/lib.wx.api.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,249 @@
/*! *****************************************************************************
Copyright (c) 2018 Tencent, Inc. 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.
***************************************************************************** */
declare namespace App {
interface ILaunchOptions {
query: number
}
interface IReferrerInfo {
/** App appId
*
* referrerInfo.appId
* - 1020 profile appId
* - 1035 appId
* - 1036App appId
* - 1037 appId
* - 1038 appId
* - 1043 appId
*/
appId: string
/** 来源小程序传过来的数据scene=1037或1038时支持 */
extraData?: any
}
type SceneValues = 1001
| 1005
| 1006
| 1007
| 1008
| 1011
| 1012
| 1013
| 1014
| 1017
| 1019
| 1020
| 1022
| 1023
| 1024
| 1025
| 1026
| 1027
| 1028
| 1029
| 1030
| 1031
| 1032
| 1034
| 1035
| 1036
| 1037
| 1038
| 1039
| 1042
| 1043
| 1044
| 1045
| 1046
| 1047
| 1048
| 1049
| 1052
| 1053
| 1054
| 1056
| 1057
| 1058
| 1059
| 1064
| 1067
| 1068
| 1069
| 1071
| 1072
| 1073
| 1074
| 1077
| 1078
| 1079
| 1081
| 1082
| 1084
| 1089
| 1090
| 1091
| 1092
| 1095
| 1096
| 1097
| 1099
| 1102
| 1103
| 1104
| number
interface ILaunchShowOption {
/** 打开小程序的路径 */
path: string
/** 打开小程序的query */
query: IAnyObject
/**
* - 1001: 发现栏小程序主入口使2.2.4
* - 1005: 顶部搜索框的搜索结果页
* - 1006: 发现栏小程序主入口搜索框的搜索结果页
* - 1007: 单人聊天会话中的小程序消息卡片
* - 1008: 群聊会话中的小程序消息卡片
* - 1011: 扫描二维码
* - 1012: 长按图片识别二维码
* - 1013: 手机相册选取二维码
* - 1014: 小程序模板消息
* - 1017: 前往体验版的入口页
* - 1019: 微信钱包
* - 1020: 公众号 profile
* - 1022: 聊天顶部置顶小程序入口
* - 1023: 安卓系统桌面图标
* - 1024: 小程序 profile
* - 1025: 扫描一维码
* - 1026: 附近小程序列表
* - 1027: 顶部搜索框搜索结果页使
* - 1028: 我的卡包
* - 1029: 卡券详情页
* - 1030: 自动化测试下打开小程序
* - 1031: 长按图片识别一维码
* - 1032: 手机相册选取一维码
* - 1034: 微信支付完成页
* - 1035: 公众号自定义菜单
* - 1036: App
* - 1037: 小程序打开小程序
* - 1038: 从另一个小程序返回
* - 1039: 摇电视
* - 1042: 添加好友搜索框的搜索结果页
* - 1043: 公众号模板消息
* - 1044: shareTicket []((#))
* - 1045: 朋友圈广告
* - 1046: 朋友圈广告详情页
* - 1047: 扫描小程序码
* - 1048: 长按图片识别小程序码
* - 1049: 手机相册选取小程序码
* - 1052: 卡券的适用门店列表
* - 1053: 搜一搜的结果页
* - 1054: 顶部搜索框小程序快捷入口
* - 1056: 音乐播放器菜单
* - 1057: 钱包中的银行卡详情页
* - 1058: 公众号文章
* - 1059: 体验版小程序绑定邀请页
* - 1064: 微信连Wi-Fi状态栏
* - 1067: 公众号文章广告
* - 1068: 附近小程序列表广告
* - 1069: 移动应用
* - 1071: 钱包中的银行卡列表页
* - 1072: 二维码收款页面
* - 1073: 客服消息列表下发的小程序消息卡片
* - 1074: 公众号会话下发的小程序消息卡片
* - 1077: 摇周边
* - 1078: 连Wi-Fi成功页
* - 1079: 微信游戏中心
* - 1081: 客服消息下发的文字链
* - 1082: 公众号会话下发的文字链
* - 1084: 朋友圈广告原生页
* - 1089: 微信聊天主界面下拉使2.2.4
* - 1090: 长按小程序右上角菜单唤出最近使用历史
* - 1091: 公众号文章商品卡片
* - 1092: 城市服务入口
* - 1095: 小程序广告组件
* - 1096: 聊天记录
* - 1097: 微信支付签约页
* - 1099: 页面内嵌插件
* - 1102: 公众号 profile
* - 1103: 发现栏小程序主入口2.2.4
* - 1104: 微信聊天主界面下拉2.2.4
*/
scene: SceneValues
/** shareTicket详见 [获取更多转发信息]((转发#获取更多转发信息)) */
shareTicket: string
/** 当场景为由从另一个小程序或公众号或App打开时返回此字段 */
referrerInfo?: IReferrerInfo
}
interface IPageNotFoundOption {
/** 不存在页面的路径 */
path: string
/** 打开不存在页面的 query */
query: IAnyObject
/** 是否本次启动的首个页面(例如从分享等入口进来,首个页面是开发者配置的分享页面) */
isEntryPage: boolean
}
interface AppInstance<T extends IAnyObject = {}> {
/**
*
*
*/
onLaunch?(options?: ILaunchShowOption): void
/**
*
*
*/
onShow?(options?: ILaunchShowOption): void
/**
*
*
*/
onHide?(): void
/**
*
* api
*/
onError?(/** 错误信息,包含堆栈 */error?: string): void
/**
*
*
*
* ****
* 1. `onPageNotFound`
* 2. `onPageNotFound` `onPageNotFound`
*
* 1.9.90
*/
onPageNotFound?(options?: IPageNotFoundOption): void
}
interface AppConstructor {
<T extends IAnyObject & AppInstance>(
options: AppInstance<T> & T
): void
}
interface IGetAppOption {
/** `App` AppApp
*
* 2.2.4
*/
allowDefault: boolean
}
interface GetApp {
<T extends IAnyObject>(opts?: IGetAppOption): AppInstance<T> & T
}
}
declare const App: App.AppConstructor
declare const getApp: App.GetApp

View File

@ -0,0 +1,687 @@
/*! *****************************************************************************
Copyright (c) 2018 Tencent, Inc. 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.
***************************************************************************** */
/////////////////////
///// WX Cloud Apis
/////////////////////
/**
* Common interfaces and types
*/
interface IAPIError {
errMsg: string,
}
interface IAPIParam<T = any> {
config?: ICloudConfig,
success?: (res: T) => void,
fail?: (err: IAPIError) => void,
complete?: (val: T | IAPIError) => void,
}
interface IAPISuccessParam {
errMsg: string,
}
type IAPICompleteParam = IAPISuccessParam | IAPIError
type IAPIFunction<T, P extends IAPIParam<T>> = (param: P) => Promise<T> | any
interface IInitCloudConfig {
env?: string | {
database?: string,
functions?: string,
storage?: string,
},
traceUser?: boolean,
}
interface ICloudConfig {
env?: string,
traceUser?: boolean,
}
interface IICloudAPI {
init: (config?: IInitCloudConfig) => void,
[api: string]: AnyFunction | IAPIFunction<any, any>,
}
interface ICloudService {
name: string,
getAPIs: () => { [name: string]: IAPIFunction<any, any> },
}
interface ICloudServices {
[serviceName: string]: ICloudService
}
interface ICloudMetaData {
session_id: string,
}
declare class InternalSymbol {
}
type AnyObject = {
[x: string]: any
}
type AnyArray = any[]
type AnyFunction = (...args: any[]) => any
/**
* original wx
*/
declare namespace WXNS {
interface AnyObject {
[key: string]: any
}
interface IAPIParam<T> {
success?: (res: T) => void,
fail?: (err: IAPIError) => void,
complete?: (val: T | IAPIError) => void,
}
interface CommonAPIResult {
errMsg: string,
}
interface IAPIError {
errMsg: string,
}
interface IProgressUpdateEvent {
progress: number,
totalBytesWritten: number,
totalBytesExpectedToWrite: number,
}
interface operateWXData {
(param: any): void
}
interface uploadFile {
/**
* upload file
* @param param
*/
(param: IUploadFileParam): IUploadFileTask
}
interface IUploadFileParam extends IAPIParam<IUploadFileSuccessResult> {
url: string,
filePath: string,
name: string,
header?: AnyObject,
}
interface IUploadFileSuccessResult extends CommonAPIResult {
data: string,
statusCode: number,
}
interface IUploadFileTask {
onProgressUpdate: (fn: (event: IProgressUpdateEvent) => void) => void,
abort: AnyFunction,
}
interface downloadFile {
/**
* download file
* @param param
*/
(param: IDownloadFileParam): IDownloadFileTask
}
interface IDownloadFileParam extends IAPIParam<IDownloadFileSuccessResult> {
url: string,
header?: AnyObject,
}
interface IDownloadFileSuccessResult extends CommonAPIResult {
tempFilePath: string,
statusCode: number,
}
interface IDownloadFileTask {
onProgressUpdate: (fn: (event: IProgressUpdateEvent) => void) => void,
abort: AnyFunction,
}
interface request {
(param: IRequestParam): IRequestTask
}
interface IRequestParam extends IAPIParam<IRequestSuccessResult> {
url: string,
data?: AnyObject | string | ArrayBuffer,
header?: AnyObject,
method?: string,
dataType?: string,
responseType?: string,
}
interface IRequestSuccessResult {
data: AnyObject | string | ArrayBuffer,
statusCode: number,
header: AnyObject,
}
interface IRequestTask {
abort: () => void
}
interface getFileInfo {
(param: IGetFileInfoParam): void
}
interface IGetFileInfoParam extends IAPIParam<IGetFileInfoSuccessResult> {
filePath: string,
digestAlgorithm?: string,
}
interface IGetFileInfoSuccessResult {
size: number,
digest: string,
}
}
declare namespace wx {
interface WX {
cloud: {
init: (config?: ICloudConfig) => void,
// callFunction: (param: ICloud.CallFunctionParam) => Promise<ICloud.CallFunctionResult> | void,
// uploadFile: (param: ICloud.UploadFileParam) => Promise<ICloud.UploadFileResult> | WXNS.IUploadFileTask,
// downloadFile: (param: ICloud.DownloadFileParam) => Promise<ICloud.DownloadFileResult> | WXNS.IDownloadFileTask,
// getTempFileURL: (param: ICloud.GetTempFileURLParam) => Promise<ICloud.GetTempFileURLResult> | void,
// deleteFile: (param: ICloud.DeleteFileParam) => Promise<ICloud.DeleteFileResult> | void,
callFunction(param: OQ<ICloud.CallFunctionParam>): void
callFunction(param: RQ<ICloud.CallFunctionParam>): Promise<ICloud.CallFunctionResult>
uploadFile(param: OQ<ICloud.UploadFileParam>): WXNS.IUploadFileTask
uploadFile(param: RQ<ICloud.UploadFileParam>): Promise<ICloud.UploadFileResult>
downloadFile(param: OQ<ICloud.DownloadFileParam>): WXNS.IDownloadFileTask
downloadFile(param: RQ<ICloud.DownloadFileParam>): Promise<ICloud.DownloadFileResult>
getTempFileURL(param: OQ<ICloud.GetTempFileURLParam>): void,
getTempFileURL(param: RQ<ICloud.GetTempFileURLParam>): Promise<ICloud.GetTempFileURLResult>
deleteFile(param: OQ<ICloud.DeleteFileParam>): void,
deleteFile(param: RQ<ICloud.DeleteFileParam>): Promise<ICloud.DeleteFileResult>
database: (config?: ICloudConfig) => DB.Database,
}
}
}
declare namespace ICloud {
interface ICloudAPIParam<T = any> extends IAPIParam<T> {
config?: ICloudConfig
}
// === API: callFunction ===
export type CallFunctionData = AnyObject
export interface CallFunctionResult extends IAPISuccessParam {
result: AnyObject | string | undefined,
}
export interface CallFunctionParam extends ICloudAPIParam<CallFunctionResult> {
name: string,
data?: CallFunctionData,
slow?: boolean,
}
// === end ===
// === API: uploadFile ===
export interface UploadFileResult extends IAPISuccessParam {
fileID: string,
statusCode: number,
}
export interface UploadFileParam extends ICloudAPIParam<UploadFileResult> {
cloudPath: string,
filePath: string,
header?: AnyObject,
}
// === end ===
// === API: downloadFile ===
export interface DownloadFileResult extends IAPISuccessParam {
tempFilePath: string,
statusCode: number,
}
export interface DownloadFileParam extends ICloudAPIParam<DownloadFileResult> {
fileID: string,
cloudPath?: string,
}
// === end ===
// === API: getTempFileURL ===
export interface GetTempFileURLResult extends IAPISuccessParam {
fileList: GetTempFileURLResultItem[],
}
export interface GetTempFileURLResultItem {
fileID: string,
tempFileURL: string,
maxAge: number,
status: number,
errMsg: string,
}
export interface GetTempFileURLParam extends ICloudAPIParam<GetTempFileURLResult> {
fileList: string[],
}
// === end ===
// === API: deleteFile ===
interface DeleteFileResult extends IAPISuccessParam {
fileList: DeleteFileResultItem[],
}
interface DeleteFileResultItem {
fileID: string,
status: number,
errMsg: string,
}
interface DeleteFileParam extends ICloudAPIParam<DeleteFileResult> {
fileList: string[],
}
// === end ===
}
// === Database ===
declare namespace DB {
/**
* The class of all exposed cloud database instances
*/
export class Database {
public readonly config: ICloudConfig
public readonly command: DatabaseCommand
public readonly Geo: Geo
public readonly serverDate: () => ServerDate
private constructor();
collection(collectionName: string): CollectionReference
}
export class CollectionReference extends Query {
public readonly collectionName: string
public readonly database: Database
private constructor(name: string, database: Database)
doc(docId: string | number): DocumentReference
// add(options: IAddDocumentOptions): Promise<IAddResult> | void
add(options: OQ<IAddDocumentOptions>): void
add(options: RQ<IAddDocumentOptions>): Promise<IAddResult>
}
export class DocumentReference {
private constructor(docId: string | number, database: Database)
field(object: object): this
// get(options?: IGetDocumentOptions): Promise<IQuerySingleResult> | void
// set(options?: ISetSingleDocumentOptions): Promise<ISetResult> | void
// update(options?: IUpdateSingleDocumentOptions): Promise<IUpdateResult> | void
// remove(options?: IRemoveSingleDocumentOptions): Promise<IRemoveResult> | void
// get(options?: IGetDocumentOptions): Promise<IQuerySingleResult> | void
get(): Promise<IQuerySingleResult>
get(options: OQ<IGetDocumentOptions>): void
get(options: RQ<IGetDocumentOptions>): Promise<IQuerySingleResult>
// set(options?: ISetSingleDocumentOptions): Promise<ISetResult> | void
set(): Promise<ISetResult>
set(options: OQ<ISetSingleDocumentOptions>): void
set(options: RQ<ISetSingleDocumentOptions>): Promise<ISetResult>
// update(options?: IUpdateSingleDocumentOptions): Promise<IUpdateResult> | void
update(): Promise<IUpdateResult>
update(options: OQ<IUpdateSingleDocumentOptions>): void
update(options: RQ<IUpdateSingleDocumentOptions>): Promise<IUpdateResult>
// remove(options?: IRemoveSingleDocumentOptions): Promise<IRemoveResult> | void
remove(): Promise<IRemoveResult>
remove(options: OQ<IRemoveSingleDocumentOptions>): void
remove(options: RQ<IRemoveSingleDocumentOptions>): Promise<IRemoveResult>
}
export class Query {
where(condition: IQueryCondition): Query
orderBy(fieldPath: string, order: string): Query
limit(max: number): Query
skip(offset: number): Query
field(object: object): Query
// get(options?: IGetDocumentOptions): Promise<IQueryResult> | void
// // update(options?: IUpdateDocumentOptions): Promise<IUpdateResult> | void
// // remove(options?: IRemoveDocumentOptions): Promise<IRemoveResult> | void
// count(options?: ICountDocumentOptions): Promise<ICountResult> | void
// get(options?: IGetDocumentOptions): Promise<IQueryResult> | void
get(): Promise<IQueryResult>
get(options: OQ<IGetDocumentOptions>): void
get(options: RQ<IGetDocumentOptions>): Promise<IQueryResult>
// update(options?: IUpdateDocumentOptions): Promise<IUpdateResult> | void
// remove(options?: IRemoveDocumentOptions): Promise<IRemoveResult> | void
// count(options?: ICountDocumentOptions): Promise<ICountResult> | void
count(): Promise<ICountResult>
count(options: OQ<ICountDocumentOptions>): void
count(options: RQ<ICountDocumentOptions>): Promise<ICountResult>
}
export interface DatabaseCommand {
eq(val: any): DatabaseQueryCommand
neq(val: any): DatabaseQueryCommand
gt(val: any): DatabaseQueryCommand
gte(val: any): DatabaseQueryCommand
lt(val: any): DatabaseQueryCommand
lte(val: any): DatabaseQueryCommand
in(val: any[]): DatabaseQueryCommand
nin(val: any[]): DatabaseQueryCommand
and(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
or(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
set(val: any): DatabaseUpdateCommand
remove(): DatabaseUpdateCommand
inc(val: number): DatabaseUpdateCommand
mul(val: number): DatabaseUpdateCommand
push(...values: any[]): DatabaseUpdateCommand
pop(): DatabaseUpdateCommand
shift(): DatabaseUpdateCommand
unshift(...values: any[]): DatabaseUpdateCommand
}
export enum LOGIC_COMMANDS_LITERAL {
AND = 'and',
OR = 'or',
NOT = 'not',
NOR = 'nor',
}
export class DatabaseLogicCommand {
public fieldName: string | InternalSymbol
public operator: LOGIC_COMMANDS_LITERAL | string
public operands: any[]
_setFieldName(fieldName: string): DatabaseLogicCommand
and(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
or(...expressions: (DatabaseLogicCommand | IQueryCondition)[]): DatabaseLogicCommand
}
export enum QUERY_COMMANDS_LITERAL {
EQ = 'eq',
NEQ = 'neq',
GT = 'gt',
GTE = 'gte',
LT = 'lt',
LTE = 'lte',
IN = 'in',
NIN = 'nin',
}
export class DatabaseQueryCommand extends DatabaseLogicCommand {
public operator: QUERY_COMMANDS_LITERAL | string
_setFieldName(fieldName: string): DatabaseQueryCommand
eq(val: any): DatabaseLogicCommand
neq(val: any): DatabaseLogicCommand
gt(val: any): DatabaseLogicCommand
gte(val: any): DatabaseLogicCommand
lt(val: any): DatabaseLogicCommand
lte(val: any): DatabaseLogicCommand
in(val: any[]): DatabaseLogicCommand
nin(val: any[]): DatabaseLogicCommand
}
export enum UPDATE_COMMANDS_LITERAL {
SET = 'set',
REMOVE = 'remove',
INC = 'inc',
MUL = 'mul',
PUSH = 'push',
POP = 'pop',
SHIFT = 'shift',
UNSHIFT = 'unshift',
}
export class DatabaseUpdateCommand {
public fieldName: string | InternalSymbol
public operator: UPDATE_COMMANDS_LITERAL
public operands: any[]
constructor(operator: UPDATE_COMMANDS_LITERAL, operands: any[], fieldName?: string | InternalSymbol)
_setFieldName(fieldName: string): DatabaseUpdateCommand
}
export class Batch {
}
/**
* A contract that all API provider must adhere to
*/
export class APIBaseContract<PROMISE_RETURN, CALLBACK_RETURN, PARAM extends IAPIParam, CONTEXT = any> {
getContext(param: PARAM): CONTEXT
/**
* In case of callback-style invocation, this function will be called
*/
getCallbackReturn(param: PARAM, context: CONTEXT): CALLBACK_RETURN
getFinalParam<T extends PARAM>(param: PARAM, context: CONTEXT): T
run<T extends PARAM>(param: T): Promise<PROMISE_RETURN>
}
export interface GeoPointConstructor {
new (longitude: number, latitide: number): GeoPoint
}
export interface Geo {
Point: {
new (longitude: number, latitide: number): GeoPoint
(longitude: number, latitide: number): GeoPoint
}
}
export abstract class GeoPoint {
public longitude: number
public latitude: number
constructor(longitude: number, latitude: number)
toJSON(): object
toString(): string
}
export interface IServerDateOptions {
offset: number,
}
export abstract class ServerDate {
public readonly options: IServerDateOptions
constructor(options?: IServerDateOptions)
}
export type DocumentId = string | number
export interface IDocumentData {
_id?: DocumentId,
[key: string]: any,
}
export interface IDBAPIParam extends IAPIParam {
}
export interface IAddDocumentOptions extends IDBAPIParam {
data: IDocumentData,
}
export interface IGetDocumentOptions extends IDBAPIParam {
}
export interface ICountDocumentOptions extends IDBAPIParam {
}
export interface IUpdateDocumentOptions extends IDBAPIParam {
data: IUpdateCondition,
}
export interface IUpdateSingleDocumentOptions extends IDBAPIParam {
data: IUpdateCondition,
}
export interface ISetDocumentOptions extends IDBAPIParam {
data: IUpdateCondition,
}
export interface ISetSingleDocumentOptions extends IDBAPIParam {
data: IUpdateCondition,
}
export interface IRemoveDocumentOptions extends IDBAPIParam {
query: IQueryCondition,
}
export interface IRemoveSingleDocumentOptions extends IDBAPIParam {
}
export interface IQueryCondition {
[key: string]: any,
}
export type IStringQueryCondition = string
export interface IQueryResult extends IAPISuccessParam {
data: IDocumentData[],
}
export interface IQuerySingleResult extends IAPISuccessParam {
data: IDocumentData,
}
export interface IUpdateCondition {
[key: string]: any,
}
export type IStringUpdateCondition = string
export interface ISetCondition {
}
export interface IAddResult extends IAPISuccessParam {
_id: DocumentId,
}
export interface IUpdateResult extends IAPISuccessParam {
stats: {
updated: number,
// created: number,
}
}
export interface ISetResult extends IAPISuccessParam {
_id: DocumentId,
stats: {
updated: number,
created: number,
}
}
export interface IRemoveResult extends IAPISuccessParam {
stats: {
removed: number,
}
}
export interface ICountResult extends IAPISuccessParam {
total: number
}
}
/**
* Utils
*/
type OQ<T extends Optional<Record<'complete' | 'success' | 'fail', (...args: any[]) => any>>> =
(RQ<T> & Required<Pick<T, 'success'>>) |
(RQ<T> & Required<Pick<T, 'fail'>>) |
(RQ<T> & Required<Pick<T, 'complete'>>) |
(RQ<T> & Required<Pick<T, 'success' | 'fail'>>) |
(RQ<T> & Required<Pick<T, 'success' | 'complete'>>) |
(RQ<T> & Required<Pick<T, 'fail' | 'complete'>>) |
(RQ<T> & Required<Pick<T, 'fail' | 'complete' | 'success'>>)
type RQ<T extends Optional<Record<'complete' | 'success' | 'fail', (...args: any[]) => any>>> = Pick<T, Exclude<keyof T, 'complete' | 'success' | 'fail'>>

View File

@ -0,0 +1,213 @@
/*! *****************************************************************************
Copyright (c) 2018 Tencent, Inc. 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.
***************************************************************************** */
/*! *****************************************************************************
Copyright (c) 2018 Tencent, Inc. 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.
***************************************************************************** */
type PropertyType =
| StringConstructor
| NumberConstructor
| BooleanConstructor
| ObjectConstructor
| ArrayConstructor
| null;
declare interface PropertyOption {
/** 属性类型 */
type: PropertyType;
/** 属性初始值 */
value: any;
/** 属性值被更改时的响应函数 */
observer?(
newVal?: any,
oldVal?: any,
changedPath?: Array<string | number>,
): void;
optionalTypes?: PropertyType[];
}
declare interface TriggerEventOption {
/**
*
* `false`
*/
bubbles?: boolean;
/** 穿false
*
* `false`
*/
composed?: boolean;
/**
*
* `false`
*/
capturePhase?: boolean;
}
declare interface WxComponent extends BaseComponent {
/** 组件的文件路径 */
is: string;
/** 节点id */
id: string;
/** 节点dataset */
dataset: string;
/** 组件数据,**包括内部数据和属性值** */
data: IAnyObject;
/** 组件数据,**包括内部数据和属性值**(与 `data` 一致) */
properties: {
[propertyName: string]: PropertyOption;
};
/** 设置data并执行视图层渲染 */
setData(
/**
*
* `key: value` `this.data` `key` `value`
*
* `key` `array[2].message``a.b.c.d` this.data
*/
data: IAnyObject,
/** setData引起的界面更新渲染完毕后的回调函数最低基础库 `1.5.0` */
callback?: (data: IAnyObject) => void,
): void;
/** 检查组件是否具有 `behavior` 检查时会递归检查被直接或间接引入的所有behavior */
hasBehavior(behavior: object): void;
/** 触发事件,参见组件事件 */
triggerEvent(name: string, detail: object, options: TriggerEventOption): void;
/** 创建一个 SelectorQuery 对象,选择器选取范围为这个组件实例内 */
createSelectorQuery(): wx.SelectorQuery;
/** 创建一个 IntersectionObserver 对象,选择器选取范围为这个组件实例内 */
createIntersectionObserver(
options: wx.CreateIntersectionObserverOption,
): wx.IntersectionObserver;
/** 使用选择器选择组件实例节点,返回匹配到的第一个组件实例对象(会被 `wx://component-export` 影响) */
selectComponent(selector: string): WxComponent;
/** 使用选择器选择组件实例节点,返回匹配到的全部组件实例对象组成的数组 */
selectAllComponents(selector: string): WxComponent[];
/** 获取这个关系所对应的所有关联节点,参见 组件间关系 */
getRelationNodes(relationKey: string): WxComponent[];
/** 立刻执行 callback ,其中的多个 setData 之间不会触发界面绘制(只有某些特殊场景中需要,如用于在不同组件同时 setData 时进行界面绘制同步)*/
groupSetData(callback?: () => void): void;
/** 返回当前页面的 custom-tab-bar 的组件实例 */
getTabBar(): WxComponent;
}
declare interface ComponentLifetimes {
/** 组件生命周期函数,在组件实例进入页面节点树时执行,注意此时不能调用 `setData` */
created?(this: WxComponent): void;
/** 组件生命周期函数,在组件实例进入页面节点树时执行 */
attached?(this: WxComponent): void;
/** 组件生命周期函数,在组件布局完成后执行,此时可以获取节点信息(使用 [SelectorQuery]((SelectorQuery)) */
ready?(this: WxComponent): void;
/** 组件生命周期函数,在组件实例被移动到节点树另一个位置时执行 */
moved?(this: WxComponent): void;
/** 组件生命周期函数,在组件实例被从页面节点树移除时执行 */
detached?(this: WxComponent): void;
/** 组件生命周期函数,每当组件方法抛出错误时执行 */
error?(error: Error): void;
}
declare interface PageLifetimes {
/**
*
* /
*/
show?(this: Page.PageInstance): void;
/**
*
* / `navigateTo` `tab`
*/
hide?(this: Page.PageInstance): void;
/**
*
*
*/
resize?(Size?: Page.IResizeOption): void;
}
declare interface RelationOption {
/** 目标组件的相对关系 */
type: 'parent' | 'child' | 'ancestor' | 'descendant';
/** 关系生命周期函数当关系被建立在页面节点树中时触发触发时机在组件attached生命周期之后 */
linked?(target: WxComponent): any;
/** 关系生命周期函数当关系在页面节点树中发生改变时触发触发时机在组件moved生命周期之后 */
linkChanged?(target: WxComponent): any;
/** 关系生命周期函数当关系脱离页面节点树时触发触发时机在组件detached生命周期之后 */
unlinked?(target: WxComponent): any;
/** 如果这一项被设置则它表示关联的目标节点所应具有的behavior所有拥有这一behavior的组件节点都会被关联 */
target?: string;
}
type DefinitionFilter = (
defFields: WxComponent,
definitionFilterArr?: DefinitionFilter[],
) => void;
declare interface ComponentOptions {
multipleSlots?: boolean;
addGlobalClass?: boolean;
}
declare interface BaseComponent extends ComponentLifetimes {
/** 组件的对外属性,是属性名到属性设置的映射表 */
properties?: {
[propertyName: string]: PropertyOption;
};
/** 组件的内部数据,和 `properties` 一同用于组件的模板渲染 */
data?: IAnyObject;
/** 组件数据字段监听器,用于监听 properties 和 data 的变化 */
observers?: IAnyObject;
/** object组件的方法包括事件响应函数和任意的自定义方法关于事件响应函数的使用参见 [组件事件](events.md) */
methods?: {
[methodName: string]: (this: WxComponent) => any;
};
/** 类似于mixins和traits的组件间代码复用机制参见 [behaviors](behaviors.md) */
behaviors?: string[];
/** 组件间关系定义,参见 [组件间关系](relations.md) */
relations?: {
[componentName: string]: RelationOption;
};
/** 组件接受的外部样式类,参见 [外部样式类](wxml-wxss.md) */
externalClasses?: string[];
/** 一些选项(文档中介绍相关特性时会涉及具体的选项设置,这里暂不列举) */
options?: ComponentOptions;
/** `created``attached``ready``moved``detached` `lifetimes` `lifetimes`
*
* `2.2.3` */
lifetimes?: ComponentLifetimes;
/** `show` `hide`
*
* `2.2.3` */
pageLifetimes?: PageLifetimes;
/** [](extend.md)
*
* `2.2.3` */
definitionFilter?: DefinitionFilter;
}
/** ComponentComponent
*
* * 使 `this.data` 使 `setData`
* * `this` 访
* * data `dataXyz` WXML `data-xyz=""` dataset
* * 使 data
* * `2.0.9` data
* * `bug` : type Object Array `this.setData` observer observer `newVal` `oldVal` `changedPath`
*/
declare function Component(
/** 自定义组件注册参数 */ options: BaseComponent,
): void;

View File

@ -0,0 +1,212 @@
/*! *****************************************************************************
Copyright (c) 2018 Tencent, Inc. 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.
***************************************************************************** */
/*! *****************************************************************************
Copyright (c) 2018 Tencent, Inc. 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.
***************************************************************************** */
declare namespace Page {
interface ICustomShareContent {
/** 转发标题。默认值:当前小程序名称 */
title?: string;
/** 转发路径,必须是以 / 开头的完整路径。默认值:当前页面 path */
path?: string;
/** 自定义图片路径可以是本地文件路径、代码包文件路径或者网络图片路径。支持PNG及JPG。显示图片长宽比是 5:4最低基础库 `1.5.0`。默认值:使用默认截图 */
imageUrl?: string;
}
interface IPageScrollOption {
/** 页面在垂直方向已滚动的距离单位px */
scrollTop: number;
}
interface IShareAppMessageOption {
/**
*
*
* - `button`
* - `menu`
*
* `1.2.4`
*/
from: 'button' | 'menu' | string;
/** `from` `button` `target` `button` `undefined`
*
* `1.2.4` */
target: any;
/** `<web-view>``<web-view>`url
*
* `1.6.4`
*/
webViewUrl?: string;
}
interface ITabItemTapOption {
/** 被点击tabItem的序号从0开始最低基础库 `1.9.0` */
index: string;
/** 被点击tabItem的页面路径最低基础库 `1.9.0` */
pagePath: string;
/** 被点击tabItem的按钮文字最低基础库 `1.9.0` */
text: string;
}
interface IResizeOption {
size: {
/** 变化后的窗口宽度,单位 px */
windowWidth: number;
/** 变化后的窗口高度,单位 px */
windowHeight: number;
};
}
interface PageInstanceBaseProps<D extends IAnyObject = any> {
/**
*
* `data` 使****
*
* `data` `JSON``data``JSON`
*
* `WXML`
*/
data?: D;
/** `setData` `this.data`
*
* ****
*
* 1. ** this.data this.setData **
* 1. JSON
* 1. 1024kB
* 1. data value `undefined`
*/
setData?<K extends keyof D>(
/**
*
* `key: value` `this.data` `key` `value`
*
* `key` `array[2].message``a.b.c.d` this.data
*/
data: D | Pick<D, K> | IAnyObject,
/** setData引起的界面更新渲染完毕后的回调函数最低基础库 `1.5.0` */
callback?: () => void,
): void;
/** 到当前页面的路径,类型为`String`。最低基础库: `1.2.0` */
route?: string;
}
interface PageInstance<
D extends IAnyObject = any,
T extends IAnyObject = any
> extends PageInstanceBaseProps<D> {
/**
*
* onLoad
*/
onLoad?(
/** 打开当前页面路径中的参数 */
query?: { [queryKey: string]: string },
): void;
/**
*
* /
*/
onShow?(): void;
/**
*
*
*
* API `wx.setNavigationBarTitle``onReady`
*/
onReady?(): void;
/**
*
* / `navigateTo` `tab`
*/
onHide?(): void;
/**
*
* `redirectTo``navigateBack`
*/
onUnload?(): void;
/**
*
*
* - `app.json``window``enablePullDownRefresh`
* - `wx.startPullDownRefresh`
* - `wx.stopPullDownRefresh`
*/
onPullDownRefresh?(): void;
/**
*
*
* - `app.json``window``onReachBottomDistance`
* -
*/
onReachBottom?(): void;
/**
*
* `<button>` `open-type="share"`
*
* ****
*
* return Object
*/
onShareAppMessage?(
/** 分享发起来源参数 */
options?: IShareAppMessageOption,
): ICustomShareContent;
/**
*
*
*/
onPageScroll?(
/** 页面滚动参数 */
options?: IPageScrollOption,
): void;
/** 当前是 tab 页时,点击 tab 时触发,最低基础库: `1.9.0` */
onTabItemTap?(
/** tab 点击参数 */
options?: ITabItemTapOption,
): void;
/** 窗口尺寸改变时触发,最低基础库:`2.4.0` */
onResize?(
/** 窗口尺寸参数 */
options?: IResizeOption,
): void;
}
interface PageConstructor {
<D extends IAnyObject, T extends IAnyObject & PageInstance>(
options: PageInstance<D, T> & T,
): void;
}
interface GetCurrentPages {
<D extends IAnyObject = {}, T extends IAnyObject = {}>(): (PageInstance<
D,
T
> &
T)[];
}
}
declare const Page: Page.PageConstructor;
declare const getCurrentPages: Page.GetCurrentPages;