@narumitw/pi-sync 0.50.2 → 0.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/chunks/{chunk-6LP3MCR2.ts → chunk-2JZFHNLM.ts} +3 -5
- package/dist/chunks/chunk-2JZFHNLM.ts.map +7 -0
- package/dist/chunks/{chunk-LCRI3ABW.ts → chunk-2RZSQWBH.ts} +8 -19
- package/dist/chunks/chunk-2RZSQWBH.ts.map +7 -0
- package/dist/chunks/{chunk-IJ6FJFA5.ts → chunk-4AIHXRKE.ts} +11 -17
- package/dist/chunks/chunk-4AIHXRKE.ts.map +7 -0
- package/dist/chunks/{chunk-C7XY5NF5.ts → chunk-4MPIH46N.ts} +29 -51
- package/dist/chunks/chunk-4MPIH46N.ts.map +7 -0
- package/dist/chunks/{chunk-5B3FXBLE.ts → chunk-6546TS54.ts} +16 -20
- package/dist/chunks/chunk-6546TS54.ts.map +7 -0
- package/dist/chunks/{chunk-Q2TUM5X6.ts → chunk-6NT3YFGY.ts} +2 -2
- package/dist/chunks/chunk-6NT3YFGY.ts.map +7 -0
- package/dist/chunks/{chunk-2B2ELUF5.ts → chunk-7D5SF7P3.ts} +1 -1
- package/dist/chunks/chunk-7D5SF7P3.ts.map +7 -0
- package/dist/chunks/{chunk-4CHTZMEO.ts → chunk-7KHKWL3Q.ts} +37 -55
- package/dist/chunks/chunk-7KHKWL3Q.ts.map +7 -0
- package/dist/chunks/{chunk-ZI5MXMEX.ts → chunk-BVVP33U5.ts} +2 -4
- package/dist/chunks/chunk-BVVP33U5.ts.map +7 -0
- package/dist/chunks/{chunk-SZWBGPID.ts → chunk-DM4X4FIA.ts} +8 -13
- package/dist/chunks/chunk-DM4X4FIA.ts.map +7 -0
- package/dist/chunks/{chunk-SL64RLXR.ts → chunk-DZUSTGQV.ts} +8 -16
- package/dist/chunks/chunk-DZUSTGQV.ts.map +7 -0
- package/dist/chunks/{chunk-G4RNQQZS.ts → chunk-E42GXD6D.ts} +13 -19
- package/dist/chunks/chunk-E42GXD6D.ts.map +7 -0
- package/dist/chunks/{chunk-Z4DQF6L3.ts → chunk-ECYCNZOE.ts} +1 -1
- package/dist/chunks/chunk-ECYCNZOE.ts.map +7 -0
- package/dist/chunks/{chunk-OEX4ABY6.ts → chunk-EEJPYTWE.ts} +11 -21
- package/dist/chunks/chunk-EEJPYTWE.ts.map +7 -0
- package/dist/chunks/{chunk-CPEHGXJV.ts → chunk-G4RUXRWZ.ts} +3 -5
- package/dist/chunks/chunk-G4RUXRWZ.ts.map +7 -0
- package/dist/chunks/{chunk-T2B5IU74.ts → chunk-HGJH56KR.ts} +4 -4
- package/dist/chunks/chunk-HGJH56KR.ts.map +7 -0
- package/dist/chunks/{chunk-JAAKLL6M.ts → chunk-IVXEDPAD.ts} +10 -34
- package/dist/chunks/chunk-IVXEDPAD.ts.map +7 -0
- package/dist/chunks/chunk-K3RIEL6J.ts +20 -0
- package/dist/chunks/chunk-K3RIEL6J.ts.map +7 -0
- package/dist/chunks/{chunk-LTBWGSBV.ts → chunk-MSSW6F3R.ts} +1 -1
- package/dist/chunks/chunk-MSSW6F3R.ts.map +7 -0
- package/dist/chunks/{chunk-T3HH3UEJ.ts → chunk-OVDTF5CH.ts} +4 -10
- package/dist/chunks/chunk-OVDTF5CH.ts.map +7 -0
- package/dist/chunks/{chunk-NJFUIVYL.ts → chunk-PWMWOJP4.ts} +1 -1
- package/dist/chunks/chunk-PWMWOJP4.ts.map +7 -0
- package/dist/chunks/{chunk-HUDQATCL.ts → chunk-Q32CQWPM.ts} +6 -8
- package/dist/chunks/chunk-Q32CQWPM.ts.map +7 -0
- package/dist/chunks/{chunk-ETTRJDNP.ts → chunk-QLSN7AGX.ts} +6 -13
- package/dist/chunks/chunk-QLSN7AGX.ts.map +7 -0
- package/dist/chunks/{chunk-THMF4BVL.ts → chunk-SWUXA3MH.ts} +1 -1
- package/dist/chunks/chunk-SWUXA3MH.ts.map +7 -0
- package/dist/chunks/{chunk-TEN2ZBJV.ts → chunk-T2SJD3N7.ts} +2 -4
- package/dist/chunks/chunk-T2SJD3N7.ts.map +7 -0
- package/dist/chunks/{chunk-AUSDLD6F.ts → chunk-T56RNRZJ.ts} +10 -26
- package/dist/chunks/chunk-T56RNRZJ.ts.map +7 -0
- package/dist/chunks/{chunk-KW7YQEZN.ts → chunk-UA7RXOIT.ts} +48 -100
- package/dist/chunks/chunk-UA7RXOIT.ts.map +7 -0
- package/dist/chunks/{chunk-D5X27LCA.ts → chunk-UETBKTDI.ts} +1 -1
- package/dist/chunks/chunk-UETBKTDI.ts.map +7 -0
- package/dist/chunks/{chunk-CHH26D4F.ts → chunk-YFADF5ZQ.ts} +7 -6
- package/dist/chunks/chunk-YFADF5ZQ.ts.map +7 -0
- package/dist/chunks/{chunk-CCSN3F47.ts → chunk-YPXGU5OR.ts} +4 -4
- package/dist/chunks/chunk-YPXGU5OR.ts.map +7 -0
- package/dist/chunks/{file-selection-FTTKAOYX.ts → file-selection-RAVHRYFG.ts} +14 -26
- package/dist/chunks/file-selection-RAVHRYFG.ts.map +7 -0
- package/dist/chunks/{git-backend-GMVS4PD4.ts → git-backend-IAANDL3K.ts} +41 -104
- package/dist/chunks/git-backend-IAANDL3K.ts.map +7 -0
- package/dist/chunks/manager-result-dispatcher-OTUMQM26.ts +23 -0
- package/dist/chunks/{manager-ui-5KLKVMRC.ts → manager-ui-763NEKJY.ts} +124 -251
- package/dist/chunks/manager-ui-763NEKJY.ts.map +7 -0
- package/dist/chunks/remote-selection-ui-TZTJF32Y.ts +22 -0
- package/dist/chunks/{s3-backend-66O4FGBH.ts → s3-backend-XGXUOPUN.ts} +23 -54
- package/dist/chunks/s3-backend-XGXUOPUN.ts.map +7 -0
- package/dist/chunks/{setup-switch-IS2PEZ3J.ts → setup-switch-5G2VNJHL.ts} +9 -9
- package/dist/chunks/{setup-wizard-IUB6ESEU.ts → setup-wizard-YIEWGX32.ts} +12 -12
- package/dist/chunks/setup-wizard-YIEWGX32.ts.map +7 -0
- package/dist/chunks/{snapshot-HKEWCVK6.ts → snapshot-JL5DFSXI.ts} +5 -5
- package/dist/chunks/sync-inspection-P3ENJLNF.ts +20 -0
- package/dist/chunks/{sync-operations-LBX3GKCM.ts → sync-operations-AR76EB6C.ts} +85 -201
- package/dist/chunks/sync-operations-AR76EB6C.ts.map +7 -0
- package/dist/chunks/{sync-state-Q2FTXTW6.ts → sync-state-VHJUZ4YG.ts} +6 -6
- package/dist/chunks/{webdav-backend-ECIKD7SO.ts → webdav-backend-3EGUONAT.ts} +20 -51
- package/dist/chunks/webdav-backend-3EGUONAT.ts.map +7 -0
- package/dist/index.ts +49 -74
- package/dist/index.ts.map +3 -3
- package/docs/settings.md +9 -0
- package/package.json +61 -62
- package/src/backends/backend-factory.ts +15 -15
- package/src/backends/backend-identity.ts +31 -31
- package/src/backends/backend-types.ts +42 -42
- package/src/backends/git/git-backend.ts +714 -788
- package/src/backends/git/git-config.ts +104 -111
- package/src/backends/git/git-runner.ts +230 -247
- package/src/backends/git/git-storage.ts +228 -245
- package/src/backends/s3/s3-backend.ts +408 -441
- package/src/backends/s3/s3-client.ts +288 -333
- package/src/backends/sync-backend.ts +65 -65
- package/src/backends/webdav/webdav-backend.ts +542 -589
- package/src/backends/webdav/webdav-client.ts +292 -316
- package/src/backends/webdav/webdav-config.ts +57 -68
- package/src/commands/command-execution.ts +270 -289
- package/src/commands/command-handler.ts +160 -163
- package/src/commands/command-types.ts +13 -13
- package/src/commands/command.ts +190 -196
- package/src/commands/setup-completions.ts +1 -1
- package/src/paths.ts +47 -47
- package/src/settings/config-errors.ts +4 -5
- package/src/settings/config-file.ts +473 -506
- package/src/settings/config.ts +171 -174
- package/src/settings/settings-management.ts +191 -216
- package/src/settings/settings-store.ts +63 -77
- package/src/settings/settings-types.ts +78 -75
- package/src/settings/settings-validation.ts +328 -364
- package/src/snapshot/session-paths.ts +41 -55
- package/src/snapshot/snapshot-apply.ts +197 -229
- package/src/snapshot/snapshot-codec.ts +29 -31
- package/src/snapshot/snapshot-paths.ts +4 -6
- package/src/snapshot/snapshot-transaction.ts +161 -170
- package/src/snapshot/snapshot-types.ts +24 -24
- package/src/snapshot/snapshot.ts +310 -343
- package/src/state/json-file.ts +11 -11
- package/src/state/lock.ts +226 -242
- package/src/state/lockfile-fs.ts +20 -20
- package/src/state/operation-availability.ts +36 -41
- package/src/state/state-directory.ts +171 -173
- package/src/state/state-types.ts +15 -15
- package/src/state/sync-state-store.ts +23 -23
- package/src/sync/automatic-sync.ts +75 -80
- package/src/sync/remote-snapshot.ts +52 -60
- package/src/sync/setup-switch.ts +99 -114
- package/src/sync/signals.ts +3 -5
- package/src/sync/startup-check.ts +97 -111
- package/src/sync/sync-decision.ts +76 -80
- package/src/sync/sync-error-guidance.ts +41 -48
- package/src/sync/sync-errors.ts +10 -10
- package/src/sync/sync-inspection.ts +29 -33
- package/src/sync/sync-loaders.ts +28 -36
- package/src/sync/sync-mutations.ts +510 -622
- package/src/sync/sync-operations.ts +7 -7
- package/src/sync/sync-policy.ts +296 -326
- package/src/sync/sync-queries.ts +175 -194
- package/src/sync/sync-state.ts +74 -100
- package/src/sync-extension.ts +89 -101
- package/src/sync.ts +26 -26
- package/src/types.ts +37 -37
- package/src/ui/automatic-sync-summary.ts +1 -3
- package/src/ui/cancellable-operation.ts +92 -112
- package/src/ui/file-selection.ts +250 -274
- package/src/ui/manager-attention.ts +51 -63
- package/src/ui/manager-recovery.ts +48 -57
- package/src/ui/manager-result-dispatcher.ts +62 -76
- package/src/ui/manager-state.ts +200 -232
- package/src/ui/manager-ui.ts +264 -362
- package/src/ui/remote-selection-ui.ts +547 -588
- package/src/ui/secret-input.ts +198 -214
- package/src/ui/settings-ui.ts +175 -172
- package/src/ui/setup/git-ui.ts +232 -261
- package/src/ui/setup/s3-credentials-ui.ts +58 -65
- package/src/ui/setup/s3-ui.ts +171 -195
- package/src/ui/setup/setup-actions.ts +91 -101
- package/src/ui/setup/setup-location-ui.ts +121 -137
- package/src/ui/setup/setup-name-ui.ts +27 -27
- package/src/ui/setup/setup-prompts.ts +65 -65
- package/src/ui/setup/setup-review.ts +58 -59
- package/src/ui/setup/setup-switcher.ts +156 -160
- package/src/ui/setup/setup-wizard.ts +28 -28
- package/src/ui/setup/text-input.ts +54 -58
- package/src/ui/setup/webdav-ui.ts +246 -293
- package/src/ui/storage-connections-ui.ts +317 -369
- package/src/ui/sync-attention.ts +148 -164
- package/src/ui/sync-format.ts +110 -121
- package/src/ui/sync-resolution-ui.ts +147 -153
- package/src/ui/sync-setups-ui.ts +218 -238
- package/src/ui/sync-status.ts +17 -0
- package/src/ui/terminal-text.ts +2 -2
- package/dist/chunks/chunk-2B2ELUF5.ts.map +0 -7
- package/dist/chunks/chunk-4CHTZMEO.ts.map +0 -7
- package/dist/chunks/chunk-5B3FXBLE.ts.map +0 -7
- package/dist/chunks/chunk-6LP3MCR2.ts.map +0 -7
- package/dist/chunks/chunk-AUSDLD6F.ts.map +0 -7
- package/dist/chunks/chunk-C7XY5NF5.ts.map +0 -7
- package/dist/chunks/chunk-CCSN3F47.ts.map +0 -7
- package/dist/chunks/chunk-CHH26D4F.ts.map +0 -7
- package/dist/chunks/chunk-CPEHGXJV.ts.map +0 -7
- package/dist/chunks/chunk-D5X27LCA.ts.map +0 -7
- package/dist/chunks/chunk-ETTRJDNP.ts.map +0 -7
- package/dist/chunks/chunk-G4RNQQZS.ts.map +0 -7
- package/dist/chunks/chunk-HUDQATCL.ts.map +0 -7
- package/dist/chunks/chunk-IJ6FJFA5.ts.map +0 -7
- package/dist/chunks/chunk-JAAKLL6M.ts.map +0 -7
- package/dist/chunks/chunk-KW7YQEZN.ts.map +0 -7
- package/dist/chunks/chunk-LCRI3ABW.ts.map +0 -7
- package/dist/chunks/chunk-LTBWGSBV.ts.map +0 -7
- package/dist/chunks/chunk-NJFUIVYL.ts.map +0 -7
- package/dist/chunks/chunk-OEX4ABY6.ts.map +0 -7
- package/dist/chunks/chunk-Q2TUM5X6.ts.map +0 -7
- package/dist/chunks/chunk-SL64RLXR.ts.map +0 -7
- package/dist/chunks/chunk-SZWBGPID.ts.map +0 -7
- package/dist/chunks/chunk-T2B5IU74.ts.map +0 -7
- package/dist/chunks/chunk-T3HH3UEJ.ts.map +0 -7
- package/dist/chunks/chunk-TEN2ZBJV.ts.map +0 -7
- package/dist/chunks/chunk-THMF4BVL.ts.map +0 -7
- package/dist/chunks/chunk-Z4DQF6L3.ts.map +0 -7
- package/dist/chunks/chunk-ZI5MXMEX.ts.map +0 -7
- package/dist/chunks/file-selection-FTTKAOYX.ts.map +0 -7
- package/dist/chunks/git-backend-GMVS4PD4.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-FKIBM3GO.ts +0 -22
- package/dist/chunks/manager-ui-5KLKVMRC.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-D7RBRJNL.ts +0 -21
- package/dist/chunks/s3-backend-66O4FGBH.ts.map +0 -7
- package/dist/chunks/setup-wizard-IUB6ESEU.ts.map +0 -7
- package/dist/chunks/sync-inspection-CST2KL65.ts +0 -20
- package/dist/chunks/sync-operations-LBX3GKCM.ts.map +0 -7
- package/dist/chunks/webdav-backend-ECIKD7SO.ts.map +0 -7
- /package/dist/chunks/{manager-result-dispatcher-FKIBM3GO.ts.map → manager-result-dispatcher-OTUMQM26.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-D7RBRJNL.ts.map → remote-selection-ui-TZTJF32Y.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-IS2PEZ3J.ts.map → setup-switch-5G2VNJHL.ts.map} +0 -0
- /package/dist/chunks/{snapshot-HKEWCVK6.ts.map → snapshot-JL5DFSXI.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-CST2KL65.ts.map → sync-inspection-P3ENJLNF.ts.map} +0 -0
- /package/dist/chunks/{sync-state-Q2FTXTW6.ts.map → sync-state-VHJUZ4YG.ts.map} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import {
|
|
4
4
|
filterSnapshotForConfigPolicy,
|
|
5
5
|
isSessionPath
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EEJPYTWE.ts";
|
|
7
7
|
import {
|
|
8
8
|
canonicalSnapshotPathForConfig,
|
|
9
9
|
customIncludePathsByLower,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
isConfiguredSnapshotPath,
|
|
12
12
|
normalizeSyncInclude,
|
|
13
13
|
toPosix
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-IVXEDPAD.ts";
|
|
15
15
|
|
|
16
16
|
// src/sync/sync-state.ts
|
|
17
17
|
function hasLocalChanges(local, state, config) {
|
|
@@ -20,19 +20,13 @@ function hasLocalChanges(local, state, config) {
|
|
|
20
20
|
function remoteChangedSinceState(head, state, config, sameRevision) {
|
|
21
21
|
if (!head) return Boolean(state.lastAppliedSnapshot);
|
|
22
22
|
if (head.snapshotId !== state.lastAppliedSnapshot) return true;
|
|
23
|
-
if (state.lastRemoteRevision && !sameRevision(head.revision, state.lastRemoteRevision))
|
|
24
|
-
return true;
|
|
23
|
+
if (state.lastRemoteRevision && !sameRevision(head.revision, state.lastRemoteRevision)) return true;
|
|
25
24
|
if (syncIncludeChanged(state, config)) return true;
|
|
26
25
|
return includeFromSelectionConfig(config).includes("sessions") && !state.include?.includes("sessions") && head.syncSessions;
|
|
27
26
|
}
|
|
28
27
|
function hasRemoteChanges(remote, state, config, ignoredPaths = /* @__PURE__ */ new Set()) {
|
|
29
28
|
if (remote.id === state.lastAppliedSnapshot && !syncPolicyChanged(state, config)) return false;
|
|
30
|
-
return !snapshotHashesMatchState(
|
|
31
|
-
filterSnapshotForConfigPolicy(remote, config),
|
|
32
|
-
state,
|
|
33
|
-
config,
|
|
34
|
-
ignoredPaths
|
|
35
|
-
);
|
|
29
|
+
return !snapshotHashesMatchState(filterSnapshotForConfigPolicy(remote, config), state, config, ignoredPaths);
|
|
36
30
|
}
|
|
37
31
|
function sameHashes(left, right) {
|
|
38
32
|
const keys = /* @__PURE__ */ new Set([...Object.keys(left), ...Object.keys(right)]);
|
|
@@ -59,17 +53,13 @@ function snapshotsMatch(left, right) {
|
|
|
59
53
|
}
|
|
60
54
|
function withoutHashPaths(hashes, ignoredPaths) {
|
|
61
55
|
if (ignoredPaths.size === 0) return hashes;
|
|
62
|
-
return Object.fromEntries(
|
|
63
|
-
Object.entries(hashes).filter(([filePath]) => !ignoredPaths.has(toPosix(filePath)))
|
|
64
|
-
);
|
|
56
|
+
return Object.fromEntries(Object.entries(hashes).filter(([filePath]) => !ignoredPaths.has(toPosix(filePath))));
|
|
65
57
|
}
|
|
66
58
|
function syncPolicyChanged(state, config) {
|
|
67
59
|
return syncIncludeChanged(state, config);
|
|
68
60
|
}
|
|
69
61
|
function shouldRefreshSyncedState(remote, head, state, config, sameRevision) {
|
|
70
|
-
return remote.id !== state.lastAppliedSnapshot || Boolean(
|
|
71
|
-
head && (!state.lastRemoteRevision || !sameRevision(head.revision, state.lastRemoteRevision))
|
|
72
|
-
) || syncPolicyChanged(state, config);
|
|
62
|
+
return remote.id !== state.lastAppliedSnapshot || Boolean(head && (!state.lastRemoteRevision || !sameRevision(head.revision, state.lastRemoteRevision))) || syncPolicyChanged(state, config);
|
|
73
63
|
}
|
|
74
64
|
function syncIncludeChanged(state, config) {
|
|
75
65
|
const stored = state.include ? normalizeSyncInclude(state.include) : includeFromSelectionConfig(state);
|
|
@@ -87,25 +77,19 @@ function sessionHashMap(snapshot) {
|
|
|
87
77
|
);
|
|
88
78
|
}
|
|
89
79
|
function settingsHashMapFromState(state) {
|
|
90
|
-
return Object.fromEntries(
|
|
91
|
-
Object.entries(state.lastFileHashes).filter(([filePath]) => !isSessionPath(filePath))
|
|
92
|
-
);
|
|
80
|
+
return Object.fromEntries(Object.entries(state.lastFileHashes).filter(([filePath]) => !isSessionPath(filePath)));
|
|
93
81
|
}
|
|
94
82
|
function settingsHashesMatchState(remote, state) {
|
|
95
83
|
return sameHashes(settingsHashMap(remote), settingsHashMapFromState(state));
|
|
96
84
|
}
|
|
97
85
|
function canPullRemoteSettingsOnFirstSync(local, remote) {
|
|
98
86
|
const remoteSettings = settingsHashMap(remote);
|
|
99
|
-
return Object.entries(settingsHashMap(local)).every(
|
|
100
|
-
([filePath, hash]) => remoteSettings[filePath] === hash
|
|
101
|
-
);
|
|
87
|
+
return Object.entries(settingsHashMap(local)).every(([filePath, hash]) => remoteSettings[filePath] === hash);
|
|
102
88
|
}
|
|
103
89
|
function canPullRemoteSessionsOnFirstSync(local, remote) {
|
|
104
90
|
const localSessions = sessionHashMap(local);
|
|
105
91
|
const remoteSessions = sessionHashMap(remote);
|
|
106
|
-
return Object.entries(localSessions).every(
|
|
107
|
-
([filePath, hash]) => remoteSessions[filePath] === hash
|
|
108
|
-
);
|
|
92
|
+
return Object.entries(localSessions).every(([filePath, hash]) => remoteSessions[filePath] === hash);
|
|
109
93
|
}
|
|
110
94
|
|
|
111
95
|
export {
|
|
@@ -125,4 +109,4 @@ export {
|
|
|
125
109
|
canPullRemoteSettingsOnFirstSync,
|
|
126
110
|
canPullRemoteSessionsOnFirstSync
|
|
127
111
|
};
|
|
128
|
-
//# sourceMappingURL=chunk-
|
|
112
|
+
//# sourceMappingURL=chunk-T56RNRZJ.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/sync-state.ts"],
|
|
4
|
+
"sourcesContent": ["import type { RemoteHead } from \"../backends/sync-backend.js\";\nimport { toPosix } from \"../paths.js\";\nimport {\n canonicalSnapshotPathForConfig,\n filterSnapshotForConfigPolicy,\n isConfiguredSnapshotPath,\n isSessionPath,\n} from \"../snapshot/snapshot.js\";\nimport type { Snapshot } from \"../snapshot/snapshot-types.js\";\nimport type { SyncState } from \"../state/state-types.js\";\nimport {\n customIncludePathsByLower,\n includeFromSelectionConfig,\n normalizeSyncInclude,\n type SyncSelectionConfig,\n} from \"./sync-policy.js\";\n\ntype SyncPolicyConfig = SyncSelectionConfig;\n\nexport function hasLocalChanges(local: Snapshot, state: SyncState, config: SyncPolicyConfig) {\n return !sameHashes(fileHashMap(local), stateHashMapForConfig(state, config));\n}\n\nexport function remoteChangedSinceState(\n head: RemoteHead | undefined,\n state: SyncState,\n config: SyncPolicyConfig,\n sameRevision: (left: string, right: string) => boolean,\n) {\n if (!head) return Boolean(state.lastAppliedSnapshot);\n if (head.snapshotId !== state.lastAppliedSnapshot) return true;\n if (state.lastRemoteRevision && !sameRevision(head.revision, state.lastRemoteRevision)) return true;\n if (syncIncludeChanged(state, config)) return true;\n return (\n includeFromSelectionConfig(config).includes(\"sessions\") && !state.include?.includes(\"sessions\") && head.syncSessions\n );\n}\n\nexport function hasRemoteChanges(\n remote: Snapshot,\n state: SyncState,\n config: SyncPolicyConfig,\n ignoredPaths = new Set<string>(),\n) {\n if (remote.id === state.lastAppliedSnapshot && !syncPolicyChanged(state, config)) return false;\n return !snapshotHashesMatchState(filterSnapshotForConfigPolicy(remote, config), state, config, ignoredPaths);\n}\n\nexport function sameHashes(left: Record<string, string>, right: Record<string, string>) {\n const keys = new Set([...Object.keys(left), ...Object.keys(right)]);\n for (const key of keys) if (left[key] !== right[key]) return false;\n return true;\n}\n\nexport function fileHashMap(snapshot: Snapshot) {\n return Object.fromEntries(snapshot.files.map((file) => [file.path, file.sha256]));\n}\n\nfunction stateHashMapForConfig(state: SyncState, config: SyncPolicyConfig) {\n const includePaths = customIncludePathsByLower(includeFromSelectionConfig(config));\n return Object.fromEntries(\n Object.entries(state.lastFileHashes)\n .filter(([filePath]) => isConfiguredSnapshotPath(filePath, config))\n .map(([filePath, hash]) => [canonicalSnapshotPathForConfig(filePath, includePaths), hash]),\n );\n}\n\nexport function snapshotHashesMatchState(\n snapshot: Snapshot,\n state: SyncState,\n config: SyncPolicyConfig,\n ignoredPaths = new Set<string>(),\n) {\n return sameHashes(\n withoutHashPaths(fileHashMap(snapshot), ignoredPaths),\n withoutHashPaths(stateHashMapForConfig(state, config), ignoredPaths),\n );\n}\n\nexport function snapshotsMatch(left: Snapshot, right: Snapshot) {\n return left.syncSessions === right.syncSessions && sameHashes(fileHashMap(left), fileHashMap(right));\n}\n\nfunction withoutHashPaths(hashes: Record<string, string>, ignoredPaths: Set<string>) {\n if (ignoredPaths.size === 0) return hashes;\n return Object.fromEntries(Object.entries(hashes).filter(([filePath]) => !ignoredPaths.has(toPosix(filePath))));\n}\n\nexport function syncPolicyChanged(state: SyncState, config: SyncPolicyConfig) {\n return syncIncludeChanged(state, config);\n}\n\nexport function shouldRefreshSyncedState(\n remote: Snapshot,\n head: RemoteHead | undefined,\n state: SyncState,\n config: SyncPolicyConfig,\n sameRevision: (left: string, right: string) => boolean,\n) {\n return (\n remote.id !== state.lastAppliedSnapshot ||\n Boolean(head && (!state.lastRemoteRevision || !sameRevision(head.revision, state.lastRemoteRevision))) ||\n syncPolicyChanged(state, config)\n );\n}\n\nfunction syncIncludeChanged(state: SyncState, config: SyncPolicyConfig) {\n const stored = state.include ? normalizeSyncInclude(state.include) : includeFromSelectionConfig(state);\n const current = includeFromSelectionConfig(config);\n return stored.length !== current.length || stored.some((item, index) => item !== current[index]);\n}\n\nexport function settingsHashMap(snapshot: Snapshot) {\n return Object.fromEntries(\n snapshot.files.filter((file) => !isSessionPath(file.path)).map((file) => [file.path, file.sha256]),\n );\n}\n\nexport function sessionHashMap(snapshot: Snapshot) {\n return Object.fromEntries(\n snapshot.files.filter((file) => isSessionPath(file.path)).map((file) => [file.path, file.sha256]),\n );\n}\n\nexport function settingsHashMapFromState(state: SyncState) {\n return Object.fromEntries(Object.entries(state.lastFileHashes).filter(([filePath]) => !isSessionPath(filePath)));\n}\n\nexport function settingsHashesMatchState(remote: Snapshot, state: SyncState) {\n return sameHashes(settingsHashMap(remote), settingsHashMapFromState(state));\n}\n\nexport function canPullRemoteSettingsOnFirstSync(local: Snapshot, remote: Snapshot) {\n const remoteSettings = settingsHashMap(remote);\n return Object.entries(settingsHashMap(local)).every(([filePath, hash]) => remoteSettings[filePath] === hash);\n}\n\nexport function canPullRemoteSessionsOnFirstSync(local: Snapshot, remote: Snapshot) {\n const localSessions = sessionHashMap(local);\n const remoteSessions = sessionHashMap(remote);\n return Object.entries(localSessions).every(([filePath, hash]) => remoteSessions[filePath] === hash);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAmBO,SAAS,gBAAgB,OAAiB,OAAkB,QAA0B;AAC3F,SAAO,CAAC,WAAW,YAAY,KAAK,GAAG,sBAAsB,OAAO,MAAM,CAAC;AAC7E;AAEO,SAAS,wBACd,MACA,OACA,QACA,cACA;AACA,MAAI,CAAC,KAAM,QAAO,QAAQ,MAAM,mBAAmB;AACnD,MAAI,KAAK,eAAe,MAAM,oBAAqB,QAAO;AAC1D,MAAI,MAAM,sBAAsB,CAAC,aAAa,KAAK,UAAU,MAAM,kBAAkB,EAAG,QAAO;AAC/F,MAAI,mBAAmB,OAAO,MAAM,EAAG,QAAO;AAC9C,SACE,2BAA2B,MAAM,EAAE,SAAS,UAAU,KAAK,CAAC,MAAM,SAAS,SAAS,UAAU,KAAK,KAAK;AAE5G;AAEO,SAAS,iBACd,QACA,OACA,QACA,eAAe,oBAAI,IAAY,GAC/B;AACA,MAAI,OAAO,OAAO,MAAM,uBAAuB,CAAC,kBAAkB,OAAO,MAAM,EAAG,QAAO;AACzF,SAAO,CAAC,yBAAyB,8BAA8B,QAAQ,MAAM,GAAG,OAAO,QAAQ,YAAY;AAC7G;AAEO,SAAS,WAAW,MAA8B,OAA+B;AACtF,QAAM,OAAO,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,IAAI,GAAG,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC;AAClE,aAAW,OAAO,KAAM,KAAI,KAAK,GAAG,MAAM,MAAM,GAAG,EAAG,QAAO;AAC7D,SAAO;AACT;AAEO,SAAS,YAAY,UAAoB;AAC9C,SAAO,OAAO,YAAY,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,MAAM,KAAK,MAAM,CAAC,CAAC;AAClF;AAEA,SAAS,sBAAsB,OAAkB,QAA0B;AACzE,QAAM,eAAe,0BAA0B,2BAA2B,MAAM,CAAC;AACjF,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,MAAM,cAAc,EAChC,OAAO,CAAC,CAAC,QAAQ,MAAM,yBAAyB,UAAU,MAAM,CAAC,EACjE,IAAI,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC,+BAA+B,UAAU,YAAY,GAAG,IAAI,CAAC;AAAA,EAC7F;AACF;AAEO,SAAS,yBACd,UACA,OACA,QACA,eAAe,oBAAI,IAAY,GAC/B;AACA,SAAO;AAAA,IACL,iBAAiB,YAAY,QAAQ,GAAG,YAAY;AAAA,IACpD,iBAAiB,sBAAsB,OAAO,MAAM,GAAG,YAAY;AAAA,EACrE;AACF;AAEO,SAAS,eAAe,MAAgB,OAAiB;AAC9D,SAAO,KAAK,iBAAiB,MAAM,gBAAgB,WAAW,YAAY,IAAI,GAAG,YAAY,KAAK,CAAC;AACrG;AAEA,SAAS,iBAAiB,QAAgC,cAA2B;AACnF,MAAI,aAAa,SAAS,EAAG,QAAO;AACpC,SAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,MAAM,CAAC,aAAa,IAAI,QAAQ,QAAQ,CAAC,CAAC,CAAC;AAC/G;AAEO,SAAS,kBAAkB,OAAkB,QAA0B;AAC5E,SAAO,mBAAmB,OAAO,MAAM;AACzC;AAEO,SAAS,yBACd,QACA,MACA,OACA,QACA,cACA;AACA,SACE,OAAO,OAAO,MAAM,uBACpB,QAAQ,SAAS,CAAC,MAAM,sBAAsB,CAAC,aAAa,KAAK,UAAU,MAAM,kBAAkB,EAAE,KACrG,kBAAkB,OAAO,MAAM;AAEnC;AAEA,SAAS,mBAAmB,OAAkB,QAA0B;AACtE,QAAM,SAAS,MAAM,UAAU,qBAAqB,MAAM,OAAO,IAAI,2BAA2B,KAAK;AACrG,QAAM,UAAU,2BAA2B,MAAM;AACjD,SAAO,OAAO,WAAW,QAAQ,UAAU,OAAO,KAAK,CAAC,MAAM,UAAU,SAAS,QAAQ,KAAK,CAAC;AACjG;AAEO,SAAS,gBAAgB,UAAoB;AAClD,SAAO,OAAO;AAAA,IACZ,SAAS,MAAM,OAAO,CAAC,SAAS,CAAC,cAAc,KAAK,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,MAAM,KAAK,MAAM,CAAC;AAAA,EACnG;AACF;AAEO,SAAS,eAAe,UAAoB;AACjD,SAAO,OAAO;AAAA,IACZ,SAAS,MAAM,OAAO,CAAC,SAAS,cAAc,KAAK,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,MAAM,KAAK,MAAM,CAAC;AAAA,EAClG;AACF;AAEO,SAAS,yBAAyB,OAAkB;AACzD,SAAO,OAAO,YAAY,OAAO,QAAQ,MAAM,cAAc,EAAE,OAAO,CAAC,CAAC,QAAQ,MAAM,CAAC,cAAc,QAAQ,CAAC,CAAC;AACjH;AAEO,SAAS,yBAAyB,QAAkB,OAAkB;AAC3E,SAAO,WAAW,gBAAgB,MAAM,GAAG,yBAAyB,KAAK,CAAC;AAC5E;AAEO,SAAS,iCAAiC,OAAiB,QAAkB;AAClF,QAAM,iBAAiB,gBAAgB,MAAM;AAC7C,SAAO,OAAO,QAAQ,gBAAgB,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,UAAU,IAAI,MAAM,eAAe,QAAQ,MAAM,IAAI;AAC7G;AAEO,SAAS,iCAAiC,OAAiB,QAAkB;AAClF,QAAM,gBAAgB,eAAe,KAAK;AAC1C,QAAM,iBAAiB,eAAe,MAAM;AAC5C,SAAO,OAAO,QAAQ,aAAa,EAAE,MAAM,CAAC,CAAC,UAAU,IAAI,MAAM,eAAe,QAAQ,MAAM,IAAI;AACpG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
automaticSyncSummary
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ECYCNZOE.ts";
|
|
6
6
|
import {
|
|
7
7
|
setSyncSetupCompletions
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YFADF5ZQ.ts";
|
|
9
9
|
import {
|
|
10
10
|
safeTerminalText
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MSSW6F3R.ts";
|
|
12
12
|
import {
|
|
13
13
|
addStorageConnection,
|
|
14
14
|
addSyncSetup,
|
|
15
15
|
saveNewV3Settings,
|
|
16
16
|
updateStorageConnection,
|
|
17
17
|
updateSyncSetup
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-2RZSQWBH.ts";
|
|
19
19
|
import {
|
|
20
20
|
configuredSyncSetupNames,
|
|
21
21
|
effectiveSyncSetupRemoteIdentity,
|
|
@@ -26,26 +26,26 @@ import {
|
|
|
26
26
|
readLocalConfigObject,
|
|
27
27
|
requiredString,
|
|
28
28
|
validateConfigName
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-4MPIH46N.ts";
|
|
30
30
|
import {
|
|
31
31
|
normalizeWebDavPath,
|
|
32
32
|
normalizeWebDavUrl,
|
|
33
33
|
validateWebDavCredentials
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-2JZFHNLM.ts";
|
|
35
35
|
import {
|
|
36
36
|
normalizeGitBranch,
|
|
37
37
|
normalizeGitDirectory,
|
|
38
38
|
normalizeGitRemote
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-T2SJD3N7.ts";
|
|
40
40
|
import {
|
|
41
41
|
syncErrorGuidance
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-G4RUXRWZ.ts";
|
|
43
43
|
import {
|
|
44
44
|
errorMessage
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-7D5SF7P3.ts";
|
|
46
46
|
import {
|
|
47
47
|
DEFAULT_SYNC_INCLUDE
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-IVXEDPAD.ts";
|
|
49
49
|
|
|
50
50
|
// src/commands/setup-completions.ts
|
|
51
51
|
async function refreshTargetCompletions() {
|
|
@@ -103,8 +103,7 @@ async function chooseInitialRemoteLocation(ctx, _preset, setupName, signal) {
|
|
|
103
103
|
{ signal }
|
|
104
104
|
);
|
|
105
105
|
if (signal?.aborted || !choice || choice === "Cancel") return void 0;
|
|
106
|
-
if (choice === "Customize remote location")
|
|
107
|
-
return chooseCustomRemoteLocation(ctx, setupName, signal);
|
|
106
|
+
if (choice === "Customize remote location") return chooseCustomRemoteLocation(ctx, setupName, signal);
|
|
108
107
|
const bucket = await requiredExistingBucket(ctx, "pi-sync", signal);
|
|
109
108
|
return bucket ? { connectionName: setupName, bucket, path: "./" } : void 0;
|
|
110
109
|
}
|
|
@@ -165,10 +164,7 @@ async function promptAvailableSetupStorage(ctx, initial, signal) {
|
|
|
165
164
|
if (!settings || !connection) throw new Error("Storage connection changed; reopen setup.");
|
|
166
165
|
const identity = setupPublicationIdentity(storage, connection);
|
|
167
166
|
const occupied = Object.entries(settings.syncSetups).find(
|
|
168
|
-
([, setup]) => setupPublicationIdentity(
|
|
169
|
-
setup.storage,
|
|
170
|
-
settings.storageConnections[setup.storage.connection]
|
|
171
|
-
) === identity
|
|
167
|
+
([, setup]) => setupPublicationIdentity(setup.storage, settings.storageConnections[setup.storage.connection]) === identity
|
|
172
168
|
);
|
|
173
169
|
if (!occupied) return storage;
|
|
174
170
|
const git = connection.type === "git";
|
|
@@ -377,10 +373,7 @@ async function showGitSetup(ctx, targetName, signal) {
|
|
|
377
373
|
signal
|
|
378
374
|
);
|
|
379
375
|
if (saved && !signal?.aborted)
|
|
380
|
-
ctx.ui.notify(
|
|
381
|
-
`Saved Git sync setup \u201C${safeTerminalText(targetName)}\u201D. Choose Sync now to start.`,
|
|
382
|
-
"info"
|
|
383
|
-
);
|
|
376
|
+
ctx.ui.notify(`Saved Git sync setup \u201C${safeTerminalText(targetName)}\u201D. Choose Sync now to start.`, "info");
|
|
384
377
|
return saved;
|
|
385
378
|
}
|
|
386
379
|
async function showAddGitStorageProfile(ctx, signal) {
|
|
@@ -402,16 +395,11 @@ async function showAddGitStorageProfile(ctx, signal) {
|
|
|
402
395
|
(saveSignal) => addStorageConnection(name, { type: "git", remote }, saveSignal),
|
|
403
396
|
signal
|
|
404
397
|
);
|
|
405
|
-
if (saved && !signal?.aborted)
|
|
406
|
-
ctx.ui.notify(`Added storage connection \u201C${safeTerminalText(name)}\u201D.`, "info");
|
|
398
|
+
if (saved && !signal?.aborted) ctx.ui.notify(`Added storage connection \u201C${safeTerminalText(name)}\u201D.`, "info");
|
|
407
399
|
return saved;
|
|
408
400
|
}
|
|
409
401
|
async function showEditGitStorageProfile(ctx, name, profile, signal, affectedSetups) {
|
|
410
|
-
const remote = await promptGitRemote(
|
|
411
|
-
ctx,
|
|
412
|
-
signal,
|
|
413
|
-
typeof profile.remote === "string" ? profile.remote : void 0
|
|
414
|
-
);
|
|
402
|
+
const remote = await promptGitRemote(ctx, signal, typeof profile.remote === "string" ? profile.remote : void 0);
|
|
415
403
|
if (!remote) return false;
|
|
416
404
|
const saved = await saveReviewedDraft(
|
|
417
405
|
ctx,
|
|
@@ -435,8 +423,7 @@ async function showEditGitStorageProfile(ctx, name, profile, signal, affectedSet
|
|
|
435
423
|
),
|
|
436
424
|
signal
|
|
437
425
|
);
|
|
438
|
-
if (saved && !signal?.aborted)
|
|
439
|
-
ctx.ui.notify(`Saved storage connection \u201C${safeTerminalText(name)}\u201D.`, "info");
|
|
426
|
+
if (saved && !signal?.aborted) ctx.ui.notify(`Saved storage connection \u201C${safeTerminalText(name)}\u201D.`, "info");
|
|
440
427
|
return saved;
|
|
441
428
|
}
|
|
442
429
|
async function showAddGitTarget(ctx, name, profile, signal) {
|
|
@@ -471,8 +458,7 @@ async function showAddGitTarget(ctx, name, profile, signal) {
|
|
|
471
458
|
(saveSignal) => addSyncSetup(name, { storage, sync: { include, automatic } }, saveSignal, connection),
|
|
472
459
|
signal
|
|
473
460
|
);
|
|
474
|
-
if (saved && !signal?.aborted)
|
|
475
|
-
ctx.ui.notify(`Added sync setup \u201C${safeTerminalText(name)}\u201D.`, "info");
|
|
461
|
+
if (saved && !signal?.aborted) ctx.ui.notify(`Added sync setup \u201C${safeTerminalText(name)}\u201D.`, "info");
|
|
476
462
|
return saved;
|
|
477
463
|
}
|
|
478
464
|
async function showEditGitTarget(ctx, partial, signal) {
|
|
@@ -511,8 +497,7 @@ async function showEditGitTarget(ctx, partial, signal) {
|
|
|
511
497
|
(saveSignal) => updateSyncSetup(
|
|
512
498
|
partial.setupName,
|
|
513
499
|
(setup) => {
|
|
514
|
-
if (typeof setup.storage.branch !== "string")
|
|
515
|
-
throw new Error("Sync setup storage type changed; reopen it.");
|
|
500
|
+
if (typeof setup.storage.branch !== "string") throw new Error("Sync setup storage type changed; reopen it.");
|
|
516
501
|
return {
|
|
517
502
|
...setup,
|
|
518
503
|
storage: { ...setup.storage, branch: chosen.branch, path: chosen.directory }
|
|
@@ -522,8 +507,7 @@ async function showEditGitTarget(ctx, partial, signal) {
|
|
|
522
507
|
),
|
|
523
508
|
signal
|
|
524
509
|
);
|
|
525
|
-
if (saved && !signal?.aborted)
|
|
526
|
-
ctx.ui.notify(`Saved sync setup \u201C${safeTerminalText(partial.setupName)}\u201D.`, "info");
|
|
510
|
+
if (saved && !signal?.aborted) ctx.ui.notify(`Saved sync setup \u201C${safeTerminalText(partial.setupName)}\u201D.`, "info");
|
|
527
511
|
return saved;
|
|
528
512
|
}
|
|
529
513
|
async function promptGitRemote(ctx, signal, current) {
|
|
@@ -569,7 +553,7 @@ import {
|
|
|
569
553
|
Text,
|
|
570
554
|
truncateToWidth
|
|
571
555
|
} from "@earendil-works/pi-tui";
|
|
572
|
-
import { runCustomInteraction } from "@narumitw/pi-tui-kit";
|
|
556
|
+
import { formatInteractionHints, runCustomInteraction } from "@narumitw/pi-tui-kit";
|
|
573
557
|
var MASK = "\u2022";
|
|
574
558
|
async function promptSecret(ctx, title, options = { required: true }) {
|
|
575
559
|
if (ctx.mode !== "tui" || options.signal?.aborted) return void 0;
|
|
@@ -579,13 +563,19 @@ async function promptSecret(ctx, title, options = { required: true }) {
|
|
|
579
563
|
create: ({ tui, theme, keybindings, complete }) => {
|
|
580
564
|
const heading = new Text("", 0, 0);
|
|
581
565
|
const hint = new Text("", 0, 0);
|
|
582
|
-
const
|
|
583
|
-
|
|
566
|
+
const interactionHint = formatInteractionHints(keybindings, [
|
|
567
|
+
{
|
|
568
|
+
keys: keybindings.getKeys("tui.input.submit").filter((key) => !hasControlCharacter(key)),
|
|
569
|
+
label: "continue"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
keys: [...keybindings.getKeys("tui.select.cancel").filter((key) => !hasControlCharacter(key)), "ctrl+c"],
|
|
573
|
+
label: "cancel"
|
|
574
|
+
}
|
|
575
|
+
]);
|
|
584
576
|
const applyTheme = () => {
|
|
585
577
|
heading.setText(theme.fg("accent", theme.bold(title)));
|
|
586
|
-
hint.setText(
|
|
587
|
-
theme.fg("dim", `${submitKey} continue \u2022 ${cancelKey} cancel \u2022 Input is hidden`)
|
|
588
|
-
);
|
|
578
|
+
hint.setText(theme.fg("dim", `${interactionHint} \u2022 Input is hidden`));
|
|
589
579
|
};
|
|
590
580
|
applyTheme();
|
|
591
581
|
const input = new MaskedInput(keybindings);
|
|
@@ -598,11 +588,9 @@ async function promptSecret(ctx, title, options = { required: true }) {
|
|
|
598
588
|
},
|
|
599
589
|
render(width) {
|
|
600
590
|
const safeWidth = Math.max(1, width);
|
|
601
|
-
return [
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
...hint.render(safeWidth)
|
|
605
|
-
].map((line) => truncateToWidth(line, safeWidth));
|
|
591
|
+
return [...heading.render(safeWidth), ...input.render(safeWidth), ...hint.render(safeWidth)].map(
|
|
592
|
+
(line) => truncateToWidth(line, safeWidth)
|
|
593
|
+
);
|
|
606
594
|
},
|
|
607
595
|
invalidate() {
|
|
608
596
|
applyTheme();
|
|
@@ -722,10 +710,7 @@ var MaskedInput = class {
|
|
|
722
710
|
const contentWidth = Math.max(0, available - 1);
|
|
723
711
|
let start = 0;
|
|
724
712
|
if (this.value.length > contentWidth) {
|
|
725
|
-
start = Math.max(
|
|
726
|
-
0,
|
|
727
|
-
Math.min(this.cursor - Math.floor(contentWidth / 2), this.value.length - contentWidth)
|
|
728
|
-
);
|
|
713
|
+
start = Math.max(0, Math.min(this.cursor - Math.floor(contentWidth / 2), this.value.length - contentWidth));
|
|
729
714
|
}
|
|
730
715
|
const end = Math.min(this.value.length, start + contentWidth);
|
|
731
716
|
const visibleCursor = Math.max(0, Math.min(this.cursor - start, end - start));
|
|
@@ -752,14 +737,6 @@ var MaskedInput = class {
|
|
|
752
737
|
this.cursor += characters.length;
|
|
753
738
|
}
|
|
754
739
|
};
|
|
755
|
-
function keybindingText(keybindings, binding, fallback, additionalKeys = []) {
|
|
756
|
-
const keys = [.../* @__PURE__ */ new Set([...keybindings.getKeys(binding), ...additionalKeys])].map(String).map((key) => {
|
|
757
|
-
if (key === "return") return "enter";
|
|
758
|
-
if (key === "escape") return "esc";
|
|
759
|
-
return hasControlCharacter(key) ? "" : key;
|
|
760
|
-
}).filter(Boolean);
|
|
761
|
-
return keys.join("/") || fallback;
|
|
762
|
-
}
|
|
763
740
|
function hasControlCharacter(value) {
|
|
764
741
|
return [...value].some((character) => {
|
|
765
742
|
const code = character.codePointAt(0) ?? 0;
|
|
@@ -771,11 +748,9 @@ function hasControlCharacter(value) {
|
|
|
771
748
|
async function chooseS3CredentialUpdate(ctx, profile, signal) {
|
|
772
749
|
const hasStored = typeof profile.accessKeyId === "string" && profile.accessKeyId.length > 0 && typeof profile.secretAccessKey === "string" && profile.secretAccessKey.length > 0;
|
|
773
750
|
if (hasStored) {
|
|
774
|
-
const action = await ctx.ui.select(
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
{ signal }
|
|
778
|
-
);
|
|
751
|
+
const action = await ctx.ui.select("Credentials", ["Keep current credentials", "Replace credentials", "Cancel"], {
|
|
752
|
+
signal
|
|
753
|
+
});
|
|
779
754
|
throwIfAborted(signal);
|
|
780
755
|
if (!action || action === "Cancel") return void 0;
|
|
781
756
|
if (action === "Keep current credentials") {
|
|
@@ -895,20 +870,13 @@ async function showS3Setup(ctx, preset, targetName, signal) {
|
|
|
895
870
|
if (!saved || signal?.aborted) return false;
|
|
896
871
|
await refreshTargetCompletions();
|
|
897
872
|
if (!signal?.aborted)
|
|
898
|
-
ctx.ui.notify(
|
|
899
|
-
`Sync setup \u201C${safeTerminalText(targetName)}\u201D saved. Choose Sync now to start.`,
|
|
900
|
-
"info"
|
|
901
|
-
);
|
|
873
|
+
ctx.ui.notify(`Sync setup \u201C${safeTerminalText(targetName)}\u201D saved. Choose Sync now to start.`, "info");
|
|
902
874
|
return true;
|
|
903
875
|
}
|
|
904
876
|
async function showAddS3Target(ctx, raw, profile, name, signal) {
|
|
905
877
|
const location = await chooseAdditionalRemoteLocation(ctx, raw, profile, name, signal);
|
|
906
878
|
if (!location) return;
|
|
907
|
-
const storage = await promptAvailableSetupStorage(
|
|
908
|
-
ctx,
|
|
909
|
-
{ connection: profile, ...location },
|
|
910
|
-
signal
|
|
911
|
-
);
|
|
879
|
+
const storage = await promptAvailableSetupStorage(ctx, { connection: profile, ...location }, signal);
|
|
912
880
|
if (!storage) return;
|
|
913
881
|
const include = await chooseSetupContent(ctx, signal);
|
|
914
882
|
if (!include) return;
|
|
@@ -972,16 +940,14 @@ async function showEditS3Target(ctx, partial, signal) {
|
|
|
972
940
|
(saveSignal) => updateSyncSetup(
|
|
973
941
|
partial.setupName,
|
|
974
942
|
(setup) => {
|
|
975
|
-
if (typeof setup.storage.bucket !== "string")
|
|
976
|
-
throw new Error("Sync setup storage type changed; reopen it.");
|
|
943
|
+
if (typeof setup.storage.bucket !== "string") throw new Error("Sync setup storage type changed; reopen it.");
|
|
977
944
|
return { ...setup, storage: { ...setup.storage, bucket, path: storagePath } };
|
|
978
945
|
},
|
|
979
946
|
{ expectedStorage: partial, expectedConnection: connection, signal: saveSignal }
|
|
980
947
|
),
|
|
981
948
|
signal
|
|
982
949
|
);
|
|
983
|
-
if (saved && !signal?.aborted)
|
|
984
|
-
ctx.ui.notify(`Saved sync setup \u201C${safeTerminalText(partial.setupName)}\u201D.`, "info");
|
|
950
|
+
if (saved && !signal?.aborted) ctx.ui.notify(`Saved sync setup \u201C${safeTerminalText(partial.setupName)}\u201D.`, "info");
|
|
985
951
|
}
|
|
986
952
|
|
|
987
953
|
// src/ui/setup/webdav-ui.ts
|
|
@@ -1037,11 +1003,7 @@ async function showWebDavSetup(ctx, targetName, signal) {
|
|
|
1037
1003
|
async function showAddWebDavTarget(ctx, name, profile, signal) {
|
|
1038
1004
|
const remotePath = await chooseDestination(ctx, signal);
|
|
1039
1005
|
if (!remotePath) return false;
|
|
1040
|
-
const storage = await promptAvailableSetupStorage(
|
|
1041
|
-
ctx,
|
|
1042
|
-
{ connection: profile, path: remotePath },
|
|
1043
|
-
signal
|
|
1044
|
-
);
|
|
1006
|
+
const storage = await promptAvailableSetupStorage(ctx, { connection: profile, path: remotePath }, signal);
|
|
1045
1007
|
if (!storage) return false;
|
|
1046
1008
|
const include = await chooseSetupContent(ctx, signal);
|
|
1047
1009
|
if (!include) return false;
|
|
@@ -1094,8 +1056,7 @@ async function showEditWebDavTarget(ctx, partial, signal) {
|
|
|
1094
1056
|
),
|
|
1095
1057
|
signal
|
|
1096
1058
|
);
|
|
1097
|
-
if (saved && !signal?.aborted)
|
|
1098
|
-
ctx.ui.notify(`Saved sync setup \u201C${safeTerminalText(partial.setupName)}\u201D.`, "info");
|
|
1059
|
+
if (saved && !signal?.aborted) ctx.ui.notify(`Saved sync setup \u201C${safeTerminalText(partial.setupName)}\u201D.`, "info");
|
|
1099
1060
|
return saved;
|
|
1100
1061
|
}
|
|
1101
1062
|
async function showAddWebDavStorageProfile(ctx, signal) {
|
|
@@ -1119,32 +1080,19 @@ async function showAddWebDavStorageProfile(ctx, signal) {
|
|
|
1119
1080
|
"Adding a connection does not contact the server or start syncing."
|
|
1120
1081
|
],
|
|
1121
1082
|
"Add storage connection",
|
|
1122
|
-
(saveSignal) => addStorageConnection(
|
|
1123
|
-
name,
|
|
1124
|
-
{ type: "webdav", url, credentials: { username, password } },
|
|
1125
|
-
saveSignal
|
|
1126
|
-
),
|
|
1083
|
+
(saveSignal) => addStorageConnection(name, { type: "webdav", url, credentials: { username, password } }, saveSignal),
|
|
1127
1084
|
signal
|
|
1128
1085
|
);
|
|
1129
1086
|
if (saved && !signal?.aborted) ctx.ui.notify(`Added storage connection \u201C${safeTerminalText(name)}\u201D.`, "info");
|
|
1130
1087
|
return saved;
|
|
1131
1088
|
}
|
|
1132
1089
|
async function showEditWebDavStorageProfile(ctx, name, profile, signal, affectedSetups) {
|
|
1133
|
-
const url = await promptWebDavUrl(
|
|
1134
|
-
ctx,
|
|
1135
|
-
signal,
|
|
1136
|
-
typeof profile.url === "string" ? profile.url : void 0
|
|
1137
|
-
);
|
|
1090
|
+
const url = await promptWebDavUrl(ctx, signal, typeof profile.url === "string" ? profile.url : void 0);
|
|
1138
1091
|
if (!url) return false;
|
|
1139
1092
|
const username = await promptUsername(ctx, signal);
|
|
1140
1093
|
if (!username) return false;
|
|
1141
1094
|
const hasPassword = typeof profile.password === "string" && profile.password.length > 0;
|
|
1142
|
-
const passwordAction = hasPassword ? await select(
|
|
1143
|
-
ctx,
|
|
1144
|
-
"WebDAV password",
|
|
1145
|
-
["Keep current password", "Replace password", "Cancel"],
|
|
1146
|
-
signal
|
|
1147
|
-
) : "Replace password";
|
|
1095
|
+
const passwordAction = hasPassword ? await select(ctx, "WebDAV password", ["Keep current password", "Replace password", "Cancel"], signal) : "Replace password";
|
|
1148
1096
|
if (!passwordAction || passwordAction === "Cancel") return false;
|
|
1149
1097
|
const replacePassword = passwordAction === "Replace password";
|
|
1150
1098
|
const password = replacePassword ? await promptSecret(ctx, "New WebDAV password", { signal }) : void 0;
|
|
@@ -1252,4 +1200,4 @@ export {
|
|
|
1252
1200
|
showAddWebDavStorageProfile,
|
|
1253
1201
|
showEditWebDavStorageProfile
|
|
1254
1202
|
};
|
|
1255
|
-
//# sourceMappingURL=chunk-
|
|
1203
|
+
//# sourceMappingURL=chunk-UA7RXOIT.ts.map
|