worsoft-frontend-codegen-local-mcp 0.1.76 → 0.1.77
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/mcp_server.js +38 -30
- package/package.json +1 -1
package/mcp_server.js
CHANGED
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
7
|
const SERVER_NAME = 'worsoft-codegen-local';
|
|
8
|
-
const SERVER_VERSION = '0.1.
|
|
8
|
+
const SERVER_VERSION = '0.1.77';
|
|
9
9
|
const PROTOCOL_VERSION = '2024-11-05';
|
|
10
10
|
const TOOL_NAME = 'worsoft_codegen_local_generate_frontend';
|
|
11
11
|
const STYLE_CATALOG_PATH = path.join(__dirname, 'assets', 'style-catalog.json');
|
|
@@ -1346,20 +1346,27 @@ function normalizeStructuredLengthAndScale(lengthValue, scaleValue) {
|
|
|
1346
1346
|
};
|
|
1347
1347
|
}
|
|
1348
1348
|
|
|
1349
|
-
function parseOptionalOrder(value, label) {
|
|
1350
|
-
if (value === undefined || value === null || value === '') return undefined;
|
|
1351
|
-
const order = Number.parseInt(String(value), 10);
|
|
1352
|
-
if (Number.isNaN(order) || order < 0) {
|
|
1353
|
-
throw new Error(`${label} must be a positive integer when provided, or 0/empty when unspecified`);
|
|
1349
|
+
function parseOptionalOrder(value, label) {
|
|
1350
|
+
if (value === undefined || value === null || value === '') return undefined;
|
|
1351
|
+
const order = Number.parseInt(String(value), 10);
|
|
1352
|
+
if (Number.isNaN(order) || order < 0) {
|
|
1353
|
+
throw new Error(`${label} must be a positive integer when provided, or 0/empty when unspecified`);
|
|
1354
1354
|
}
|
|
1355
|
-
if (order === 0) return undefined;
|
|
1356
|
-
return order;
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
function
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1355
|
+
if (order === 0) return undefined;
|
|
1356
|
+
return order;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
function normalizeOptionWidth(value) {
|
|
1360
|
+
if (value === undefined || value === null) return '';
|
|
1361
|
+
const normalized = String(value).trim();
|
|
1362
|
+
if (!normalized || normalized === '-' || normalized === '/') return '';
|
|
1363
|
+
return normalized.replace(/px$/i, '');
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
function sortFieldsForForm(fields) {
|
|
1367
|
+
const seenOrders = new Map();
|
|
1368
|
+
fields
|
|
1369
|
+
.filter((field) => field.formShow !== false && !field.primary)
|
|
1363
1370
|
.forEach((field) => {
|
|
1364
1371
|
if (field.formOrder === undefined) return;
|
|
1365
1372
|
const existing = seenOrders.get(field.formOrder);
|
|
@@ -1430,13 +1437,14 @@ function normalizeStructuredField(inputField, index, contextLabel) {
|
|
|
1430
1437
|
readonly: parseBooleanLike(inputField.readonly, false),
|
|
1431
1438
|
show,
|
|
1432
1439
|
listShow,
|
|
1433
|
-
formShow,
|
|
1434
|
-
formOrder,
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
+
formShow,
|
|
1441
|
+
formOrder,
|
|
1442
|
+
width: normalizeOptionWidth(inputField.width),
|
|
1443
|
+
smart: parseBooleanLike(inputField.smart, false),
|
|
1444
|
+
queryType: Number.isNaN(explicitQueryType)
|
|
1445
|
+
? undefined
|
|
1446
|
+
: explicitQueryType !== undefined
|
|
1447
|
+
? explicitQueryType
|
|
1440
1448
|
: normalizeDictType(inputField.dictType) && listShow
|
|
1441
1449
|
? 30
|
|
1442
1450
|
: undefined,
|
|
@@ -2213,15 +2221,15 @@ function includesAnyLabel(label, values) {
|
|
|
2213
2221
|
function getDefaultOptionFieldWidthV2(field) {
|
|
2214
2222
|
return '100';
|
|
2215
2223
|
}
|
|
2216
|
-
function renderOptionFieldV2(field, labelKey, dictRegistryRefs, indent = ' ') {
|
|
2217
|
-
const fallbackLabel = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
2218
|
-
const parts = [`key: '${field.attrName}'`, `labelKey: '${labelKey}'`, `label: '${fallbackLabel}'`];
|
|
2219
|
-
const prdWidth = field.width
|
|
2220
|
-
const width = prdWidth || getDefaultOptionFieldWidthV2(field);
|
|
2221
|
-
|
|
2222
|
-
if (width !== '100') {
|
|
2223
|
-
parts.push(`width: '${width}'`);
|
|
2224
|
-
}
|
|
2224
|
+
function renderOptionFieldV2(field, labelKey, dictRegistryRefs, indent = ' ') {
|
|
2225
|
+
const fallbackLabel = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
|
|
2226
|
+
const parts = [`key: '${field.attrName}'`, `labelKey: '${labelKey}'`, `label: '${fallbackLabel}'`];
|
|
2227
|
+
const prdWidth = normalizeOptionWidth(field.width);
|
|
2228
|
+
const width = prdWidth || getDefaultOptionFieldWidthV2(field);
|
|
2229
|
+
|
|
2230
|
+
if (prdWidth || width !== '100') {
|
|
2231
|
+
parts.push(`width: '${width}'`);
|
|
2232
|
+
}
|
|
2225
2233
|
|
|
2226
2234
|
if (field.dictType) {
|
|
2227
2235
|
parts.push(`dictType: ${getDictRegistryReference(field.dictType, dictRegistryRefs)}`);
|
package/package.json
CHANGED