@volter/live 0.5.209 → 0.5.211
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/BUNDLED_NOTICES +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +2 -2
- package/dist/session.d.ts +3 -0
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/src/session.ts +24 -5
package/dist/session.d.ts
CHANGED
|
@@ -29,4 +29,7 @@ export interface ProjectSessionHint {
|
|
|
29
29
|
url: string;
|
|
30
30
|
startedAt: string;
|
|
31
31
|
}
|
|
32
|
+
/** The code a refusal carries when the registry was read and no session opens the project: the
|
|
33
|
+
* one state in which "no editor is open here" is a fact, which `close` answers as done. */
|
|
34
|
+
export declare const NO_SESSION_FOR_PROJECT = "VOLTER_NO_SESSION_FOR_PROJECT";
|
|
32
35
|
export declare function resolveSession(projectDir?: string, deps?: SessionResolutionDeps): Promise<ResolvedSession>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/live",
|
|
3
3
|
"author": "Volter AI, Inc.",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.211",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"node": ">=22"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@volter/sdk": "0.5.
|
|
34
|
-
"@volter/project": "0.5.
|
|
33
|
+
"@volter/sdk": "0.5.211",
|
|
34
|
+
"@volter/project": "0.5.211",
|
|
35
35
|
"undici": "^7.28.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { LiveEditorDocument } from './editor-document.js';
|
|
|
12
12
|
export type { DocumentGestureOptions, DocumentKeyOptions, DocumentPasteOptions } from './editor-document.js';
|
|
13
13
|
export { LiveTools } from './tools.js';
|
|
14
14
|
export { editorMemberHint, withEditorMemberHints } from './member-hints.js';
|
|
15
|
-
export { resolveSession, findProjectRootFrom } from './session.js';
|
|
15
|
+
export { resolveSession, findProjectRootFrom, NO_SESSION_FOR_PROJECT } from './session.js';
|
|
16
16
|
export type { ResolvedSession, SessionResolutionDeps, SessionListingTransport, ProjectSessionHint } from './session.js';
|
|
17
17
|
export type { ActiveDocumentCapture, EditorView, PresentedEditorView } from '@volter/sdk';
|
|
18
18
|
|
package/src/session.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* then consult the shared registry. Never fall back to another project.
|
|
4
4
|
* Storage identifiers move with the server in the coordinated migration. */
|
|
5
5
|
|
|
6
|
-
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
6
|
+
import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
7
7
|
import { dirname, join, resolve } from 'node:path';
|
|
8
8
|
import { resolveManifestPath } from '@volter/project/manifest/locate';
|
|
9
9
|
import { resolveProductForProject } from '@volter/sdk/session/product-locator';
|
|
@@ -63,6 +63,22 @@ function canonicalPath(path: string): string {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/** Whether two paths are the same folder on disk, which `canonicalPath` alone misses on Windows
|
|
67
|
+
* (it keeps the letter case typed, and short names and `subst` drives unexpanded). */
|
|
68
|
+
function sameDirectory(a: string, b: string): boolean {
|
|
69
|
+
try {
|
|
70
|
+
const x = statSync(a, { bigint: true });
|
|
71
|
+
const y = statSync(b, { bigint: true });
|
|
72
|
+
return x.dev === y.dev && x.ino === y.ino;
|
|
73
|
+
} catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The code a refusal carries when the registry was read and no session opens the project: the
|
|
79
|
+
* one state in which "no editor is open here" is a fact, which `close` answers as done. */
|
|
80
|
+
export const NO_SESSION_FOR_PROJECT = 'VOLTER_NO_SESSION_FOR_PROJECT';
|
|
81
|
+
|
|
66
82
|
function readProjectSession(projectRoot: string): ProjectSessionHint | null {
|
|
67
83
|
try {
|
|
68
84
|
const value: unknown = JSON.parse(
|
|
@@ -181,16 +197,19 @@ function noMatchingSessionRefusal(
|
|
|
181
197
|
);
|
|
182
198
|
}
|
|
183
199
|
if (sessions.length === 0) {
|
|
184
|
-
return new Error(
|
|
200
|
+
return Object.assign(new Error(
|
|
185
201
|
`@volter/live: the editor session registry is readable and lists NO live sessions, so none ` +
|
|
186
202
|
`covers ${projectRoot}. @volter/live only attaches to an already-running session — it ` +
|
|
187
203
|
`never starts one — so run ${editCommandFor(projectRoot)} in that project first, then retry.`,
|
|
188
|
-
);
|
|
204
|
+
), { code: NO_SESSION_FOR_PROJECT });
|
|
189
205
|
}
|
|
190
206
|
const listed = sessions
|
|
191
207
|
.map((s) => ` port ${s.port} → ${s.project === null ? '(no project)' : s.project}`)
|
|
192
208
|
.join('\n');
|
|
193
|
-
|
|
209
|
+
// A listed session that is this same folder under another spelling is not "nothing open here":
|
|
210
|
+
// it keeps the refusal, so `close` does not report done while that editor runs on.
|
|
211
|
+
const thisFolderElsewhere = sessions.some((s) => s.project !== null && sameDirectory(s.project, projectRoot));
|
|
212
|
+
return Object.assign(new Error(
|
|
194
213
|
`@volter/live: ${sessions.length} live editor session(s) are running, but none of them opens ` +
|
|
195
214
|
`${projectRoot}. @volter/live never silently attaches to a different project.\n` +
|
|
196
215
|
` looking for (resolved): ${canon}\n` +
|
|
@@ -199,7 +218,7 @@ function noMatchingSessionRefusal(
|
|
|
199
218
|
'the usual cause is a git worktree or a symlink, where the session was opened through a ' +
|
|
200
219
|
`different path to the same files. Run ${editCommandFor(projectRoot)} from THIS path, or use the path the ` +
|
|
201
220
|
'session lists.',
|
|
202
|
-
);
|
|
221
|
+
), thisFolderElsewhere ? {} : { code: NO_SESSION_FOR_PROJECT });
|
|
203
222
|
}
|
|
204
223
|
|
|
205
224
|
export async function resolveSession(
|