@cloudbase/lowcode-builder 1.8.19 → 1.8.21
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/dist/builder.web.js +2 -2
- package/lib/builder.web.js +2 -2
- package/package.json +3 -3
- package/lib/weapp-page.d.ts +0 -17
- package/lib/weapp-page.js +0 -301
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.21",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@babel/core": "
|
|
43
|
-
"@babel/preset-env": "
|
|
42
|
+
"@babel/core": "7.12.3",
|
|
43
|
+
"@babel/preset-env": "7.12.1",
|
|
44
44
|
"@cloudbase/cals": "^1.0.15",
|
|
45
45
|
"@cloudbase/lowcode-generator": "^1.8.9",
|
|
46
46
|
"axios": "^0.21.0",
|
package/lib/weapp-page.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare function createPage({ app, id, widgetProps, index, lifecycle, state, computed, evtListeners, dataBinds, handlers, query: datasetQuery, eventFlows, pageContext, pageAttributes, enableShare, }: {
|
|
2
|
-
app: any;
|
|
3
|
-
id: any;
|
|
4
|
-
widgetProps: any;
|
|
5
|
-
index?: {} | undefined;
|
|
6
|
-
lifecycle: any;
|
|
7
|
-
state: any;
|
|
8
|
-
computed: any;
|
|
9
|
-
evtListeners: any;
|
|
10
|
-
dataBinds: any;
|
|
11
|
-
handlers: any;
|
|
12
|
-
query?: {} | undefined;
|
|
13
|
-
eventFlows?: never[] | undefined;
|
|
14
|
-
pageContext?: {} | undefined;
|
|
15
|
-
pageAttributes?: {} | undefined;
|
|
16
|
-
enableShare?: boolean | undefined;
|
|
17
|
-
}): string;
|
package/lib/weapp-page.js
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createPage = void 0;
|
|
7
|
-
const mobx_1 = require("mobx");
|
|
8
|
-
const util_1 = require("./util");
|
|
9
|
-
const widget_1 = require("./widget");
|
|
10
|
-
const merge_renderer_1 = __importDefault(require("./merge-renderer"));
|
|
11
|
-
const index_1 = require("../datasources/index");
|
|
12
|
-
const watch_1 = require("./watch");
|
|
13
|
-
const weapps_api_1 = require("../app/weapps-api");
|
|
14
|
-
const event_emitter_1 = require("./event-emitter");
|
|
15
|
-
const weda_client_1 = require("@cloudbase/weda-client");
|
|
16
|
-
const wxApp = getApp();
|
|
17
|
-
function extractLifecycles(ctx, lifecycle, appShareMessage, enableShare = false) {
|
|
18
|
-
const result = {};
|
|
19
|
-
Object.keys(lifecycle).map((name) => {
|
|
20
|
-
result[name] = function () {
|
|
21
|
-
return lifecycle[name].apply(this._getInstance(), arguments);
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
if (enableShare) {
|
|
25
|
-
result['onShareAppMessage'] = (res) => {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
27
|
-
if ((res === null || res === void 0 ? void 0 : res.from) === 'button' && ((_b = (_a = res === null || res === void 0 ? void 0 : res.target) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.weda_share_info)) {
|
|
28
|
-
return (_d = (_c = res === null || res === void 0 ? void 0 : res.target) === null || _c === void 0 ? void 0 : _c.dataset) === null || _d === void 0 ? void 0 : _d.weda_share_info;
|
|
29
|
-
}
|
|
30
|
-
else if ((res === null || res === void 0 ? void 0 : res.from) === 'menu' && (appShareMessage === null || appShareMessage === void 0 ? void 0 : appShareMessage.enable)) {
|
|
31
|
-
let { pageId, params, imageUrl, title, packageName } = appShareMessage || {};
|
|
32
|
-
return {
|
|
33
|
-
path: (0, weda_client_1.generatePageUrl)({
|
|
34
|
-
pageId,
|
|
35
|
-
packageName,
|
|
36
|
-
params,
|
|
37
|
-
}),
|
|
38
|
-
imageUrl: ((_g = (_f = (_e = ctx.app) === null || _e === void 0 ? void 0 : _e.__internal__) === null || _f === void 0 ? void 0 : _f.resolveStaticResourceUrl) === null || _g === void 0 ? void 0 : _g.call(_f, imageUrl)) || imageUrl,
|
|
39
|
-
title,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
return ((_h = lifecycle === null || lifecycle === void 0 ? void 0 : lifecycle['onShareAppMessage']) === null || _h === void 0 ? void 0 : _h.call(lifecycle)) || {};
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
console.log(error);
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
// 更新设备信息 窗口信息
|
|
52
|
-
result['onResize'] = (res) => {
|
|
53
|
-
var _a, _b, _c, _d;
|
|
54
|
-
let device = weapps_api_1.$w.device;
|
|
55
|
-
if (!device) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const width = (_a = res === null || res === void 0 ? void 0 : res.size) === null || _a === void 0 ? void 0 : _a.windowWidth;
|
|
59
|
-
const height = (_b = res === null || res === void 0 ? void 0 : res.size) === null || _b === void 0 ? void 0 : _b.windowHeight;
|
|
60
|
-
if (width !== ((_c = device === null || device === void 0 ? void 0 : device.viewport) === null || _c === void 0 ? void 0 : _c.width) || height !== ((_d = device === null || device === void 0 ? void 0 : device.viewport) === null || _d === void 0 ? void 0 : _d.height)) {
|
|
61
|
-
device.viewport = {
|
|
62
|
-
width,
|
|
63
|
-
height,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
function createPage({ app, id, widgetProps, index = {}, lifecycle, state, computed, evtListeners, dataBinds, handlers, query: datasetQuery = {}, eventFlows = [], pageContext = {}, pageAttributes = {}, enableShare = false, }) {
|
|
70
|
-
const evtHandlers = (0, util_1.createEventHandlers)(evtListeners);
|
|
71
|
-
return Component({
|
|
72
|
-
_componentType: 'page',
|
|
73
|
-
data: {
|
|
74
|
-
...(0, widget_1.createInitData)(widgetProps, dataBinds),
|
|
75
|
-
_isCheckingAtuh: false,
|
|
76
|
-
weDaHasLogin: false,
|
|
77
|
-
},
|
|
78
|
-
lifetimes: {
|
|
79
|
-
attached() {
|
|
80
|
-
this._disposers = [];
|
|
81
|
-
const $page = this._getInstance();
|
|
82
|
-
this._pageActive = true;
|
|
83
|
-
/**
|
|
84
|
-
* @deprecated
|
|
85
|
-
* 使用 behavior 的方式挂载methods
|
|
86
|
-
*/
|
|
87
|
-
this.__mnt__ = (e) => {
|
|
88
|
-
const widget = (0, widget_1.getWidget)($page.widgets, e.target.id);
|
|
89
|
-
widget._methods = e.detail.methods;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* @deprecated
|
|
93
|
-
* 使用 behavior 的方式挂载methods
|
|
94
|
-
*/
|
|
95
|
-
this.__unmnt__ = (e) => {
|
|
96
|
-
const widget = (0, widget_1.getWidget)($page.widgets, e.target.id);
|
|
97
|
-
widget._methods = {};
|
|
98
|
-
};
|
|
99
|
-
this._disposers.push(...this.initMergeRenderer($page.widgets));
|
|
100
|
-
},
|
|
101
|
-
detached() {
|
|
102
|
-
const $page = this._getInstance();
|
|
103
|
-
this._pageActive = false;
|
|
104
|
-
$page.__internal__.active = this._pageActive;
|
|
105
|
-
(0, widget_1.disposeWidget)($page._rootWidget);
|
|
106
|
-
this._disposers.forEach((dispose) => dispose());
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
pageLifetimes: {
|
|
110
|
-
// 组件所在页面的生命周期函数,定义下给运营平台上报用
|
|
111
|
-
show: function () { },
|
|
112
|
-
hide: function () { },
|
|
113
|
-
},
|
|
114
|
-
methods: {
|
|
115
|
-
_pageActive: true,
|
|
116
|
-
_beforePageCustomLaunchPromise: null,
|
|
117
|
-
_query: {},
|
|
118
|
-
_disposers: [],
|
|
119
|
-
/** page lifecycles **/
|
|
120
|
-
...extractLifecycles({ app }, lifecycle, pageAttributes === null || pageAttributes === void 0 ? void 0 : pageAttributes.appShareMessage, enableShare),
|
|
121
|
-
...evtHandlers,
|
|
122
|
-
...merge_renderer_1.default,
|
|
123
|
-
async beforePageCustomLaunch(query) {
|
|
124
|
-
if (!this._beforePageCustomLaunchPromise) {
|
|
125
|
-
this._beforePageCustomLaunchPromise = new Promise(async (resolve) => {
|
|
126
|
-
var _a, _b, _c, _d, _e;
|
|
127
|
-
await ((_a = wxApp.globaldata) === null || _a === void 0 ? void 0 : _a._beforePageCustomLaunchPromise);
|
|
128
|
-
const $page = this._getInstance();
|
|
129
|
-
if (query) {
|
|
130
|
-
index_1.EXTRA_API.setParams($page.uuid, query);
|
|
131
|
-
}
|
|
132
|
-
try {
|
|
133
|
-
this.setData({ _isCheckingAtuh: true });
|
|
134
|
-
const auth = await (0, util_1.checkAuth)(app, app.id, $page);
|
|
135
|
-
if (auth) {
|
|
136
|
-
this.setData({
|
|
137
|
-
weDaHasLogin: true,
|
|
138
|
-
});
|
|
139
|
-
(0, index_1.createStateDataSourceVar)($page.uuid, (0, index_1.generateParamsParser)({ app, $page, $w: (_b = $page.__internal__) === null || _b === void 0 ? void 0 : _b.$w }));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
this.setData({ _isCheckingAtuh: false });
|
|
144
|
-
}
|
|
145
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
146
|
-
for (const queryId in ((_c = $page.dataset) === null || _c === void 0 ? void 0 : _c.query) || {}) {
|
|
147
|
-
if (((_e = (_d = $page.dataset.query[queryId]) === null || _d === void 0 ? void 0 : _d._schema) === null || _e === void 0 ? void 0 : _e.trigger) === 'auto') {
|
|
148
|
-
try {
|
|
149
|
-
$page.dataset.query[queryId].trigger();
|
|
150
|
-
this._disposers.push(() => $page.dataset.query[queryId].destroy());
|
|
151
|
-
}
|
|
152
|
-
catch (e) {
|
|
153
|
-
console.error(`query ${queryId} 初始化失败:`, e);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
resolve();
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
return this._beforePageCustomLaunchPromise;
|
|
161
|
-
},
|
|
162
|
-
async onLoad(options) {
|
|
163
|
-
var _a, _b;
|
|
164
|
-
const $page = this._getInstance();
|
|
165
|
-
(0, index_1.setConfig)({ currentPageId: $page.uuid });
|
|
166
|
-
this._pageActive = true;
|
|
167
|
-
$page.__internal__.active = this._pageActive;
|
|
168
|
-
app.__internal__.activePage = $page;
|
|
169
|
-
this._query = decodePageQuery(options || {});
|
|
170
|
-
await ((_a = this.beforePageCustomLaunch) === null || _a === void 0 ? void 0 : _a.call(this, this._query));
|
|
171
|
-
const hook = lifecycle.onLoad || lifecycle.onPageLoad;
|
|
172
|
-
await ((_b = hook === null || hook === void 0 ? void 0 : hook.call) === null || _b === void 0 ? void 0 : _b.call(hook, $page, this._query));
|
|
173
|
-
this._invokeEventHandler('load', { query: this._query });
|
|
174
|
-
},
|
|
175
|
-
async onReady() {
|
|
176
|
-
var _a;
|
|
177
|
-
const $page = this._getInstance();
|
|
178
|
-
this._disposers.push(...(0, watch_1.runWatchers)(index, this));
|
|
179
|
-
const hook = lifecycle.onReady || lifecycle.onPageReady;
|
|
180
|
-
await ((_a = hook === null || hook === void 0 ? void 0 : hook.call) === null || _a === void 0 ? void 0 : _a.call(hook, $page));
|
|
181
|
-
this._invokeEventHandler('ready');
|
|
182
|
-
},
|
|
183
|
-
onUnload() {
|
|
184
|
-
var _a;
|
|
185
|
-
const $page = this._getInstance();
|
|
186
|
-
const hook = lifecycle.onUnload || lifecycle.onPageUnload;
|
|
187
|
-
(_a = hook === null || hook === void 0 ? void 0 : hook.call) === null || _a === void 0 ? void 0 : _a.call(hook, $page);
|
|
188
|
-
this._invokeEventHandler('unload');
|
|
189
|
-
},
|
|
190
|
-
async onShow() {
|
|
191
|
-
var _a, _b;
|
|
192
|
-
const $page = this._getInstance();
|
|
193
|
-
(0, index_1.setConfig)({ currentPageId: $page.uuid });
|
|
194
|
-
this._pageActive = true;
|
|
195
|
-
$page.__internal__.active = this._pageActive;
|
|
196
|
-
app.__internal__.activePage = $page;
|
|
197
|
-
await ((_a = this.beforePageCustomLaunch) === null || _a === void 0 ? void 0 : _a.call(this, this._query));
|
|
198
|
-
const hook = lifecycle.onShow || lifecycle.onPageShow;
|
|
199
|
-
await ((_b = hook === null || hook === void 0 ? void 0 : hook.call) === null || _b === void 0 ? void 0 : _b.call(hook, $page));
|
|
200
|
-
this._invokeEventHandler('show');
|
|
201
|
-
},
|
|
202
|
-
onHide() {
|
|
203
|
-
var _a;
|
|
204
|
-
const $page = this._getInstance();
|
|
205
|
-
const hook = lifecycle.onHide || lifecycle.onPageHide;
|
|
206
|
-
(_a = hook === null || hook === void 0 ? void 0 : hook.call) === null || _a === void 0 ? void 0 : _a.call(hook, $page);
|
|
207
|
-
this._pageActive = false;
|
|
208
|
-
// 触发页面节点事件
|
|
209
|
-
this._invokeEventHandler('hide');
|
|
210
|
-
$page.__internal__.active = this._pageActive;
|
|
211
|
-
},
|
|
212
|
-
_invokeEventHandler(triggerName, params = {}) {
|
|
213
|
-
var _a, _b;
|
|
214
|
-
const keyName = (0, util_1.getMpEventHandlerName)(id, triggerName);
|
|
215
|
-
const event = new event_emitter_1.Event({
|
|
216
|
-
type: triggerName,
|
|
217
|
-
detail: params,
|
|
218
|
-
});
|
|
219
|
-
return (_b = (_a = this[keyName]) === null || _a === void 0 ? void 0 : _a.call) === null || _b === void 0 ? void 0 : _b.call(_a, this, event);
|
|
220
|
-
},
|
|
221
|
-
_getInstance() {
|
|
222
|
-
let $page = this.$WEAPPS_PAGE;
|
|
223
|
-
if ($page) {
|
|
224
|
-
return $page;
|
|
225
|
-
}
|
|
226
|
-
Object.assign(pageContext, {
|
|
227
|
-
id,
|
|
228
|
-
state: (0, mobx_1.observable)(state),
|
|
229
|
-
path: this.route,
|
|
230
|
-
widgets: {},
|
|
231
|
-
});
|
|
232
|
-
$page = pageContext;
|
|
233
|
-
this.$WEAPPS_PAGE = $page;
|
|
234
|
-
$page.handler = Object.keys(handlers).reduce((result, key) => {
|
|
235
|
-
try {
|
|
236
|
-
result[key] = handlers[key].bind($page);
|
|
237
|
-
}
|
|
238
|
-
catch (e) {
|
|
239
|
-
console.error('添加页面handler失败', e);
|
|
240
|
-
}
|
|
241
|
-
return result;
|
|
242
|
-
}, {});
|
|
243
|
-
$page.computed = (0, util_1.createComputed)(computed, $page);
|
|
244
|
-
let dataset = (0, index_1.createDataset)($page.uuid);
|
|
245
|
-
dataset.query = (0, util_1.generateDatasetQuery)(datasetQuery, {
|
|
246
|
-
$w: $page.__internal__.$w,
|
|
247
|
-
$app: app,
|
|
248
|
-
$page,
|
|
249
|
-
});
|
|
250
|
-
$page.dataset = dataset;
|
|
251
|
-
$page.state.dataset = dataset;
|
|
252
|
-
$page.setState = (userSetState) => {
|
|
253
|
-
Object.keys(userSetState).forEach((keyPath) => {
|
|
254
|
-
app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
|
|
255
|
-
});
|
|
256
|
-
};
|
|
257
|
-
const { widgets, rootWidget } = (0, widget_1.createWidgets)(widgetProps, dataBinds, this, $page.widgets);
|
|
258
|
-
$page.widgets = widgets;
|
|
259
|
-
$page._rootWidget = rootWidget;
|
|
260
|
-
$page.invokeComponentMethod = ({ component, method, params }) => {
|
|
261
|
-
var _a;
|
|
262
|
-
const components = $page.widgets[component];
|
|
263
|
-
let componentInstance = undefined;
|
|
264
|
-
if (Array.isArray(components)) {
|
|
265
|
-
if (components.length > 1) {
|
|
266
|
-
throw new Error(`调用方法失败:id为${component}的组件拥有多个实例`);
|
|
267
|
-
}
|
|
268
|
-
componentInstance = components[0];
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
componentInstance = components;
|
|
272
|
-
}
|
|
273
|
-
const currentInstanceRef = ((_a = componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance._getInstanceRef()) === null || _a === void 0 ? void 0 : _a.current) || {};
|
|
274
|
-
const { methods = {}, ...restInstanceRef } = currentInstanceRef;
|
|
275
|
-
const readonlyMap = {
|
|
276
|
-
...componentInstance === null || componentInstance === void 0 ? void 0 : componentInstance._methods,
|
|
277
|
-
...restInstanceRef,
|
|
278
|
-
...methods,
|
|
279
|
-
};
|
|
280
|
-
if (typeof readonlyMap[method] !== 'function') {
|
|
281
|
-
throw new Error(`调用方法失败:未找到id为${component}下的方法${method}`);
|
|
282
|
-
}
|
|
283
|
-
return readonlyMap[method](params);
|
|
284
|
-
};
|
|
285
|
-
$page.__internal__.eventFlows = (0, util_1.generateEventFlows)(eventFlows, {
|
|
286
|
-
$w: $page.__internal__.$w,
|
|
287
|
-
$app: app,
|
|
288
|
-
$page,
|
|
289
|
-
});
|
|
290
|
-
return $page;
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
exports.createPage = createPage;
|
|
296
|
-
function decodePageQuery(query) {
|
|
297
|
-
return Object.keys(query).reduce((decoded, key) => {
|
|
298
|
-
decoded[key] = decodeURIComponent(query[key]);
|
|
299
|
-
return decoded;
|
|
300
|
-
}, {});
|
|
301
|
-
}
|