@cloudbase/lowcode-builder 1.8.93 → 1.8.94
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/lib/builder.web.js +1 -1
- package/package.json +2 -2
- package/template/html/index.html.ejs +2 -2
- package/template/mp/app/weapps-api.js +15 -2
- package/template/mp/common/watch.js +20 -0
- package/template/mp/common/weapp-page.js +12 -2
- package/template/mp/datasources/index.js.tpl +4 -0
- package/template/mp/package.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.94",
|
|
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",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@babel/core": "7.21.4",
|
|
49
49
|
"@babel/preset-env": "7.21.4",
|
|
50
50
|
"@cloudbase/cals": "^1.0.75",
|
|
51
|
-
"@cloudbase/lowcode-generator": "^1.8.
|
|
51
|
+
"@cloudbase/lowcode-generator": "^1.8.27",
|
|
52
52
|
"axios": "^0.21.0",
|
|
53
53
|
"browserfs": "^1.4.3",
|
|
54
54
|
"browserify-zlib": "^0.2.0",
|
|
@@ -516,7 +516,7 @@
|
|
|
516
516
|
crossorigin="anonymous"
|
|
517
517
|
src="<%=
|
|
518
518
|
cdnEndpoints.cdngo
|
|
519
|
-
%>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.
|
|
519
|
+
%>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.59/dist/h5.browser.js"
|
|
520
520
|
></script>
|
|
521
521
|
<script
|
|
522
522
|
crossorigin
|
|
@@ -545,7 +545,7 @@
|
|
|
545
545
|
crossorigin
|
|
546
546
|
src="<%=
|
|
547
547
|
cdnEndpoints.cdngo
|
|
548
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
548
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.399c0d6128e9bf679e96.bundle.js"
|
|
549
549
|
></script>
|
|
550
550
|
</body>
|
|
551
551
|
</html>
|
|
@@ -8,13 +8,17 @@ import { createDataset } from '<%= subLevelPath %>../datasources/index'
|
|
|
8
8
|
|
|
9
9
|
import lodashGet from 'lodash.get';
|
|
10
10
|
import config from '<%= subLevelPath %>../common/config';
|
|
11
|
+
import { watchAndSyncDatasetState2Local } from '<%= subLevelPath %>../common/watch';
|
|
12
|
+
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
<%= importor.state? `import state from '../lowcode/state'` : "const state = {}" %>
|
|
14
16
|
<%= importor.computed? `import computed from '../lowcode/computed'` : "const computed = {}" %>
|
|
15
17
|
<%= importor.common? `import common from './common'` : "const common = {}" %>
|
|
16
18
|
|
|
17
|
-
const mainAppKey = '__weappsMainApp'
|
|
19
|
+
const mainAppKey = '__weappsMainApp';
|
|
20
|
+
let GLOBAL_DATASET_SYNC_DISPOSES = [];
|
|
21
|
+
|
|
18
22
|
|
|
19
23
|
<% function printBoundData(boundData={}) {
|
|
20
24
|
/**
|
|
@@ -112,7 +116,9 @@ function createGlboalApi() {
|
|
|
112
116
|
return globalAPI.__internal__.getConfig()
|
|
113
117
|
}
|
|
114
118
|
|
|
115
|
-
let dataset = createDataset('$global'
|
|
119
|
+
let dataset = createDataset('$global', undefined, {
|
|
120
|
+
appId: globalAPI.id
|
|
121
|
+
})
|
|
116
122
|
dataset.query = generateDatasetQuery({<% Object.entries(appQuery).map(([id, item])=>{%>
|
|
117
123
|
<%= id %>: { <% const { dataBinds, eventHandlers, handler, ...rest } = item %>
|
|
118
124
|
...(<%= JSON.stringify(rest, undefined, 2) %>),
|
|
@@ -124,7 +130,14 @@ function createGlboalApi() {
|
|
|
124
130
|
$app: globalAPI,
|
|
125
131
|
$w: globalAPI.__internal__.$w,
|
|
126
132
|
})
|
|
133
|
+
|
|
134
|
+
GLOBAL_DATASET_SYNC_DISPOSES.forEach((dispose) => {
|
|
135
|
+
dispose?.();
|
|
136
|
+
});
|
|
137
|
+
GLOBAL_DATASET_SYNC_DISPOSES = [];
|
|
127
138
|
globalAPI.dataset = dataset
|
|
139
|
+
GLOBAL_DATASET_SYNC_DISPOSES = watchAndSyncDatasetState2Local(globalAPI.id, '$global', globalAPI.dataset.state);
|
|
140
|
+
|
|
128
141
|
globalAPI.state.dataset = dataset
|
|
129
142
|
globalAPI.setState = (userSetState) => {
|
|
130
143
|
Object.keys(userSetState).forEach((keyPath) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { autorun, reaction } from 'mobx'
|
|
2
2
|
import { getDeep } from './util'
|
|
3
|
+
import { getDatasetProfiles, setLocalDatasetState } from '../datasources/index'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
@@ -48,3 +49,22 @@ function parseWatcher(watcher) {
|
|
|
48
49
|
if (!(handler instanceof Function)) return
|
|
49
50
|
return { handler, immediate }
|
|
50
51
|
}
|
|
52
|
+
|
|
53
|
+
export function watchAndSyncDatasetState2Local(appId, datasetProfileKey, dataset) {
|
|
54
|
+
const disposes = [];
|
|
55
|
+
const stateProfile = getDatasetProfiles(datasetProfileKey)?.state || {};
|
|
56
|
+
for (const key in stateProfile) {
|
|
57
|
+
const config = stateProfile[key];
|
|
58
|
+
if (config.enableSyncLocal) {
|
|
59
|
+
const dispose = autorun((r) => {
|
|
60
|
+
try {
|
|
61
|
+
setLocalDatasetState(appId, datasetProfileKey, key, dataset[key]);
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.error('setLocalDatasetState error:', e);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
disposes.push(dispose);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return disposes;
|
|
70
|
+
}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
generateParamsParser,
|
|
19
19
|
setConfig,
|
|
20
20
|
} from '../datasources/index';
|
|
21
|
-
import { runWatchers } from './watch';
|
|
21
|
+
import { runWatchers, watchAndSyncDatasetState2Local } from './watch';
|
|
22
22
|
import { $w as baseAPI } from '../app/weapps-api';
|
|
23
23
|
import { Event } from './event-emitter';
|
|
24
24
|
import { mergeDynamic2StaticData, patchWdigetPropsWithEvtListeners } from './util';
|
|
@@ -378,13 +378,23 @@ export function createPage({
|
|
|
378
378
|
return result;
|
|
379
379
|
}, {});
|
|
380
380
|
$page.computed = createComputed(computed, $page);
|
|
381
|
-
let dataset = createDataset($page.uuid
|
|
381
|
+
let dataset = createDataset($page.uuid, undefined, {
|
|
382
|
+
appId: app.id
|
|
383
|
+
});
|
|
382
384
|
dataset.query = generateDatasetQuery(datasetQuery, {
|
|
383
385
|
$w: $page.__internal__.$w,
|
|
384
386
|
$app: app,
|
|
385
387
|
$page,
|
|
386
388
|
});
|
|
389
|
+
this._disposers.push(...Object.values(dataset.query).map(query=>{
|
|
390
|
+
return function dispose() {
|
|
391
|
+
try {
|
|
392
|
+
query?.destroy?.()
|
|
393
|
+
} catch(e) {}
|
|
394
|
+
}
|
|
395
|
+
}))
|
|
387
396
|
$page.dataset = dataset;
|
|
397
|
+
this._disposers.push(...watchAndSyncDatasetState2Local(app.id, $page.uuid, $page.dataset.state))
|
|
388
398
|
$page.state.dataset = dataset;
|
|
389
399
|
$page.setState = (userSetState) => {
|
|
390
400
|
Object.keys(userSetState).forEach((keyPath) => {
|
|
@@ -6,17 +6,20 @@ const {
|
|
|
6
6
|
initTcb,
|
|
7
7
|
CLOUD_SDK,
|
|
8
8
|
createDataset,
|
|
9
|
+
getDatasetProfiles,
|
|
9
10
|
setDatasetProfiles,
|
|
10
11
|
createStateDataSourceVar,
|
|
11
12
|
generateParamsParser,
|
|
12
13
|
EXTRA_API,
|
|
13
14
|
DS_SDK,
|
|
15
|
+
setLocalDatasetState
|
|
14
16
|
} = WEDA_CLOUD_SDK
|
|
15
17
|
const getAccessToken = auth.getAccessToken
|
|
16
18
|
const loginScope = auth.loginScope
|
|
17
19
|
|
|
18
20
|
export {
|
|
19
21
|
createDataset,
|
|
22
|
+
getDatasetProfiles,
|
|
20
23
|
setDatasetProfiles,
|
|
21
24
|
createStateDataSourceVar,
|
|
22
25
|
generateParamsParser,
|
|
@@ -27,6 +30,7 @@ export {
|
|
|
27
30
|
getAccessToken,
|
|
28
31
|
loginScope,
|
|
29
32
|
initTcb,
|
|
33
|
+
setLocalDatasetState
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
import { default as config, AEGIS_CONFIG } from './config'
|
package/template/mp/package.json
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"dependencies": {<% if(importJSSDK) {%>
|
|
6
6
|
"@cloudbase/js-sdk": "2.5.6-beta.1",<% } %>
|
|
7
7
|
"@cloudbase/oauth": "0.1.1-alpha.5",
|
|
8
|
-
"@cloudbase/weda-client": "1.0.
|
|
9
|
-
"@cloudbase/weda-cloud-sdk": "1.0.
|
|
8
|
+
"@cloudbase/weda-client": "1.0.29",
|
|
9
|
+
"@cloudbase/weda-cloud-sdk": "1.0.59",
|
|
10
10
|
"mobx": "^5.15.4",
|
|
11
11
|
"lodash.get": "^4.4.2",
|
|
12
12
|
"lodash.set": "^4.3.2",
|