layermap 0.1.28 → 0.1.30
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 +2 -2
- package/analyzers/project-map-java/java-map.jar +0 -0
- package/analyzers/project-map-worker.mjs +187 -57
- package/dist/cli.mjs +63 -14
- package/package.json +1 -1
- package/pi/layermap.mjs +1 -1
package/README.md
CHANGED
|
@@ -30,8 +30,8 @@ with dozens of searches:
|
|
|
30
30
|
It maps **TypeScript, JavaScript, Go, Python and Java** with each language's own compiler, so calls
|
|
31
31
|
through interfaces, base classes, templates and decorators resolve as the compiler resolves them,
|
|
32
32
|
including the ones text search misses. In WeChat mini-programs, it also links each page's and
|
|
33
|
-
component's template (`.wxml`) to the methods it binds and the components it shows,
|
|
34
|
-
the pages.
|
|
33
|
+
component's template (`.wxml`) to the methods it binds and the components it shows, and each event a
|
|
34
|
+
component emits to the handlers the pages bind to it, so callers reach the pages.
|
|
35
35
|
|
|
36
36
|
## Example
|
|
37
37
|
|
|
Binary file
|
|
@@ -16069,32 +16069,81 @@ var propertyName = (member) => {
|
|
|
16069
16069
|
const name = member.name;
|
|
16070
16070
|
return name && (isIdentifier(name) || isStringLiteral(name)) ? name.text : void 0;
|
|
16071
16071
|
};
|
|
16072
|
-
function
|
|
16072
|
+
function registration(file2) {
|
|
16073
16073
|
for (const statement of file2.statements) {
|
|
16074
16074
|
if (!isExpressionStatement(statement)) continue;
|
|
16075
16075
|
const call = statement.expression;
|
|
16076
16076
|
if (!isCallExpression(call) || !isIdentifier(call.expression)) continue;
|
|
16077
|
-
const
|
|
16077
|
+
const kind = call.expression.text;
|
|
16078
16078
|
const options = call.arguments[0];
|
|
16079
|
-
if (
|
|
16080
|
-
|
|
16081
|
-
let members = options.properties;
|
|
16082
|
-
if (registration === "Component") {
|
|
16083
|
-
const methods = options.properties.find((member) => propertyName(member) === "methods");
|
|
16084
|
-
const value = methods && isPropertyAssignment(methods) ? methods.initializer : void 0;
|
|
16085
|
-
members = value && isObjectLiteralExpression(value) ? value.properties : [];
|
|
16086
|
-
}
|
|
16087
|
-
const found = /* @__PURE__ */ new Map();
|
|
16088
|
-
for (const member of members) {
|
|
16089
|
-
const name = propertyName(member);
|
|
16090
|
-
if (name !== void 0 && (isMethodDeclaration(member) || isPropertyAssignment(member)))
|
|
16091
|
-
found.set(name, member);
|
|
16092
|
-
}
|
|
16093
|
-
return found;
|
|
16079
|
+
if ((kind === "Page" || kind === "Component") && options && isObjectLiteralExpression(options))
|
|
16080
|
+
return { kind, options };
|
|
16094
16081
|
}
|
|
16095
16082
|
return void 0;
|
|
16096
16083
|
}
|
|
16084
|
+
function miniprogramMethods(file2) {
|
|
16085
|
+
const registered = registration(file2);
|
|
16086
|
+
if (!registered) return void 0;
|
|
16087
|
+
const { kind, options } = registered;
|
|
16088
|
+
let members = options.properties;
|
|
16089
|
+
if (kind === "Component") {
|
|
16090
|
+
const methods = options.properties.find((member) => propertyName(member) === "methods");
|
|
16091
|
+
const value = methods && isPropertyAssignment(methods) ? methods.initializer : void 0;
|
|
16092
|
+
members = value && isObjectLiteralExpression(value) ? value.properties : [];
|
|
16093
|
+
}
|
|
16094
|
+
const found = /* @__PURE__ */ new Map();
|
|
16095
|
+
for (const member of members) {
|
|
16096
|
+
const name = propertyName(member);
|
|
16097
|
+
if (name !== void 0 && (isMethodDeclaration(member) || isPropertyAssignment(member)))
|
|
16098
|
+
found.set(name, member);
|
|
16099
|
+
}
|
|
16100
|
+
return found;
|
|
16101
|
+
}
|
|
16102
|
+
var composedEvent = (options) => {
|
|
16103
|
+
if (!options) return false;
|
|
16104
|
+
if (!isObjectLiteralExpression(options)) return true;
|
|
16105
|
+
const composed = options.properties.find(
|
|
16106
|
+
(member) => propertyName(member) === "composed"
|
|
16107
|
+
);
|
|
16108
|
+
if (!composed) return false;
|
|
16109
|
+
return !(isPropertyAssignment(composed) && composed.initializer.kind === SyntaxKind.FalseKeyword);
|
|
16110
|
+
};
|
|
16111
|
+
function miniprogramEmits(file2) {
|
|
16112
|
+
const registered = registration(file2);
|
|
16113
|
+
if (registered?.kind !== "Component" || registered.options.properties.some((member) => propertyName(member) === "behaviors"))
|
|
16114
|
+
return void 0;
|
|
16115
|
+
const emits = [];
|
|
16116
|
+
let readable = true;
|
|
16117
|
+
const visit = (node) => {
|
|
16118
|
+
if (isCallExpression(node) && isPropertyAccessExpression(node.expression) && node.expression.name.text === "triggerEvent") {
|
|
16119
|
+
const [name, , options] = node.arguments;
|
|
16120
|
+
if (node.expression.expression.kind !== SyntaxKind.ThisKeyword || !name || node.arguments.some((argument) => argument.kind === SyntaxKind.SpreadElement))
|
|
16121
|
+
readable = false;
|
|
16122
|
+
else emits.push({ call: node, name, composed: composedEvent(options) });
|
|
16123
|
+
}
|
|
16124
|
+
node.forEachChild(visit);
|
|
16125
|
+
return void 0;
|
|
16126
|
+
};
|
|
16127
|
+
visit(file2);
|
|
16128
|
+
return readable ? emits : void 0;
|
|
16129
|
+
}
|
|
16130
|
+
var miniprogramEventTarget = (tag, event) => `<${tag}> ${event} event`;
|
|
16131
|
+
var NATIVE_EVENTS = /* @__PURE__ */ new Set([
|
|
16132
|
+
"touchstart",
|
|
16133
|
+
"touchmove",
|
|
16134
|
+
"touchcancel",
|
|
16135
|
+
"touchend",
|
|
16136
|
+
"touchforcechange",
|
|
16137
|
+
"tap",
|
|
16138
|
+
"longpress",
|
|
16139
|
+
"longtap",
|
|
16140
|
+
"transitionend",
|
|
16141
|
+
"animationstart",
|
|
16142
|
+
"animationiteration",
|
|
16143
|
+
"animationend"
|
|
16144
|
+
]);
|
|
16097
16145
|
var BINDING = /^(?:(?:capture-)?(?:bind|catch)|mut-bind):?[a-z][\w-]*$/iu;
|
|
16146
|
+
var BINDING_PREFIX = /^(?:(?:capture-)?(?:bind|catch)|mut-bind):?/iu;
|
|
16098
16147
|
var METHOD = /^[A-Za-z_$][\w$]*$/u;
|
|
16099
16148
|
var TAG = /<([A-Za-z][\w.:-]*)/uy;
|
|
16100
16149
|
var ATTRIBUTE = /\s*([^\s"'=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>]+)))?/uy;
|
|
@@ -16137,12 +16186,19 @@ function parseMiniprogramTemplate(text2) {
|
|
|
16137
16186
|
}
|
|
16138
16187
|
at = ATTRIBUTE.lastIndex;
|
|
16139
16188
|
const value = attribute[2] ?? attribute[3] ?? attribute[4];
|
|
16140
|
-
|
|
16189
|
+
const attributeName = attribute[1] ?? "";
|
|
16190
|
+
if (value === void 0 || !BINDING.test(attributeName)) continue;
|
|
16141
16191
|
const end = at - (attribute[4] === void 0 ? 1 : 0);
|
|
16142
16192
|
const start = end - value.length;
|
|
16143
16193
|
const method = value.trim();
|
|
16144
|
-
|
|
16145
|
-
|
|
16194
|
+
const binding = {
|
|
16195
|
+
event: attributeName.replace(BINDING_PREFIX, ""),
|
|
16196
|
+
tag: tags.length - 1,
|
|
16197
|
+
start,
|
|
16198
|
+
end
|
|
16199
|
+
};
|
|
16200
|
+
if (METHOD.test(method)) bindings.push({ ...binding, method });
|
|
16201
|
+
else if (method.includes("{{")) bindings.push(binding);
|
|
16146
16202
|
}
|
|
16147
16203
|
index = text2[at] === ">" ? at + 1 : at + 2;
|
|
16148
16204
|
if (name === "wxs" && text2[at] === ">") index = skip(index, "</wxs>");
|
|
@@ -16200,28 +16256,65 @@ function linkMiniprogramTemplates(scripts, context) {
|
|
|
16200
16256
|
links.objects.push(object2);
|
|
16201
16257
|
return object2;
|
|
16202
16258
|
};
|
|
16203
|
-
const owned = scripts.flatMap((
|
|
16204
|
-
const object2 = module2(template, "DEFAULT");
|
|
16205
|
-
return object2 ? [{
|
|
16259
|
+
const owned = scripts.flatMap((script) => {
|
|
16260
|
+
const object2 = module2(script.template, "DEFAULT");
|
|
16261
|
+
return object2 ? [{ ...script, object: object2 }] : [];
|
|
16206
16262
|
});
|
|
16263
|
+
const events = new Map(owned.map((script) => [script.template, script.events]));
|
|
16264
|
+
const emitted = /* @__PURE__ */ new Set();
|
|
16207
16265
|
for (const { template, methods, object: object2 } of owned) {
|
|
16208
16266
|
links.parsedFiles.push(template);
|
|
16209
16267
|
const parsed = parseMiniprogramTemplate(context.read(template) ?? "");
|
|
16268
|
+
const registered = /* @__PURE__ */ new Map();
|
|
16269
|
+
if (parsed.tags.length) {
|
|
16270
|
+
const { own, app, root } = miniprogramConfiguration(template, context.inventory);
|
|
16271
|
+
for (const file2 of [app, own])
|
|
16272
|
+
if (file2 !== void 0)
|
|
16273
|
+
for (const [tag, value] of Object.entries(usingComponents(context.read(file2))))
|
|
16274
|
+
registered.set(tag, componentTemplate(value, file2, root, context.inventory));
|
|
16275
|
+
}
|
|
16210
16276
|
let computed = 0;
|
|
16211
16277
|
for (const binding of parsed.bindings) {
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
continue;
|
|
16215
|
-
}
|
|
16216
|
-
const method = methods.get(binding.method);
|
|
16278
|
+
const anchor = context.span(template, binding.start, binding.end);
|
|
16279
|
+
const method = binding.method === void 0 ? void 0 : methods.get(binding.method);
|
|
16217
16280
|
const target = method && context.materialize(method);
|
|
16218
|
-
|
|
16219
|
-
|
|
16220
|
-
|
|
16221
|
-
|
|
16222
|
-
|
|
16223
|
-
|
|
16224
|
-
|
|
16281
|
+
if (binding.method === void 0) computed++;
|
|
16282
|
+
else
|
|
16283
|
+
links.relations.push({
|
|
16284
|
+
from: object2.id,
|
|
16285
|
+
kind: "CALLS",
|
|
16286
|
+
anchor,
|
|
16287
|
+
target: binding.method,
|
|
16288
|
+
...target ? { to: target.id, basis: "SYNTAX_DECLARED" } : { basis: "UNRESOLVED", unresolvedReason: "SYMBOL_NOT_RESOLVED" }
|
|
16289
|
+
});
|
|
16290
|
+
const tag = parsed.tags[binding.tag]?.name;
|
|
16291
|
+
const component = tag === void 0 ? void 0 : registered.get(tag);
|
|
16292
|
+
const known = component === void 0 ? void 0 : events.get(component);
|
|
16293
|
+
if (tag === void 0 || !known) continue;
|
|
16294
|
+
const emits = known.get(binding.event);
|
|
16295
|
+
if (emits) {
|
|
16296
|
+
for (const emit of emits) {
|
|
16297
|
+
const link = `${emit.emitter.id}\0${target?.id}\0${emit.anchor.start}`;
|
|
16298
|
+
if (!target || emitted.has(link)) continue;
|
|
16299
|
+
emitted.add(link);
|
|
16300
|
+
links.relations.push({
|
|
16301
|
+
from: emit.emitter.id,
|
|
16302
|
+
to: target.id,
|
|
16303
|
+
kind: "CALLS",
|
|
16304
|
+
anchor: emit.anchor,
|
|
16305
|
+
target: target.name,
|
|
16306
|
+
basis: "SYNTAX_DECLARED"
|
|
16307
|
+
});
|
|
16308
|
+
}
|
|
16309
|
+
} else if (!NATIVE_EVENTS.has(binding.event) && context.composed && !context.composed.has(binding.event))
|
|
16310
|
+
links.relations.push({
|
|
16311
|
+
from: object2.id,
|
|
16312
|
+
kind: "CALLS",
|
|
16313
|
+
anchor,
|
|
16314
|
+
target: miniprogramEventTarget(tag, binding.event),
|
|
16315
|
+
basis: "UNRESOLVED",
|
|
16316
|
+
unresolvedReason: "SYMBOL_NOT_RESOLVED"
|
|
16317
|
+
});
|
|
16225
16318
|
}
|
|
16226
16319
|
if (computed)
|
|
16227
16320
|
links.gaps.push({
|
|
@@ -16229,13 +16322,6 @@ function linkMiniprogramTemplates(scripts, context) {
|
|
|
16229
16322
|
path: template,
|
|
16230
16323
|
count: computed
|
|
16231
16324
|
});
|
|
16232
|
-
if (!parsed.tags.length) continue;
|
|
16233
|
-
const { own, app, root } = miniprogramConfiguration(template, context.inventory);
|
|
16234
|
-
const registered = /* @__PURE__ */ new Map();
|
|
16235
|
-
for (const file2 of [app, own])
|
|
16236
|
-
if (file2 !== void 0)
|
|
16237
|
-
for (const [tag, value] of Object.entries(usingComponents(context.read(file2))))
|
|
16238
|
-
registered.set(tag, componentTemplate(value, file2, root, context.inventory));
|
|
16239
16325
|
for (const tag of parsed.tags) {
|
|
16240
16326
|
if (!registered.has(tag.name)) continue;
|
|
16241
16327
|
const component = registered.get(tag.name);
|
|
@@ -16404,9 +16490,9 @@ var httpMethod = (name) => HTTP_METHODS.has(name.toUpperCase()) ? name.toUpperCa
|
|
|
16404
16490
|
function registeredRoute(node, kind) {
|
|
16405
16491
|
for (let child = node, parent = node.parent; parent; child = parent, parent = parent.parent) {
|
|
16406
16492
|
if (isCallExpression(parent) && parent.arguments.includes(child)) {
|
|
16407
|
-
const
|
|
16408
|
-
const direct = child === node && (kind === "REFERENCES" ||
|
|
16409
|
-
if (
|
|
16493
|
+
const registration2 = routeOf(parent, parent.arguments.indexOf(child));
|
|
16494
|
+
const direct = child === node && (kind === "REFERENCES" || registration2?.method);
|
|
16495
|
+
if (registration2 && (isFunction(child) || direct)) return registration2.label;
|
|
16410
16496
|
}
|
|
16411
16497
|
if (isDeclaration(parent)) return void 0;
|
|
16412
16498
|
}
|
|
@@ -31692,19 +31778,63 @@ async function extractProjectMap(project, input, trace, read) {
|
|
|
31692
31778
|
return object2;
|
|
31693
31779
|
};
|
|
31694
31780
|
trace.phase = "MINIPROGRAM_TEMPLATES";
|
|
31695
|
-
const
|
|
31696
|
-
|
|
31697
|
-
|
|
31698
|
-
|
|
31699
|
-
|
|
31700
|
-
|
|
31701
|
-
|
|
31702
|
-
inventory,
|
|
31703
|
-
read,
|
|
31704
|
-
span: (path8, start, end) => positions.span(path8, start, end),
|
|
31705
|
-
materialize
|
|
31781
|
+
const enclosing = (node) => {
|
|
31782
|
+
for (let at = node.parent; at; at = at.parent) {
|
|
31783
|
+
if (at.kind === SyntaxKind.SourceFile) return declared.get(key(at));
|
|
31784
|
+
if (declared.has(key(at)) || mapDeclarationKind(at) && mapDeclarationName(at) || mapExecutionDeclaration(at)) {
|
|
31785
|
+
const object2 = materialize(at);
|
|
31786
|
+
if (object2) return object2;
|
|
31787
|
+
}
|
|
31706
31788
|
}
|
|
31707
|
-
|
|
31789
|
+
return void 0;
|
|
31790
|
+
};
|
|
31791
|
+
const scripts = pages.flatMap(({ file: file2, template }) => {
|
|
31792
|
+
const methods = miniprogramMethods(file2);
|
|
31793
|
+
return methods ? [{ file: file2, template, methods, emits: miniprogramEmits(file2) }] : [];
|
|
31794
|
+
});
|
|
31795
|
+
const emits = scripts.flatMap((script) => script.emits ?? []);
|
|
31796
|
+
const nameTypes = emits.length ? await project.checker.getTypeAtLocation(emits.map((emit) => emit.name)) : [];
|
|
31797
|
+
const names = /* @__PURE__ */ new Map();
|
|
31798
|
+
for (const [index, emit] of emits.entries()) {
|
|
31799
|
+
const type = nameTypes[index];
|
|
31800
|
+
const types = type?.isUnionType() ? await type.getTypes() ?? [] : type ? [type] : [];
|
|
31801
|
+
names.set(
|
|
31802
|
+
emit,
|
|
31803
|
+
types.length && types.every((each) => each.isStringLiteralType()) ? types.map((each) => each.value) : void 0
|
|
31804
|
+
);
|
|
31805
|
+
}
|
|
31806
|
+
let composed = /* @__PURE__ */ new Set();
|
|
31807
|
+
const linked = scripts.map(({ file: file2, template, methods, emits: calls }) => {
|
|
31808
|
+
if (!calls) return { template, methods };
|
|
31809
|
+
const events = /* @__PURE__ */ new Map();
|
|
31810
|
+
let readable = true;
|
|
31811
|
+
for (const emit of calls) {
|
|
31812
|
+
const emitted = names.get(emit);
|
|
31813
|
+
const emitter = enclosing(emit.call);
|
|
31814
|
+
if (!emitted || !emitter) {
|
|
31815
|
+
if (emit.composed) composed = void 0;
|
|
31816
|
+
readable = false;
|
|
31817
|
+
continue;
|
|
31818
|
+
}
|
|
31819
|
+
for (const event of emitted) {
|
|
31820
|
+
if (emit.composed) composed?.add(event);
|
|
31821
|
+
const known = events.get(event) ?? [];
|
|
31822
|
+
known.push({ emitter, anchor: anchor(emit.call, file2) });
|
|
31823
|
+
events.set(event, known);
|
|
31824
|
+
}
|
|
31825
|
+
}
|
|
31826
|
+
if (readable) return { template, methods, events };
|
|
31827
|
+
gap("MINIPROGRAM_COMPUTED_EVENT_NAMES", mapRelativePath(file2.fileName));
|
|
31828
|
+
return { template, methods };
|
|
31829
|
+
});
|
|
31830
|
+
const templates = linkMiniprogramTemplates(linked, {
|
|
31831
|
+
contextRef: input.contextRef,
|
|
31832
|
+
inventory,
|
|
31833
|
+
read,
|
|
31834
|
+
span: (path8, start, end) => positions.span(path8, start, end),
|
|
31835
|
+
materialize,
|
|
31836
|
+
composed
|
|
31837
|
+
});
|
|
31708
31838
|
for (const object2 of templates.objects) collect.object(object2);
|
|
31709
31839
|
for (const relation of templates.relations) collect.relation(relation);
|
|
31710
31840
|
output.gaps.push(...templates.gaps);
|
package/dist/cli.mjs
CHANGED
|
@@ -18786,8 +18786,10 @@ import {
|
|
|
18786
18786
|
isIdentifier,
|
|
18787
18787
|
isMethodDeclaration,
|
|
18788
18788
|
isObjectLiteralExpression,
|
|
18789
|
+
isPropertyAccessExpression,
|
|
18789
18790
|
isPropertyAssignment,
|
|
18790
|
-
isStringLiteral
|
|
18791
|
+
isStringLiteral,
|
|
18792
|
+
SyntaxKind
|
|
18791
18793
|
} from "typescript/unstable/ast";
|
|
18792
18794
|
var mapMiniprogramTemplate = (file2) => file2.endsWith(".wxml");
|
|
18793
18795
|
var templateOf = (script) => script.replace(/\.[cm]?[jt]sx?$/u, ".wxml");
|
|
@@ -18802,10 +18804,14 @@ function miniprogramConfiguration(template, inventory) {
|
|
|
18802
18804
|
if (!root) return configuration;
|
|
18803
18805
|
}
|
|
18804
18806
|
}
|
|
18807
|
+
var miniprogramEventOf = (target) => {
|
|
18808
|
+
const match = /^<([^>]+)> (\S+) event$/u.exec(target);
|
|
18809
|
+
return match?.[1] && match[2] ? { tag: match[1], event: match[2] } : void 0;
|
|
18810
|
+
};
|
|
18805
18811
|
|
|
18806
18812
|
// src/project-map-language-typescript.ts
|
|
18807
18813
|
var TYPESCRIPT_MAP_LANGUAGE = Object.freeze({
|
|
18808
|
-
id: "typescript-7.0.2-map-
|
|
18814
|
+
id: "typescript-7.0.2-map-v20",
|
|
18809
18815
|
claims: (path15) => /\.[cm]?[jt]sx?$/u.test(path15),
|
|
18810
18816
|
reads: (path15) => path15.endsWith(".json") || path15.endsWith(".wxml") || path15 === "pnpm-workspace.yaml",
|
|
18811
18817
|
create: () => new TypeScriptMapAnalyzer()
|
|
@@ -23050,6 +23056,7 @@ var Tracer = class {
|
|
|
23050
23056
|
var mapRunnableTest = (file2) => /_test\.(?:go|py)$|(?:^|\/)test_[^/]*\.py$|\.(?:test|spec)\.[cm]?[jt]sx?$|(?:Test|Tests|IT)\.(?:java|kt)$/u.test(
|
|
23051
23057
|
file2
|
|
23052
23058
|
);
|
|
23059
|
+
var renamedTemplate = (file2) => file2.status === "RENAMED" && file2.basePath !== void 0 && mapMiniprogramTemplate(file2.basePath);
|
|
23053
23060
|
function mapChangeImpact(store, working, base, changes, project) {
|
|
23054
23061
|
const graph = new MapViewGraph(store, working);
|
|
23055
23062
|
const cache = new MapViewCache();
|
|
@@ -23058,6 +23065,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23058
23065
|
const unclear = [];
|
|
23059
23066
|
const removed = [];
|
|
23060
23067
|
const declarations2 = (g, path15) => g.objectsAt(path15).filter((object2) => !mapIsModule(object2) && g.isAddressable(object2));
|
|
23068
|
+
const units = (g, path15) => mapMiniprogramTemplate(path15) ? g.objectsAt(path15).filter((object2) => mapIsModule(object2) && object2.parsing === "PARSED") : declarations2(g, path15);
|
|
23061
23069
|
let changedCount = 0;
|
|
23062
23070
|
const starts = [];
|
|
23063
23071
|
const importers = /* @__PURE__ */ new Map();
|
|
@@ -23082,7 +23090,7 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23082
23090
|
if (!objects2.length) continue;
|
|
23083
23091
|
const hits = /* @__PURE__ */ new Set();
|
|
23084
23092
|
let topLevel = false;
|
|
23085
|
-
const inFile =
|
|
23093
|
+
const inFile = units(graph, file2.path);
|
|
23086
23094
|
for (const [from, to] of file2.lines) {
|
|
23087
23095
|
const containing = inFile.filter(
|
|
23088
23096
|
(object2) => object2.anchor.startLine <= to && from <= object2.anchor.endLine
|
|
@@ -23150,21 +23158,22 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23150
23158
|
const now = graph.objectsAt(file2?.path ?? relation.anchor.path).find((object2) => same2(graph, object2.id) === name);
|
|
23151
23159
|
if (!now || relation.to === void 0) return true;
|
|
23152
23160
|
const used = same2(before, relation.to);
|
|
23161
|
+
const tag = mapIsModule(before.object(relation.to));
|
|
23153
23162
|
return !graph.relationsFrom(graph.scope(now.id).refs).some(
|
|
23154
|
-
(use) => NAMING_KINDS.has(use.kind) && use.to !== void 0 && same2(graph, use.to) === used
|
|
23163
|
+
(use) => NAMING_KINDS.has(use.kind) && use.to !== void 0 && (tag ? use.target === relation.target : same2(graph, use.to) === used)
|
|
23155
23164
|
);
|
|
23156
23165
|
};
|
|
23157
23166
|
const gone = [];
|
|
23158
23167
|
for (const file2 of changes.files) {
|
|
23159
|
-
if (!file2.basePath ||
|
|
23160
|
-
|
|
23168
|
+
if (!file2.basePath || file2.binary || testCode(file2.basePath)) continue;
|
|
23169
|
+
const renamed = renamedTemplate(file2);
|
|
23170
|
+
if (!file2.baseLines.length && !renamed) continue;
|
|
23161
23171
|
const now = new Set(
|
|
23162
|
-
file2.status === "DELETED" ? [] :
|
|
23163
|
-
(o) => `${o.kind}\0${graph.qualifiedName(o.id)}`
|
|
23164
|
-
)
|
|
23172
|
+
file2.status === "DELETED" ? [] : units(graph, file2.path).map((o) => `${o.kind}\0${graph.qualifiedName(o.id)}`)
|
|
23165
23173
|
);
|
|
23166
|
-
for (const object2 of
|
|
23167
|
-
if (!overlaps(file2.baseLines, object2.anchor.startLine, object2.anchor.endLine))
|
|
23174
|
+
for (const object2 of units(before, file2.basePath)) {
|
|
23175
|
+
if (!renamed && !overlaps(file2.baseLines, object2.anchor.startLine, object2.anchor.endLine))
|
|
23176
|
+
continue;
|
|
23168
23177
|
if (now.has(`${object2.kind}\0${before.qualifiedName(object2.id)}`)) continue;
|
|
23169
23178
|
const parent = before.parent(object2.id);
|
|
23170
23179
|
if (parent && !mapIsModule(before.object(parent)) && gone.includes(parent)) continue;
|
|
@@ -23183,15 +23192,55 @@ function mapChangeImpact(store, working, base, changes, project) {
|
|
|
23183
23192
|
continue;
|
|
23184
23193
|
const user = before.object(owner);
|
|
23185
23194
|
usedBy.add(
|
|
23186
|
-
`${user.anchor.path}
|
|
23195
|
+
mapIsModule(user) ? `${user.anchor.path}${mapMiniprogramTemplate(user.anchor.path) ? " (template)" : ": top-level code"}` : `${user.anchor.path}: ${before.qualifiedName(owner)}`
|
|
23187
23196
|
);
|
|
23188
23197
|
}
|
|
23189
23198
|
removed.push({
|
|
23190
|
-
declaration: `${file2.basePath}: ${before.qualifiedName(object2.id)} ${mapDeclarationLabel(object2)}`,
|
|
23199
|
+
declaration: mapIsModule(object2) ? `${file2.basePath} (template)` : `${file2.basePath}: ${before.qualifiedName(object2.id)} ${mapDeclarationLabel(object2)}`,
|
|
23191
23200
|
usedBy: [...usedBy].sort()
|
|
23192
23201
|
});
|
|
23193
23202
|
}
|
|
23194
23203
|
}
|
|
23204
|
+
const removedAt = (ref) => {
|
|
23205
|
+
for (let at = ref; at !== void 0; at = before.parent(at))
|
|
23206
|
+
if (gone.includes(at)) return true;
|
|
23207
|
+
return false;
|
|
23208
|
+
};
|
|
23209
|
+
const lost = /* @__PURE__ */ new Map();
|
|
23210
|
+
const changedAt = new Map(changes.files.map((file2) => [file2.path, file2]));
|
|
23211
|
+
for (const path15 of mappedPaths().filter(mapMiniprogramTemplate)) {
|
|
23212
|
+
const template = graph.objectsAt(path15).find((object2) => mapIsModule(object2));
|
|
23213
|
+
if (!template) continue;
|
|
23214
|
+
const broken = graph.relationsFrom(graph.scope(template.id).refs).filter((relation) => relation.to === void 0 && NAMING_KINDS.has(relation.kind));
|
|
23215
|
+
if (!broken.length) continue;
|
|
23216
|
+
const file2 = changedAt.get(path15);
|
|
23217
|
+
const basePath = file2 ? file2.basePath : path15;
|
|
23218
|
+
const was = basePath === void 0 ? void 0 : before.objectsAt(basePath).find(mapIsModule);
|
|
23219
|
+
const links = was ? before.relationsFrom(before.scope(was.id).refs) : [];
|
|
23220
|
+
for (const relation of broken) {
|
|
23221
|
+
const earlier = links.filter(
|
|
23222
|
+
(link) => link.kind === relation.kind && link.target === relation.target
|
|
23223
|
+
);
|
|
23224
|
+
if (earlier.some((link) => link.to === void 0)) continue;
|
|
23225
|
+
const event = miniprogramEventOf(relation.target);
|
|
23226
|
+
const at = `${path15}:${relation.anchor.startLine}`;
|
|
23227
|
+
if (file2 && overlaps(file2.lines, relation.anchor.startLine, relation.anchor.endLine)) {
|
|
23228
|
+
unclear.push(
|
|
23229
|
+
event ? `${at} binds the ${event.event} event of <${event.tag}>, which it does not emit` : relation.kind === "REFERENCES" ? `${at} puts <${relation.target}>, which its registration does not find` : `${at} binds ${relation.target}, which its page or component does not register`
|
|
23230
|
+
);
|
|
23231
|
+
continue;
|
|
23232
|
+
}
|
|
23233
|
+
const reached = event ? links.find((link) => link.kind === "REFERENCES" && link.target === event.tag)?.to : earlier.find((link) => link.to !== void 0)?.to;
|
|
23234
|
+
if (reached === void 0 || removedAt(reached)) continue;
|
|
23235
|
+
const object2 = before.object(reached);
|
|
23236
|
+
const name = mapIsModule(object2) ? `${object2.anchor.path} (template)${event ? `: ${event.event} event` : ""}` : `${object2.anchor.path}: ${before.qualifiedName(reached)} ${mapDeclarationLabel(object2)}`;
|
|
23237
|
+
const users = lost.get(name) ?? /* @__PURE__ */ new Set();
|
|
23238
|
+
users.add(`${path15} (template)`);
|
|
23239
|
+
lost.set(name, users);
|
|
23240
|
+
}
|
|
23241
|
+
}
|
|
23242
|
+
for (const [declaration, users] of lost)
|
|
23243
|
+
removed.push({ declaration, usedBy: [...users].sort() });
|
|
23195
23244
|
for (const file2 of changes.files) {
|
|
23196
23245
|
if (!file2.basePath || file2.status === "DELETED" || testCode(file2.basePath)) continue;
|
|
23197
23246
|
const module = before.objectsAt(file2.basePath).find(mapIsModule);
|
|
@@ -23446,7 +23495,7 @@ async function checkMapChanges(input, signal) {
|
|
|
23446
23495
|
const changes = await readMapChanges(project, input.base, signal);
|
|
23447
23496
|
await index.ensureIndex(working, signal);
|
|
23448
23497
|
const base = changes.files.some(
|
|
23449
|
-
(file2) => file2.basePath !== void 0 && (file2.baseLines.length || file2.baseText !== void 0)
|
|
23498
|
+
(file2) => file2.basePath !== void 0 && (file2.baseLines.length || file2.baseText !== void 0 || renamedTemplate(file2))
|
|
23450
23499
|
) ? await input.baseVersion(changes.commit, signal) : void 0;
|
|
23451
23500
|
const impact = mapChangeImpact(index.store, working, base, changes, project);
|
|
23452
23501
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layermap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"mcpName": "io.github.coffeecoproject/layermap",
|
|
5
5
|
"description": "A layered map of a codebase for coding agents: directories, modules and call chains across TypeScript, JavaScript, Go, Python and Java.",
|
|
6
6
|
"license": "Apache-2.0",
|
package/pi/layermap.mjs
CHANGED
|
@@ -268,7 +268,7 @@ function layermap(pi) {
|
|
|
268
268
|
if (server && !server.dead) return server;
|
|
269
269
|
starting ??= (async () => {
|
|
270
270
|
const next = new MapServer(cwd);
|
|
271
|
-
const tools = await next.start("0.1.
|
|
271
|
+
const tools = await next.start("0.1.30");
|
|
272
272
|
for (const tool of tools) {
|
|
273
273
|
if (registered.has(tool.name)) continue;
|
|
274
274
|
registered.add(tool.name);
|