@cloudbase/lowcode-builder 0.1.4 → 0.1.5-mpbeta.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 +59 -0
- package/lib/builder/config/index.d.ts +14 -0
- package/lib/builder/config/index.js +21 -2
- package/lib/builder/core/index.d.ts +4 -1
- package/lib/builder/core/index.js +15 -3
- package/lib/builder/h5/copy.js +5 -1
- package/lib/builder/h5/material.js +5 -1
- package/lib/builder/mp/BuildContext.d.ts +1 -0
- package/lib/builder/mp/index.d.ts +2 -1
- package/lib/builder/mp/index.js +12 -6
- package/lib/builder/mp/materials.d.ts +7 -0
- package/lib/builder/mp/materials.js +30 -14
- package/lib/builder/mp/mixMode.js +5 -1
- package/lib/builder/mp/mp_config.js +8 -4
- package/lib/builder/mp/plugin.js +5 -1
- package/lib/builder/mp/util.js +14 -1
- package/lib/builder/mp/wxml.js +4 -0
- package/lib/builder/service/webpack.js +10 -10
- package/lib/builder/util/common.js +5 -4
- package/lib/builder/util/generateFiles.d.ts +35 -0
- package/lib/builder/util/generateFiles.js +128 -2
- package/lib/builder/util/index.js +5 -1
- package/lib/builder/util/junk.js +4 -1
- package/lib/builder/util/mp.js +5 -1
- package/lib/builder/util/net.d.ts +20 -1
- package/lib/builder/util/net.js +77 -4
- package/lib/builder.web.js +94 -0
- package/lib/index.js +5 -1
- package/lib/types.d.ts +1 -0
- package/lib/types.js +3 -1
- package/package.json +21 -7
- package/template/mp/common/util.js +2 -2
- package/template/mp/common/weapp-component.js +3 -3
- package/template/mp/common/weapp-page.js +4 -3
- package/template/mp/common/widget.js +10 -10
- package/template/mp/component/index.js +10 -4
- package/template/mp/page/index.js +11 -4
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/types.d.ts
CHANGED
package/lib/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HISTORY_TYPE = exports.RUNTIME = exports.DEPLOY_MODE = void 0;
|
|
3
|
+
exports.PropBindType = exports.HISTORY_TYPE = exports.RUNTIME = exports.DEPLOY_MODE = void 0;
|
|
4
4
|
var DEPLOY_MODE;
|
|
5
5
|
(function (DEPLOY_MODE) {
|
|
6
6
|
DEPLOY_MODE["PREVIEW"] = "preview";
|
|
@@ -17,3 +17,5 @@ var HISTORY_TYPE;
|
|
|
17
17
|
HISTORY_TYPE["BROWSER"] = "BROWSER";
|
|
18
18
|
HISTORY_TYPE["HASH"] = "HASH";
|
|
19
19
|
})(HISTORY_TYPE = exports.HISTORY_TYPE || (exports.HISTORY_TYPE = {}));
|
|
20
|
+
var cals_1 = require("@cloudbase/cals");
|
|
21
|
+
Object.defineProperty(exports, "PropBindType", { enumerable: true, get: function () { return cals_1.PropBindType; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5-mpbeta.1",
|
|
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",
|
|
@@ -25,32 +25,42 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"dev": "tsc -w",
|
|
27
27
|
"develop": "tsc -w",
|
|
28
|
-
"build": "tsc",
|
|
28
|
+
"build": "rm -rf lib && tsc && npm run build:web",
|
|
29
29
|
"test": "jest",
|
|
30
|
-
"test:build": "ts-node ./__test__/build.ts"
|
|
30
|
+
"test:build": "ts-node ./__test__/build.ts",
|
|
31
|
+
"dev:web": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=development webpack-dev-server --config ./webpack/web.config.js",
|
|
32
|
+
"build:web": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=production webpack --config ./webpack/web.config.js && node ./webpack/scripts/web.post.js"
|
|
31
33
|
},
|
|
32
34
|
"bugs": {
|
|
33
35
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
38
|
"@cloudbase/cals": "^0.3.3",
|
|
37
|
-
"@cloudbase/lowcode-generator": "
|
|
39
|
+
"@cloudbase/lowcode-generator": "0.6.17-mpbeta.0",
|
|
38
40
|
"axios": "^0.21.0",
|
|
41
|
+
"browserfs": "^1.4.3",
|
|
42
|
+
"browserify-zlib": "^0.2.0",
|
|
39
43
|
"chalk": "^2.4.2",
|
|
40
44
|
"compare-versions": "^3.6.0",
|
|
41
45
|
"compressing": "^1.4.0",
|
|
46
|
+
"constants-browserify": "^1.0.0",
|
|
42
47
|
"cross-spawn": "^6.0.5",
|
|
48
|
+
"crypto-browserify": "^3.12.0",
|
|
43
49
|
"fs-extra": "^7.0.1",
|
|
50
|
+
"jszip": "^3.7.1",
|
|
44
51
|
"lodash": "^4.17.11",
|
|
45
52
|
"lodash.clone": "^4.5.0",
|
|
46
53
|
"lodash.get": "^4.4.2",
|
|
47
54
|
"lodash.set": "^4.3.2",
|
|
48
55
|
"lodash.template": "^4.5.0",
|
|
49
56
|
"lodash.uniqby": "^4.7.0",
|
|
57
|
+
"os-browserify": "^0.3.0",
|
|
58
|
+
"stream-browserify": "^3.0.0",
|
|
50
59
|
"webpack": "^4.41.4",
|
|
51
60
|
"xml-js": "^1.6.11"
|
|
52
61
|
},
|
|
53
62
|
"devDependencies": {
|
|
63
|
+
"@rollup/plugin-alias": "^3.1.9",
|
|
54
64
|
"@types/archiver": "^3.1.0",
|
|
55
65
|
"@types/command-exists": "^1.2.0",
|
|
56
66
|
"@types/cross-spawn": "^6.0.2",
|
|
@@ -64,8 +74,12 @@
|
|
|
64
74
|
"@types/weixin-app": "^2.9.0",
|
|
65
75
|
"csstype": "^2.6.10",
|
|
66
76
|
"jest": "^26.0.1",
|
|
67
|
-
"ts-
|
|
77
|
+
"ts-loader": "^8.3.0",
|
|
68
78
|
"ts-node": "^10.4.0",
|
|
69
|
-
"typescript": "^4.4.2"
|
|
79
|
+
"typescript": "^4.4.2",
|
|
80
|
+
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
81
|
+
"webpack-cli": "^4.9.1",
|
|
82
|
+
"webpack-dev-server": "^4.7.3",
|
|
83
|
+
"worker-loader": "^3.0.8"
|
|
70
84
|
}
|
|
71
|
-
}
|
|
85
|
+
}
|
|
@@ -27,7 +27,7 @@ export function createComputed(funcs, bindContext = null) {
|
|
|
27
27
|
return computed
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function createEventHandlers(evtListeners) {
|
|
30
|
+
export function createEventHandlers(evtListeners, context) {
|
|
31
31
|
const evtHandlers = {}
|
|
32
32
|
for (const name in evtListeners) {
|
|
33
33
|
const listeners = evtListeners[name]
|
|
@@ -45,7 +45,7 @@ export function createEventHandlers(evtListeners) {
|
|
|
45
45
|
let { data = {}, boundData = {} } = l
|
|
46
46
|
data = { ...data }
|
|
47
47
|
for (const k in boundData) {
|
|
48
|
-
set(data, k, boundData[k].call(owner, owner, lists, itemsById, event))
|
|
48
|
+
set(data, k, boundData[k].call(owner, owner, lists, itemsById, event, context))
|
|
49
49
|
}
|
|
50
50
|
try {
|
|
51
51
|
let res = await l.handler.call(owner, { event, lists, forItems: itemsById, data })
|
|
@@ -10,7 +10,7 @@ import sdk from './weapp-sdk'
|
|
|
10
10
|
*/
|
|
11
11
|
export const compLowcodes = {}
|
|
12
12
|
|
|
13
|
-
export function createComponent(key, behaviors, properties, events, handler, dataBinds, evtListeners, widgetProps, index, lifeCycle, stateFn, computedFuncs, config, libCommonRes) {
|
|
13
|
+
export function createComponent(key, behaviors, properties, events, handler, dataBinds, evtListeners, widgetProps, index, lifeCycle, stateFn, computedFuncs, config, libCommonRes, undefined, context) {
|
|
14
14
|
|
|
15
15
|
compLowcodes[key] = {
|
|
16
16
|
index,
|
|
@@ -56,7 +56,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
56
56
|
|
|
57
57
|
$comp.props.events = createPropEvents(events, this)
|
|
58
58
|
$comp.widgets = {}
|
|
59
|
-
const { widgets, rootWidget: virtualRootWidget } = createWidgets(widgetProps, dataBinds, $comp.widgets, this)
|
|
59
|
+
const { widgets, rootWidget: virtualRootWidget } = createWidgets(widgetProps, dataBinds, $comp.widgets, context, this)
|
|
60
60
|
this._virtualRootWidget = virtualRootWidget
|
|
61
61
|
|
|
62
62
|
try {
|
|
@@ -104,7 +104,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
104
104
|
},
|
|
105
105
|
|
|
106
106
|
methods: {
|
|
107
|
-
...createEventHandlers(evtListeners),
|
|
107
|
+
...createEventHandlers(evtListeners, context),
|
|
108
108
|
...mergeRenderer,
|
|
109
109
|
getWeAppInst() {
|
|
110
110
|
const $comp = this.$WEAPPS_COMP
|
|
@@ -17,9 +17,10 @@ export function createPage(
|
|
|
17
17
|
dataBinds,
|
|
18
18
|
app,
|
|
19
19
|
handler,
|
|
20
|
-
pageContext = {}
|
|
20
|
+
pageContext = {},
|
|
21
|
+
context
|
|
21
22
|
) {
|
|
22
|
-
const evtHandlers = createEventHandlers(evtListeners);
|
|
23
|
+
const evtHandlers = createEventHandlers(evtListeners, context);
|
|
23
24
|
|
|
24
25
|
function extractLifecyles() {
|
|
25
26
|
const result = { };
|
|
@@ -144,7 +145,7 @@ export function createPage(
|
|
|
144
145
|
});
|
|
145
146
|
};
|
|
146
147
|
|
|
147
|
-
const { rootWidget } = createWidgets(widgetProps, dataBinds, $page.widgets, this)
|
|
148
|
+
const { rootWidget } = createWidgets(widgetProps, dataBinds, $page.widgets, context, this)
|
|
148
149
|
$page._rootWidget = rootWidget
|
|
149
150
|
|
|
150
151
|
return $page
|
|
@@ -35,10 +35,10 @@ export function resolveWidgetData(props) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
export function createWidgets(widgetProps, dataBinds, widgetHolder, ownerMpInst) {
|
|
38
|
+
export function createWidgets(widgetProps, dataBinds, widgetHolder, context, ownerMpInst) {
|
|
39
39
|
const rootNode = createWidgetDataTree(widgetProps, dataBinds)
|
|
40
40
|
const failedBinds = []
|
|
41
|
-
const result = createSubWidgetTree(rootNode, widgetProps, dataBinds, ownerMpInst, widgetHolder, 0, {}, null, failedBinds)
|
|
41
|
+
const result = createSubWidgetTree(rootNode, widgetProps, dataBinds, ownerMpInst, widgetHolder, 0, {}, null, failedBinds, undefined, context)
|
|
42
42
|
retryFailedBinds(failedBinds, true)
|
|
43
43
|
return result
|
|
44
44
|
}
|
|
@@ -51,7 +51,7 @@ export function createWidgets(widgetProps, dataBinds, widgetHolder, ownerMpInst)
|
|
|
51
51
|
*/
|
|
52
52
|
function createSubWidgetTree(curForNode, widgetProps, dataBinds, ownerMpInst, widgetHolder = {},
|
|
53
53
|
index = 0, forItems = {}, ownerForWidgetHolder = null,
|
|
54
|
-
failedBinds = [], defaultParent = { children: observable([]), _disposers: [] }) {
|
|
54
|
+
failedBinds = [], defaultParent = { children: observable([]), _disposers: [] }, context) {
|
|
55
55
|
const indexPostfix = (forItems.lists || []).slice().reverse().map(list => idSeparator + list.currentIndex).join('')
|
|
56
56
|
|
|
57
57
|
// traverse down the tree to set up all widgets
|
|
@@ -75,7 +75,7 @@ function createSubWidgetTree(curForNode, widgetProps, dataBinds, ownerMpInst, wi
|
|
|
75
75
|
} else {
|
|
76
76
|
disposeWidget(existedWidget, true)
|
|
77
77
|
}
|
|
78
|
-
setUpWidgetDataBinds(w, dataBinds[node.id], forItems, failedBinds, ownerMpInst.getWeAppInst())
|
|
78
|
+
setUpWidgetDataBinds(w, dataBinds[node.id], forItems, failedBinds, ownerMpInst.getWeAppInst(), context)
|
|
79
79
|
widgetHolder[node.id] = w
|
|
80
80
|
} else if (!existedWidget) {
|
|
81
81
|
const len = parentForWidgetArr.push(observable([]))
|
|
@@ -91,7 +91,7 @@ function createSubWidgetTree(curForNode, widgetProps, dataBinds, ownerMpInst, wi
|
|
|
91
91
|
if (node.forCount === curForNode.forCount + 1 && dataBinds[node.id] && dataBinds[node.id]._waFor) {
|
|
92
92
|
// find the node bound with next level for
|
|
93
93
|
const parent = node.parent ? widgetHolder[node.parent.id] : defaultParent
|
|
94
|
-
const dispose = runFor(node, widgetProps, dataBinds, ownerMpInst, forItems, widgetHolder, failedBinds, parent)
|
|
94
|
+
const dispose = runFor(node, widgetProps, dataBinds, ownerMpInst, forItems, widgetHolder, failedBinds, parent, context)
|
|
95
95
|
parent._disposers.push(dispose) // Add the for bind dispose to the parent node of forNode
|
|
96
96
|
}
|
|
97
97
|
})
|
|
@@ -119,12 +119,12 @@ function retryFailedBinds(failedBinds, finalTry) {
|
|
|
119
119
|
* @param {*} parentWidget
|
|
120
120
|
* @returns top level widgets or for dispose
|
|
121
121
|
*/
|
|
122
|
-
function runFor(curForNode, widgetProps, dataBinds, ownerMpInst, forItems, ownerForWidgetHolder, failedBinds, defaultParent) {
|
|
122
|
+
function runFor(curForNode, widgetProps, dataBinds, ownerMpInst, forItems, ownerForWidgetHolder, failedBinds, defaultParent, context) {
|
|
123
123
|
const nodeId = curForNode.id
|
|
124
124
|
const dispose = autorun(() => {
|
|
125
125
|
let forList = []
|
|
126
126
|
try {
|
|
127
|
-
forList = dataBinds[nodeId]._waFor.call(ownerMpInst.getWeAppInst(), ownerMpInst.getWeAppInst(), forItems.lists, forItems.itemsById)
|
|
127
|
+
forList = dataBinds[nodeId]._waFor.call(ownerMpInst.getWeAppInst(), ownerMpInst.getWeAppInst(), forItems.lists, forItems.itemsById, undefined, context)
|
|
128
128
|
if (!Array.isArray(forList)) {
|
|
129
129
|
forList = []
|
|
130
130
|
}
|
|
@@ -162,7 +162,7 @@ function runFor(curForNode, widgetProps, dataBinds, ownerMpInst, forItems, owner
|
|
|
162
162
|
lists: [{ currentItem: item, currentIndex: index }, ...lists],
|
|
163
163
|
itemsById: { ...itemsById, [nodeId]: item },
|
|
164
164
|
}
|
|
165
|
-
const { rootWidget } = createSubWidgetTree(curForNode, widgetProps, dataBinds, ownerMpInst, {}, index, _forItems, ownerForWidgetHolder, failedBinds, defaultParent)
|
|
165
|
+
const { rootWidget } = createSubWidgetTree(curForNode, widgetProps, dataBinds, ownerMpInst, {}, index, _forItems, ownerForWidgetHolder, failedBinds, defaultParent, context)
|
|
166
166
|
rootWidget._forItems = _forItems
|
|
167
167
|
})
|
|
168
168
|
})
|
|
@@ -198,7 +198,7 @@ function createAWidget(props, id, parent, ownerMpInst) {
|
|
|
198
198
|
return w
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
function setUpWidgetDataBinds(w, dataBinds, forItems, failedBinds, ctx) {
|
|
201
|
+
function setUpWidgetDataBinds(w, dataBinds, forItems, failedBinds, ctx, context) {
|
|
202
202
|
Object.keys(dataBinds || {}).map(prop => {
|
|
203
203
|
if (prop === '_waFor') { return }
|
|
204
204
|
const setUpDataBind = (isFinalTry) => {
|
|
@@ -207,7 +207,7 @@ function setUpWidgetDataBinds(w, dataBinds, forItems, failedBinds, ctx) {
|
|
|
207
207
|
const dispose = autorun((reaction) => {
|
|
208
208
|
try {
|
|
209
209
|
// Computed data bind in the next tick since data bind may read widgets data
|
|
210
|
-
w[prop] = dataBinds[prop].call(ctx,ctx,forItems.lists, forItems.itemsById)
|
|
210
|
+
w[prop] = dataBinds[prop].call(ctx,ctx,forItems.lists, forItems.itemsById, undefined, context)
|
|
211
211
|
} catch (e) {
|
|
212
212
|
if (prop === '_waIf') {
|
|
213
213
|
w[prop] = false
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { observable } from 'mobx';
|
|
1
2
|
import { createComponent } from '../../../common/weapp-component'
|
|
2
3
|
import { concatClassList, px2rpx } from '../../../common/style'
|
|
3
4
|
import app from '../../../common/weapp-sdk'
|
|
@@ -11,6 +12,7 @@ import * as constObj from '../libCommonRes/const'
|
|
|
11
12
|
import * as toolsObj from '../libCommonRes/tools'
|
|
12
13
|
|
|
13
14
|
const libCode = '<%= materialName %>'
|
|
15
|
+
const context = observable({});
|
|
14
16
|
|
|
15
17
|
const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
|
|
16
18
|
|
|
@@ -18,9 +20,11 @@ const evtListeners = {<% Object.entries(eventHandlers).map(([handlerName, listen
|
|
|
18
20
|
<%= handlerName%>: [
|
|
19
21
|
<%listeners.map(l=> { %>{
|
|
20
22
|
key: '<%= l.key %>',
|
|
21
|
-
handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else if (l.type === 'inline') {%> function({event, lists, forItems}, $comp){ <%= l.handler %> } <%} else {%> <%= l.handler %> <%} %>,
|
|
23
|
+
handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else if (l.type === 'inline') {%> function({event, lists, forItems, $context}, $comp){ <%= l.handler %> } <%} else {%> <%= l.handler %> <%} %>,
|
|
22
24
|
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
23
|
-
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':($comp, lists, forItems, event) => {const $for=forItems;return
|
|
25
|
+
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':($comp, lists, forItems, event, $context) => {const $for=forItems;return (
|
|
26
|
+
<%= expr %>
|
|
27
|
+
)},
|
|
24
28
|
<%}) %>}
|
|
25
29
|
},<%})%>
|
|
26
30
|
],<%})%>
|
|
@@ -48,11 +52,13 @@ const handler = {<% handlers.forEach(h => {%>
|
|
|
48
52
|
|
|
49
53
|
const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
|
|
50
54
|
<%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
|
|
51
|
-
<%= prop %>: function ($comp, lists, forItems, event) {const $for=forItems; return
|
|
55
|
+
<%= prop %>: function ($comp, lists, forItems, event, $context) {const $for=forItems; return (
|
|
56
|
+
<%= expr %>
|
|
57
|
+
); },<% }) %>
|
|
52
58
|
},<%}) %>
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
const config = <%= JSON.stringify(config || {})%>
|
|
56
62
|
|
|
57
63
|
createComponent('<%= key %>', behaviors, properties, events, handler, dataBinds, evtListeners, widgetProps,
|
|
58
|
-
index, lifeCycle, stateFn, computedFuncs, config, { const: constObj, tools: toolsObj }, libCode)
|
|
64
|
+
index, lifeCycle, stateFn, computedFuncs, config, { const: constObj, tools: toolsObj }, libCode, context)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { observable } from 'mobx';
|
|
1
2
|
import { createPage } from '<%= subLevelPath %>../../common/weapp-page'
|
|
2
3
|
import { concatClassList, px2rpx } from '<%= subLevelPath %>../../common/style'
|
|
3
4
|
import { app } from '<%= subLevelPath %>../../app/weapps-api'
|
|
@@ -7,7 +8,9 @@ import lifecyle from '../../lowcode/<%= pageName %>/lifecycle'
|
|
|
7
8
|
import state from '../../lowcode/<%= pageName %>/state'
|
|
8
9
|
import computed from '../../lowcode/<%= pageName %>/computed'
|
|
9
10
|
import { $page } from './api'
|
|
11
|
+
|
|
10
12
|
const $app = app;
|
|
13
|
+
const context = observable({});
|
|
11
14
|
|
|
12
15
|
const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
|
|
13
16
|
/** widget event listeners **/
|
|
@@ -15,17 +18,21 @@ const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listen
|
|
|
15
18
|
<%= handlerName%>: [
|
|
16
19
|
<%listeners.map(l=> { %>{
|
|
17
20
|
key: '<%= l.key %>',
|
|
18
|
-
handler: <% if (l.type === 'rematch') {%> handlers.<%= l.handler %> <%} else if (l.type == 'material') {%> function(...args) { return require('../../materials/<%= l.handlerModule %>/actions/<%= l.handler %>/index').default(...args) } <%} else if (l.type == 'inline') {%> function({event, lists, forItems}, $page){const $for = forItems; return <%= l.handler %> } <%} else {%> <%= l.handler %> <%} %>,
|
|
21
|
+
handler: <% if (l.type === 'rematch') {%> handlers.<%= l.handler %> <%} else if (l.type == 'material') {%> function(...args) { return require('../../materials/<%= l.handlerModule %>/actions/<%= l.handler %>/index').default(...args) } <%} else if (l.type == 'inline') {%> function({event, lists, forItems, $context}, $page){const $for = forItems; return <%= l.handler %> } <%} else {%> <%= l.handler %> <%} %>,
|
|
19
22
|
data: <%= stringifyObj(l.data, {depth: null}) %>,
|
|
20
|
-
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':($page, lists, forItems, event) => {const $for = forItems; return
|
|
23
|
+
boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':($page, lists, forItems, event, $context) => {const $for = forItems; return (
|
|
24
|
+
<%= expr %>
|
|
25
|
+
)},
|
|
21
26
|
<%}) %>}
|
|
22
27
|
},<%})%>
|
|
23
28
|
],<%})%>
|
|
24
29
|
}
|
|
25
30
|
const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
|
|
26
31
|
<%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
|
|
27
|
-
<%= prop %>: function ($page, lists, forItems, event) {const $for = forItems; return
|
|
32
|
+
<%= prop %>: function ($page, lists, forItems, event, $context) {const $for = forItems; return (
|
|
33
|
+
<%= expr %>
|
|
34
|
+
); },<% }) %>
|
|
28
35
|
},<%}) %>
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
createPage('<%= pageName %>', '<%= pageUUID %>', widgetProps, {}, lifecyle, state, computed, evtListeners, dataBinds, app, handlers, $page)
|
|
38
|
+
createPage('<%= pageName %>', '<%= pageUUID %>', widgetProps, {}, lifecyle, state, computed, evtListeners, dataBinds, app, handlers, $page, context)
|