easyeda-mcp-pro 0.32.0 → 0.34.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.
Files changed (197) hide show
  1. package/README.md +8 -6
  2. package/dist/bridge/protocol.d.ts +1 -1
  3. package/dist/bridge/types.d.ts +1 -0
  4. package/dist/bridge/types.js +1 -0
  5. package/dist/bridge/types.js.map +1 -1
  6. package/dist/circuit/circuit-ir.d.ts +15 -2
  7. package/dist/circuit/circuit-ir.js +2 -0
  8. package/dist/circuit/circuit-ir.js.map +1 -1
  9. package/dist/circuit/compiler.js +1 -0
  10. package/dist/circuit/compiler.js.map +1 -1
  11. package/dist/circuit/design-intent.d.ts +13 -0
  12. package/dist/circuit/design-intent.js +2 -0
  13. package/dist/circuit/design-intent.js.map +1 -1
  14. package/dist/circuit/index.d.ts +2 -0
  15. package/dist/circuit/index.js +2 -0
  16. package/dist/circuit/index.js.map +1 -1
  17. package/dist/circuit/reference-design.d.ts +16 -0
  18. package/dist/circuit/reference-design.js +16 -0
  19. package/dist/circuit/reference-design.js.map +1 -0
  20. package/dist/config/env.js +10 -4
  21. package/dist/config/env.js.map +1 -1
  22. package/dist/config/profiles.js +4 -4
  23. package/dist/config/version.d.ts +1 -1
  24. package/dist/config/version.js +1 -1
  25. package/dist/index.js +4 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/layout/autofix.d.ts +93 -0
  28. package/dist/layout/autofix.js +376 -0
  29. package/dist/layout/autofix.js.map +1 -0
  30. package/dist/layout/block-detector.d.ts +3 -0
  31. package/dist/layout/block-detector.js +252 -0
  32. package/dist/layout/block-detector.js.map +1 -0
  33. package/dist/layout/geometry.d.ts +20 -0
  34. package/dist/layout/geometry.js +150 -0
  35. package/dist/layout/geometry.js.map +1 -0
  36. package/dist/layout/graph.d.ts +5 -0
  37. package/dist/layout/graph.js +185 -0
  38. package/dist/layout/graph.js.map +1 -0
  39. package/dist/layout/index.d.ts +8 -0
  40. package/dist/layout/index.js +9 -0
  41. package/dist/layout/index.js.map +1 -0
  42. package/dist/layout/operations.d.ts +7 -0
  43. package/dist/layout/operations.js +170 -0
  44. package/dist/layout/operations.js.map +1 -0
  45. package/dist/layout/placement.d.ts +79 -0
  46. package/dist/layout/placement.js +248 -0
  47. package/dist/layout/placement.js.map +1 -0
  48. package/dist/layout/planner.d.ts +98 -0
  49. package/dist/layout/planner.js +338 -0
  50. package/dist/layout/planner.js.map +1 -0
  51. package/dist/layout/types.d.ts +281 -0
  52. package/dist/layout/types.js +2 -0
  53. package/dist/layout/types.js.map +1 -0
  54. package/dist/live/readback.d.ts +16 -0
  55. package/dist/live/readback.js +38 -0
  56. package/dist/live/readback.js.map +1 -0
  57. package/dist/professional-layout-templates/catalog.v1.d.ts +390 -0
  58. package/dist/professional-layout-templates/catalog.v1.js +460 -0
  59. package/dist/professional-layout-templates/catalog.v1.js.map +1 -0
  60. package/dist/professional-layout-templates/index.d.ts +14 -0
  61. package/dist/professional-layout-templates/index.js +118 -0
  62. package/dist/professional-layout-templates/index.js.map +1 -0
  63. package/dist/professional-layout-templates/types.d.ts +74 -0
  64. package/dist/professional-layout-templates/types.js +2 -0
  65. package/dist/professional-layout-templates/types.js.map +1 -0
  66. package/dist/remote/approval-policy.d.ts +9 -0
  67. package/dist/remote/approval-policy.js +30 -2
  68. package/dist/remote/approval-policy.js.map +1 -1
  69. package/dist/remote/gateway.d.ts +45 -9
  70. package/dist/remote/gateway.js +360 -37
  71. package/dist/remote/gateway.js.map +1 -1
  72. package/dist/remote/session-dispatch-queue.d.ts +5 -0
  73. package/dist/remote/session-dispatch-queue.js +25 -0
  74. package/dist/remote/session-dispatch-queue.js.map +1 -0
  75. package/dist/router/astar.d.ts +23 -0
  76. package/dist/router/astar.js +177 -0
  77. package/dist/router/astar.js.map +1 -0
  78. package/dist/router/geometry.d.ts +39 -0
  79. package/dist/router/geometry.js +240 -0
  80. package/dist/router/geometry.js.map +1 -0
  81. package/dist/router/grid.d.ts +24 -0
  82. package/dist/router/grid.js +50 -0
  83. package/dist/router/grid.js.map +1 -0
  84. package/dist/router/obstacles.d.ts +33 -0
  85. package/dist/router/obstacles.js +243 -0
  86. package/dist/router/obstacles.js.map +1 -0
  87. package/dist/router/path-simplifier.d.ts +6 -0
  88. package/dist/router/path-simplifier.js +35 -0
  89. package/dist/router/path-simplifier.js.map +1 -0
  90. package/dist/router/pin-escape.d.ts +24 -0
  91. package/dist/router/pin-escape.js +155 -0
  92. package/dist/router/pin-escape.js.map +1 -0
  93. package/dist/router/route-cost.d.ts +10 -0
  94. package/dist/router/route-cost.js +82 -0
  95. package/dist/router/route-cost.js.map +1 -0
  96. package/dist/router/types.d.ts +187 -0
  97. package/dist/router/types.js +2 -0
  98. package/dist/router/types.js.map +1 -0
  99. package/dist/schematic-engine/errors.d.ts +22 -0
  100. package/dist/schematic-engine/errors.js +83 -0
  101. package/dist/schematic-engine/errors.js.map +1 -0
  102. package/dist/schematic-engine/geometry.d.ts +33 -0
  103. package/dist/schematic-engine/geometry.js +49 -0
  104. package/dist/schematic-engine/geometry.js.map +1 -0
  105. package/dist/schematic-engine/index.d.ts +2 -0
  106. package/dist/schematic-engine/index.js +3 -0
  107. package/dist/schematic-engine/index.js.map +1 -0
  108. package/dist/schematic-model/connectivity-fingerprint.d.ts +60 -0
  109. package/dist/schematic-model/connectivity-fingerprint.js +117 -0
  110. package/dist/schematic-model/connectivity-fingerprint.js.map +1 -0
  111. package/dist/schematic-model/geometry-model.d.ts +329 -0
  112. package/dist/schematic-model/geometry-model.js +8 -0
  113. package/dist/schematic-model/geometry-model.js.map +1 -0
  114. package/dist/schematic-model/geometry-net-names.d.ts +23 -0
  115. package/dist/schematic-model/geometry-net-names.js +166 -0
  116. package/dist/schematic-model/geometry-net-names.js.map +1 -0
  117. package/dist/schematic-model/geometry-normalize.d.ts +18 -0
  118. package/dist/schematic-model/geometry-normalize.js +281 -0
  119. package/dist/schematic-model/geometry-normalize.js.map +1 -0
  120. package/dist/schematic-model/imported-symbols.d.ts +13 -0
  121. package/dist/schematic-model/imported-symbols.js +155 -0
  122. package/dist/schematic-model/imported-symbols.js.map +1 -0
  123. package/dist/schematic-model/live-functional-layout.d.ts +45 -0
  124. package/dist/schematic-model/live-functional-layout.js +109 -0
  125. package/dist/schematic-model/live-functional-layout.js.map +1 -0
  126. package/dist/schematic-model/live-layout-autofix.d.ts +59 -0
  127. package/dist/schematic-model/live-layout-autofix.js +132 -0
  128. package/dist/schematic-model/live-layout-autofix.js.map +1 -0
  129. package/dist/schematic-model/live-placement-check.d.ts +32 -0
  130. package/dist/schematic-model/live-placement-check.js +56 -0
  131. package/dist/schematic-model/live-placement-check.js.map +1 -0
  132. package/dist/schematic-model/live-primitive-bounds.d.ts +18 -0
  133. package/dist/schematic-model/live-primitive-bounds.js +83 -0
  134. package/dist/schematic-model/live-primitive-bounds.js.map +1 -0
  135. package/dist/schematic-model/live-snapshot.d.ts +16 -0
  136. package/dist/schematic-model/live-snapshot.js +99 -0
  137. package/dist/schematic-model/live-snapshot.js.map +1 -0
  138. package/dist/schematic-model/model-builder.d.ts +7 -0
  139. package/dist/schematic-model/model-builder.js +429 -0
  140. package/dist/schematic-model/model-builder.js.map +1 -0
  141. package/dist/schematic-model/model-validator.d.ts +8 -0
  142. package/dist/schematic-model/model-validator.js +180 -0
  143. package/dist/schematic-model/model-validator.js.map +1 -0
  144. package/dist/schematic-model/pin-semantics.d.ts +17 -0
  145. package/dist/schematic-model/pin-semantics.js +70 -0
  146. package/dist/schematic-model/pin-semantics.js.map +1 -0
  147. package/dist/schematic-model/primitive-bounds.d.ts +69 -0
  148. package/dist/schematic-model/primitive-bounds.js +141 -0
  149. package/dist/schematic-model/primitive-bounds.js.map +1 -0
  150. package/dist/server/factory.d.ts +1 -0
  151. package/dist/server/factory.js +42 -20
  152. package/dist/server/factory.js.map +1 -1
  153. package/dist/server/transports/http.d.ts +3 -0
  154. package/dist/server/transports/http.js +136 -7
  155. package/dist/server/transports/http.js.map +1 -1
  156. package/dist/tools/L1_bom_core.js +3 -2
  157. package/dist/tools/L1_bom_core.js.map +1 -1
  158. package/dist/tools/L1_schematic_read.js +29 -4
  159. package/dist/tools/L1_schematic_read.js.map +1 -1
  160. package/dist/tools/L1_visual.js +146 -0
  161. package/dist/tools/L1_visual.js.map +1 -1
  162. package/dist/tools/L2_schematic_layout.d.ts +141 -0
  163. package/dist/tools/L2_schematic_layout.js +1155 -0
  164. package/dist/tools/L2_schematic_layout.js.map +1 -0
  165. package/dist/tools/L2_workflows.js +301 -10
  166. package/dist/tools/L2_workflows.js.map +1 -1
  167. package/dist/tools/register.js +2 -0
  168. package/dist/tools/register.js.map +1 -1
  169. package/dist/tools/registry.d.ts +1 -1
  170. package/dist/tools/registry.js +92 -30
  171. package/dist/tools/registry.js.map +1 -1
  172. package/dist/transactions/operation-log.d.ts +32 -0
  173. package/dist/transactions/operation-log.js +58 -0
  174. package/dist/transactions/operation-log.js.map +1 -0
  175. package/dist/workflows/index.d.ts +1 -1
  176. package/dist/workflows/led-blinker-template.d.ts +131 -0
  177. package/dist/workflows/led-blinker-template.js +212 -0
  178. package/dist/workflows/led-blinker-template.js.map +1 -0
  179. package/dist/workflows/ne555-astable-template.js +2 -2
  180. package/dist/workflows/ne555-astable-template.js.map +1 -1
  181. package/dist/workflows/ne555-wire-stubs.d.ts +17 -0
  182. package/dist/workflows/ne555-wire-stubs.js +114 -31
  183. package/dist/workflows/ne555-wire-stubs.js.map +1 -1
  184. package/dist/workflows/planner.js +58 -8
  185. package/dist/workflows/planner.js.map +1 -1
  186. package/dist/workflows/rp2040-servo-module-scaffold.d.ts +22 -1
  187. package/dist/workflows/rp2040-servo-module-scaffold.js +218 -77
  188. package/dist/workflows/rp2040-servo-module-scaffold.js.map +1 -1
  189. package/dist/workflows/schematic-layout-qa.d.ts +177 -0
  190. package/dist/workflows/schematic-layout-qa.js +727 -0
  191. package/dist/workflows/schematic-layout-qa.js.map +1 -0
  192. package/dist/workflows/types.d.ts +50 -0
  193. package/dist/workflows/wire-stub-generator.d.ts +104 -0
  194. package/dist/workflows/wire-stub-generator.js +105 -0
  195. package/dist/workflows/wire-stub-generator.js.map +1 -0
  196. package/easyeda-bridge-extension.eext +0 -0
  197. package/package.json +1 -1
