glimmervoid 0.48.4-next.372 → 0.48.4-next.374
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/bin/glimmervoid.js +8 -8
- package/dist/chunks/{agent-api-cli-CdH4FPs0.js → agent-api-cli-BJS9NzHM.js} +1 -1
- package/dist/chunks/{agent-api-cli-_LARN_Fw.js → agent-api-cli-C5EAcLcV.js} +379 -6
- package/dist/chunks/{agent-api-core-Dh837S6e.js → agent-api-core-I0VUtqYU.js} +31 -7
- package/dist/chunks/config-store-BIr4xVth.js +1 -0
- package/dist/chunks/{config-store-pdqPJdAR.js → config-store-OdyfXb2W.js} +1 -1
- package/dist/chunks/{main-4ekC1xUK.js → main-BTgxpzRg.js} +63 -1242
- package/dist/chunks/{pair-cli-BrBfDhjN.js → pair-cli-BGbjIhc8.js} +2 -2
- package/dist/chunks/{pairings-store-Ct1E_XlV.js → pairings-store-BzA3p9oE.js} +1 -1
- package/dist/chunks/{settings-cli-CjILhezb.js → settings-cli-B_Fl0uRl.js} +3 -3
- package/dist/chunks/{settings-readout-core-B8wF5y4U.js → settings-readout-core-Cc5zwF6w.js} +1 -1
- package/dist/chunks/shown-files-core-nS3KPkN_.js +1439 -0
- package/dist/chunks/{ssh-sign-cli-9TxVwZta.js → ssh-sign-cli-CV1VA1Rp.js} +1 -1
- package/dist/chunks/{why-cli-COxYCd2L.js → why-cli-C_AHDxKT.js} +1 -1
- package/dist/client/assets/{benchmark-panel-UJIpNEO7.js → benchmark-panel-C-OXJRrA.js} +1 -1
- package/dist/client/assets/benchmark-panel-C-OXJRrA.js.br +0 -0
- package/dist/client/assets/boards-view-BeEaY6C9.js +1 -0
- package/dist/client/assets/boards-view-BeEaY6C9.js.br +0 -0
- package/dist/client/assets/{community-panel-D3d-egkg.js → community-panel-D4AA_Zns.js} +1 -1
- package/dist/client/assets/community-panel-D4AA_Zns.js.br +0 -0
- package/dist/client/assets/dialogs-CkneZ7uI.js +74 -0
- package/dist/client/assets/dialogs-CkneZ7uI.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-BWF2gHC9.js → doc-editor-ui-DWxRm4O0.js} +1 -1
- package/dist/client/assets/doc-editor-ui-DWxRm4O0.js.br +0 -0
- package/dist/client/assets/escape-markup-CKuHtFmo.js +1 -0
- package/dist/client/assets/{feature-hint-nHyPkN-S.js → feature-hint-DQ0b_hs0.js} +1 -1
- package/dist/client/assets/feature-hint-DQ0b_hs0.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-BSkoci92.js → first-run-checklist-BX6xdYS_.js} +1 -1
- package/dist/client/assets/first-run-checklist-BX6xdYS_.js.br +0 -0
- package/dist/client/assets/{hooks-panel-Yrwybzvb.js → hooks-panel-C12PxpSE.js} +1 -1
- package/dist/client/assets/hooks-panel-C12PxpSE.js.br +0 -0
- package/dist/client/assets/index-CUbWeDtv.js +78 -0
- package/dist/client/assets/index-CUbWeDtv.js.br +0 -0
- package/dist/client/assets/issues-panel-BvjKIXB5.js +1 -0
- package/dist/client/assets/issues-panel-BvjKIXB5.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-Bw_c7HtL.js → my-prs-panel-CUeDb48b.js} +1 -1
- package/dist/client/assets/my-prs-panel-CUeDb48b.js.br +0 -0
- package/dist/client/assets/{nyan-cat-D4tylwYT.js → nyan-cat-B9bWjC-E.js} +1 -1
- package/dist/client/assets/nyan-cat-B9bWjC-E.js.br +0 -0
- package/dist/client/assets/phone-shell-D3ufCox8.js +1 -0
- package/dist/client/assets/phone-shell-D3ufCox8.js.br +0 -0
- package/dist/client/assets/{plan-face-C78j3fT0.js → plan-face-mS3l9wy_.js} +1 -1
- package/dist/client/assets/plan-face-mS3l9wy_.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-CB7-jax3.js → pr-queue-columns-BcEC1DsD.js} +1 -1
- package/dist/client/assets/pr-queue-columns-BcEC1DsD.js.br +0 -0
- package/dist/client/assets/{radar-panel-KvziKbpN.js → radar-panel-B9KgQdIN.js} +1 -1
- package/dist/client/assets/radar-panel-B9KgQdIN.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-DR9Gxbvk.js → repo-roots-adder-CYO3qVCJ.js} +1 -1
- package/dist/client/assets/repo-roots-adder-CYO3qVCJ.js.br +0 -0
- package/dist/client/assets/resume-dialog-CEjf4G4s.js +1 -0
- package/dist/client/assets/resume-dialog-CEjf4G4s.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-DzPBPCVF.js → review-queue-panel-CJ1TXCwt.js} +1 -1
- package/dist/client/assets/review-queue-panel-CJ1TXCwt.js.br +0 -0
- package/dist/client/assets/roving-keys-core-BDobx2It.js +1 -0
- package/dist/client/assets/{settings-panel-BfpMv5Bi.js → settings-panel-Bk33t3uI.js} +3 -3
- package/dist/client/assets/settings-panel-Bk33t3uI.js.br +0 -0
- package/dist/client/assets/{shown-lightbox-DpmoJvyi.js → shown-lightbox-CRgREiGD.js} +1 -1
- package/dist/client/assets/shown-lightbox-CRgREiGD.js.br +0 -0
- package/dist/client/assets/{team-review-panel-zbTQb2ed.js → team-review-panel-BQX8iKpi.js} +1 -1
- package/dist/client/assets/team-review-panel-BQX8iKpi.js.br +0 -0
- package/dist/client/assets/{trace-panel-D3EJ9Ici.js → trace-panel-B_1sI5bQ.js} +1 -1
- package/dist/client/assets/trace-panel-B_1sI5bQ.js.br +0 -0
- package/dist/client/assets/{usage-panel-LX_w7crU.js → usage-panel-CwTzRXC-.js} +1 -1
- package/dist/client/assets/usage-panel-CwTzRXC-.js.br +0 -0
- package/dist/client/assets/{your-day-tip-DtI3SbrB.js → your-day-tip-xiaEIrmf.js} +1 -1
- package/dist/client/assets/your-day-tip-xiaEIrmf.js.br +4 -0
- package/dist/client/index.html +3 -1
- package/dist/client/index.html.br +0 -0
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/config-store-B4vUTgoX.js +0 -1
- package/dist/chunks/shown-files-core-B6ovU6SV.js +0 -224
- package/dist/client/assets/benchmark-panel-UJIpNEO7.js.br +0 -0
- package/dist/client/assets/boards-view-Dm2q6ifp.js +0 -1
- package/dist/client/assets/boards-view-Dm2q6ifp.js.br +0 -0
- package/dist/client/assets/community-panel-D3d-egkg.js.br +0 -0
- package/dist/client/assets/dialogs-PaO3ZtYa.js +0 -74
- package/dist/client/assets/dialogs-PaO3ZtYa.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-BWF2gHC9.js.br +0 -0
- package/dist/client/assets/feature-hint-nHyPkN-S.js.br +0 -0
- package/dist/client/assets/first-run-checklist-BSkoci92.js.br +0 -0
- package/dist/client/assets/hooks-panel-Yrwybzvb.js.br +0 -0
- package/dist/client/assets/index-DV9XfyFg.js +0 -78
- package/dist/client/assets/index-DV9XfyFg.js.br +0 -0
- package/dist/client/assets/issues-panel-Cbv8r63_.js +0 -1
- package/dist/client/assets/issues-panel-Cbv8r63_.js.br +0 -0
- package/dist/client/assets/my-prs-panel-Bw_c7HtL.js.br +0 -0
- package/dist/client/assets/nyan-cat-D4tylwYT.js.br +0 -0
- package/dist/client/assets/phone-shell-Ck5cuGlO.js +0 -1
- package/dist/client/assets/phone-shell-Ck5cuGlO.js.br +0 -0
- package/dist/client/assets/plan-face-C78j3fT0.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-CB7-jax3.js.br +0 -0
- package/dist/client/assets/radar-panel-KvziKbpN.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-DR9Gxbvk.js.br +0 -8
- package/dist/client/assets/resume-dialog-BnH4tvvE.js +0 -1
- package/dist/client/assets/resume-dialog-BnH4tvvE.js.br +0 -0
- package/dist/client/assets/review-queue-panel-DzPBPCVF.js.br +0 -0
- package/dist/client/assets/settings-panel-BfpMv5Bi.js.br +0 -0
- package/dist/client/assets/shown-lightbox-DpmoJvyi.js.br +0 -0
- package/dist/client/assets/team-review-panel-zbTQb2ed.js.br +0 -0
- package/dist/client/assets/trace-panel-D3EJ9Ici.js.br +0 -0
- package/dist/client/assets/usage-panel-LX_w7crU.js.br +0 -0
- package/dist/client/assets/your-day-tip-DtI3SbrB.js.br +0 -0
|
@@ -6,7 +6,7 @@ import { n as glimmervoidHomeDir, r as isOperatorHomeUnderTest, t as decideConfi
|
|
|
6
6
|
import { $ as LinkedPr, $t as shortSha, A as SIGN_URL_ENV, At as PrDetail, Bt as TeamReviewCompareFiles, Ct as DECIDING_REVIEW_STATES, D as SESSION_NAME_PATTERN, Dt as GithubReviewState, F as ShownFile, Ft as ReviewResult, G as Frame, Gt as TeamReviewThreadResult, H as BoardRecord, Ht as TeamReviewStateEntry, It as ReviewThreadId, J as Unit, Jt as decisionAsIfApprovalRequired, K as Note, Kt as TeamReviewThreadsRepository, L as SshSignRequest, Lt as ReviewVerdict, Mt as ReviewComment, Nt as ReviewDraft, O as SESSION_NAME_RULE_TEXT, Ot as PostedReviewEvent, Pt as ReviewFinding, Q as Wire, Qt as HEX_SHA_RE, Rt as TeamReviewActionRequest, S as ConversationQuestion, St as CommitSha, T as SESSION_DOC_BODY_CAP_BYTES, Tt as FindingSeverity, Ut as TeamReviewStatus, Vt as TeamReviewResolveResponse, W as Box, Wt as TeamReviewThreadCommentsResponse, Xt as hasStandingViewerApproval, Y as WHITEBOARD_LIMITS, _ as COHERENCE_HOOKS_INACTIVE, _t as MyPrsState, b as CONVERSATION_TOOL_RESULT_HOOK_EVENT, cn as BADGE_LABELS, ct as MyPrMergeRequest, dn as RESTARTABLE_STATES, dt as MyPrMergeWhenReadyRequest, en as GH_SEGMENT, et as MyPr, fn as STATES, gt as MyPrsSnapshot, ht as MyPrThreadsResponse, i as ASK_USER_QUESTION_TOOL_NAME, it as MyPrKeepMergeableRequest, j as SSH_SIGN_BODY_CAP_BYTES, k as SHOWN_FILE_CAP_BYTES, kt as PostingPlan, ln as KILLABLE_STATES, mt as MyPrThreadNode, nn as REPO_SLUG_RE, nt as MyPrCheckContext, ot as MyPrLaneEntry, qt as canApproveAfterComment, r as AGENT_URL_ENV, rn as repoParts, rt as MyPrCheckContextsResponse, st as MyPrMergeMethod, tn as NODE_ID_RE, tt as MyPrAutoRebase, un as MERGEABLE_LIVE_STATES, ut as MyPrMergeStateResponse, v as CONVERSATION_APPROVAL_SUMMARY_MAX_CHARS, wt as EarlierReview, y as CONVERSATION_PERMISSION_HOOK_EVENT, z as TaskTitle } from "./session-CmkfJxzB.js";
|
|
7
7
|
import { c as spawn, i as execFileSync, n as execFile, r as execFileAsync, s as refuseLaunchesOf, t as assertLaunchable } from "./child-process-safe-BCOoKfxG.js";
|
|
8
8
|
import { $t as IssuesStatus, A as HINT_VIEW_BY_FEATURE, At as UpdateJournal, B as MergedPrListing, Bt as PLAN_HOOK_OUTPUT_MAX_CHARS, Ct as CommunityItem, D as pullRequestKeyFromReference, Dt as SKILL_NAME_RE, Et as DISCORD_CHANNEL_NAME_RE, F as BenchmarkJudgement, Ft as CoherenceJournalOutput, G as GithubPrLightSearchNode, Gt as parseExitPlanModeHookPayload, H as PrCheckoutCaseInput, Ht as PLAN_TOOL_NAME, I as BenchmarkRun, It as ChangeMap, J as WorkflowCommentBody, Jt as GithubIssueResponse, K as GithubPrsFrame, Kt as planTitle, L as BenchmarkStatus, Lt as changeMapFactId, M as BenchmarkActionRequest, Mt as MAX_RAW_LINE_CHARS, N as BenchmarkCase, Nt as TraceCheckpoint, O as FeatureHintState, P as BenchmarkId, Pt as TraceRecord, Qt as IssuesState, R as BenchmarkSuite, Rt as PLAN_BODY_CAP_BYTES, St as CommunityDraft, Tt as CommunityVerdict, U as GithubPrDetailNode, Ut as PlanDecision, V as MinedPrReviewData, Vt as PLAN_RESULT_HOOK_EVENT, W as GithubPrKey, Wt as PlanRevision, X as WorkflowsSettings, Xt as IssueUpdate, Y as WorkflowLabelName, Yt as IssueKey, Z as WorkflowsState, Zt as IssuesSearchResponse, _ as CLIENT_LOG_TEXT_MAX_CHARS, a as ConfigUpdate, c as SHELL_AGENT_ID, en as issuePullRequestStateFromGithub, f as USAGE_COST_MODES, gt as USAGE_INTEGER_RANGES, h as CHANGES_POLL_INTERVAL_MS, jt as SessionSetup, k as HINT_FEATURES, p as USAGE_VENDOR_KEYS, q as comparablePrKey, qt as GithubIssuePullRequestsRepository, r as BrowserConfig, rt as KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE, s as RUNTIME_CONFIG_SCALAR_KEYS, u as configIssueMessage, v as CONTROL_FRAME_MAX_BYTES, wt as CommunityState, x as GithubTeam, xt as CommunityActionRequest, y as ClientMessage, z as CommitComparison, zt as PLAN_HOOK_EVENT } from "./config-Dbjq0LnF.js";
|
|
9
|
-
import { A as parseRefinedSessionName, B as resumePromptFor, C as decideTaskTitleRefinement, D as extractPromptTaskTitle, E as extractOscTaskTitle, F as AUTO_CONTINUE_PROMPT, G as isAutoNameOf, H as claudeProjectsDir, I as RESUME_ID_RE, K as nextSuggestedName, L as isConversationReplacedAtStartup, M as resolveRefocusTaskTitle, N as resolveTaskTitle, O as isSelfWakePrompt, P as seedTaskTitleSources, R as pickAutoResume, S as cleanTaskPrompt, T as extractHookTaskTitle, U as listRepoConversations, V as shouldAdoptReportedResumeId, W as listRepoWorktreePaths, _ as projectReviewDetail, a as checkAgentReply, b as buildTaskTitleRefinementPrompt, c as deriveChildSessionName, d as describePushLanding, f as describeRoleRefusal, g as projectMyPrs, h as parseAgentVerb, j as parseRefinedTaskTitle, k as isSubstantivePrompt, l as describeChildEndNote, n as REFUSAL_REASON, o as decideAgentRequest, p as describeUnpushedCloseRefusal, s as decideSpawnAllowance, u as describeKeptChildAttention, v as projectReviews, w as extractAiTitle, x as chooseRefinedSessionName, y as buildPersistedTaskTitle, z as resolveResumeTarget } from "./agent-api-core-
|
|
9
|
+
import { A as parseRefinedSessionName, B as resumePromptFor, C as decideTaskTitleRefinement, D as extractPromptTaskTitle, E as extractOscTaskTitle, F as AUTO_CONTINUE_PROMPT, G as isAutoNameOf, H as claudeProjectsDir, I as RESUME_ID_RE, K as nextSuggestedName, L as isConversationReplacedAtStartup, M as resolveRefocusTaskTitle, N as resolveTaskTitle, O as isSelfWakePrompt, P as seedTaskTitleSources, R as pickAutoResume, S as cleanTaskPrompt, T as extractHookTaskTitle, U as listRepoConversations, V as shouldAdoptReportedResumeId, W as listRepoWorktreePaths, _ as projectReviewDetail, a as checkAgentReply, b as buildTaskTitleRefinementPrompt, c as deriveChildSessionName, d as describePushLanding, f as describeRoleRefusal, g as projectMyPrs, h as parseAgentVerb, j as parseRefinedTaskTitle, k as isSubstantivePrompt, l as describeChildEndNote, n as REFUSAL_REASON, o as decideAgentRequest, p as describeUnpushedCloseRefusal, s as decideSpawnAllowance, u as describeKeptChildAttention, v as projectReviews, w as extractAiTitle, x as chooseRefinedSessionName, y as buildPersistedTaskTitle, z as resolveResumeTarget } from "./agent-api-core-I0VUtqYU.js";
|
|
10
10
|
import { a as permitsHelpCommand, o as supervisionLine, r as describeSessionLimits } from "./session-routes-CgqWd0bR.js";
|
|
11
11
|
import { a as rawTextOr, i as positiveNumberOr, n as isRecord$1, o as textOr, r as numberOr, t as coercedNumberOr } from "./coerce-oz_Z_6E7.js";
|
|
12
12
|
import { i as parseCommandLine, n as warnWhenGitIsTooOld } from "./git-version-xS1GFU8P.js";
|
|
@@ -15,18 +15,18 @@ import { r as refocusReplyFor, t as promptContextReplyOf } from "./refocus-core-
|
|
|
15
15
|
import { n as parseJsonRecord, t as parseJsonOrNull } from "./json-core-If8h-Qgy.js";
|
|
16
16
|
import { a as saneYoloFiles } from "./sane-yolo-BjUkqIoH.js";
|
|
17
17
|
import { r as knownWriteHookInput } from "./posthog-read-gate-core-CeSY56AB.js";
|
|
18
|
-
import { a as readPageTitle, c as
|
|
18
|
+
import { a as readPageTitle, c as layoutBoard, d as unitsOf, i as filesAfterRetention, l as findDependencyCycle, n as decideShownKind, o as shownMimeForFilename, r as describeOverCap, s as escapeMarkup, t as SHOWN_SNIFF_BYTES } from "./shown-files-core-nS3KPkN_.js";
|
|
19
19
|
import { n as shellQuote } from "./hook-command-core-qTNK-xMF.js";
|
|
20
20
|
import { C as parseCgroupBytes, D as DEFAULT_MAX_MS, E as DEFAULT_BASE_MS, O as nextBackoffMs, S as memoryReserveBytes, T as parseMemAvailableBytes, _ as createSpawnGate, a as jsonStateLoadError, b as cgroupLimitBytes, c as loadedJsonValue, d as writeJsonAtomicSync, g as createSerialQueue, h as createMemoryAdmission, i as createJsonStateWriter, m as createKeyedSerialQueue, n as appendJsonLines, o as loadJsonStateFile, p as writeTextAtomicSync, r as createJsonStateStore, s as loadJsonStateFileSync, t as appendJsonLine, u as writeJsonAtomic, v as isQueueAdmissionTimeout, w as parseCgroupV2Path, x as headroomFromReadings, y as cgroupAncestorPaths } from "./json-file-AKRVPqG1.js";
|
|
21
|
-
import { $ as stableConfigKey, B as buildPersonProperties, F as TELEMETRY_FLAGS_URL, G as decideRemoteTelemetryState, H as claudeAccountUuidOf, I as adapterBucket, J as nodeMajorVersion, K as decideTelemetryConsent, L as buildAiGenerationEvents, M as isExperimentalSetting, N as FIRST_RUN_NOTICE, P as TELEMETRY_BATCH_URL, R as buildBrowserExceptionProperties, U as codexUserIdOf, V as classifySessionExit, W as decideIsDevInstall, X as resolveProjectToken, Y as parsePosthogReleaseId, _ as settingsBlockSpecFor, a as ensureProjectIds, at as sessionIdFromBranch, ct as canonicalizePath, f as DEFAULT_TIMER_FNS, g as mergeSettingsBlock, i as createConfigStore, it as planWorktreeGc, k as valueAtPath, lt as comparableDirectoryPath, n as DEFAULT_CONFIG, nt as matchedPrefix, o as generateProjectId, ot as usablePrefixes, p as unrefTimer, q as exceptionFingerprint, rt as planBranchGc, s as glimmervoidHomeDir$1, st as worktreeIntegrationTips, t as ABORT_CONFIG_SAVE, tt as DEFAULT_BRANCH_GC_PREFIXES, ut as isSameDirectoryPath, v as validateSettingsBlock, y as SETTINGS_INDEX, z as buildExceptionProperties } from "./config-store-
|
|
21
|
+
import { $ as stableConfigKey, B as buildPersonProperties, F as TELEMETRY_FLAGS_URL, G as decideRemoteTelemetryState, H as claudeAccountUuidOf, I as adapterBucket, J as nodeMajorVersion, K as decideTelemetryConsent, L as buildAiGenerationEvents, M as isExperimentalSetting, N as FIRST_RUN_NOTICE, P as TELEMETRY_BATCH_URL, R as buildBrowserExceptionProperties, U as codexUserIdOf, V as classifySessionExit, W as decideIsDevInstall, X as resolveProjectToken, Y as parsePosthogReleaseId, _ as settingsBlockSpecFor, a as ensureProjectIds, at as sessionIdFromBranch, ct as canonicalizePath, f as DEFAULT_TIMER_FNS, g as mergeSettingsBlock, i as createConfigStore, it as planWorktreeGc, k as valueAtPath, lt as comparableDirectoryPath, n as DEFAULT_CONFIG, nt as matchedPrefix, o as generateProjectId, ot as usablePrefixes, p as unrefTimer, q as exceptionFingerprint, rt as planBranchGc, s as glimmervoidHomeDir$1, st as worktreeIntegrationTips, t as ABORT_CONFIG_SAVE, tt as DEFAULT_BRANCH_GC_PREFIXES, ut as isSameDirectoryPath, v as validateSettingsBlock, y as SETTINGS_INDEX, z as buildExceptionProperties } from "./config-store-OdyfXb2W.js";
|
|
22
22
|
import { _ as TelemetryState, a as DEEP_HISTORY_SCROLLBACK_LINES, c as describeDataAttach, d as DashboardTelemetryReport, h as TELEMETRY_EVENT_SCHEMAS, i as HookEnvelope, l as parseDataAttach, m as PendingCrashReport, r as HTTP_URL_RE, s as LOGGED_FAST_CLOSE_COUNTS, u as parseDataClientMessage } from "./build-channel-K92w1xip.js";
|
|
23
23
|
import { i as resolveArgvCommandMatches } from "./kimi-DGnMgNsj.js";
|
|
24
24
|
import { $ as grokHomes, A as decideUploadType, B as containmentRefusalReason, C as parseRegistryLatest, Ct as shouldReplace, D as openContainedFile, Dt as claudeCode, E as shortSha$1, Et as HOOK_TOOLS, F as planUploadRetention, G as codexFallbackRoots, H as planContiguousRead, I as MAX_TRANSCRIPT_READ_BYTES, J as codexSessionIdFromPath, K as codexHomes, L as TRACE_TAIL_SCAN_BYTES, M as framePathPaste, N as imageMimeForUploadFilename, O as MAX_UPLOAD_BYTES, P as isSafePathSegment, Q as expandTilde, R as committedOffsetFromTraceTailOrNull, S as parseRegistryDeprecation, St as parseUsageLine, T as pickNewestPublished, Tt as vendorUsageEntry, U as resumeOffsetFrom, V as isOversizedPartialLine, W as withCommittedOffset, X as decideFileRead, Y as continuationDelayMs, Z as dedupeCodexFiles, _ as decideInstallFlavor, _t as foldReplacementIntoGenerationRollup, a as describeAgentResolvability, at as scopedClaudeRoots, b as normalizeSha, bt as mergeGenerationRollups, c as isKnownAgentId, ct as shouldPersistWarehouse, d as resolveAdapter, dt as parseKimiUsageLine, et as isUsageFile, f as setCustomAgents, ft as addEntryToTotals, g as NODE_PTY_INSTALL_SCRIPT_FLAG, gt as foldEntryIntoGenerationRollup, h as requestCodexAppServer, ht as expandAdvisorIterations, i as customAgentFingerprint, it as resolveProjectsDirs, j as exceedsUploadCap, k as buildUploadFilename, l as listAgentIds, lt as splitLines, m as readHostCodexVersion, mt as emptyTotals, n as cachedAgentResolvability, nt as passOutcome, o as getAdapter, ot as sessionsRootCandidates, p as codex, pt as dedupKeys, q as codexRootCandidates, r as commandFor, rt as projectDirCandidates, s as hookProfileOf, st as shouldEvaluateDespiteIoFailures, t as DEFAULT_AGENT_ID$1, tt as kimiHomes, u as resetCommandCache, ut as kimiDedupIdentity, v as decideUpdateStatus, vt as identityFromRelPath, w as parseResolvedSha, wt as totalTokensOf$1, x as normalizeUpdateChannel, xt as parseJsonLine, y as isCheckFresh, yt as isWithinGenerationRecencyWindow, z as completeLineBytes } from "./adapters-DIW_DqzO.js";
|
|
25
25
|
import { c as CODEX_HOME_PROFILE, l as KIMI_HOME_PROFILE } from "./agent-home-core-DgW3orTE.js";
|
|
26
26
|
import { d as releaseSessionLock, f as sessionIdOfLockFile, l as releaseUnheldAgentHomeSecrets, n as generatedAgentHomePath, p as trashSessionTempFolderOnceUnheld, s as realAgentHome, u as createHeldSessionTempFolder } from "./agent-home-BzANIIVe.js";
|
|
27
27
|
import { a as formatSshPublicKey, c as orderAgentSockets, i as commitSigningShimText, l as parseSshPublicKey, n as NO_AGENT_HOLDS_KEY, o as isForwardedAgentDirName, r as agentListsKey, s as isSignableGitObject, t as COMMIT_SIGNING_SHIM_NAME } from "./ssh-signing-core-CRhVVWNW.js";
|
|
28
|
-
import { a as defaultPairingsPath, c as decideDeviceAuth, i as createSeenStore, l as deviceNameFromUserAgent, n as configSiblingPath, o as defaultSeenPath, r as createPairingsStore, s as DEFAULT_DEVICE_MAX_AGE_MS, u as hashSecret } from "./pairings-store-
|
|
29
|
-
import { n as configFileViewOf, u as readSettingsForAgent } from "./settings-readout-core-
|
|
28
|
+
import { a as defaultPairingsPath, c as decideDeviceAuth, i as createSeenStore, l as deviceNameFromUserAgent, n as configSiblingPath, o as defaultSeenPath, r as createPairingsStore, s as DEFAULT_DEVICE_MAX_AGE_MS, u as hashSecret } from "./pairings-store-BzA3p9oE.js";
|
|
29
|
+
import { n as configFileViewOf, u as readSettingsForAgent } from "./settings-readout-core-Cc5zwF6w.js";
|
|
30
30
|
import { n as normalizeRemoteConfig, r as validateRemoteConfig, t as decideBindHost } from "./remote-config-Dcejfz01.js";
|
|
31
31
|
import { g as runGit, h as runGh, i as createCommitSessions, m as runCommand, p as gitCommandFailure, t as COMMIT_SESSIONS_FOLDER_NAME } from "./commit-sessions-T8B0plD9.js";
|
|
32
32
|
import { createRequire } from "node:module";
|
|
@@ -4124,1216 +4124,6 @@ function createBoard({ id, title, nowMs }) {
|
|
|
4124
4124
|
};
|
|
4125
4125
|
}
|
|
4126
4126
|
//#endregion
|
|
4127
|
-
//#region shared/whiteboard-layout-core.ts
|
|
4128
|
-
var MARGIN = 40;
|
|
4129
|
-
var COLUMN_HEADER_HEIGHT = 44;
|
|
4130
|
-
var COLUMN_WIDTH = 220;
|
|
4131
|
-
var COLUMN_GAP = 90;
|
|
4132
|
-
var BOX_GAP = 30;
|
|
4133
|
-
var TITLE_LINE_HEIGHT = 20;
|
|
4134
|
-
var BODY_LINE_HEIGHT = 18;
|
|
4135
|
-
var TITLE_CHARS_PER_LINE = 20;
|
|
4136
|
-
var BODY_CHARS_PER_LINE = 26;
|
|
4137
|
-
var FRAME_PADDING = 18;
|
|
4138
|
-
var FRAME_TITLE_HEIGHT = 26;
|
|
4139
|
-
var NOTE_WIDTH = 170;
|
|
4140
|
-
var NOTE_CHARS_PER_LINE = 21;
|
|
4141
|
-
var NOTE_LINE_HEIGHT = 17;
|
|
4142
|
-
var NOTE_GAP = 10;
|
|
4143
|
-
var LEGEND_ROW_HEIGHT = 22;
|
|
4144
|
-
var COLUMN_TITLE_CHARS_PER_LINE = 24;
|
|
4145
|
-
var COLUMN_TITLE_LINE_HEIGHT = 16;
|
|
4146
|
-
var COLUMN_TITLE_BASELINE = 16;
|
|
4147
|
-
var COLUMN_RULE_OFFSET = 26;
|
|
4148
|
-
var NOTE_OVERLAP = 24;
|
|
4149
|
-
var NOTE_RISE = 8;
|
|
4150
|
-
var CHANNEL_PAD = 10;
|
|
4151
|
-
var TRACK_SPACING = 14;
|
|
4152
|
-
var RUN_CLEARANCE = 4;
|
|
4153
|
-
var PORT_SPACING = 14;
|
|
4154
|
-
var PORT_INSET = 8;
|
|
4155
|
-
var GUTTER_CLEARANCE = 6;
|
|
4156
|
-
var MIN_GUTTER_HEIGHT = 4;
|
|
4157
|
-
var MIN_GUTTER_TRACK_SPACING = 6;
|
|
4158
|
-
var TOP_TRACK_SPACING = 12;
|
|
4159
|
-
var TOP_BAND_PAD = 10;
|
|
4160
|
-
var LABEL_CHAR_WIDTH = 6.6;
|
|
4161
|
-
var LABEL_GAP = 5;
|
|
4162
|
-
var LABEL_ASCENT = 10;
|
|
4163
|
-
var LABEL_CLEARANCE = 2;
|
|
4164
|
-
var BOX_CROSSING_COST = 100;
|
|
4165
|
-
var MAX_WIRES_FOR_PORT_SEARCH = 120;
|
|
4166
|
-
var MAX_ROOM_ATTEMPTS = 4;
|
|
4167
|
-
var PLAN_BAND_GAP = 40;
|
|
4168
|
-
var LABEL_SLIDE_FRACTIONS = [
|
|
4169
|
-
.5,
|
|
4170
|
-
.35,
|
|
4171
|
-
.65,
|
|
4172
|
-
.2,
|
|
4173
|
-
.8
|
|
4174
|
-
];
|
|
4175
|
-
var LANE_HEX_BY_COLOR = Object.freeze({
|
|
4176
|
-
blue: "#60a5fa",
|
|
4177
|
-
green: "#4ade80",
|
|
4178
|
-
orange: "#fb923c",
|
|
4179
|
-
pink: "#f472b6",
|
|
4180
|
-
cyan: "#22d3ee",
|
|
4181
|
-
yellow: "#facc15"
|
|
4182
|
-
});
|
|
4183
|
-
function wrapText(text, charsPerLine) {
|
|
4184
|
-
const words = text.split(/\s+/).filter(Boolean);
|
|
4185
|
-
const lines = [];
|
|
4186
|
-
let current = "";
|
|
4187
|
-
for (const word of words) {
|
|
4188
|
-
const pieces = word.match(new RegExp(`.{1,${charsPerLine}}`, "g")) ?? [word];
|
|
4189
|
-
for (const piece of pieces) {
|
|
4190
|
-
const candidate = current ? `${current} ${piece}` : piece;
|
|
4191
|
-
if (candidate.length <= charsPerLine) {
|
|
4192
|
-
current = candidate;
|
|
4193
|
-
continue;
|
|
4194
|
-
}
|
|
4195
|
-
lines.push(current);
|
|
4196
|
-
current = piece;
|
|
4197
|
-
}
|
|
4198
|
-
}
|
|
4199
|
-
if (current) lines.push(current);
|
|
4200
|
-
return lines.length > 0 ? lines : [""];
|
|
4201
|
-
}
|
|
4202
|
-
function laneOf(board, box) {
|
|
4203
|
-
const lane = board.lanes.find((candidate) => candidate.id === box.lane);
|
|
4204
|
-
if (!lane) return null;
|
|
4205
|
-
return {
|
|
4206
|
-
label: lane.label || lane.id,
|
|
4207
|
-
hex: LANE_HEX_BY_COLOR[lane.color]
|
|
4208
|
-
};
|
|
4209
|
-
}
|
|
4210
|
-
function boxShape(board, box) {
|
|
4211
|
-
const titleLines = wrapText(box.title, TITLE_CHARS_PER_LINE);
|
|
4212
|
-
const bodyLines = box.lines.flatMap((line) => wrapText(line.text, BODY_CHARS_PER_LINE - (line.muted ? 2 : 0)).map((text) => ({
|
|
4213
|
-
text,
|
|
4214
|
-
muted: line.muted
|
|
4215
|
-
})));
|
|
4216
|
-
const lane = laneOf(board, box);
|
|
4217
|
-
return {
|
|
4218
|
-
titleLines,
|
|
4219
|
-
bodyLines,
|
|
4220
|
-
lane,
|
|
4221
|
-
height: 24 + titleLines.length * TITLE_LINE_HEIGHT + bodyLines.length * BODY_LINE_HEIGHT + (lane ? 26 : 0)
|
|
4222
|
-
};
|
|
4223
|
-
}
|
|
4224
|
-
function elementsOfKind(board, kind) {
|
|
4225
|
-
return Object.values(board.elements).filter((element) => element.kind === kind);
|
|
4226
|
-
}
|
|
4227
|
-
function noteShape(note) {
|
|
4228
|
-
const lines = wrapText(note.text, NOTE_CHARS_PER_LINE);
|
|
4229
|
-
return {
|
|
4230
|
-
lines,
|
|
4231
|
-
height: 24 + (lines.length + 1) * NOTE_LINE_HEIGHT
|
|
4232
|
-
};
|
|
4233
|
-
}
|
|
4234
|
-
function noteStackHeightByBoxId(board) {
|
|
4235
|
-
const stackHeightByBoxId = /* @__PURE__ */ new Map();
|
|
4236
|
-
for (const note of elementsOfKind(board, "note")) {
|
|
4237
|
-
const stackedSoFar = stackHeightByBoxId.get(note.on);
|
|
4238
|
-
const noteHeight = noteShape(note).height;
|
|
4239
|
-
stackHeightByBoxId.set(note.on, stackedSoFar === void 0 ? noteHeight : stackedSoFar + NOTE_GAP + noteHeight);
|
|
4240
|
-
}
|
|
4241
|
-
return stackHeightByBoxId;
|
|
4242
|
-
}
|
|
4243
|
-
function columnTitleLines(board) {
|
|
4244
|
-
return board.columns.map((column) => column.title ? wrapText(column.title, COLUMN_TITLE_CHARS_PER_LINE) : []);
|
|
4245
|
-
}
|
|
4246
|
-
function headerExtraHeight(titleLinesByColumn) {
|
|
4247
|
-
return (Math.max(1, ...titleLinesByColumn.map((lines) => lines.length)) - 1) * COLUMN_TITLE_LINE_HEIGHT;
|
|
4248
|
-
}
|
|
4249
|
-
function groupedBy(items, keyOf) {
|
|
4250
|
-
const groups = /* @__PURE__ */ new Map();
|
|
4251
|
-
for (const item of items) {
|
|
4252
|
-
const key = keyOf(item);
|
|
4253
|
-
const group = groups.get(key);
|
|
4254
|
-
if (group) {
|
|
4255
|
-
group.push(item);
|
|
4256
|
-
continue;
|
|
4257
|
-
}
|
|
4258
|
-
groups.set(key, [item]);
|
|
4259
|
-
}
|
|
4260
|
-
return groups;
|
|
4261
|
-
}
|
|
4262
|
-
function gapReservesOf(board, stackHeightByBoxId) {
|
|
4263
|
-
const flowBoxes = elementsOfKind(board, "box").filter((box) => !box.at);
|
|
4264
|
-
const notedColumnIds = new Set(flowBoxes.filter((box) => stackHeightByBoxId.has(box.id)).map((box) => box.column));
|
|
4265
|
-
const framedBoxIds = new Set(elementsOfKind(board, "frame").flatMap((frame) => frame.contains));
|
|
4266
|
-
const framedColumnIds = new Set(flowBoxes.filter((box) => framedBoxIds.has(box.id)).map((box) => box.column));
|
|
4267
|
-
const sideReserve = (columnId) => CHANNEL_PAD + (columnId !== void 0 && framedColumnIds.has(columnId) ? FRAME_PADDING : 0);
|
|
4268
|
-
return board.columns.map((column, index) => {
|
|
4269
|
-
const isNoted = notedColumnIds.has(column.id);
|
|
4270
|
-
return {
|
|
4271
|
-
left: isNoted ? 156 : sideReserve(column.id),
|
|
4272
|
-
right: sideReserve(board.columns[index + 1]?.id),
|
|
4273
|
-
minimumWidth: isNoted ? Math.max(COLUMN_GAP, 186) : COLUMN_GAP
|
|
4274
|
-
};
|
|
4275
|
-
});
|
|
4276
|
-
}
|
|
4277
|
-
function gapWidthsOf(reserves, tracksByGap, labelWidthByGap) {
|
|
4278
|
-
return reserves.map((reserve, index) => {
|
|
4279
|
-
const tracks = tracksByGap[index] ?? 0;
|
|
4280
|
-
const labelWidth = labelWidthByGap[index] ?? 0;
|
|
4281
|
-
const trackNeed = tracks > 0 ? reserve.left + reserve.right + (tracks + 1) * TRACK_SPACING : 0;
|
|
4282
|
-
const labelNeed = labelWidth > 0 ? reserve.left + reserve.right + labelWidth + 20 : 0;
|
|
4283
|
-
return Math.max(reserve.minimumWidth, trackNeed, labelNeed);
|
|
4284
|
-
});
|
|
4285
|
-
}
|
|
4286
|
-
function columnLeftEdgesOf(board, gapWidths) {
|
|
4287
|
-
const columnLeftEdges = [];
|
|
4288
|
-
let nextX = MARGIN;
|
|
4289
|
-
for (const [index] of board.columns.entries()) {
|
|
4290
|
-
columnLeftEdges.push(nextX);
|
|
4291
|
-
nextX += COLUMN_WIDTH + (gapWidths[index] ?? COLUMN_GAP);
|
|
4292
|
-
}
|
|
4293
|
-
return columnLeftEdges;
|
|
4294
|
-
}
|
|
4295
|
-
function channelGapsOf(columnLeftEdges, gapWidths, reserves) {
|
|
4296
|
-
return columnLeftEdges.map((leftEdge, index) => {
|
|
4297
|
-
const reserve = reserves[index] ?? {
|
|
4298
|
-
left: CHANNEL_PAD,
|
|
4299
|
-
right: CHANNEL_PAD,
|
|
4300
|
-
minimumWidth: COLUMN_GAP
|
|
4301
|
-
};
|
|
4302
|
-
const gapRight = leftEdge + COLUMN_WIDTH + (gapWidths[index] ?? COLUMN_GAP);
|
|
4303
|
-
return {
|
|
4304
|
-
left: leftEdge + COLUMN_WIDTH + reserve.left,
|
|
4305
|
-
right: gapRight - reserve.right
|
|
4306
|
-
};
|
|
4307
|
-
});
|
|
4308
|
-
}
|
|
4309
|
-
function columnIndexOf(board, box, laidOut, columnLeftEdges) {
|
|
4310
|
-
if (!box.at) return Math.max(0, board.columns.findIndex((column) => column.id === box.column));
|
|
4311
|
-
const centerX = laidOut.x + laidOut.width / 2;
|
|
4312
|
-
const lastLeftOfCenter = columnLeftEdges.findLastIndex((leftEdge) => leftEdge <= centerX);
|
|
4313
|
-
return Math.max(0, lastLeftOfCenter);
|
|
4314
|
-
}
|
|
4315
|
-
function frameIdByBoxId(board) {
|
|
4316
|
-
const frameIds = /* @__PURE__ */ new Map();
|
|
4317
|
-
for (const frame of elementsOfKind(board, "frame")) for (const boxId of frame.contains) if (!frameIds.has(boxId)) frameIds.set(boxId, frame.id);
|
|
4318
|
-
return frameIds;
|
|
4319
|
-
}
|
|
4320
|
-
function frameClearance(previousFrameId, nextFrameId) {
|
|
4321
|
-
if (previousFrameId === nextFrameId) return 0;
|
|
4322
|
-
return (previousFrameId ? FRAME_PADDING : 0) + (nextFrameId ? 44 : 0);
|
|
4323
|
-
}
|
|
4324
|
-
function layoutBoxes(board, columnLeftEdges, boxesTop, stackHeightByBoxId) {
|
|
4325
|
-
const boxesById = /* @__PURE__ */ new Map();
|
|
4326
|
-
const nextYByColumnId = /* @__PURE__ */ new Map();
|
|
4327
|
-
const lastFrameIdByColumnId = /* @__PURE__ */ new Map();
|
|
4328
|
-
const frameIds = frameIdByBoxId(board);
|
|
4329
|
-
const boxes = elementsOfKind(board, "box").map((box, index) => ({
|
|
4330
|
-
box,
|
|
4331
|
-
index
|
|
4332
|
-
})).sort((left, right) => left.box.order - right.box.order || left.index - right.index);
|
|
4333
|
-
for (const { box } of boxes) {
|
|
4334
|
-
const columnIndex = Math.max(0, board.columns.findIndex((column) => column.id === box.column));
|
|
4335
|
-
const shape = boxShape(board, box);
|
|
4336
|
-
const frameId = frameIds.get(box.id) ?? null;
|
|
4337
|
-
const flowY = (nextYByColumnId.get(box.column) ?? boxesTop) + frameClearance(lastFrameIdByColumnId.get(box.column) ?? null, frameId);
|
|
4338
|
-
const position = box.at ?? {
|
|
4339
|
-
x: columnLeftEdges[columnIndex] ?? MARGIN,
|
|
4340
|
-
y: flowY
|
|
4341
|
-
};
|
|
4342
|
-
if (!box.at) {
|
|
4343
|
-
const noteStackBottom = (stackHeightByBoxId.get(box.id) ?? 0) - NOTE_RISE;
|
|
4344
|
-
nextYByColumnId.set(box.column, flowY + Math.max(shape.height, noteStackBottom) + BOX_GAP);
|
|
4345
|
-
lastFrameIdByColumnId.set(box.column, frameId);
|
|
4346
|
-
}
|
|
4347
|
-
boxesById.set(box.id, {
|
|
4348
|
-
kind: "box",
|
|
4349
|
-
id: box.id,
|
|
4350
|
-
x: position.x,
|
|
4351
|
-
y: position.y,
|
|
4352
|
-
width: COLUMN_WIDTH,
|
|
4353
|
-
height: shape.height,
|
|
4354
|
-
titleLines: shape.titleLines,
|
|
4355
|
-
bodyLines: shape.bodyLines,
|
|
4356
|
-
lane: shape.lane,
|
|
4357
|
-
isGhost: box.ghost
|
|
4358
|
-
});
|
|
4359
|
-
}
|
|
4360
|
-
return boxesById;
|
|
4361
|
-
}
|
|
4362
|
-
function unionOf(rects) {
|
|
4363
|
-
if (rects.length === 0) return null;
|
|
4364
|
-
const left = Math.min(...rects.map((rect) => rect.x));
|
|
4365
|
-
const top = Math.min(...rects.map((rect) => rect.y));
|
|
4366
|
-
const right = Math.max(...rects.map((rect) => rect.x + rect.width));
|
|
4367
|
-
const bottom = Math.max(...rects.map((rect) => rect.y + rect.height));
|
|
4368
|
-
return {
|
|
4369
|
-
x: left,
|
|
4370
|
-
y: top,
|
|
4371
|
-
width: right - left,
|
|
4372
|
-
height: bottom - top
|
|
4373
|
-
};
|
|
4374
|
-
}
|
|
4375
|
-
function layoutFrames(board, boxesById) {
|
|
4376
|
-
return elementsOfKind(board, "frame").flatMap((frame) => {
|
|
4377
|
-
const around = unionOf(frame.contains.flatMap((id) => boxesById.get(id) ?? []));
|
|
4378
|
-
if (!around) return [];
|
|
4379
|
-
return [{
|
|
4380
|
-
kind: "frame",
|
|
4381
|
-
id: frame.id,
|
|
4382
|
-
title: frame.title,
|
|
4383
|
-
x: around.x - FRAME_PADDING,
|
|
4384
|
-
y: around.y - FRAME_PADDING - FRAME_TITLE_HEIGHT,
|
|
4385
|
-
width: around.width + 36,
|
|
4386
|
-
height: around.height + 36 + FRAME_TITLE_HEIGHT
|
|
4387
|
-
}];
|
|
4388
|
-
});
|
|
4389
|
-
}
|
|
4390
|
-
function isSideways(side) {
|
|
4391
|
-
return side === "left" || side === "right";
|
|
4392
|
-
}
|
|
4393
|
-
function centerOf(rect) {
|
|
4394
|
-
return {
|
|
4395
|
-
x: rect.x + rect.width / 2,
|
|
4396
|
-
y: rect.y + rect.height / 2
|
|
4397
|
-
};
|
|
4398
|
-
}
|
|
4399
|
-
function hasBoxBetweenInColumn(from, to, columnIndex, input) {
|
|
4400
|
-
const upper = from.y < to.y ? from : to;
|
|
4401
|
-
const lower = upper === from ? to : from;
|
|
4402
|
-
return [...input.boxesById.values()].some((box) => box.id !== from.id && box.id !== to.id && input.columnIndexByBoxId.get(box.id) === columnIndex && box.y < lower.y && box.y + box.height > upper.y + upper.height);
|
|
4403
|
-
}
|
|
4404
|
-
function shapeOf(from, to, input) {
|
|
4405
|
-
const fromColumn = input.columnIndexByBoxId.get(from.id) ?? 0;
|
|
4406
|
-
const toColumn = input.columnIndexByBoxId.get(to.id) ?? 0;
|
|
4407
|
-
if (fromColumn === toColumn) {
|
|
4408
|
-
if (from.id !== to.id && !hasBoxBetweenInColumn(from, to, fromColumn, input)) {
|
|
4409
|
-
const isDownward = to.y > from.y;
|
|
4410
|
-
return {
|
|
4411
|
-
shape: "straight",
|
|
4412
|
-
exitSide: isDownward ? "bottom" : "top",
|
|
4413
|
-
entrySide: isDownward ? "top" : "bottom",
|
|
4414
|
-
sourceGap: -1,
|
|
4415
|
-
targetGap: -1
|
|
4416
|
-
};
|
|
4417
|
-
}
|
|
4418
|
-
return {
|
|
4419
|
-
shape: "channel",
|
|
4420
|
-
exitSide: "right",
|
|
4421
|
-
entrySide: "right",
|
|
4422
|
-
sourceGap: fromColumn,
|
|
4423
|
-
targetGap: fromColumn
|
|
4424
|
-
};
|
|
4425
|
-
}
|
|
4426
|
-
if (toColumn > fromColumn) return {
|
|
4427
|
-
shape: toColumn === fromColumn + 1 ? "channel" : "long",
|
|
4428
|
-
exitSide: "right",
|
|
4429
|
-
entrySide: "left",
|
|
4430
|
-
sourceGap: fromColumn,
|
|
4431
|
-
targetGap: toColumn - 1
|
|
4432
|
-
};
|
|
4433
|
-
return {
|
|
4434
|
-
shape: toColumn === fromColumn - 1 ? "channel" : "long",
|
|
4435
|
-
exitSide: "left",
|
|
4436
|
-
entrySide: "right",
|
|
4437
|
-
sourceGap: fromColumn - 1,
|
|
4438
|
-
targetGap: toColumn
|
|
4439
|
-
};
|
|
4440
|
-
}
|
|
4441
|
-
function planWires(input) {
|
|
4442
|
-
const plans = input.wires.flatMap((wire) => {
|
|
4443
|
-
const from = input.boxesById.get(wire.from);
|
|
4444
|
-
const to = input.boxesById.get(wire.to);
|
|
4445
|
-
if (!from || !to) return [];
|
|
4446
|
-
const strokeHex = wire.tone === "lane" ? from.lane?.hex ?? null : null;
|
|
4447
|
-
const origin = centerOf(from);
|
|
4448
|
-
return [{
|
|
4449
|
-
wire,
|
|
4450
|
-
from,
|
|
4451
|
-
to,
|
|
4452
|
-
strokeHex,
|
|
4453
|
-
styleKey: `${wire.dashed}|${wire.tone}|${strokeHex}`,
|
|
4454
|
-
...shapeOf(from, to, input),
|
|
4455
|
-
busKey: null,
|
|
4456
|
-
start: origin,
|
|
4457
|
-
end: centerOf(to),
|
|
4458
|
-
crossingY: origin.y
|
|
4459
|
-
}];
|
|
4460
|
-
});
|
|
4461
|
-
const memberCountByBusKey = /* @__PURE__ */ new Map();
|
|
4462
|
-
const busKeyOf = (plan) => `${plan.to.id}|${plan.entrySide}|${plan.styleKey}`;
|
|
4463
|
-
for (const plan of plans) {
|
|
4464
|
-
if (plan.shape === "straight") continue;
|
|
4465
|
-
memberCountByBusKey.set(busKeyOf(plan), (memberCountByBusKey.get(busKeyOf(plan)) ?? 0) + 1);
|
|
4466
|
-
}
|
|
4467
|
-
for (const plan of plans) if (plan.shape !== "straight" && (memberCountByBusKey.get(busKeyOf(plan)) ?? 0) > 1) plan.busKey = busKeyOf(plan);
|
|
4468
|
-
return plans;
|
|
4469
|
-
}
|
|
4470
|
-
function portPositions(box, side, count) {
|
|
4471
|
-
const indexes = Array.from({ length: count }, (_, index) => index);
|
|
4472
|
-
if (isSideways(side)) {
|
|
4473
|
-
const x = side === "left" ? box.x : box.x + box.width;
|
|
4474
|
-
const spacing = Math.min(PORT_SPACING, (box.height - 16) / Math.max(count - 1, 1));
|
|
4475
|
-
const centeredFirstY = box.y + Math.min(box.height / 2, 40) - (count - 1) * spacing / 2;
|
|
4476
|
-
const firstY = Math.max(box.y + PORT_INSET, Math.min(centeredFirstY, box.y + box.height - PORT_INSET - (count - 1) * spacing));
|
|
4477
|
-
return indexes.map((index) => ({
|
|
4478
|
-
x,
|
|
4479
|
-
y: Math.round(firstY + index * spacing)
|
|
4480
|
-
}));
|
|
4481
|
-
}
|
|
4482
|
-
const y = side === "top" ? box.y : box.y + box.height;
|
|
4483
|
-
const firstX = box.x + box.width / 2 - (count - 1) * PORT_SPACING / 2;
|
|
4484
|
-
return indexes.map((index) => ({
|
|
4485
|
-
x: Math.round(firstX + index * PORT_SPACING),
|
|
4486
|
-
y
|
|
4487
|
-
}));
|
|
4488
|
-
}
|
|
4489
|
-
function portRequestsBySide(plans) {
|
|
4490
|
-
return groupedBy(plans.flatMap((plan) => [{
|
|
4491
|
-
box: plan.from,
|
|
4492
|
-
side: plan.exitSide,
|
|
4493
|
-
groupKey: `exit|${plan.styleKey}`,
|
|
4494
|
-
wireId: plan.wire.id,
|
|
4495
|
-
farPoint: centerOf(plan.to),
|
|
4496
|
-
assign: (point) => {
|
|
4497
|
-
plan.start = point;
|
|
4498
|
-
}
|
|
4499
|
-
}, {
|
|
4500
|
-
box: plan.to,
|
|
4501
|
-
side: plan.entrySide,
|
|
4502
|
-
groupKey: plan.busKey ? `bus|${plan.busKey}` : `entry|${plan.wire.id}`,
|
|
4503
|
-
wireId: plan.wire.id,
|
|
4504
|
-
farPoint: centerOf(plan.from),
|
|
4505
|
-
assign: (point) => {
|
|
4506
|
-
plan.end = point;
|
|
4507
|
-
}
|
|
4508
|
-
}]), (request) => `${request.box.id}|${request.side}`);
|
|
4509
|
-
}
|
|
4510
|
-
function defaultPortOrders(requestsBySide) {
|
|
4511
|
-
return new Map([...requestsBySide.entries()].map(([sideKey, sideRequests]) => {
|
|
4512
|
-
return [sideKey, [...groupedBy(sideRequests, (request) => request.groupKey).entries()].map(([groupKey, members]) => ({
|
|
4513
|
-
groupKey,
|
|
4514
|
-
firstWireId: members.map((member) => member.wireId).sort()[0] ?? groupKey,
|
|
4515
|
-
farCoordinate: members.reduce((sum, member) => sum + (isSideways(member.side) ? member.farPoint.y : member.farPoint.x), 0) / members.length
|
|
4516
|
-
})).sort((left, right) => left.farCoordinate - right.farCoordinate || left.firstWireId.localeCompare(right.firstWireId) || left.groupKey.localeCompare(right.groupKey)).map((group) => group.groupKey)];
|
|
4517
|
-
}));
|
|
4518
|
-
}
|
|
4519
|
-
function assignPorts(requestsBySide, groupOrderBySide) {
|
|
4520
|
-
for (const [sideKey, sideRequests] of requestsBySide) {
|
|
4521
|
-
const first = sideRequests[0];
|
|
4522
|
-
const groupOrder = groupOrderBySide.get(sideKey) ?? [];
|
|
4523
|
-
if (!first) continue;
|
|
4524
|
-
const positions = portPositions(first.box, first.side, groupOrder.length);
|
|
4525
|
-
for (const request of sideRequests) {
|
|
4526
|
-
const position = positions[groupOrder.indexOf(request.groupKey)];
|
|
4527
|
-
if (position) request.assign(position);
|
|
4528
|
-
}
|
|
4529
|
-
}
|
|
4530
|
-
}
|
|
4531
|
-
function crossedSpanOf(plan, gaps) {
|
|
4532
|
-
const sourceGap = gaps[plan.sourceGap] ?? {
|
|
4533
|
-
left: plan.start.x,
|
|
4534
|
-
right: plan.start.x
|
|
4535
|
-
};
|
|
4536
|
-
const targetGap = gaps[plan.targetGap] ?? {
|
|
4537
|
-
left: plan.end.x,
|
|
4538
|
-
right: plan.end.x
|
|
4539
|
-
};
|
|
4540
|
-
return {
|
|
4541
|
-
left: Math.min(sourceGap.left, targetGap.left),
|
|
4542
|
-
right: Math.max(sourceGap.right, targetGap.right)
|
|
4543
|
-
};
|
|
4544
|
-
}
|
|
4545
|
-
function blockersAcross(plan, span, input) {
|
|
4546
|
-
return [...[...input.boxesById.values()].filter((box) => box.id !== plan.from.id && box.id !== plan.to.id), ...input.obstacles].filter((rect) => rect.x < span.right && rect.x + rect.width > span.left);
|
|
4547
|
-
}
|
|
4548
|
-
function isClearRowAt(y, blockers) {
|
|
4549
|
-
return !blockers.some((rect) => y > rect.y - GUTTER_CLEARANCE && y < rect.y + rect.height + GUTTER_CLEARANCE);
|
|
4550
|
-
}
|
|
4551
|
-
function gutterIntervalsBetween(blockers) {
|
|
4552
|
-
const blocked = blockers.map((rect) => ({
|
|
4553
|
-
top: rect.y - GUTTER_CLEARANCE,
|
|
4554
|
-
bottom: rect.y + rect.height + GUTTER_CLEARANCE
|
|
4555
|
-
})).sort((left, right) => left.top - right.top);
|
|
4556
|
-
const merged = [];
|
|
4557
|
-
for (const interval of blocked) {
|
|
4558
|
-
const last = merged.at(-1);
|
|
4559
|
-
if (last && interval.top <= last.bottom) {
|
|
4560
|
-
last.bottom = Math.max(last.bottom, interval.bottom);
|
|
4561
|
-
continue;
|
|
4562
|
-
}
|
|
4563
|
-
merged.push({ ...interval });
|
|
4564
|
-
}
|
|
4565
|
-
return merged.slice(1).flatMap((interval, index) => {
|
|
4566
|
-
const above = merged[index];
|
|
4567
|
-
if (!above || interval.top - above.bottom < MIN_GUTTER_HEIGHT) return [];
|
|
4568
|
-
return [{
|
|
4569
|
-
top: above.bottom,
|
|
4570
|
-
bottom: interval.top
|
|
4571
|
-
}];
|
|
4572
|
-
});
|
|
4573
|
-
}
|
|
4574
|
-
function overlapsSpan(first, second) {
|
|
4575
|
-
return first.left < second.right && second.left < first.right;
|
|
4576
|
-
}
|
|
4577
|
-
function stackedTracks(items, overlaps) {
|
|
4578
|
-
const tracks = [];
|
|
4579
|
-
items.forEach((item, index) => {
|
|
4580
|
-
const earlierTracks = items.slice(0, index).flatMap((earlier, earlierIndex) => overlaps(item, earlier) ? [tracks[earlierIndex] ?? 0] : []);
|
|
4581
|
-
tracks.push(earlierTracks.length > 0 ? Math.max(...earlierTracks) + 1 : 0);
|
|
4582
|
-
});
|
|
4583
|
-
return tracks;
|
|
4584
|
-
}
|
|
4585
|
-
function assignCrossings(plans, input) {
|
|
4586
|
-
const claims = [];
|
|
4587
|
-
const topBandPlans = [];
|
|
4588
|
-
for (const plan of plans) {
|
|
4589
|
-
if (plan.shape !== "long") continue;
|
|
4590
|
-
const span = crossedSpanOf(plan, input.gaps);
|
|
4591
|
-
const blockers = blockersAcross(plan, span, input);
|
|
4592
|
-
const clearPortY = [plan.start.y, plan.end.y].find((y) => isClearRowAt(y, blockers));
|
|
4593
|
-
if (clearPortY !== void 0) {
|
|
4594
|
-
plan.crossingY = clearPortY;
|
|
4595
|
-
continue;
|
|
4596
|
-
}
|
|
4597
|
-
const middleY = (plan.start.y + plan.end.y) / 2;
|
|
4598
|
-
const nearestGutter = gutterIntervalsBetween(blockers).sort((left, right) => Math.abs((left.top + left.bottom) / 2 - middleY) - Math.abs((right.top + right.bottom) / 2 - middleY))[0];
|
|
4599
|
-
if (nearestGutter) {
|
|
4600
|
-
claims.push({
|
|
4601
|
-
plan,
|
|
4602
|
-
interval: nearestGutter,
|
|
4603
|
-
span
|
|
4604
|
-
});
|
|
4605
|
-
continue;
|
|
4606
|
-
}
|
|
4607
|
-
topBandPlans.push({
|
|
4608
|
-
plan,
|
|
4609
|
-
span
|
|
4610
|
-
});
|
|
4611
|
-
}
|
|
4612
|
-
const claimsByInterval = groupedBy(claims, (claim) => `${Math.round(claim.interval.top)}|${Math.round(claim.interval.bottom)}`);
|
|
4613
|
-
for (const intervalClaims of claimsByInterval.values()) {
|
|
4614
|
-
const ordered = [...intervalClaims].sort((left, right) => left.plan.start.y - right.plan.start.y || left.plan.wire.id.localeCompare(right.plan.wire.id));
|
|
4615
|
-
const tracks = stackedTracks(ordered, (first, second) => overlapsSpan(first.span, second.span));
|
|
4616
|
-
const interval = ordered[0]?.interval ?? {
|
|
4617
|
-
top: 0,
|
|
4618
|
-
bottom: 0
|
|
4619
|
-
};
|
|
4620
|
-
const height = interval.bottom - interval.top;
|
|
4621
|
-
const capacity = Math.max(1, Math.floor(height / MIN_GUTTER_TRACK_SPACING) - 1);
|
|
4622
|
-
const trackCount = Math.min(capacity, Math.max(...tracks) + 1);
|
|
4623
|
-
ordered.forEach((claim, index) => {
|
|
4624
|
-
const track = tracks[index] ?? 0;
|
|
4625
|
-
if (track >= capacity) {
|
|
4626
|
-
topBandPlans.push({
|
|
4627
|
-
plan: claim.plan,
|
|
4628
|
-
span: claim.span
|
|
4629
|
-
});
|
|
4630
|
-
return;
|
|
4631
|
-
}
|
|
4632
|
-
claim.plan.crossingY = Math.round(interval.top + height * (track + 1) / (trackCount + 1));
|
|
4633
|
-
});
|
|
4634
|
-
}
|
|
4635
|
-
const outermostFirst = [...topBandPlans].sort((left, right) => right.span.right - right.span.left - (left.span.right - left.span.left) || left.plan.wire.id.localeCompare(right.plan.wire.id));
|
|
4636
|
-
const topTracks = stackedTracks(outermostFirst, (first, second) => overlapsSpan(first.span, second.span)).map((track) => outermostFirst.length - 1 - track);
|
|
4637
|
-
outermostFirst.forEach(({ plan }, index) => {
|
|
4638
|
-
plan.crossingY = input.topBandBottom - (topTracks[index] ?? 0) * TOP_TRACK_SPACING;
|
|
4639
|
-
});
|
|
4640
|
-
return topBandPlans.length > 0 ? Math.max(...topTracks) + 1 : 0;
|
|
4641
|
-
}
|
|
4642
|
-
function attachmentSideFor(gap, columnIndex) {
|
|
4643
|
-
return columnIndex <= gap ? "left" : "right";
|
|
4644
|
-
}
|
|
4645
|
-
function newRun(key, gap) {
|
|
4646
|
-
return {
|
|
4647
|
-
key,
|
|
4648
|
-
gap,
|
|
4649
|
-
top: Infinity,
|
|
4650
|
-
bottom: -Infinity,
|
|
4651
|
-
leftYs: [],
|
|
4652
|
-
rightYs: [],
|
|
4653
|
-
track: -1,
|
|
4654
|
-
x: 0
|
|
4655
|
-
};
|
|
4656
|
-
}
|
|
4657
|
-
function attach(run, side, y) {
|
|
4658
|
-
(side === "left" ? run.leftYs : run.rightYs).push(y);
|
|
4659
|
-
run.top = Math.min(run.top, y);
|
|
4660
|
-
run.bottom = Math.max(run.bottom, y);
|
|
4661
|
-
}
|
|
4662
|
-
function targetRunKey(plan) {
|
|
4663
|
-
return plan.busKey ? `bus|${plan.busKey}` : `wire|${plan.wire.id}|target`;
|
|
4664
|
-
}
|
|
4665
|
-
function buildRuns(plans, input) {
|
|
4666
|
-
const runsByKey = /* @__PURE__ */ new Map();
|
|
4667
|
-
const runFor = (key, gap) => {
|
|
4668
|
-
const existing = runsByKey.get(key);
|
|
4669
|
-
if (existing) return existing;
|
|
4670
|
-
const created = newRun(key, gap);
|
|
4671
|
-
runsByKey.set(key, created);
|
|
4672
|
-
return created;
|
|
4673
|
-
};
|
|
4674
|
-
const enteredRunKeys = /* @__PURE__ */ new Set();
|
|
4675
|
-
for (const plan of plans) {
|
|
4676
|
-
if (plan.shape === "straight") continue;
|
|
4677
|
-
const fromColumn = input.columnIndexByBoxId.get(plan.from.id) ?? 0;
|
|
4678
|
-
const toColumn = input.columnIndexByBoxId.get(plan.to.id) ?? 0;
|
|
4679
|
-
const isForward = plan.exitSide === "right" && plan.entrySide === "left";
|
|
4680
|
-
const targetRun = runFor(targetRunKey(plan), plan.targetGap);
|
|
4681
|
-
if (plan.shape === "channel") attach(targetRun, attachmentSideFor(plan.targetGap, fromColumn), plan.start.y);
|
|
4682
|
-
if (plan.shape === "long") {
|
|
4683
|
-
const sourceRun = runFor(`wire|${plan.wire.id}|source`, plan.sourceGap);
|
|
4684
|
-
attach(sourceRun, attachmentSideFor(plan.sourceGap, fromColumn), plan.start.y);
|
|
4685
|
-
attach(sourceRun, isForward ? "right" : "left", plan.crossingY);
|
|
4686
|
-
attach(targetRun, isForward ? "left" : "right", plan.crossingY);
|
|
4687
|
-
}
|
|
4688
|
-
if (enteredRunKeys.has(targetRun.key)) continue;
|
|
4689
|
-
enteredRunKeys.add(targetRun.key);
|
|
4690
|
-
attach(targetRun, attachmentSideFor(plan.targetGap, toColumn), plan.end.y);
|
|
4691
|
-
}
|
|
4692
|
-
return runsByKey;
|
|
4693
|
-
}
|
|
4694
|
-
function countInside(ys, run) {
|
|
4695
|
-
return ys.filter((y) => y > run.top && y < run.bottom).length;
|
|
4696
|
-
}
|
|
4697
|
-
function crossingsWhenLeftOf(leftRun, rightRun) {
|
|
4698
|
-
return countInside(rightRun.leftYs, leftRun) + countInside(leftRun.rightYs, rightRun);
|
|
4699
|
-
}
|
|
4700
|
-
function placeTracks(runsByKey, gaps) {
|
|
4701
|
-
const tracksByGap = gaps.map(() => 0);
|
|
4702
|
-
const runsByGap = groupedBy([...runsByKey.values()].filter((run) => run.bottom > run.top), (run) => run.gap);
|
|
4703
|
-
for (const [gapIndex, gapRuns] of runsByGap) {
|
|
4704
|
-
const ordered = [...gapRuns].sort((first, second) => crossingsWhenLeftOf(first, second) - crossingsWhenLeftOf(second, first) || first.top - second.top || first.key.localeCompare(second.key));
|
|
4705
|
-
const tracks = stackedTracks(ordered, (first, second) => first.top < second.bottom + RUN_CLEARANCE && second.top < first.bottom + RUN_CLEARANCE);
|
|
4706
|
-
const trackCount = Math.max(...tracks) + 1;
|
|
4707
|
-
tracksByGap[gapIndex] = trackCount;
|
|
4708
|
-
const gap = gaps[gapIndex] ?? {
|
|
4709
|
-
left: 0,
|
|
4710
|
-
right: 0
|
|
4711
|
-
};
|
|
4712
|
-
ordered.forEach((run, index) => {
|
|
4713
|
-
run.track = tracks[index] ?? 0;
|
|
4714
|
-
run.x = Math.round(gap.left + (gap.right - gap.left) * (run.track + 1) / (trackCount + 1));
|
|
4715
|
-
});
|
|
4716
|
-
}
|
|
4717
|
-
for (const run of runsByKey.values()) {
|
|
4718
|
-
if (run.track >= 0) continue;
|
|
4719
|
-
const gap = gaps[run.gap] ?? {
|
|
4720
|
-
left: 0,
|
|
4721
|
-
right: 0
|
|
4722
|
-
};
|
|
4723
|
-
run.x = Math.round((gap.left + gap.right) / 2);
|
|
4724
|
-
}
|
|
4725
|
-
return tracksByGap;
|
|
4726
|
-
}
|
|
4727
|
-
function withoutBends(points) {
|
|
4728
|
-
const distinct = points.filter((point, index) => {
|
|
4729
|
-
const previous = points[index - 1];
|
|
4730
|
-
return !previous || previous.x !== point.x || previous.y !== point.y;
|
|
4731
|
-
});
|
|
4732
|
-
return distinct.filter((point, index) => {
|
|
4733
|
-
const previous = distinct[index - 1];
|
|
4734
|
-
const next = distinct[index + 1];
|
|
4735
|
-
if (!previous || !next) return true;
|
|
4736
|
-
return !(previous.x === point.x && point.x === next.x || previous.y === point.y && point.y === next.y);
|
|
4737
|
-
});
|
|
4738
|
-
}
|
|
4739
|
-
function segmentsOf(points) {
|
|
4740
|
-
return points.slice(1).flatMap((point, index) => {
|
|
4741
|
-
const previous = points[index];
|
|
4742
|
-
return previous ? [{
|
|
4743
|
-
from: previous,
|
|
4744
|
-
to: point
|
|
4745
|
-
}] : [];
|
|
4746
|
-
});
|
|
4747
|
-
}
|
|
4748
|
-
function straightPoints(plan) {
|
|
4749
|
-
if (plan.start.x === plan.end.x) return [plan.start, plan.end];
|
|
4750
|
-
const middleY = Math.round((plan.start.y + plan.end.y) / 2);
|
|
4751
|
-
return [
|
|
4752
|
-
plan.start,
|
|
4753
|
-
{
|
|
4754
|
-
x: plan.start.x,
|
|
4755
|
-
y: middleY
|
|
4756
|
-
},
|
|
4757
|
-
{
|
|
4758
|
-
x: plan.end.x,
|
|
4759
|
-
y: middleY
|
|
4760
|
-
},
|
|
4761
|
-
plan.end
|
|
4762
|
-
];
|
|
4763
|
-
}
|
|
4764
|
-
function routedPoints(plan, runsByKey) {
|
|
4765
|
-
if (plan.shape === "straight") return straightPoints(plan);
|
|
4766
|
-
const targetX = runsByKey.get(targetRunKey(plan))?.x ?? plan.end.x;
|
|
4767
|
-
const arrivalY = plan.shape === "long" ? plan.crossingY : plan.start.y;
|
|
4768
|
-
const sourceX = runsByKey.get(`wire|${plan.wire.id}|source`)?.x ?? targetX;
|
|
4769
|
-
const approach = plan.shape === "long" ? [
|
|
4770
|
-
plan.start,
|
|
4771
|
-
{
|
|
4772
|
-
x: sourceX,
|
|
4773
|
-
y: plan.start.y
|
|
4774
|
-
},
|
|
4775
|
-
{
|
|
4776
|
-
x: sourceX,
|
|
4777
|
-
y: arrivalY
|
|
4778
|
-
},
|
|
4779
|
-
{
|
|
4780
|
-
x: targetX,
|
|
4781
|
-
y: arrivalY
|
|
4782
|
-
}
|
|
4783
|
-
] : [plan.start, {
|
|
4784
|
-
x: targetX,
|
|
4785
|
-
y: arrivalY
|
|
4786
|
-
}];
|
|
4787
|
-
if (plan.busKey) return approach;
|
|
4788
|
-
return [
|
|
4789
|
-
...approach,
|
|
4790
|
-
{
|
|
4791
|
-
x: targetX,
|
|
4792
|
-
y: plan.end.y
|
|
4793
|
-
},
|
|
4794
|
-
plan.end
|
|
4795
|
-
];
|
|
4796
|
-
}
|
|
4797
|
-
function pathOf(points) {
|
|
4798
|
-
return points.map((point, index) => `${index === 0 ? "M" : "L"} ${point.x} ${point.y}`).join(" ");
|
|
4799
|
-
}
|
|
4800
|
-
function drawWires(plans, runsByKey) {
|
|
4801
|
-
const leadIdByBusKey = /* @__PURE__ */ new Map();
|
|
4802
|
-
for (const plan of [...plans].sort((left, right) => left.wire.id.localeCompare(right.wire.id))) if (plan.busKey && !leadIdByBusKey.has(plan.busKey)) leadIdByBusKey.set(plan.busKey, plan.wire.id);
|
|
4803
|
-
return plans.map((plan) => {
|
|
4804
|
-
const points = withoutBends(routedPoints(plan, runsByKey));
|
|
4805
|
-
const trunkRun = plan.busKey ? runsByKey.get(targetRunKey(plan)) : void 0;
|
|
4806
|
-
const isLead = plan.busKey !== null && leadIdByBusKey.get(plan.busKey) === plan.wire.id;
|
|
4807
|
-
const trunk = trunkRun && isLead ? [{
|
|
4808
|
-
from: {
|
|
4809
|
-
x: trunkRun.x,
|
|
4810
|
-
y: trunkRun.top
|
|
4811
|
-
},
|
|
4812
|
-
to: {
|
|
4813
|
-
x: trunkRun.x,
|
|
4814
|
-
y: trunkRun.bottom
|
|
4815
|
-
}
|
|
4816
|
-
}, {
|
|
4817
|
-
from: {
|
|
4818
|
-
x: trunkRun.x,
|
|
4819
|
-
y: plan.end.y
|
|
4820
|
-
},
|
|
4821
|
-
to: plan.end
|
|
4822
|
-
}].filter((segment) => segment.from.x !== segment.to.x || segment.from.y !== segment.to.y) : [];
|
|
4823
|
-
return {
|
|
4824
|
-
plan,
|
|
4825
|
-
points,
|
|
4826
|
-
trunk,
|
|
4827
|
-
segments: [...segmentsOf(points), ...trunk]
|
|
4828
|
-
};
|
|
4829
|
-
});
|
|
4830
|
-
}
|
|
4831
|
-
function isHorizontal(segment) {
|
|
4832
|
-
return segment.from.y === segment.to.y;
|
|
4833
|
-
}
|
|
4834
|
-
function segmentHitsRect(segment, rect) {
|
|
4835
|
-
const right = rect.x + rect.width;
|
|
4836
|
-
const bottom = rect.y + rect.height;
|
|
4837
|
-
if (isHorizontal(segment)) {
|
|
4838
|
-
const y = segment.from.y;
|
|
4839
|
-
return rect.y < y && y < bottom && Math.min(segment.from.x, segment.to.x) < right && Math.max(segment.from.x, segment.to.x) > rect.x;
|
|
4840
|
-
}
|
|
4841
|
-
const x = segment.from.x;
|
|
4842
|
-
return rect.x < x && x < right && Math.min(segment.from.y, segment.to.y) < bottom && Math.max(segment.from.y, segment.to.y) > rect.y;
|
|
4843
|
-
}
|
|
4844
|
-
function rectsOverlap(first, second) {
|
|
4845
|
-
return first.x < second.x + second.width && second.x < first.x + first.width && first.y < second.y + second.height && second.y < first.y + first.height;
|
|
4846
|
-
}
|
|
4847
|
-
function labelWidthOf(label) {
|
|
4848
|
-
return Math.ceil(label.length * LABEL_CHAR_WIDTH);
|
|
4849
|
-
}
|
|
4850
|
-
function labelBoundsAt(baseline, width) {
|
|
4851
|
-
return {
|
|
4852
|
-
x: baseline.x - width / 2,
|
|
4853
|
-
y: baseline.y - LABEL_ASCENT,
|
|
4854
|
-
width,
|
|
4855
|
-
height: 13
|
|
4856
|
-
};
|
|
4857
|
-
}
|
|
4858
|
-
function segmentLength(segment) {
|
|
4859
|
-
return Math.abs(segment.from.x - segment.to.x) + Math.abs(segment.from.y - segment.to.y);
|
|
4860
|
-
}
|
|
4861
|
-
function labelCandidates(segments, width) {
|
|
4862
|
-
const byLength = [...segments].sort((left, right) => segmentLength(right) - segmentLength(left));
|
|
4863
|
-
return [...segments.slice(0, 1), ...byLength].flatMap((segment) => [...LABEL_SLIDE_FRACTIONS.flatMap((fraction) => {
|
|
4864
|
-
const x = segment.from.x + (segment.to.x - segment.from.x) * fraction;
|
|
4865
|
-
const y = segment.from.y + (segment.to.y - segment.from.y) * fraction;
|
|
4866
|
-
if (isHorizontal(segment)) return [{
|
|
4867
|
-
x,
|
|
4868
|
-
y: y - LABEL_GAP
|
|
4869
|
-
}, {
|
|
4870
|
-
x,
|
|
4871
|
-
y: y + LABEL_GAP + LABEL_ASCENT
|
|
4872
|
-
}];
|
|
4873
|
-
return [{
|
|
4874
|
-
x: x + LABEL_GAP + width / 2,
|
|
4875
|
-
y: y + LABEL_ASCENT / 2
|
|
4876
|
-
}, {
|
|
4877
|
-
x: x - LABEL_GAP - width / 2,
|
|
4878
|
-
y: y + LABEL_ASCENT / 2
|
|
4879
|
-
}];
|
|
4880
|
-
}), ...flushLabelCandidates(segment, width)]);
|
|
4881
|
-
}
|
|
4882
|
-
function flushLabelCandidates(segment, width) {
|
|
4883
|
-
if (!isHorizontal(segment)) return [];
|
|
4884
|
-
const y = segment.from.y;
|
|
4885
|
-
return [Math.min(segment.from.x, segment.to.x) + LABEL_GAP + width / 2, Math.max(segment.from.x, segment.to.x) - LABEL_GAP - width / 2].flatMap((x) => [{
|
|
4886
|
-
x,
|
|
4887
|
-
y: y - LABEL_GAP
|
|
4888
|
-
}, {
|
|
4889
|
-
x,
|
|
4890
|
-
y: y + LABEL_GAP + LABEL_ASCENT
|
|
4891
|
-
}]);
|
|
4892
|
-
}
|
|
4893
|
-
function inflated(rect, by) {
|
|
4894
|
-
return {
|
|
4895
|
-
x: rect.x - by,
|
|
4896
|
-
y: rect.y - by,
|
|
4897
|
-
width: rect.width + by * 2,
|
|
4898
|
-
height: rect.height + by * 2
|
|
4899
|
-
};
|
|
4900
|
-
}
|
|
4901
|
-
function placeLabels(drawn, input, warnings) {
|
|
4902
|
-
const placedById = /* @__PURE__ */ new Map();
|
|
4903
|
-
const allSegments = drawn.flatMap((wire) => wire.segments);
|
|
4904
|
-
const solids = [...input.boxesById.values(), ...input.obstacles];
|
|
4905
|
-
for (const wire of drawn) {
|
|
4906
|
-
const label = wire.plan.wire.label;
|
|
4907
|
-
if (!label) continue;
|
|
4908
|
-
const width = labelWidthOf(label);
|
|
4909
|
-
const candidates = labelCandidates(wire.segments, width);
|
|
4910
|
-
const isClear = (baseline) => {
|
|
4911
|
-
const bounds = labelBoundsAt(baseline, width);
|
|
4912
|
-
if (bounds.y < input.contentTop) return false;
|
|
4913
|
-
const padded = inflated(bounds, LABEL_CLEARANCE);
|
|
4914
|
-
if (allSegments.some((segment) => segmentHitsRect(segment, padded))) return false;
|
|
4915
|
-
if (solids.some((rect) => rectsOverlap(bounds, rect))) return false;
|
|
4916
|
-
return ![...placedById.values()].some((placed) => rectsOverlap(bounds, placed.bounds));
|
|
4917
|
-
};
|
|
4918
|
-
const clearSpot = candidates.find(isClear);
|
|
4919
|
-
const at = clearSpot ?? candidates[0] ?? centerOf(wire.plan.from);
|
|
4920
|
-
if (!clearSpot) warnings.push(`wire ${wire.plan.wire.id} label "${label}" has no clear spot`);
|
|
4921
|
-
placedById.set(wire.plan.wire.id, {
|
|
4922
|
-
at: {
|
|
4923
|
-
x: Math.round(at.x),
|
|
4924
|
-
y: Math.round(at.y)
|
|
4925
|
-
},
|
|
4926
|
-
bounds: labelBoundsAt(at, width)
|
|
4927
|
-
});
|
|
4928
|
-
}
|
|
4929
|
-
return placedById;
|
|
4930
|
-
}
|
|
4931
|
-
function isStrictlyBetween(value, first, second) {
|
|
4932
|
-
return value > Math.min(first, second) + .5 && value < Math.max(first, second) - .5;
|
|
4933
|
-
}
|
|
4934
|
-
function segmentsCross(first, second) {
|
|
4935
|
-
if (isHorizontal(first) === isHorizontal(second)) return false;
|
|
4936
|
-
const horizontal = isHorizontal(first) ? first : second;
|
|
4937
|
-
const vertical = horizontal === first ? second : first;
|
|
4938
|
-
return isStrictlyBetween(vertical.from.x, horizontal.from.x, horizontal.to.x) && isStrictlyBetween(horizontal.from.y, vertical.from.y, vertical.to.y);
|
|
4939
|
-
}
|
|
4940
|
-
function segmentsOverlap(first, second) {
|
|
4941
|
-
if (isHorizontal(first) !== isHorizontal(second)) return false;
|
|
4942
|
-
const isAlongX = isHorizontal(first);
|
|
4943
|
-
const lineOf = (segment) => isAlongX ? segment.from.y : segment.from.x;
|
|
4944
|
-
const startOf = (segment) => Math.min(isAlongX ? segment.from.x : segment.from.y, isAlongX ? segment.to.x : segment.to.y);
|
|
4945
|
-
const endOf = (segment) => Math.max(isAlongX ? segment.from.x : segment.from.y, isAlongX ? segment.to.x : segment.to.y);
|
|
4946
|
-
return lineOf(first) === lineOf(second) && Math.min(endOf(first), endOf(second)) - Math.max(startOf(first), startOf(second)) > 1;
|
|
4947
|
-
}
|
|
4948
|
-
function isSharedFanOut(first, second) {
|
|
4949
|
-
return first.plan.styleKey === second.plan.styleKey && first.plan.start.x === second.plan.start.x && first.plan.start.y === second.plan.start.y;
|
|
4950
|
-
}
|
|
4951
|
-
function findCrossings(drawn) {
|
|
4952
|
-
return drawn.flatMap((first, index) => drawn.slice(index + 1).flatMap((second) => {
|
|
4953
|
-
if (first.plan.busKey !== null && first.plan.busKey === second.plan.busKey) return [];
|
|
4954
|
-
const pairs = first.segments.flatMap((firstSegment) => second.segments.map((secondSegment) => [firstSegment, secondSegment]));
|
|
4955
|
-
if (pairs.some(([firstSegment, secondSegment]) => segmentsCross(firstSegment, secondSegment))) return [`wire ${first.plan.wire.id} crosses wire ${second.plan.wire.id}`];
|
|
4956
|
-
if (isSharedFanOut(first, second)) return [];
|
|
4957
|
-
return pairs.some(([firstSegment, secondSegment]) => segmentsOverlap(firstSegment, secondSegment)) ? [`wire ${first.plan.wire.id} overlaps wire ${second.plan.wire.id}`] : [];
|
|
4958
|
-
}));
|
|
4959
|
-
}
|
|
4960
|
-
function findBoxCrossings(drawn, input) {
|
|
4961
|
-
const boxes = [...input.boxesById.values()];
|
|
4962
|
-
return drawn.flatMap((wire) => boxes.flatMap((box) => {
|
|
4963
|
-
if (box.id === wire.plan.from.id || box.id === wire.plan.to.id) return [];
|
|
4964
|
-
const inset = inflated(box, -2);
|
|
4965
|
-
return wire.segments.some((segment) => segmentHitsRect(segment, inset)) ? [`wire ${wire.plan.wire.id} runs through box ${box.id}`] : [];
|
|
4966
|
-
}));
|
|
4967
|
-
}
|
|
4968
|
-
function cappedWarnings(warnings) {
|
|
4969
|
-
if (warnings.length <= WHITEBOARD_LIMITS.layoutWarnings) return [...warnings];
|
|
4970
|
-
const shown = warnings.slice(0, WHITEBOARD_LIMITS.layoutWarnings - 1);
|
|
4971
|
-
return [...shown, `and ${warnings.length - shown.length} more`];
|
|
4972
|
-
}
|
|
4973
|
-
function labelWidthsByGap(plans, gaps) {
|
|
4974
|
-
const widths = gaps.map(() => 0);
|
|
4975
|
-
for (const plan of plans) {
|
|
4976
|
-
if (!plan.wire.label || plan.shape !== "channel") continue;
|
|
4977
|
-
widths[plan.targetGap] = Math.max(widths[plan.targetGap] ?? 0, labelWidthOf(plan.wire.label));
|
|
4978
|
-
}
|
|
4979
|
-
return widths;
|
|
4980
|
-
}
|
|
4981
|
-
function extentOf(drawn, labelRects) {
|
|
4982
|
-
return unionOf([...drawn.flatMap((wire) => wire.segments.flatMap((segment) => [segment.from, segment.to])).map((point) => ({
|
|
4983
|
-
x: point.x,
|
|
4984
|
-
y: point.y,
|
|
4985
|
-
width: 0,
|
|
4986
|
-
height: 0
|
|
4987
|
-
})), ...labelRects]);
|
|
4988
|
-
}
|
|
4989
|
-
function routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide) {
|
|
4990
|
-
assignPorts(requestsBySide, groupOrderBySide);
|
|
4991
|
-
const topTrackCount = assignCrossings(plans, input);
|
|
4992
|
-
const runsByKey = buildRuns(plans, input);
|
|
4993
|
-
const tracksByGap = placeTracks(runsByKey, input.gaps);
|
|
4994
|
-
const drawn = drawWires(plans, runsByKey);
|
|
4995
|
-
return {
|
|
4996
|
-
runsByKey,
|
|
4997
|
-
tracksByGap,
|
|
4998
|
-
topTrackCount,
|
|
4999
|
-
drawn,
|
|
5000
|
-
crossingCost: findBoxCrossings(drawn, input).length * BOX_CROSSING_COST + findCrossings(drawn).length
|
|
5001
|
-
};
|
|
5002
|
-
}
|
|
5003
|
-
function swapNeighbors(order, index) {
|
|
5004
|
-
const left = order[index];
|
|
5005
|
-
const right = order[index + 1];
|
|
5006
|
-
if (left === void 0 || right === void 0) return;
|
|
5007
|
-
order[index] = right;
|
|
5008
|
-
order[index + 1] = left;
|
|
5009
|
-
}
|
|
5010
|
-
function routeWithFewestCrossings(plans, input) {
|
|
5011
|
-
const requestsBySide = portRequestsBySide(plans);
|
|
5012
|
-
const groupOrderBySide = defaultPortOrders(requestsBySide);
|
|
5013
|
-
let bestCost = routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide).crossingCost;
|
|
5014
|
-
const canSearchPortOrders = plans.length <= MAX_WIRES_FOR_PORT_SEARCH;
|
|
5015
|
-
for (const groupOrder of groupOrderBySide.values()) for (let index = 0; canSearchPortOrders && bestCost > 0 && index + 1 < groupOrder.length; index += 1) {
|
|
5016
|
-
swapNeighbors(groupOrder, index);
|
|
5017
|
-
const trialCost = routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide).crossingCost;
|
|
5018
|
-
if (trialCost < bestCost) {
|
|
5019
|
-
bestCost = trialCost;
|
|
5020
|
-
continue;
|
|
5021
|
-
}
|
|
5022
|
-
swapNeighbors(groupOrder, index);
|
|
5023
|
-
}
|
|
5024
|
-
return routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide);
|
|
5025
|
-
}
|
|
5026
|
-
function routeWires(input) {
|
|
5027
|
-
const plans = planWires(input);
|
|
5028
|
-
const { runsByKey, tracksByGap, topTrackCount, drawn } = routeWithFewestCrossings(plans, input);
|
|
5029
|
-
const labelWarnings = [];
|
|
5030
|
-
const labelById = placeLabels(drawn, input, labelWarnings);
|
|
5031
|
-
const wires = drawn.map(({ plan, points, trunk }) => {
|
|
5032
|
-
const lastPoint = points.at(-1) ?? plan.end;
|
|
5033
|
-
const trunkRun = plan.busKey ? runsByKey.get(targetRunKey(plan)) : void 0;
|
|
5034
|
-
const isTrunkLead = trunk.length > 0;
|
|
5035
|
-
const isTJoin = trunkRun !== void 0 && lastPoint.y > trunkRun.top && lastPoint.y < trunkRun.bottom;
|
|
5036
|
-
return {
|
|
5037
|
-
kind: "wire",
|
|
5038
|
-
id: plan.wire.id,
|
|
5039
|
-
path: [pathOf(points), ...trunk.map((segment) => pathOf([segment.from, segment.to]))].join(" "),
|
|
5040
|
-
start: plan.start,
|
|
5041
|
-
end: isTrunkLead || !plan.busKey ? plan.end : lastPoint,
|
|
5042
|
-
label: plan.wire.label,
|
|
5043
|
-
labelAt: labelById.get(plan.wire.id)?.at ?? centerOf(plan.from),
|
|
5044
|
-
isDashed: plan.wire.dashed,
|
|
5045
|
-
strokeHex: plan.strokeHex,
|
|
5046
|
-
tone: plan.wire.tone,
|
|
5047
|
-
hasArrowhead: plan.busKey === null || isTrunkLead,
|
|
5048
|
-
joinAt: isTJoin ? lastPoint : null
|
|
5049
|
-
};
|
|
5050
|
-
});
|
|
5051
|
-
const labelRects = [...labelById.values()].map((placed) => placed.bounds);
|
|
5052
|
-
return {
|
|
5053
|
-
wires,
|
|
5054
|
-
tracksByGap,
|
|
5055
|
-
topTrackCount,
|
|
5056
|
-
labelWidthByGap: labelWidthsByGap(plans, input.gaps),
|
|
5057
|
-
warnings: cappedWarnings([
|
|
5058
|
-
...findBoxCrossings(drawn, input),
|
|
5059
|
-
...findCrossings(drawn),
|
|
5060
|
-
...labelWarnings
|
|
5061
|
-
]),
|
|
5062
|
-
extent: extentOf(drawn, labelRects)
|
|
5063
|
-
};
|
|
5064
|
-
}
|
|
5065
|
-
function noteByline(note) {
|
|
5066
|
-
if (note.resolvedBy) return `resolved by ${note.resolvedBy}`;
|
|
5067
|
-
return note.author ? `from ${note.author}` : "";
|
|
5068
|
-
}
|
|
5069
|
-
function layoutNotes(board, boxesById) {
|
|
5070
|
-
const nextYByBoxId = /* @__PURE__ */ new Map();
|
|
5071
|
-
return elementsOfKind(board, "note").flatMap((note) => {
|
|
5072
|
-
const target = boxesById.get(note.on);
|
|
5073
|
-
if (!target) return [];
|
|
5074
|
-
const { lines, height } = noteShape(note);
|
|
5075
|
-
const y = nextYByBoxId.get(note.on) ?? target.y - NOTE_RISE;
|
|
5076
|
-
nextYByBoxId.set(note.on, y + height + NOTE_GAP);
|
|
5077
|
-
return [{
|
|
5078
|
-
kind: "note",
|
|
5079
|
-
id: note.id,
|
|
5080
|
-
x: target.x + target.width - NOTE_OVERLAP,
|
|
5081
|
-
y,
|
|
5082
|
-
width: NOTE_WIDTH,
|
|
5083
|
-
height,
|
|
5084
|
-
lines,
|
|
5085
|
-
byline: noteByline(note),
|
|
5086
|
-
isResolved: note.resolvedBy !== null
|
|
5087
|
-
}];
|
|
5088
|
-
});
|
|
5089
|
-
}
|
|
5090
|
-
function boundsOf(elements, wireExtent, columnLeftEdges, boxesTop) {
|
|
5091
|
-
const rects = elements.flatMap((element) => element.kind === "wire" ? [] : [element]);
|
|
5092
|
-
const columnsRight = (columnLeftEdges.at(-1) ?? MARGIN) + COLUMN_WIDTH;
|
|
5093
|
-
const around = unionOf([
|
|
5094
|
-
...rects,
|
|
5095
|
-
...wireExtent ? [wireExtent] : [],
|
|
5096
|
-
{
|
|
5097
|
-
x: 0,
|
|
5098
|
-
y: 0,
|
|
5099
|
-
width: columnsRight,
|
|
5100
|
-
height: boxesTop
|
|
5101
|
-
}
|
|
5102
|
-
]);
|
|
5103
|
-
if (!around) return {
|
|
5104
|
-
x: 0,
|
|
5105
|
-
y: 0,
|
|
5106
|
-
width: columnsRight + MARGIN,
|
|
5107
|
-
height: 80
|
|
5108
|
-
};
|
|
5109
|
-
return {
|
|
5110
|
-
x: Math.min(0, around.x - MARGIN),
|
|
5111
|
-
y: Math.min(0, around.y - MARGIN),
|
|
5112
|
-
width: around.width + 80,
|
|
5113
|
-
height: around.height + 80
|
|
5114
|
-
};
|
|
5115
|
-
}
|
|
5116
|
-
function placeAndRoute(board, placement) {
|
|
5117
|
-
const columnLeftEdges = columnLeftEdgesOf(board, placement.gapWidths);
|
|
5118
|
-
const boxesById = layoutBoxes(board, columnLeftEdges, placement.boxesTop, placement.stackHeightByBoxId);
|
|
5119
|
-
const frames = layoutFrames(board, boxesById);
|
|
5120
|
-
const notes = layoutNotes(board, boxesById);
|
|
5121
|
-
const columnIndexByBoxId = new Map(elementsOfKind(board, "box").flatMap((box) => {
|
|
5122
|
-
const laidOut = boxesById.get(box.id);
|
|
5123
|
-
return laidOut ? [[box.id, columnIndexOf(board, box, laidOut, columnLeftEdges)]] : [];
|
|
5124
|
-
}));
|
|
5125
|
-
return {
|
|
5126
|
-
columnLeftEdges,
|
|
5127
|
-
boxesById,
|
|
5128
|
-
frames,
|
|
5129
|
-
notes,
|
|
5130
|
-
routing: routeWires({
|
|
5131
|
-
wires: elementsOfKind(board, "wire"),
|
|
5132
|
-
boxesById,
|
|
5133
|
-
columnIndexByBoxId,
|
|
5134
|
-
obstacles: [...notes, ...frames.map((frame) => ({
|
|
5135
|
-
x: frame.x,
|
|
5136
|
-
y: frame.y,
|
|
5137
|
-
width: frame.width,
|
|
5138
|
-
height: FRAME_TITLE_HEIGHT
|
|
5139
|
-
}))],
|
|
5140
|
-
gaps: channelGapsOf(columnLeftEdges, placement.gapWidths, placement.reserves),
|
|
5141
|
-
topBandBottom: placement.boxesTop - TOP_BAND_PAD,
|
|
5142
|
-
contentTop: placement.contentTop
|
|
5143
|
-
})
|
|
5144
|
-
};
|
|
5145
|
-
}
|
|
5146
|
-
function maxByIndex(first, second) {
|
|
5147
|
-
return Array.from({ length: Math.max(first.length, second.length) }, (_, index) => Math.max(first[index] ?? 0, second[index] ?? 0));
|
|
5148
|
-
}
|
|
5149
|
-
function placeWithReservedRoom(board, draftRouting, room) {
|
|
5150
|
-
let reservedTracksByGap = draftRouting.tracksByGap;
|
|
5151
|
-
let reservedTopTracks = draftRouting.topTrackCount;
|
|
5152
|
-
for (let attempt = 1;; attempt += 1) {
|
|
5153
|
-
const gapWidths = gapWidthsOf(room.reserves, reservedTracksByGap, draftRouting.labelWidthByGap);
|
|
5154
|
-
const boxesTop = room.headerBoxesTop + topBandHeight(reservedTopTracks);
|
|
5155
|
-
const placed = placeAndRoute(board, {
|
|
5156
|
-
gapWidths,
|
|
5157
|
-
reserves: room.reserves,
|
|
5158
|
-
boxesTop,
|
|
5159
|
-
contentTop: room.contentTop,
|
|
5160
|
-
stackHeightByBoxId: room.stackHeightByBoxId
|
|
5161
|
-
});
|
|
5162
|
-
const needsMoreTop = placed.routing.topTrackCount > reservedTopTracks;
|
|
5163
|
-
const needsMoreTracks = placed.routing.tracksByGap.some((tracks, index) => tracks > (reservedTracksByGap[index] ?? 0));
|
|
5164
|
-
if (attempt >= MAX_ROOM_ATTEMPTS || !needsMoreTop && !needsMoreTracks) return {
|
|
5165
|
-
placed,
|
|
5166
|
-
boxesTop
|
|
5167
|
-
};
|
|
5168
|
-
reservedTopTracks = Math.max(reservedTopTracks, placed.routing.topTrackCount);
|
|
5169
|
-
reservedTracksByGap = maxByIndex(reservedTracksByGap, placed.routing.tracksByGap);
|
|
5170
|
-
}
|
|
5171
|
-
}
|
|
5172
|
-
function unitShape(unit) {
|
|
5173
|
-
const titleLines = wrapText(unit.title, TITLE_CHARS_PER_LINE);
|
|
5174
|
-
const bodyLines = unit.lines.flatMap((line) => wrapText(line.text, BODY_CHARS_PER_LINE));
|
|
5175
|
-
const linkLineCount = unit.linkedBoardId ? 1 : 0;
|
|
5176
|
-
return {
|
|
5177
|
-
titleLines,
|
|
5178
|
-
bodyLines,
|
|
5179
|
-
height: 42 + titleLines.length * TITLE_LINE_HEIGHT + (bodyLines.length + linkLineCount) * BODY_LINE_HEIGHT
|
|
5180
|
-
};
|
|
5181
|
-
}
|
|
5182
|
-
function layoutUnits(board) {
|
|
5183
|
-
const unitsById = /* @__PURE__ */ new Map();
|
|
5184
|
-
const nextYByLevel = /* @__PURE__ */ new Map();
|
|
5185
|
-
for (const step of planSteps$1(board)) {
|
|
5186
|
-
const unit = board.elements[step.unitId];
|
|
5187
|
-
if (unit?.kind !== "unit") continue;
|
|
5188
|
-
const shape = unitShape(unit);
|
|
5189
|
-
const y = nextYByLevel.get(step.level) ?? 70;
|
|
5190
|
-
nextYByLevel.set(step.level, y + shape.height + BOX_GAP);
|
|
5191
|
-
unitsById.set(unit.id, {
|
|
5192
|
-
kind: "unit",
|
|
5193
|
-
id: unit.id,
|
|
5194
|
-
x: MARGIN + (step.level - 1) * 310,
|
|
5195
|
-
y,
|
|
5196
|
-
width: COLUMN_WIDTH,
|
|
5197
|
-
height: shape.height,
|
|
5198
|
-
label: step.label,
|
|
5199
|
-
titleLines: shape.titleLines,
|
|
5200
|
-
bodyLines: shape.bodyLines,
|
|
5201
|
-
linkedBoardId: unit.linkedBoardId
|
|
5202
|
-
});
|
|
5203
|
-
}
|
|
5204
|
-
return unitsById;
|
|
5205
|
-
}
|
|
5206
|
-
function planArrowPath(from, to) {
|
|
5207
|
-
const start = {
|
|
5208
|
-
x: from.x + from.width,
|
|
5209
|
-
y: from.y + Math.round(from.height / 2)
|
|
5210
|
-
};
|
|
5211
|
-
const end = {
|
|
5212
|
-
x: to.x,
|
|
5213
|
-
y: to.y + Math.round(to.height / 2)
|
|
5214
|
-
};
|
|
5215
|
-
const bendX = to.x - Math.round(COLUMN_GAP / 2);
|
|
5216
|
-
return pathOf(withoutBends([
|
|
5217
|
-
start,
|
|
5218
|
-
{
|
|
5219
|
-
x: bendX,
|
|
5220
|
-
y: start.y
|
|
5221
|
-
},
|
|
5222
|
-
{
|
|
5223
|
-
x: bendX,
|
|
5224
|
-
y: end.y
|
|
5225
|
-
},
|
|
5226
|
-
end
|
|
5227
|
-
]));
|
|
5228
|
-
}
|
|
5229
|
-
function planArrowPaths(board, unitsById) {
|
|
5230
|
-
return elementsOfKind(board, "unit").flatMap((unit) => {
|
|
5231
|
-
const to = unitsById.get(unit.id);
|
|
5232
|
-
if (!to) return [];
|
|
5233
|
-
return unit.after.flatMap((afterId) => {
|
|
5234
|
-
const from = unitsById.get(afterId);
|
|
5235
|
-
return from ? [planArrowPath(from, to)] : [];
|
|
5236
|
-
});
|
|
5237
|
-
});
|
|
5238
|
-
}
|
|
5239
|
-
function planBandBottom(unitsById) {
|
|
5240
|
-
if (unitsById.size === 0) return MARGIN;
|
|
5241
|
-
return Math.max(...[...unitsById.values()].map((unit) => unit.y + unit.height)) + PLAN_BAND_GAP;
|
|
5242
|
-
}
|
|
5243
|
-
function withPinnedBoxesShifted(board, offsetY) {
|
|
5244
|
-
if (offsetY === 0) return board;
|
|
5245
|
-
const elements = Object.fromEntries(Object.entries(board.elements).map(([elementId, element]) => {
|
|
5246
|
-
if (element.kind !== "box" || !element.at) return [elementId, element];
|
|
5247
|
-
return [elementId, {
|
|
5248
|
-
...element,
|
|
5249
|
-
at: {
|
|
5250
|
-
x: element.at.x,
|
|
5251
|
-
y: element.at.y + offsetY
|
|
5252
|
-
}
|
|
5253
|
-
}];
|
|
5254
|
-
}));
|
|
5255
|
-
return {
|
|
5256
|
-
...board,
|
|
5257
|
-
elements
|
|
5258
|
-
};
|
|
5259
|
-
}
|
|
5260
|
-
function topBandHeight(topTrackCount) {
|
|
5261
|
-
return topTrackCount > 0 ? topTrackCount * TOP_TRACK_SPACING + TOP_BAND_PAD : 0;
|
|
5262
|
-
}
|
|
5263
|
-
function layoutBoard(storedBoard) {
|
|
5264
|
-
const unitsById = layoutUnits(storedBoard);
|
|
5265
|
-
const freeformTop = planBandBottom(unitsById);
|
|
5266
|
-
const pinnedOffsetY = freeformTop - MARGIN;
|
|
5267
|
-
const board = withPinnedBoxesShifted(storedBoard, pinnedOffsetY);
|
|
5268
|
-
const stackHeightByBoxId = noteStackHeightByBoxId(board);
|
|
5269
|
-
const titleLinesByColumn = columnTitleLines(board);
|
|
5270
|
-
const extraHeaderHeight = headerExtraHeight(titleLinesByColumn);
|
|
5271
|
-
const ruleY = freeformTop + COLUMN_RULE_OFFSET + extraHeaderHeight;
|
|
5272
|
-
const headerBoxesTop = freeformTop + COLUMN_HEADER_HEIGHT + extraHeaderHeight;
|
|
5273
|
-
const reserves = gapReservesOf(board, stackHeightByBoxId);
|
|
5274
|
-
const { placed, boxesTop } = placeWithReservedRoom(board, placeAndRoute(board, {
|
|
5275
|
-
gapWidths: gapWidthsOf(reserves, [], []),
|
|
5276
|
-
reserves,
|
|
5277
|
-
boxesTop: headerBoxesTop,
|
|
5278
|
-
contentTop: ruleY,
|
|
5279
|
-
stackHeightByBoxId
|
|
5280
|
-
}).routing, {
|
|
5281
|
-
reserves,
|
|
5282
|
-
headerBoxesTop,
|
|
5283
|
-
contentTop: ruleY,
|
|
5284
|
-
stackHeightByBoxId
|
|
5285
|
-
});
|
|
5286
|
-
const { columnLeftEdges } = placed;
|
|
5287
|
-
const elements = [
|
|
5288
|
-
...placed.frames,
|
|
5289
|
-
...placed.routing.wires,
|
|
5290
|
-
...placed.boxesById.values(),
|
|
5291
|
-
...placed.notes,
|
|
5292
|
-
...unitsById.values()
|
|
5293
|
-
];
|
|
5294
|
-
const contentBounds = boundsOf(elements, placed.routing.extent, columnLeftEdges, boxesTop);
|
|
5295
|
-
const legendTop = contentBounds.y + contentBounds.height;
|
|
5296
|
-
const legend = board.lanes.map((lane, index) => ({
|
|
5297
|
-
label: lane.label || lane.id,
|
|
5298
|
-
hex: LANE_HEX_BY_COLOR[lane.color],
|
|
5299
|
-
x: MARGIN,
|
|
5300
|
-
y: legendTop + index * LEGEND_ROW_HEIGHT
|
|
5301
|
-
}));
|
|
5302
|
-
const captionTop = legendTop + legend.length * LEGEND_ROW_HEIGHT + (legend.length > 0 ? 12 : 0);
|
|
5303
|
-
const caption = board.caption ? {
|
|
5304
|
-
text: board.caption,
|
|
5305
|
-
x: MARGIN,
|
|
5306
|
-
y: captionTop
|
|
5307
|
-
} : null;
|
|
5308
|
-
const extraHeight = legend.length * LEGEND_ROW_HEIGHT + (caption ? 30 : 0) + (legend.length > 0 ? 12 : 0);
|
|
5309
|
-
return {
|
|
5310
|
-
columns: board.columns.map((column, index) => ({
|
|
5311
|
-
id: column.id,
|
|
5312
|
-
titleLines: titleLinesByColumn[index] ?? [],
|
|
5313
|
-
titleBaselineY: freeformTop + COLUMN_TITLE_BASELINE,
|
|
5314
|
-
ruleY,
|
|
5315
|
-
x: columnLeftEdges[index] ?? MARGIN,
|
|
5316
|
-
width: COLUMN_WIDTH
|
|
5317
|
-
})),
|
|
5318
|
-
elements,
|
|
5319
|
-
legend,
|
|
5320
|
-
caption,
|
|
5321
|
-
pinnedOffsetY,
|
|
5322
|
-
plan: unitsById.size > 0 ? {
|
|
5323
|
-
titleAt: {
|
|
5324
|
-
x: MARGIN,
|
|
5325
|
-
y: 56
|
|
5326
|
-
},
|
|
5327
|
-
arrowPaths: planArrowPaths(board, unitsById)
|
|
5328
|
-
} : null,
|
|
5329
|
-
bounds: {
|
|
5330
|
-
...contentBounds,
|
|
5331
|
-
height: contentBounds.height + extraHeight
|
|
5332
|
-
},
|
|
5333
|
-
warnings: placed.routing.warnings
|
|
5334
|
-
};
|
|
5335
|
-
}
|
|
5336
|
-
//#endregion
|
|
5337
4127
|
//#region server/core/whiteboard-store-core.ts
|
|
5338
4128
|
function lowestCursor(record) {
|
|
5339
4129
|
const cursors = Object.values(record.cursorBySessionId);
|
|
@@ -5493,7 +4283,7 @@ var WHITEBOARDS_FOLDER_NAME = "whiteboards";
|
|
|
5493
4283
|
var BOARD_FILE_EXTENSION = ".json";
|
|
5494
4284
|
var BOARD_FILE_MODE = 384;
|
|
5495
4285
|
var PUT_GUIDE = [
|
|
5496
|
-
"glimmervoid whiteboard put <board> <ops> takes a JSON array of ops,
|
|
4286
|
+
"glimmervoid whiteboard put <board> <ops> takes a JSON array of ops, - to read it from stdin, or --file <path> to read it from a file, for example",
|
|
5497
4287
|
"'[{\"op\":\"columns\",\"columns\":[{\"id\":\"intake\",\"title\":\"Intake\"}]},",
|
|
5498
4288
|
"{\"op\":\"lanes\",\"lanes\":[{\"id\":\"pr1\",\"label\":\"PR 1\",\"color\":\"blue\"}]},",
|
|
5499
4289
|
"{\"op\":\"add\",\"element\":{\"kind\":\"box\",\"id\":\"parse\",\"title\":\"Parse\",\"column\":\"intake\",\"lane\":\"pr1\",\"lines\":[{\"text\":\"reads the feed\"},{\"text\":\"skips drafts\",\"muted\":true}]}},",
|
|
@@ -5502,7 +4292,8 @@ var PUT_GUIDE = [
|
|
|
5502
4292
|
"Element kinds: box (title, column, lines, lane, ghost, order), wire (from, to, dashed, tone plain|fail|join|lane, label), frame (title, contains), note (on, text), unit (title, lines, after, linkedBoardId).",
|
|
5503
4293
|
"Units lay out work in dependency order: glimmervoid whiteboard plan add|after|show edits and reads them.",
|
|
5504
4294
|
"Columns place boxes, so never send pixel positions. A put is applied whole or refused whole.",
|
|
5505
|
-
"glimmervoid whiteboard get <board> returns the board and a one-line summary of each change others made since this session last read it
|
|
4295
|
+
"glimmervoid whiteboard get <board> returns the board and a one-line summary of each change others made since this session last read it;",
|
|
4296
|
+
"add --layout to see where every box, wire and label landed, or run glimmervoid whiteboard render <board> --out board.svg to draw it as the dashboard does."
|
|
5506
4297
|
].join(" ");
|
|
5507
4298
|
var OPERATOR_AUTHOR = Object.freeze({
|
|
5508
4299
|
id: "operator",
|
|
@@ -6835,11 +5626,6 @@ function decideCookieFlags({ forwardedProto } = {}) {
|
|
|
6835
5626
|
};
|
|
6836
5627
|
}
|
|
6837
5628
|
//#endregion
|
|
6838
|
-
//#region shared/escape-markup.ts
|
|
6839
|
-
function escapeMarkup(value) {
|
|
6840
|
-
return String(value).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
6841
|
-
}
|
|
6842
|
-
//#endregion
|
|
6843
5629
|
//#region server/remote-auth.ts
|
|
6844
5630
|
var DEVICE_COOKIE_MAX_AGE_SECONDS = Math.floor(DEFAULT_DEVICE_MAX_AGE_MS / 1e3);
|
|
6845
5631
|
var TAILSCALE_USER_LOGIN_HEADER = "tailscale-user-login";
|
|
@@ -17048,6 +15834,14 @@ var LOCKFILE_BY_KIND = {
|
|
|
17048
15834
|
installState: path.join("node_modules", ".pnpm", "lock.yaml")
|
|
17049
15835
|
}
|
|
17050
15836
|
};
|
|
15837
|
+
var KNOWN_LOCKFILES = [
|
|
15838
|
+
"package-lock.json",
|
|
15839
|
+
"npm-shrinkwrap.json",
|
|
15840
|
+
"pnpm-lock.yaml",
|
|
15841
|
+
"yarn.lock",
|
|
15842
|
+
"bun.lock",
|
|
15843
|
+
"bun.lockb"
|
|
15844
|
+
];
|
|
17051
15845
|
var CLONED_CACHE_DIRS = [
|
|
17052
15846
|
".cache",
|
|
17053
15847
|
".vite",
|
|
@@ -17057,7 +15851,7 @@ var NOTIFYING_REASONS = /* @__PURE__ */ new Set([
|
|
|
17057
15851
|
"not-apfs",
|
|
17058
15852
|
"other-volume",
|
|
17059
15853
|
"install-stale",
|
|
17060
|
-
"
|
|
15854
|
+
"outside-link",
|
|
17061
15855
|
"torn",
|
|
17062
15856
|
"failed"
|
|
17063
15857
|
]);
|
|
@@ -17077,13 +15871,13 @@ function planDependencyClone(facts) {
|
|
|
17077
15871
|
if (!isInstallCurrent(facts.lock)) return skipDependencyClone("install-stale");
|
|
17078
15872
|
const dirs = ["."];
|
|
17079
15873
|
const staleDirs = [];
|
|
17080
|
-
for (const
|
|
17081
|
-
if (dir === ".") continue;
|
|
17082
|
-
if (
|
|
17083
|
-
staleDirs.push(dir);
|
|
15874
|
+
for (const nestedDir of facts.nestedPackageDirs) {
|
|
15875
|
+
if (nestedDir.dir === ".") continue;
|
|
15876
|
+
if (!isNestedInstallCurrent(nestedDir)) {
|
|
15877
|
+
staleDirs.push(nestedDir.dir);
|
|
17084
15878
|
continue;
|
|
17085
15879
|
}
|
|
17086
|
-
dirs.push(dir);
|
|
15880
|
+
dirs.push(nestedDir.dir);
|
|
17087
15881
|
}
|
|
17088
15882
|
return {
|
|
17089
15883
|
action: "clone",
|
|
@@ -17091,6 +15885,15 @@ function planDependencyClone(facts) {
|
|
|
17091
15885
|
staleDirs
|
|
17092
15886
|
};
|
|
17093
15887
|
}
|
|
15888
|
+
function isNestedInstallCurrent({ ownLock, hasAnyLockfile }) {
|
|
15889
|
+
if (ownLock) return isInstallCurrent(ownLock);
|
|
15890
|
+
return !hasAnyLockfile;
|
|
15891
|
+
}
|
|
15892
|
+
function isLinkInsideCheckout(linkPathInCheckout, linkTarget) {
|
|
15893
|
+
if (path.isAbsolute(linkTarget)) return false;
|
|
15894
|
+
const resolvedTarget = path.join(path.dirname(linkPathInCheckout), linkTarget);
|
|
15895
|
+
return resolvedTarget !== ".." && !resolvedTarget.startsWith(`..${path.sep}`) && !path.isAbsolute(resolvedTarget);
|
|
15896
|
+
}
|
|
17094
15897
|
function isInstallCurrent(lock) {
|
|
17095
15898
|
if (lock.mainStateText === null) return false;
|
|
17096
15899
|
return installSatisfiesLockfile(lock.kind, lock.worktreeLockText, lock.mainStateText);
|
|
@@ -17159,7 +15962,7 @@ var SKIP_DESCRIPTIONS = {
|
|
|
17159
15962
|
"not-apfs": "the main checkout is not on APFS, so node_modules was not cloned; install dependencies in the worktree",
|
|
17160
15963
|
"other-volume": "the main checkout and the worktree are on different volumes, so node_modules was not cloned; install dependencies in the worktree",
|
|
17161
15964
|
"install-stale": "the main checkout's node_modules does not match the worktree's lockfile, so it was not cloned; install dependencies in the worktree",
|
|
17162
|
-
"
|
|
15965
|
+
"outside-link": "the main checkout's node_modules holds a link outside the repository (npm link or a file: dependency), so it was not cloned; install dependencies in the worktree",
|
|
17163
15966
|
torn: "the main checkout's node_modules changed during the clone, so the clone was discarded; install dependencies in the worktree",
|
|
17164
15967
|
failed: "cloning node_modules from the main checkout failed; install dependencies in the worktree"
|
|
17165
15968
|
};
|
|
@@ -51315,6 +50118,7 @@ function createRecorder(sessionName, captureConfig, recordSignals = true) {
|
|
|
51315
50118
|
//#region server/git/dependency-clone.ts
|
|
51316
50119
|
var CLONE_TIMEOUT_MS = 6e5;
|
|
51317
50120
|
var NODE_MODULES = "node_modules";
|
|
50121
|
+
var LINK_LIST_MAX_BYTES = 67108864;
|
|
51318
50122
|
var cloneQueue = createSerialQueue();
|
|
51319
50123
|
var seedWorktreeDependencies = ({ mainCheckout, worktreeDir }) => cloneQueue.run(() => cloneDependencies(mainCheckout, worktreeDir).catch(() => skipDependencyClone("failed")));
|
|
51320
50124
|
async function cloneDependencies(mainCheckout, worktreeDir) {
|
|
@@ -51374,7 +50178,7 @@ async function cloneDependencies(mainCheckout, worktreeDir) {
|
|
|
51374
50178
|
};
|
|
51375
50179
|
}
|
|
51376
50180
|
async function stageAll(stagedDirs, markerPath) {
|
|
51377
|
-
for (const { sourcePath, stagingPath } of stagedDirs) {
|
|
50181
|
+
for (const { relativeDir, sourcePath, stagingPath } of stagedDirs) {
|
|
51378
50182
|
await removeTree(stagingPath);
|
|
51379
50183
|
if (!(await runCommand("cp", [
|
|
51380
50184
|
"-Rc",
|
|
@@ -51382,17 +50186,8 @@ async function stageAll(stagedDirs, markerPath) {
|
|
|
51382
50186
|
stagingPath
|
|
51383
50187
|
], { timeoutMs: CLONE_TIMEOUT_MS })).ok) return "failed";
|
|
51384
50188
|
for (const cacheDir of CLONED_CACHE_DIRS) await removeTree(path.join(stagingPath, cacheDir));
|
|
51385
|
-
const
|
|
51386
|
-
|
|
51387
|
-
"-type",
|
|
51388
|
-
"l",
|
|
51389
|
-
"-lname",
|
|
51390
|
-
"/*",
|
|
51391
|
-
"-print",
|
|
51392
|
-
"-quit"
|
|
51393
|
-
], { timeoutMs: CLONE_TIMEOUT_MS });
|
|
51394
|
-
if (!absoluteLinks.ok) return "failed";
|
|
51395
|
-
if (absoluteLinks.out) return "absolute-link";
|
|
50189
|
+
const linkCheck = await findLinkOutsideCheckout(relativeDir, stagingPath);
|
|
50190
|
+
if (linkCheck) return linkCheck;
|
|
51396
50191
|
}
|
|
51397
50192
|
for (const { sourcePath } of stagedDirs) {
|
|
51398
50193
|
const changedDuringClone = await runCommand("find", [
|
|
@@ -51407,6 +50202,25 @@ async function stageAll(stagedDirs, markerPath) {
|
|
|
51407
50202
|
}
|
|
51408
50203
|
return null;
|
|
51409
50204
|
}
|
|
50205
|
+
async function findLinkOutsideCheckout(relativeDir, stagingPath) {
|
|
50206
|
+
const links = await runCommand("find", [
|
|
50207
|
+
stagingPath,
|
|
50208
|
+
"-type",
|
|
50209
|
+
"l",
|
|
50210
|
+
"-print0"
|
|
50211
|
+
], {
|
|
50212
|
+
timeoutMs: CLONE_TIMEOUT_MS,
|
|
50213
|
+
maxBuffer: LINK_LIST_MAX_BYTES,
|
|
50214
|
+
trim: false
|
|
50215
|
+
});
|
|
50216
|
+
if (!links.ok) return "failed";
|
|
50217
|
+
for (const linkPath of links.out.split("\0").filter(Boolean)) {
|
|
50218
|
+
const linkTarget = await fs$1.readlink(linkPath).catch(() => null);
|
|
50219
|
+
if (linkTarget === null) return "failed";
|
|
50220
|
+
if (!isLinkInsideCheckout(path.join(relativeDir, NODE_MODULES, path.relative(stagingPath, linkPath)), linkTarget)) return "outside-link";
|
|
50221
|
+
}
|
|
50222
|
+
return null;
|
|
50223
|
+
}
|
|
51410
50224
|
async function readLock(mainDir, worktreeDir) {
|
|
51411
50225
|
for (const kind of ["npm", "pnpm"]) {
|
|
51412
50226
|
const worktreeLockText = await readTextOrNull(path.join(worktreeDir, LOCKFILE_BY_KIND[kind].lockfile));
|
|
@@ -51436,13 +50250,20 @@ async function listNestedPackageDirs(mainCheckout, worktreeDir) {
|
|
|
51436
50250
|
if (relativeDir === ".") continue;
|
|
51437
50251
|
if (await pathExists(path.join(worktreeDir, relativeDir, NODE_MODULES))) continue;
|
|
51438
50252
|
if (!await pathExists(path.join(mainCheckout, relativeDir, NODE_MODULES))) continue;
|
|
50253
|
+
const mainPackageDir = path.join(mainCheckout, relativeDir);
|
|
50254
|
+
const worktreePackageDir = path.join(worktreeDir, relativeDir);
|
|
51439
50255
|
nestedDirs.push({
|
|
51440
50256
|
dir: relativeDir,
|
|
51441
|
-
ownLock: await readLock(
|
|
50257
|
+
ownLock: await readLock(mainPackageDir, worktreePackageDir),
|
|
50258
|
+
hasAnyLockfile: await hasAnyLockfile([mainPackageDir, worktreePackageDir])
|
|
51442
50259
|
});
|
|
51443
50260
|
}
|
|
51444
50261
|
return nestedDirs;
|
|
51445
50262
|
}
|
|
50263
|
+
async function hasAnyLockfile(packageDirs) {
|
|
50264
|
+
for (const packageDir of packageDirs) for (const lockfile of KNOWN_LOCKFILES) if (await pathExists(path.join(packageDir, lockfile))) return true;
|
|
50265
|
+
return false;
|
|
50266
|
+
}
|
|
51446
50267
|
async function discardStaged(stagedDirs) {
|
|
51447
50268
|
for (const { stagingPath } of stagedDirs) await removeTree(stagingPath);
|
|
51448
50269
|
}
|