@cloudbase/framework-plugin-low-code 0.7.8-beta.0 → 0.7.9
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/core/generate.d.ts.map +1 -1
- package/lib/builder/core/generate.js +0 -2
- package/lib/builder/service/builder/generate.d.ts.map +1 -1
- package/lib/builder/service/builder/generate.js +4 -0
- package/lib/builder/util/common.d.ts +1 -0
- package/lib/builder/util/common.d.ts.map +1 -1
- package/lib/builder/util/common.js +25 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +38 -73
- package/lib/weapps-core/utils/style.js +8 -0
- package/package.json +1 -1
- package/template/src/handlers/utils/common.js +24 -36
- package/template/src/index.jsx +6 -5
- package/template/src/utils/index.js +17 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/builder/core/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAe5C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAkBnD,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,kBAAkB,EAC3B,cAAc,kCAA2B,EACzC,YAAY,6BAAsB,EAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,SAAS,EAAE,EAC1B,UAAU,EAAE,WAAW,EACvB,OAAO,qBAAwB,EAC/B,aAAa,qBAAiB,EAC9B,SAAS;iBACM,OAAO;eACT,GAAG;aAIf,EACD,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/builder/core/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAe5C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAkBnD,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,kBAAkB,EAC3B,cAAc,kCAA2B,EACzC,YAAY,6BAAsB,EAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,SAAS,EAAE,EAC1B,UAAU,EAAE,WAAW,EACvB,OAAO,qBAAwB,EAC/B,aAAa,qBAAiB,EAC9B,SAAS;iBACM,OAAO;eACT,GAAG;aAIf,EACD,MAAM,EAAE,MAAM,iBA6Gf;AACD,wBAAsB,mBAAmB,CACvC,YAAY,oBAAa,EACzB,WAAW,EAAE,MAAM,EACnB,MAAM,KAAA,iBASP"}
|
|
@@ -53,7 +53,6 @@ function runGenerateCore(appBuildDir, appData, subAppDataList = [], dependencies
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
yield Promise.all(allAppDataList.map((data) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
var _a;
|
|
57
56
|
const { pageInstanceList, rootPath = '' } = data;
|
|
58
57
|
const appName = rootPath ? 'Sub app ' + rootPath : 'Main app';
|
|
59
58
|
console.log(chalk_1.default.blue.bold('Generating files for ' + appName));
|
|
@@ -69,7 +68,6 @@ function runGenerateCore(appBuildDir, appData, subAppDataList = [], dependencies
|
|
|
69
68
|
appConfig: (0, util_1.JsonToStringWithVariableName)({
|
|
70
69
|
id: appKey,
|
|
71
70
|
envId: appData.envId,
|
|
72
|
-
clientId: (_a = appData.extra) === null || _a === void 0 ? void 0 : _a.clientId,
|
|
73
71
|
staticResourceDomain: domain || '',
|
|
74
72
|
envVersion: deployMode === types_1.DEPLOY_MODE.UPLOAD ? 'production' : 'preview',
|
|
75
73
|
pages: pageInstanceList
|
|
@@ -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;
|
|
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;AAiB9B,OAAO,EAIL,SAAS,EACT,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAGxF,MAAM,WAAW,cAAe,SAAQ,kBAAkB;CAAG;AAE7D,wBAAsB,wBAAwB,CAC5C,cAAc,EAAE,kBAAkB,EAAE,EACpC,WAAW,EAAE,MAAM,iBAwBpB;AAED,wBAAsB,qBAAqB,CACzC,SAAS,oBAAa,EACtB,WAAW,EAAE,MAAM,iBAiBpB;AAED,wBAAsB,sBAAsB,CAC1C,gBAAgB,EAAE,aAAa,EAAE,EACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,6BAAsB,EAClC,SAAS;iBACM,OAAO;eACT,GAAG;aAIf,EACD,aAAa,EAAE,GAAG,EAAE,iBAcrB;AAED,wBAAsB,yBAAyB,CAC7C,YAAY,EAAE,aAAa,EAC3B,WAA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AAO,YAarC;AAED,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,cAAc,EAAE,EAC5B,wBAAwB,GAAE,MAAM,EAAO,YAoCxC;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,QA0BhC;AAED,wBAAsB,kBAAkB,CACtC,cAAc,EAAE,kBAAkB,EAAE,EACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,SAAK,EACb,aAAa,GAAE,SAAS,EAAO,iBA0ChC;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,iBA2FV"}
|
|
@@ -719,6 +719,7 @@ exports.writeLowCodeFilesForCompositeComp = writeLowCodeFilesForCompositeComp;
|
|
|
719
719
|
function generateCodeFromTpl(appData, appBuildDir, dependencies, appKey, rootPath, deployMode, buildTypeList, extraData) {
|
|
720
720
|
var _a;
|
|
721
721
|
return __awaiter(this, void 0, void 0, function* () {
|
|
722
|
+
const componentsScope = yield (0, util_1.getScopeComponents)(appBuildDir, dependencies);
|
|
722
723
|
const computedPageIds = [];
|
|
723
724
|
const pageModules = {};
|
|
724
725
|
(0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList, (p) => {
|
|
@@ -767,6 +768,9 @@ function generateCodeFromTpl(appData, appBuildDir, dependencies, appKey, rootPat
|
|
|
767
768
|
isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
|
|
768
769
|
isXPage: (0, common_1.buildAsXPageByBuildType)(buildTypeList),
|
|
769
770
|
},
|
|
771
|
+
'utils/index.js': {
|
|
772
|
+
componentsInfoMap: JSON.stringify(componentsScope),
|
|
773
|
+
},
|
|
770
774
|
};
|
|
771
775
|
if (!rootPath) {
|
|
772
776
|
templatesData['index.jsx'] = Object.assign(Object.assign({}, yyptConfig), { adminPortalKey: deployMode === types_1.DEPLOY_MODE.PREVIEW ? `${appKey}-preview` : appKey });
|
|
@@ -13,6 +13,7 @@ export declare function requireUncached(module: any): any;
|
|
|
13
13
|
export declare function removeRequireUncached(path?: string): void;
|
|
14
14
|
export declare function getInputProps(componentsMetaMap: IComponentsInfoMap): IComponentInputProps;
|
|
15
15
|
export declare function getComponentsInfo(appBuildDir: string, dependencies: IMaterialItem[]): Promise<IComponentsInfoMap>;
|
|
16
|
+
export declare function getScopeComponents(appBuildDir: string, dependencies: IMaterialItem[]): Promise<IComponentsInfoMap>;
|
|
16
17
|
export declare function getYyptConfigInfo(extraData: any): Promise<{
|
|
17
18
|
yyptAppKey: any;
|
|
18
19
|
reportUrl: any;
|
|
@@ -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,aAAa,EACd,MAAM,kCAAkC,CAAC;AAI1C,OAAO,EACL,sBAAsB,EAC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O,CAAC,kBAAkB,CAAC,CAiB7B;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"}
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = exports.getFileNameByUrl = exports.deepDealSchema = exports.simpleDeepClone = exports.deepDeal = exports.isPlainObject = exports.isArray = exports.getMetaInfoBySourceKey = void 0;
|
|
15
|
+
exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getScopeComponents = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = exports.getFileNameByUrl = exports.deepDealSchema = exports.simpleDeepClone = exports.deepDeal = exports.isPlainObject = exports.isArray = exports.getMetaInfoBySourceKey = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
18
|
const style_1 = require("./style");
|
|
@@ -151,6 +151,30 @@ function getComponentsInfo(appBuildDir, dependencies) {
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
exports.getComponentsInfo = getComponentsInfo;
|
|
154
|
+
function getScopeComponents(appBuildDir, dependencies) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
const componentsScope = {};
|
|
157
|
+
try {
|
|
158
|
+
const components = yield getComponentsInfo(appBuildDir, dependencies);
|
|
159
|
+
Object.entries(components).map(([key, value]) => {
|
|
160
|
+
var _a;
|
|
161
|
+
const dataForm = (value === null || value === void 0 ? void 0 : value.dataForm) || ((_a = value === null || value === void 0 ? void 0 : value.data) === null || _a === void 0 ? void 0 : _a.properties);
|
|
162
|
+
if (typeof dataForm === 'object') {
|
|
163
|
+
const dataFormOmit = Object.keys(dataForm).reduce((acc, prop) => {
|
|
164
|
+
var _a;
|
|
165
|
+
((_a = dataForm[prop]) === null || _a === void 0 ? void 0 : _a['x-slot-scope']) && (acc[prop] = dataForm[prop]);
|
|
166
|
+
return acc;
|
|
167
|
+
}, {});
|
|
168
|
+
Object.keys(dataFormOmit).length &&
|
|
169
|
+
(componentsScope[key] = { dataForm: dataFormOmit });
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
catch (e) { }
|
|
174
|
+
return componentsScope;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
exports.getScopeComponents = getScopeComponents;
|
|
154
178
|
function getYyptConfigInfo(extraData) {
|
|
155
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
156
180
|
let configJson;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
export * as generator from './generator/core/index';
|
|
3
2
|
import { PathLike } from 'fs-extra';
|
|
4
3
|
import { Plugin, PluginServiceApi } from '@cloudbase/framework-core';
|
|
5
4
|
import { BuildType, GenerateMpType } from './builder/types/common';
|
|
6
5
|
import { IMaterialItem, IPlugin } from './weapps-core';
|
|
7
6
|
import { DEPLOY_MODE, RUNTIME } from './types';
|
|
7
|
+
export * as generator from './generator/core/index';
|
|
8
8
|
export declare const DIST_PATH = "./dist";
|
|
9
9
|
export declare const PERSISTENT_DEPENDIENCES_MAP: {};
|
|
10
10
|
declare const DEFAULT_INPUTS: {
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,OAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAUrE,OAAO,EACL,SAAS,EAET,cAAc,EAIf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAYvD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAE7D,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAKpD,eAAO,MAAM,SAAS,WAAW,CAAC;AAClC,eAAO,MAAM,2BAA2B,IAAK,CAAC;AAoB9C,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;CAoBnB,CAAC;AAEF,MAAM,WAAW,6BAA6B;IAM5C,UAAU,CAAC,EAAE,MAAM,CAAC;IA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jB,gBAAgB;IA4HhB,2BAA2B;IAuE3B,UAAU;IAwBV,OAAO,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA;IAejB,uBAAuB;IA2BvB,yBAAyB;IAgG/B,oBAAoB;CAOrB;AA4BD,eAAO,MAAM,MAAM,sBAAgB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -43,7 +43,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
43
43
|
};
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
exports.plugin = exports.PERSISTENT_DEPENDIENCES_MAP = exports.DIST_PATH = exports.generator = void 0;
|
|
46
|
-
exports.generator = __importStar(require("./generator/core/index"));
|
|
47
46
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
48
47
|
const path_1 = __importDefault(require("path"));
|
|
49
48
|
const framework_core_1 = require("@cloudbase/framework-core");
|
|
@@ -64,6 +63,7 @@ const qrcode_1 = __importDefault(require("qrcode"));
|
|
|
64
63
|
const url_1 = __importDefault(require("url"));
|
|
65
64
|
const types_1 = require("./types");
|
|
66
65
|
const config_1 = require("./generator/config");
|
|
66
|
+
exports.generator = __importStar(require("./generator/core/index"));
|
|
67
67
|
exports.DIST_PATH = './dist';
|
|
68
68
|
exports.PERSISTENT_DEPENDIENCES_MAP = {};
|
|
69
69
|
const DEBUG_PATH = './debug';
|
|
@@ -108,7 +108,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
108
108
|
this._resolvedInputs = resolveInputs(inputs, resolveInputs(params, DEFAULT_INPUTS));
|
|
109
109
|
this._appPath = '';
|
|
110
110
|
this._productBasePath = `lca/${this._resolvedInputs.appId}/${process.env.CLOUDBASE_CIID ? `/${process.env.CLOUDBASE_CIID}` : ''}`;
|
|
111
|
-
let envId = this.api
|
|
111
|
+
let { envId } = this.api;
|
|
112
112
|
if (!this._resolvedInputs.mainAppSerializeData) {
|
|
113
113
|
throw new Error('缺少必须参数: mainAppSerializeData');
|
|
114
114
|
}
|
|
@@ -123,26 +123,28 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
123
123
|
if (this._checkIsVersion(this._resolvedInputs.calsVersion)) {
|
|
124
124
|
const cals = this._resolvedInputs.mainAppSerializeData;
|
|
125
125
|
if (!this._resolvedInputs.mainAppSerializeData.mpPkgUrl) {
|
|
126
|
-
this._resolvedInputs.mainAppSerializeData = (0, cals_1.deserializePlatformApp)(cals, {
|
|
126
|
+
this._resolvedInputs.mainAppSerializeData = (0, cals_1.deserializePlatformApp)(cals, {
|
|
127
|
+
dependencies: this._resolvedInputs.dependencies,
|
|
128
|
+
});
|
|
127
129
|
if ((_a = cals.extra) === null || _a === void 0 ? void 0 : _a.miniprogramPlugins) {
|
|
128
130
|
this._resolvedInputs.mainAppSerializeData.miniprogramPlugins = cals.extra.miniprogramPlugins.map((plugin) => {
|
|
129
131
|
var _a;
|
|
130
|
-
return Object.assign(Object.assign({}, plugin), { componentConfigs: ((_a = plugin.componentConfigs) === null || _a === void 0 ? void 0 : _a.map((component) => {
|
|
132
|
+
return (Object.assign(Object.assign({}, plugin), { componentConfigs: ((_a = plugin.componentConfigs) === null || _a === void 0 ? void 0 : _a.map((component) => {
|
|
131
133
|
const { data, events, meta = {} } = component, restComponent = __rest(component, ["data", "events", "meta"]);
|
|
132
134
|
const processedCompoennt = Object.assign(Object.assign({}, restComponent), { meta: {
|
|
133
135
|
desc: (meta === null || meta === void 0 ? void 0 : meta.desc) || (meta === null || meta === void 0 ? void 0 : meta.description),
|
|
134
136
|
} });
|
|
135
137
|
if (data) {
|
|
136
|
-
processedCompoennt
|
|
138
|
+
processedCompoennt.dataForm = data.properties;
|
|
137
139
|
}
|
|
138
140
|
if (events) {
|
|
139
|
-
processedCompoennt
|
|
141
|
+
processedCompoennt.emitEvents = events === null || events === void 0 ? void 0 : events.map((event) => ({
|
|
140
142
|
eventName: event.name,
|
|
141
143
|
name: event.title,
|
|
142
144
|
}));
|
|
143
145
|
}
|
|
144
146
|
return processedCompoennt;
|
|
145
|
-
})) || [] });
|
|
147
|
+
})) || [] }));
|
|
146
148
|
});
|
|
147
149
|
}
|
|
148
150
|
if (this._resolvedInputs.buildTypeList.includes("app") ||
|
|
@@ -325,7 +327,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
325
327
|
});
|
|
326
328
|
}
|
|
327
329
|
try {
|
|
328
|
-
const envId = this.api
|
|
330
|
+
const { envId } = this.api;
|
|
329
331
|
let [website, hostingDatas] = yield this._getHostingInfoTask(envId, true);
|
|
330
332
|
this._website = website;
|
|
331
333
|
}
|
|
@@ -380,10 +382,10 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
380
382
|
pauseConsoleOutput();
|
|
381
383
|
}
|
|
382
384
|
this._time("build process");
|
|
383
|
-
this._appPath = yield new Promise((resolve, reject) =>
|
|
384
|
-
var
|
|
385
|
+
this._appPath = yield new Promise((resolve, reject) => {
|
|
386
|
+
var _a, _b;
|
|
385
387
|
try {
|
|
386
|
-
|
|
388
|
+
(0, core_1.default)({
|
|
387
389
|
mainAppSerializeData,
|
|
388
390
|
subAppSerializeDataList,
|
|
389
391
|
dependencies,
|
|
@@ -393,7 +395,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
393
395
|
runtime: this._resolvedInputs.runtime,
|
|
394
396
|
ignoreInstall: this._resolvedInputs.ignoreInstall,
|
|
395
397
|
mode: webpackMode,
|
|
396
|
-
deployMode: (
|
|
398
|
+
deployMode: (_a = this._resolvedInputs.deployOptions) === null || _a === void 0 ? void 0 : _a.mode,
|
|
397
399
|
watch: false,
|
|
398
400
|
generateMpType,
|
|
399
401
|
generateMpPath,
|
|
@@ -401,11 +403,11 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
401
403
|
plugins,
|
|
402
404
|
extraData,
|
|
403
405
|
isCrossAccount: this._resolvedInputs.mpAppId !==
|
|
404
|
-
((
|
|
406
|
+
((_b = this._resolvedInputs.deployOptions) === null || _b === void 0 ? void 0 : _b.targetMpAppId),
|
|
405
407
|
resourceAppid: this._resolvedInputs.mpAppId,
|
|
406
408
|
domain,
|
|
407
409
|
}, (err, result) => __awaiter(this, void 0, void 0, function* () {
|
|
408
|
-
var
|
|
410
|
+
var _c;
|
|
409
411
|
if (!err) {
|
|
410
412
|
try {
|
|
411
413
|
const { appConfig = {} } = mainAppSerializeData;
|
|
@@ -447,7 +449,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
447
449
|
if ((0, common_2.buildAsWebByBuildType)(buildTypeList) &&
|
|
448
450
|
!(0, common_2.buildAsAdminPortalByBuildType)(buildTypeList) &&
|
|
449
451
|
this._checkBroswerHisroty()) {
|
|
450
|
-
yield Promise.all((((
|
|
452
|
+
yield Promise.all((((_c = this._resolvedInputs.mainAppSerializeData) === null || _c === void 0 ? void 0 : _c.pageInstanceList) || []).map((page) => fs_extra_1.default.copy(path_1.default.join(distPath, 'index.html'), path_1.default.join(distPath, page.id, 'index.html'))));
|
|
451
453
|
}
|
|
452
454
|
}
|
|
453
455
|
resolve(distPath);
|
|
@@ -486,7 +488,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
486
488
|
catch (e) {
|
|
487
489
|
reject(e);
|
|
488
490
|
}
|
|
489
|
-
})
|
|
491
|
+
});
|
|
490
492
|
if (!debug) {
|
|
491
493
|
resumeConsoleOutput();
|
|
492
494
|
}
|
|
@@ -550,11 +552,12 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
550
552
|
this._webPlugin) {
|
|
551
553
|
try {
|
|
552
554
|
const HostingProvider = (_a = this.api.resourceProviders) === null || _a === void 0 ? void 0 : _a.hosting;
|
|
553
|
-
const envId = this.api
|
|
555
|
+
const { envId } = this.api;
|
|
554
556
|
let [website, hostingDatas] = yield this._getHostingInfoTask(envId, false);
|
|
555
557
|
if (HostingProvider) {
|
|
556
558
|
if (!hostingDatas) {
|
|
557
|
-
hostingDatas = (yield HostingProvider.getHostingInfo({ envId
|
|
559
|
+
hostingDatas = (yield HostingProvider.getHostingInfo({ envId }))
|
|
560
|
+
.data;
|
|
558
561
|
}
|
|
559
562
|
let domains = hostingDatas.map((item) => item.cdnDomain);
|
|
560
563
|
this._domain = domains;
|
|
@@ -587,13 +590,11 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
587
590
|
cloudPath: `/weda-config/${config_1.PRIVATE_JS_NAME}`,
|
|
588
591
|
},
|
|
589
592
|
];
|
|
590
|
-
yield Promise.all(deployContent.map((options) => {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
});
|
|
596
|
-
}));
|
|
593
|
+
yield Promise.all(deployContent.map((options) => this.api.cloudbaseManager.hosting.uploadFiles({
|
|
594
|
+
localPath: options.src,
|
|
595
|
+
cloudPath: options.cloudPath,
|
|
596
|
+
ignore: this._webPlugin.resolvedInputs.ignore,
|
|
597
|
+
})));
|
|
597
598
|
}
|
|
598
599
|
if (!Object.keys(res.Resources || {}).length &&
|
|
599
600
|
!Object.keys(res.Config || {}).length) {
|
|
@@ -772,7 +773,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
772
773
|
return __awaiter(this, void 0, void 0, function* () {
|
|
773
774
|
const HostingProvider = (_a = this.api.resourceProviders) === null || _a === void 0 ? void 0 : _a.hosting;
|
|
774
775
|
let [website, hostingDatas] = yield HostingProvider.getHostingInfo({
|
|
775
|
-
envId
|
|
776
|
+
envId,
|
|
776
777
|
}).then(({ data: hostingDatas }) => {
|
|
777
778
|
let website = hostingDatas[0];
|
|
778
779
|
return [website, hostingDatas];
|
|
@@ -802,7 +803,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
802
803
|
let { credential, storage } = this._resolvedInputs;
|
|
803
804
|
let cos = (credential === null || credential === void 0 ? void 0 : credential.token)
|
|
804
805
|
? new cos_nodejs_sdk_v5_1.default({
|
|
805
|
-
getAuthorization
|
|
806
|
+
getAuthorization(options, callback) {
|
|
806
807
|
callback({
|
|
807
808
|
TmpSecretId: (credential === null || credential === void 0 ? void 0 : credential.secretId) || '',
|
|
808
809
|
TmpSecretKey: (credential === null || credential === void 0 ? void 0 : credential.secretKey) || '',
|
|
@@ -822,7 +823,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
822
823
|
Region: (storage === null || storage === void 0 ? void 0 : storage.region) || '',
|
|
823
824
|
Key: `${this._productBasePath}/dist.zip`,
|
|
824
825
|
Body: fs_extra_1.default.createReadStream(zipPath),
|
|
825
|
-
},
|
|
826
|
+
}, (err, data) => {
|
|
826
827
|
if (err) {
|
|
827
828
|
reject(err);
|
|
828
829
|
}
|
|
@@ -839,7 +840,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
839
840
|
Region: (storage === null || storage === void 0 ? void 0 : storage.region) || '',
|
|
840
841
|
Key: `${this._productBasePath}/qrcode.jpg`,
|
|
841
842
|
Body: fs_extra_1.default.createReadStream(path_1.default.resolve(this.api.projectPath, QRCODE_PATH)),
|
|
842
|
-
},
|
|
843
|
+
}, (err, data) => {
|
|
843
844
|
if (err) {
|
|
844
845
|
reject(err);
|
|
845
846
|
}
|
|
@@ -856,7 +857,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
856
857
|
Region: (storage === null || storage === void 0 ? void 0 : storage.region) || '',
|
|
857
858
|
Key: `${this._productBasePath}/${LOG_FILE}`,
|
|
858
859
|
Body: fs_extra_1.default.createReadStream(this._logFilePath),
|
|
859
|
-
},
|
|
860
|
+
}, (err, data) => {
|
|
860
861
|
if (err) {
|
|
861
862
|
reject(err);
|
|
862
863
|
}
|
|
@@ -876,7 +877,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
876
877
|
Region: (storage === null || storage === void 0 ? void 0 : storage.region) || '',
|
|
877
878
|
Key: `${this._productBasePath}/debug.zip`,
|
|
878
879
|
Body: fs_extra_1.default.createReadStream(zipPath),
|
|
879
|
-
},
|
|
880
|
+
}, (err, data) => {
|
|
880
881
|
if (err) {
|
|
881
882
|
reject(err);
|
|
882
883
|
}
|
|
@@ -899,7 +900,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
899
900
|
let { credential } = this._resolvedInputs;
|
|
900
901
|
let cos = (credential === null || credential === void 0 ? void 0 : credential.token)
|
|
901
902
|
? new cos_nodejs_sdk_v5_1.default({
|
|
902
|
-
getAuthorization
|
|
903
|
+
getAuthorization(options, callback) {
|
|
903
904
|
callback({
|
|
904
905
|
TmpSecretId: (credential === null || credential === void 0 ? void 0 : credential.secretId) || '',
|
|
905
906
|
TmpSecretKey: (credential === null || credential === void 0 ? void 0 : credential.secretKey) || '',
|
|
@@ -929,7 +930,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
929
930
|
Region: region,
|
|
930
931
|
Key: cosKey,
|
|
931
932
|
Body: fs_extra_1.default.createReadStream(zipPath),
|
|
932
|
-
},
|
|
933
|
+
}, (err, data) => {
|
|
933
934
|
if (err) {
|
|
934
935
|
reject(err);
|
|
935
936
|
}
|
|
@@ -962,8 +963,8 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
962
963
|
_zipDir(src, dist) {
|
|
963
964
|
return __awaiter(this, void 0, void 0, function* () {
|
|
964
965
|
return new Promise((resolve, reject) => {
|
|
965
|
-
|
|
966
|
-
|
|
966
|
+
let output = fs_extra_1.default.createWriteStream(dist);
|
|
967
|
+
let archive = (0, archiver_1.default)('zip', {
|
|
967
968
|
zlib: { level: 9 },
|
|
968
969
|
});
|
|
969
970
|
output.on('close', resolve);
|
|
@@ -979,38 +980,6 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
979
980
|
return __awaiter(this, void 0, void 0, function* () {
|
|
980
981
|
const { appId, buildTypeList, mainAppSerializeData, deployOptions, } = this._resolvedInputs;
|
|
981
982
|
if ((0, common_2.buildAsAdminPortalByBuildType)(buildTypeList)) {
|
|
982
|
-
try {
|
|
983
|
-
const isPreview = (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.PREVIEW;
|
|
984
|
-
const id = isPreview ? `${appId}-preview` : appId;
|
|
985
|
-
let name = (mainAppSerializeData === null || mainAppSerializeData === void 0 ? void 0 : mainAppSerializeData.label) || appId;
|
|
986
|
-
name = isPreview ? `${name}-预览` : name;
|
|
987
|
-
const params = {
|
|
988
|
-
ID: id,
|
|
989
|
-
Name: name,
|
|
990
|
-
EnvId: this.api.envId,
|
|
991
|
-
DeployUrl: `https://${path_1.default.join(this._website.cdnDomain, this._getWebRootPath())}?t=${Date.now()}`,
|
|
992
|
-
Pages: ((mainAppSerializeData === null || mainAppSerializeData === void 0 ? void 0 : mainAppSerializeData.pageInstanceList) || [])
|
|
993
|
-
.filter((page) => !page.hideAdminPortalMenu)
|
|
994
|
-
.map((page) => {
|
|
995
|
-
var _a, _b;
|
|
996
|
-
return ({
|
|
997
|
-
ID: page.id,
|
|
998
|
-
Title: ((_b = (_a = page.data) === null || _a === void 0 ? void 0 : _a.title) === null || _b === void 0 ? void 0 : _b.value) || page.id,
|
|
999
|
-
Path: `/${page.id}`,
|
|
1000
|
-
});
|
|
1001
|
-
}),
|
|
1002
|
-
};
|
|
1003
|
-
yield this.api.cloudbaseManager
|
|
1004
|
-
.commonService('lowcode', '2021-01-08')
|
|
1005
|
-
.call({
|
|
1006
|
-
Action: 'CreateRouter',
|
|
1007
|
-
Param: params,
|
|
1008
|
-
});
|
|
1009
|
-
this.api.logger.info('门户路由成功');
|
|
1010
|
-
}
|
|
1011
|
-
catch (e) {
|
|
1012
|
-
this.api.logger.error('门户路由注册失败: ', e);
|
|
1013
|
-
}
|
|
1014
983
|
try {
|
|
1015
984
|
if (((_b = (_a = this._resolvedInputs) === null || _a === void 0 ? void 0 : _a.deployOptions) === null || _b === void 0 ? void 0 : _b.mode) === types_1.DEPLOY_MODE.UPLOAD) {
|
|
1016
985
|
yield this.api.cloudbaseManager
|
|
@@ -1136,13 +1105,9 @@ let previousStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
|
1136
1105
|
let previousStderrWrite = process.stderr.write.bind(process.stderr);
|
|
1137
1106
|
function pauseConsoleOutput() {
|
|
1138
1107
|
previousStdoutWrite = process.stdout.write;
|
|
1139
|
-
process.stdout.write = () =>
|
|
1140
|
-
return true;
|
|
1141
|
-
};
|
|
1108
|
+
process.stdout.write = () => true;
|
|
1142
1109
|
previousStderrWrite = process.stderr.write.bind(process.stderr);
|
|
1143
|
-
process.stderr.write = () =>
|
|
1144
|
-
return true;
|
|
1145
|
-
};
|
|
1110
|
+
process.stderr.write = () => true;
|
|
1146
1111
|
}
|
|
1147
1112
|
function resumeConsoleOutput(original = false) {
|
|
1148
1113
|
if (original) {
|
|
@@ -214,7 +214,14 @@ function translateStyleByHandler(style = {}, handler) {
|
|
|
214
214
|
setStyleValue(result, key, value);
|
|
215
215
|
}
|
|
216
216
|
else if (value !== undefined && value !== null) {
|
|
217
|
+
try {
|
|
218
|
+
|
|
217
219
|
setStyleValue(result, key, handler(value));
|
|
220
|
+
}catch(e){
|
|
221
|
+
console.log(style,key,value)
|
|
222
|
+
console.log(e)
|
|
223
|
+
throw e
|
|
224
|
+
}
|
|
218
225
|
}
|
|
219
226
|
return result;
|
|
220
227
|
}, {});
|
|
@@ -257,6 +264,7 @@ function toREM(cssLen) {
|
|
|
257
264
|
return calPxToREM(cssLen);
|
|
258
265
|
}
|
|
259
266
|
else {
|
|
267
|
+
console.log(cssLen)
|
|
260
268
|
throw new Error('cssLen type error');
|
|
261
269
|
}
|
|
262
270
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/framework-plugin-low-code",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
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",
|
|
@@ -218,44 +218,29 @@ export async function checkAnonymous() {
|
|
|
218
218
|
return isAnonymous;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
let loginConfig;
|
|
222
|
-
export async function getLoginConfig() {
|
|
223
|
-
if (loginConfig !== undefined) {
|
|
224
|
-
return loginConfig;
|
|
225
|
-
}
|
|
226
|
-
const { staticResourceDomain, id } = app.__internal__.getConfig();
|
|
227
|
-
const url = `https://${staticResourceDomain}/${id}/login.config.json?t=${Date.now()}`;
|
|
228
|
-
try {
|
|
229
|
-
let response = await fetch(url);
|
|
230
|
-
loginConfig = await response.json();
|
|
231
|
-
} catch (e) {
|
|
232
|
-
loginConfig = {};
|
|
233
|
-
console.error(`加载登录配置${url}失败`, e);
|
|
234
|
-
}
|
|
235
|
-
return loginConfig;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
221
|
/**
|
|
239
222
|
* 检查页面权限
|
|
240
223
|
**/
|
|
241
224
|
export async function checkAuth(app, appId, $page) {
|
|
242
225
|
<% if (isAdminPortal || isXPage) { %>return true;<% } %>
|
|
243
|
-
|
|
244
|
-
|
|
226
|
+
const loginPage = findLoginPage(app);
|
|
227
|
+
if (loginPage?.id === $page.id) {
|
|
228
|
+
return true
|
|
229
|
+
}
|
|
230
|
+
app.showNavigationBarLoading();
|
|
245
231
|
const requestList = [getAccessPermission(app, appId, $page.id)];
|
|
246
|
-
//
|
|
247
|
-
if (
|
|
232
|
+
// 暂时先认为有登录页则自定义登录功能开启且生效
|
|
233
|
+
if (loginPage) {
|
|
248
234
|
requestList.push(getAuthConfig(app));
|
|
249
235
|
requestList.push(checkAnonymous());
|
|
250
|
-
requestList.push(getLoginConfig()); // 提前并行加载
|
|
251
236
|
}
|
|
252
237
|
const [isAccess, authConfig, isAnonymous] = await Promise.all(requestList);
|
|
253
238
|
app.hideNavigationBarLoading();
|
|
254
239
|
|
|
255
|
-
if (
|
|
240
|
+
if (loginPage && isAnonymous) {
|
|
256
241
|
if (authConfig.NeedLogin || (!isAccess && authConfig.RejectStrategy === 'to_login')) {
|
|
257
242
|
redirectToLogin($page);
|
|
258
|
-
return
|
|
243
|
+
return isAccess;
|
|
259
244
|
}
|
|
260
245
|
}
|
|
261
246
|
|
|
@@ -268,22 +253,25 @@ export async function checkAuth(app, appId, $page) {
|
|
|
268
253
|
return isAccess;
|
|
269
254
|
}
|
|
270
255
|
|
|
271
|
-
export
|
|
256
|
+
export function redirectToLogin(currentPage) {
|
|
272
257
|
// 去登录则清空权限缓存。
|
|
273
258
|
_AUTH_CACHE_MAP = {};
|
|
274
259
|
const app = window.app;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
260
|
+
const loginPage = findLoginPage(app);
|
|
261
|
+
if (!currentPage) {
|
|
262
|
+
currentPage = app.utils.getCurrentPage() || {};
|
|
263
|
+
}
|
|
264
|
+
if (loginPage?.id === currentPage.id) {
|
|
265
|
+
return true
|
|
266
|
+
}
|
|
267
|
+
if (loginPage) {
|
|
282
268
|
app.redirectTo({
|
|
283
|
-
|
|
284
|
-
params: {
|
|
285
|
-
|
|
286
|
-
|
|
269
|
+
pageId: loginPage.id,
|
|
270
|
+
params: {
|
|
271
|
+
sourcePageId: currentPage.id,
|
|
272
|
+
sourcePageParams: currentPage.dataset.params
|
|
273
|
+
}
|
|
274
|
+
})
|
|
287
275
|
} else {
|
|
288
276
|
app.showToast({
|
|
289
277
|
title: '用户未登录',
|
package/template/src/index.jsx
CHANGED
|
@@ -12,7 +12,7 @@ import attachFastClick from 'fastclick'
|
|
|
12
12
|
import { initWebConfig } from 'handlers/lifecycle'
|
|
13
13
|
const AppConfig = require('../webpack/miniprogram.config')
|
|
14
14
|
import { app } from './app/global-api'
|
|
15
|
-
import { redirectToLogin, getAuthConfig, checkAnonymous
|
|
15
|
+
import { redirectToLogin, findLoginPage, getAuthConfig, checkAnonymous } from './handlers/utils'
|
|
16
16
|
// app 中注册配置页面以及app的全局配置miniprogram.config,h5里分app以及web页分别处理,使用process.env.isApp 区分判断
|
|
17
17
|
if (process.env.isApp) {
|
|
18
18
|
initWebConfig(app, AppConfig);
|
|
@@ -26,7 +26,8 @@ setConfig({
|
|
|
26
26
|
},
|
|
27
27
|
beforeCallFunction: async (params) => {
|
|
28
28
|
try{
|
|
29
|
-
const
|
|
29
|
+
const loginPage = findLoginPage();
|
|
30
|
+
|
|
30
31
|
let skip = false;
|
|
31
32
|
switch (params?.data?.methodName) {
|
|
32
33
|
case 'callWedaApi': {
|
|
@@ -38,7 +39,7 @@ setConfig({
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
// 后续做过滤处理
|
|
41
|
-
if (!
|
|
42
|
+
if (!loginPage || (params?.data?.mode === 'c' && skip)) {
|
|
42
43
|
return params;
|
|
43
44
|
}
|
|
44
45
|
const { accessToken } = await getAccessToken();
|
|
@@ -59,8 +60,8 @@ setConfig({
|
|
|
59
60
|
},
|
|
60
61
|
async afterCallFunction(params, error, res) {
|
|
61
62
|
if(params?.data?.params?.action != 'DescribeRuntimeResourceStrategy' && ['InnerError.AuthFailure','InvalidAccessToken'].includes(res?.result?.code)) {
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
63
|
+
const loginPage = findLoginPage();
|
|
64
|
+
if (loginPage) {
|
|
64
65
|
const authConfig = await getAuthConfig();
|
|
65
66
|
const isAnonymous = await checkAnonymous();
|
|
66
67
|
if (isAnonymous && authConfig.RejectStrategy == 'to_login') {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { get as lodashGet, set as lodashSet } from 'lodash';
|
|
2
2
|
|
|
3
|
+
const componentsInfoMap = <%= componentsInfoMap %>;
|
|
4
|
+
|
|
3
5
|
export function createComputed(funcs, bindContext = null) {
|
|
4
6
|
const obj = {};
|
|
5
7
|
for (const name in funcs) {
|
|
@@ -54,11 +56,24 @@ const SCOPE_SLOT_MAP = SCOPE_SLOT_COMPONENT_LIB.reduce((map, lib) => {
|
|
|
54
56
|
return map;
|
|
55
57
|
}, {});
|
|
56
58
|
|
|
57
|
-
export function isScopeSlot(comp, slot) {
|
|
59
|
+
export function isScopeSlot(comp, slot, context={componentsInfoMap}) {
|
|
58
60
|
const { 'x-props': xProps } = comp;
|
|
59
61
|
const sourceKey = xProps && xProps.sourceKey;
|
|
62
|
+
|
|
63
|
+
let hasXslotScope = false;
|
|
64
|
+
try {
|
|
65
|
+
const component = context?.componentsInfoMap?.[sourceKey];
|
|
66
|
+
const dataForm = component?.dataForm || component?.data?.properties;
|
|
67
|
+
if (typeof dataForm === 'object') {
|
|
68
|
+
hasXslotScope = Object.keys(dataForm).some(
|
|
69
|
+
(prop) =>
|
|
70
|
+
slot.startsWith(`${prop}_`) && dataForm[prop]?.['x-slot-scope']
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
} catch (e) {}
|
|
74
|
+
|
|
60
75
|
const map = SCOPE_SLOT_MAP[sourceKey];
|
|
61
|
-
return map && map[slot];
|
|
76
|
+
return hasXslotScope || (map && map[slot]);
|
|
62
77
|
}
|
|
63
78
|
|
|
64
79
|
export function _isMobile() {
|