@rotorsoft/act-diagram 1.0.22 → 1.1.0
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/README.md +25 -7
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/client/lib/navigate.d.ts +1 -2
- package/dist/@types/client/lib/navigate.d.ts.map +1 -1
- package/dist/@types/index.d.ts +6 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/cli/act.js.map +1 -1
- package/dist/index.cjs +66 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2433,7 +2433,7 @@ function Diagram({
|
|
|
2433
2433
|
title: "@rotorsoft/act-diagram version",
|
|
2434
2434
|
children: [
|
|
2435
2435
|
"v",
|
|
2436
|
-
"1.0.
|
|
2436
|
+
"1.0.22"
|
|
2437
2437
|
]
|
|
2438
2438
|
}
|
|
2439
2439
|
)
|
|
@@ -3235,6 +3235,57 @@ function Tooltip({
|
|
|
3235
3235
|
);
|
|
3236
3236
|
}
|
|
3237
3237
|
|
|
3238
|
+
// src/client/lib/strip-fences.ts
|
|
3239
|
+
function parse_multi_file_response(raw) {
|
|
3240
|
+
const files = [];
|
|
3241
|
+
const re = /```(?:typescript|ts):([^\n]+)\n([\s\S]*?)```/g;
|
|
3242
|
+
let m;
|
|
3243
|
+
while ((m = re.exec(raw)) !== null) {
|
|
3244
|
+
const path = m[1].trim();
|
|
3245
|
+
const content = m[2].trim();
|
|
3246
|
+
if (path && content) {
|
|
3247
|
+
files.push({ path, content });
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
if (files.length === 0) {
|
|
3251
|
+
const code = strip_fences(raw);
|
|
3252
|
+
if (code.trim()) {
|
|
3253
|
+
files.push({ path: "src/app.ts", content: code });
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
return files;
|
|
3257
|
+
}
|
|
3258
|
+
function strip_fences(code) {
|
|
3259
|
+
let result = code.replace(/```(?:typescript|ts)?\s*\n/g, "");
|
|
3260
|
+
result = result.replace(/\n?```\s*$/g, "");
|
|
3261
|
+
result = result.replace(
|
|
3262
|
+
/^[\s\S]*?(?=\/\*\*|\/\/|import\b|export\b|const\b|let\b|var\b|type\b|interface\b|function\b)/,
|
|
3263
|
+
""
|
|
3264
|
+
);
|
|
3265
|
+
const lines = result.split("\n");
|
|
3266
|
+
let last_code_line = lines.length - 1;
|
|
3267
|
+
while (last_code_line > 0) {
|
|
3268
|
+
const trimmed = lines[last_code_line].trim();
|
|
3269
|
+
if (trimmed && /[;{})\]:]$|^\s*\/\/|^\s*\*\/|^\s*\*|^$/.test(trimmed))
|
|
3270
|
+
break;
|
|
3271
|
+
last_code_line--;
|
|
3272
|
+
}
|
|
3273
|
+
if (last_code_line < lines.length - 1) {
|
|
3274
|
+
result = lines.slice(0, last_code_line + 1).join("\n");
|
|
3275
|
+
}
|
|
3276
|
+
return result.trim();
|
|
3277
|
+
}
|
|
3278
|
+
function derive_project_name(prompt, code) {
|
|
3279
|
+
if (code) {
|
|
3280
|
+
const act_match = code.match(/(?:const|let|var)\s+(\w+)\s*=\s*act\s*\(/);
|
|
3281
|
+
if (act_match) return act_match[1];
|
|
3282
|
+
const state_match = code.match(/state\(\s*\{\s*(\w+)/);
|
|
3283
|
+
if (state_match) return state_match[1] + " App";
|
|
3284
|
+
}
|
|
3285
|
+
const words = prompt.replace(/[^\w\s]/g, "").split(/\s+/).filter((w) => w.length > 2).slice(0, 3);
|
|
3286
|
+
return words.length > 0 ? words.map((w) => w[0].toUpperCase() + w.slice(1).toLowerCase()).join(" ") : "Generated App";
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3238
3289
|
// src/client/types/domain-model.ts
|
|
3239
3290
|
function emptyModel2() {
|
|
3240
3291
|
return {
|
|
@@ -3252,7 +3303,14 @@ export {
|
|
|
3252
3303
|
Diagram,
|
|
3253
3304
|
Logo,
|
|
3254
3305
|
Tooltip,
|
|
3306
|
+
compute_layout as computeLayout,
|
|
3307
|
+
derive_project_name as deriveProjectName,
|
|
3255
3308
|
emptyModel2 as emptyModel,
|
|
3309
|
+
extract_model as extractModel,
|
|
3310
|
+
navigate_to_code as navigateToCode,
|
|
3311
|
+
parse_multi_file_response as parseMultiFileResponse,
|
|
3312
|
+
strip_fences as stripFences,
|
|
3313
|
+
topo_sort as topoSort,
|
|
3256
3314
|
validate
|
|
3257
3315
|
};
|
|
3258
3316
|
//# sourceMappingURL=index.js.map
|