openxiangda 1.0.4 → 1.0.6
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/package.json +1 -1
- package/packages/sdk/dist/runtime/index.cjs +84 -23
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.mjs +63 -2
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/src/build-source/scripts/build-forms.mjs +66 -13
- package/packages/sdk/src/build-source/scripts/publish-all.mjs +11 -2
- package/packages/sdk/src/build-source/scripts/utils/incremental.mjs +41 -9
- package/packages/sdk/src/build-source/scripts/utils/incremental.test.ts +78 -0
package/package.json
CHANGED
|
@@ -1108,6 +1108,7 @@ var createPageSdk = (context) => {
|
|
|
1108
1108
|
var import_cssinjs = require("@ant-design/cssinjs");
|
|
1109
1109
|
var import_antd = require("antd");
|
|
1110
1110
|
var import_zh_CN = __toESM(require("antd/locale/zh_CN.js"));
|
|
1111
|
+
var import_react3 = __toESM(require("react"));
|
|
1111
1112
|
var import_client2 = require("react-dom/client");
|
|
1112
1113
|
|
|
1113
1114
|
// packages/sdk/src/runtime/react/provider.tsx
|
|
@@ -1176,6 +1177,16 @@ var NAMESPACE_ROOT_CLASS = "sy-app-workspace";
|
|
|
1176
1177
|
var RUNTIME_PORTAL_ATTR = "data-sy-runtime-portal";
|
|
1177
1178
|
var PORTAL_CONTAINER_STACK_GLOBAL = "__OPENXIANGDA_PORTAL_CONTAINER_STACK__";
|
|
1178
1179
|
var PORTAL_CONTAINER_RESOLVER_GLOBAL = "__OPENXIANGDA_GET_PORTAL_CONTAINER__";
|
|
1180
|
+
var MESSAGE_PROXY_GLOBAL = "__OPENXIANGDA_ANTD_MESSAGE_PROXY__";
|
|
1181
|
+
var MESSAGE_METHODS = [
|
|
1182
|
+
"open",
|
|
1183
|
+
"success",
|
|
1184
|
+
"info",
|
|
1185
|
+
"warning",
|
|
1186
|
+
"error",
|
|
1187
|
+
"loading",
|
|
1188
|
+
"destroy"
|
|
1189
|
+
];
|
|
1179
1190
|
var createRuntimeRoot = (el) => {
|
|
1180
1191
|
return (0, import_client2.createRoot)(el);
|
|
1181
1192
|
};
|
|
@@ -1224,6 +1235,46 @@ var createPortalContainer = (el) => {
|
|
|
1224
1235
|
parent.appendChild(portalContainer);
|
|
1225
1236
|
return portalContainer;
|
|
1226
1237
|
};
|
|
1238
|
+
var getAntdMessageProxyState = () => {
|
|
1239
|
+
const globalScope = globalThis;
|
|
1240
|
+
if (!globalScope[MESSAGE_PROXY_GLOBAL]) {
|
|
1241
|
+
globalScope[MESSAGE_PROXY_GLOBAL] = {
|
|
1242
|
+
apiStack: [],
|
|
1243
|
+
installed: false,
|
|
1244
|
+
originalMethods: {}
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
return globalScope[MESSAGE_PROXY_GLOBAL];
|
|
1248
|
+
};
|
|
1249
|
+
var installAntdMessageProxy = () => {
|
|
1250
|
+
const state = getAntdMessageProxyState();
|
|
1251
|
+
if (state.installed) return state;
|
|
1252
|
+
MESSAGE_METHODS.forEach((method) => {
|
|
1253
|
+
const originalMethod = import_antd.message[method];
|
|
1254
|
+
if (typeof originalMethod !== "function") return;
|
|
1255
|
+
state.originalMethods[method] = originalMethod.bind(import_antd.message);
|
|
1256
|
+
import_antd.message[method] = (...args) => {
|
|
1257
|
+
const api = state.apiStack.at(-1);
|
|
1258
|
+
const apiMethod = api?.[method];
|
|
1259
|
+
if (typeof apiMethod === "function") {
|
|
1260
|
+
return apiMethod(...args);
|
|
1261
|
+
}
|
|
1262
|
+
return state.originalMethods[method]?.(...args);
|
|
1263
|
+
};
|
|
1264
|
+
});
|
|
1265
|
+
state.installed = true;
|
|
1266
|
+
return state;
|
|
1267
|
+
};
|
|
1268
|
+
var registerAntdMessageApi = (api) => {
|
|
1269
|
+
const state = installAntdMessageProxy();
|
|
1270
|
+
state.apiStack.push(api);
|
|
1271
|
+
return () => {
|
|
1272
|
+
const position = state.apiStack.lastIndexOf(api);
|
|
1273
|
+
if (position >= 0) {
|
|
1274
|
+
state.apiStack.splice(position, 1);
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
};
|
|
1227
1278
|
var installRuntimePortalContainer = (el) => {
|
|
1228
1279
|
const globalScope = globalThis;
|
|
1229
1280
|
const portalContainer = createPortalContainer(el);
|
|
@@ -1251,6 +1302,7 @@ var installRuntimePortalContainer = (el) => {
|
|
|
1251
1302
|
};
|
|
1252
1303
|
};
|
|
1253
1304
|
var installAntdStaticHolder = (el, portalContainer) => {
|
|
1305
|
+
installAntdMessageProxy();
|
|
1254
1306
|
const getMessageContainer = () => {
|
|
1255
1307
|
if (portalContainer?.isConnected) return portalContainer;
|
|
1256
1308
|
return getRuntimeRoot(el);
|
|
@@ -1280,6 +1332,15 @@ var installAntdStaticHolder = (el, portalContainer) => {
|
|
|
1280
1332
|
getContainer: getMessageContainer
|
|
1281
1333
|
});
|
|
1282
1334
|
};
|
|
1335
|
+
var RuntimeMessageBridge = ({ children }) => {
|
|
1336
|
+
const appContext = import_antd.App.useApp();
|
|
1337
|
+
import_react3.default.useLayoutEffect(() => {
|
|
1338
|
+
return registerAntdMessageApi(
|
|
1339
|
+
appContext.message
|
|
1340
|
+
);
|
|
1341
|
+
}, [appContext.message]);
|
|
1342
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children });
|
|
1343
|
+
};
|
|
1283
1344
|
var createReactPage = (AppComponent) => {
|
|
1284
1345
|
let root = null;
|
|
1285
1346
|
let currentContainer = null;
|
|
@@ -1300,7 +1361,7 @@ var createReactPage = (AppComponent) => {
|
|
|
1300
1361
|
installAntdStaticHolder(el, portalContainer);
|
|
1301
1362
|
const antdConfig = createAntdConfig(overlayContainer);
|
|
1302
1363
|
root.render(
|
|
1303
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_cssinjs.StyleProvider, { hashPriority: "high", container: getStyleContainer(el), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.ConfigProvider, { ...antdConfig, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.App, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PageProvider, { context, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AppComponent, {}) }) }) }) })
|
|
1364
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_cssinjs.StyleProvider, { hashPriority: "high", container: getStyleContainer(el), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.ConfigProvider, { ...antdConfig, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_antd.App, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RuntimeMessageBridge, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PageProvider, { context, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AppComponent, {}) }) }) }) }) })
|
|
1304
1365
|
);
|
|
1305
1366
|
};
|
|
1306
1367
|
return {
|
|
@@ -1322,7 +1383,7 @@ var createReactPage = (AppComponent) => {
|
|
|
1322
1383
|
};
|
|
1323
1384
|
|
|
1324
1385
|
// packages/sdk/src/runtime/react/hooks/useCurrentUser.ts
|
|
1325
|
-
var
|
|
1386
|
+
var import_react4 = require("react");
|
|
1326
1387
|
|
|
1327
1388
|
// packages/sdk/src/runtime/react/hooks/usePageContext.ts
|
|
1328
1389
|
var usePageContext = () => {
|
|
@@ -1332,7 +1393,7 @@ var usePageContext = () => {
|
|
|
1332
1393
|
// packages/sdk/src/runtime/react/hooks/useCurrentUser.ts
|
|
1333
1394
|
var useCurrentUser = () => {
|
|
1334
1395
|
const { user } = usePageContext();
|
|
1335
|
-
return (0,
|
|
1396
|
+
return (0, import_react4.useMemo)(() => {
|
|
1336
1397
|
const userType = user.userType === "guest" || user.isGuest ? "guest" : "normal";
|
|
1337
1398
|
const isGuest = userType === "guest";
|
|
1338
1399
|
return {
|
|
@@ -1350,7 +1411,7 @@ var useCurrentUser = () => {
|
|
|
1350
1411
|
};
|
|
1351
1412
|
|
|
1352
1413
|
// packages/sdk/src/runtime/react/hooks/useDataSource.ts
|
|
1353
|
-
var
|
|
1414
|
+
var import_react5 = require("react");
|
|
1354
1415
|
|
|
1355
1416
|
// packages/sdk/src/runtime/react/hooks/usePageSdk.ts
|
|
1356
1417
|
var usePageSdk = () => {
|
|
@@ -1368,19 +1429,19 @@ var createParamsSignature = (value) => {
|
|
|
1368
1429
|
var useDataSource = (name, options = {}) => {
|
|
1369
1430
|
const sdk = usePageSdk();
|
|
1370
1431
|
const { params, immediate = true, transform } = options;
|
|
1371
|
-
const paramsRef = (0,
|
|
1372
|
-
const transformRef = (0,
|
|
1432
|
+
const paramsRef = (0, import_react5.useRef)(params);
|
|
1433
|
+
const transformRef = (0, import_react5.useRef)(transform);
|
|
1373
1434
|
const paramsSignature = createParamsSignature(params);
|
|
1374
|
-
const [response, setResponse] = (0,
|
|
1435
|
+
const [response, setResponse] = (0, import_react5.useState)(
|
|
1375
1436
|
null
|
|
1376
1437
|
);
|
|
1377
|
-
const [result, setResult] = (0,
|
|
1378
|
-
const [data, setData] = (0,
|
|
1379
|
-
const [loading, setLoading] = (0,
|
|
1380
|
-
const [error, setError] = (0,
|
|
1438
|
+
const [result, setResult] = (0, import_react5.useState)(null);
|
|
1439
|
+
const [data, setData] = (0, import_react5.useState)(null);
|
|
1440
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
1441
|
+
const [error, setError] = (0, import_react5.useState)(null);
|
|
1381
1442
|
paramsRef.current = params;
|
|
1382
1443
|
transformRef.current = transform;
|
|
1383
|
-
const run = (0,
|
|
1444
|
+
const run = (0, import_react5.useCallback)(
|
|
1384
1445
|
async (overrideParams) => {
|
|
1385
1446
|
setLoading(true);
|
|
1386
1447
|
setError(null);
|
|
@@ -1407,7 +1468,7 @@ var useDataSource = (name, options = {}) => {
|
|
|
1407
1468
|
},
|
|
1408
1469
|
[name, sdk.dataSource]
|
|
1409
1470
|
);
|
|
1410
|
-
(0,
|
|
1471
|
+
(0, import_react5.useEffect)(() => {
|
|
1411
1472
|
if (!immediate) {
|
|
1412
1473
|
return;
|
|
1413
1474
|
}
|
|
@@ -1428,7 +1489,7 @@ var useDataSource = (name, options = {}) => {
|
|
|
1428
1489
|
};
|
|
1429
1490
|
|
|
1430
1491
|
// packages/sdk/src/runtime/react/hooks/useFormViewPermissions.ts
|
|
1431
|
-
var
|
|
1492
|
+
var import_react6 = require("react");
|
|
1432
1493
|
var EMPTY_SUMMARY = {
|
|
1433
1494
|
fieldPermissions: {},
|
|
1434
1495
|
operations: []
|
|
@@ -1444,12 +1505,12 @@ var toError = (error) => {
|
|
|
1444
1505
|
};
|
|
1445
1506
|
var useFormViewPermissions = (formUuid, options = {}) => {
|
|
1446
1507
|
const sdk = usePageSdk();
|
|
1447
|
-
const [summary, setSummary] = (0,
|
|
1448
|
-
const [response, setResponse] = (0,
|
|
1449
|
-
const [loading, setLoading] = (0,
|
|
1450
|
-
const [error, setError] = (0,
|
|
1508
|
+
const [summary, setSummary] = (0, import_react6.useState)(EMPTY_SUMMARY);
|
|
1509
|
+
const [response, setResponse] = (0, import_react6.useState)(null);
|
|
1510
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
1511
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
1451
1512
|
const immediate = options.immediate ?? true;
|
|
1452
|
-
const refresh = (0,
|
|
1513
|
+
const refresh = (0, import_react6.useCallback)(async () => {
|
|
1453
1514
|
const normalizedFormUuid = String(formUuid || "").trim();
|
|
1454
1515
|
if (!normalizedFormUuid) {
|
|
1455
1516
|
setSummary(EMPTY_SUMMARY);
|
|
@@ -1480,21 +1541,21 @@ var useFormViewPermissions = (formUuid, options = {}) => {
|
|
|
1480
1541
|
setLoading(false);
|
|
1481
1542
|
}
|
|
1482
1543
|
}, [formUuid, options.appType, sdk]);
|
|
1483
|
-
(0,
|
|
1544
|
+
(0, import_react6.useEffect)(() => {
|
|
1484
1545
|
if (!immediate) {
|
|
1485
1546
|
return;
|
|
1486
1547
|
}
|
|
1487
1548
|
void refresh();
|
|
1488
1549
|
}, [immediate, refresh]);
|
|
1489
|
-
const operationSet = (0,
|
|
1550
|
+
const operationSet = (0, import_react6.useMemo)(
|
|
1490
1551
|
() => new Set(summary.operations),
|
|
1491
1552
|
[summary.operations]
|
|
1492
1553
|
);
|
|
1493
|
-
const can = (0,
|
|
1554
|
+
const can = (0, import_react6.useCallback)(
|
|
1494
1555
|
(operation) => operationSet.has(operation),
|
|
1495
1556
|
[operationSet]
|
|
1496
1557
|
);
|
|
1497
|
-
const getFieldPermission = (0,
|
|
1558
|
+
const getFieldPermission = (0, import_react6.useCallback)(
|
|
1498
1559
|
(fieldName) => summary.fieldPermissions[fieldName] || null,
|
|
1499
1560
|
[summary.fieldPermissions]
|
|
1500
1561
|
);
|