worsoft-frontend-codegen-local-mcp 0.1.76 → 0.1.78

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.
Files changed (2) hide show
  1. package/mcp_server.js +38 -31
  2. 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.76';
8
+ const SERVER_VERSION = '0.1.78';
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,26 @@ 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`);
1354
- }
1355
- if (order === 0) return undefined;
1356
- return order;
1357
- }
1358
-
1359
- function sortFieldsForForm(fields) {
1360
- const seenOrders = new Map();
1361
- fields
1362
- .filter((field) => field.formShow !== false && !field.primary)
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 non-negative integer when provided, or empty when unspecified`);
1354
+ }
1355
+ return order;
1356
+ }
1357
+
1358
+ function normalizeOptionWidth(value) {
1359
+ if (value === undefined || value === null) return '';
1360
+ const normalized = String(value).trim();
1361
+ if (!normalized || normalized === '-' || normalized === '/') return '';
1362
+ return normalized.replace(/px$/i, '');
1363
+ }
1364
+
1365
+ function sortFieldsForForm(fields) {
1366
+ const seenOrders = new Map();
1367
+ fields
1368
+ .filter((field) => field.formShow !== false && !field.primary)
1363
1369
  .forEach((field) => {
1364
1370
  if (field.formOrder === undefined) return;
1365
1371
  const existing = seenOrders.get(field.formOrder);
@@ -1430,13 +1436,14 @@ function normalizeStructuredField(inputField, index, contextLabel) {
1430
1436
  readonly: parseBooleanLike(inputField.readonly, false),
1431
1437
  show,
1432
1438
  listShow,
1433
- formShow,
1434
- formOrder,
1435
- smart: parseBooleanLike(inputField.smart, false),
1436
- queryType: Number.isNaN(explicitQueryType)
1437
- ? undefined
1438
- : explicitQueryType !== undefined
1439
- ? explicitQueryType
1439
+ formShow,
1440
+ formOrder,
1441
+ width: normalizeOptionWidth(inputField.width),
1442
+ smart: parseBooleanLike(inputField.smart, false),
1443
+ queryType: Number.isNaN(explicitQueryType)
1444
+ ? undefined
1445
+ : explicitQueryType !== undefined
1446
+ ? explicitQueryType
1440
1447
  : normalizeDictType(inputField.dictType) && listShow
1441
1448
  ? 30
1442
1449
  : undefined,
@@ -2213,15 +2220,15 @@ function includesAnyLabel(label, values) {
2213
2220
  function getDefaultOptionFieldWidthV2(field) {
2214
2221
  return '100';
2215
2222
  }
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 ? field.width.replace('px', '') : null;
2220
- const width = prdWidth || getDefaultOptionFieldWidthV2(field);
2221
-
2222
- if (width !== '100') {
2223
- parts.push(`width: '${width}'`);
2224
- }
2223
+ function renderOptionFieldV2(field, labelKey, dictRegistryRefs, indent = ' ') {
2224
+ const fallbackLabel = stripDictAnnotation(field.comment).replace(/'/g, "\\'");
2225
+ const parts = [`key: '${field.attrName}'`, `labelKey: '${labelKey}'`, `label: '${fallbackLabel}'`];
2226
+ const prdWidth = normalizeOptionWidth(field.width);
2227
+ const width = prdWidth || getDefaultOptionFieldWidthV2(field);
2228
+
2229
+ if (prdWidth || width !== '100') {
2230
+ parts.push(`width: '${width}'`);
2231
+ }
2225
2232
 
2226
2233
  if (field.dictType) {
2227
2234
  parts.push(`dictType: ${getDictRegistryReference(field.dictType, dictRegistryRefs)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worsoft-frontend-codegen-local-mcp",
3
- "version": "0.1.76",
3
+ "version": "0.1.78",
4
4
  "description": "Worsoft frontend local-template code generation MCP server.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "worsoft <sw@worsoft.vip>",