@akanjs/cli 3.2.0-rc.17 → 3.2.0-rc.19
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/.build-stamp +2 -2
- package/{CodeAgent-18qg03re.js → CodeAgent-q0xkt4at.js} +2 -2
- package/{CodeTui-zkm51zf3.js → CodeTui-n56kpaca.js} +819 -663
- package/TunnelShare-844s9te4.js +18 -0
- package/{agent.command-5k2zegmj.js → agent.command-k07raqft.js} +20 -20
- package/akanCode.js +8 -8
- package/{appExecutor-1bgs9a69.js → appExecutor-xav1zemr.js} +3 -3
- package/{application.command-ge27047n.js → application.command-dv8y8r12.js} +52 -25
- package/{applicationBuildRunner-7skfg8zn.js → applicationBuildRunner-vhx7zq97.js} +9 -10
- package/buildBatch.proc.js +20 -11
- package/{cloud.command-d18qj1v2.js → cloud.command-0vjy3x96.js} +22 -22
- package/cloud.script-jp48r0kw.js +35 -0
- package/{code.command-tz4x5zm6.js → code.command-xc5exq4b.js} +10 -10
- package/{context.command-x1smtm5q.js → context.command-etsat8yk.js} +22 -22
- package/context.runner-e52ak0cx.js +34 -0
- package/{guideline.command-rdcwxf8g.js → guideline.command-zqkntk7b.js} +6 -6
- package/guidelines/agentRule/agentRule.instruction.md +5 -4
- package/guidelines/conventions/core.md +18 -0
- package/guidelines/errorCodes/errorCodes.instruction.md +6 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +4 -2
- package/guidelines/transportRule/transportRule.instruction.md +3 -1
- package/incrementalBuilder.proc.js +559 -409
- package/{index-gh4brxzn.js → index-12js5pj4.js} +1 -1
- package/{index-jfkh776h.js → index-12vv4g80.js} +1 -1
- package/index-4zqebbqb.js +80 -0
- package/{index-er2ja34m.js → index-6bryy19d.js} +500 -422
- package/{index-3641r8q0.js → index-6pzncry1.js} +4 -4
- package/{index-fcrr79gh.js → index-6rrh0ffr.js} +44 -32
- package/{index-nd39rssn.js → index-7jr9mfp2.js} +286 -144
- package/{index-sp331bww.js → index-81qt1jyj.js} +1 -1
- package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
- package/{index-e82xwj3x.js → index-a05ewnnp.js} +1 -1
- package/{index-bjnebzzc.js → index-bxevbjw7.js} +8 -8
- package/{index-vm6pr11y.js → index-c1vym3gx.js} +2 -2
- package/{index-t8tysbxv.js → index-c9hd79py.js} +4 -4
- package/{index-j2eqe3jk.js → index-c9mnfy9r.js} +38 -23
- package/{index-dtpeyts6.js → index-cc9pevta.js} +1 -1
- package/{index-trp7jdr1.js → index-cet2s7xk.js} +7 -6
- package/{index-yr5jv8yd.js → index-dasa0kbj.js} +3 -3
- package/{index-bxqbt5p3.js → index-ddc2zjj5.js} +1 -1
- package/{index-g7e58wz2.js → index-dz7z9n9t.js} +25 -25
- package/{index-z7t6neq1.js → index-e4vna9dn.js} +4 -4
- package/{index-669sg3yp.js → index-ean2tff1.js} +723 -691
- package/{index-ttfz2sc7.js → index-fgp04fh7.js} +6 -6
- package/{index-bzdq8wfw.js → index-g541mhzw.js} +3 -3
- package/{index-t329y8am.js → index-gh741qft.js} +8 -8
- package/{index-d2r762fk.js → index-k51718xz.js} +2136 -2175
- package/{index-39byv35b.js → index-m6r3pvf5.js} +2 -2
- package/{index-emf3wzvh.js → index-my17308p.js} +7 -7
- package/{index-xywq95wk.js → index-nd8bq17n.js} +6 -6
- package/{index-q4e18ne4.js → index-nxcmgqk3.js} +3 -3
- package/{index-b2sptt87.js → index-pkgha3rt.js} +5 -5
- package/{index-s75h0455.js → index-q2t2w996.js} +1 -1
- package/{index-6p02be7n.js → index-qtqhsb33.js} +204 -160
- package/{index-h7yd92c8.js → index-rj2n5kfk.js} +67 -67
- package/{index-1ts8vfsk.js → index-s5gvwvkb.js} +103 -138
- package/{index-neassptx.js → index-sh3yzse2.js} +8 -7
- package/{index-f482h2hj.js → index-syn4vm3y.js} +1 -1
- package/{index-n8mxyy3f.js → index-t00xrkey.js} +1 -1
- package/{index-g56xae1n.js → index-v72mh89f.js} +7 -8
- package/{index-q57rsax4.js → index-wq8pnev4.js} +3 -3
- package/{index-dp7sht3v.js → index-wxr3941g.js} +8 -8
- package/{index-0c8zj1da.js → index-y8mqkhcf.js} +1 -1
- package/{index-9mx3b3zh.js → index-zk1gjk46.js} +4 -4
- package/index.js +27 -27
- package/{libExecutor-hxe5eqfh.js → libExecutor-mr3vxtnr.js} +2 -2
- package/{library.command-83shs8fw.js → library.command-ps9q5t37.js} +7 -7
- package/{localRegistry.command-sz713jg3.js → localRegistry.command-rszxmvd0.js} +21 -21
- package/{module.command-jhhm0nmw.js → module.command-fcybnn1a.js} +10 -10
- package/{package.command-42syy96v.js → package.command-zen3rhye.js} +10 -10
- package/package.json +2 -2
- package/{page.command-jkv29zzs.js → page.command-gwrxymms.js} +7 -7
- package/{pipeline.command-6sg9g4hq.js → pipeline.command-m1brkqqw.js} +6 -6
- package/{pkgExecutor-6p82w5y1.js → pkgExecutor-x51agavp.js} +2 -2
- package/{primitive.command-tt6aq7m9.js → primitive.command-5vkxvvmk.js} +11 -11
- package/{projectTypecheck-wfrz0cxr.js → projectTypecheck-9dzfah37.js} +1 -1
- package/{quality.command-tqar7ss5.js → quality.command-gqry7eas.js} +9 -9
- package/{repair.command-qkcn329t.js → repair.command-qs4ejcrg.js} +10 -10
- package/{routeSourceValidator-8aph1dsr.js → routeSourceValidator-8n6j1vn7.js} +3 -1
- package/{scalar.command-6nvq11ag.js → scalar.command-ny0vchqq.js} +9 -9
- package/skills/akan-scaffold/SKILL.md +1 -1
- package/{subspace.command-dvwds4cv.js → subspace.command-5pxqjgmw.js} +12 -12
- package/templates/biomeForm.ts +1 -1
- package/templates/env/_env.server.type.ts +1 -1
- package/templates/facetIndex/index.ts +2 -37
- package/templates/workspaceRoot/AGENTS.md.template +2 -1
- package/{tunnel.command-h8r69a7v.js → tunnel.command-ndajt0xk.js} +11 -11
- package/{verify.command-ynec8kt2.js → verify.command-m59ashc7.js} +17 -17
- package/{workflow.command-f70fx73a.js → workflow.command-jchqey88.js} +15 -15
- package/{workspace.command-vagjy1q9.js → workspace.command-g0gzxkpd.js} +36 -36
- package/TunnelShare-6t4rwyc0.js +0 -19
- package/cloud.script-0hbhm3mw.js +0 -35
- package/context.runner-vb7jc0k8.js +0 -34
- package/index-dqsc1b5t.js +0 -18
|
@@ -110,6 +110,9 @@ ${at.file}` : null;
|
|
|
110
110
|
return node.fields ? { ...node, fields: node.fields.map(({ digest: _field, ...field }) => field) } : node;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
+
// pkgs/@akanjs/language/guardResolver.ts
|
|
114
|
+
import { barrelFacetDirs, facetBarrelNamesOf } from "akanjs/common/facetBarrel.ts";
|
|
115
|
+
|
|
113
116
|
// pkgs/@akanjs/language/escapeRegExp.ts
|
|
114
117
|
var regExpSpecials = /[\\^$.*+?()[\]{}|]/g;
|
|
115
118
|
var escapeRegExp = (text) => text.replace(regExpSpecials, (special) => `\\${special}`);
|
|
@@ -391,7 +394,7 @@ var ownerOf = (relativePath) => {
|
|
|
391
394
|
const [root, name] = relativePath.split("/");
|
|
392
395
|
return (root === "apps" || root === "libs") && name ? `${root}/${name}` : null;
|
|
393
396
|
};
|
|
394
|
-
var
|
|
397
|
+
var syntaxReaderOf = (ts, ast) => {
|
|
395
398
|
const spanOf = (source, node) => {
|
|
396
399
|
const start = node.getStart(source);
|
|
397
400
|
const end = node.getEnd();
|
|
@@ -449,6 +452,74 @@ var createFactReader = (ts, ast) => {
|
|
|
449
452
|
const node = keyName(property);
|
|
450
453
|
return name && node ? [{ name, span: spanOf(source, node), extent: extentOf(source, property) }] : [];
|
|
451
454
|
});
|
|
455
|
+
const verbReaderOf = (parameter) => {
|
|
456
|
+
const verbs = new Map;
|
|
457
|
+
if (parameter && ts.isObjectBindingPattern(parameter.name))
|
|
458
|
+
for (const element of parameter.name.elements) {
|
|
459
|
+
const verb = element.propertyName ?? element.name;
|
|
460
|
+
if (ts.isIdentifier(verb) && ts.isIdentifier(element.name))
|
|
461
|
+
verbs.set(element.name.text, verb.text);
|
|
462
|
+
}
|
|
463
|
+
const holder = parameter && ts.isIdentifier(parameter.name) ? parameter.name.text : null;
|
|
464
|
+
return (callee) => {
|
|
465
|
+
if (callee && ts.isIdentifier(callee))
|
|
466
|
+
return verbs.get(callee.text) ?? null;
|
|
467
|
+
if (callee && ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === holder)
|
|
468
|
+
return callee.name.text;
|
|
469
|
+
return null;
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
return {
|
|
473
|
+
spanOf,
|
|
474
|
+
extentOf,
|
|
475
|
+
unwrap,
|
|
476
|
+
moduleRefOf,
|
|
477
|
+
returnedObject,
|
|
478
|
+
builderOf,
|
|
479
|
+
guardNameOf,
|
|
480
|
+
optionObjectOf,
|
|
481
|
+
chainOf,
|
|
482
|
+
keyName,
|
|
483
|
+
objectKeys,
|
|
484
|
+
verbReaderOf
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
var sourceReaderOf = (ts) => {
|
|
488
|
+
const importsOf = (statement) => {
|
|
489
|
+
const { importClause, moduleSpecifier } = statement;
|
|
490
|
+
if (!importClause || !ts.isStringLiteral(moduleSpecifier))
|
|
491
|
+
return [];
|
|
492
|
+
const from = moduleSpecifier.text;
|
|
493
|
+
const bindings = importClause.namedBindings;
|
|
494
|
+
return [
|
|
495
|
+
...importClause.name ? [{ name: importClause.name.text, imported: "default", from }] : [],
|
|
496
|
+
...bindings && ts.isNamespaceImport(bindings) ? [{ name: bindings.name.text, imported: "*", from }] : [],
|
|
497
|
+
...bindings && ts.isNamedImports(bindings) ? bindings.elements.map((element) => ({
|
|
498
|
+
name: element.name.text,
|
|
499
|
+
imported: (element.propertyName ?? element.name).text,
|
|
500
|
+
from
|
|
501
|
+
})) : []
|
|
502
|
+
];
|
|
503
|
+
};
|
|
504
|
+
const docOf = (source, node) => {
|
|
505
|
+
const { text } = source;
|
|
506
|
+
const ranges = ts.getLeadingCommentRanges(text, node.getFullStart()) ?? [];
|
|
507
|
+
const comments = [];
|
|
508
|
+
let end = node.getStart(source);
|
|
509
|
+
for (const range of [...ranges].reverse()) {
|
|
510
|
+
if ((text.slice(range.end, end).match(/\n/g)?.length ?? 0) > 1)
|
|
511
|
+
break;
|
|
512
|
+
comments.unshift(text.slice(range.pos, range.end));
|
|
513
|
+
end = range.pos;
|
|
514
|
+
}
|
|
515
|
+
const lines = comments.flatMap((comment) => comment.split(`
|
|
516
|
+
`)).map((line) => line.trim().replace(/^\/\*\*?|\*\/$/g, "").replace(/^(?:\/\/[?*!]?|\*)/, "").replace(/\{@link\s+([^}\s|]+)[^}]*\}/g, "$1").trim()).filter((line) => line && !/^(?:biome-ignore|eslint-|@ts-)/.test(line));
|
|
517
|
+
return lines.length ? lines.join(" ") : null;
|
|
518
|
+
};
|
|
519
|
+
const importsIn = (source) => source.statements.filter(ts.isImportDeclaration).flatMap(importsOf);
|
|
520
|
+
return { docOf, importsIn };
|
|
521
|
+
};
|
|
522
|
+
var signalKeyReaderOf = (ts, ast, { spanOf, extentOf, returnedObject, optionObjectOf, chainOf, verbReaderOf }, guardsIn) => {
|
|
452
523
|
const sliceKeysOf = (source, builder, made, model) => (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
453
524
|
if (!ts.isPropertyAssignment(property))
|
|
454
525
|
return [];
|
|
@@ -467,23 +538,30 @@ var createFactReader = (ts, ast) => {
|
|
|
467
538
|
}
|
|
468
539
|
];
|
|
469
540
|
});
|
|
470
|
-
const
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
541
|
+
const endpointKeysOf = (source, builder, made, model) => {
|
|
542
|
+
const verbOf = verbReaderOf(builder?.parameters[0]);
|
|
543
|
+
return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
544
|
+
if (!ts.isPropertyAssignment(property))
|
|
545
|
+
return [];
|
|
546
|
+
const name = ast.nodeName(property.name);
|
|
547
|
+
if (!name)
|
|
548
|
+
return [];
|
|
549
|
+
const { root, methods } = chainOf(property.initializer);
|
|
550
|
+
return [
|
|
551
|
+
{
|
|
552
|
+
name,
|
|
553
|
+
span: spanOf(source, property.name),
|
|
554
|
+
extent: extentOf(source, property),
|
|
555
|
+
verb: root ? verbOf(root.expression) : null,
|
|
556
|
+
guards: root ? guardsIn(source, optionObjectOf(root), made, `${model}.${name}`) : [],
|
|
557
|
+
argCount: methods.filter((method) => argMethods.has(method)).length
|
|
558
|
+
}
|
|
559
|
+
];
|
|
560
|
+
});
|
|
486
561
|
};
|
|
562
|
+
return { sliceKeysOf, endpointKeysOf };
|
|
563
|
+
};
|
|
564
|
+
var jobKeyReaderOf = (ts, ast, { spanOf, extentOf, unwrap, returnedObject, chainOf, verbReaderOf }) => {
|
|
487
565
|
const numberOf = (expression) => {
|
|
488
566
|
const value = unwrap(expression);
|
|
489
567
|
if (ts.isNumericLiteral(value))
|
|
@@ -556,6 +634,9 @@ var createFactReader = (ts, ast) => {
|
|
|
556
634
|
];
|
|
557
635
|
});
|
|
558
636
|
};
|
|
637
|
+
return { internalKeysOf };
|
|
638
|
+
};
|
|
639
|
+
var serviceReaderOf = (ts, ast, { spanOf, extentOf, returnedObject, guardNameOf, chainOf, verbReaderOf }) => {
|
|
559
640
|
const plugsOf = (source, builder) => {
|
|
560
641
|
const verbOf = verbReaderOf(builder?.parameters[0]);
|
|
561
642
|
return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
@@ -581,27 +662,17 @@ var createFactReader = (ts, ast) => {
|
|
|
581
662
|
visit(source);
|
|
582
663
|
return bindings;
|
|
583
664
|
};
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
name,
|
|
596
|
-
span: spanOf(source, property.name),
|
|
597
|
-
extent: extentOf(source, property),
|
|
598
|
-
verb: root ? verbOf(root.expression) : null,
|
|
599
|
-
guards: root ? guardsIn(source, optionObjectOf(root), made, `${model}.${name}`) : [],
|
|
600
|
-
argCount: methods.filter((method) => argMethods.has(method)).length
|
|
601
|
-
}
|
|
602
|
-
];
|
|
603
|
-
});
|
|
604
|
-
};
|
|
665
|
+
const methodsOf = (source, statement) => statement.members.flatMap((member) => {
|
|
666
|
+
if (!ts.isMethodDeclaration(member) || !member.body)
|
|
667
|
+
return [];
|
|
668
|
+
const name = ast.nodeName(member.name);
|
|
669
|
+
if (!name || ts.getModifiers(member)?.some(({ kind }) => kind === ts.SyntaxKind.StaticKeyword))
|
|
670
|
+
return [];
|
|
671
|
+
return [{ name, span: spanOf(source, member.name), extent: extentOf(source, member) }];
|
|
672
|
+
});
|
|
673
|
+
return { plugsOf, adaptorBindingsIn, methodsOf };
|
|
674
|
+
};
|
|
675
|
+
var constantReaderOf = (ts, ast, { spanOf, extentOf, unwrap, returnedObject, chainOf, keyName, objectKeys }) => {
|
|
605
676
|
const filterQueriesOf = (source, builder) => {
|
|
606
677
|
const query = returnedObject(builder)?.properties.find((property) => ts.isPropertyAssignment(property) && ast.nodeName(property.name) === "query")?.initializer;
|
|
607
678
|
return query && ts.isObjectLiteralExpression(query) ? objectKeys(source, query) : [];
|
|
@@ -639,48 +710,18 @@ var createFactReader = (ts, ast) => {
|
|
|
639
710
|
return [];
|
|
640
711
|
return list.elements.flatMap((element) => ts.isStringLiteralLike(element) ? [element.text] : []);
|
|
641
712
|
};
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
return [{ name, span: spanOf(source, member.name), extent: extentOf(source, member) }];
|
|
649
|
-
});
|
|
650
|
-
const importsOf = (statement) => {
|
|
651
|
-
const { importClause, moduleSpecifier } = statement;
|
|
652
|
-
if (!importClause || !ts.isStringLiteral(moduleSpecifier))
|
|
653
|
-
return [];
|
|
654
|
-
const from = moduleSpecifier.text;
|
|
655
|
-
const bindings = importClause.namedBindings;
|
|
656
|
-
return [
|
|
657
|
-
...importClause.name ? [{ name: importClause.name.text, imported: "default", from }] : [],
|
|
658
|
-
...bindings && ts.isNamespaceImport(bindings) ? [{ name: bindings.name.text, imported: "*", from }] : [],
|
|
659
|
-
...bindings && ts.isNamedImports(bindings) ? bindings.elements.map((element) => ({
|
|
660
|
-
name: element.name.text,
|
|
661
|
-
imported: (element.propertyName ?? element.name).text,
|
|
662
|
-
from
|
|
663
|
-
})) : []
|
|
664
|
-
];
|
|
665
|
-
};
|
|
666
|
-
const docOf = (source, node) => {
|
|
667
|
-
const { text } = source;
|
|
668
|
-
const ranges = ts.getLeadingCommentRanges(text, node.getFullStart()) ?? [];
|
|
669
|
-
const comments = [];
|
|
670
|
-
let end = node.getStart(source);
|
|
671
|
-
for (const range of [...ranges].reverse()) {
|
|
672
|
-
if ((text.slice(range.end, end).match(/\n/g)?.length ?? 0) > 1)
|
|
673
|
-
break;
|
|
674
|
-
comments.unshift(text.slice(range.pos, range.end));
|
|
675
|
-
end = range.pos;
|
|
676
|
-
}
|
|
677
|
-
const lines = comments.flatMap((comment) => comment.split(`
|
|
678
|
-
`)).map((line) => line.trim().replace(/^\/\*\*?|\*\/$/g, "").replace(/^(?:\/\/[?*!]?|\*)/, "").replace(/\{@link\s+([^}\s|]+)[^}]*\}/g, "$1").trim()).filter((line) => line && !/^(?:biome-ignore|eslint-|@ts-)/.test(line));
|
|
679
|
-
return lines.length ? lines.join(" ") : null;
|
|
680
|
-
};
|
|
713
|
+
return { constantOf, enumValuesOf, filterQueriesOf };
|
|
714
|
+
};
|
|
715
|
+
var createFactReader = (ts, ast) => {
|
|
716
|
+
const syntax = syntaxReaderOf(ts, ast);
|
|
717
|
+
const { spanOf, extentOf, unwrap, moduleRefOf, returnedObject, builderOf, chainOf, objectKeys } = syntax;
|
|
718
|
+
const { docOf, importsIn } = sourceReaderOf(ts);
|
|
681
719
|
const { guardsIn, guardsOf } = createGuardFactReader(ts, ast, { spanOf, extentOf, unwrap, docOf });
|
|
720
|
+
const { sliceKeysOf, endpointKeysOf } = signalKeyReaderOf(ts, ast, syntax, guardsIn);
|
|
721
|
+
const { internalKeysOf } = jobKeyReaderOf(ts, ast, syntax);
|
|
722
|
+
const { plugsOf, adaptorBindingsIn, methodsOf } = serviceReaderOf(ts, ast, syntax);
|
|
723
|
+
const { constantOf, enumValuesOf, filterQueriesOf } = constantReaderOf(ts, ast, syntax);
|
|
682
724
|
const lowerFirst = (text) => text.charAt(0).toLowerCase() + text.slice(1);
|
|
683
|
-
const importsIn = (source) => source.statements.filter(ts.isImportDeclaration).flatMap(importsOf);
|
|
684
725
|
const read = (source, owner) => {
|
|
685
726
|
const imports = importsIn(source);
|
|
686
727
|
const madeInPlace = [];
|
|
@@ -780,7 +821,9 @@ var aliasPattern = /^@(apps|libs)\/([^/]+)/;
|
|
|
780
821
|
var maxMapDepth = 4;
|
|
781
822
|
var identifierPattern = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200c\u200d]*$/u;
|
|
782
823
|
var starExportPattern = /export\s*\*\s*from\s*["']([^"']+)["']/g;
|
|
824
|
+
var facetEntryPattern = new RegExp(`^((?:apps|libs)/[^/]+/(${barrelFacetDirs.map(escapeRegExp).join("|")}))/([^/]+)(/)?`);
|
|
783
825
|
var exportingPatternOf = (name) => new RegExp(`export\\s*\\{(?:[^}]*?[\\s,])?${escapeRegExp(name)}(?![\\w$])`);
|
|
826
|
+
var exportMentioningPatternOf = (name) => new RegExp(`export\\s[^;]*?(?<![\\w$])${escapeRegExp(name)}(?![\\w$])`);
|
|
784
827
|
var declaringPatternOf = (name, isAnyBinding) => {
|
|
785
828
|
const escaped = escapeRegExp(name);
|
|
786
829
|
const braced = "\\{(?:[^}]*?[\\s,])?";
|
|
@@ -803,8 +846,11 @@ class GuardResolver {
|
|
|
803
846
|
#declarations = new Map;
|
|
804
847
|
#starExports = new Map;
|
|
805
848
|
#moduleExports = new Map;
|
|
849
|
+
#fileStars = new Map;
|
|
850
|
+
#starReach = new Map;
|
|
806
851
|
#ownerFiles = null;
|
|
807
852
|
#modules = null;
|
|
853
|
+
#barrels = null;
|
|
808
854
|
constructor(source, routes) {
|
|
809
855
|
this.#source = source;
|
|
810
856
|
this.#routes = routes;
|
|
@@ -932,7 +978,7 @@ ${name}`, guard);
|
|
|
932
978
|
const own = this.#nearest(candidates.filter((other) => other.owner === from), ({ site }) => site.fileName, near);
|
|
933
979
|
if (own)
|
|
934
980
|
return own;
|
|
935
|
-
const reexport = from && depth < maxMapDepth ? this
|
|
981
|
+
const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
|
|
936
982
|
if (reexport)
|
|
937
983
|
return this.#factoryAt(factories, reexport.local, reexport.site, depth + 1);
|
|
938
984
|
return from && near ? this.#throughStar(candidates, from, name, near) : undefined;
|
|
@@ -970,13 +1016,13 @@ ${name}`, guard);
|
|
|
970
1016
|
const visible = isBase ? undefined : declared.find((other) => this.visible(other.owner, site.owner));
|
|
971
1017
|
return visible ? { guard: visible } : { name, from };
|
|
972
1018
|
}
|
|
973
|
-
const reexport = from && depth < maxMapDepth ? this
|
|
1019
|
+
const reexport = from && depth < maxMapDepth ? this.#reexportOf(from, name, near) : null;
|
|
974
1020
|
if (reexport)
|
|
975
1021
|
return this.#findGuard(reexport.local, reexport.site, depth + 1, isBase);
|
|
976
1022
|
const reached = from && near ? this.#throughStar(declared, from, name, near) : undefined;
|
|
977
1023
|
return reached ? { guard: reached } : { name, from };
|
|
978
1024
|
}
|
|
979
|
-
reexportOf(owner, name, near) {
|
|
1025
|
+
#reexportOf(owner, name, near) {
|
|
980
1026
|
const key = `${owner}
|
|
981
1027
|
${name}
|
|
982
1028
|
${near ?? ""}`;
|
|
@@ -1133,20 +1179,24 @@ ${near}`;
|
|
|
1133
1179
|
return cached;
|
|
1134
1180
|
const found = { owners: [], packages: [], paths: [near], isOpaque: false };
|
|
1135
1181
|
this.#starExports.set(key, found);
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1182
|
+
const reach = (specifier, path, target) => {
|
|
1183
|
+
if (path === null && !found.packages.includes(specifier))
|
|
1184
|
+
found.packages.push(specifier);
|
|
1185
|
+
if (target === undefined || target === frameworkOwner || path === null)
|
|
1186
|
+
found.isOpaque = true;
|
|
1187
|
+
else if (!found.paths.includes(path))
|
|
1188
|
+
found.paths.push(path);
|
|
1189
|
+
if (target && target !== frameworkOwner && target !== owner && !found.owners.includes(target))
|
|
1190
|
+
found.owners.push(target);
|
|
1191
|
+
};
|
|
1192
|
+
for (let idx = 0;idx < found.paths.length; idx++) {
|
|
1193
|
+
const path = found.paths[idx] ?? "";
|
|
1194
|
+
for (const module of this.#barrelAt(path) ?? [])
|
|
1195
|
+
reach(module, module, ownerOf(module) ?? undefined);
|
|
1196
|
+
for (const fileName of this.#modulesAt(path))
|
|
1197
|
+
for (const [, specifier = ""] of this.#source.readText(fileName)?.matchAll(starExportPattern) ?? [])
|
|
1198
|
+
reach(specifier, this.pathOfSpecifier(fileName, specifier), this.ownerOfSpecifier(fileName, specifier));
|
|
1199
|
+
}
|
|
1150
1200
|
return found;
|
|
1151
1201
|
}
|
|
1152
1202
|
exportsAt(path, name) {
|
|
@@ -1155,27 +1205,78 @@ ${name}`;
|
|
|
1155
1205
|
const cached = this.#moduleExports.get(key);
|
|
1156
1206
|
if (cached)
|
|
1157
1207
|
return cached;
|
|
1158
|
-
const found = { named: null, stars: [] };
|
|
1159
|
-
const
|
|
1208
|
+
const found = { named: null, stars: [], isLocal: false };
|
|
1209
|
+
const stars = new Set(this.#barrelAt(path));
|
|
1160
1210
|
for (const fileName of this.#modulesAt(path)) {
|
|
1161
1211
|
const text = this.#source.readText(fileName);
|
|
1162
1212
|
if (text === undefined)
|
|
1163
1213
|
continue;
|
|
1164
|
-
const named = identifierPattern.test(name) &&
|
|
1214
|
+
const named = text.includes(name) && identifierPattern.test(name) && exportingPatternOf(name).test(text) ? this.#reexportIn(this.#source.parse(fileName, text), name) : null;
|
|
1165
1215
|
if (named) {
|
|
1166
1216
|
found.named = { ...named, fileName };
|
|
1167
|
-
found.stars = [];
|
|
1168
1217
|
break;
|
|
1169
1218
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
found.stars.push(target);
|
|
1219
|
+
if (text.includes(name) && exportMentioningPatternOf(name).test(text) && this.#exportsLocally(this.#source.parse(fileName, text), name)) {
|
|
1220
|
+
found.isLocal = true;
|
|
1221
|
+
break;
|
|
1174
1222
|
}
|
|
1223
|
+
for (const target of this.#starsIn(fileName, text))
|
|
1224
|
+
stars.add(target);
|
|
1175
1225
|
}
|
|
1226
|
+
if (!found.named && !found.isLocal)
|
|
1227
|
+
found.stars = [...stars];
|
|
1176
1228
|
this.#moduleExports.set(key, found);
|
|
1177
1229
|
return found;
|
|
1178
1230
|
}
|
|
1231
|
+
#exportsLocally(source, name) {
|
|
1232
|
+
const { ts } = this.#source;
|
|
1233
|
+
const binds = (node) => ts.isIdentifier(node) ? node.text === name : node.elements.some((element) => !ts.isOmittedExpression(element) && binds(element.name));
|
|
1234
|
+
return source.statements.some((statement) => {
|
|
1235
|
+
if (ts.isExportDeclaration(statement))
|
|
1236
|
+
return !statement.moduleSpecifier && !statement.isTypeOnly && !!statement.exportClause && ts.isNamedExports(statement.exportClause) && statement.exportClause.elements.some((element) => !element.isTypeOnly && element.name.text === name);
|
|
1237
|
+
const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) ?? [] : [];
|
|
1238
|
+
if (!modifiers.some(({ kind }) => kind === ts.SyntaxKind.ExportKeyword) || modifiers.some(({ kind }) => kind === ts.SyntaxKind.DefaultKeyword))
|
|
1239
|
+
return false;
|
|
1240
|
+
if (ts.isVariableStatement(statement))
|
|
1241
|
+
return statement.declarationList.declarations.some((declaration) => binds(declaration.name));
|
|
1242
|
+
return (ts.isClassDeclaration(statement) || ts.isFunctionDeclaration(statement) || ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement) || ts.isImportEqualsDeclaration(statement)) && !!statement.name && ts.isIdentifier(statement.name) && statement.name.text === name;
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
mentionsAlong(path, name) {
|
|
1246
|
+
return this.#starReachOf(path).some((text) => text.includes(name));
|
|
1247
|
+
}
|
|
1248
|
+
#starReachOf(path) {
|
|
1249
|
+
const cached = this.#starReach.get(path);
|
|
1250
|
+
if (cached)
|
|
1251
|
+
return cached;
|
|
1252
|
+
const paths = new Set([path]);
|
|
1253
|
+
const texts = [];
|
|
1254
|
+
for (const at of paths) {
|
|
1255
|
+
for (const next of this.#barrelAt(at) ?? [])
|
|
1256
|
+
paths.add(next);
|
|
1257
|
+
for (const fileName of this.#modulesAt(at)) {
|
|
1258
|
+
const text = this.#source.readText(fileName) ?? "";
|
|
1259
|
+
texts.push(text);
|
|
1260
|
+
for (const next of this.#starsIn(fileName, text))
|
|
1261
|
+
paths.add(next);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
this.#starReach.set(path, texts);
|
|
1265
|
+
return texts;
|
|
1266
|
+
}
|
|
1267
|
+
#starsIn(fileName, text) {
|
|
1268
|
+
const cached = this.#fileStars.get(fileName);
|
|
1269
|
+
if (cached)
|
|
1270
|
+
return cached;
|
|
1271
|
+
const found = [];
|
|
1272
|
+
for (const [, specifier = ""] of text.matchAll(starExportPattern)) {
|
|
1273
|
+
const target = this.pathOfSpecifier(fileName, specifier);
|
|
1274
|
+
if (target !== null)
|
|
1275
|
+
found.push(target);
|
|
1276
|
+
}
|
|
1277
|
+
this.#fileStars.set(fileName, found);
|
|
1278
|
+
return found;
|
|
1279
|
+
}
|
|
1179
1280
|
#modulesAt(path) {
|
|
1180
1281
|
if (!this.#modules) {
|
|
1181
1282
|
this.#modules = new Map;
|
|
@@ -1187,21 +1288,23 @@ ${name}`;
|
|
|
1187
1288
|
}
|
|
1188
1289
|
return this.#modules.get(path) ?? [];
|
|
1189
1290
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1291
|
+
#barrelAt(path) {
|
|
1292
|
+
if (!this.#barrels) {
|
|
1293
|
+
const entries = new Map;
|
|
1294
|
+
for (const [fileName] of this.#source.files) {
|
|
1295
|
+
const [, folder, facet, entry, nested] = this.#source.relative(fileName).match(facetEntryPattern) ?? [];
|
|
1296
|
+
if (!folder || !facet || !entry)
|
|
1297
|
+
continue;
|
|
1298
|
+
const found = entries.get(folder) ?? { facet, files: new Set, dirs: new Set };
|
|
1299
|
+
(nested ? found.dirs : found.files).add(entry);
|
|
1300
|
+
entries.set(folder, found);
|
|
1301
|
+
}
|
|
1302
|
+
this.#barrels = new Map([...entries].map(([folder, { facet, files, dirs }]) => [
|
|
1303
|
+
folder,
|
|
1304
|
+
facetBarrelNamesOf(facet, [...files], [...dirs]).map((name) => `${folder}/${name}`)
|
|
1305
|
+
]));
|
|
1203
1306
|
}
|
|
1204
|
-
return
|
|
1307
|
+
return this.#modulesAt(path).length ? undefined : this.#barrels.get(path);
|
|
1205
1308
|
}
|
|
1206
1309
|
declares(owner, name) {
|
|
1207
1310
|
const declaring = declaringPatternOf(name, true);
|
|
@@ -1262,7 +1365,12 @@ export
|
|
|
1262
1365
|
}
|
|
1263
1366
|
|
|
1264
1367
|
// pkgs/@akanjs/language/adaptorResolver.ts
|
|
1265
|
-
var
|
|
1368
|
+
var packageOf = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
|
|
1369
|
+
var packageKeyOf = ({ name, from }) => `${packageOf(from)}
|
|
1370
|
+
${name}`;
|
|
1371
|
+
var exportedKeyOf = (item) => ("fact" in item) ? item.id : ("local" in item) ? `${item.local}
|
|
1372
|
+
` : packageKeyOf(item);
|
|
1373
|
+
var isPackageExport = (item) => ("from" in item);
|
|
1266
1374
|
|
|
1267
1375
|
class AdaptorResolver {
|
|
1268
1376
|
#source;
|
|
@@ -1271,6 +1379,7 @@ class AdaptorResolver {
|
|
|
1271
1379
|
#adaptors = new Map;
|
|
1272
1380
|
#plugs = new Map;
|
|
1273
1381
|
#serviceFields = new Set;
|
|
1382
|
+
#exported = new Map;
|
|
1274
1383
|
constructor(source, resolver, sink) {
|
|
1275
1384
|
this.#source = source;
|
|
1276
1385
|
this.#resolver = resolver;
|
|
@@ -1353,52 +1462,85 @@ ${field}`))
|
|
|
1353
1462
|
return own.find((adaptor) => adaptor.fileName === fileName) ?? first;
|
|
1354
1463
|
if (own.length === 1)
|
|
1355
1464
|
return first;
|
|
1356
|
-
|
|
1357
|
-
return own.find((adaptor) => this.#source.relative(adaptor.fileName).startsWith(`${path}/`)) ?? first;
|
|
1358
|
-
const exported = this.#exportedAt(name, path, new Set).filter((item) => first || ("fact" in item));
|
|
1465
|
+
const exported = this.#exportedAt(name, path).filter((item) => first || !isPackageExport(item));
|
|
1359
1466
|
const [only] = exported;
|
|
1360
1467
|
if (only)
|
|
1361
|
-
return exported.length === 1 ? only : null;
|
|
1468
|
+
return exported.length === 1 && !("local" in only) ? only : null;
|
|
1362
1469
|
return first ? null : undefined;
|
|
1363
1470
|
}
|
|
1364
|
-
#exportedAt(name, path
|
|
1471
|
+
#exportedAt(name, path) {
|
|
1365
1472
|
const key = `${path}
|
|
1366
1473
|
${name}`;
|
|
1367
|
-
|
|
1474
|
+
const cached = this.#exported.get(key);
|
|
1475
|
+
if (cached)
|
|
1476
|
+
return cached;
|
|
1477
|
+
if (!this.#resolver.mentionsAlong(path, name)) {
|
|
1478
|
+
this.#exported.set(key, []);
|
|
1368
1479
|
return [];
|
|
1369
|
-
|
|
1370
|
-
const
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1480
|
+
}
|
|
1481
|
+
const reached = new Map;
|
|
1482
|
+
const seen = new Set;
|
|
1483
|
+
const pending = [[name, path]];
|
|
1484
|
+
for (let next = pending.pop();next; next = pending.pop()) {
|
|
1485
|
+
const [wanted, at] = next;
|
|
1486
|
+
if (seen.has(`${at}
|
|
1487
|
+
${wanted}`))
|
|
1488
|
+
continue;
|
|
1489
|
+
seen.add(`${at}
|
|
1490
|
+
${wanted}`);
|
|
1491
|
+
for (const item of this.#bindingAt(wanted, at, pending))
|
|
1492
|
+
reached.set(exportedKeyOf(item), item);
|
|
1493
|
+
}
|
|
1494
|
+
const found = [...reached.values()];
|
|
1495
|
+
this.#exported.set(key, found);
|
|
1496
|
+
return found;
|
|
1497
|
+
}
|
|
1498
|
+
#bindingAt(name, path, pending) {
|
|
1499
|
+
const here = this.#declaredAt(name, path);
|
|
1374
1500
|
if (here.length)
|
|
1375
1501
|
return here;
|
|
1376
|
-
const { named, stars } = this.#resolver.exportsAt(path, name);
|
|
1377
|
-
if (
|
|
1378
|
-
return [{
|
|
1502
|
+
const { named, stars, isLocal } = this.#resolver.exportsAt(path, name);
|
|
1503
|
+
if (isLocal)
|
|
1504
|
+
return [{ local: path }];
|
|
1505
|
+
if (named?.from === null) {
|
|
1506
|
+
const local = this.#declaredAt(named.name, path);
|
|
1507
|
+
return local.length ? local : [{ local: path }];
|
|
1508
|
+
}
|
|
1379
1509
|
if (named) {
|
|
1380
|
-
const target =
|
|
1381
|
-
|
|
1510
|
+
const target = this.#resolver.pathOfSpecifier(named.fileName, named.from);
|
|
1511
|
+
if (target === null)
|
|
1512
|
+
return [{ name: named.name === "default" ? name : named.name, from: named.from }];
|
|
1513
|
+
pending.push([named.name, target]);
|
|
1514
|
+
return [];
|
|
1382
1515
|
}
|
|
1383
|
-
|
|
1516
|
+
for (const star of stars)
|
|
1517
|
+
pending.push([name, star]);
|
|
1518
|
+
return [];
|
|
1519
|
+
}
|
|
1520
|
+
#declaredAt(name, path) {
|
|
1521
|
+
return (this.#adaptors.get(name) ?? []).filter((adaptor) => {
|
|
1522
|
+
const module = this.#source.relative(adaptor.fileName).replace(/\.tsx?$/, "");
|
|
1523
|
+
return module === path || module === `${path}/index`;
|
|
1524
|
+
});
|
|
1384
1525
|
}
|
|
1385
1526
|
#packageAdaptorOf(name, specifier) {
|
|
1386
1527
|
if (frameworkPattern.test(specifier))
|
|
1387
1528
|
return this.#sink.addNode(this.#sink.key("adaptor", null, name), "adaptor", null, name, null, [frameworkOwner]).id;
|
|
1388
|
-
const pkg =
|
|
1529
|
+
const pkg = packageOf(specifier);
|
|
1389
1530
|
return this.#sink.addNode(this.#sink.key("adaptor", pkg, name), "adaptor", null, name, null, [pkg]).id;
|
|
1390
1531
|
}
|
|
1391
1532
|
#packageShimOf(owner, name, near) {
|
|
1392
|
-
|
|
1393
|
-
const [shim] = reexport?.site.imports ?? [];
|
|
1394
|
-
if (reexport && shim && this.#resolver.pathOfSpecifier(reexport.site.fileName, shim.from) === null)
|
|
1395
|
-
return { name: reexport.local === "default" ? name : reexport.local, from: shim.from };
|
|
1396
|
-
if (reexport || !near)
|
|
1533
|
+
if (!near)
|
|
1397
1534
|
return null;
|
|
1398
|
-
const
|
|
1535
|
+
const shims = this.#exportedAt(name, near).filter(isPackageExport);
|
|
1536
|
+
const [shim] = shims;
|
|
1537
|
+
if (shim)
|
|
1538
|
+
return shims.length === 1 ? shim : null;
|
|
1539
|
+
const { packages, paths } = this.#resolver.starExportsOf(owner, near);
|
|
1399
1540
|
const [only] = packages;
|
|
1400
|
-
|
|
1401
|
-
|
|
1541
|
+
if (!only || new Set(packages.map(packageOf)).size !== 1)
|
|
1542
|
+
return null;
|
|
1543
|
+
return paths.some((path) => this.#resolver.declaresAt(path, name)) ? null : { name, from: only };
|
|
1402
1544
|
}
|
|
1403
1545
|
#nodeOf({ fact, owner, fileName, id }) {
|
|
1404
1546
|
const detail = fact.refName ? [fact.refName] : [];
|
|
@@ -758,4 +758,4 @@ class CodeTuiParts2 {
|
|
|
758
758
|
}
|
|
759
759
|
}
|
|
760
760
|
|
|
761
|
-
export {
|
|
761
|
+
export { CodeTuiCommands2, CodeTuiLines2, CodeTuiEditor2, CodeTuiAgents2, CodeTuiMarkdown2, CodeTuiParts2, CodeTuiClipboard2, CodeTuiFiles2 };
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runner,
|
|
4
4
|
script
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-sh3yzse2.js";
|
|
6
6
|
import {
|
|
7
|
-
|
|
7
|
+
bilingualLabelForField,
|
|
8
|
+
bilingualDescriptionForField,
|
|
8
9
|
moduleSourcePaths,
|
|
10
|
+
sourceFile,
|
|
9
11
|
generatedFilesForSync,
|
|
10
|
-
createPassedPrimitiveReport
|
|
11
|
-
|
|
12
|
-
bilingualDescriptionForField
|
|
13
|
-
} from "./index-669sg3yp.js";
|
|
12
|
+
createPassedPrimitiveReport
|
|
13
|
+
} from "./index-ean2tff1.js";
|
|
14
14
|
import {
|
|
15
15
|
PageScript
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-a05ewnnp.js";
|
|
17
17
|
import {
|
|
18
18
|
pluralizeName
|
|
19
19
|
} from "./index-nz8prx9g.js";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./index-va90m8nd.js";
|
|
23
23
|
import {
|
|
24
24
|
ModuleExecutor
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-4zqebbqb.js";
|
|
26
26
|
|
|
27
27
|
// pkgs/@akanjs/cli/module/module.script.ts
|
|
28
28
|
import { capitalize as capitalize2 } from "akanjs/common";
|