@flighthq/shell 0.5.1-next.1069.554a2ac → 0.5.1-next.1201.9b49dee
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 +2 -2
- package/dist/shell.d.ts +10 -10
- package/dist/shell.d.ts.map +1 -1
- package/dist/shell.js +18 -18
- package/dist/shell.js.map +1 -1
- package/package.json +2 -2
- package/src/shell.test.ts +44 -41
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/shell`. The `@flight
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/shell@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/shell@0.5.1-next.1201.9b49dee](https://github.com/flighthq/flight/tree/9b49dee3f22f6b2838c3d237edcc77bca65734f2/packages/shell)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/9b49dee3f22f6b2838c3d237edcc77bca65734f2/LICENSE.md)
|
package/dist/shell.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostShellBeepProvider, HostShellExternalProvider, HostShellPathOpenProvider, HostShellPathRevealProvider, HostShellProcessProvider, HostShellShortcutLinkProvider, HostShellTrashProvider, ShellExternalOutcome, ShellExternalUrlPolicy, ShellPathOpenOutcome, ShellPathRevealOutcome, ShellProcess, ShellProcessOptions, ShellShortcutLink, ShellShortcutLinkReadOutcome, ShellShortcutLinkWriteOutcome, ShellShortcutWriteOperation, ShellTrashOutcome } from '@flighthq/types/contract';
|
|
2
2
|
export declare function isShellUrlAllowed(url: string, policy: Readonly<ShellExternalUrlPolicy>): boolean;
|
|
3
|
-
export declare function moveShellItemsToTrash(
|
|
4
|
-
export declare function moveShellItemToTrash(
|
|
5
|
-
export declare function openShellExternalUrl(
|
|
6
|
-
export declare function openShellPath(
|
|
7
|
-
export declare function readShellShortcutLink(
|
|
8
|
-
export declare function revealShellPath(
|
|
9
|
-
export declare function shellBeep(
|
|
10
|
-
export declare function spawnShellProcess(
|
|
11
|
-
export declare function writeShellShortcutLink(
|
|
3
|
+
export declare function moveShellItemsToTrash(hostShellTrash: Readonly<HostShellTrashProvider>, paths: readonly string[]): Promise<readonly ShellTrashOutcome[]>;
|
|
4
|
+
export declare function moveShellItemToTrash(hostShellTrash: Readonly<HostShellTrashProvider>, path: string): Promise<ShellTrashOutcome>;
|
|
5
|
+
export declare function openShellExternalUrl(hostShellExternal: Readonly<HostShellExternalProvider>, url: string, policy: Readonly<ShellExternalUrlPolicy>): Promise<ShellExternalOutcome>;
|
|
6
|
+
export declare function openShellPath(hostShellPathOpen: Readonly<HostShellPathOpenProvider>, path: string): Promise<ShellPathOpenOutcome>;
|
|
7
|
+
export declare function readShellShortcutLink(hostShellShortcutLink: Readonly<HostShellShortcutLinkProvider>, shortcutPath: string): Promise<ShellShortcutLinkReadOutcome>;
|
|
8
|
+
export declare function revealShellPath(hostShellPathReveal: Readonly<HostShellPathRevealProvider>, path: string): Promise<ShellPathRevealOutcome>;
|
|
9
|
+
export declare function shellBeep(hostShellBeep: Readonly<HostShellBeepProvider>): void;
|
|
10
|
+
export declare function spawnShellProcess(hostShellProcess: Readonly<HostShellProcessProvider>, command: string, args: readonly string[], options?: Readonly<ShellProcessOptions>): ShellProcess;
|
|
11
|
+
export declare function writeShellShortcutLink(hostShellShortcutLink: Readonly<HostShellShortcutLinkProvider>, shortcutPath: string, link: Readonly<ShellShortcutLink>, operation: ShellShortcutWriteOperation): Promise<ShellShortcutLinkWriteOutcome>;
|
|
12
12
|
//# sourceMappingURL=shell.d.ts.map
|
package/dist/shell.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","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,MAAM,GACnB,OAAO,CAAC,4BAA4B,CAAC,CAEvC;AAED,wBAAgB,eAAe,CAC7B,mBAAmB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EAC1D,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,sBAAsB,CAAC,CAEjC;AAED,wBAAgB,SAAS,CAAC,aAAa,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAE9E;AAED,wBAAgB,iBAAiB,CAC/B,gBAAgB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,EACpD,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GACtC,YAAY,CAEd;AAED,wBAAgB,sBAAsB,CACpC,qBAAqB,EAAE,QAAQ,CAAC,6BAA6B,CAAC,EAC9D,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,QAAQ,CAAC,iBAAiB,CAAC,EACjC,SAAS,EAAE,2BAA2B,GACrC,OAAO,CAAC,6BAA6B,CAAC,CAExC"}
|
package/dist/shell.js
CHANGED
|
@@ -11,36 +11,36 @@ export function isShellUrlAllowed(url, policy) {
|
|
|
11
11
|
}
|
|
12
12
|
// Projects the one-path provider operation across the batch. Promise.all starts every operation,
|
|
13
13
|
// awaits every settlement, and returns outcomes in the same order as paths.
|
|
14
|
-
export function moveShellItemsToTrash(
|
|
15
|
-
return Promise.all(paths.map((path) =>
|
|
14
|
+
export function moveShellItemsToTrash(hostShellTrash, paths) {
|
|
15
|
+
return Promise.all(paths.map((path) => hostShellTrash.moveToTrash(path)));
|
|
16
16
|
}
|
|
17
|
-
export function moveShellItemToTrash(
|
|
18
|
-
return
|
|
17
|
+
export function moveShellItemToTrash(hostShellTrash, path) {
|
|
18
|
+
return hostShellTrash.moveToTrash(path);
|
|
19
19
|
}
|
|
20
20
|
// Handing a URL to an OS handler can launch a local application or registered protocol. The required
|
|
21
21
|
// per-call policy is validated before dispatch, so a blocked or malformed scheme never reaches the
|
|
22
22
|
// host. There is intentionally no policy default, ambient allowlist, or allow-all path.
|
|
23
|
-
export function openShellExternalUrl(
|
|
23
|
+
export function openShellExternalUrl(hostShellExternal, url, policy) {
|
|
24
24
|
if (!isShellUrlAllowed(url, policy))
|
|
25
25
|
return Promise.resolve({ reason: 'blocked-scheme' });
|
|
26
|
-
return
|
|
26
|
+
return hostShellExternal.open(url);
|
|
27
27
|
}
|
|
28
|
-
export function openShellPath(
|
|
29
|
-
return
|
|
28
|
+
export function openShellPath(hostShellPathOpen, path) {
|
|
29
|
+
return hostShellPathOpen.open(path);
|
|
30
30
|
}
|
|
31
|
-
export function readShellShortcutLink(
|
|
32
|
-
return
|
|
31
|
+
export function readShellShortcutLink(hostShellShortcutLink, shortcutPath) {
|
|
32
|
+
return hostShellShortcutLink.read(shortcutPath);
|
|
33
33
|
}
|
|
34
|
-
export function revealShellPath(
|
|
35
|
-
return
|
|
34
|
+
export function revealShellPath(hostShellPathReveal, path) {
|
|
35
|
+
return hostShellPathReveal.reveal(path);
|
|
36
36
|
}
|
|
37
|
-
export function shellBeep(
|
|
38
|
-
|
|
37
|
+
export function shellBeep(hostShellBeep) {
|
|
38
|
+
hostShellBeep.beep();
|
|
39
39
|
}
|
|
40
|
-
export function spawnShellProcess(
|
|
41
|
-
return
|
|
40
|
+
export function spawnShellProcess(hostShellProcess, command, args, options) {
|
|
41
|
+
return hostShellProcess.spawn(command, args, options);
|
|
42
42
|
}
|
|
43
|
-
export function writeShellShortcutLink(
|
|
44
|
-
return
|
|
43
|
+
export function writeShellShortcutLink(hostShellShortcutLink, shortcutPath, link, operation) {
|
|
44
|
+
return hostShellShortcutLink.write(shortcutPath, link, operation);
|
|
45
45
|
}
|
|
46
46
|
//# sourceMappingURL=shell.js.map
|
package/dist/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../src/shell.ts"],"names":[],"mappings":"AAqBA,s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}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/shell",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.1201.9b49dee",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/types": "0.5.1-next.1201.9b49dee"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@flighthq/entity": "*",
|
package/src/shell.test.ts
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import type {
|
|
3
3
|
EntityRuntimeKey,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ShellBeepBackend,
|
|
11
|
-
ShellExternalBackend,
|
|
4
|
+
HostShellBeepProvider,
|
|
5
|
+
HostShellExternalProvider,
|
|
6
|
+
HostShellPathOpenProvider,
|
|
7
|
+
HostShellPathRevealProvider,
|
|
8
|
+
HostShellShortcutLinkProvider,
|
|
9
|
+
HostShellTrashProvider,
|
|
12
10
|
ShellExternalUrlPolicy,
|
|
13
|
-
ShellPathOpenBackend,
|
|
14
|
-
ShellPathRevealBackend,
|
|
15
11
|
ShellProcess,
|
|
16
|
-
|
|
17
|
-
ShellProcessHost,
|
|
12
|
+
HostShellProcessProvider,
|
|
18
13
|
ShellProcessOptions,
|
|
19
|
-
ShellShortcutLinkBackend,
|
|
20
|
-
ShellTrashBackend,
|
|
21
14
|
} from '@flighthq/types/contract';
|
|
22
15
|
|
|
23
16
|
import {
|
|
@@ -60,7 +53,7 @@ describe('moveShellItemsToTrash', () => {
|
|
|
60
53
|
})(),
|
|
61
54
|
);
|
|
62
55
|
|
|
63
|
-
const outcomes = moveShellItemsToTrash(host, ['/first', '/second']);
|
|
56
|
+
const outcomes = moveShellItemsToTrash(host.shell.trash, ['/first', '/second']);
|
|
64
57
|
expect(paths).toEqual(['/first', '/second']);
|
|
65
58
|
resolvers[1]?.({ reason: 'operation-failed' });
|
|
66
59
|
let settled = false;
|
|
@@ -85,7 +78,7 @@ describe('moveShellItemToTrash', () => {
|
|
|
85
78
|
out.moveToTrash = moveToTrash;
|
|
86
79
|
return finishEntity(out);
|
|
87
80
|
})(),
|
|
88
|
-
),
|
|
81
|
+
).shell.trash,
|
|
89
82
|
'/item',
|
|
90
83
|
),
|
|
91
84
|
).resolves.toEqual({
|
|
@@ -98,7 +91,7 @@ describe('moveShellItemToTrash', () => {
|
|
|
98
91
|
describe('openShellExternalUrl', () => {
|
|
99
92
|
it('requires policy as the third parameter at the type boundary', () => {
|
|
100
93
|
expectTypeOf(openShellExternalUrl).parameters.toEqualTypeOf<
|
|
101
|
-
[
|
|
94
|
+
[Readonly<HostShellExternalProvider>, string, Readonly<ShellExternalUrlPolicy>]
|
|
102
95
|
>();
|
|
103
96
|
});
|
|
104
97
|
|
|
@@ -111,7 +104,9 @@ describe('openShellExternalUrl', () => {
|
|
|
111
104
|
return finishEntity(out);
|
|
112
105
|
})(),
|
|
113
106
|
);
|
|
114
|
-
await expect(
|
|
107
|
+
await expect(
|
|
108
|
+
openShellExternalUrl(host.shell.external, 'file:///etc/passwd', { allowedSchemes: ['https'] }),
|
|
109
|
+
).resolves.toEqual({
|
|
115
110
|
reason: 'blocked-scheme',
|
|
116
111
|
});
|
|
117
112
|
expect(open).not.toHaveBeenCalled();
|
|
@@ -139,8 +134,10 @@ describe('openShellExternalUrl', () => {
|
|
|
139
134
|
return finishEntity(out);
|
|
140
135
|
})(),
|
|
141
136
|
);
|
|
142
|
-
await expect(openShellExternalUrl(first, 'https://one.test', HTTPS_ONLY)).resolves.toEqual({
|
|
143
|
-
|
|
137
|
+
await expect(openShellExternalUrl(first.shell.external, 'https://one.test', HTTPS_ONLY)).resolves.toEqual({
|
|
138
|
+
reason: 'ok',
|
|
139
|
+
});
|
|
140
|
+
await expect(openShellExternalUrl(second.shell.external, 'https://two.test', HTTPS_ONLY)).resolves.toEqual({
|
|
144
141
|
reason: 'operation-failed',
|
|
145
142
|
});
|
|
146
143
|
expect(calls).toEqual(['first:https://one.test', 'second:https://two.test']);
|
|
@@ -149,11 +146,11 @@ describe('openShellExternalUrl', () => {
|
|
|
149
146
|
|
|
150
147
|
describe('openShellPath', () => {
|
|
151
148
|
it('preserves a provider failure and its message', async () => {
|
|
152
|
-
const provider = allocateEntity<
|
|
149
|
+
const provider = allocateEntity<HostShellPathOpenProvider>();
|
|
153
150
|
provider.open = async () => {
|
|
154
151
|
return { message: '', reason: 'operation-failed' as const };
|
|
155
152
|
};
|
|
156
|
-
await expect(openShellPath(pathOpenHost(finishEntity(provider)), '/missing')).resolves.toEqual({
|
|
153
|
+
await expect(openShellPath(pathOpenHost(finishEntity(provider)).shell.pathOpen, '/missing')).resolves.toEqual({
|
|
157
154
|
message: '',
|
|
158
155
|
reason: 'operation-failed',
|
|
159
156
|
});
|
|
@@ -163,7 +160,7 @@ describe('openShellPath', () => {
|
|
|
163
160
|
describe('readShellShortcutLink', () => {
|
|
164
161
|
it('returns the read-specific outcome', async () => {
|
|
165
162
|
const provider = shortcutLinkProvider();
|
|
166
|
-
await expect(readShellShortcutLink(shortcutLinkHost(provider), '/app.lnk')).resolves.toEqual({
|
|
163
|
+
await expect(readShellShortcutLink(shortcutLinkHost(provider).shell.shortcutLink, '/app.lnk')).resolves.toEqual({
|
|
167
164
|
link: { target: '/app' },
|
|
168
165
|
reason: 'ok',
|
|
169
166
|
});
|
|
@@ -181,7 +178,7 @@ describe('revealShellPath', () => {
|
|
|
181
178
|
out.reveal = reveal;
|
|
182
179
|
return finishEntity(out);
|
|
183
180
|
})(),
|
|
184
|
-
),
|
|
181
|
+
).shell.pathReveal,
|
|
185
182
|
'/item',
|
|
186
183
|
),
|
|
187
184
|
).resolves.toEqual({
|
|
@@ -200,7 +197,7 @@ describe('shellBeep', () => {
|
|
|
200
197
|
out.beep = beep;
|
|
201
198
|
return finishEntity(out);
|
|
202
199
|
})(),
|
|
203
|
-
),
|
|
200
|
+
).shell.beep,
|
|
204
201
|
);
|
|
205
202
|
expect(beep).toHaveBeenCalledOnce();
|
|
206
203
|
});
|
|
@@ -209,9 +206,9 @@ describe('shellBeep', () => {
|
|
|
209
206
|
describe('spawnShellProcess', () => {
|
|
210
207
|
it('exposes the explicit host, command, argument-vector, and optional-options API', () => {
|
|
211
208
|
expectTypeOf(spawnShellProcess).parameters.toEqualTypeOf<
|
|
212
|
-
[
|
|
209
|
+
[Readonly<HostShellProcessProvider>, string, readonly string[], Readonly<ShellProcessOptions>?]
|
|
213
210
|
>();
|
|
214
|
-
expectTypeOf(spawnShellProcess).returns.toEqualTypeOf<ShellProcess
|
|
211
|
+
expectTypeOf(spawnShellProcess).returns.toEqualTypeOf<ShellProcess>();
|
|
215
212
|
});
|
|
216
213
|
|
|
217
214
|
it('forwards the command, argument vector, and options to the host backend unchanged', () => {
|
|
@@ -227,20 +224,16 @@ describe('spawnShellProcess', () => {
|
|
|
227
224
|
const args = ['--flag', 'value'] as const;
|
|
228
225
|
const options = { cwd: '/work', environment: { MODE: 'test' } } as const;
|
|
229
226
|
|
|
230
|
-
expect(spawnShellProcess(host, '/bin/tool', args, options)).toBe(process);
|
|
227
|
+
expect(spawnShellProcess(host.shell.process, '/bin/tool', args, options)).toBe(process);
|
|
231
228
|
expect(spawn).toHaveBeenCalledWith('/bin/tool', args, options);
|
|
232
229
|
});
|
|
233
|
-
|
|
234
|
-
it('returns null when the host does not expose child-process support', () => {
|
|
235
|
-
expect(spawnShellProcess({ shell: {} }, '/bin/tool', [])).toBeNull();
|
|
236
|
-
});
|
|
237
230
|
});
|
|
238
231
|
|
|
239
232
|
describe('writeShellShortcutLink', () => {
|
|
240
233
|
it('requires an explicit write operation and returns the write-specific outcome', async () => {
|
|
241
234
|
const provider = shortcutLinkProvider();
|
|
242
235
|
await expect(
|
|
243
|
-
writeShellShortcutLink(shortcutLinkHost(provider), '/app.lnk', { target: '/app' }, 'replace'),
|
|
236
|
+
writeShellShortcutLink(shortcutLinkHost(provider).shell.shortcutLink, '/app.lnk', { target: '/app' }, 'replace'),
|
|
244
237
|
).resolves.toEqual({ reason: 'ok' });
|
|
245
238
|
expect(provider.write).toHaveBeenCalledWith('/app.lnk', { target: '/app' }, 'replace');
|
|
246
239
|
});
|
|
@@ -248,23 +241,31 @@ describe('writeShellShortcutLink', () => {
|
|
|
248
241
|
|
|
249
242
|
const HTTPS_ONLY: ShellExternalUrlPolicy = { allowedSchemes: ['https'] };
|
|
250
243
|
|
|
251
|
-
function beepHost(beep:
|
|
244
|
+
function beepHost(beep: HostShellBeepProvider): { readonly shell: { readonly beep: HostShellBeepProvider } } {
|
|
252
245
|
return { shell: { beep } };
|
|
253
246
|
}
|
|
254
247
|
|
|
255
|
-
function externalHost(external:
|
|
248
|
+
function externalHost(external: HostShellExternalProvider): {
|
|
249
|
+
readonly shell: { readonly external: HostShellExternalProvider };
|
|
250
|
+
} {
|
|
256
251
|
return { shell: { external } };
|
|
257
252
|
}
|
|
258
253
|
|
|
259
|
-
function pathOpenHost(pathOpen:
|
|
254
|
+
function pathOpenHost(pathOpen: HostShellPathOpenProvider): {
|
|
255
|
+
readonly shell: { readonly pathOpen: HostShellPathOpenProvider };
|
|
256
|
+
} {
|
|
260
257
|
return { shell: { pathOpen } };
|
|
261
258
|
}
|
|
262
259
|
|
|
263
|
-
function pathRevealHost(pathReveal:
|
|
260
|
+
function pathRevealHost(pathReveal: HostShellPathRevealProvider): {
|
|
261
|
+
readonly shell: { readonly pathReveal: HostShellPathRevealProvider };
|
|
262
|
+
} {
|
|
264
263
|
return { shell: { pathReveal } };
|
|
265
264
|
}
|
|
266
265
|
|
|
267
|
-
function processHost(process:
|
|
266
|
+
function processHost(process: HostShellProcessProvider): {
|
|
267
|
+
readonly shell: { readonly process: HostShellProcessProvider };
|
|
268
|
+
} {
|
|
268
269
|
return { shell: { process } };
|
|
269
270
|
}
|
|
270
271
|
|
|
@@ -278,11 +279,13 @@ function shellProcess(): ShellProcess {
|
|
|
278
279
|
return finishEntity(out);
|
|
279
280
|
}
|
|
280
281
|
|
|
281
|
-
function shortcutLinkHost(shortcutLink:
|
|
282
|
+
function shortcutLinkHost(shortcutLink: HostShellShortcutLinkProvider): {
|
|
283
|
+
readonly shell: { readonly shortcutLink: HostShellShortcutLinkProvider };
|
|
284
|
+
} {
|
|
282
285
|
return { shell: { shortcutLink } };
|
|
283
286
|
}
|
|
284
287
|
|
|
285
|
-
function shortcutLinkProvider():
|
|
288
|
+
function shortcutLinkProvider(): HostShellShortcutLinkProvider & { write: ReturnType<typeof vi.fn> } {
|
|
286
289
|
const out = allocateEntity<any>();
|
|
287
290
|
out.read = async () => {
|
|
288
291
|
return { link: { target: '/app' }, reason: 'ok' };
|
|
@@ -291,6 +294,6 @@ function shortcutLinkProvider(): ShellShortcutLinkBackend & { write: ReturnType<
|
|
|
291
294
|
return finishEntity(out);
|
|
292
295
|
}
|
|
293
296
|
|
|
294
|
-
function trashHost(trash:
|
|
297
|
+
function trashHost(trash: HostShellTrashProvider): { readonly shell: { readonly trash: HostShellTrashProvider } } {
|
|
295
298
|
return { shell: { trash } };
|
|
296
299
|
}
|