This repository has been archived by the owner on Sep 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
global.d.ts
585 lines (483 loc) · 12.6 KB
/
global.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
/* jsbox类型文件 请勿移除 */
declare interface JSBoxDataTypesBase{
rawValue:any;
runtimeValue:any;
}
declare interface JSBoxColor extends JSBoxDataTypesBase {}
declare interface JSBoxRect extends JSBoxDataTypesBase {}
declare interface JSBoxContentMode extends JSBoxDataTypesBase {}
declare interface JSBoxSize extends JSBoxDataTypesBase {
width: number;
height: number;
}
declare interface JSBoxRect extends JSBoxDataTypesBase {}
declare interface JSBoxPoint extends JSBoxDataTypesBase {}
declare interface JSBoxFont extends JSBoxDataTypesBase {}
declare interface JSBoxRange extends JSBoxDataTypesBase {}
declare interface JSBoxIndexPath extends JSBoxDataTypesBase {}
declare interface JSBoxData extends JSBoxDataTypesBase {}
declare interface JSBoxIcon extends JSBoxDataTypesBase {}
declare interface JSBoxInsets extends JSBoxDataTypesBase {}
/** 生成一个大小 */
declare function $size(width:number,height:number):JSBoxSize
declare function $rgb(r:number,g:number,b:number):JSBoxColor
declare function $rgba(r:number,g:number,b:number,a:number):JSBoxColor
/** 生成一个矩形 */
declare function $rect(x: number, y: number, width: number, height: number):JSBoxRect
/** 生成一个位置 */
declare function $point(x: number, y: number):JSBoxPoint;
declare function $color(hex:string):JSBoxColor;
declare function $color(name:string):JSBoxColor;
/** 返回一个字体,name 字段是可选的:
* 其中 name 是 "bold" 和 default 时,分别会使用粗体和正常字体,否则根据 name 查找系统支持的字体。
*/
declare function $font(name:string, size:number):JSBoxFont;
declare function $font(size:number):JSBoxFont;
declare function $range(location: number, length: number):JSBoxRange;
declare function $indexPath(section: number, row: number):JSBoxIndexPath;
declare function $data(form:{
string?: string;
path?: string;
url?: string;
}):JSBoxData
declare function $icon(code: string, color?: JSBoxColor, size?: JSBoxSize): JSBoxIcon
declare class $console{
static log(...info:any[]):void;
static info(...info:any[]):void;
static warn(...info:any[]):void;
static error(...info:any[]):void;
}
declare function $props(data:any):string[];
declare const $env:{
app: 1;
today: 2;
action: 4;
safari: 8;
all: 15;
}
declare const $align: {
left: 0;
center: 1;
right: 2;
justified: 3;
natural: 4;
}
declare const $contentMode: {
scaleToFill: 0,
scaleAspectFit: 1,
scaleAspectFill: 2,
redraw: 3,
center: 4,
top: 5,
bottom: 6,
left: 7,
right: 8,
}
declare const $btnType :{
custom: 0,
system: 1,
disclosure: 2,
infoLight: 3,
infoDark: 4,
contactAdd: 5,
}
declare const $zero:{
point: JSBoxPoint;
size: JSBoxSize;
rect: JSBoxRect;
insets: JSBoxInsets;
}
declare const $layout:{
fill: (make: any, view: any) => void;
center: (make: any, view: any) => void;
}
declare const $lineCap: {
butt: 0,
round: 1,
square: 2
}
declare const $lineJoin: {
miter: 0,
round: 1,
bevel: 2
}
declare const $mediaType:{
image: "public.image",
jpeg: "public.jpeg",
jpeg2000: "public.jpeg-2000",
tiff: "public.tiff",
pict: "com.apple.pict",
gif: "com.compuserve.gif",
png: "public.png",
icns: "com.apple.icns",
bmp: "com.microsoft.bmp",
ico: "com.microsoft.ico",
raw: "public.camera-raw-image",
live: "com.apple.live-photo",
movie: "public.movie",
video: "public.video",
audio: "public.audio",
mov: "com.apple.quicktime-movie",
mpeg: "public.mpeg",
mpeg2: "public.mpeg-2-video",
mp3: "public.mp3",
mp4: "public.mpeg-4",
avi: "public.avi",
wav: "com.microsoft.waveform-audio",
midi: "public.midi-audio"
}
declare const $imgPicker: {
quality: {
high: 0,
medium: 1,
low: 2,
r640x480: 3,
r1280x720: 4,
r960x540: 5
},
captureMode: {
photo: 0,
video: 1
},
device: {
rear: 0,
front: 1
},
flashMode: {
off: -1,
auto: 0,
on: 1
}
}
declare const $kbType:{
default: 0,
ascii: 1,
nap: 2,
url: 3,
number: 4,
phone: 5,
namePhone: 6,
email: 7,
decimal: 8,
twitter: 9,
search: 10,
asciiPhone: 11
}
declare const $assetMedia: {
type: {
unknown: 0,
image: 1,
video: 2,
audio: 3
},
subType: {
none: 0,
panorama: 1,
hdr: 2,
screenshot: 4,
live: 8,
depthEffect: 16,
streamed: 65536,
highFrameRate: 131072,
timelapse: 262144
}
}
declare const $pageSize: {
letter: 0, governmentLetter: 1, legal: 2, juniorLegal: 3, ledger: 4, tabloid: 5,
A0: 6, A1: 7, A2: 8, A3: 9, A4: 10, A5: 11, A6: 12, A7: 13, A8: 14, A9: 15, A10: 16,
B0: 17, B1: 18, B2: 19, B3: 20, B4: 21, B5: 22, B6: 23, B7: 24, B8: 25, B9: 26, B10: 27,
C0: 28, C1: 29, C2: 30, C3: 31, C4: 32, C5: 33, C6: 34, C7: 35, C8: 36, C9: 37, C10: 38,
custom: 52
}
declare namespace $app {
/** 指定此扩展可用的最低 SDK 版本(SDK 版本即 JSBox 的版本) */
const minSDKVer: string;
/** 指定此扩展可用的最低 iOS 版本: */
const minOSVer: string;
/** 给用户展示一个使用提示,效果如同 $ui.alert,但请注意这个提示只会运行一次: */
function tips(string: string):void;
/** 返回 app 本身的信息 */
const info: {
"bundleID": string;
"version": string;
"build": string;
}
/** 设置成 true 时屏幕不会自动休眠: */
var idleTimerDisabled: boolean;
/**
* 关闭当前的扩展,请注意扩展被关闭之后的代码都不会再被执行。
* @param {number} delay 表示延迟的秒数,可以缺省,缺省即立即关闭。
*/
function close(delay:number):void;
/** 设置此扩展适合运行的环境,当用户在不适合的环境里运行时,将会给出提示: */
var validEnv: number;
/** 获得此扩展当前运行的环境: */
const env: number;
/** 在某些滚动列表里面,可能会出现键盘遮挡住输入框的情况,开启之后将会自动避免这个问题: */
var autoKeyboardEnabled: boolean;
/** 同样在滚动列表里,为键盘展示一个工具栏将会让输入更加方便,尤其是对于多个输入框: */
var keyboardToolbarEnabled: boolean;
/** 设置为 true 时屏幕将不可以旋转: */
var rotateDisabled: boolean;
/** 打开一个 URL,例如打开微信:$app.openURL("weixin://") */
function openURL(url:string):void;
/** 在用户安装了某个浏览器的情况下,通过某个浏览器打开 URL,例如:
* type 浏览器
* 10000 Chrome
* 10001 UC
* 10002 Firefox
* 10003 QQ
* 10004 Opera
* 10005 Quark
* 10006 iCab
* 10007 Maxthon
* 10008 Dolphin
* 10009 2345
*/
function openBrowser(object:{type?:number, url:string}):void;
function openExtension(fileName: string):void;
function listen(object:{
ready?:()=>void;
exit?:()=>void;
}):void;
var strings:any;
}
interface JSBoxDeviceInfo {
"model": string;
"language": string;
"version": string;
"name": string;
"screen": {
"width": number;
"height": number;
"scale": number;
"orientation": number;
}
}
interface JSBoxDeviceSSID {
"SSIDDATA": any;
"BSSID": string;
"SSID": string;
}
interface JSBoxDeviceSpace {
"disk": {
"free": {
"bytes": number;
"string": string;
};
"total": {
"bytes": number;
"string": string;
}
};
"memory": {
"free": {
"bytes": number;
"string": string;
};
"total": {
"bytes": number;
"string": string;
}
}
}
declare interface JSBoxView extends JSBoxDataTypesBase {
//todo: 完成模型
}
declare namespace $device{
const info: JSBoxDeviceInfo;
const ssid: JSBoxDeviceSSID;
const networkType: number;
const space: JSBoxDeviceSpace;
function taptic(level: number):void;
}
interface JSBoxUiRenderOption {
props?: {
id: string;
/** 标题 */
title?: string;
/** 标题颜色 */
titleColor?: JSBoxColor;
/** bar 背景色 */
barColor?: JSBoxColor;
/** 图标颜色 */
iconColor?: JSBoxColor;
};
// todo: 参数类型
views: any[];
[key: string]: any;
}
declare function $(id:string):JSBoxView;
// todo:
declare namespace $ui {
function render(option: JSBoxUiRenderOption): void;
function push(option: JSBoxUiRenderOption): void;
function alert(text: string): void;
// todo: 参数类型
function alert(option: any): void;
function animate(option: any): void;
function toast(option: any): void;
}
declare namespace $system {
/** 设置屏幕 */
var brightness:number;
/** 获取或设置设备音量 (0.0 ~ 1.0) */
var volume:number;
/** 拨打电话 */
function call(number:string):void;
/** 发送短信 */
function sms(number:string):void;
/** 发送邮件 */
function mailto(email:string):void;
/** 拨打FaceTime */
function facetime(number:string):void;
}
interface JSBoxHttpOption {
/** 方式 GET/POST/DELETE 等*/
method?: string;
/** 链接 */
url: string;
/** 请求头 */
header?: {
[key:string]:string;
};
/** 请求体 */
body?: any
/** 请求超时时间 */
timeout?: number;
/** form-data 参数 */
form?: any;
/** todo: 文件列表 */
files?: any;
/** 上传进度 upload/download 中进度回调 */
progress?: (bytesWritten:number, totalBytes:number) => void;
/** 是否显示进度条(默认显示) */
showsProgress?: boolean;
/** upload/download 中的提示语 */
message?: string;
/** 回调函数 */
handler: (resp:JSBoxHttpResp)=>void;
}
interface JSBoxHttpResponse{
url:string
/** MIME 类型 */
MIMEType:string;
/** 长度 */
expectedContentLength:number;
/** 编码 */
textEncodingName:string;
/** 建议的文件名 */
suggestedFilename:string;
/** HTTP 状态码 */
statusCode:number;
/** HTTP header */
headers:{[key:string]:string};
}
interface JSBoxHttpError{
domain:string;
code:number;
userInfo:any;
localizedDescription:string;
localizedFailureReason:string;
localizedRecoverySuggestion:string;
}
interface JSBoxHttpResp{
data?:any;
response?:JSBoxHttpResponse;
error?:any;
}
declare namespace $http{
/** 发起一个 HTTP 请求 */
function request(option:JSBoxHttpOption):void;
function get(option:JSBoxHttpOption):void;
function post(option:JSBoxHttpOption):void;
}
interface JSBoxCacheSetOption{
key:string;
value:any;
handler:(object:any)=>void;
}
interface JSBoxCacheGetOption{
key:string;
handler:(object:any)=>void;
}
interface JSBoxCacheRemoveOption{
key:string;
handler:()=>void;
}
interface JSBoxCacheClearOption{
handler:()=>void;
}
declare namespace $cache{
function set(key:string, object:any):void;
function setAsync(option:JSBoxCacheSetOption):void;
function get(key:string):any;
function getAsync(option:JSBoxCacheGetOption):void;
function remove(key:string):any;
function remove(option:JSBoxCacheRemoveOption):void;
function clear():any;
function clear(option:JSBoxCacheClearOption):void;
}
interface JSBoxThreadOption{
/** 延迟执行的时间,可选 */
delay?: number;
handler:()=>void;
}
declare namespace $thread{
function background(option:JSBoxThreadOption):void;
function main(option:JSBoxThreadOption):void;
}
declare function $delay(delay:number,handler:()=>void):void;
interface JSBoxTimerOption {
interval: number;
handler: ()=>void;
}
interface JSBoxTimerHandle {
/** 取消任务 */
invalidate:()=>void;
}
declare namespace $timer{
function schedule(option:JSBoxTimerOption):JSBoxTimerHandle;
}
interface JSBoxClipboardCopyOption{
text?:string;
image?:any;
data?:any;
/** 几秒之后过期 */
ttl?:number;
/** 本地剪贴板 */
locally:boolean;
}
interface JSBoxClipboardSetOption{
"type": string;
"value": any;
}
declare namespace $clipboard{
const text:string;
/** todo: */
const image:any;
/** todo: */
const items:any;
/** 获取剪贴板中的所有电话号码。 */
const phoneNumbers:string[];
/** 获取剪贴板中的第一个电话号码。 */
const phoneNumber:string;
/** 获取剪贴板中的所有链接。 */
const links:string[];
/** 获取剪贴板中的第一个链接。 */
const link:string;
/** 获取剪贴板中的所有 email。 */
const emails:string[];
/** 获取剪贴板中的第一个 email。 */
const email:string;
/** 获取剪贴板中的所有日期。 */
const dates:string[];
/** 获取剪贴板中的第一个日期。 */
const date:string;
/** 设置剪贴板的文本,但忽略 Universal Clipboard: */
function setTextLocalOnly(string:string):void;
function set(option:JSBoxClipboardSetOption):void;
function copy(option:JSBoxClipboardCopyOption):void;
function clear():void;
}
declare function $l10n(key:string):string;