@lark-apaas/fullstack-cli 1.1.63-beta.0 → 1.1.64-alpha.20260901040718
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/dist/index.js +71 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1195,19 +1195,80 @@ function extractTypeAnnotation(comment) {
|
|
|
1195
1195
|
const typeStart = comment.indexOf("@type");
|
|
1196
1196
|
if (typeStart === -1) return null;
|
|
1197
1197
|
const afterType = comment.slice(typeStart + 5).trimStart();
|
|
1198
|
-
if (!afterType
|
|
1198
|
+
if (!afterType) return null;
|
|
1199
|
+
if (afterType.startsWith("{")) {
|
|
1200
|
+
const braceEnd = matchBalanced(afterType, 0, "{", "}");
|
|
1201
|
+
if (braceEnd === -1) return null;
|
|
1202
|
+
return afterType.slice(0, consumeArraySuffixes(afterType, braceEnd)).trimEnd();
|
|
1203
|
+
}
|
|
1204
|
+
const parsedEnd = parseTypeExpression(afterType);
|
|
1205
|
+
if (parsedEnd === -1) return null;
|
|
1206
|
+
const rest = afterType.slice(parsedEnd).replace(/^\s+/, "");
|
|
1207
|
+
if (rest && !rest.startsWith("@") && continuesTypeExpression(rest)) return null;
|
|
1208
|
+
return afterType.slice(0, parsedEnd).trimEnd();
|
|
1209
|
+
}
|
|
1210
|
+
function matchBalanced(source, start, open, close) {
|
|
1199
1211
|
let depth = 0;
|
|
1200
|
-
let
|
|
1201
|
-
|
|
1202
|
-
if (
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1212
|
+
for (let i = start; i < source.length; i++) {
|
|
1213
|
+
const quoted = skipStringLiteral(source, i);
|
|
1214
|
+
if (quoted !== -1) {
|
|
1215
|
+
i = quoted - 1;
|
|
1216
|
+
continue;
|
|
1217
|
+
}
|
|
1218
|
+
if (source[i] === open) depth++;
|
|
1219
|
+
else if (source[i] === close) {
|
|
1220
|
+
depth--;
|
|
1221
|
+
if (depth === 0) return i + 1;
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
return -1;
|
|
1225
|
+
}
|
|
1226
|
+
function skipStringLiteral(source, i) {
|
|
1227
|
+
const quote = source[i];
|
|
1228
|
+
if (quote !== "'" && quote !== '"' && quote !== "`") return -1;
|
|
1229
|
+
for (let j = i + 1; j < source.length; j++) {
|
|
1230
|
+
if (source[j] === "\\") {
|
|
1231
|
+
j++;
|
|
1232
|
+
continue;
|
|
1207
1233
|
}
|
|
1234
|
+
if (source[j] === quote) return j + 1;
|
|
1208
1235
|
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1236
|
+
return -1;
|
|
1237
|
+
}
|
|
1238
|
+
function consumeArraySuffixes(source, end) {
|
|
1239
|
+
let i = end;
|
|
1240
|
+
for (; ; ) {
|
|
1241
|
+
const suffix = /^\s*\[\s*\]/.exec(source.slice(i));
|
|
1242
|
+
if (!suffix) return i;
|
|
1243
|
+
i += suffix[0].length;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
function parseTypeExpression(source) {
|
|
1247
|
+
let i = parseTypeAtom(source, 0);
|
|
1248
|
+
if (i === -1) return -1;
|
|
1249
|
+
for (; ; ) {
|
|
1250
|
+
const union = /^\s*\|\s*/.exec(source.slice(i));
|
|
1251
|
+
if (!union) return i;
|
|
1252
|
+
const next = parseTypeAtom(source, i + union[0].length);
|
|
1253
|
+
if (next === -1) return i;
|
|
1254
|
+
i = next;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
function parseTypeAtom(source, start) {
|
|
1258
|
+
const quoted = skipStringLiteral(source, start);
|
|
1259
|
+
if (quoted !== -1) return consumeArraySuffixes(source, quoted);
|
|
1260
|
+
const identifier = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*/.exec(source.slice(start));
|
|
1261
|
+
if (!identifier) return -1;
|
|
1262
|
+
let i = start + identifier[0].length;
|
|
1263
|
+
if (source[i] === "<") {
|
|
1264
|
+
const generic = matchBalanced(source, i, "<", ">");
|
|
1265
|
+
if (generic === -1) return i;
|
|
1266
|
+
i = generic;
|
|
1267
|
+
}
|
|
1268
|
+
return consumeArraySuffixes(source, i);
|
|
1269
|
+
}
|
|
1270
|
+
function continuesTypeExpression(rest) {
|
|
1271
|
+
return /^(?:[|&<>[\].,()?:=]|extends\b|keyof\b|typeof\b|infer\b)/.test(rest);
|
|
1211
1272
|
}
|
|
1212
1273
|
function parseColumnComment(comment) {
|
|
1213
1274
|
const typeValue = extractTypeAnnotation(comment);
|