@lace-cloud/proto 0.16.0 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +89 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +87 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -915,6 +915,12 @@ type ProjectionMeta = {
|
|
|
915
915
|
declare function projectCanvasView(bundle: Bundle, arrangement: CanvasArrangement | undefined, meta: ProjectionMeta): CanvasView;
|
|
916
916
|
|
|
917
917
|
declare function resolveScopePositions(ids: string[], arrangementNodes: CanvasArrangement[string]['nodes']): Map<string, XY>;
|
|
918
|
+
declare function resolveScopePositionsByDepth(ids: string[], arrangementNodes: CanvasArrangement[string]['nodes'], edges: readonly LayoutEdge[]): Map<string, XY>;
|
|
919
|
+
/** One dependency arrow, as `deriveEdges` emits it. */
|
|
920
|
+
type LayoutEdge = {
|
|
921
|
+
source_instance: string;
|
|
922
|
+
target_instance: string;
|
|
923
|
+
};
|
|
918
924
|
|
|
919
925
|
type ParsedModuleKey = {
|
|
920
926
|
id: string;
|
|
@@ -929,4 +935,4 @@ declare const NodeConfigProto: MessageFns<NodeConfig$1>;
|
|
|
929
935
|
declare const EdgeConfigProto: MessageFns<EdgeConfig$1>;
|
|
930
936
|
declare const SettingsConfigProto: MessageFns<SettingsConfig$1>;
|
|
931
937
|
|
|
932
|
-
export { Bundle, type CanvasArrangement, type CanvasView, CanvasViewProto, type DeepPartial$1 as DeepPartial, type Diagnostic, type EdgeConfig, EdgeConfigProto, type GeneratePhase, type HostToWebview, type NodeConfig, NodeConfigProto, type NodePin, type ParsedModuleKey, type ProjectionMeta, type ProtoCanvasViewLike, type ProtoDiagnosticLike, type ProtoEdgeConfigLike, type ProtoInputDefLike, type ProtoNodeConfigLike, type ProtoOutputDefLike, type ProtoOutputExportEntryLike, type ProtoRenderErrorLike, type ProtoRenderInputLike, type ProtoRenderNodeLike, type ProtoSettingsConfigLike, type RenderEdge, type RenderError, type RenderGroup, type RenderInput, type RenderNode, type RenderOutput, type SettingsConfig, SettingsConfigProto, type ViewportIntent, type XY, convertCanvasView, convertDiagnostic, convertDiagnosticSeverity, convertEdgeConfig, convertInputMode, convertNodeConfig, convertNodeKind, convertRenderError, convertRenderInput, convertRenderNode, convertSettingsConfig, modeToInputMode, parseModuleKey, projectCanvasView, resolveScopePath, resolveScopePositions };
|
|
938
|
+
export { Bundle, type CanvasArrangement, type CanvasView, CanvasViewProto, type DeepPartial$1 as DeepPartial, type Diagnostic, type EdgeConfig, EdgeConfigProto, type GeneratePhase, type HostToWebview, type NodeConfig, NodeConfigProto, type NodePin, type ParsedModuleKey, type ProjectionMeta, type ProtoCanvasViewLike, type ProtoDiagnosticLike, type ProtoEdgeConfigLike, type ProtoInputDefLike, type ProtoNodeConfigLike, type ProtoOutputDefLike, type ProtoOutputExportEntryLike, type ProtoRenderErrorLike, type ProtoRenderInputLike, type ProtoRenderNodeLike, type ProtoSettingsConfigLike, type RenderEdge, type RenderError, type RenderGroup, type RenderInput, type RenderNode, type RenderOutput, type SettingsConfig, SettingsConfigProto, type ViewportIntent, type XY, convertCanvasView, convertDiagnostic, convertDiagnosticSeverity, convertEdgeConfig, convertInputMode, convertNodeConfig, convertNodeKind, convertRenderError, convertRenderInput, convertRenderNode, convertSettingsConfig, modeToInputMode, parseModuleKey, projectCanvasView, resolveScopePath, resolveScopePositions, resolveScopePositionsByDepth };
|
package/dist/index.d.ts
CHANGED
|
@@ -915,6 +915,12 @@ type ProjectionMeta = {
|
|
|
915
915
|
declare function projectCanvasView(bundle: Bundle, arrangement: CanvasArrangement | undefined, meta: ProjectionMeta): CanvasView;
|
|
916
916
|
|
|
917
917
|
declare function resolveScopePositions(ids: string[], arrangementNodes: CanvasArrangement[string]['nodes']): Map<string, XY>;
|
|
918
|
+
declare function resolveScopePositionsByDepth(ids: string[], arrangementNodes: CanvasArrangement[string]['nodes'], edges: readonly LayoutEdge[]): Map<string, XY>;
|
|
919
|
+
/** One dependency arrow, as `deriveEdges` emits it. */
|
|
920
|
+
type LayoutEdge = {
|
|
921
|
+
source_instance: string;
|
|
922
|
+
target_instance: string;
|
|
923
|
+
};
|
|
918
924
|
|
|
919
925
|
type ParsedModuleKey = {
|
|
920
926
|
id: string;
|
|
@@ -929,4 +935,4 @@ declare const NodeConfigProto: MessageFns<NodeConfig$1>;
|
|
|
929
935
|
declare const EdgeConfigProto: MessageFns<EdgeConfig$1>;
|
|
930
936
|
declare const SettingsConfigProto: MessageFns<SettingsConfig$1>;
|
|
931
937
|
|
|
932
|
-
export { Bundle, type CanvasArrangement, type CanvasView, CanvasViewProto, type DeepPartial$1 as DeepPartial, type Diagnostic, type EdgeConfig, EdgeConfigProto, type GeneratePhase, type HostToWebview, type NodeConfig, NodeConfigProto, type NodePin, type ParsedModuleKey, type ProjectionMeta, type ProtoCanvasViewLike, type ProtoDiagnosticLike, type ProtoEdgeConfigLike, type ProtoInputDefLike, type ProtoNodeConfigLike, type ProtoOutputDefLike, type ProtoOutputExportEntryLike, type ProtoRenderErrorLike, type ProtoRenderInputLike, type ProtoRenderNodeLike, type ProtoSettingsConfigLike, type RenderEdge, type RenderError, type RenderGroup, type RenderInput, type RenderNode, type RenderOutput, type SettingsConfig, SettingsConfigProto, type ViewportIntent, type XY, convertCanvasView, convertDiagnostic, convertDiagnosticSeverity, convertEdgeConfig, convertInputMode, convertNodeConfig, convertNodeKind, convertRenderError, convertRenderInput, convertRenderNode, convertSettingsConfig, modeToInputMode, parseModuleKey, projectCanvasView, resolveScopePath, resolveScopePositions };
|
|
938
|
+
export { Bundle, type CanvasArrangement, type CanvasView, CanvasViewProto, type DeepPartial$1 as DeepPartial, type Diagnostic, type EdgeConfig, EdgeConfigProto, type GeneratePhase, type HostToWebview, type NodeConfig, NodeConfigProto, type NodePin, type ParsedModuleKey, type ProjectionMeta, type ProtoCanvasViewLike, type ProtoDiagnosticLike, type ProtoEdgeConfigLike, type ProtoInputDefLike, type ProtoNodeConfigLike, type ProtoOutputDefLike, type ProtoOutputExportEntryLike, type ProtoRenderErrorLike, type ProtoRenderInputLike, type ProtoRenderNodeLike, type ProtoSettingsConfigLike, type RenderEdge, type RenderError, type RenderGroup, type RenderInput, type RenderNode, type RenderOutput, type SettingsConfig, SettingsConfigProto, type ViewportIntent, type XY, convertCanvasView, convertDiagnostic, convertDiagnosticSeverity, convertEdgeConfig, convertInputMode, convertNodeConfig, convertNodeKind, convertRenderError, convertRenderInput, convertRenderNode, convertSettingsConfig, modeToInputMode, parseModuleKey, projectCanvasView, resolveScopePath, resolveScopePositions, resolveScopePositionsByDepth };
|
package/dist/index.mjs
CHANGED
|
@@ -3777,7 +3777,7 @@ function overlapsAny(candidate, occupied) {
|
|
|
3777
3777
|
(o) => candidate.x < o.x + SPACING_X && candidate.x + SPACING_X > o.x && candidate.y < o.y + SPACING_Y && candidate.y + SPACING_Y > o.y
|
|
3778
3778
|
);
|
|
3779
3779
|
}
|
|
3780
|
-
function
|
|
3780
|
+
function partitionStored(ids, arrangementNodes) {
|
|
3781
3781
|
const positions = /* @__PURE__ */ new Map();
|
|
3782
3782
|
const occupied = [];
|
|
3783
3783
|
const unresolved = [];
|
|
@@ -3790,6 +3790,10 @@ function resolveScopePositions(ids, arrangementNodes) {
|
|
|
3790
3790
|
unresolved.push(id);
|
|
3791
3791
|
}
|
|
3792
3792
|
}
|
|
3793
|
+
return { positions, occupied, unresolved };
|
|
3794
|
+
}
|
|
3795
|
+
function resolveScopePositions(ids, arrangementNodes) {
|
|
3796
|
+
const { positions, occupied, unresolved } = partitionStored(ids, arrangementNodes);
|
|
3793
3797
|
let slot = 0;
|
|
3794
3798
|
for (const id of unresolved) {
|
|
3795
3799
|
let candidate = gridPosition(slot, ids.length);
|
|
@@ -3803,9 +3807,85 @@ function resolveScopePositions(ids, arrangementNodes) {
|
|
|
3803
3807
|
}
|
|
3804
3808
|
return positions;
|
|
3805
3809
|
}
|
|
3810
|
+
function resolveScopePositionsByDepth(ids, arrangementNodes, edges) {
|
|
3811
|
+
const { positions, occupied, unresolved } = partitionStored(ids, arrangementNodes);
|
|
3812
|
+
const columns = columnByDepth(ids, edges);
|
|
3813
|
+
const predecessors = /* @__PURE__ */ new Map();
|
|
3814
|
+
for (const edge of edges) {
|
|
3815
|
+
if (edge.source_instance === edge.target_instance) continue;
|
|
3816
|
+
predecessors.set(edge.target_instance, [
|
|
3817
|
+
...predecessors.get(edge.target_instance) ?? [],
|
|
3818
|
+
edge.source_instance
|
|
3819
|
+
]);
|
|
3820
|
+
}
|
|
3821
|
+
const rows = /* @__PURE__ */ new Map();
|
|
3822
|
+
const order = [...ids].sort((a, b) => (columns.get(a) ?? 0) - (columns.get(b) ?? 0));
|
|
3823
|
+
const seeded = /* @__PURE__ */ new Map();
|
|
3824
|
+
for (const id of order) {
|
|
3825
|
+
const column = columns.get(id) ?? 0;
|
|
3826
|
+
const stored = arrangementNodes?.[id];
|
|
3827
|
+
if (stored) {
|
|
3828
|
+
rows.set(id, stored.y);
|
|
3829
|
+
continue;
|
|
3830
|
+
}
|
|
3831
|
+
const seq = seeded.get(column) ?? 0;
|
|
3832
|
+
seeded.set(column, seq + 1);
|
|
3833
|
+
rows.set(id, seq * SPACING_Y);
|
|
3834
|
+
}
|
|
3835
|
+
for (const id of order) {
|
|
3836
|
+
if (arrangementNodes?.[id]) continue;
|
|
3837
|
+
const feeders = (predecessors.get(id) ?? []).filter((f) => rows.has(f));
|
|
3838
|
+
if (feeders.length === 0) continue;
|
|
3839
|
+
rows.set(id, feeders.reduce((sum, f) => sum + (rows.get(f) ?? 0), 0) / feeders.length);
|
|
3840
|
+
}
|
|
3841
|
+
const byColumn = /* @__PURE__ */ new Map();
|
|
3842
|
+
for (const id of ids) {
|
|
3843
|
+
const column = columns.get(id) ?? 0;
|
|
3844
|
+
byColumn.set(column, [...byColumn.get(column) ?? [], id]);
|
|
3845
|
+
}
|
|
3846
|
+
for (const [, members] of byColumn) {
|
|
3847
|
+
const movable = members.filter((id) => !arrangementNodes?.[id]);
|
|
3848
|
+
if (movable.length < 2) continue;
|
|
3849
|
+
const sorted = [...movable].sort((a, b) => (rows.get(a) ?? 0) - (rows.get(b) ?? 0));
|
|
3850
|
+
const centre = sorted.reduce((sum, id) => sum + (rows.get(id) ?? 0), 0) / sorted.length;
|
|
3851
|
+
const first = centre - (sorted.length - 1) * SPACING_Y / 2;
|
|
3852
|
+
for (const [i, id] of sorted.entries()) {
|
|
3853
|
+
rows.set(id, first + i * SPACING_Y);
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
for (const id of unresolved) {
|
|
3857
|
+
const column = columns.get(id) ?? 0;
|
|
3858
|
+
let candidate = { x: column * SPACING_X, y: rows.get(id) ?? 0 };
|
|
3859
|
+
while (overlapsAny(candidate, occupied)) {
|
|
3860
|
+
candidate = { x: candidate.x, y: candidate.y + SPACING_Y };
|
|
3861
|
+
}
|
|
3862
|
+
positions.set(id, candidate);
|
|
3863
|
+
occupied.push(candidate);
|
|
3864
|
+
}
|
|
3865
|
+
return positions;
|
|
3866
|
+
}
|
|
3867
|
+
function columnByDepth(ids, edges) {
|
|
3868
|
+
const present = new Set(ids);
|
|
3869
|
+
const real = edges.filter(
|
|
3870
|
+
(e) => e.source_instance !== e.target_instance && present.has(e.source_instance) && present.has(e.target_instance)
|
|
3871
|
+
);
|
|
3872
|
+
const depth = new Map(ids.map((id) => [id, 0]));
|
|
3873
|
+
for (let round = 0; round < ids.length; round += 1) {
|
|
3874
|
+
let moved = false;
|
|
3875
|
+
for (const e of real) {
|
|
3876
|
+
const want = (depth.get(e.source_instance) ?? 0) + 1;
|
|
3877
|
+
if (want > (depth.get(e.target_instance) ?? 0)) {
|
|
3878
|
+
depth.set(e.target_instance, want);
|
|
3879
|
+
moved = true;
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
if (!moved) break;
|
|
3883
|
+
}
|
|
3884
|
+
return depth;
|
|
3885
|
+
}
|
|
3806
3886
|
|
|
3807
3887
|
// src/projection/derive-edges.ts
|
|
3808
|
-
var
|
|
3888
|
+
var moduleDepPattern = /\bmodule\.([A-Za-z_][A-Za-z0-9_-]*)(?:\[\s*(?:\*|[0-9]+|"[^"]*")\s*\])?\.([A-Za-z_][A-Za-z0-9_-]*)/g;
|
|
3809
3889
|
function emitEdgesFromBinding(binding, targetId, toInput, useIds, seen, edges) {
|
|
3810
3890
|
if (binding.out?.module && binding.out.name) {
|
|
3811
3891
|
edges.push({
|
|
@@ -3817,7 +3897,7 @@ function emitEdgesFromBinding(binding, targetId, toInput, useIds, seen, edges) {
|
|
|
3817
3897
|
return;
|
|
3818
3898
|
}
|
|
3819
3899
|
if (binding.expr?.value) {
|
|
3820
|
-
for (const match of binding.expr.value.matchAll(
|
|
3900
|
+
for (const match of binding.expr.value.matchAll(moduleDepPattern)) {
|
|
3821
3901
|
const srcInstance = match[1];
|
|
3822
3902
|
const srcOutput = match[2];
|
|
3823
3903
|
if (!useIds.has(srcInstance)) continue;
|
|
@@ -3963,7 +4043,7 @@ function projectScope(bundle, mod, path, arrangement, errorsByInstance) {
|
|
|
3963
4043
|
const groups = [];
|
|
3964
4044
|
const classified = uses.map((use) => ({ use, group: isGroupUse(bundle, use) }));
|
|
3965
4045
|
const nodeUseIds = classified.filter((c) => !c.group).map((c) => c.use.id);
|
|
3966
|
-
const positions =
|
|
4046
|
+
const positions = resolveScopePositionsByDepth(nodeUseIds, scopeArrangement?.nodes, derived);
|
|
3967
4047
|
for (const { use, group } of classified) {
|
|
3968
4048
|
const fullId = joinPath(path, use.id);
|
|
3969
4049
|
if (group) {
|
|
@@ -3976,7 +4056,7 @@ function projectScope(bundle, mod, path, arrangement, errorsByInstance) {
|
|
|
3976
4056
|
bundle,
|
|
3977
4057
|
use,
|
|
3978
4058
|
fullId,
|
|
3979
|
-
// Every non-group use is in nodeUseIds, so
|
|
4059
|
+
// Every non-group use is in nodeUseIds, so resolveScopePositionsByDepth
|
|
3980
4060
|
// always has an entry for it — a fallback here would only mask a
|
|
3981
4061
|
// classification bug, not handle a real gap.
|
|
3982
4062
|
positions.get(use.id),
|
|
@@ -7246,6 +7326,7 @@ export {
|
|
|
7246
7326
|
parseModuleKey,
|
|
7247
7327
|
projectCanvasView,
|
|
7248
7328
|
resolveScopePath,
|
|
7249
|
-
resolveScopePositions
|
|
7329
|
+
resolveScopePositions,
|
|
7330
|
+
resolveScopePositionsByDepth
|
|
7250
7331
|
};
|
|
7251
7332
|
//# sourceMappingURL=index.mjs.map
|