@theia/preferences 1.76.0-next.7 → 1.76.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/lib/browser/preference-frontend-contribution.d.ts +18 -0
- package/lib/browser/preference-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/preference-frontend-contribution.js +48 -12
- package/lib/browser/preference-frontend-contribution.js.map +1 -1
- package/lib/browser/preference-frontend-contribution.spec.d.ts +2 -0
- package/lib/browser/preference-frontend-contribution.spec.d.ts.map +1 -0
- package/lib/browser/preference-frontend-contribution.spec.js +76 -0
- package/lib/browser/preference-frontend-contribution.spec.js.map +1 -0
- package/lib/browser/preference-frontend-module.d.ts.map +1 -1
- package/lib/browser/preference-frontend-module.js +4 -0
- package/lib/browser/preference-frontend-module.js.map +1 -1
- package/lib/browser/session-preference-remote-cli-contribution.d.ts +17 -0
- package/lib/browser/session-preference-remote-cli-contribution.d.ts.map +1 -0
- package/lib/browser/session-preference-remote-cli-contribution.js +54 -0
- package/lib/browser/session-preference-remote-cli-contribution.js.map +1 -0
- package/lib/browser/session-preference-remote-cli-contribution.spec.d.ts +2 -0
- package/lib/browser/session-preference-remote-cli-contribution.spec.d.ts.map +1 -0
- package/lib/browser/session-preference-remote-cli-contribution.spec.js +50 -0
- package/lib/browser/session-preference-remote-cli-contribution.spec.js.map +1 -0
- package/lib/common/cli-preferences.d.ts +28 -0
- package/lib/common/cli-preferences.d.ts.map +1 -1
- package/lib/common/cli-preferences.js +66 -1
- package/lib/common/cli-preferences.js.map +1 -1
- package/lib/common/cli-preferences.spec.d.ts +2 -0
- package/lib/common/cli-preferences.spec.d.ts.map +1 -0
- package/lib/common/cli-preferences.spec.js +64 -0
- package/lib/common/cli-preferences.spec.js.map +1 -0
- package/lib/node/preference-cli-contribution.d.ts.map +1 -1
- package/lib/node/preference-cli-contribution.js +3 -22
- package/lib/node/preference-cli-contribution.js.map +1 -1
- package/package.json +9 -9
- package/src/browser/preference-frontend-contribution.spec.ts +92 -0
- package/src/browser/preference-frontend-contribution.ts +50 -13
- package/src/browser/preference-frontend-module.ts +4 -0
- package/src/browser/session-preference-remote-cli-contribution.spec.ts +59 -0
- package/src/browser/session-preference-remote-cli-contribution.ts +49 -0
- package/src/common/cli-preferences.spec.ts +73 -0
- package/src/common/cli-preferences.ts +75 -0
- package/src/node/preference-cli-contribution.ts +3 -22
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
2
|
+
import { WindowLaunchArgs } from '@theia/core/lib/browser/window/window-launch-args';
|
|
2
3
|
import { CliPreferences } from '../common/cli-preferences';
|
|
3
4
|
import { PreferenceService, PreferenceScope } from '@theia/core/lib/common/preferences';
|
|
4
5
|
import { ILogger } from '@theia/core';
|
|
@@ -6,8 +7,25 @@ export declare class PreferenceFrontendContribution implements FrontendApplicati
|
|
|
6
7
|
protected readonly CliPreferences: CliPreferences;
|
|
7
8
|
protected readonly preferenceService: PreferenceService;
|
|
8
9
|
protected readonly logger: ILogger;
|
|
10
|
+
protected readonly launchArgs: WindowLaunchArgs;
|
|
9
11
|
onStart(): void;
|
|
10
12
|
protected applyCliPreferences(): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the CLI-provided preferences to apply to this window.
|
|
15
|
+
*
|
|
16
|
+
* The shared backend reflects the original cold-start launch (it cannot distinguish between
|
|
17
|
+
* windows), so it supplies the process-wide CLI preferences. A forwarded (second-instance)
|
|
18
|
+
* window additionally carries its own options, provided by the trusted main process, and layers
|
|
19
|
+
* them on top, overriding by key. Merging (rather than replacing) means a plain
|
|
20
|
+
* second-instance window keeps the process-wide values instead of dropping them, while an attach
|
|
21
|
+
* window still gets its own overrides.
|
|
22
|
+
*/
|
|
23
|
+
protected resolveCliPreferences(): Promise<{
|
|
24
|
+
session: [string, unknown][];
|
|
25
|
+
persistent: [string, unknown][];
|
|
26
|
+
}>;
|
|
27
|
+
/** Overlays `overrides` onto `base`, later entries winning per key while preserving order (base first). */
|
|
28
|
+
protected mergeEntries(base: ReadonlyArray<[string, unknown]>, overrides: ReadonlyArray<[string, unknown]>): [string, unknown][];
|
|
11
29
|
/**
|
|
12
30
|
* Applies a batch of CLI-provided preferences sequentially. A rejection from an
|
|
13
31
|
* individual write (bad key, invalid scope, etc.) is logged and does not abort the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preference-frontend-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/preference-frontend-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"preference-frontend-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/preference-frontend-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EAAE,cAAc,EAAsB,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,qBACa,8BAA+B,YAAW,+BAA+B;IAElF,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAGlD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAGxD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAGnC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAEhD,OAAO,IAAI,IAAI;cAIC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBpD;;;;;;;;;OASG;cACa,qBAAqB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAAC,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;KAAE,CAAC;IAwBnH,2GAA2G;IAC3G,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAQhI;;;;OAIG;cACa,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAS7G"}
|
|
@@ -18,6 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.PreferenceFrontendContribution = void 0;
|
|
19
19
|
const tslib_1 = require("tslib");
|
|
20
20
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const launch_arguments_1 = require("@theia/core/lib/common/launch-arguments");
|
|
22
|
+
const window_launch_args_1 = require("@theia/core/lib/browser/window/window-launch-args");
|
|
21
23
|
const cli_preferences_1 = require("../common/cli-preferences");
|
|
22
24
|
const preferences_1 = require("@theia/core/lib/common/preferences");
|
|
23
25
|
const core_1 = require("@theia/core");
|
|
@@ -26,18 +28,7 @@ let PreferenceFrontendContribution = class PreferenceFrontendContribution {
|
|
|
26
28
|
this.applyCliPreferences();
|
|
27
29
|
}
|
|
28
30
|
async applyCliPreferences() {
|
|
29
|
-
|
|
30
|
-
// can overlap with the preference service initialising its providers.
|
|
31
|
-
const [session, persistent] = await Promise.all([
|
|
32
|
-
this.CliPreferences.getSessionPreferences().catch(e => {
|
|
33
|
-
this.logger.warn('Failed to fetch --session-preference values:', e);
|
|
34
|
-
return [];
|
|
35
|
-
}),
|
|
36
|
-
this.CliPreferences.getPreferences().catch(e => {
|
|
37
|
-
this.logger.warn('Failed to fetch --set-preference values:', e);
|
|
38
|
-
return [];
|
|
39
|
-
})
|
|
40
|
-
]);
|
|
31
|
+
const { session, persistent } = await this.resolveCliPreferences();
|
|
41
32
|
// `preferenceService.set()` needs the target provider registered in the providers
|
|
42
33
|
// map, which only happens once `initializeProviders()` has walked every scope and
|
|
43
34
|
// resolved `ready`. Writing before that returns `undefined` from `getProvider()`
|
|
@@ -55,6 +46,47 @@ let PreferenceFrontendContribution = class PreferenceFrontendContribution {
|
|
|
55
46
|
}
|
|
56
47
|
await this.applyAll(persistent, preferences_1.PreferenceScope.User);
|
|
57
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolves the CLI-provided preferences to apply to this window.
|
|
51
|
+
*
|
|
52
|
+
* The shared backend reflects the original cold-start launch (it cannot distinguish between
|
|
53
|
+
* windows), so it supplies the process-wide CLI preferences. A forwarded (second-instance)
|
|
54
|
+
* window additionally carries its own options, provided by the trusted main process, and layers
|
|
55
|
+
* them on top, overriding by key. Merging (rather than replacing) means a plain
|
|
56
|
+
* second-instance window keeps the process-wide values instead of dropping them, while an attach
|
|
57
|
+
* window still gets its own overrides.
|
|
58
|
+
*/
|
|
59
|
+
async resolveCliPreferences() {
|
|
60
|
+
// Fetch both buckets in parallel; both are RPC hops to the same backend and
|
|
61
|
+
// can overlap with the preference service initialising its providers.
|
|
62
|
+
const [session, persistent] = await Promise.all([
|
|
63
|
+
this.CliPreferences.getSessionPreferences().catch(e => {
|
|
64
|
+
this.logger.warn('Failed to fetch --session-preference values:', e);
|
|
65
|
+
return [];
|
|
66
|
+
}),
|
|
67
|
+
this.CliPreferences.getPreferences().catch(e => {
|
|
68
|
+
this.logger.warn('Failed to fetch --set-preference values:', e);
|
|
69
|
+
return [];
|
|
70
|
+
})
|
|
71
|
+
]);
|
|
72
|
+
const forwarded = this.launchArgs.getLaunchArgs();
|
|
73
|
+
if (forwarded === undefined) {
|
|
74
|
+
return { session, persistent };
|
|
75
|
+
}
|
|
76
|
+
const warn = (message) => this.logger.warn(message);
|
|
77
|
+
return {
|
|
78
|
+
session: this.mergeEntries(session, cli_preferences_1.CliPreferenceEntry.parseAll(launch_arguments_1.LaunchArguments.values(forwarded, 'session-preference'), warn)),
|
|
79
|
+
persistent: this.mergeEntries(persistent, cli_preferences_1.CliPreferenceEntry.parseAll(launch_arguments_1.LaunchArguments.values(forwarded, 'set-preference'), warn))
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Overlays `overrides` onto `base`, later entries winning per key while preserving order (base first). */
|
|
83
|
+
mergeEntries(base, overrides) {
|
|
84
|
+
const merged = new Map();
|
|
85
|
+
for (const [key, value] of [...base, ...overrides]) {
|
|
86
|
+
merged.set(key, value);
|
|
87
|
+
}
|
|
88
|
+
return [...merged];
|
|
89
|
+
}
|
|
58
90
|
/**
|
|
59
91
|
* Applies a batch of CLI-provided preferences sequentially. A rejection from an
|
|
60
92
|
* individual write (bad key, invalid scope, etc.) is logged and does not abort the
|
|
@@ -85,6 +117,10 @@ tslib_1.__decorate([
|
|
|
85
117
|
(0, inversify_1.named)('preferences:PreferenceFrontendContribution'),
|
|
86
118
|
tslib_1.__metadata("design:type", Object)
|
|
87
119
|
], PreferenceFrontendContribution.prototype, "logger", void 0);
|
|
120
|
+
tslib_1.__decorate([
|
|
121
|
+
(0, inversify_1.inject)(window_launch_args_1.WindowLaunchArgs),
|
|
122
|
+
tslib_1.__metadata("design:type", Object)
|
|
123
|
+
], PreferenceFrontendContribution.prototype, "launchArgs", void 0);
|
|
88
124
|
exports.PreferenceFrontendContribution = PreferenceFrontendContribution = tslib_1.__decorate([
|
|
89
125
|
(0, inversify_1.injectable)()
|
|
90
126
|
], PreferenceFrontendContribution);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preference-frontend-contribution.js","sourceRoot":"","sources":["../../src/browser/preference-frontend-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAyE;AAEzE,+
|
|
1
|
+
{"version":3,"file":"preference-frontend-contribution.js","sourceRoot":"","sources":["../../src/browser/preference-frontend-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAyE;AAEzE,8EAA0E;AAC1E,0FAAqF;AACrF,+DAA+E;AAC/E,oEAAwF;AACxF,sCAAsC;AAG/B,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAavC,OAAO;QACH,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IAES,KAAK,CAAC,mBAAmB;QAC/B,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAEnE,kFAAkF;QAClF,kFAAkF;QAClF,iFAAiF;QACjF,yDAAyD;QACzD,MAAM,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;QAEnC,iFAAiF;QACjF,gFAAgF;QAChF,kFAAkF;QAClF,qEAAqE;QACrE,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,6BAAe,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,yEAAyE;YACzE,wFAAwF;YACxF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,OAAO,CAAC,MAAM,iCAAiC,EACvE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAA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GAAE;GACA,8BAA8B,CAkG1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preference-frontend-contribution.spec.d.ts","sourceRoot":"","sources":["../../src/browser/preference-frontend-contribution.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 EclipseSource GmbH and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const chai_1 = require("chai");
|
|
19
|
+
const launchArgs = (values) => ({ values, negated: [] });
|
|
20
|
+
const preference_frontend_contribution_1 = require("./preference-frontend-contribution");
|
|
21
|
+
class TestPreferenceFrontendContribution extends preference_frontend_contribution_1.PreferenceFrontendContribution {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.sessionBackendCalls = 0;
|
|
25
|
+
this.persistentBackendCalls = 0;
|
|
26
|
+
}
|
|
27
|
+
resolve() {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
this.launchArgs = { getLaunchArgs: () => this.forwardedArgs };
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
this.CliPreferences = {
|
|
32
|
+
getSessionPreferences: async () => {
|
|
33
|
+
this.sessionBackendCalls++;
|
|
34
|
+
return [['backend.session', 1]];
|
|
35
|
+
},
|
|
36
|
+
getPreferences: async () => {
|
|
37
|
+
this.persistentBackendCalls++;
|
|
38
|
+
return [['backend.persistent', 2]];
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return this.resolveCliPreferences();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
describe('PreferenceFrontendContribution#resolveCliPreferences', () => {
|
|
45
|
+
let contribution;
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
contribution = new TestPreferenceFrontendContribution();
|
|
48
|
+
});
|
|
49
|
+
it('reads preferences from the backend on a cold-start window (no forwarded options)', async () => {
|
|
50
|
+
contribution.forwardedArgs = undefined;
|
|
51
|
+
const result = await contribution.resolve();
|
|
52
|
+
(0, chai_1.expect)(result.session).to.deep.equal([['backend.session', 1]]);
|
|
53
|
+
(0, chai_1.expect)(result.persistent).to.deep.equal([['backend.persistent', 2]]);
|
|
54
|
+
(0, chai_1.expect)(contribution.sessionBackendCalls).to.equal(1);
|
|
55
|
+
});
|
|
56
|
+
it('layers --session-preference from the forwarded options on top of the backend values', async () => {
|
|
57
|
+
contribution.forwardedArgs = launchArgs({ 'session-preference': ['editor.fontSize=20'], 'attach-container': ['B'] });
|
|
58
|
+
const result = await contribution.resolve();
|
|
59
|
+
// Process-wide backend values are kept (base) and the forwarded value is added on top.
|
|
60
|
+
(0, chai_1.expect)(result.session).to.deep.equal([['backend.session', 1], ['editor.fontSize', 20]]);
|
|
61
|
+
(0, chai_1.expect)(result.persistent).to.deep.equal([['backend.persistent', 2]]);
|
|
62
|
+
(0, chai_1.expect)(contribution.sessionBackendCalls).to.equal(1);
|
|
63
|
+
});
|
|
64
|
+
it('layers --set-preference from the forwarded options on top of the backend values', async () => {
|
|
65
|
+
contribution.forwardedArgs = launchArgs({ 'set-preference': ['editor.tabSize=2'] });
|
|
66
|
+
const result = await contribution.resolve();
|
|
67
|
+
(0, chai_1.expect)(result.persistent).to.deep.equal([['backend.persistent', 2], ['editor.tabSize', 2]]);
|
|
68
|
+
(0, chai_1.expect)(result.session).to.deep.equal([['backend.session', 1]]);
|
|
69
|
+
});
|
|
70
|
+
it('lets a forwarded value override a same-key backend value', async () => {
|
|
71
|
+
contribution.forwardedArgs = launchArgs({ 'session-preference': ['backend.session=99'] });
|
|
72
|
+
const result = await contribution.resolve();
|
|
73
|
+
(0, chai_1.expect)(result.session).to.deep.equal([['backend.session', 99]]);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=preference-frontend-contribution.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preference-frontend-contribution.spec.js","sourceRoot":"","sources":["../../src/browser/preference-frontend-contribution.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,+BAA8B;AAG9B,MAAM,UAAU,GAAG,CAAC,MAAgC,EAAmB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;AACpG,yFAAoF;AAEpF,MAAM,kCAAmC,SAAQ,iEAA8B;IAA/E;;QAGI,wBAAmB,GAAG,CAAC,CAAC;QACxB,2BAAsB,GAAG,CAAC,CAAC;IAkB/B,CAAC;IAhBG,OAAO;QACH,8DAA8D;QAC7D,IAAY,CAAC,UAAU,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QACvE,8DAA8D;QAC7D,IAAY,CAAC,cAAc,GAAG;YAC3B,qBAAqB,EAAE,KAAK,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,aAAa,GAAG,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC;QAE1F,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,CAAC;QAE5C,IAAA,aAAM,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preference-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/preference-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"preference-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/preference-frontend-module.ts"],"names":[],"mappings":"AAgBA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AA0B3E,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,IAAI,CAqCtF;;AAED,wBAEG"}
|
|
@@ -34,6 +34,8 @@ const preference_open_handler_1 = require("./preference-open-handler");
|
|
|
34
34
|
const cli_preferences_1 = require("../common/cli-preferences");
|
|
35
35
|
const service_connection_provider_1 = require("@theia/core/lib/browser/messaging/service-connection-provider");
|
|
36
36
|
const preference_frontend_contribution_1 = require("./preference-frontend-contribution");
|
|
37
|
+
const remote_cli_args_contribution_1 = require("@theia/core/lib/common/remote-cli-args-contribution");
|
|
38
|
+
const session_preference_remote_cli_contribution_1 = require("./session-preference-remote-cli-contribution");
|
|
37
39
|
const session_preference_status_bar_contribution_1 = require("./session-preference-status-bar-contribution");
|
|
38
40
|
const preference_layout_1 = require("./util/preference-layout");
|
|
39
41
|
const preference_widget_1 = require("./views/preference-widget");
|
|
@@ -59,6 +61,8 @@ function bindPreferences(bind, unbind) {
|
|
|
59
61
|
bind(cli_preferences_1.CliPreferences).toDynamicValue(ctx => service_connection_provider_1.ServiceConnectionProvider.createProxy(ctx.container, cli_preferences_1.CliPreferencesPath)).inSingletonScope();
|
|
60
62
|
bind(preference_frontend_contribution_1.PreferenceFrontendContribution).toSelf().inSingletonScope();
|
|
61
63
|
bind(browser_1.FrontendApplicationContribution).toService(preference_frontend_contribution_1.PreferenceFrontendContribution);
|
|
64
|
+
bind(session_preference_remote_cli_contribution_1.SessionPreferenceRemoteCliContribution).toSelf().inSingletonScope();
|
|
65
|
+
bind(remote_cli_args_contribution_1.RemoteCliArgsContribution).toService(session_preference_remote_cli_contribution_1.SessionPreferenceRemoteCliContribution);
|
|
62
66
|
bind(session_preference_status_bar_contribution_1.SessionPreferenceStatusBarContribution).toSelf().inSingletonScope();
|
|
63
67
|
bind(browser_1.FrontendApplicationContribution).toService(session_preference_status_bar_contribution_1.SessionPreferenceStatusBarContribution);
|
|
64
68
|
bind(browser_1.WidgetStatusBarContribution).toConstantValue((0, browser_1.noopWidgetStatusBarContribution)(preference_widget_1.PreferencesWidget));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preference-frontend-module.js","sourceRoot":"","sources":["../../src/browser/preference-frontend-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;
|
|
1
|
+
{"version":3,"file":"preference-frontend-module.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C,mFAAsC,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACzE,IAAI,CAAC,yCAA+B,CAAC,CAAC,SAAS,CAAC,mFAAsC,CAAC,CAAC;IAExF,IAAI,CAAC,qCAA2B,CAAC,CAAC,eAAe,CAAC,IAAA,yCAA+B,EAAC,qCAAiB,CAAC,CAAC,CAAC;AAC1G,CAAC;AAED,kBAAe,IAAI,2BAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IACjE,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RemoteCliArgsContribution } from '@theia/core/lib/common/remote-cli-args-contribution';
|
|
2
|
+
import { WindowLaunchArgs } from '@theia/core/lib/browser/window/window-launch-args';
|
|
3
|
+
/**
|
|
4
|
+
* Re-applies `--session-preference` values on a remote backend that is started for a *forwarded*
|
|
5
|
+
* (second-instance) window.
|
|
6
|
+
*
|
|
7
|
+
* The shared local backend only knows the preferences of the original cold-start launch, so its
|
|
8
|
+
* `RemoteCliContribution#enhanceArgs` cannot supply the right values for a window opened by a
|
|
9
|
+
* later launch. This frontend contribution reads the session preferences forwarded to the current
|
|
10
|
+
* window (provided by the trusted main process) and formats them as CLI arguments for the remote
|
|
11
|
+
* backend.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SessionPreferenceRemoteCliContribution implements RemoteCliArgsContribution {
|
|
14
|
+
protected readonly launchArgs: WindowLaunchArgs;
|
|
15
|
+
getRemoteCliArgs(): Promise<string[]>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=session-preference-remote-cli-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-preference-remote-cli-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/session-preference-remote-cli-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qDAAqD,CAAC;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAGrF;;;;;;;;;GASG;AACH,qBACa,sCAAuC,YAAW,yBAAyB;IAGpF,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IAE1C,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAU9C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 EclipseSource GmbH and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.SessionPreferenceRemoteCliContribution = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const launch_arguments_1 = require("@theia/core/lib/common/launch-arguments");
|
|
22
|
+
const window_launch_args_1 = require("@theia/core/lib/browser/window/window-launch-args");
|
|
23
|
+
const cli_preferences_1 = require("../common/cli-preferences");
|
|
24
|
+
/**
|
|
25
|
+
* Re-applies `--session-preference` values on a remote backend that is started for a *forwarded*
|
|
26
|
+
* (second-instance) window.
|
|
27
|
+
*
|
|
28
|
+
* The shared local backend only knows the preferences of the original cold-start launch, so its
|
|
29
|
+
* `RemoteCliContribution#enhanceArgs` cannot supply the right values for a window opened by a
|
|
30
|
+
* later launch. This frontend contribution reads the session preferences forwarded to the current
|
|
31
|
+
* window (provided by the trusted main process) and formats them as CLI arguments for the remote
|
|
32
|
+
* backend.
|
|
33
|
+
*/
|
|
34
|
+
let SessionPreferenceRemoteCliContribution = class SessionPreferenceRemoteCliContribution {
|
|
35
|
+
async getRemoteCliArgs() {
|
|
36
|
+
const forwarded = this.launchArgs.getLaunchArgs();
|
|
37
|
+
if (forwarded === undefined) {
|
|
38
|
+
// Cold-start window: the shared backend already forwards its session preferences.
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
return cli_preferences_1.CliPreferenceEntry
|
|
42
|
+
.parseAll(launch_arguments_1.LaunchArguments.values(forwarded, 'session-preference'))
|
|
43
|
+
.map(entry => cli_preferences_1.CliPreferenceEntry.toArg('session-preference', entry));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.SessionPreferenceRemoteCliContribution = SessionPreferenceRemoteCliContribution;
|
|
47
|
+
tslib_1.__decorate([
|
|
48
|
+
(0, inversify_1.inject)(window_launch_args_1.WindowLaunchArgs),
|
|
49
|
+
tslib_1.__metadata("design:type", Object)
|
|
50
|
+
], SessionPreferenceRemoteCliContribution.prototype, "launchArgs", void 0);
|
|
51
|
+
exports.SessionPreferenceRemoteCliContribution = SessionPreferenceRemoteCliContribution = tslib_1.__decorate([
|
|
52
|
+
(0, inversify_1.injectable)()
|
|
53
|
+
], SessionPreferenceRemoteCliContribution);
|
|
54
|
+
//# sourceMappingURL=session-preference-remote-cli-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-preference-remote-cli-contribution.js","sourceRoot":"","sources":["../../src/browser/session-preference-remote-cli-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,4DAAkE;AAElE,8EAA0E;AAC1E,0FAAqF;AACrF,+DAA+D;AAE/D;;;;;;;;;GASG;AAEI,IAAM,sCAAsC,GAA5C,MAAM,sCAAsC;IAK/C,KAAK,CAAC,gBAAgB;QAClB,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;QAClD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC1B,kFAAkF;YAClF,OAAO,EAAE,CAAC;QACd,CAAC;QACD,OAAO,oCAAkB;aACpB,QAAQ,CAAC,kCAAe,CAAC,MAAM,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;aACjE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,oCAAkB,CAAC,KAAK,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7E,CAAC;CACJ,CAAA;AAfY,wFAAsC;AAG5B;IADlB,IAAA,kBAAM,EAAC,qCAAgB,CAAC;;0EACuB;iDAHvC,sCAAsC;IADlD,IAAA,sBAAU,GAAE;GACA,sCAAsC,CAelD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-preference-remote-cli-contribution.spec.d.ts","sourceRoot":"","sources":["../../src/browser/session-preference-remote-cli-contribution.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 EclipseSource GmbH and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const chai_1 = require("chai");
|
|
19
|
+
const launchArgs = (values) => ({ values, negated: [] });
|
|
20
|
+
const cli_preferences_1 = require("../common/cli-preferences");
|
|
21
|
+
const session_preference_remote_cli_contribution_1 = require("./session-preference-remote-cli-contribution");
|
|
22
|
+
class TestContribution extends session_preference_remote_cli_contribution_1.SessionPreferenceRemoteCliContribution {
|
|
23
|
+
set forwardedArgs(args) {
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
this.launchArgs = { getLaunchArgs: () => args };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
describe('SessionPreferenceRemoteCliContribution#getRemoteCliArgs', () => {
|
|
29
|
+
let contribution;
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
contribution = new TestContribution();
|
|
32
|
+
});
|
|
33
|
+
it('returns no args for a cold-start window (no forwarded options)', async () => {
|
|
34
|
+
contribution.forwardedArgs = undefined;
|
|
35
|
+
(0, chai_1.expect)(await contribution.getRemoteCliArgs()).to.deep.equal([]);
|
|
36
|
+
});
|
|
37
|
+
it('returns no args for a forwarded window without --session-preference', async () => {
|
|
38
|
+
contribution.forwardedArgs = launchArgs({ 'attach-container': ['B'] });
|
|
39
|
+
(0, chai_1.expect)(await contribution.getRemoteCliArgs()).to.deep.equal([]);
|
|
40
|
+
});
|
|
41
|
+
it('formats forwarded --session-preference values for the remote backend', async () => {
|
|
42
|
+
contribution.forwardedArgs = launchArgs({ 'attach-container': ['B'], 'session-preference': ['editor.fontSize=20'] });
|
|
43
|
+
const args = await contribution.getRemoteCliArgs();
|
|
44
|
+
(0, chai_1.expect)(args).to.have.lengthOf(1);
|
|
45
|
+
// The produced arg must parse back to the original entry on the remote.
|
|
46
|
+
const value = args[0].substring('--session-preference='.length);
|
|
47
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse(value)).to.deep.equal(['editor.fontSize', 20]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=session-preference-remote-cli-contribution.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-preference-remote-cli-contribution.spec.js","sourceRoot":"","sources":["../../src/browser/session-preference-remote-cli-contribution.spec.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,+BAA8B;AAG9B,MAAM,UAAU,GAAG,CAAC,MAAgC,EAAmB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;AACpG,+DAA+D;AAC/D,6GAAsG;AAEtG,MAAM,gBAAiB,SAAQ,mFAAsC;IACjE,IAAI,aAAa,CAAC,IAAiC;QAC/C,8DAA8D;QAC7D,IAAY,CAAC,UAAU,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IAC7D,CAAC;CACJ;AAED,QAAQ,CAAC,yDAAyD,EAAE,GAAG,EAAE;IAErE,IAAI,YAA8B,CAAC;IAEnC,UAAU,CAAC,GAAG,EAAE;QACZ,YAAY,GAAG,IAAI,gBAAgB,EAAE,CAAC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|
|
@@ -4,4 +4,32 @@ export interface CliPreferences {
|
|
|
4
4
|
getPreferences(): Promise<[string, unknown][]>;
|
|
5
5
|
getSessionPreferences(): Promise<[string, unknown][]>;
|
|
6
6
|
}
|
|
7
|
+
export declare namespace CliPreferenceEntry {
|
|
8
|
+
/**
|
|
9
|
+
* Sink for warnings about malformed entries. Callers running in an Inversify context should
|
|
10
|
+
* pass their named `ILogger`, since these helpers live in `common` and cannot inject one
|
|
11
|
+
* themselves. Defaults to `console.warn`.
|
|
12
|
+
*/
|
|
13
|
+
type WarningSink = (message: string) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Parses a single `KEY=JSONVALUE` preference assignment as accepted by `--set-preference`
|
|
16
|
+
* and `--session-preference`. The value may be `base64:`-prefixed (used when forwarding
|
|
17
|
+
* values that must survive shell/URL transport intact). Returns `undefined` (after logging a
|
|
18
|
+
* warning to {@link warn}) when the entry has no key or the value is not valid JSON.
|
|
19
|
+
*/
|
|
20
|
+
function parse(entry: string, warn?: WarningSink): [string, unknown] | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Formats a preference entry as a CLI argument of the form
|
|
23
|
+
* `--<optionName>=<key>=base64:<base64(JSON(value))>`, the inverse of {@link parse}.
|
|
24
|
+
*
|
|
25
|
+
* The value is base64-encoded so it survives shell/URL transport intact (e.g. when the
|
|
26
|
+
* argument is passed to a remote backend over an SSH command line).
|
|
27
|
+
*/
|
|
28
|
+
function toArg(optionName: string, [key, value]: [string, unknown]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Parses a list of `KEY=JSONVALUE` assignments, dropping any invalid entries and reporting
|
|
31
|
+
* them to {@link warn}.
|
|
32
|
+
*/
|
|
33
|
+
function parseAll(entries: readonly string[], warn?: WarningSink): [string, unknown][];
|
|
34
|
+
}
|
|
7
35
|
//# sourceMappingURL=cli-preferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-preferences.d.ts","sourceRoot":"","sources":["../../src/common/cli-pre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
|
|
|
15
15
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
16
|
// *****************************************************************************
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.CliPreferencesPath = exports.CliPreferences = void 0;
|
|
18
|
+
exports.CliPreferenceEntry = exports.CliPreferencesPath = exports.CliPreferences = void 0;
|
|
19
19
|
exports.CliPreferences = Symbol('CliPreferences');
|
|
20
20
|
exports.CliPreferencesPath = '/services/cli-preferences';
|
|
21
|
+
var CliPreferenceEntry;
|
|
22
|
+
(function (CliPreferenceEntry) {
|
|
23
|
+
const defaultWarn = message => console.warn(message);
|
|
24
|
+
/**
|
|
25
|
+
* Parses a single `KEY=JSONVALUE` preference assignment as accepted by `--set-preference`
|
|
26
|
+
* and `--session-preference`. The value may be `base64:`-prefixed (used when forwarding
|
|
27
|
+
* values that must survive shell/URL transport intact). Returns `undefined` (after logging a
|
|
28
|
+
* warning to {@link warn}) when the entry has no key or the value is not valid JSON.
|
|
29
|
+
*/
|
|
30
|
+
function parse(entry, warn = defaultWarn) {
|
|
31
|
+
const firstEqualIndex = entry.indexOf('=');
|
|
32
|
+
if (firstEqualIndex <= 0) {
|
|
33
|
+
warn(`Ignoring preference CLI argument "${entry}": expected KEY=JSONVALUE.`);
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
const rawValue = entry.substring(firstEqualIndex + 1);
|
|
37
|
+
try {
|
|
38
|
+
// Decoding happens inside the `try` so that a malformed `base64:` payload is reported
|
|
39
|
+
// like any other invalid value instead of throwing out of `parse`.
|
|
40
|
+
const value = rawValue.startsWith('base64:') ? decodeBase64(rawValue.substring('base64:'.length)) : rawValue;
|
|
41
|
+
return [entry.substring(0, firstEqualIndex), JSON.parse(value)];
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
45
|
+
warn(`Ignoring preference CLI argument "${entry}": value is not valid JSON (${reason}).`);
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
CliPreferenceEntry.parse = parse;
|
|
50
|
+
/**
|
|
51
|
+
* Formats a preference entry as a CLI argument of the form
|
|
52
|
+
* `--<optionName>=<key>=base64:<base64(JSON(value))>`, the inverse of {@link parse}.
|
|
53
|
+
*
|
|
54
|
+
* The value is base64-encoded so it survives shell/URL transport intact (e.g. when the
|
|
55
|
+
* argument is passed to a remote backend over an SSH command line).
|
|
56
|
+
*/
|
|
57
|
+
function toArg(optionName, [key, value]) {
|
|
58
|
+
return `--${optionName}=${key}=base64:${encodeBase64(JSON.stringify(value))}`;
|
|
59
|
+
}
|
|
60
|
+
CliPreferenceEntry.toArg = toArg;
|
|
61
|
+
/**
|
|
62
|
+
* Parses a list of `KEY=JSONVALUE` assignments, dropping any invalid entries and reporting
|
|
63
|
+
* them to {@link warn}.
|
|
64
|
+
*/
|
|
65
|
+
function parseAll(entries, warn = defaultWarn) {
|
|
66
|
+
const result = [];
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
const parsed = parse(entry, warn);
|
|
69
|
+
if (parsed) {
|
|
70
|
+
result.push(parsed);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
CliPreferenceEntry.parseAll = parseAll;
|
|
76
|
+
// `Buffer` is available on the backend and is polyfilled into the frontend bundle by the
|
|
77
|
+
// esbuild generator, so a single implementation covers both. It also handles UTF-8 directly,
|
|
78
|
+
// unlike `atob`/`btoa`, which only deal in binary strings.
|
|
79
|
+
function decodeBase64(value) {
|
|
80
|
+
return Buffer.from(value, 'base64').toString('utf-8');
|
|
81
|
+
}
|
|
82
|
+
function encodeBase64(value) {
|
|
83
|
+
return Buffer.from(value, 'utf-8').toString('base64');
|
|
84
|
+
}
|
|
85
|
+
})(CliPreferenceEntry || (exports.CliPreferenceEntry = CliPreferenceEntry = {}));
|
|
21
86
|
//# sourceMappingURL=cli-preferences.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-preferences.js","sourceRoot":"","sources":["../../src/common/cli-preferences.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEnE,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC1C,QAAA,kBAAkB,GAAG,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli-preferences.js","sourceRoot":"","sources":["../../src/common/cli-preferences.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEnE,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC1C,QAAA,kBAAkB,GAAG,2BAA2B,CAAC;AAO9D,IAAiB,kBAAkB,CAyElC;AAzED,WAAiB,kBAAkB;IAS/B,MAAM,WAAW,GAAgB,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAElE;;;;;OAKG;IACH,SAAgB,KAAK,CAAC,KAAa,EAAE,OAAoB,WAAW;QAChE,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,eAAe,IAAI,CAAC,EAAE,CAAC;YACvB,IAAI,CAAC,qCAAqC,KAAK,4BAA4B,CAAC,CAAC;YAC7E,OAAO,SAAS,CAAC;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MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IATe,2BAAQ,WASvB,CAAA;IAED,yFAAyF;IACzF,6FAA6F;IAC7F,2DAA2D;IAE3D,SAAS,YAAY,CAAC,KAAa;QAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,SAAS,YAAY,CAAC,KAAa;QAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;AACL,CAAC,EAzEgB,kBAAkB,kCAAlB,kBAAkB,QAyElC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-preferences.spec.d.ts","sourceRoot":"","sources":["../../src/common/cli-preferences.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 EclipseSource GmbH and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const chai_1 = require("chai");
|
|
19
|
+
const cli_preferences_1 = require("./cli-preferences");
|
|
20
|
+
describe('CliPreferenceEntry.parse', () => {
|
|
21
|
+
it('parses a KEY=JSONVALUE assignment', () => {
|
|
22
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse('editor.fontSize=14')).to.deep.equal(['editor.fontSize', 14]);
|
|
23
|
+
});
|
|
24
|
+
it('parses boolean and string JSON values', () => {
|
|
25
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse('foo.enabled=true')).to.deep.equal(['foo.enabled', true]);
|
|
26
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse('foo.label="hello"')).to.deep.equal(['foo.label', 'hello']);
|
|
27
|
+
});
|
|
28
|
+
it('keeps "=" characters that are part of the value', () => {
|
|
29
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse('foo.expr="a=b"')).to.deep.equal(['foo.expr', 'a=b']);
|
|
30
|
+
});
|
|
31
|
+
it('decodes a base64-encoded value', () => {
|
|
32
|
+
// base64 of the JSON value `42`
|
|
33
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse('foo.num=base64:NDI=')).to.deep.equal(['foo.num', 42]);
|
|
34
|
+
});
|
|
35
|
+
it('returns undefined when there is no key', () => {
|
|
36
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse('=1')).to.be.undefined;
|
|
37
|
+
});
|
|
38
|
+
it('returns undefined when there is no "="', () => {
|
|
39
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse('noequals')).to.be.undefined;
|
|
40
|
+
});
|
|
41
|
+
it('returns undefined for an invalid JSON value', () => {
|
|
42
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse('foo.bar=not json')).to.be.undefined;
|
|
43
|
+
});
|
|
44
|
+
describe('parseAll', () => {
|
|
45
|
+
it('parses and filters a list, dropping invalid entries', () => {
|
|
46
|
+
const result = cli_preferences_1.CliPreferenceEntry.parseAll(['a=1', 'bad', 'b="x"']);
|
|
47
|
+
(0, chai_1.expect)(result).to.deep.equal([['a', 1], ['b', 'x']]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe('toArg', () => {
|
|
51
|
+
it('formats an entry as a base64-encoded CLI argument', () => {
|
|
52
|
+
// base64 of the JSON value `42`
|
|
53
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.toArg('session-preference', ['foo.num', 42])).to.equal('--session-preference=foo.num=base64:NDI=');
|
|
54
|
+
});
|
|
55
|
+
it('round-trips a value with shell-special characters through toArg + parse', () => {
|
|
56
|
+
const entry = ['foo.expr', '$HOME && "quoted"'];
|
|
57
|
+
const arg = cli_preferences_1.CliPreferenceEntry.toArg('session-preference', entry);
|
|
58
|
+
// The value part of `--session-preference=<value>` must parse back to the original entry.
|
|
59
|
+
const value = arg.substring('--session-preference='.length);
|
|
60
|
+
(0, chai_1.expect)(cli_preferences_1.CliPreferenceEntry.parse(value)).to.deep.equal(entry);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=cli-preferences.spec.js.map
|