@cloudbase/framework-plugin-low-code 0.6.12 → 0.6.16
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/mp/index.d.ts.map +1 -1
- package/lib/builder/mp/index.js +5 -3
- package/lib/builder/service/builder/generate.d.ts.map +1 -1
- package/lib/builder/service/builder/generate.js +5 -5
- package/lib/builder/util/common.d.ts.map +1 -1
- package/lib/builder/util/common.js +7 -5
- package/lib/generator/template.js +1 -1
- package/package.json +1 -1
- package/template/generator/handlers/NodeRenderer.jsx +3 -3
- package/template/mp/package.json +1 -1
- package/template/src/handlers/FieldMiddleware/renderer.jsx +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EACb,UAAU,EAEV,OAAO,EAIR,MAAM,mBAAmB,CAAC;AAU3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAkB/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEL,SAAS,EACT,YAAY,EACZ,UAAU,EACX,MAAM,iBAAiB,CAAC;AAUzB,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,EACZ,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,GACd,EAAE;IACD,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,WAAW,CAAC;IACxB,SAAS,EAAE,GAAG,CAAC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AE,CAAC,CAuSvC;AAkKD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,aAAa,iBAgCnB;AAYD,wBAAgB,oBAAoB,CAAC,EACnC,YAAY,EACZ,MAAM,EACN,SAAS,GACV,EAAE;IACD,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B;;;EA0CA"}
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -100,9 +100,11 @@ function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isPr
|
|
|
100
100
|
let appFileData = {};
|
|
101
101
|
if (weapps.find((item) => !item.mpPkgUrl)) {
|
|
102
102
|
yield generateFramework(mainAppData, miniprogramRoot, buildContext);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
if (mainAppData.mpPkgUrl) {
|
|
104
|
+
let appJsPath = path_1.default.join(miniprogramRoot, 'app.js');
|
|
105
|
+
let appJsContent = yield fs.readFile(appJsPath);
|
|
106
|
+
yield generateFiles_1.writeFile(appJsPath, `import { app as wedaApp } from './app/weapps-api'\n${appJsContent}`);
|
|
107
|
+
}
|
|
106
108
|
appFileData = Object.assign(Object.assign({}, appFileData), { 'common/style.js': {}, 'common/utils.wxs': {
|
|
107
109
|
domain: domain,
|
|
108
110
|
}, 'common/util.js': {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/builder/service/builder/generate.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAGxD,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,oBAAoB,EACpB,eAAe,EAEf,aAAa,EAEb,kBAAkB,EAWlB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAgB9B,OAAO,EAGL,SAAS,EACT,kB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AwB,CAAC,SAAS,EAAE,aAAa,EAAE,UAWlE;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,GAAG,EACZ,qBAAqB,GAAE,MAAM,EAAO,YAarC;AAED,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,cAAc,EAAE,EAC5B,wBAAwB,GAAE,MAAM,EAAO,YA+BxC;AAED,wBAAgB,uBAAuB,CACrC,gBAAgB,GAAE;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B,EAAO,EACR,oBAAoB,GAAE,MAAM,EAAO,YAepC;AAED,wBAAgB,wBAAwB,CACtC,gBAAgB,EAAE,cAAc,EAAE,EAClC,qBAAqB,GAAE,MAAM,EAAO,YAQrC;AAED,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,cAAc,EAChC,qBAAqB,EAAE,MAAM,EAAE,QAqBhC;AAED,wBAAsB,kBAAkB,CACtC,cAAc,EAAE,kBAAkB,EAAE,EACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,SAAK,EACb,aAAa,GAAE,SAAS,EAAO,iBAwChC;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,MAAM,iBAuCpB;AAED,wBAAsB,iCAAiC,CACrD,eAAe,EAAE,aAAa,EAAE,EAChC,WAAW,EAAE,MAAM,iBA6EpB;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,kBAAkB,EAC3B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,aAAa,EAAE,EAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,KAAA,EACR,UAAU,EAAE,WAAW,EACvB,aAAa,EAAE,SAAS,EAAE,EAC1B,SAAS,KAAA,iBAkFV"}
|
|
@@ -386,8 +386,8 @@ function getComponentSchemaString(componentSchema, isComposite = false, componen
|
|
|
386
386
|
});
|
|
387
387
|
return {
|
|
388
388
|
widgets: util_1.JsonToStringWithVariableName(compWidgets),
|
|
389
|
-
dataBinds: util_1.JsonToStringWithVariableName(compDataBinds)
|
|
390
|
-
componentSchema: util_1.JsonToStringWithVariableName(componentSchemaJson)
|
|
389
|
+
dataBinds: util_1.JsonToStringWithVariableName(compDataBinds),
|
|
390
|
+
componentSchema: util_1.JsonToStringWithVariableName(componentSchemaJson),
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
exports.getComponentSchemaString = getComponentSchemaString;
|
|
@@ -406,14 +406,14 @@ function generateDataBinds(dataBinds, isComposite) {
|
|
|
406
406
|
funcCode = `() => ({__type: "scopedValue", getValue: ($scope)=>$scope.${bind.bindDataPath}})}`;
|
|
407
407
|
}
|
|
408
408
|
else if (bind.type === weapps_core_1.PropBindType.expression) {
|
|
409
|
-
let code = bind.bindDataPath
|
|
409
|
+
let code = bind.bindDataPath;
|
|
410
410
|
if (isComposite) {
|
|
411
411
|
funcCode = `(forItems) => { const $for = forItems; return (${code.replace(/\$comp/g, 'this.$WEAPPS_COMP')})}`;
|
|
412
412
|
}
|
|
413
413
|
else {
|
|
414
414
|
funcCode = /\$scope\./.test(code)
|
|
415
|
-
? `(forItems, event) => ({__type: "scopedValue", getValue: ($scope) => { const $for = forItems;return (${code})}})`
|
|
416
|
-
: `(forItems, event) => { const $for = forItems;return (${code})}`;
|
|
415
|
+
? `(forItems, event) => ({__type: "scopedValue", getValue: ($scope) => { const $for = forItems;return (\n${code}\n)}})`
|
|
416
|
+
: `(forItems, event) => { const $for = forItems;return (\n${code}\n)}`;
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
else if (bind.type === weapps_core_1.PropBindType.prop) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/builder/util/common.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,a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AE,GAAG,GAAG,MAAM,CAWlE;AAED,wBAAgB,eAAe,CAAC,MAAM,KAAA,OAIrC;AAED,wBAAgB,qBAAqB,CAAC,IAAI,SAAK,QAI9C;AAED,wBAAgB,aAAa,CAC3B,iBAAiB,EAAE,kBAAkB,GACpC,oBAAoB,CA2BtB;AAED,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,aAAa,EAAE,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CAuD7B;AAED,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,GAAG;;;;GA2BrD;AAED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,MAAM,iBAgChB;AAED,wBAAgB,oBAAoB,CAAC,MAAM,KAAA,GAAG;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC7C,UAAU,EAAE;QACV,CAAC,aAAa,EAAE,MAAM,GAAG;YACvB,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;KACH,CAAC;CACH,GAAG,IAAI,CA0BP;AAOD,wBAAgB,sBAAsB,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,GAAG,OAAO,CAK7D"}
|
|
@@ -59,11 +59,13 @@ function getSelfPackageJson() {
|
|
|
59
59
|
}
|
|
60
60
|
exports.getSelfPackageJson = getSelfPackageJson;
|
|
61
61
|
function JsonToStringWithVariableName(copyJson) {
|
|
62
|
-
return JSON.stringify(copyJson, null, 2)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
return JSON.stringify(copyJson, null, 2).replace(/"%%%(.*?)%%%"/g, function (match, expression) {
|
|
63
|
+
return expression
|
|
64
|
+
.replace(/\\"/g, '"')
|
|
65
|
+
.replace(/\\'/g, "'")
|
|
66
|
+
.replace(/\\r/g, '\r')
|
|
67
|
+
.replace(/\\n/g, '\n');
|
|
68
|
+
});
|
|
67
69
|
}
|
|
68
70
|
exports.JsonToStringWithVariableName = JsonToStringWithVariableName;
|
|
69
71
|
function requireUncached(module) {
|
|
@@ -23,7 +23,7 @@ exports.default = {
|
|
|
23
23
|
"code": "import { setConfig, initTcb, CLOUD_SDK } from '@cloudbase/weda-cloud-sdk/dist/h5';\nimport config from './config';\nexport {\n createDataset,\n createStateDataSourceVar,\n generateParamsParser,\n EXTRA_API,\n CLOUD_SDK,\n DS_API,\n DS_SDK,\n} from '@cloudbase/weda-cloud-sdk/dist/h5';\n\nsetConfig(config);\ninitTcb();\n"
|
|
24
24
|
},
|
|
25
25
|
"/src/handlers/NodeRenderer.jsx": {
|
|
26
|
-
"code": "import * as React from 'react';\nimport {\n useContext,\n useCallback,\n createContext,\n useState,\n useRef,\n} from 'react';\nimport { observer } from 'mobx-react-lite';\nimport { emitEvent, translateStyleToRem, checkVisible } from '../utils';\nimport { get, set } from 'lodash';\nimport { getDom } from '../utils/widgets';\n\nexport const ForContext = createContext({});\n\nexport const CompRenderer = observer(function (props) {\n const {\n id: compId,\n xProps,\n virtualFields,\n slots = {},\n codeContext = {},\n scopeContext = {},\n genericComp = {},\n emitEvents = [],\n componentSchema = {},\n } = props;\n\n const [blockIndex, setBlockIndex] = useState();\n const [blockType, setBlockType] = useState();\n const indexRef = useRef();\n const typeRef = useRef();\n indexRef.current = blockIndex;\n typeRef.current = blockType;\n\n const isInComposite = !!codeContext.$WEAPPS_COMP;\n // 判断 widgets 是从 page 来的,还是组件来的\n const widgetsData = !isInComposite\n ? codeContext.$page.widgets[compId]\n : codeContext.$WEAPPS_COMP.widgets[compId];\n\n const isRootNode = widgetsData && !widgetsData.parent;\n\n if (!xProps) {\n return props.children;\n }\n\n const {\n commonStyle = {},\n sourceKey,\n listenerInstances,\n classNameList = [],\n staticResourceAttribute = [],\n } = xProps;\n const dataBinds =\n (codeContext._dataBinds && codeContext._dataBinds[compId]) || {};\n const FieldKey = genericComp.propName\n ? codeContext.node[genericComp.propName]\n : sourceKey;\n const Field = virtualFields[FieldKey];\n const parentForItems = useContext(ForContext);\n\n // 组件最终用于执行的事件函数\n const emit = useCallback(\n (trigger, eventData, forItems, domEvent, scopeContext) => {\n const listeners = listenerInstances;\n const event = {\n detail: eventData,\n name: trigger,\n target: widgetsData,\n currentTarget: widgetsData,\n domEvent,\n };\n forItems = {\n ...forItems,\n forIndexes: getForIndexes(forItems, widgetsData),\n };\n emitEvent(\n trigger,\n listeners,\n {\n event,\n customEventData: event,\n forItems,\n domEvent,\n },\n scopeContext\n );\n },\n [props]\n );\n\n // 选区最终用于执行的事件函数\n const emitSB = useCallback(\n (trigger, eventData, forItems, domEvent, scopeContext, fieldData) => {\n const listeners =\n typeRef.current &&\n indexRef.current &&\n fieldData?.[typeRef.current]?.[indexRef.current]?.selectableBlock?.[\n 'x-props'\n ]?.listenerInstances;\n const event = {\n detail: eventData,\n name: trigger,\n target: widgetsData,\n currentTarget: widgetsData,\n domEvent,\n };\n forItems = {\n ...forItems,\n forIndexes: getForIndexes(forItems, widgetsData),\n };\n emitEvent(\n trigger,\n listeners,\n {\n event,\n customEventData: event,\n forItems,\n domEvent,\n },\n scopeContext\n );\n },\n [props]\n );\n\n function getSafeComponentProps({\n style,\n classNameList,\n staticResourceAttribute,\n }) {\n const componentProps = {};\n if (classNameList.length) {\n componentProps.className = classNameList.join(' ');\n }\n\n if (style && Object.keys(style).length) {\n componentProps.style = style;\n }\n\n if (staticResourceAttribute && staticResourceAttribute.length > 0) {\n componentProps.staticResourceAttribute = staticResourceAttribute;\n }\n return componentProps;\n }\n\n // 选区的预览的click事件\n const onCustomEvent = ({ order: index, blockKey }) => {\n if (index) {\n setBlockIndex(index);\n setBlockType(blockKey);\n }\n };\n\n // For循环渲染\n let forList;\n try {\n forList = dataBinds && dataBinds._waFor && dataBinds._waFor(parentForItems);\n } catch (e) {\n forList = [];\n console.error('_waFor data', e);\n }\n if (forList) {\n if (!Array.isArray(forList)) {\n console.warn(`${compId}循环绑定非数组值:`, forList);\n forList = [];\n }\n return forList.map((item, index) => {\n const forItemsIndexes = (parentForItems.forIndexes || []).concat(index);\n const forItems = {\n ...parentForItems,\n [compId]: item,\n forIndexes: forItemsIndexes,\n };\n const {\n fieldData: forItemData,\n finalStyle: forItemStyle,\n finalClassNameList: forItemClassNameList,\n } = getBindData(forItems, scopeContext);\n if (!checkVisible(forItemData)) {\n return null;\n }\n // 多个组件的 slot 属性\n Object.keys(slots).forEach((slotProp) => {\n set(forItemData, slotProp, slots[slotProp]);\n });\n const emitWithForItems = (trigger, eventData, domEvent) =>\n emit(trigger, eventData, forItems, domEvent, scopeContext);\n\n const _selectableBlockEventsForItems = {\n onCustomEvent,\n events:\n componentSchema?.selectableBlock?.events.map((item) => item.name) ||\n [],\n emit: (trigger, eventData, domEvent) =>\n emitSB(\n trigger,\n eventData,\n forItems,\n domEvent,\n scopeContext,\n forItemData\n ),\n };\n\n delete forItemData.style;\n\n // 获取当前元素的 ref\n const currentWidget = Array.isArray(widgetsData)\n ? get(widgetsData, forItemsIndexes)\n : widgetsData;\n const domRef = setGetDomApi(currentWidget, props);\n return (\n <ForContext.Provider key={index} value={forItems}>\n <Field\n data={{\n ...forItemData,\n _selectableBlockEvents: _selectableBlockEventsForItems,\n }}\n id={compId}\n {...getSafeComponentProps({\n style: forItemStyle,\n classNameList: forItemClassNameList,\n staticResourceAttribute,\n })}\n emit={emitWithForItems}\n events={emitEvents}\n compositeParent={codeContext}\n forIndexes={forItemsIndexes}\n $node={currentWidget}\n domRef={domRef}\n >\n {props.children}\n </Field>\n </ForContext.Provider>\n );\n });\n }\n\n // 单节点渲染\n const { fieldData, finalClassNameList, finalStyle } = getBindData(\n parentForItems,\n scopeContext\n );\n const emitWithFiedle = (trigger, eventData, domEvent) =>\n emit(trigger, eventData, parentForItems, domEvent, scopeContext);\n\n const _selectableBlockEventsWithFiedle = {\n onCustomEvent,\n events:\n componentSchema?.selectableBlock?.events.map((item) => item.name) || [],\n emit: (trigger, eventData, domEvent) =>\n emitSB(\n trigger,\n eventData,\n parentForItems,\n domEvent,\n scopeContext,\n fieldData\n ),\n };\n\n // false 或空字符串时\n if (!checkVisible(fieldData)) {\n return null;\n }\n\n // 单个组件的 slot 属性\n Object.keys(slots).forEach((slotProp) => {\n set(fieldData, slotProp, slots[slotProp]);\n });\n\n // 防止渲染时 data 的 style 与实际的 style 冲突\n delete fieldData.style;\n\n // 修正 forIndexes\n const forIndexes = getForIndexes(parentForItems, widgetsData);\n\n // 获取 Element Ref\n const currentWidget = Array.isArray(widgetsData)\n ? get(widgetsData, forIndexes)\n : widgetsData;\n const domRef = setGetDomApi(currentWidget, props);\n\n return (\n <Field\n data={{\n ...fieldData,\n _selectableBlockEvents: _selectableBlockEventsWithFiedle,\n }}\n id={compId}\n {...getSafeComponentProps({\n style: finalStyle,\n classNameList: finalClassNameList,\n staticResourceAttribute,\n })}\n emit={emitWithFiedle}\n events={emitEvents}\n compositeParent={codeContext}\n forIndexes={forIndexes}\n $node={currentWidget}\n domRef={domRef}\n >\n {props.children}\n </Field>\n );\n\n // TODO: 需要不断移除 dataBinds(style/classList)\n function getBindData(forItems, scopeContext) {\n // bindData\n let wData = widgetsData;\n if (Array.isArray(wData)) {\n wData =\n forItems.forIndexes === void 0 || wData.length === 0\n ? {}\n : get(wData, getForIndexes(forItems, wData));\n }\n wData = wData || {};\n const fieldData = { ...wData };\n\n // 再次计算 scope value\n for (let key in fieldData) {\n if (Object.prototype.hasOwnProperty.call(fieldData, key)) {\n const value = fieldData[key];\n if (value && value.__type === 'scopedValue') {\n try {\n fieldData[key] = value.getValue(scopeContext);\n } catch (e) {\n console.warn(`Error computing data bind '${key}' error:`, e);\n fieldData[key] = '';\n }\n }\n }\n }\n\n // bindStyle\n let bindStyle = fieldData.style || {};\n // 复合组件第一层需要将最外层样式 style 挂到节点上\n let cssStyle = commonStyle;\n if (isInComposite && wData && !wData.parent) {\n cssStyle = {\n ...cssStyle,\n ...(codeContext.$WEAPPS_COMP.props?.style || {}),\n };\n bindStyle = {\n ...bindStyle,\n ...(codeContext.$WEAPPS_COMP.props?.style || {}),\n };\n }\n const finalStyle = getFinalStyle(cssStyle, bindStyle);\n\n // bindClassList\n const bindClassList = fieldData.classList || [];\n const finalClassNameList = getFinalClassNameList(\n classNameList,\n bindClassList\n );\n\n // 当前在复合组件中,且当前节点为根节点\n if (isInComposite && isRootNode) {\n if (wData.ownerWidget) {\n Object.keys(wData.ownerWidget).forEach((propName) => {\n if (\n propName === 'role' ||\n ['aria-', 'data-'].some((prefix) => propName.startsWith(prefix))\n ) {\n wData[propName] = wData.ownerWidget[propName];\n }\n });\n }\n }\n\n return { fieldData, finalStyle, finalClassNameList };\n }\n});\n\nexport function getFinalStyle(\n commonStyle = {},\n bindStyle = {},\n widgetStyle = {}\n) {\n const remBindStyle =\n typeof bindStyle === 'object' ? translateStyleToRem(bindStyle) : {};\n\n return {\n ...(translateStyleToRem(commonStyle) || {}),\n ...(translateStyleToRem(widgetStyle) || {}),\n ...remBindStyle,\n };\n}\n\nexport function getFinalClassNameList(\n classNameList = [],\n bindClassList = [],\n widgetClassList = []\n) {\n return [].concat(classNameList, bindClassList, widgetClassList);\n}\n\n// HACK: 从后向前保证循环的深度与 forIndexes 一致\n// 后续需要将 For 循环迁移到外层\nfunction getForIndexes(parentForItems, widgetsData) {\n return Array.isArray(widgetsData) && widgetsData.length > 0\n ? (parentForItems.forIndexes || []).slice(0 - getDeepArrLen(widgetsData))\n : undefined;\n}\n\nfunction getDeepArrLen(arr, len = 0) {\n if (Array.isArray(arr)) {\n return getDeepArrLen(arr[0], len + 1);\n } else {\n return len;\n }\n}\n\nfunction setGetDomApi(currentWidget, props) {\n if (!currentWidget) return React.createRef();\n const isComposite = !currentWidget.widgetType.startsWith('gsd-h5-react');\n const isInComposite = !!(props.codeContext || {}).$WEAPPS_COMP;\n\n // 如果当前是复合组件,不做 getDom 的挂载\n if (!isComposite) {\n if (!currentWidget.domRef) {\n currentWidget.domRef = React.createRef();\n }\n if (!currentWidget.getDom) {\n currentWidget.getDom = (options) =>\n getDom(currentWidget.domRef.current, options);\n }\n\n if (\n isInComposite && // 当前在复合组件内\n !currentWidget.parent && // 当前节点为复合组件的根节点\n props.codeContext.node && // 复合组件的 node 已经创建\n !props.codeContext.node.getDom // 复合组件的 node 未挂载 getDom 方法\n ) {\n props.codeContext.node.domRef = currentWidget.domRef;\n props.codeContext.node.getDom = currentWidget.getDom;\n }\n }\n\n return currentWidget.domRef;\n}\n"
|
|
26
|
+
"code": "import * as React from 'react';\nimport {\n useContext,\n useCallback,\n createContext,\n useState,\n useRef,\n} from 'react';\nimport { observer } from 'mobx-react-lite';\nimport { emitEvent, translateStyleToRem, checkVisible } from '../utils';\nimport { get, set } from 'lodash';\nimport { getDom } from '../utils/widgets';\n\nexport const ForContext = createContext({});\n\nexport const CompRenderer = observer(function (props) {\n const {\n id: compId,\n xProps,\n virtualFields,\n slots = {},\n codeContext = {},\n scopeContext = {},\n genericComp = {},\n emitEvents = [],\n componentSchema = {},\n } = props;\n\n const [blockIndex, setBlockIndex] = useState();\n const [blockType, setBlockType] = useState();\n const indexRef = useRef();\n const typeRef = useRef();\n indexRef.current = blockIndex;\n typeRef.current = blockType;\n\n const isInComposite = !!codeContext.$WEAPPS_COMP;\n // 判断 widgets 是从 page 来的,还是组件来的\n const widgetsData = !isInComposite\n ? codeContext.$page.widgets[compId]\n : codeContext.$WEAPPS_COMP.widgets[compId];\n\n const isRootNode = widgetsData && !widgetsData.parent;\n\n if (!xProps) {\n return props.children;\n }\n\n const {\n commonStyle = {},\n sourceKey,\n listenerInstances,\n classNameList = [],\n staticResourceAttribute = [],\n } = xProps;\n const dataBinds =\n (codeContext._dataBinds && codeContext._dataBinds[compId]) || {};\n const FieldKey = genericComp.propName\n ? codeContext.node[genericComp.propName]\n : sourceKey;\n const Field = virtualFields[FieldKey];\n const parentForItems = useContext(ForContext);\n\n // 组件最终用于执行的事件函数\n const emit = useCallback(\n (trigger, eventData, forItems, domEvent, scopeContext) => {\n const listeners = listenerInstances;\n const event = {\n detail: eventData,\n name: trigger,\n target: widgetsData,\n currentTarget: widgetsData,\n domEvent,\n };\n forItems = {\n ...forItems,\n forIndexes: getForIndexes(forItems, widgetsData),\n };\n emitEvent(\n trigger,\n listeners,\n {\n event,\n customEventData: event,\n forItems,\n domEvent,\n },\n scopeContext\n );\n },\n [props]\n );\n\n // 选区最终用于执行的事件函数\n const emitSB = useCallback(\n (trigger, eventData, forItems, domEvent, scopeContext, fieldData) => {\n const listeners =\n typeRef?.current &&\n indexRef?.current !== undefined &&\n fieldData?.[typeRef.current]?.[indexRef.current]?.selectableBlock?.[\n 'x-props'\n ]?.listenerInstances;\n const event = {\n detail: eventData,\n name: trigger,\n target: widgetsData,\n currentTarget: widgetsData,\n domEvent,\n };\n forItems = {\n ...forItems,\n forIndexes: getForIndexes(forItems, widgetsData),\n };\n emitEvent(\n trigger,\n listeners,\n {\n event,\n customEventData: event,\n forItems,\n domEvent,\n },\n scopeContext\n );\n },\n [props]\n );\n\n function getSafeComponentProps({\n style,\n classNameList,\n staticResourceAttribute,\n }) {\n const componentProps = {};\n if (classNameList.length) {\n componentProps.className = classNameList.join(' ');\n }\n\n if (style && Object.keys(style).length) {\n componentProps.style = style;\n }\n\n if (staticResourceAttribute && staticResourceAttribute.length > 0) {\n componentProps.staticResourceAttribute = staticResourceAttribute;\n }\n return componentProps;\n }\n\n // 选区的预览的click事件\n const onCustomEvent = ({ order: index, blockKey }) => {\n if (index !== undefined) {\n setBlockIndex(index);\n setBlockType(blockKey);\n }\n };\n\n // For循环渲染\n let forList;\n try {\n forList = dataBinds && dataBinds._waFor && dataBinds._waFor(parentForItems);\n } catch (e) {\n forList = [];\n console.error('_waFor data', e);\n }\n if (forList) {\n if (!Array.isArray(forList)) {\n console.warn(`${compId}循环绑定非数组值:`, forList);\n forList = [];\n }\n return forList.map((item, index) => {\n const forItemsIndexes = (parentForItems.forIndexes || []).concat(index);\n const forItems = {\n ...parentForItems,\n [compId]: item,\n forIndexes: forItemsIndexes,\n };\n const {\n fieldData: forItemData,\n finalStyle: forItemStyle,\n finalClassNameList: forItemClassNameList,\n } = getBindData(forItems, scopeContext);\n if (!checkVisible(forItemData)) {\n return null;\n }\n // 多个组件的 slot 属性\n Object.keys(slots).forEach((slotProp) => {\n set(forItemData, slotProp, slots[slotProp]);\n });\n const emitWithForItems = (trigger, eventData, domEvent) =>\n emit(trigger, eventData, forItems, domEvent, scopeContext);\n\n const _selectableBlockEventsForItems = {\n onCustomEvent,\n events:\n componentSchema?.selectableBlock?.events.map((item) => item.name) ||\n [],\n emit: (trigger, eventData, domEvent) =>\n emitSB(\n trigger,\n eventData,\n forItems,\n domEvent,\n scopeContext,\n forItemData\n ),\n };\n\n delete forItemData.style;\n\n // 获取当前元素的 ref\n const currentWidget = Array.isArray(widgetsData)\n ? get(widgetsData, forItemsIndexes)\n : widgetsData;\n const domRef = setGetDomApi(currentWidget, props);\n return (\n <ForContext.Provider key={index} value={forItems}>\n <Field\n data={{\n ...forItemData,\n _selectableBlockEvents: _selectableBlockEventsForItems,\n }}\n id={compId}\n {...getSafeComponentProps({\n style: forItemStyle,\n classNameList: forItemClassNameList,\n staticResourceAttribute,\n })}\n emit={emitWithForItems}\n events={emitEvents}\n compositeParent={codeContext}\n forIndexes={forItemsIndexes}\n $node={currentWidget}\n domRef={domRef}\n >\n {props.children}\n </Field>\n </ForContext.Provider>\n );\n });\n }\n\n // 单节点渲染\n const { fieldData, finalClassNameList, finalStyle } = getBindData(\n parentForItems,\n scopeContext\n );\n const emitWithFiedle = (trigger, eventData, domEvent) =>\n emit(trigger, eventData, parentForItems, domEvent, scopeContext);\n\n const _selectableBlockEventsWithFiedle = {\n onCustomEvent,\n events:\n componentSchema?.selectableBlock?.events.map((item) => item.name) || [],\n emit: (trigger, eventData, domEvent) =>\n emitSB(\n trigger,\n eventData,\n parentForItems,\n domEvent,\n scopeContext,\n fieldData\n ),\n };\n\n // false 或空字符串时\n if (!checkVisible(fieldData)) {\n return null;\n }\n\n // 单个组件的 slot 属性\n Object.keys(slots).forEach((slotProp) => {\n set(fieldData, slotProp, slots[slotProp]);\n });\n\n // 防止渲染时 data 的 style 与实际的 style 冲突\n delete fieldData.style;\n\n // 修正 forIndexes\n const forIndexes = getForIndexes(parentForItems, widgetsData);\n\n // 获取 Element Ref\n const currentWidget = Array.isArray(widgetsData)\n ? get(widgetsData, forIndexes)\n : widgetsData;\n const domRef = setGetDomApi(currentWidget, props);\n\n return (\n <Field\n data={{\n ...fieldData,\n _selectableBlockEvents: _selectableBlockEventsWithFiedle,\n }}\n id={compId}\n {...getSafeComponentProps({\n style: finalStyle,\n classNameList: finalClassNameList,\n staticResourceAttribute,\n })}\n emit={emitWithFiedle}\n events={emitEvents}\n compositeParent={codeContext}\n forIndexes={forIndexes}\n $node={currentWidget}\n domRef={domRef}\n >\n {props.children}\n </Field>\n );\n\n // TODO: 需要不断移除 dataBinds(style/classList)\n function getBindData(forItems, scopeContext) {\n // bindData\n let wData = widgetsData;\n if (Array.isArray(wData)) {\n wData =\n forItems.forIndexes === void 0 || wData.length === 0\n ? {}\n : get(wData, getForIndexes(forItems, wData));\n }\n wData = wData || {};\n const fieldData = { ...wData };\n\n // 再次计算 scope value\n for (let key in fieldData) {\n if (Object.prototype.hasOwnProperty.call(fieldData, key)) {\n const value = fieldData[key];\n if (value && value.__type === 'scopedValue') {\n try {\n fieldData[key] = value.getValue(scopeContext);\n } catch (e) {\n console.warn(`Error computing data bind '${key}' error:`, e);\n fieldData[key] = '';\n }\n }\n }\n }\n\n // bindStyle\n let bindStyle = fieldData.style || {};\n // 复合组件第一层需要将最外层样式 style 挂到节点上\n let cssStyle = commonStyle;\n if (isInComposite && wData && !wData.parent) {\n cssStyle = {\n ...cssStyle,\n ...(codeContext.$WEAPPS_COMP.props?.style || {}),\n };\n bindStyle = {\n ...bindStyle,\n ...(codeContext.$WEAPPS_COMP.props?.style || {}),\n };\n }\n const finalStyle = getFinalStyle(cssStyle, bindStyle);\n\n // bindClassList\n const bindClassList = fieldData.classList || [];\n const finalClassNameList = getFinalClassNameList(\n classNameList,\n bindClassList\n );\n\n // 当前在复合组件中,且当前节点为根节点\n if (isInComposite && isRootNode) {\n if (wData.ownerWidget) {\n Object.keys(wData.ownerWidget).forEach((propName) => {\n if (\n propName === 'role' ||\n ['aria-', 'data-'].some((prefix) => propName.startsWith(prefix))\n ) {\n wData[propName] = wData.ownerWidget[propName];\n }\n });\n }\n }\n\n return { fieldData, finalStyle, finalClassNameList };\n }\n});\n\nexport function getFinalStyle(\n commonStyle = {},\n bindStyle = {},\n widgetStyle = {}\n) {\n const remBindStyle =\n typeof bindStyle === 'object' ? translateStyleToRem(bindStyle) : {};\n\n return {\n ...(translateStyleToRem(commonStyle) || {}),\n ...(translateStyleToRem(widgetStyle) || {}),\n ...remBindStyle,\n };\n}\n\nexport function getFinalClassNameList(\n classNameList = [],\n bindClassList = [],\n widgetClassList = []\n) {\n return [].concat(classNameList, bindClassList, widgetClassList);\n}\n\n// HACK: 从后向前保证循环的深度与 forIndexes 一致\n// 后续需要将 For 循环迁移到外层\nfunction getForIndexes(parentForItems, widgetsData) {\n return Array.isArray(widgetsData) && widgetsData.length > 0\n ? (parentForItems.forIndexes || []).slice(0 - getDeepArrLen(widgetsData))\n : undefined;\n}\n\nfunction getDeepArrLen(arr, len = 0) {\n if (Array.isArray(arr)) {\n return getDeepArrLen(arr[0], len + 1);\n } else {\n return len;\n }\n}\n\nfunction setGetDomApi(currentWidget, props) {\n if (!currentWidget) return React.createRef();\n const isComposite = !currentWidget.widgetType.startsWith('gsd-h5-react');\n const isInComposite = !!(props.codeContext || {}).$WEAPPS_COMP;\n\n // 如果当前是复合组件,不做 getDom 的挂载\n if (!isComposite) {\n if (!currentWidget.domRef) {\n currentWidget.domRef = React.createRef();\n }\n if (!currentWidget.getDom) {\n currentWidget.getDom = (options) =>\n getDom(currentWidget.domRef.current, options);\n }\n\n if (\n isInComposite && // 当前在复合组件内\n !currentWidget.parent && // 当前节点为复合组件的根节点\n props.codeContext.node && // 复合组件的 node 已经创建\n !props.codeContext.node.getDom // 复合组件的 node 未挂载 getDom 方法\n ) {\n props.codeContext.node.domRef = currentWidget.domRef;\n props.codeContext.node.getDom = currentWidget.getDom;\n }\n }\n\n return currentWidget.domRef;\n}\n"
|
|
27
27
|
},
|
|
28
28
|
"/src/handlers/RenderWrapper.jsx": {
|
|
29
29
|
"code": "import * as React from 'react';\nimport { useRef } from 'react';\nimport { CompRenderer } from './NodeRenderer';\nimport lodashSet from 'lodash.set';\nimport cloneDeep from 'lodash.clonedeep';\nimport { isScopeSlot } from '../utils/common';\n\nfunction getComponentChildren(component) {\n const { properties } = component;\n if (!properties) {\n return [];\n }\n return Object.values(properties).sort(\n (a, b) => (a['x-index'] || 0) - (b['x-index'] || 0)\n );\n}\n\nexport function AppRender(props) {\n const {\n className,\n virtualFields,\n componentSchema,\n renderSlot,\n rootNode = true,\n codeContext,\n scopeContext = {},\n } = props;\n const {\n 'x-props': xProps,\n properties = {},\n genericComp = {},\n } = componentSchema;\n // 判断是否为 slot\n const isSlot = !xProps;\n if (isSlot && !(renderSlot || rootNode)) {\n return null;\n }\n\n const preClassName = useRef();\n\n // wrapperClass\n const containerEl = Object.values(properties)[0];\n if (containerEl && containerEl['x-props'] && className) {\n let { classNameList = [] } = containerEl['x-props'];\n\n // 先替换掉先前计算出来的className部分\n if (preClassName.current) {\n if (preClassName.current !== className) {\n classNameList = classNameList.filter(\n (clsName) => clsName !== preClassName.current\n );\n preClassName.current = className;\n }\n } else {\n preClassName.current = className;\n }\n\n containerEl['x-props'].classNameList = [className, ...classNameList];\n }\n\n if (xProps && xProps.sourceKey) {\n const { sourceKey } = xProps;\n const Field = virtualFields[sourceKey];\n if (!Field) {\n return (\n <div style={{ color: 'red' }}>\n 组件<em>{sourceKey}</em>未找到\n </div>\n );\n }\n }\n const children = getComponentChildren(componentSchema);\n const slots = {};\n // eslint-disable-next-line guard-for-in\n for (const key in properties) {\n const child = properties[key];\n if (!child['x-props'] && child.properties) {\n slots[key] = isScopeSlot(componentSchema, key) ? (\n (props) => {\n let clonedScopeContext = cloneDeep(scopeContext);\n lodashSet(\n clonedScopeContext,\n `${componentSchema.key}.${child.key}`,\n props\n );\n return (\n <AppRender\n key={child.key}\n componentSchema={child}\n renderSlot\n virtualFields={virtualFields}\n codeContext={codeContext}\n scopeContext={clonedScopeContext}\n />\n );\n }\n ) : (\n <AppRender\n key={child.key}\n componentSchema={child}\n renderSlot\n virtualFields={virtualFields}\n codeContext={codeContext}\n scopeContext={scopeContext}\n />\n );\n }\n }\n\n return (\n <CompRenderer\n id={componentSchema.key}\n xProps={xProps}\n emitEvents={componentSchema.emitEvents || []}\n componentSchema={componentSchema}\n virtualFields={virtualFields}\n slots={slots}\n codeContext={codeContext}\n scopeContext={scopeContext}\n genericComp={genericComp}\n >\n {children.map((comp) => (\n <AppRender\n key={comp.key}\n componentSchema={comp}\n rootNode={false}\n renderSlot={false}\n virtualFields={virtualFields}\n codeContext={codeContext}\n scopeContext={scopeContext}\n />\n ))}\n </CompRenderer>\n );\n}\n"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/framework-plugin-low-code",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
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",
|
|
@@ -94,8 +94,8 @@ export const CompRenderer = observer(function (props) {
|
|
|
94
94
|
const emitSB = useCallback(
|
|
95
95
|
(trigger, eventData, forItems, domEvent, scopeContext, fieldData) => {
|
|
96
96
|
const listeners =
|
|
97
|
-
typeRef
|
|
98
|
-
indexRef
|
|
97
|
+
typeRef?.current &&
|
|
98
|
+
indexRef?.current !== undefined &&
|
|
99
99
|
fieldData?.[typeRef.current]?.[indexRef.current]?.selectableBlock?.[
|
|
100
100
|
'x-props'
|
|
101
101
|
]?.listenerInstances;
|
|
@@ -147,7 +147,7 @@ export const CompRenderer = observer(function (props) {
|
|
|
147
147
|
|
|
148
148
|
// 选区的预览的click事件
|
|
149
149
|
const onCustomEvent = ({ order: index, blockKey }) => {
|
|
150
|
-
if (index) {
|
|
150
|
+
if (index !== undefined) {
|
|
151
151
|
setBlockIndex(index);
|
|
152
152
|
setBlockType(blockKey);
|
|
153
153
|
}
|
package/template/mp/package.json
CHANGED
|
@@ -86,8 +86,8 @@ export const CompRenderer = observer(function (props) {
|
|
|
86
86
|
const emitSB = useCallback(
|
|
87
87
|
(trigger, event, forItems, scopeContext, fieldData) => {
|
|
88
88
|
const listeners =
|
|
89
|
-
indexRef
|
|
90
|
-
typeRef
|
|
89
|
+
indexRef?.current !== undefined &&
|
|
90
|
+
typeRef?.current &&
|
|
91
91
|
fieldData?.[typeRef.current]?.[indexRef.current]?.selectableBlock?.[
|
|
92
92
|
'x-props'
|
|
93
93
|
]?.listenerInstances;
|
|
@@ -131,7 +131,7 @@ export const CompRenderer = observer(function (props) {
|
|
|
131
131
|
|
|
132
132
|
// 选区的预览的click事件
|
|
133
133
|
const onCustomEvent = ({ order: index, blockKey }) => {
|
|
134
|
-
if (index) {
|
|
134
|
+
if (index !== undefined) {
|
|
135
135
|
setBlockIndex(index);
|
|
136
136
|
setBlockType(blockKey);
|
|
137
137
|
}
|