@rotorsoft/act-diagram 1.0.22 → 1.1.1

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.cjs CHANGED
@@ -25,7 +25,14 @@ __export(index_exports, {
25
25
  Diagram: () => Diagram,
26
26
  Logo: () => Logo,
27
27
  Tooltip: () => Tooltip,
28
+ computeLayout: () => compute_layout,
29
+ deriveProjectName: () => derive_project_name,
28
30
  emptyModel: () => emptyModel2,
31
+ extractModel: () => extract_model,
32
+ navigateToCode: () => navigate_to_code,
33
+ parseMultiFileResponse: () => parse_multi_file_response,
34
+ stripFences: () => strip_fences,
35
+ topoSort: () => topo_sort,
29
36
  validate: () => validate
30
37
  });
31
38
  module.exports = __toCommonJS(index_exports);
@@ -2457,7 +2464,7 @@ function Diagram({
2457
2464
  title: "@rotorsoft/act-diagram version",
2458
2465
  children: [
2459
2466
  "v",
2460
- "1.0.21"
2467
+ "1.1.0"
2461
2468
  ]
2462
2469
  }
2463
2470
  )
@@ -3259,6 +3266,57 @@ function Tooltip({
3259
3266
  );
3260
3267
  }
3261
3268
 
3269
+ // src/client/lib/strip-fences.ts
3270
+ function parse_multi_file_response(raw) {
3271
+ const files = [];
3272
+ const re = /```(?:typescript|ts):([^\n]+)\n([\s\S]*?)```/g;
3273
+ let m;
3274
+ while ((m = re.exec(raw)) !== null) {
3275
+ const path = m[1].trim();
3276
+ const content = m[2].trim();
3277
+ if (path && content) {
3278
+ files.push({ path, content });
3279
+ }
3280
+ }
3281
+ if (files.length === 0) {
3282
+ const code = strip_fences(raw);
3283
+ if (code.trim()) {
3284
+ files.push({ path: "src/app.ts", content: code });
3285
+ }
3286
+ }
3287
+ return files;
3288
+ }
3289
+ function strip_fences(code) {
3290
+ let result = code.replace(/```(?:typescript|ts)?\s*\n/g, "");
3291
+ result = result.replace(/\n?```\s*$/g, "");
3292
+ result = result.replace(
3293
+ /^[\s\S]*?(?=\/\*\*|\/\/|import\b|export\b|const\b|let\b|var\b|type\b|interface\b|function\b)/,
3294
+ ""
3295
+ );
3296
+ const lines = result.split("\n");
3297
+ let last_code_line = lines.length - 1;
3298
+ while (last_code_line > 0) {
3299
+ const trimmed = lines[last_code_line].trim();
3300
+ if (trimmed && /[;{})\]:]$|^\s*\/\/|^\s*\*\/|^\s*\*|^$/.test(trimmed))
3301
+ break;
3302
+ last_code_line--;
3303
+ }
3304
+ if (last_code_line < lines.length - 1) {
3305
+ result = lines.slice(0, last_code_line + 1).join("\n");
3306
+ }
3307
+ return result.trim();
3308
+ }
3309
+ function derive_project_name(prompt, code) {
3310
+ if (code) {
3311
+ const act_match = code.match(/(?:const|let|var)\s+(\w+)\s*=\s*act\s*\(/);
3312
+ if (act_match) return act_match[1];
3313
+ const state_match = code.match(/state\(\s*\{\s*(\w+)/);
3314
+ if (state_match) return state_match[1] + " App";
3315
+ }
3316
+ const words = prompt.replace(/[^\w\s]/g, "").split(/\s+/).filter((w) => w.length > 2).slice(0, 3);
3317
+ return words.length > 0 ? words.map((w) => w[0].toUpperCase() + w.slice(1).toLowerCase()).join(" ") : "Generated App";
3318
+ }
3319
+
3262
3320
  // src/client/types/domain-model.ts
3263
3321
  function emptyModel2() {
3264
3322
  return {
@@ -3277,7 +3335,14 @@ function emptyModel2() {
3277
3335
  Diagram,
3278
3336
  Logo,
3279
3337
  Tooltip,
3338
+ computeLayout,
3339
+ deriveProjectName,
3280
3340
  emptyModel,
3341
+ extractModel,
3342
+ navigateToCode,
3343
+ parseMultiFileResponse,
3344
+ stripFences,
3345
+ topoSort,
3281
3346
  validate
3282
3347
  });
3283
3348
  //# sourceMappingURL=index.cjs.map