@@ -0,0 +1,93 @@
1
+ import { type SchematicBounds, type SchematicPoint, type SchematicSheetGeometry } from '../schematic-engine/geometry.js';
2
+ import { type ConnectivityFingerprint, type ConnectivityFingerprintDiff } from '../schematic-model/connectivity-fingerprint.js';
3
+ import { type StableReadOptions } from '../live/readback.js';
4
+ import { type SchematicOperation } from '../transactions/operation-log.js';
5
+ import { type TransactionBridgeCaller } from '../transactions/easyeda.js';
6
+ import type { TransactionManager } from '../transactions/manager.js';
7
+ import type { TransactionRecord } from '../transactions/model.js';
8
+ import { type PlacementConstraintRegion } from './placement.js';
9
+ export type AutofixPrimitiveType = 'component' | 'text' | 'label' | 'annotation' | 'section-box' | 'section-title' | 'wire' | 'power-symbol' | 'no-connect';
10
+ export type AutofixCosmeticProperty = 'position' | 'bounds';
11
+ export interface LayoutAutofixPrimitive {
12
+ id: string;
13
+ primitiveType: AutofixPrimitiveType;
14
+ origin: SchematicPoint;
15
+ combinedBounds: SchematicBounds;
16
+ sectionId?: string;
17
+ locked?: boolean;
18
+ }
19
+ export type LayoutAutofixViolationCode = 'TITLE_BLOCK_OVERLAP' | 'PAGE_BOUNDARY_OVERFLOW' | 'COMPONENT_OVERLAP' | 'TEXT_OVERLAP' | 'SECTION_BOX_TOO_SMALL';
20
+ export interface LayoutAutofixViolation {
21
+ id: string;
22
+ code: LayoutAutofixViolationCode;
23
+ primitiveIds: string[];
24
+ message: string;
25
+ }
26
+ export interface LayoutAutofixAllowlist {
27
+ primitiveTypes: readonly AutofixPrimitiveType[];
28
+ properties: readonly AutofixCosmeticProperty[];
29
+ }
30
+ export interface LayoutAutofixMove {
31
+ id: string;
32
+ primitiveId: string;
33
+ primitiveType: AutofixPrimitiveType;
34
+ property: AutofixCosmeticProperty;
35
+ from: SchematicPoint | SchematicBounds;
36
+ to: SchematicPoint | SchematicBounds;
37
+ reason: string;
38
+ expectedQaImprovement: string;
39
+ resolvesViolationIds: string[];
40
+ }
41
+ export interface LayoutAutofixPreviewInput {
42
+ sheet: SchematicSheetGeometry;
43
+ primitives: readonly LayoutAutofixPrimitive[];
44
+ allowlist: LayoutAutofixAllowlist;
45
+ hardKeepouts?: readonly PlacementConstraintRegion[];
46
+ callerReservedRegions?: readonly PlacementConstraintRegion[];
47
+ minimumClearance?: number;
48
+ maxMoves?: number;
49
+ }
50
+ export interface LayoutAutofixReport {
51
+ fixed: string[];
52
+ skipped: Array<{
53
+ violationId: string;
54
+ reason: string;
55
+ }>;
56
+ remaining: string[];
57
+ }
58
+ export interface LayoutAutofixPreview {
59
+ mode: 'preview';
60
+ requiresConfirmWrite: true;
61
+ violations: LayoutAutofixViolation[];
62
+ moves: LayoutAutofixMove[];
63
+ report: LayoutAutofixReport;
64
+ allowlist: LayoutAutofixAllowlist;
65
+ }
66
+ export interface ApplyLayoutAutofixOptions {
67
+ confirmWrite: boolean;
68
+ documentId: string;
69
+ transactionManager: TransactionManager;
70
+ bridge: TransactionBridgeCaller;
71
+ readConnectivity: () => Promise<ConnectivityFingerprint>;
72
+ operationFactory?: (move: LayoutAutofixMove, index: number) => SchematicOperation;
73
+ batchSize?: number;
74
+ stableRead?: StableReadOptions<ConnectivityFingerprint>;
75
+ }
76
+ export interface LayoutAutofixApplyResult {
77
+ applied: boolean;
78
+ transaction?: TransactionRecord;
79
+ preview: LayoutAutofixPreview;
80
+ beforeFingerprint?: ConnectivityFingerprint;
81
+ afterFingerprint?: ConnectivityFingerprint;
82
+ connectivityDiff?: ConnectivityFingerprintDiff;
83
+ batchesVerified: number;
84
+ actualStateReadAfterFailure: boolean;
85
+ report: LayoutAutofixReport;
86
+ }
87
+ export declare class LayoutAutofixConnectivityError extends Error {
88
+ readonly result: LayoutAutofixApplyResult;
89
+ constructor(message: string, result: LayoutAutofixApplyResult);
90
+ }
91
+ export declare function previewLayoutAutofix(input: LayoutAutofixPreviewInput): LayoutAutofixPreview;
92
+ export declare function applyLayoutAutofix(preview: LayoutAutofixPreview, options: ApplyLayoutAutofixOptions): Promise<LayoutAutofixApplyResult>;
93
+ export declare function applyPreviewMovesToGeometry(primitives: readonly LayoutAutofixPrimitive[], preview: LayoutAutofixPreview): LayoutAutofixPrimitive[];
@@ -0,0 +1,376 @@
1
+ import { boundsInside, boundsOverlap, combineBounds, inflateBounds, translateBounds, } from '../schematic-engine/geometry.js';
2
+ import { compareConnectivityFingerprints, } from '../schematic-model/connectivity-fingerprint.js';
3
+ import { readStable } from '../live/readback.js';
4
+ import { operationId } from '../transactions/operation-log.js';
5
+ import { getPrimitiveSnapshot, rollbackEasyedaTransaction, } from '../transactions/easyeda.js';
6
+ import { checkPlacement } from './placement.js';
7
+ export class LayoutAutofixConnectivityError extends Error {
8
+ result;
9
+ constructor(message, result) {
10
+ super(message);
11
+ this.result = result;
12
+ this.name = 'LayoutAutofixConnectivityError';
13
+ }
14
+ }
15
+ const TEXT_TYPES = new Set(['text', 'label', 'annotation', 'section-title']);
16
+ const ELECTRICAL_TYPES = new Set(['wire', 'power-symbol', 'no-connect']);
17
+ function violation(code, primitiveIds, message) {
18
+ const sortedIds = [...primitiveIds].sort((a, b) => a.localeCompare(b));
19
+ return { id: `${code}:${sortedIds.join(':')}`, code, primitiveIds: sortedIds, message };
20
+ }
21
+ function detectViolations(input) {
22
+ const result = [];
23
+ const ordered = [...input.primitives].sort((a, b) => a.id.localeCompare(b.id));
24
+ for (const primitive of ordered) {
25
+ if (!boundsInside(primitive.combinedBounds, input.sheet.drawableBounds)) {
26
+ result.push(violation('PAGE_BOUNDARY_OVERFLOW', [primitive.id], `Primitive "${primitive.id}" extends beyond drawable sheet bounds.`));
27
+ }
28
+ if (input.sheet.titleBlockBounds &&
29
+ boundsOverlap(primitive.combinedBounds, input.sheet.titleBlockBounds)) {
30
+ result.push(violation('TITLE_BLOCK_OVERLAP', [primitive.id], `Primitive "${primitive.id}" intersects the title block.`));
31
+ }
32
+ }
33
+ for (let leftIndex = 0; leftIndex < ordered.length; leftIndex += 1) {
34
+ const left = ordered[leftIndex];
35
+ if (!left || left.primitiveType === 'section-box')
36
+ continue;
37
+ for (let rightIndex = leftIndex + 1; rightIndex < ordered.length; rightIndex += 1) {
38
+ const right = ordered[rightIndex];
39
+ if (!right || right.primitiveType === 'section-box')
40
+ continue;
41
+ if (!boundsOverlap(left.combinedBounds, right.combinedBounds))
42
+ continue;
43
+ const isText = TEXT_TYPES.has(left.primitiveType) || TEXT_TYPES.has(right.primitiveType);
44
+ result.push(violation(isText ? 'TEXT_OVERLAP' : 'COMPONENT_OVERLAP', [left.id, right.id], `Primitives "${left.id}" and "${right.id}" overlap.`));
45
+ }
46
+ }
47
+ for (const sectionBox of ordered.filter((item) => item.primitiveType === 'section-box')) {
48
+ const children = ordered.filter((item) => item.sectionId === sectionBox.sectionId && item.id !== sectionBox.id);
49
+ const childBounds = combineBounds(children.map((child) => child.combinedBounds));
50
+ if (childBounds && !boundsInside(childBounds, sectionBox.combinedBounds)) {
51
+ result.push(violation('SECTION_BOX_TOO_SMALL', [sectionBox.id, ...children.map((child) => child.id)], `Section box "${sectionBox.id}" does not enclose all section content.`));
52
+ }
53
+ }
54
+ return result.sort((a, b) => a.id.localeCompare(b.id));
55
+ }
56
+ function propertyAllowed(primitive, property, allowlist) {
57
+ if (primitive.locked || ELECTRICAL_TYPES.has(primitive.primitiveType))
58
+ return false;
59
+ if (!allowlist.primitiveTypes.includes(primitive.primitiveType))
60
+ return false;
61
+ if (!allowlist.properties.includes(property))
62
+ return false;
63
+ if (property === 'bounds')
64
+ return primitive.primitiveType === 'section-box';
65
+ return primitive.primitiveType !== 'section-box';
66
+ }
67
+ function primitiveRegions(primitives, excludedIds) {
68
+ return primitives
69
+ .filter((primitive) => !excludedIds.has(primitive.id))
70
+ .map((primitive) => ({
71
+ id: `primitive:${primitive.id}`,
72
+ kind: 'existing-object',
73
+ primitiveId: primitive.id,
74
+ bounds: primitive.combinedBounds,
75
+ }));
76
+ }
77
+ function moveForViolation(input, target, issue) {
78
+ const check = checkPlacement({
79
+ sheet: input.sheet,
80
+ candidate: {
81
+ origin: target.origin,
82
+ rotation: 0,
83
+ combinedBounds: target.combinedBounds,
84
+ },
85
+ hardKeepouts: input.hardKeepouts,
86
+ reservedRegions: input.callerReservedRegions,
87
+ occupiedRegions: primitiveRegions(input.primitives, new Set([target.id])),
88
+ minimumClearance: input.minimumClearance,
89
+ maxAlternatives: 1,
90
+ searchPreference: 'upper-left',
91
+ });
92
+ const alternative = check.suggestedAlternatives[0];
93
+ if (!alternative)
94
+ return undefined;
95
+ return {
96
+ id: `autofix:${issue.id}:${target.id}`,
97
+ primitiveId: target.id,
98
+ primitiveType: target.primitiveType,
99
+ property: 'position',
100
+ from: target.origin,
101
+ to: alternative.origin,
102
+ reason: issue.message,
103
+ expectedQaImprovement: `Resolve ${issue.code} while preserving rendered clearance constraints.`,
104
+ resolvesViolationIds: [issue.id],
105
+ };
106
+ }
107
+ function resizeSectionBox(input, target, issue) {
108
+ const children = input.primitives.filter((item) => item.sectionId === target.sectionId && item.id !== target.id);
109
+ const childBounds = combineBounds(children.map((child) => child.combinedBounds));
110
+ if (!childBounds)
111
+ return undefined;
112
+ const proposed = inflateBounds(childBounds, Math.max(0, input.minimumClearance ?? input.sheet.grid));
113
+ if (!boundsInside(proposed, input.sheet.drawableBounds))
114
+ return undefined;
115
+ if (input.sheet.titleBlockBounds && boundsOverlap(proposed, input.sheet.titleBlockBounds))
116
+ return undefined;
117
+ return {
118
+ id: `autofix:${issue.id}:${target.id}`,
119
+ primitiveId: target.id,
120
+ primitiveType: target.primitiveType,
121
+ property: 'bounds',
122
+ from: target.combinedBounds,
123
+ to: proposed,
124
+ reason: issue.message,
125
+ expectedQaImprovement: 'Resize the cosmetic section box to enclose its section content.',
126
+ resolvesViolationIds: [issue.id],
127
+ };
128
+ }
129
+ function moveTarget(issue, primitives, allowlist) {
130
+ const candidates = issue.primitiveIds
131
+ .map((id) => primitives.get(id))
132
+ .filter((item) => item !== undefined)
133
+ .filter((item) => propertyAllowed(item, 'position', allowlist));
134
+ return candidates.sort((a, b) => {
135
+ const aText = TEXT_TYPES.has(a.primitiveType) ? 0 : 1;
136
+ const bText = TEXT_TYPES.has(b.primitiveType) ? 0 : 1;
137
+ return aText - bText || b.id.localeCompare(a.id);
138
+ })[0];
139
+ }
140
+ export function previewLayoutAutofix(input) {
141
+ const violations = detectViolations(input);
142
+ const byId = new Map(input.primitives.map((primitive) => [primitive.id, primitive]));
143
+ const moves = [];
144
+ const skipped = [];
145
+ const maxMoves = Math.max(0, input.maxMoves ?? 100);
146
+ const movedIds = new Set();
147
+ for (const issue of violations) {
148
+ if (moves.length >= maxMoves) {
149
+ skipped.push({
150
+ violationId: issue.id,
151
+ reason: 'The configured autofix move limit was reached.',
152
+ });
153
+ continue;
154
+ }
155
+ const sectionBox = issue.code === 'SECTION_BOX_TOO_SMALL'
156
+ ? issue.primitiveIds
157
+ .map((id) => byId.get(id))
158
+ .find((item) => item?.primitiveType === 'section-box')
159
+ : undefined;
160
+ let move;
161
+ if (sectionBox && propertyAllowed(sectionBox, 'bounds', input.allowlist)) {
162
+ move = resizeSectionBox(input, sectionBox, issue);
163
+ }
164
+ else {
165
+ const target = moveTarget(issue, byId, input.allowlist);
166
+ if (target && !movedIds.has(target.id))
167
+ move = moveForViolation(input, target, issue);
168
+ }
169
+ if (move) {
170
+ moves.push(move);
171
+ movedIds.add(move.primitiveId);
172
+ }
173
+ else {
174
+ skipped.push({
175
+ violationId: issue.id,
176
+ reason: 'No explicitly allowed cosmetic change can resolve this violation safely.',
177
+ });
178
+ }
179
+ }
180
+ const proposed = new Set(moves.flatMap((move) => move.resolvesViolationIds));
181
+ return {
182
+ mode: 'preview',
183
+ requiresConfirmWrite: true,
184
+ violations,
185
+ moves,
186
+ report: {
187
+ fixed: [],
188
+ skipped,
189
+ remaining: violations.filter((issue) => !proposed.has(issue.id)).map((issue) => issue.id),
190
+ },
191
+ allowlist: {
192
+ primitiveTypes: [...input.allowlist.primitiveTypes],
193
+ properties: [...input.allowlist.properties],
194
+ },
195
+ };
196
+ }
197
+ function defaultOperationFactory(move, index) {
198
+ const input = {
199
+ primitiveId: move.primitiveId,
200
+ cosmeticOnly: true,
201
+ changes: move.property === 'position' ? { position: move.to } : { bounds: move.to },
202
+ };
203
+ return {
204
+ operationId: operationId('modifyComponent', input, index),
205
+ kind: 'modifyComponent',
206
+ input,
207
+ targetPrimitiveIds: [move.primitiveId],
208
+ order: index,
209
+ };
210
+ }
211
+ function batches(items, size) {
212
+ const result = [];
213
+ for (let index = 0; index < items.length; index += size) {
214
+ result.push(items.slice(index, index + size));
215
+ }
216
+ return result;
217
+ }
218
+ function appliedReport(preview) {
219
+ const fixed = [...new Set(preview.moves.flatMap((move) => move.resolvesViolationIds))].sort((a, b) => a.localeCompare(b));
220
+ return {
221
+ fixed,
222
+ skipped: preview.report.skipped,
223
+ remaining: preview.violations
224
+ .filter((issue) => !fixed.includes(issue.id))
225
+ .map((issue) => issue.id),
226
+ };
227
+ }
228
+ async function stableConnectivityRead(reader, options) {
229
+ const read = await readStable(reader, {
230
+ ...options,
231
+ fingerprint: options?.fingerprint ?? ((value) => value.hash),
232
+ });
233
+ if (!read.stable)
234
+ throw new Error('Connectivity readback did not stabilize.');
235
+ return read.value;
236
+ }
237
+ export async function applyLayoutAutofix(preview, options) {
238
+ if (!options.confirmWrite) {
239
+ return {
240
+ applied: false,
241
+ preview,
242
+ batchesVerified: 0,
243
+ actualStateReadAfterFailure: false,
244
+ report: preview.report,
245
+ };
246
+ }
247
+ const beforeFingerprint = await stableConnectivityRead(options.readConnectivity, options.stableRead);
248
+ if (preview.moves.length === 0) {
249
+ return {
250
+ applied: false,
251
+ preview,
252
+ beforeFingerprint,
253
+ afterFingerprint: beforeFingerprint,
254
+ connectivityDiff: compareConnectivityFingerprints(beforeFingerprint, beforeFingerprint),
255
+ batchesVerified: 0,
256
+ actualStateReadAfterFailure: false,
257
+ report: preview.report,
258
+ };
259
+ }
260
+ const operationFactory = options.operationFactory ?? defaultOperationFactory;
261
+ const operations = preview.moves.map((move, index) => operationFactory(move, index));
262
+ const operationBatches = batches(operations, Math.max(1, options.batchSize ?? 20));
263
+ const started = options.transactionManager.begin({
264
+ documentId: options.documentId,
265
+ label: 'schematic-layout-autofix',
266
+ });
267
+ const bridge = options.bridge;
268
+ let verified = 0;
269
+ let lastFingerprint = beforeFingerprint;
270
+ try {
271
+ for (const batch of operationBatches) {
272
+ for (const operation of batch) {
273
+ const targetId = operation.targetPrimitiveIds?.[0];
274
+ if (!targetId) {
275
+ throw new Error(`Operation ${operation.operationId} has no target primitive.`);
276
+ }
277
+ const changes = operation.input.changes;
278
+ await options.transactionManager.runModify(started.id, targetId, {
279
+ getSnapshot: () => getPrimitiveSnapshot(bridge, targetId),
280
+ apply: () => bridge.call('schematic.modifyPrimitive', { primitiveId: targetId, property: changes }),
281
+ restore: (snapshot) => bridge.call('schematic.restorePrimitiveSnapshot', { snapshot }),
282
+ });
283
+ }
284
+ lastFingerprint = await stableConnectivityRead(options.readConnectivity, options.stableRead);
285
+ const diff = compareConnectivityFingerprints(beforeFingerprint, lastFingerprint);
286
+ if (!diff.equal) {
287
+ await rollbackEasyedaTransaction(options.transactionManager, started.id, bridge);
288
+ const result = {
289
+ applied: false,
290
+ transaction: options.transactionManager.get(started.id),
291
+ preview,
292
+ beforeFingerprint,
293
+ afterFingerprint: lastFingerprint,
294
+ connectivityDiff: diff,
295
+ batchesVerified: verified,
296
+ actualStateReadAfterFailure: true,
297
+ report: preview.report,
298
+ };
299
+ throw new LayoutAutofixConnectivityError('Layout autofix changed electrical connectivity; the transaction was rolled back.', result);
300
+ }
301
+ verified += 1;
302
+ }
303
+ await options.transactionManager.validate(started.id, []);
304
+ const transaction = options.transactionManager.commit(started.id);
305
+ const diff = compareConnectivityFingerprints(beforeFingerprint, lastFingerprint);
306
+ return {
307
+ applied: true,
308
+ transaction,
309
+ preview,
310
+ beforeFingerprint,
311
+ afterFingerprint: lastFingerprint,
312
+ connectivityDiff: diff,
313
+ batchesVerified: verified,
314
+ actualStateReadAfterFailure: false,
315
+ report: appliedReport(preview),
316
+ };
317
+ }
318
+ catch (error) {
319
+ if (error instanceof LayoutAutofixConnectivityError)
320
+ throw error;
321
+ let actualStateReadAfterFailure = false;
322
+ let afterFingerprint = lastFingerprint;
323
+ try {
324
+ afterFingerprint = await options.readConnectivity();
325
+ actualStateReadAfterFailure = true;
326
+ }
327
+ catch {
328
+ // Preserve the original write/transaction failure when readback is also unavailable.
329
+ }
330
+ try {
331
+ await rollbackEasyedaTransaction(options.transactionManager, started.id, bridge);
332
+ }
333
+ catch {
334
+ // The manager may already have rolled back after an apply timeout or adapter failure.
335
+ }
336
+ const diff = compareConnectivityFingerprints(beforeFingerprint, afterFingerprint);
337
+ const result = {
338
+ applied: false,
339
+ transaction: options.transactionManager.get(started.id),
340
+ preview,
341
+ beforeFingerprint,
342
+ afterFingerprint,
343
+ connectivityDiff: diff,
344
+ batchesVerified: verified,
345
+ actualStateReadAfterFailure,
346
+ report: preview.report,
347
+ };
348
+ throw new LayoutAutofixConnectivityError(error instanceof Error ? error.message : 'Layout autofix failed.', result);
349
+ }
350
+ }
351
+ export function applyPreviewMovesToGeometry(primitives, preview) {
352
+ const moveById = new Map(preview.moves.map((move) => [move.primitiveId, move]));
353
+ return primitives.map((primitive) => {
354
+ const move = moveById.get(primitive.id);
355
+ if (!move)
356
+ return {
357
+ ...primitive,
358
+ origin: { ...primitive.origin },
359
+ combinedBounds: { ...primitive.combinedBounds },
360
+ };
361
+ if (move.property === 'bounds') {
362
+ const bounds = move.to;
363
+ return { ...primitive, origin: { x: bounds.x, y: bounds.y }, combinedBounds: { ...bounds } };
364
+ }
365
+ const origin = move.to;
366
+ return {
367
+ ...primitive,
368
+ origin: { ...origin },
369
+ combinedBounds: translateBounds(primitive.combinedBounds, {
370
+ x: origin.x - primitive.origin.x,
371
+ y: origin.y - primitive.origin.y,
372
+ }),
373
+ };
374
+ });
375
+ }
376
+ //# sourceMappingURL=autofix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autofix.js","sourceRoot":"","sources":["../../src/layout/autofix.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,eAAe,GAIhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,+BAA+B,GAGhC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,UAAU,EAA0B,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,WAAW,EAA2B,MAAM,kCAAkC,CAAC;AACxF,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAE3B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,cAAc,EAAkC,MAAM,gBAAgB,CAAC;AAuGhF,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IAG5C;IAFX,YACE,OAAe,EACN,MAAgC;QAEzC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,WAAM,GAAN,MAAM,CAA0B;QAGzC,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;AACnG,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAuB,CAAC,MAAM,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;AAE/F,SAAS,SAAS,CAChB,IAAgC,EAChC,YAA+B,EAC/B,OAAe;IAEf,MAAM,SAAS,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,IAAI,SAAS,C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AG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI;YACP,OAAO;gBACL,GAAG,SAAS;gBACZ,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE;gBAC/B,cAAc,EAAE,EAAE,GAAG,SAAS,CAAC,cAAc,EAAE;aAChD,CAAC;QACJ,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,EAAqB,CAAC;YAC1C,OAAO,EAAE,GAAG,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,EAAE,cAAc,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC;QAC/F,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,EAAoB,CAAC;QACzC,OAAO;YACL,GAAG,SAAS;YACZ,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE;YACrB,cAAc,EAAE,eAAe,CAAC,SAAS,CAAC,cAAc,EAAE;gBACxD,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;gBAChC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;aACjC,CAAC;SACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DetectedFunctionalBlock, ExplicitFunctionalBlock, FunctionalBlockKind, LayoutComponentInput, SchematicLayoutGraph } from './types.js';
2
+ export declare function inferFunctionalBlockKind(component: LayoutComponentInput): FunctionalBlockKind;
3
+ export declare function detectFunctionalBlocks(components: readonly LayoutComponentInput[], graph: SchematicLayoutGraph, explicitBlocks?: readonly ExplicitFunctionalBlock[]): DetectedFunctionalBlock[];