minidev 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/assets/builder-debug-utils/CHANGELOG.md +263 -0
- package/assets/builder-debug-utils/README.md +55 -0
- package/assets/builder-debug-utils/dist/index.js +1 -0
- package/assets/builder-debug-utils/lib/compose.d.ts +2 -0
- package/assets/builder-debug-utils/lib/compose.js +81 -0
- package/assets/builder-debug-utils/lib/config.d.ts +3 -0
- package/assets/builder-debug-utils/lib/config.js +18 -0
- package/assets/builder-debug-utils/lib/context.d.ts +14 -0
- package/assets/builder-debug-utils/lib/context.js +31 -0
- package/assets/builder-debug-utils/lib/index.d.ts +3 -0
- package/assets/builder-debug-utils/lib/index.js +17 -0
- package/assets/builder-debug-utils/lib/interface.d.ts +86 -0
- package/assets/builder-debug-utils/lib/interface.js +15 -0
- package/assets/builder-debug-utils/lib/sdk.d.ts +30 -0
- package/assets/builder-debug-utils/lib/sdk.js +148 -0
- package/assets/builder-debug-utils/lib/updater.d.ts +16 -0
- package/assets/builder-debug-utils/lib/updater.js +137 -0
- package/assets/builder-debug-utils/lib/utils.d.ts +13 -0
- package/assets/builder-debug-utils/lib/utils.js +59 -0
- package/assets/builder-debug-utils/offline/assets_map +1 -0
- package/assets/builder-debug-utils/offline/boatman_cube +1 -0
- package/assets/builder-debug-utils/offline/boatman_mini +3 -0
- package/assets/builder-debug-utils/package.json +49 -0
- package/assets/builder-debug-utils/readonly/assets_map +1 -0
- package/assets/builder-debug-utils/readonly/boatman_cube +1 -0
- package/assets/builder-debug-utils/readonly/boatman_mini +3 -0
- package/bin/minidev.js +4 -0
- package/index.d.ts +5500 -0
- package/lib/index.js +2 -0
- package/lib/index.js.LICENSE.txt +36 -0
- package/package.json +36 -0
- package/scripts/post-install.js +6 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
# Minidev - 支付宝小程序开发 Cli (WIP)
|
|
3
|
+
|
|
4
|
+
支付宝小程序开发 cli(minidev) 提供了常用的支付宝系小程序开发指令,能够方便地在各类平台上快速进行小程序的开发、预览、上传等操作。
|
|
5
|
+
|
|
6
|
+
## 如何使用
|
|
7
|
+
|
|
8
|
+
### 安装
|
|
9
|
+
|
|
10
|
+
npm i -g minidev
|
|
11
|
+
|
|
12
|
+
### 工具授权 (真机预览和真机调试都需要)
|
|
13
|
+
|
|
14
|
+
````
|
|
15
|
+
minidev login
|
|
16
|
+
````
|
|
17
|
+
|
|
18
|
+
### 真机预览
|
|
19
|
+
|
|
20
|
+
````
|
|
21
|
+
cd /path/to/yourProject
|
|
22
|
+
minidev preview -a {yourAppId}
|
|
23
|
+
````
|
|
24
|
+
|
|
25
|
+
### 真机调试
|
|
26
|
+
|
|
27
|
+
````
|
|
28
|
+
cd /path/to/yourProject
|
|
29
|
+
minidev remote-debug -a {yourAppId}
|
|
30
|
+
````
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### 启动 devServer
|
|
34
|
+
|
|
35
|
+
````
|
|
36
|
+
cd /path/to/yourProject
|
|
37
|
+
minidev dev
|
|
38
|
+
````
|
|
39
|
+
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
## 3.0.4
|
|
2
|
+
|
|
3
|
+
- fix: composeAssets4Preview 传入 Cube 时返回 undefined 的问题
|
|
4
|
+
|
|
5
|
+
## 3.0.3
|
|
6
|
+
|
|
7
|
+
- boatman-cube prerelease
|
|
8
|
+
|
|
9
|
+
## 3.0.2
|
|
10
|
+
|
|
11
|
+
- tinybugme 0.0.73
|
|
12
|
+
- boatman 0.10.0
|
|
13
|
+
|
|
14
|
+
## 3.0.1
|
|
15
|
+
|
|
16
|
+
- tinybugme 0.0.72
|
|
17
|
+
|
|
18
|
+
## 3.0.0
|
|
19
|
+
|
|
20
|
+
- boatman cube 支持
|
|
21
|
+
|
|
22
|
+
## 2.5.11
|
|
23
|
+
|
|
24
|
+
- boatman 0.9.0
|
|
25
|
+
|
|
26
|
+
## 2.5.10
|
|
27
|
+
|
|
28
|
+
- tinybugme 0.0.71
|
|
29
|
+
|
|
30
|
+
## 2.5.9
|
|
31
|
+
|
|
32
|
+
- tinybugme 0.0.70
|
|
33
|
+
|
|
34
|
+
## 2.5.8
|
|
35
|
+
|
|
36
|
+
- tinybugme 0.0.69
|
|
37
|
+
|
|
38
|
+
## 2.5.7
|
|
39
|
+
|
|
40
|
+
- boatman 0.8.0
|
|
41
|
+
|
|
42
|
+
## 2.5.6
|
|
43
|
+
|
|
44
|
+
- tinybugme 0.0.68
|
|
45
|
+
|
|
46
|
+
## 2.5.5
|
|
47
|
+
|
|
48
|
+
- tinybugme 0.0.67
|
|
49
|
+
|
|
50
|
+
## 2.5.4
|
|
51
|
+
|
|
52
|
+
- tinybugme 0.0.66
|
|
53
|
+
|
|
54
|
+
## 2.5.3
|
|
55
|
+
|
|
56
|
+
- tinybugme 0.0.65
|
|
57
|
+
- boatman 0.7.10
|
|
58
|
+
|
|
59
|
+
## 2.5.2
|
|
60
|
+
|
|
61
|
+
- boatman 0.7.9
|
|
62
|
+
|
|
63
|
+
## 2.5.1
|
|
64
|
+
|
|
65
|
+
- boatman 0.7.8
|
|
66
|
+
|
|
67
|
+
## 2.5.0
|
|
68
|
+
|
|
69
|
+
- SDK 化重构
|
|
70
|
+
- 支持外部设置 offline 目录位置
|
|
71
|
+
|
|
72
|
+
## 2.4.14
|
|
73
|
+
|
|
74
|
+
- tinybugme 0.0.64 bugmeWRemote
|
|
75
|
+
|
|
76
|
+
## 2.4.13
|
|
77
|
+
|
|
78
|
+
- tinybugme 0.0.64 bugmeRRemote
|
|
79
|
+
|
|
80
|
+
## 2.4.12
|
|
81
|
+
|
|
82
|
+
- tinybugme 0.0.63
|
|
83
|
+
|
|
84
|
+
## 2.4.11
|
|
85
|
+
|
|
86
|
+
- tinybugme 0.0.62
|
|
87
|
+
- boatman 0.7.7
|
|
88
|
+
|
|
89
|
+
## 2.4.10
|
|
90
|
+
|
|
91
|
+
- tinybugme 0.0.59
|
|
92
|
+
|
|
93
|
+
## 2.4.9
|
|
94
|
+
|
|
95
|
+
- boatman 0.7.5
|
|
96
|
+
|
|
97
|
+
## 2.4.8
|
|
98
|
+
|
|
99
|
+
- tinybugme 0.0.58
|
|
100
|
+
|
|
101
|
+
## 2.4.7
|
|
102
|
+
|
|
103
|
+
- boatman 0.7.4
|
|
104
|
+
|
|
105
|
+
## 2.4.6
|
|
106
|
+
|
|
107
|
+
- tinybugme 0.0.55
|
|
108
|
+
|
|
109
|
+
## 2.4.5
|
|
110
|
+
|
|
111
|
+
- boatman 0.7.2
|
|
112
|
+
|
|
113
|
+
## 2.4.4
|
|
114
|
+
|
|
115
|
+
- boatman 0.7.1
|
|
116
|
+
|
|
117
|
+
## 2.4.3
|
|
118
|
+
|
|
119
|
+
- boatman 0.7.0
|
|
120
|
+
|
|
121
|
+
## 2.4.2
|
|
122
|
+
|
|
123
|
+
- boatman 0.6.0
|
|
124
|
+
|
|
125
|
+
## 2.4.1
|
|
126
|
+
|
|
127
|
+
- boatman 0.5.1
|
|
128
|
+
|
|
129
|
+
## 2.4.0
|
|
130
|
+
|
|
131
|
+
- boatman 0.5.0
|
|
132
|
+
- tinybugme 0.0.53
|
|
133
|
+
- boatman_mini 中包含 tinybugme worker-remote
|
|
134
|
+
|
|
135
|
+
## 2.3.4
|
|
136
|
+
|
|
137
|
+
- boatman 0.4.2
|
|
138
|
+
|
|
139
|
+
## 2.3.3
|
|
140
|
+
|
|
141
|
+
- tinybugme 0.0.52
|
|
142
|
+
- boatman 0.4.0
|
|
143
|
+
|
|
144
|
+
## 2.3.2
|
|
145
|
+
|
|
146
|
+
- boatman 0.3.8
|
|
147
|
+
|
|
148
|
+
## 2.3.1
|
|
149
|
+
|
|
150
|
+
- tinybugme 0.0.51
|
|
151
|
+
|
|
152
|
+
## 2.3.0
|
|
153
|
+
|
|
154
|
+
- 增加 RemtoexLite 模式支持 IDE 无插桩调试
|
|
155
|
+
|
|
156
|
+
## 2.2.1
|
|
157
|
+
|
|
158
|
+
- tinybugme 0.0.48
|
|
159
|
+
|
|
160
|
+
## 2.2.0
|
|
161
|
+
|
|
162
|
+
- Boatman
|
|
163
|
+
|
|
164
|
+
## 2.1.2
|
|
165
|
+
|
|
166
|
+
- LegecyRemote htmlTop 注入 bugmeRRemote
|
|
167
|
+
|
|
168
|
+
## 2.1.0
|
|
169
|
+
|
|
170
|
+
- tinybugme 0.0.38
|
|
171
|
+
|
|
172
|
+
## 2.0.0-alpha.13
|
|
173
|
+
|
|
174
|
+
- tinybugme 0.0.31
|
|
175
|
+
|
|
176
|
+
## 2.0.0-alpha.12
|
|
177
|
+
|
|
178
|
+
- tinybugme 0.0.23
|
|
179
|
+
- tyro 48a39846f1a310babc60d07344786f1ee65bf63c
|
|
180
|
+
|
|
181
|
+
## 2.0.0-alpha.11
|
|
182
|
+
|
|
183
|
+
- tinybugme 0.0.20
|
|
184
|
+
|
|
185
|
+
## 2.0.0-alpha.10
|
|
186
|
+
|
|
187
|
+
- Render 不使用 bugme/assets 加载脚本,直接打包源码
|
|
188
|
+
|
|
189
|
+
## 2.0.0-alpha.9
|
|
190
|
+
|
|
191
|
+
- fix onSocketOpen
|
|
192
|
+
|
|
193
|
+
## 2.0.0-alpha.8
|
|
194
|
+
|
|
195
|
+
- 使用 uniweb
|
|
196
|
+
- tinybugme 0.0.13
|
|
197
|
+
|
|
198
|
+
## 2.0.0-alpha.7
|
|
199
|
+
|
|
200
|
+
- bugmeRPreview 2.0 不注入
|
|
201
|
+
|
|
202
|
+
## 2.0.0-alpha.5
|
|
203
|
+
|
|
204
|
+
- 区分 BugmeRender Preview/Remote 两种脚本
|
|
205
|
+
|
|
206
|
+
## 2.0.0-alpha.4
|
|
207
|
+
|
|
208
|
+
- 兼容 SimulatorWithTyro mode
|
|
209
|
+
|
|
210
|
+
## 2.0.0
|
|
211
|
+
|
|
212
|
+
- 同时支持 Appx1.0/2.0 的版本
|
|
213
|
+
- bugmeWRemote/bugmeWPreview 分开注入
|
|
214
|
+
- h5data 拓展 v2 字段
|
|
215
|
+
|
|
216
|
+
## 1.0.3
|
|
217
|
+
|
|
218
|
+
- 更新 assets: fix console in iOS9 5edcab66bcbf9ea761cac8dcb2f5294db403262b
|
|
219
|
+
- 更新 tyro-assets: fix console in iOS9 cee63b712436033aba0d1df331b0330c2c6adedf
|
|
220
|
+
|
|
221
|
+
## 1.0.2
|
|
222
|
+
|
|
223
|
+
- 更新 assets: 2de4c2ae7d3e5a3fecb7426808b4e72daea89d64
|
|
224
|
+
- 兼容 JSI
|
|
225
|
+
- 兼容钉钉不存在 callSync
|
|
226
|
+
|
|
227
|
+
## 1.0.1
|
|
228
|
+
|
|
229
|
+
- 更新 assets: 兼容钉钉不存在 callSync 方法 1da33830f8b4a15c9a25a6a36d9cbaa79e064463
|
|
230
|
+
|
|
231
|
+
## 1.0.0
|
|
232
|
+
|
|
233
|
+
- 支持同/异步调用,重新设计对外接口
|
|
234
|
+
|
|
235
|
+
## 0.4.3
|
|
236
|
+
|
|
237
|
+
- 使用更轻量的 bent 替换 liburl
|
|
238
|
+
|
|
239
|
+
## 0.4.2
|
|
240
|
+
|
|
241
|
+
- 增加 generateInjectCode 方法,直接返回 Assets JSON;
|
|
242
|
+
|
|
243
|
+
## 0.4.1
|
|
244
|
+
|
|
245
|
+
- 更新 assets: 断线重连及清理连接 4621c1598645e76fe71c864104a18171df6db4c6
|
|
246
|
+
|
|
247
|
+
## 0.4.0
|
|
248
|
+
|
|
249
|
+
- 去除时间纬度的缓存,通过比较本地资源决定是否更新
|
|
250
|
+
- 增加 readonly 兜底文件损坏
|
|
251
|
+
- 支持设置外部 assets_map 路径
|
|
252
|
+
|
|
253
|
+
## 0.3.7
|
|
254
|
+
|
|
255
|
+
- 增加 compilePlugin 入参,只对插件产物注入 TyroAgent
|
|
256
|
+
|
|
257
|
+
## 0.3.6
|
|
258
|
+
|
|
259
|
+
- 废弃
|
|
260
|
+
|
|
261
|
+
## 0.3.5
|
|
262
|
+
|
|
263
|
+
- 更新 assets: 支持插件插桩调试
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
```
|
|
2
|
+
const debugUtils = require('builder-debug-utils');
|
|
3
|
+
|
|
4
|
+
const debugUtils.generateInjectCodePath({
|
|
5
|
+
target: 'Mini',
|
|
6
|
+
mode: 'Preview',
|
|
7
|
+
compilePlugin: false,
|
|
8
|
+
}); // /Users/foo/bar
|
|
9
|
+
|
|
10
|
+
tiny-cli --injectCodePath /Users/foo/bar
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
/offline/assets_map - 用于存储构建脚本文本
|
|
14
|
+
$TMPDIR/builder_debug_output_v2 - 用于作为 tiny-cli injectCodePath 入参
|
|
15
|
+
|
|
16
|
+
### API
|
|
17
|
+
|
|
18
|
+
- 检查更新
|
|
19
|
+
比较本地与服务端资源 sha256 是否相同,若不同更新本地资源
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
const injectCodePath = await updateInjectCodeAssets();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- 生成 injectCode
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
await generateInjectCode({
|
|
29
|
+
mode: 'Remotex',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
generateInjectCodeSync({
|
|
33
|
+
mode: 'Remotex',
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- 生成 injectCodePath
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
await generateInjectCodePath({
|
|
41
|
+
mode: 'Remotex',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
generateInjectCodePathSync({
|
|
45
|
+
mode: 'Remotex',
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- 获取 boatman 资源路径
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
await getBoatmanBundlePath();
|
|
53
|
+
|
|
54
|
+
getBoatmanBundlePathSync();
|
|
55
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("fs-extra")),n=e(require("bent")),o=e(require("crypto")),a=e(require("os")),i=e(require("path")),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e,t){return e(t={exports:{}},t.exports),t.exports}var d=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Mini="Mini",e.Cube="Cube"}(t.ECompileTargetType||(t.ECompileTargetType={})),function(e){e.Remote="Remote",e.Remotex="Remotex",e.RemotexLite="RemotexLite",e.Preview="Preview",e.RemoteBoatman="RemoteBoatman"}(t.ECompileModeType||(t.ECompileModeType={}))}));s(d);d.ECompileTargetType,d.ECompileModeType;var u=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.defaultConfig={assetsQueryUrl:"https://render.alipay.com/p/s/h5data/prod/h5config/builder-debug-h5data.json",injectCodeTempPath:i.join(a.tmpdir(),"./builder_debug_output_v2"),offlineDirectoryPath:i.join(__dirname,"../offline"),readonlyDirectoryPath:i.join(__dirname,"../readonly"),assetsMapFilename:"assets_map",boatmanFilename:{[d.ECompileTargetType.Mini]:"boatman_mini",[d.ECompileTargetType.Cube]:"boatman_cube"}},t.libName="builder-debug-utils"}));s(u);u.defaultConfig,u.libName;var c=l((function(e,a){var i=r&&r.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(a,i){function r(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))},s=r&&r.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(a,"__esModule",{value:!0});const l=s(n),c=s(t),p=s(o),f=l.default("json"),h=l.default("buffer"),g=`[${u.libName}]`;a.AssetsUpdater=class{constructor(e){this.context=e}updateOfflineAssetsToday(){return i(this,void 0,void 0,(function*(){!function(e){return i(this,void 0,void 0,(function*(){try{const t=yield c.default.stat(e),n=new Date(parseInt(""+t.mtimeMs,10));return(new Date).toLocaleDateString()===n.toLocaleDateString()}catch(e){return!1}}))}(this.context.getAssetsMapFilePath())?(console.log(g+" local assets are outdated, start to download new debug assets"),yield this.updateOfflineAssets()):console.log(g+" local assets are in the period of validity")}))}updateOfflineAssets(){return i(this,void 0,void 0,(function*(){if(this.updatingTask)return this.updatingTask;this.updatingTask=this.runUpdateTask();try{yield this.updatingTask,this.updatingTask=void 0}catch(e){throw this.updatingTask=void 0,e}}))}runUpdateTask(){return i(this,void 0,void 0,(function*(){let e;try{e=yield f(u.defaultConfig.assetsQueryUrl)}catch(e){throw new Error("Failed to request online config")}yield Promise.all([this.updateLocalFile(this.context.getAssetsMapFilePath(),e.url_v2,e.integrity_v2),this.updateLocalFile(this.context.getBoatmanFilePath(d.ECompileTargetType.Mini),e.url_boatman_mini,e.integrity_boatman_mini),this.updateLocalFile(this.context.getBoatmanFilePath(d.ECompileTargetType.Cube),e.url_boatman_cube,e.integrity_boatman_cube)])}))}updateLocalFile(e,t,n){return i(this,void 0,void 0,(function*(){if(!t||!n)return void console.error(g+" Empty key in config");try{const t=yield c.default.readFile(e);if(p.default.createHash("sha256").update(t).digest("base64")===n)return void console.log(g+" Local is latested")}catch(e){}let o;console.log(g+" Start to update local");try{o=yield h(t)}catch(e){return void console.error(`${g} Download error ${e.message}`)}if(p.default.createHash("sha256").update(o).digest("base64")!==n)throw new Error("Failed to verify");yield c.default.writeFile(e,o),console.log(g+" Updated")}))}}}));s(c);c.AssetsUpdater;var p=l((function(e,t){function n(...e){return e.join("\n")}function o(e,t){return t.target===d.ECompileTargetType.Cube?{}:{workerTop:e.bugmeWPreview,htmlTop:"<script>window.__BUGME_ENV__='preview';<\/script>"+e.bugmeRPreview}}function a(e,t){return{htmlTop:e.bugmeRRemote}}function i(e,t){return t.compilePlugin?{workerTop:e.bugmeWRemote,pluginWorkerTop:e.tyroAgent,htmlTop:e.bugmeRRemote}:{workerTop:n(e.tyroAgent||"",e.bugmeWRemote||""),htmlTop:e.bugmeRRemote}}function r(e,t){return{workerTop:n("var __BUGME_CONSOLE_ENABLE__=true;",e.bugmeWRemote||""),htmlTop:e.bugmeRRemote}}function s(e,t){if(t.target===d.ECompileTargetType.Cube)return{};{const n={htmlTop:e.bugmeRRemote};return t.compilePlugin&&(n.workerTop=e.bugmeWRemote),n}}Object.defineProperty(t,"__esModule",{value:!0}),t.composeAssetsByCompileMode=function(e,t){let n;switch(t.mode){case d.ECompileModeType.Preview:n=o;break;case d.ECompileModeType.Remote:n=a;break;case d.ECompileModeType.Remotex:n=i;break;case d.ECompileModeType.RemotexLite:n=r;break;case d.ECompileModeType.RemoteBoatman:n=s;break;default:throw new Error(`[${u.libName}] unknown compile mode: ${t.mode}`)}return n(e,t)}}));s(p);p.composeAssetsByCompileMode;var f=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});t.BuilderDebugContext=class{constructor(e){this.assetsQueryUrl="",this.injectCodeTempPath="",this.offlineDirectoryPath="",this.readonlyDirectoryPath="",this.assetsMapFilename="",this.assetsQueryUrl=e.assetsQueryUrl,this.injectCodeTempPath=e.injectCodeTempPath,this.offlineDirectoryPath=e.offlineDirectoryPath,this.readonlyDirectoryPath=e.readonlyDirectoryPath,this.assetsMapFilename=e.assetsMapFilename,this.boatmanFilename=e.boatmanFilename}getAssetsMapFilePath(){return i.join(this.offlineDirectoryPath,this.assetsMapFilename)}getBoatmanFilePath(e){return i.join(this.offlineDirectoryPath,this.boatmanFilename[e])}getReadonlyAssetsMapFilePath(){return i.join(this.readonlyDirectoryPath,this.assetsMapFilename)}getReadonlyBoatmanFilePath(e){return i.join(this.readonlyDirectoryPath,this.boatmanFilename[e])}}}));s(f);f.BuilderDebugContext;var h=l((function(e,n){var o=r&&r.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(a,i){function r(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))},a=r&&r.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0});const i=a(t);function s(e){const t={target:d.ECompileTargetType.Mini};return e.target&&Object.keys(d.ECompileTargetType).indexOf(e.target)>-1&&(t.target=e.target),t}function l(e){const t=Object.assign({},e);if(!t.mode||-1===Object.keys(d.ECompileModeType).indexOf(t.mode))throw new Error(`[${u.libName}] invalid 'mode' option: ${t.mode}`);return t.target&&-1!==Object.keys(d.ECompileTargetType).indexOf(t.target)||(t.target=d.ECompileTargetType.Mini),e}n.BuilderDebugClient=class{constructor(e){this.context=new f.BuilderDebugContext(Object.assign(Object.assign({},u.defaultConfig),e))}updateOfflineAssets(e){return o(this,void 0,void 0,(function*(){this.assetsUpdater||(this.assetsUpdater=new c.AssetsUpdater(this.context)),e.cacheToday?yield this.assetsUpdater.updateOfflineAssetsToday():yield this.assetsUpdater.updateOfflineAssets()}))}generateInjectCode(e){return o(this,void 0,void 0,(function*(){e=l(e);const t=yield function(e){return o(this,void 0,void 0,(function*(){let t;try{t=yield i.default.readJSON(e.getAssetsMapFilePath(),{throws:!1})}catch(e){}return t||(console.log(`[${u.libName}] offline assets_map file was damaged, fallback to readonly file`),t=yield i.default.readJSON(e.getReadonlyAssetsMapFilePath())),t}))}(this.context);return p.composeAssetsByCompileMode(t,e)}))}generateInjectCodeSync(e){e=l(e);const t=function(e){let t=i.default.readJSONSync(e.getAssetsMapFilePath(),{throws:!1});t||(console.log(`[${u.libName}] offline assets_map file was damaged, fallback to readonly file`),t=i.default.readJSONSync(e.getReadonlyAssetsMapFilePath()));return t}(this.context);return p.composeAssetsByCompileMode(t,e)}generateInjectCodePath(e){return o(this,void 0,void 0,(function*(){const t=yield this.generateInjectCode(e);return yield i.default.writeJSON(u.defaultConfig.injectCodeTempPath,t),u.defaultConfig.injectCodeTempPath}))}generateInjectCodePathSync(e){const t=this.generateInjectCodeSync(e);return i.default.writeJSONSync(u.defaultConfig.injectCodeTempPath,t),u.defaultConfig.injectCodeTempPath}getBoatmanBundlePath(e){return o(this,void 0,void 0,(function*(){const t=s(e);try{const e=this.context.getBoatmanFilePath(t.target);return yield i.default.access(e,i.default.constants.R_OK),e}catch(e){return this.context.getReadonlyBoatmanFilePath(t.target)}}))}getBoatmanBundlePathSync(e){const t=s(e);try{const e=this.context.getBoatmanFilePath(t.target);return i.default.accessSync(e,i.default.constants.R_OK),e}catch(e){return this.context.getReadonlyBoatmanFilePath(t.target)}}}}));s(h);h.BuilderDebugClient;var g=l((function(e,t){var n=r&&r.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(a,i){function r(e){try{l(o.next(e))}catch(e){i(e)}}function s(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,s)}l((o=o.apply(e,t||[])).next())}))};let o;function a(){return o||(o=new h.BuilderDebugClient),o}Object.defineProperty(t,"__esModule",{value:!0}),t.updateInjectCodeAssets=function(e={}){return n(this,void 0,void 0,(function*(){return a().updateOfflineAssets(e)}))},t.generateInjectCode=function(e){return n(this,void 0,void 0,(function*(){return a().generateInjectCode(e)}))},t.generateInjectCodeSync=function(e){return a().generateInjectCodeSync(e)},t.generateInjectCodePath=function(e){return n(this,void 0,void 0,(function*(){return a().generateInjectCodePath(e)}))},t.generateInjectCodePathSync=function(e){return a().generateInjectCodePathSync(e)},t.getBoatmanBundlePath=function(e={}){return n(this,void 0,void 0,(function*(){return a().getBoatmanBundlePath(e)}))},t.getBoatmanBundlePathSync=function(e={}){return a().getBoatmanBundlePathSync(e)},t.loadConfig=function(e){o=new h.BuilderDebugClient(e)}}));s(g);g.updateInjectCodeAssets,g.generateInjectCode,g.generateInjectCodeSync,g.generateInjectCodePath,g.generateInjectCodePathSync,g.getBoatmanBundlePath,g.getBoatmanBundlePathSync,g.loadConfig;var m=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ECompileModeType=d.ECompileModeType,t.ECompileTargetType=d.ECompileTargetType,t.BuilderDebugClient=h.BuilderDebugClient,t.updateInjectCodeAssets=g.updateInjectCodeAssets,t.generateInjectCode=g.generateInjectCode,t.generateInjectCodeSync=g.generateInjectCodeSync,t.generateInjectCodePath=g.generateInjectCodePath,t.generateInjectCodePathSync=g.generateInjectCodePathSync,t.getBoatmanBundlePath=g.getBoatmanBundlePath,t.getBoatmanBundlePathSync=g.getBoatmanBundlePathSync,t.loadConfig=g.loadConfig})),y=s(m),C=m.ECompileModeType,P=m.ECompileTargetType,b=m.BuilderDebugClient,T=m.updateInjectCodeAssets,v=m.generateInjectCode,j=m.generateInjectCodeSync,_=m.generateInjectCodePath,B=m.generateInjectCodePathSync,w=m.getBoatmanBundlePath,M=m.getBoatmanBundlePathSync,x=m.loadConfig;exports.BuilderDebugClient=b,exports.ECompileModeType=C,exports.ECompileTargetType=P,exports.default=y,exports.generateInjectCode=v,exports.generateInjectCodePath=_,exports.generateInjectCodePathSync=B,exports.generateInjectCodeSync=j,exports.getBoatmanBundlePath=w,exports.getBoatmanBundlePathSync=M,exports.loadConfig=x,exports.updateInjectCodeAssets=T;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const interface_1 = require("./interface");
|
|
4
|
+
const config_1 = require("./config");
|
|
5
|
+
function concatSource(...argv) {
|
|
6
|
+
return argv.join('\n');
|
|
7
|
+
}
|
|
8
|
+
function composeAssetsByCompileMode(assetsMap, options) {
|
|
9
|
+
let composeMethod;
|
|
10
|
+
switch (options.mode) {
|
|
11
|
+
case interface_1.ECompileModeType.Preview:
|
|
12
|
+
composeMethod = composeAssets4Preview;
|
|
13
|
+
break;
|
|
14
|
+
case interface_1.ECompileModeType.Remote:
|
|
15
|
+
composeMethod = composeAssets4Remote;
|
|
16
|
+
break;
|
|
17
|
+
case interface_1.ECompileModeType.Remotex:
|
|
18
|
+
composeMethod = composeAssets4Remotex;
|
|
19
|
+
break;
|
|
20
|
+
case interface_1.ECompileModeType.RemotexLite:
|
|
21
|
+
composeMethod = composeAssets4RemotexLite;
|
|
22
|
+
break;
|
|
23
|
+
case interface_1.ECompileModeType.RemoteBoatman:
|
|
24
|
+
composeMethod = composeAssets4RemoteBoatman;
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
throw new Error(`[${config_1.libName}] unknown compile mode: ${options.mode}`);
|
|
28
|
+
}
|
|
29
|
+
return composeMethod(assetsMap, options);
|
|
30
|
+
}
|
|
31
|
+
exports.composeAssetsByCompileMode = composeAssetsByCompileMode;
|
|
32
|
+
function composeAssets4Preview(assetsMap, options) {
|
|
33
|
+
if (options.target === interface_1.ECompileTargetType.Cube) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return {
|
|
38
|
+
workerTop: assetsMap.bugmeWPreview,
|
|
39
|
+
htmlTop: `<script>window.__BUGME_ENV__='preview';</script>${assetsMap.bugmeRPreview}`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function composeAssets4Remote(assetsMap, options) {
|
|
44
|
+
return {
|
|
45
|
+
htmlTop: assetsMap.bugmeRRemote,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function composeAssets4Remotex(assetsMap, options) {
|
|
49
|
+
return options.compilePlugin
|
|
50
|
+
? {
|
|
51
|
+
workerTop: assetsMap.bugmeWRemote,
|
|
52
|
+
pluginWorkerTop: assetsMap.tyroAgent,
|
|
53
|
+
htmlTop: assetsMap.bugmeRRemote,
|
|
54
|
+
}
|
|
55
|
+
: {
|
|
56
|
+
workerTop: concatSource(assetsMap.tyroAgent || '', assetsMap.bugmeWRemote || ''),
|
|
57
|
+
htmlTop: assetsMap.bugmeRRemote,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function composeAssets4RemotexLite(assetsMap, options) {
|
|
61
|
+
return {
|
|
62
|
+
workerTop: concatSource('var __BUGME_CONSOLE_ENABLE__=true;', assetsMap.bugmeWRemote || ''),
|
|
63
|
+
htmlTop: assetsMap.bugmeRRemote,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function composeAssets4RemoteBoatman(assetsMap, options) {
|
|
67
|
+
if (options.target === interface_1.ECompileTargetType.Cube) {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
// Boatman 模式下 tinybugme 会跟随 boatman_mini 一起注入到 worker 中
|
|
72
|
+
const points = {
|
|
73
|
+
htmlTop: assetsMap.bugmeRRemote,
|
|
74
|
+
};
|
|
75
|
+
// 插件模式下 boatman_mini 注入到插件上下文中,tinybugme 不会生效,因此需要额外注入到宿主 worker 中
|
|
76
|
+
if (options.compilePlugin) {
|
|
77
|
+
points.workerTop = assetsMap.bugmeWRemote;
|
|
78
|
+
}
|
|
79
|
+
return points;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const os_1 = require("os");
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const interface_1 = require("./interface");
|
|
6
|
+
exports.defaultConfig = {
|
|
7
|
+
assetsQueryUrl: 'https://render.alipay.com/p/s/h5data/prod/h5config/builder-debug-h5data.json',
|
|
8
|
+
injectCodeTempPath: path_1.join(os_1.tmpdir(), './builder_debug_output_v2'),
|
|
9
|
+
offlineDirectoryPath: path_1.join(__dirname, '../offline'),
|
|
10
|
+
readonlyDirectoryPath: path_1.join(__dirname, '../readonly'),
|
|
11
|
+
assetsMapFilename: 'assets_map',
|
|
12
|
+
boatmanFilename: {
|
|
13
|
+
[interface_1.ECompileTargetType.Mini]: 'boatman_mini',
|
|
14
|
+
// Cube 未支持,先占位
|
|
15
|
+
[interface_1.ECompileTargetType.Cube]: 'boatman_cube',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
exports.libName = 'builder-debug-utils';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IBuilderDebugConfig, ECompileTargetType } from './interface';
|
|
2
|
+
export declare class BuilderDebugContext {
|
|
3
|
+
assetsQueryUrl: string;
|
|
4
|
+
injectCodeTempPath: string;
|
|
5
|
+
protected offlineDirectoryPath: string;
|
|
6
|
+
protected readonlyDirectoryPath: string;
|
|
7
|
+
protected assetsMapFilename: string;
|
|
8
|
+
protected boatmanFilename: Record<ECompileTargetType, string>;
|
|
9
|
+
constructor(config: IBuilderDebugConfig);
|
|
10
|
+
getAssetsMapFilePath(): string;
|
|
11
|
+
getBoatmanFilePath(target: ECompileTargetType): string;
|
|
12
|
+
getReadonlyAssetsMapFilePath(): string;
|
|
13
|
+
getReadonlyBoatmanFilePath(target: ECompileTargetType): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
class BuilderDebugContext {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.assetsQueryUrl = '';
|
|
7
|
+
this.injectCodeTempPath = '';
|
|
8
|
+
this.offlineDirectoryPath = '';
|
|
9
|
+
this.readonlyDirectoryPath = '';
|
|
10
|
+
this.assetsMapFilename = '';
|
|
11
|
+
this.assetsQueryUrl = config.assetsQueryUrl;
|
|
12
|
+
this.injectCodeTempPath = config.injectCodeTempPath;
|
|
13
|
+
this.offlineDirectoryPath = config.offlineDirectoryPath;
|
|
14
|
+
this.readonlyDirectoryPath = config.readonlyDirectoryPath;
|
|
15
|
+
this.assetsMapFilename = config.assetsMapFilename;
|
|
16
|
+
this.boatmanFilename = config.boatmanFilename;
|
|
17
|
+
}
|
|
18
|
+
getAssetsMapFilePath() {
|
|
19
|
+
return path_1.join(this.offlineDirectoryPath, this.assetsMapFilename);
|
|
20
|
+
}
|
|
21
|
+
getBoatmanFilePath(target) {
|
|
22
|
+
return path_1.join(this.offlineDirectoryPath, this.boatmanFilename[target]);
|
|
23
|
+
}
|
|
24
|
+
getReadonlyAssetsMapFilePath() {
|
|
25
|
+
return path_1.join(this.readonlyDirectoryPath, this.assetsMapFilename);
|
|
26
|
+
}
|
|
27
|
+
getReadonlyBoatmanFilePath(target) {
|
|
28
|
+
return path_1.join(this.readonlyDirectoryPath, this.boatmanFilename[target]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.BuilderDebugContext = BuilderDebugContext;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ECompileModeType, ECompileTargetType, IBuilderDebugClient, IBuilderDebugClientOptions } from './interface';
|
|
2
|
+
export { BuilderDebugClient } from './sdk';
|
|
3
|
+
export { updateInjectCodeAssets, generateInjectCode, generateInjectCodeSync, generateInjectCodePath, generateInjectCodePathSync, getBoatmanBundlePath, getBoatmanBundlePathSync, loadConfig, } from './utils';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// export * 导出 commonjs 会多一层 default
|
|
4
|
+
var interface_1 = require("./interface");
|
|
5
|
+
exports.ECompileModeType = interface_1.ECompileModeType;
|
|
6
|
+
exports.ECompileTargetType = interface_1.ECompileTargetType;
|
|
7
|
+
var sdk_1 = require("./sdk");
|
|
8
|
+
exports.BuilderDebugClient = sdk_1.BuilderDebugClient;
|
|
9
|
+
var utils_1 = require("./utils");
|
|
10
|
+
exports.updateInjectCodeAssets = utils_1.updateInjectCodeAssets;
|
|
11
|
+
exports.generateInjectCode = utils_1.generateInjectCode;
|
|
12
|
+
exports.generateInjectCodeSync = utils_1.generateInjectCodeSync;
|
|
13
|
+
exports.generateInjectCodePath = utils_1.generateInjectCodePath;
|
|
14
|
+
exports.generateInjectCodePathSync = utils_1.generateInjectCodePathSync;
|
|
15
|
+
exports.getBoatmanBundlePath = utils_1.getBoatmanBundlePath;
|
|
16
|
+
exports.getBoatmanBundlePathSync = utils_1.getBoatmanBundlePathSync;
|
|
17
|
+
exports.loadConfig = utils_1.loadConfig;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export declare enum ECompileTargetType {
|
|
2
|
+
Mini = "Mini",
|
|
3
|
+
Cube = "Cube"
|
|
4
|
+
}
|
|
5
|
+
export declare enum ECompileModeType {
|
|
6
|
+
Remote = "Remote",
|
|
7
|
+
Remotex = "Remotex",
|
|
8
|
+
RemotexLite = "RemotexLite",
|
|
9
|
+
Preview = "Preview",
|
|
10
|
+
RemoteBoatman = "RemoteBoatman"
|
|
11
|
+
}
|
|
12
|
+
export interface IGenerateInjectCodeOptions {
|
|
13
|
+
mode: ECompileModeType;
|
|
14
|
+
target?: ECompileTargetType;
|
|
15
|
+
compilePlugin?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface IGetBoatmanBundleOptions {
|
|
18
|
+
target?: ECompileTargetType;
|
|
19
|
+
}
|
|
20
|
+
export interface IInjectionPoints {
|
|
21
|
+
htmlTop?: string;
|
|
22
|
+
webTop?: string;
|
|
23
|
+
workerTop?: string;
|
|
24
|
+
pluginWebTop?: string;
|
|
25
|
+
pluginWorkerTop?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface IUpdateAssetsOptions {
|
|
28
|
+
cacheToday?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface IOnlineAssetsConfig {
|
|
31
|
+
integrity: string;
|
|
32
|
+
url: string;
|
|
33
|
+
integrity_v2: string;
|
|
34
|
+
url_v2: string;
|
|
35
|
+
url_boatman_mini: string;
|
|
36
|
+
integrity_boatman_mini: string;
|
|
37
|
+
url_boatman_cube?: string;
|
|
38
|
+
integrity_boatman_cube: string;
|
|
39
|
+
}
|
|
40
|
+
export interface IAssetsMap {
|
|
41
|
+
tyroAgent?: string;
|
|
42
|
+
bugmeRRemote?: string;
|
|
43
|
+
bugmeRPreview?: string;
|
|
44
|
+
bugmeWRemote?: string;
|
|
45
|
+
bugmeWPreview?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface IBuilderDebugClientOptions extends IBuilderDebugConfig {
|
|
48
|
+
}
|
|
49
|
+
export interface IBuilderDebugConfig {
|
|
50
|
+
assetsQueryUrl: string;
|
|
51
|
+
injectCodeTempPath: string;
|
|
52
|
+
offlineDirectoryPath: string;
|
|
53
|
+
readonlyDirectoryPath: string;
|
|
54
|
+
assetsMapFilename: string;
|
|
55
|
+
boatmanFilename: Record<ECompileTargetType, string>;
|
|
56
|
+
}
|
|
57
|
+
export interface IBuilderDebugClient {
|
|
58
|
+
/**
|
|
59
|
+
* 检查更新本地 offline 目录下的资源文件
|
|
60
|
+
*/
|
|
61
|
+
updateOfflineAssets(options: IUpdateAssetsOptions): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* 生成构建器消费的 InjectCode 注入点对象
|
|
64
|
+
*/
|
|
65
|
+
generateInjectCode(options: IGenerateInjectCodeOptions): Promise<IInjectionPoints>;
|
|
66
|
+
/**
|
|
67
|
+
* generateInjectCode 同步方法
|
|
68
|
+
*/
|
|
69
|
+
generateInjectCodeSync(options: IGenerateInjectCodeOptions): IInjectionPoints;
|
|
70
|
+
/**
|
|
71
|
+
* 生成构建器消费的 InjectCode JSON 文件,并返回路径
|
|
72
|
+
*/
|
|
73
|
+
generateInjectCodePath(options: IGenerateInjectCodeOptions): Promise<string>;
|
|
74
|
+
/**
|
|
75
|
+
* generateInjectCodePath 同步方法
|
|
76
|
+
*/
|
|
77
|
+
generateInjectCodePathSync(options: IGenerateInjectCodeOptions): string;
|
|
78
|
+
/**
|
|
79
|
+
* 获取本地 boatman 文件资源路径
|
|
80
|
+
*/
|
|
81
|
+
getBoatmanBundlePath(options: IGetBoatmanBundleOptions): Promise<string>;
|
|
82
|
+
/**
|
|
83
|
+
* getBoatmanBundlePath 同步方法
|
|
84
|
+
*/
|
|
85
|
+
getBoatmanBundlePathSync(options: IGetBoatmanBundleOptions): string;
|
|
86
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var ECompileTargetType;
|
|
4
|
+
(function (ECompileTargetType) {
|
|
5
|
+
ECompileTargetType["Mini"] = "Mini";
|
|
6
|
+
ECompileTargetType["Cube"] = "Cube";
|
|
7
|
+
})(ECompileTargetType = exports.ECompileTargetType || (exports.ECompileTargetType = {}));
|
|
8
|
+
var ECompileModeType;
|
|
9
|
+
(function (ECompileModeType) {
|
|
10
|
+
ECompileModeType["Remote"] = "Remote";
|
|
11
|
+
ECompileModeType["Remotex"] = "Remotex";
|
|
12
|
+
ECompileModeType["RemotexLite"] = "RemotexLite";
|
|
13
|
+
ECompileModeType["Preview"] = "Preview";
|
|
14
|
+
ECompileModeType["RemoteBoatman"] = "RemoteBoatman";
|
|
15
|
+
})(ECompileModeType = exports.ECompileModeType || (exports.ECompileModeType = {}));
|