@dsmm/dsmm 0.1.1 → 0.1.4
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 +24 -13
- package/agent-presets/dsmm-builder/agent.cordis.yml +14 -12
- package/agent-presets/dsmm-builder/preset.yml +1 -1
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-clarifier/preset.yml +1 -1
- package/agent-presets/dsmm-code-search/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-code-search/preset.yml +1 -1
- package/agent-presets/dsmm-creative/agent.cordis.yml +3 -1
- package/agent-presets/dsmm-creative/preset.yml +1 -1
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-doc-search/preset.yml +1 -1
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-media-reader/preset.yml +1 -1
- package/agent-presets/dsmm-oracle/agent.cordis.yml +3 -1
- package/agent-presets/dsmm-oracle/preset.yml +1 -1
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +3 -1
- package/agent-presets/dsmm-oracle-2nd/preset.yml +1 -1
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +15 -13
- package/agent-presets/dsmm-orchestrator/preset.yml +2 -2
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-plan-critic/preset.yml +1 -1
- package/agent-presets/dsmm-planner/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-planner/preset.yml +1 -1
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-reviewer/preset.yml +1 -1
- package/docs/agent-presets.md +15 -5
- package/docs/compatibility.md +64 -11
- package/docs/model-routing.md +10 -6
- package/docs/profiles.md +83 -0
- package/docs/releasing.md +58 -19
- package/docs/settings-status.md +13 -5
- package/lib/client/ProfilesSection.d.ts +11 -0
- package/lib/client/ProfilesSection.js +62 -0
- package/lib/client/controller.d.ts +77 -0
- package/lib/client/controller.js +198 -0
- package/lib/client/index.d.ts +11 -0
- package/lib/client/index.js +34 -0
- package/lib/client/locales.d.ts +56 -0
- package/lib/client/locales.js +48 -0
- package/lib/client/styles.d.ts +3 -0
- package/lib/client/styles.js +25 -0
- package/lib/client.js +1930 -0
- package/lib/commands.d.ts +3 -3
- package/lib/commands.js +4 -4
- package/lib/dsh-types.d.ts +4 -0
- package/lib/guards.d.ts +2 -2
- package/lib/guards.js +3 -2
- package/lib/index.d.ts +12 -4
- package/lib/index.js +72 -20
- package/lib/mode.d.ts +2 -2
- package/lib/mode.js +1 -1
- package/lib/model-routing.d.ts +2 -2
- package/lib/model-routing.js +17 -2
- package/lib/preset-registry.js +5 -3
- package/lib/profile-remote.d.ts +31 -0
- package/lib/profile-remote.js +106 -0
- package/lib/profile-rpc.d.ts +27 -0
- package/lib/profile-rpc.js +90 -0
- package/lib/profile-runtime.d.ts +44 -0
- package/lib/profile-runtime.js +159 -0
- package/lib/profile-store.d.ts +42 -0
- package/lib/profile-store.js +478 -0
- package/lib/profile-types.d.ts +40 -0
- package/lib/profile-types.js +2 -0
- package/lib/profiles.d.ts +26 -0
- package/lib/profiles.js +237 -0
- package/lib/prompts.d.ts +2 -2
- package/lib/prompts.js +4 -4
- package/lib/role-providers.d.ts +2 -2
- package/lib/role-providers.js +39 -6
- package/lib/role-routing.d.ts +2 -2
- package/lib/role-routing.js +4 -1
- package/lib/role-subagents.d.ts +2 -2
- package/lib/role-subagents.js +6 -4
- package/lib/roles.d.ts +4 -0
- package/lib/roles.js +43 -27
- package/lib/runtime-recovery.d.ts +2 -2
- package/lib/runtime-recovery.js +3 -3
- package/lib/session-metadata.d.ts +13 -0
- package/lib/session-metadata.js +34 -0
- package/lib/session-persistence.d.ts +35 -0
- package/lib/session-persistence.js +304 -0
- package/lib/settings.d.ts +8 -1
- package/lib/settings.js +4 -0
- package/lib/state.d.ts +1 -0
- package/lib/state.js +4 -0
- package/lib/status.js +6 -5
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +62 -15
- package/patches/agent-presets-root.example.cordis.patch.yml +6 -10
- package/prompts/deepseek-v4-pro.md +1 -1
- package/prompts/deepwork.md +3 -3
- package/scripts/repair-session-log.mjs +476 -0
- package/scripts/session-repair-native-verifier.mjs +367 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,1930 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "@dsmm/dsmm", factory: (require) => { const module = { exports: {} }; const exports = module.exports;
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/client/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
NEW_PROFILE_CONTENT: () => NEW_PROFILE_CONTENT,
|
|
25
|
+
NS: () => NS,
|
|
26
|
+
ProfilesController: () => ProfilesController,
|
|
27
|
+
ProfilesSection: () => ProfilesSection,
|
|
28
|
+
TYPERT_REMOTE: () => TYPERT_REMOTE,
|
|
29
|
+
apply: () => apply,
|
|
30
|
+
en: () => en,
|
|
31
|
+
inject: () => inject,
|
|
32
|
+
zh: () => zh
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(index_exports);
|
|
35
|
+
|
|
36
|
+
// src/profile-remote.ts
|
|
37
|
+
var errorCodes = /* @__PURE__ */ new Set(["validation", "conflict", "not-found", "lock-timeout", "unsafe-path", "io", "activation", "corrupt-selection", "limit"]);
|
|
38
|
+
var idPattern = /^[a-z0-9][a-z0-9_-]{0,63}$/u;
|
|
39
|
+
var revisionPattern = /^[a-f0-9]{64}$/u;
|
|
40
|
+
function isProfileId(value) {
|
|
41
|
+
return typeof value === "string" && idPattern.test(value) && !/^(?:con|prn|aux|nul|com[0-9]|lpt[0-9])$/iu.test(value);
|
|
42
|
+
}
|
|
43
|
+
function fail(field) {
|
|
44
|
+
throw new TypeError(`Invalid Deepwork profile wire field: ${field}`);
|
|
45
|
+
}
|
|
46
|
+
function text(value, field, maximum = 1024) {
|
|
47
|
+
if (typeof value !== "string" || value.length > maximum) fail(field);
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
function id(value) {
|
|
51
|
+
const result = text(value, "id", 64);
|
|
52
|
+
if (!isProfileId(result)) fail("id");
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
function revision(value) {
|
|
56
|
+
const result = text(value, "revision", 64);
|
|
57
|
+
if (!revisionPattern.test(result)) fail("revision");
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
function selectionRevision(value) {
|
|
61
|
+
return value === "absent" ? value : revision(value);
|
|
62
|
+
}
|
|
63
|
+
function object(value, required, optional2 = []) {
|
|
64
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) fail("object");
|
|
65
|
+
const result = value;
|
|
66
|
+
if (Object.keys(result).some((key) => !required.includes(key) && !optional2.includes(key)) || required.some((key) => !Object.hasOwn(result, key))) fail("object keys");
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
function optional(value, key, parse2) {
|
|
70
|
+
return Object.hasOwn(value, key) ? { [key]: parse2(value[key]) } : {};
|
|
71
|
+
}
|
|
72
|
+
function errorInfo(value) {
|
|
73
|
+
const item = object(value, ["code", "message"], ["field"]);
|
|
74
|
+
const code = text(item.code, "code");
|
|
75
|
+
if (!errorCodes.has(code)) fail("code");
|
|
76
|
+
return { code, message: text(item.message, "message", 4096), ...optional(item, "field", (input) => text(input, "field", 256)) };
|
|
77
|
+
}
|
|
78
|
+
function readResult(value) {
|
|
79
|
+
const item = object(value, ["id", "revision", "content"], ["label"]);
|
|
80
|
+
return { id: id(item.id), revision: revision(item.revision), content: content(item.content), ...optional(item, "label", (input) => text(input, "label", 120)) };
|
|
81
|
+
}
|
|
82
|
+
function content(value) {
|
|
83
|
+
const result = text(value, "content", 128 * 1024);
|
|
84
|
+
if (new TextEncoder().encode(result).byteLength > 128 * 1024) fail("content");
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
function snapshot(value) {
|
|
88
|
+
const item = object(value, ["profiles", "selectedId", "appliedRevision", "selectionRevision"], ["selectionError"]);
|
|
89
|
+
if (!Array.isArray(item.profiles) || item.profiles.length > 128) fail("profiles");
|
|
90
|
+
return {
|
|
91
|
+
profiles: item.profiles.map((input) => {
|
|
92
|
+
const row = object(input, ["id", "revision"], ["label", "error"]);
|
|
93
|
+
return { id: text(row.id, "id", 64), revision: row.revision === null ? null : revision(row.revision), ...optional(row, "label", (input2) => text(input2, "label", 120)), ...optional(row, "error", errorInfo) };
|
|
94
|
+
}),
|
|
95
|
+
selectedId: item.selectedId === null ? null : id(item.selectedId),
|
|
96
|
+
appliedRevision: item.appliedRevision === null ? null : revision(item.appliedRevision),
|
|
97
|
+
selectionRevision: item.selectionRevision === "unavailable" && Object.hasOwn(item, "selectionError") ? "unavailable" : selectionRevision(item.selectionRevision),
|
|
98
|
+
...optional(item, "selectionError", errorInfo)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function saveRequest(value) {
|
|
102
|
+
const item = object(value, ["id", "content", "expectedRevision"]);
|
|
103
|
+
return { id: id(item.id), content: content(item.content), expectedRevision: item.expectedRevision === null ? null : revision(item.expectedRevision) };
|
|
104
|
+
}
|
|
105
|
+
function selectRequest(value) {
|
|
106
|
+
const item = object(value, ["id", "expectedSelectionRevision"], ["expectedRevision"]);
|
|
107
|
+
const result = { id: item.id === null ? null : id(item.id), expectedSelectionRevision: selectionRevision(item.expectedSelectionRevision), ...optional(item, "expectedRevision", revision) };
|
|
108
|
+
if (result.id !== null && result.expectedRevision === void 0) fail("expectedRevision");
|
|
109
|
+
if (result.id === null && result.expectedRevision !== void 0) fail("expectedRevision");
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
function codec(symbol, parse2) {
|
|
113
|
+
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: parse2 }) };
|
|
114
|
+
}
|
|
115
|
+
function descriptor(method, result, parameter) {
|
|
116
|
+
return { id: `@dsmm/dsmm#dsmmProfiles/${method}`, service: "dsmmProfiles", namespace: "dsmmProfiles", method, invocation: { kind: "direct" }, parameters: parameter === void 0 ? [] : [{ name: parameter.name, wire: parameter.name, source: "json", codec: parameter.codec }], result };
|
|
117
|
+
}
|
|
118
|
+
var TYPERT_REMOTE = {
|
|
119
|
+
package: "@dsmm/dsmm",
|
|
120
|
+
descriptors: [
|
|
121
|
+
descriptor("describe", codec("ProfileSnapshot", snapshot)),
|
|
122
|
+
descriptor("read", codec("ProfileReadResult", readResult), { name: "id", codec: codec("ProfileId", id) }),
|
|
123
|
+
descriptor("save", codec("ProfileReadResult", readResult), { name: "request", codec: codec("ProfileSaveRequest", saveRequest) }),
|
|
124
|
+
descriptor("select", codec("ProfileSnapshot", snapshot), { name: "request", codec: codec("ProfileSelectRequest", selectRequest) })
|
|
125
|
+
]
|
|
126
|
+
};
|
|
127
|
+
var TYPERT_HOST = {
|
|
128
|
+
package: "@dsmm/dsmm",
|
|
129
|
+
face: "host",
|
|
130
|
+
schemas: [],
|
|
131
|
+
model: { services: [], events: [], objects: [] },
|
|
132
|
+
invocations: TYPERT_REMOTE.descriptors
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// ../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
136
|
+
function createScanner(text2, ignoreTrivia = false) {
|
|
137
|
+
const len = text2.length;
|
|
138
|
+
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
|
|
139
|
+
function scanHexDigits(count, exact) {
|
|
140
|
+
let digits = 0;
|
|
141
|
+
let value2 = 0;
|
|
142
|
+
while (digits < count || !exact) {
|
|
143
|
+
let ch = text2.charCodeAt(pos);
|
|
144
|
+
if (ch >= 48 && ch <= 57) {
|
|
145
|
+
value2 = value2 * 16 + ch - 48;
|
|
146
|
+
} else if (ch >= 65 && ch <= 70) {
|
|
147
|
+
value2 = value2 * 16 + ch - 65 + 10;
|
|
148
|
+
} else if (ch >= 97 && ch <= 102) {
|
|
149
|
+
value2 = value2 * 16 + ch - 97 + 10;
|
|
150
|
+
} else {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
pos++;
|
|
154
|
+
digits++;
|
|
155
|
+
}
|
|
156
|
+
if (digits < count) {
|
|
157
|
+
value2 = -1;
|
|
158
|
+
}
|
|
159
|
+
return value2;
|
|
160
|
+
}
|
|
161
|
+
function setPosition(newPosition) {
|
|
162
|
+
pos = newPosition;
|
|
163
|
+
value = "";
|
|
164
|
+
tokenOffset = 0;
|
|
165
|
+
token = 16;
|
|
166
|
+
scanError = 0;
|
|
167
|
+
}
|
|
168
|
+
function scanNumber() {
|
|
169
|
+
let start = pos;
|
|
170
|
+
if (text2.charCodeAt(pos) === 48) {
|
|
171
|
+
pos++;
|
|
172
|
+
} else {
|
|
173
|
+
pos++;
|
|
174
|
+
while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
|
|
175
|
+
pos++;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (pos < text2.length && text2.charCodeAt(pos) === 46) {
|
|
179
|
+
pos++;
|
|
180
|
+
if (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
|
|
181
|
+
pos++;
|
|
182
|
+
while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
|
|
183
|
+
pos++;
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
scanError = 3;
|
|
187
|
+
return text2.substring(start, pos);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
let end = pos;
|
|
191
|
+
if (pos < text2.length && (text2.charCodeAt(pos) === 69 || text2.charCodeAt(pos) === 101)) {
|
|
192
|
+
pos++;
|
|
193
|
+
if (pos < text2.length && text2.charCodeAt(pos) === 43 || text2.charCodeAt(pos) === 45) {
|
|
194
|
+
pos++;
|
|
195
|
+
}
|
|
196
|
+
if (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
|
|
197
|
+
pos++;
|
|
198
|
+
while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
|
|
199
|
+
pos++;
|
|
200
|
+
}
|
|
201
|
+
end = pos;
|
|
202
|
+
} else {
|
|
203
|
+
scanError = 3;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return text2.substring(start, end);
|
|
207
|
+
}
|
|
208
|
+
function scanString() {
|
|
209
|
+
let result = "", start = pos;
|
|
210
|
+
while (true) {
|
|
211
|
+
if (pos >= len) {
|
|
212
|
+
result += text2.substring(start, pos);
|
|
213
|
+
scanError = 2;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
const ch = text2.charCodeAt(pos);
|
|
217
|
+
if (ch === 34) {
|
|
218
|
+
result += text2.substring(start, pos);
|
|
219
|
+
pos++;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
if (ch === 92) {
|
|
223
|
+
result += text2.substring(start, pos);
|
|
224
|
+
pos++;
|
|
225
|
+
if (pos >= len) {
|
|
226
|
+
scanError = 2;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
const ch2 = text2.charCodeAt(pos++);
|
|
230
|
+
switch (ch2) {
|
|
231
|
+
case 34:
|
|
232
|
+
result += '"';
|
|
233
|
+
break;
|
|
234
|
+
case 92:
|
|
235
|
+
result += "\\";
|
|
236
|
+
break;
|
|
237
|
+
case 47:
|
|
238
|
+
result += "/";
|
|
239
|
+
break;
|
|
240
|
+
case 98:
|
|
241
|
+
result += "\b";
|
|
242
|
+
break;
|
|
243
|
+
case 102:
|
|
244
|
+
result += "\f";
|
|
245
|
+
break;
|
|
246
|
+
case 110:
|
|
247
|
+
result += "\n";
|
|
248
|
+
break;
|
|
249
|
+
case 114:
|
|
250
|
+
result += "\r";
|
|
251
|
+
break;
|
|
252
|
+
case 116:
|
|
253
|
+
result += " ";
|
|
254
|
+
break;
|
|
255
|
+
case 117:
|
|
256
|
+
const ch3 = scanHexDigits(4, true);
|
|
257
|
+
if (ch3 >= 0) {
|
|
258
|
+
result += String.fromCharCode(ch3);
|
|
259
|
+
} else {
|
|
260
|
+
scanError = 4;
|
|
261
|
+
}
|
|
262
|
+
break;
|
|
263
|
+
default:
|
|
264
|
+
scanError = 5;
|
|
265
|
+
}
|
|
266
|
+
start = pos;
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (ch >= 0 && ch <= 31) {
|
|
270
|
+
if (isLineBreak(ch)) {
|
|
271
|
+
result += text2.substring(start, pos);
|
|
272
|
+
scanError = 2;
|
|
273
|
+
break;
|
|
274
|
+
} else {
|
|
275
|
+
scanError = 6;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
pos++;
|
|
279
|
+
}
|
|
280
|
+
return result;
|
|
281
|
+
}
|
|
282
|
+
function scanNext() {
|
|
283
|
+
value = "";
|
|
284
|
+
scanError = 0;
|
|
285
|
+
tokenOffset = pos;
|
|
286
|
+
lineStartOffset = lineNumber;
|
|
287
|
+
prevTokenLineStartOffset = tokenLineStartOffset;
|
|
288
|
+
if (pos >= len) {
|
|
289
|
+
tokenOffset = len;
|
|
290
|
+
return token = 17;
|
|
291
|
+
}
|
|
292
|
+
let code = text2.charCodeAt(pos);
|
|
293
|
+
if (isWhiteSpace(code)) {
|
|
294
|
+
do {
|
|
295
|
+
pos++;
|
|
296
|
+
value += String.fromCharCode(code);
|
|
297
|
+
code = text2.charCodeAt(pos);
|
|
298
|
+
} while (isWhiteSpace(code));
|
|
299
|
+
return token = 15;
|
|
300
|
+
}
|
|
301
|
+
if (isLineBreak(code)) {
|
|
302
|
+
pos++;
|
|
303
|
+
value += String.fromCharCode(code);
|
|
304
|
+
if (code === 13 && text2.charCodeAt(pos) === 10) {
|
|
305
|
+
pos++;
|
|
306
|
+
value += "\n";
|
|
307
|
+
}
|
|
308
|
+
lineNumber++;
|
|
309
|
+
tokenLineStartOffset = pos;
|
|
310
|
+
return token = 14;
|
|
311
|
+
}
|
|
312
|
+
switch (code) {
|
|
313
|
+
// tokens: []{}:,
|
|
314
|
+
case 123:
|
|
315
|
+
pos++;
|
|
316
|
+
return token = 1;
|
|
317
|
+
case 125:
|
|
318
|
+
pos++;
|
|
319
|
+
return token = 2;
|
|
320
|
+
case 91:
|
|
321
|
+
pos++;
|
|
322
|
+
return token = 3;
|
|
323
|
+
case 93:
|
|
324
|
+
pos++;
|
|
325
|
+
return token = 4;
|
|
326
|
+
case 58:
|
|
327
|
+
pos++;
|
|
328
|
+
return token = 6;
|
|
329
|
+
case 44:
|
|
330
|
+
pos++;
|
|
331
|
+
return token = 5;
|
|
332
|
+
// strings
|
|
333
|
+
case 34:
|
|
334
|
+
pos++;
|
|
335
|
+
value = scanString();
|
|
336
|
+
return token = 10;
|
|
337
|
+
// comments
|
|
338
|
+
case 47:
|
|
339
|
+
const start = pos - 1;
|
|
340
|
+
if (text2.charCodeAt(pos + 1) === 47) {
|
|
341
|
+
pos += 2;
|
|
342
|
+
while (pos < len) {
|
|
343
|
+
if (isLineBreak(text2.charCodeAt(pos))) {
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
pos++;
|
|
347
|
+
}
|
|
348
|
+
value = text2.substring(start, pos);
|
|
349
|
+
return token = 12;
|
|
350
|
+
}
|
|
351
|
+
if (text2.charCodeAt(pos + 1) === 42) {
|
|
352
|
+
pos += 2;
|
|
353
|
+
const safeLength = len - 1;
|
|
354
|
+
let commentClosed = false;
|
|
355
|
+
while (pos < safeLength) {
|
|
356
|
+
const ch = text2.charCodeAt(pos);
|
|
357
|
+
if (ch === 42 && text2.charCodeAt(pos + 1) === 47) {
|
|
358
|
+
pos += 2;
|
|
359
|
+
commentClosed = true;
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
pos++;
|
|
363
|
+
if (isLineBreak(ch)) {
|
|
364
|
+
if (ch === 13 && text2.charCodeAt(pos) === 10) {
|
|
365
|
+
pos++;
|
|
366
|
+
}
|
|
367
|
+
lineNumber++;
|
|
368
|
+
tokenLineStartOffset = pos;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (!commentClosed) {
|
|
372
|
+
pos++;
|
|
373
|
+
scanError = 1;
|
|
374
|
+
}
|
|
375
|
+
value = text2.substring(start, pos);
|
|
376
|
+
return token = 13;
|
|
377
|
+
}
|
|
378
|
+
value += String.fromCharCode(code);
|
|
379
|
+
pos++;
|
|
380
|
+
return token = 16;
|
|
381
|
+
// numbers
|
|
382
|
+
case 45:
|
|
383
|
+
value += String.fromCharCode(code);
|
|
384
|
+
pos++;
|
|
385
|
+
if (pos === len || !isDigit(text2.charCodeAt(pos))) {
|
|
386
|
+
return token = 16;
|
|
387
|
+
}
|
|
388
|
+
// found a minus, followed by a number so
|
|
389
|
+
// we fall through to proceed with scanning
|
|
390
|
+
// numbers
|
|
391
|
+
case 48:
|
|
392
|
+
case 49:
|
|
393
|
+
case 50:
|
|
394
|
+
case 51:
|
|
395
|
+
case 52:
|
|
396
|
+
case 53:
|
|
397
|
+
case 54:
|
|
398
|
+
case 55:
|
|
399
|
+
case 56:
|
|
400
|
+
case 57:
|
|
401
|
+
value += scanNumber();
|
|
402
|
+
return token = 11;
|
|
403
|
+
// literals and unknown symbols
|
|
404
|
+
default:
|
|
405
|
+
while (pos < len && isUnknownContentCharacter(code)) {
|
|
406
|
+
pos++;
|
|
407
|
+
code = text2.charCodeAt(pos);
|
|
408
|
+
}
|
|
409
|
+
if (tokenOffset !== pos) {
|
|
410
|
+
value = text2.substring(tokenOffset, pos);
|
|
411
|
+
switch (value) {
|
|
412
|
+
case "true":
|
|
413
|
+
return token = 8;
|
|
414
|
+
case "false":
|
|
415
|
+
return token = 9;
|
|
416
|
+
case "null":
|
|
417
|
+
return token = 7;
|
|
418
|
+
}
|
|
419
|
+
return token = 16;
|
|
420
|
+
}
|
|
421
|
+
value += String.fromCharCode(code);
|
|
422
|
+
pos++;
|
|
423
|
+
return token = 16;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function isUnknownContentCharacter(code) {
|
|
427
|
+
if (isWhiteSpace(code) || isLineBreak(code)) {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
switch (code) {
|
|
431
|
+
case 125:
|
|
432
|
+
case 93:
|
|
433
|
+
case 123:
|
|
434
|
+
case 91:
|
|
435
|
+
case 34:
|
|
436
|
+
case 58:
|
|
437
|
+
case 44:
|
|
438
|
+
case 47:
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
function scanNextNonTrivia() {
|
|
444
|
+
let result;
|
|
445
|
+
do {
|
|
446
|
+
result = scanNext();
|
|
447
|
+
} while (result >= 12 && result <= 15);
|
|
448
|
+
return result;
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
setPosition,
|
|
452
|
+
getPosition: () => pos,
|
|
453
|
+
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
|
|
454
|
+
getToken: () => token,
|
|
455
|
+
getTokenValue: () => value,
|
|
456
|
+
getTokenOffset: () => tokenOffset,
|
|
457
|
+
getTokenLength: () => pos - tokenOffset,
|
|
458
|
+
getTokenStartLine: () => lineStartOffset,
|
|
459
|
+
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
|
|
460
|
+
getTokenError: () => scanError
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function isWhiteSpace(ch) {
|
|
464
|
+
return ch === 32 || ch === 9;
|
|
465
|
+
}
|
|
466
|
+
function isLineBreak(ch) {
|
|
467
|
+
return ch === 10 || ch === 13;
|
|
468
|
+
}
|
|
469
|
+
function isDigit(ch) {
|
|
470
|
+
return ch >= 48 && ch <= 57;
|
|
471
|
+
}
|
|
472
|
+
var CharacterCodes;
|
|
473
|
+
(function(CharacterCodes2) {
|
|
474
|
+
CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
|
|
475
|
+
CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
|
|
476
|
+
CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
|
|
477
|
+
CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
|
|
478
|
+
CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
|
|
479
|
+
CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
|
|
480
|
+
CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
|
|
481
|
+
CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
|
|
482
|
+
CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
|
|
483
|
+
CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
|
|
484
|
+
CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
|
|
485
|
+
CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
|
|
486
|
+
CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
|
|
487
|
+
CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
|
|
488
|
+
CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
|
|
489
|
+
CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
|
|
490
|
+
CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
|
|
491
|
+
CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
|
|
492
|
+
CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
|
|
493
|
+
CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
|
|
494
|
+
CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
|
|
495
|
+
CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
|
|
496
|
+
CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
|
|
497
|
+
CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
|
|
498
|
+
CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
|
|
499
|
+
CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
|
|
500
|
+
CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
|
|
501
|
+
CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
|
|
502
|
+
CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
|
|
503
|
+
CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
|
|
504
|
+
CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
|
|
505
|
+
CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
|
|
506
|
+
CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
|
|
507
|
+
CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
|
|
508
|
+
CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
|
|
509
|
+
CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
|
|
510
|
+
CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
|
|
511
|
+
CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
|
|
512
|
+
CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
|
|
513
|
+
CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
|
|
514
|
+
CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
|
|
515
|
+
CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
|
|
516
|
+
CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
|
|
517
|
+
CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
|
|
518
|
+
CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
|
|
519
|
+
CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
|
|
520
|
+
CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
|
|
521
|
+
CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
|
|
522
|
+
CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
|
|
523
|
+
CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
|
|
524
|
+
CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
|
|
525
|
+
CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
|
|
526
|
+
CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
|
|
527
|
+
CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
|
|
528
|
+
CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
|
|
529
|
+
CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
|
|
530
|
+
CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
|
|
531
|
+
CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
|
|
532
|
+
CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
|
|
533
|
+
CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
|
|
534
|
+
CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
|
|
535
|
+
CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
|
|
536
|
+
CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
|
|
537
|
+
CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
|
|
538
|
+
CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
|
|
539
|
+
CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
|
|
540
|
+
CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
|
|
541
|
+
CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
|
|
542
|
+
CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
|
|
543
|
+
CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
|
|
544
|
+
CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
|
|
545
|
+
CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
|
|
546
|
+
CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
|
|
547
|
+
CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
|
|
548
|
+
CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
|
|
549
|
+
CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
|
|
550
|
+
CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
|
|
551
|
+
CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
|
|
552
|
+
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
|
|
553
|
+
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
|
|
554
|
+
})(CharacterCodes || (CharacterCodes = {}));
|
|
555
|
+
|
|
556
|
+
// ../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
|
|
557
|
+
var cachedSpaces = new Array(20).fill(0).map((_, index) => {
|
|
558
|
+
return " ".repeat(index);
|
|
559
|
+
});
|
|
560
|
+
var maxCachedValues = 200;
|
|
561
|
+
var cachedBreakLinesWithSpaces = {
|
|
562
|
+
" ": {
|
|
563
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
564
|
+
return "\n" + " ".repeat(index);
|
|
565
|
+
}),
|
|
566
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
567
|
+
return "\r" + " ".repeat(index);
|
|
568
|
+
}),
|
|
569
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
570
|
+
return "\r\n" + " ".repeat(index);
|
|
571
|
+
})
|
|
572
|
+
},
|
|
573
|
+
" ": {
|
|
574
|
+
"\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
575
|
+
return "\n" + " ".repeat(index);
|
|
576
|
+
}),
|
|
577
|
+
"\r": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
578
|
+
return "\r" + " ".repeat(index);
|
|
579
|
+
}),
|
|
580
|
+
"\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
|
|
581
|
+
return "\r\n" + " ".repeat(index);
|
|
582
|
+
})
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
var supportedEols = ["\n", "\r", "\r\n"];
|
|
586
|
+
|
|
587
|
+
// ../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/format.js
|
|
588
|
+
function format(documentText, range, options) {
|
|
589
|
+
let initialIndentLevel;
|
|
590
|
+
let formatText;
|
|
591
|
+
let formatTextStart;
|
|
592
|
+
let rangeStart;
|
|
593
|
+
let rangeEnd;
|
|
594
|
+
if (range) {
|
|
595
|
+
rangeStart = range.offset;
|
|
596
|
+
rangeEnd = rangeStart + range.length;
|
|
597
|
+
formatTextStart = rangeStart;
|
|
598
|
+
while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
|
|
599
|
+
formatTextStart--;
|
|
600
|
+
}
|
|
601
|
+
let endOffset = rangeEnd;
|
|
602
|
+
while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
|
|
603
|
+
endOffset++;
|
|
604
|
+
}
|
|
605
|
+
formatText = documentText.substring(formatTextStart, endOffset);
|
|
606
|
+
initialIndentLevel = computeIndentLevel(formatText, options);
|
|
607
|
+
} else {
|
|
608
|
+
formatText = documentText;
|
|
609
|
+
initialIndentLevel = 0;
|
|
610
|
+
formatTextStart = 0;
|
|
611
|
+
rangeStart = 0;
|
|
612
|
+
rangeEnd = documentText.length;
|
|
613
|
+
}
|
|
614
|
+
const eol = getEOL(options, documentText);
|
|
615
|
+
const eolFastPathSupported = supportedEols.includes(eol);
|
|
616
|
+
let numberLineBreaks = 0;
|
|
617
|
+
let indentLevel = 0;
|
|
618
|
+
let indentValue;
|
|
619
|
+
if (options.insertSpaces) {
|
|
620
|
+
indentValue = cachedSpaces[options.tabSize || 4] ?? repeat(cachedSpaces[1], options.tabSize || 4);
|
|
621
|
+
} else {
|
|
622
|
+
indentValue = " ";
|
|
623
|
+
}
|
|
624
|
+
const indentType = indentValue === " " ? " " : " ";
|
|
625
|
+
let scanner = createScanner(formatText, false);
|
|
626
|
+
let hasError = false;
|
|
627
|
+
function newLinesAndIndent() {
|
|
628
|
+
if (numberLineBreaks > 1) {
|
|
629
|
+
return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
630
|
+
}
|
|
631
|
+
const amountOfSpaces = indentValue.length * (initialIndentLevel + indentLevel);
|
|
632
|
+
if (!eolFastPathSupported || amountOfSpaces > cachedBreakLinesWithSpaces[indentType][eol].length) {
|
|
633
|
+
return eol + repeat(indentValue, initialIndentLevel + indentLevel);
|
|
634
|
+
}
|
|
635
|
+
if (amountOfSpaces <= 0) {
|
|
636
|
+
return eol;
|
|
637
|
+
}
|
|
638
|
+
return cachedBreakLinesWithSpaces[indentType][eol][amountOfSpaces];
|
|
639
|
+
}
|
|
640
|
+
function scanNext() {
|
|
641
|
+
let token = scanner.scan();
|
|
642
|
+
numberLineBreaks = 0;
|
|
643
|
+
while (token === 15 || token === 14) {
|
|
644
|
+
if (token === 14 && options.keepLines) {
|
|
645
|
+
numberLineBreaks += 1;
|
|
646
|
+
} else if (token === 14) {
|
|
647
|
+
numberLineBreaks = 1;
|
|
648
|
+
}
|
|
649
|
+
token = scanner.scan();
|
|
650
|
+
}
|
|
651
|
+
hasError = token === 16 || scanner.getTokenError() !== 0;
|
|
652
|
+
return token;
|
|
653
|
+
}
|
|
654
|
+
const editOperations = [];
|
|
655
|
+
function addEdit(text2, startOffset, endOffset) {
|
|
656
|
+
if (!hasError && (!range || startOffset < rangeEnd && endOffset > rangeStart) && documentText.substring(startOffset, endOffset) !== text2) {
|
|
657
|
+
editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text2 });
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
let firstToken = scanNext();
|
|
661
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
662
|
+
addEdit(repeat(eol, numberLineBreaks), 0, 0);
|
|
663
|
+
}
|
|
664
|
+
if (firstToken !== 17) {
|
|
665
|
+
let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
666
|
+
let initialIndent = indentValue.length * initialIndentLevel < 20 && options.insertSpaces ? cachedSpaces[indentValue.length * initialIndentLevel] : repeat(indentValue, initialIndentLevel);
|
|
667
|
+
addEdit(initialIndent, formatTextStart, firstTokenStart);
|
|
668
|
+
}
|
|
669
|
+
while (firstToken !== 17) {
|
|
670
|
+
let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
671
|
+
let secondToken = scanNext();
|
|
672
|
+
let replaceContent = "";
|
|
673
|
+
let needsLineBreak = false;
|
|
674
|
+
while (numberLineBreaks === 0 && (secondToken === 12 || secondToken === 13)) {
|
|
675
|
+
let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
676
|
+
addEdit(cachedSpaces[1], firstTokenEnd, commentTokenStart);
|
|
677
|
+
firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
|
|
678
|
+
needsLineBreak = secondToken === 12;
|
|
679
|
+
replaceContent = needsLineBreak ? newLinesAndIndent() : "";
|
|
680
|
+
secondToken = scanNext();
|
|
681
|
+
}
|
|
682
|
+
if (secondToken === 2) {
|
|
683
|
+
if (firstToken !== 1) {
|
|
684
|
+
indentLevel--;
|
|
685
|
+
}
|
|
686
|
+
;
|
|
687
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1) {
|
|
688
|
+
replaceContent = newLinesAndIndent();
|
|
689
|
+
} else if (options.keepLines) {
|
|
690
|
+
replaceContent = cachedSpaces[1];
|
|
691
|
+
}
|
|
692
|
+
} else if (secondToken === 4) {
|
|
693
|
+
if (firstToken !== 3) {
|
|
694
|
+
indentLevel--;
|
|
695
|
+
}
|
|
696
|
+
;
|
|
697
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3) {
|
|
698
|
+
replaceContent = newLinesAndIndent();
|
|
699
|
+
} else if (options.keepLines) {
|
|
700
|
+
replaceContent = cachedSpaces[1];
|
|
701
|
+
}
|
|
702
|
+
} else {
|
|
703
|
+
switch (firstToken) {
|
|
704
|
+
case 3:
|
|
705
|
+
case 1:
|
|
706
|
+
indentLevel++;
|
|
707
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
|
708
|
+
replaceContent = newLinesAndIndent();
|
|
709
|
+
} else {
|
|
710
|
+
replaceContent = cachedSpaces[1];
|
|
711
|
+
}
|
|
712
|
+
break;
|
|
713
|
+
case 5:
|
|
714
|
+
if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
|
|
715
|
+
replaceContent = newLinesAndIndent();
|
|
716
|
+
} else {
|
|
717
|
+
replaceContent = cachedSpaces[1];
|
|
718
|
+
}
|
|
719
|
+
break;
|
|
720
|
+
case 12:
|
|
721
|
+
replaceContent = newLinesAndIndent();
|
|
722
|
+
break;
|
|
723
|
+
case 13:
|
|
724
|
+
if (numberLineBreaks > 0) {
|
|
725
|
+
replaceContent = newLinesAndIndent();
|
|
726
|
+
} else if (!needsLineBreak) {
|
|
727
|
+
replaceContent = cachedSpaces[1];
|
|
728
|
+
}
|
|
729
|
+
break;
|
|
730
|
+
case 6:
|
|
731
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
732
|
+
replaceContent = newLinesAndIndent();
|
|
733
|
+
} else if (!needsLineBreak) {
|
|
734
|
+
replaceContent = cachedSpaces[1];
|
|
735
|
+
}
|
|
736
|
+
break;
|
|
737
|
+
case 10:
|
|
738
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
739
|
+
replaceContent = newLinesAndIndent();
|
|
740
|
+
} else if (secondToken === 6 && !needsLineBreak) {
|
|
741
|
+
replaceContent = "";
|
|
742
|
+
}
|
|
743
|
+
break;
|
|
744
|
+
case 7:
|
|
745
|
+
case 8:
|
|
746
|
+
case 9:
|
|
747
|
+
case 11:
|
|
748
|
+
case 2:
|
|
749
|
+
case 4:
|
|
750
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
751
|
+
replaceContent = newLinesAndIndent();
|
|
752
|
+
} else {
|
|
753
|
+
if ((secondToken === 12 || secondToken === 13) && !needsLineBreak) {
|
|
754
|
+
replaceContent = cachedSpaces[1];
|
|
755
|
+
} else if (secondToken !== 5 && secondToken !== 17) {
|
|
756
|
+
hasError = true;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
break;
|
|
760
|
+
case 16:
|
|
761
|
+
hasError = true;
|
|
762
|
+
break;
|
|
763
|
+
}
|
|
764
|
+
if (numberLineBreaks > 0 && (secondToken === 12 || secondToken === 13)) {
|
|
765
|
+
replaceContent = newLinesAndIndent();
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
if (secondToken === 17) {
|
|
769
|
+
if (options.keepLines && numberLineBreaks > 0) {
|
|
770
|
+
replaceContent = newLinesAndIndent();
|
|
771
|
+
} else {
|
|
772
|
+
replaceContent = options.insertFinalNewline ? eol : "";
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
|
|
776
|
+
addEdit(replaceContent, firstTokenEnd, secondTokenStart);
|
|
777
|
+
firstToken = secondToken;
|
|
778
|
+
}
|
|
779
|
+
return editOperations;
|
|
780
|
+
}
|
|
781
|
+
function repeat(s, count) {
|
|
782
|
+
let result = "";
|
|
783
|
+
for (let i = 0; i < count; i++) {
|
|
784
|
+
result += s;
|
|
785
|
+
}
|
|
786
|
+
return result;
|
|
787
|
+
}
|
|
788
|
+
function computeIndentLevel(content2, options) {
|
|
789
|
+
let i = 0;
|
|
790
|
+
let nChars = 0;
|
|
791
|
+
const tabSize = options.tabSize || 4;
|
|
792
|
+
while (i < content2.length) {
|
|
793
|
+
let ch = content2.charAt(i);
|
|
794
|
+
if (ch === cachedSpaces[1]) {
|
|
795
|
+
nChars++;
|
|
796
|
+
} else if (ch === " ") {
|
|
797
|
+
nChars += tabSize;
|
|
798
|
+
} else {
|
|
799
|
+
break;
|
|
800
|
+
}
|
|
801
|
+
i++;
|
|
802
|
+
}
|
|
803
|
+
return Math.floor(nChars / tabSize);
|
|
804
|
+
}
|
|
805
|
+
function getEOL(options, text2) {
|
|
806
|
+
for (let i = 0; i < text2.length; i++) {
|
|
807
|
+
const ch = text2.charAt(i);
|
|
808
|
+
if (ch === "\r") {
|
|
809
|
+
if (i + 1 < text2.length && text2.charAt(i + 1) === "\n") {
|
|
810
|
+
return "\r\n";
|
|
811
|
+
}
|
|
812
|
+
return "\r";
|
|
813
|
+
} else if (ch === "\n") {
|
|
814
|
+
return "\n";
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return options && options.eol || "\n";
|
|
818
|
+
}
|
|
819
|
+
function isEOL(text2, offset) {
|
|
820
|
+
return "\r\n".indexOf(text2.charAt(offset)) !== -1;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// ../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
|
|
824
|
+
var ParseOptions;
|
|
825
|
+
(function(ParseOptions2) {
|
|
826
|
+
ParseOptions2.DEFAULT = {
|
|
827
|
+
allowTrailingComma: false
|
|
828
|
+
};
|
|
829
|
+
})(ParseOptions || (ParseOptions = {}));
|
|
830
|
+
function parseTree(text2, errors = [], options = ParseOptions.DEFAULT) {
|
|
831
|
+
let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
|
|
832
|
+
function ensurePropertyComplete(endOffset) {
|
|
833
|
+
if (currentParent.type === "property") {
|
|
834
|
+
currentParent.length = endOffset - currentParent.offset;
|
|
835
|
+
currentParent = currentParent.parent;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
function onValue(valueNode) {
|
|
839
|
+
currentParent.children.push(valueNode);
|
|
840
|
+
return valueNode;
|
|
841
|
+
}
|
|
842
|
+
const visitor = {
|
|
843
|
+
onObjectBegin: (offset) => {
|
|
844
|
+
currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
|
|
845
|
+
},
|
|
846
|
+
onObjectProperty: (name, offset, length) => {
|
|
847
|
+
currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
|
|
848
|
+
currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
|
|
849
|
+
},
|
|
850
|
+
onObjectEnd: (offset, length) => {
|
|
851
|
+
ensurePropertyComplete(offset + length);
|
|
852
|
+
currentParent.length = offset + length - currentParent.offset;
|
|
853
|
+
currentParent = currentParent.parent;
|
|
854
|
+
ensurePropertyComplete(offset + length);
|
|
855
|
+
},
|
|
856
|
+
onArrayBegin: (offset, length) => {
|
|
857
|
+
currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
|
|
858
|
+
},
|
|
859
|
+
onArrayEnd: (offset, length) => {
|
|
860
|
+
currentParent.length = offset + length - currentParent.offset;
|
|
861
|
+
currentParent = currentParent.parent;
|
|
862
|
+
ensurePropertyComplete(offset + length);
|
|
863
|
+
},
|
|
864
|
+
onLiteralValue: (value, offset, length) => {
|
|
865
|
+
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
|
866
|
+
ensurePropertyComplete(offset + length);
|
|
867
|
+
},
|
|
868
|
+
onSeparator: (sep, offset, length) => {
|
|
869
|
+
if (currentParent.type === "property") {
|
|
870
|
+
if (sep === ":") {
|
|
871
|
+
currentParent.colonOffset = offset;
|
|
872
|
+
} else if (sep === ",") {
|
|
873
|
+
ensurePropertyComplete(offset);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
},
|
|
877
|
+
onError: (error, offset, length) => {
|
|
878
|
+
errors.push({ error, offset, length });
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
visit(text2, visitor, options);
|
|
882
|
+
const result = currentParent.children[0];
|
|
883
|
+
if (result) {
|
|
884
|
+
delete result.parent;
|
|
885
|
+
}
|
|
886
|
+
return result;
|
|
887
|
+
}
|
|
888
|
+
function findNodeAtLocation(root, path) {
|
|
889
|
+
if (!root) {
|
|
890
|
+
return void 0;
|
|
891
|
+
}
|
|
892
|
+
let node = root;
|
|
893
|
+
for (let segment of path) {
|
|
894
|
+
if (typeof segment === "string") {
|
|
895
|
+
if (node.type !== "object" || !Array.isArray(node.children)) {
|
|
896
|
+
return void 0;
|
|
897
|
+
}
|
|
898
|
+
let found = false;
|
|
899
|
+
for (const propertyNode of node.children) {
|
|
900
|
+
if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
|
|
901
|
+
node = propertyNode.children[1];
|
|
902
|
+
found = true;
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
if (!found) {
|
|
907
|
+
return void 0;
|
|
908
|
+
}
|
|
909
|
+
} else {
|
|
910
|
+
const index = segment;
|
|
911
|
+
if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
|
|
912
|
+
return void 0;
|
|
913
|
+
}
|
|
914
|
+
node = node.children[index];
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return node;
|
|
918
|
+
}
|
|
919
|
+
function visit(text2, visitor, options = ParseOptions.DEFAULT) {
|
|
920
|
+
const _scanner = createScanner(text2, false);
|
|
921
|
+
const _jsonPath = [];
|
|
922
|
+
let suppressedCallbacks = 0;
|
|
923
|
+
function toNoArgVisit(visitFunction) {
|
|
924
|
+
return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
925
|
+
}
|
|
926
|
+
function toOneArgVisit(visitFunction) {
|
|
927
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
|
|
928
|
+
}
|
|
929
|
+
function toOneArgVisitWithPath(visitFunction) {
|
|
930
|
+
return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
|
|
931
|
+
}
|
|
932
|
+
function toBeginVisit(visitFunction) {
|
|
933
|
+
return visitFunction ? () => {
|
|
934
|
+
if (suppressedCallbacks > 0) {
|
|
935
|
+
suppressedCallbacks++;
|
|
936
|
+
} else {
|
|
937
|
+
let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
|
|
938
|
+
if (cbReturn === false) {
|
|
939
|
+
suppressedCallbacks = 1;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
} : () => true;
|
|
943
|
+
}
|
|
944
|
+
function toEndVisit(visitFunction) {
|
|
945
|
+
return visitFunction ? () => {
|
|
946
|
+
if (suppressedCallbacks > 0) {
|
|
947
|
+
suppressedCallbacks--;
|
|
948
|
+
}
|
|
949
|
+
if (suppressedCallbacks === 0) {
|
|
950
|
+
visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
|
|
951
|
+
}
|
|
952
|
+
} : () => true;
|
|
953
|
+
}
|
|
954
|
+
const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
|
|
955
|
+
const disallowComments = options && options.disallowComments;
|
|
956
|
+
const allowTrailingComma = options && options.allowTrailingComma;
|
|
957
|
+
function scanNext() {
|
|
958
|
+
while (true) {
|
|
959
|
+
const token = _scanner.scan();
|
|
960
|
+
switch (_scanner.getTokenError()) {
|
|
961
|
+
case 4:
|
|
962
|
+
handleError(
|
|
963
|
+
14
|
|
964
|
+
/* ParseErrorCode.InvalidUnicode */
|
|
965
|
+
);
|
|
966
|
+
break;
|
|
967
|
+
case 5:
|
|
968
|
+
handleError(
|
|
969
|
+
15
|
|
970
|
+
/* ParseErrorCode.InvalidEscapeCharacter */
|
|
971
|
+
);
|
|
972
|
+
break;
|
|
973
|
+
case 3:
|
|
974
|
+
handleError(
|
|
975
|
+
13
|
|
976
|
+
/* ParseErrorCode.UnexpectedEndOfNumber */
|
|
977
|
+
);
|
|
978
|
+
break;
|
|
979
|
+
case 1:
|
|
980
|
+
if (!disallowComments) {
|
|
981
|
+
handleError(
|
|
982
|
+
11
|
|
983
|
+
/* ParseErrorCode.UnexpectedEndOfComment */
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
break;
|
|
987
|
+
case 2:
|
|
988
|
+
handleError(
|
|
989
|
+
12
|
|
990
|
+
/* ParseErrorCode.UnexpectedEndOfString */
|
|
991
|
+
);
|
|
992
|
+
break;
|
|
993
|
+
case 6:
|
|
994
|
+
handleError(
|
|
995
|
+
16
|
|
996
|
+
/* ParseErrorCode.InvalidCharacter */
|
|
997
|
+
);
|
|
998
|
+
break;
|
|
999
|
+
}
|
|
1000
|
+
switch (token) {
|
|
1001
|
+
case 12:
|
|
1002
|
+
case 13:
|
|
1003
|
+
if (disallowComments) {
|
|
1004
|
+
handleError(
|
|
1005
|
+
10
|
|
1006
|
+
/* ParseErrorCode.InvalidCommentToken */
|
|
1007
|
+
);
|
|
1008
|
+
} else {
|
|
1009
|
+
onComment();
|
|
1010
|
+
}
|
|
1011
|
+
break;
|
|
1012
|
+
case 16:
|
|
1013
|
+
handleError(
|
|
1014
|
+
1
|
|
1015
|
+
/* ParseErrorCode.InvalidSymbol */
|
|
1016
|
+
);
|
|
1017
|
+
break;
|
|
1018
|
+
case 15:
|
|
1019
|
+
case 14:
|
|
1020
|
+
break;
|
|
1021
|
+
default:
|
|
1022
|
+
return token;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
1027
|
+
onError(error);
|
|
1028
|
+
if (skipUntilAfter.length + skipUntil.length > 0) {
|
|
1029
|
+
let token = _scanner.getToken();
|
|
1030
|
+
while (token !== 17) {
|
|
1031
|
+
if (skipUntilAfter.indexOf(token) !== -1) {
|
|
1032
|
+
scanNext();
|
|
1033
|
+
break;
|
|
1034
|
+
} else if (skipUntil.indexOf(token) !== -1) {
|
|
1035
|
+
break;
|
|
1036
|
+
}
|
|
1037
|
+
token = scanNext();
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
function parseString(isValue) {
|
|
1042
|
+
const value = _scanner.getTokenValue();
|
|
1043
|
+
if (isValue) {
|
|
1044
|
+
onLiteralValue(value);
|
|
1045
|
+
} else {
|
|
1046
|
+
onObjectProperty(value);
|
|
1047
|
+
_jsonPath.push(value);
|
|
1048
|
+
}
|
|
1049
|
+
scanNext();
|
|
1050
|
+
return true;
|
|
1051
|
+
}
|
|
1052
|
+
function parseLiteral() {
|
|
1053
|
+
switch (_scanner.getToken()) {
|
|
1054
|
+
case 11:
|
|
1055
|
+
const tokenValue = _scanner.getTokenValue();
|
|
1056
|
+
let value = Number(tokenValue);
|
|
1057
|
+
if (isNaN(value)) {
|
|
1058
|
+
handleError(
|
|
1059
|
+
2
|
|
1060
|
+
/* ParseErrorCode.InvalidNumberFormat */
|
|
1061
|
+
);
|
|
1062
|
+
value = 0;
|
|
1063
|
+
}
|
|
1064
|
+
onLiteralValue(value);
|
|
1065
|
+
break;
|
|
1066
|
+
case 7:
|
|
1067
|
+
onLiteralValue(null);
|
|
1068
|
+
break;
|
|
1069
|
+
case 8:
|
|
1070
|
+
onLiteralValue(true);
|
|
1071
|
+
break;
|
|
1072
|
+
case 9:
|
|
1073
|
+
onLiteralValue(false);
|
|
1074
|
+
break;
|
|
1075
|
+
default:
|
|
1076
|
+
return false;
|
|
1077
|
+
}
|
|
1078
|
+
scanNext();
|
|
1079
|
+
return true;
|
|
1080
|
+
}
|
|
1081
|
+
function parseProperty() {
|
|
1082
|
+
if (_scanner.getToken() !== 10) {
|
|
1083
|
+
handleError(3, [], [
|
|
1084
|
+
2,
|
|
1085
|
+
5
|
|
1086
|
+
/* SyntaxKind.CommaToken */
|
|
1087
|
+
]);
|
|
1088
|
+
return false;
|
|
1089
|
+
}
|
|
1090
|
+
parseString(false);
|
|
1091
|
+
if (_scanner.getToken() === 6) {
|
|
1092
|
+
onSeparator(":");
|
|
1093
|
+
scanNext();
|
|
1094
|
+
if (!parseValue()) {
|
|
1095
|
+
handleError(4, [], [
|
|
1096
|
+
2,
|
|
1097
|
+
5
|
|
1098
|
+
/* SyntaxKind.CommaToken */
|
|
1099
|
+
]);
|
|
1100
|
+
}
|
|
1101
|
+
} else {
|
|
1102
|
+
handleError(5, [], [
|
|
1103
|
+
2,
|
|
1104
|
+
5
|
|
1105
|
+
/* SyntaxKind.CommaToken */
|
|
1106
|
+
]);
|
|
1107
|
+
}
|
|
1108
|
+
_jsonPath.pop();
|
|
1109
|
+
return true;
|
|
1110
|
+
}
|
|
1111
|
+
function parseObject() {
|
|
1112
|
+
onObjectBegin();
|
|
1113
|
+
scanNext();
|
|
1114
|
+
let needsComma = false;
|
|
1115
|
+
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
|
|
1116
|
+
if (_scanner.getToken() === 5) {
|
|
1117
|
+
if (!needsComma) {
|
|
1118
|
+
handleError(4, [], []);
|
|
1119
|
+
}
|
|
1120
|
+
onSeparator(",");
|
|
1121
|
+
scanNext();
|
|
1122
|
+
if (_scanner.getToken() === 2 && allowTrailingComma) {
|
|
1123
|
+
break;
|
|
1124
|
+
}
|
|
1125
|
+
} else if (needsComma) {
|
|
1126
|
+
handleError(6, [], []);
|
|
1127
|
+
}
|
|
1128
|
+
if (!parseProperty()) {
|
|
1129
|
+
handleError(4, [], [
|
|
1130
|
+
2,
|
|
1131
|
+
5
|
|
1132
|
+
/* SyntaxKind.CommaToken */
|
|
1133
|
+
]);
|
|
1134
|
+
}
|
|
1135
|
+
needsComma = true;
|
|
1136
|
+
}
|
|
1137
|
+
onObjectEnd();
|
|
1138
|
+
if (_scanner.getToken() !== 2) {
|
|
1139
|
+
handleError(7, [
|
|
1140
|
+
2
|
|
1141
|
+
/* SyntaxKind.CloseBraceToken */
|
|
1142
|
+
], []);
|
|
1143
|
+
} else {
|
|
1144
|
+
scanNext();
|
|
1145
|
+
}
|
|
1146
|
+
return true;
|
|
1147
|
+
}
|
|
1148
|
+
function parseArray() {
|
|
1149
|
+
onArrayBegin();
|
|
1150
|
+
scanNext();
|
|
1151
|
+
let isFirstElement = true;
|
|
1152
|
+
let needsComma = false;
|
|
1153
|
+
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
|
|
1154
|
+
if (_scanner.getToken() === 5) {
|
|
1155
|
+
if (!needsComma) {
|
|
1156
|
+
handleError(4, [], []);
|
|
1157
|
+
}
|
|
1158
|
+
onSeparator(",");
|
|
1159
|
+
scanNext();
|
|
1160
|
+
if (_scanner.getToken() === 4 && allowTrailingComma) {
|
|
1161
|
+
break;
|
|
1162
|
+
}
|
|
1163
|
+
} else if (needsComma) {
|
|
1164
|
+
handleError(6, [], []);
|
|
1165
|
+
}
|
|
1166
|
+
if (isFirstElement) {
|
|
1167
|
+
_jsonPath.push(0);
|
|
1168
|
+
isFirstElement = false;
|
|
1169
|
+
} else {
|
|
1170
|
+
_jsonPath[_jsonPath.length - 1]++;
|
|
1171
|
+
}
|
|
1172
|
+
if (!parseValue()) {
|
|
1173
|
+
handleError(4, [], [
|
|
1174
|
+
4,
|
|
1175
|
+
5
|
|
1176
|
+
/* SyntaxKind.CommaToken */
|
|
1177
|
+
]);
|
|
1178
|
+
}
|
|
1179
|
+
needsComma = true;
|
|
1180
|
+
}
|
|
1181
|
+
onArrayEnd();
|
|
1182
|
+
if (!isFirstElement) {
|
|
1183
|
+
_jsonPath.pop();
|
|
1184
|
+
}
|
|
1185
|
+
if (_scanner.getToken() !== 4) {
|
|
1186
|
+
handleError(8, [
|
|
1187
|
+
4
|
|
1188
|
+
/* SyntaxKind.CloseBracketToken */
|
|
1189
|
+
], []);
|
|
1190
|
+
} else {
|
|
1191
|
+
scanNext();
|
|
1192
|
+
}
|
|
1193
|
+
return true;
|
|
1194
|
+
}
|
|
1195
|
+
function parseValue() {
|
|
1196
|
+
switch (_scanner.getToken()) {
|
|
1197
|
+
case 3:
|
|
1198
|
+
return parseArray();
|
|
1199
|
+
case 1:
|
|
1200
|
+
return parseObject();
|
|
1201
|
+
case 10:
|
|
1202
|
+
return parseString(true);
|
|
1203
|
+
default:
|
|
1204
|
+
return parseLiteral();
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
scanNext();
|
|
1208
|
+
if (_scanner.getToken() === 17) {
|
|
1209
|
+
if (options.allowEmptyContent) {
|
|
1210
|
+
return true;
|
|
1211
|
+
}
|
|
1212
|
+
handleError(4, [], []);
|
|
1213
|
+
return false;
|
|
1214
|
+
}
|
|
1215
|
+
if (!parseValue()) {
|
|
1216
|
+
handleError(4, [], []);
|
|
1217
|
+
return false;
|
|
1218
|
+
}
|
|
1219
|
+
if (_scanner.getToken() !== 17) {
|
|
1220
|
+
handleError(9, [], []);
|
|
1221
|
+
}
|
|
1222
|
+
return true;
|
|
1223
|
+
}
|
|
1224
|
+
function getNodeType(value) {
|
|
1225
|
+
switch (typeof value) {
|
|
1226
|
+
case "boolean":
|
|
1227
|
+
return "boolean";
|
|
1228
|
+
case "number":
|
|
1229
|
+
return "number";
|
|
1230
|
+
case "string":
|
|
1231
|
+
return "string";
|
|
1232
|
+
case "object": {
|
|
1233
|
+
if (!value) {
|
|
1234
|
+
return "null";
|
|
1235
|
+
} else if (Array.isArray(value)) {
|
|
1236
|
+
return "array";
|
|
1237
|
+
}
|
|
1238
|
+
return "object";
|
|
1239
|
+
}
|
|
1240
|
+
default:
|
|
1241
|
+
return "null";
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// ../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/edit.js
|
|
1246
|
+
function setProperty(text2, originalPath, value, options) {
|
|
1247
|
+
const path = originalPath.slice();
|
|
1248
|
+
const errors = [];
|
|
1249
|
+
const root = parseTree(text2, errors);
|
|
1250
|
+
let parent = void 0;
|
|
1251
|
+
let lastSegment = void 0;
|
|
1252
|
+
while (path.length > 0) {
|
|
1253
|
+
lastSegment = path.pop();
|
|
1254
|
+
parent = findNodeAtLocation(root, path);
|
|
1255
|
+
if (parent === void 0 && value !== void 0) {
|
|
1256
|
+
if (typeof lastSegment === "string") {
|
|
1257
|
+
value = { [lastSegment]: value };
|
|
1258
|
+
} else {
|
|
1259
|
+
value = [value];
|
|
1260
|
+
}
|
|
1261
|
+
} else {
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
if (!parent) {
|
|
1266
|
+
if (value === void 0) {
|
|
1267
|
+
throw new Error("Can not delete in empty document");
|
|
1268
|
+
}
|
|
1269
|
+
return withFormatting(text2, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
|
|
1270
|
+
} else if (parent.type === "object" && typeof lastSegment === "string" && Array.isArray(parent.children)) {
|
|
1271
|
+
const existing = findNodeAtLocation(parent, [lastSegment]);
|
|
1272
|
+
if (existing !== void 0) {
|
|
1273
|
+
if (value === void 0) {
|
|
1274
|
+
if (!existing.parent) {
|
|
1275
|
+
throw new Error("Malformed AST");
|
|
1276
|
+
}
|
|
1277
|
+
const propertyIndex = parent.children.indexOf(existing.parent);
|
|
1278
|
+
let removeBegin;
|
|
1279
|
+
let removeEnd = existing.parent.offset + existing.parent.length;
|
|
1280
|
+
if (propertyIndex > 0) {
|
|
1281
|
+
let previous = parent.children[propertyIndex - 1];
|
|
1282
|
+
removeBegin = previous.offset + previous.length;
|
|
1283
|
+
} else {
|
|
1284
|
+
removeBegin = parent.offset + 1;
|
|
1285
|
+
if (parent.children.length > 1) {
|
|
1286
|
+
let next = parent.children[1];
|
|
1287
|
+
removeEnd = next.offset;
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
return withFormatting(text2, { offset: removeBegin, length: removeEnd - removeBegin, content: "" }, options);
|
|
1291
|
+
} else {
|
|
1292
|
+
return withFormatting(text2, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
|
|
1293
|
+
}
|
|
1294
|
+
} else {
|
|
1295
|
+
if (value === void 0) {
|
|
1296
|
+
return [];
|
|
1297
|
+
}
|
|
1298
|
+
const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
|
|
1299
|
+
const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map((p) => p.children[0].value)) : parent.children.length;
|
|
1300
|
+
let edit;
|
|
1301
|
+
if (index > 0) {
|
|
1302
|
+
let previous = parent.children[index - 1];
|
|
1303
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
1304
|
+
} else if (parent.children.length === 0) {
|
|
1305
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
|
1306
|
+
} else {
|
|
1307
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty + "," };
|
|
1308
|
+
}
|
|
1309
|
+
return withFormatting(text2, edit, options);
|
|
1310
|
+
}
|
|
1311
|
+
} else if (parent.type === "array" && typeof lastSegment === "number" && Array.isArray(parent.children)) {
|
|
1312
|
+
const insertIndex = lastSegment;
|
|
1313
|
+
if (insertIndex === -1) {
|
|
1314
|
+
const newProperty = `${JSON.stringify(value)}`;
|
|
1315
|
+
let edit;
|
|
1316
|
+
if (parent.children.length === 0) {
|
|
1317
|
+
edit = { offset: parent.offset + 1, length: 0, content: newProperty };
|
|
1318
|
+
} else {
|
|
1319
|
+
const previous = parent.children[parent.children.length - 1];
|
|
1320
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
1321
|
+
}
|
|
1322
|
+
return withFormatting(text2, edit, options);
|
|
1323
|
+
} else if (value === void 0 && parent.children.length >= 0) {
|
|
1324
|
+
const removalIndex = lastSegment;
|
|
1325
|
+
const toRemove = parent.children[removalIndex];
|
|
1326
|
+
let edit;
|
|
1327
|
+
if (parent.children.length === 1) {
|
|
1328
|
+
edit = { offset: parent.offset + 1, length: parent.length - 2, content: "" };
|
|
1329
|
+
} else if (parent.children.length - 1 === removalIndex) {
|
|
1330
|
+
let previous = parent.children[removalIndex - 1];
|
|
1331
|
+
let offset = previous.offset + previous.length;
|
|
1332
|
+
let parentEndOffset = parent.offset + parent.length;
|
|
1333
|
+
edit = { offset, length: parentEndOffset - 2 - offset, content: "" };
|
|
1334
|
+
} else {
|
|
1335
|
+
edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: "" };
|
|
1336
|
+
}
|
|
1337
|
+
return withFormatting(text2, edit, options);
|
|
1338
|
+
} else if (value !== void 0) {
|
|
1339
|
+
let edit;
|
|
1340
|
+
const newProperty = `${JSON.stringify(value)}`;
|
|
1341
|
+
if (!options.isArrayInsertion && parent.children.length > lastSegment) {
|
|
1342
|
+
const toModify = parent.children[lastSegment];
|
|
1343
|
+
edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
|
|
1344
|
+
} else if (parent.children.length === 0 || lastSegment === 0) {
|
|
1345
|
+
edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + "," };
|
|
1346
|
+
} else {
|
|
1347
|
+
const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
|
|
1348
|
+
const previous = parent.children[index - 1];
|
|
1349
|
+
edit = { offset: previous.offset + previous.length, length: 0, content: "," + newProperty };
|
|
1350
|
+
}
|
|
1351
|
+
return withFormatting(text2, edit, options);
|
|
1352
|
+
} else {
|
|
1353
|
+
throw new Error(`Can not ${value === void 0 ? "remove" : options.isArrayInsertion ? "insert" : "modify"} Array index ${insertIndex} as length is not sufficient`);
|
|
1354
|
+
}
|
|
1355
|
+
} else {
|
|
1356
|
+
throw new Error(`Can not add ${typeof lastSegment !== "number" ? "index" : "property"} to parent of type ${parent.type}`);
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
function withFormatting(text2, edit, options) {
|
|
1360
|
+
if (!options.formattingOptions) {
|
|
1361
|
+
return [edit];
|
|
1362
|
+
}
|
|
1363
|
+
let newText = applyEdit(text2, edit);
|
|
1364
|
+
let begin = edit.offset;
|
|
1365
|
+
let end = edit.offset + edit.content.length;
|
|
1366
|
+
if (edit.length === 0 || edit.content.length === 0) {
|
|
1367
|
+
while (begin > 0 && !isEOL(newText, begin - 1)) {
|
|
1368
|
+
begin--;
|
|
1369
|
+
}
|
|
1370
|
+
while (end < newText.length && !isEOL(newText, end)) {
|
|
1371
|
+
end++;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
const edits = format(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
|
|
1375
|
+
for (let i = edits.length - 1; i >= 0; i--) {
|
|
1376
|
+
const edit2 = edits[i];
|
|
1377
|
+
newText = applyEdit(newText, edit2);
|
|
1378
|
+
begin = Math.min(begin, edit2.offset);
|
|
1379
|
+
end = Math.max(end, edit2.offset + edit2.length);
|
|
1380
|
+
end += edit2.content.length - edit2.length;
|
|
1381
|
+
}
|
|
1382
|
+
const editLength = text2.length - (newText.length - end) - begin;
|
|
1383
|
+
return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
|
|
1384
|
+
}
|
|
1385
|
+
function applyEdit(text2, edit) {
|
|
1386
|
+
return text2.substring(0, edit.offset) + edit.content + text2.substring(edit.offset + edit.length);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// ../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
|
|
1390
|
+
var ScanError;
|
|
1391
|
+
(function(ScanError2) {
|
|
1392
|
+
ScanError2[ScanError2["None"] = 0] = "None";
|
|
1393
|
+
ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
|
|
1394
|
+
ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
|
|
1395
|
+
ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
|
|
1396
|
+
ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
|
|
1397
|
+
ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
|
|
1398
|
+
ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
|
|
1399
|
+
})(ScanError || (ScanError = {}));
|
|
1400
|
+
var SyntaxKind;
|
|
1401
|
+
(function(SyntaxKind2) {
|
|
1402
|
+
SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
|
|
1403
|
+
SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
|
|
1404
|
+
SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
|
|
1405
|
+
SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
|
|
1406
|
+
SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
|
|
1407
|
+
SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
|
|
1408
|
+
SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
|
|
1409
|
+
SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
|
|
1410
|
+
SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
|
|
1411
|
+
SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
|
|
1412
|
+
SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
|
|
1413
|
+
SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
|
|
1414
|
+
SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
|
|
1415
|
+
SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
|
|
1416
|
+
SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
|
|
1417
|
+
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
|
|
1418
|
+
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
|
|
1419
|
+
})(SyntaxKind || (SyntaxKind = {}));
|
|
1420
|
+
var ParseErrorCode;
|
|
1421
|
+
(function(ParseErrorCode2) {
|
|
1422
|
+
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
|
|
1423
|
+
ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
|
|
1424
|
+
ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
|
|
1425
|
+
ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
|
|
1426
|
+
ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
|
|
1427
|
+
ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
|
|
1428
|
+
ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
|
|
1429
|
+
ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
|
|
1430
|
+
ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
|
|
1431
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
|
|
1432
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
|
|
1433
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
|
|
1434
|
+
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
|
|
1435
|
+
ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
|
|
1436
|
+
ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
|
|
1437
|
+
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
|
|
1438
|
+
})(ParseErrorCode || (ParseErrorCode = {}));
|
|
1439
|
+
function modify(text2, path, value, options) {
|
|
1440
|
+
return setProperty(text2, path, value, options);
|
|
1441
|
+
}
|
|
1442
|
+
function applyEdits(text2, edits) {
|
|
1443
|
+
let sortedEdits = edits.slice(0).sort((a, b) => {
|
|
1444
|
+
const diff = a.offset - b.offset;
|
|
1445
|
+
if (diff === 0) {
|
|
1446
|
+
return a.length - b.length;
|
|
1447
|
+
}
|
|
1448
|
+
return diff;
|
|
1449
|
+
});
|
|
1450
|
+
let lastModifiedOffset = text2.length;
|
|
1451
|
+
for (let i = sortedEdits.length - 1; i >= 0; i--) {
|
|
1452
|
+
let e = sortedEdits[i];
|
|
1453
|
+
if (e.offset + e.length <= lastModifiedOffset) {
|
|
1454
|
+
text2 = applyEdit(text2, e);
|
|
1455
|
+
} else {
|
|
1456
|
+
throw new Error("Overlapping edit");
|
|
1457
|
+
}
|
|
1458
|
+
lastModifiedOffset = e.offset;
|
|
1459
|
+
}
|
|
1460
|
+
return text2;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
// src/client/controller.ts
|
|
1464
|
+
var NEW_EDITOR = "";
|
|
1465
|
+
var NEW_PROFILE_CONTENT = '{\n "version": 1,\n "id": "new-profile",\n "label": "New profile",\n "settings": {\n // Runtime overlay only. Omitted fields inherit the deployment baseline.\n "defaultActive": true\n }\n}\n';
|
|
1466
|
+
function canReconcileSelection(snapshot2) {
|
|
1467
|
+
return snapshot2 !== null && (snapshot2.selectionRevision === "absent" || /^[a-f0-9]{64}$/u.test(snapshot2.selectionRevision)) && (snapshot2.selectionError === void 0 || snapshot2.selectionError.code === "conflict");
|
|
1468
|
+
}
|
|
1469
|
+
var ProfilesController = class {
|
|
1470
|
+
constructor(remote) {
|
|
1471
|
+
this.remote = remote;
|
|
1472
|
+
}
|
|
1473
|
+
current = { snapshot: null, editor: null, dirty: false, busy: null, issue: null, notice: null, pendingEditor: null };
|
|
1474
|
+
accepted = null;
|
|
1475
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1476
|
+
generation = 0;
|
|
1477
|
+
disposed = false;
|
|
1478
|
+
store = {
|
|
1479
|
+
getSnapshot: () => this.current,
|
|
1480
|
+
subscribe: (listener) => {
|
|
1481
|
+
this.listeners.add(listener);
|
|
1482
|
+
return () => {
|
|
1483
|
+
this.listeners.delete(listener);
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
actions = {
|
|
1488
|
+
refresh: () => this.refresh(),
|
|
1489
|
+
open: (id2) => this.open(id2),
|
|
1490
|
+
create: () => this.open(NEW_EDITOR),
|
|
1491
|
+
reload: () => this.reload(),
|
|
1492
|
+
editId: (id2) => this.editId(id2),
|
|
1493
|
+
editContent: (content2) => this.editContent(content2),
|
|
1494
|
+
save: () => this.save(),
|
|
1495
|
+
apply: () => this.apply(),
|
|
1496
|
+
reset: () => this.reset(),
|
|
1497
|
+
discardAndOpen: () => this.discardAndOpen(),
|
|
1498
|
+
cancelDiscard: () => this.publish({ pendingEditor: null })
|
|
1499
|
+
};
|
|
1500
|
+
dispose() {
|
|
1501
|
+
this.disposed = true;
|
|
1502
|
+
this.generation += 1;
|
|
1503
|
+
this.listeners.clear();
|
|
1504
|
+
}
|
|
1505
|
+
publish(patch) {
|
|
1506
|
+
if (this.disposed) return;
|
|
1507
|
+
this.current = { ...this.current, ...patch };
|
|
1508
|
+
for (const listener of this.listeners) listener();
|
|
1509
|
+
}
|
|
1510
|
+
accept(document2) {
|
|
1511
|
+
this.accepted = { ...document2 };
|
|
1512
|
+
this.publish({ editor: { ...document2 }, dirty: false, pendingEditor: null });
|
|
1513
|
+
}
|
|
1514
|
+
async unwrap(request, field) {
|
|
1515
|
+
const result = await request;
|
|
1516
|
+
if (result.ok) return result.value;
|
|
1517
|
+
if (result.error.code === "dsmm-profiles/refused") {
|
|
1518
|
+
throw { kind: "domain", ...result.error.details };
|
|
1519
|
+
}
|
|
1520
|
+
if (["gateway/input-invalid", "gateway/arguments-invalid"].includes(String(result.error.code))) {
|
|
1521
|
+
throw { kind: "domain", code: "validation", field, message: "The native Host rejected a request field. Check the profile ID and document size before retrying." };
|
|
1522
|
+
}
|
|
1523
|
+
throw { kind: "transport", code: result.error.code };
|
|
1524
|
+
}
|
|
1525
|
+
issue(error) {
|
|
1526
|
+
if (typeof error === "object" && error !== null && "kind" in error && (error.kind === "domain" || error.kind === "transport")) return error;
|
|
1527
|
+
return { kind: "assembly", code: "unavailable" };
|
|
1528
|
+
}
|
|
1529
|
+
async perform(busy, operation) {
|
|
1530
|
+
if (this.disposed || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1531
|
+
const generation = ++this.generation;
|
|
1532
|
+
const live = () => !this.disposed && generation === this.generation;
|
|
1533
|
+
this.publish({ busy, issue: null, notice: null });
|
|
1534
|
+
try {
|
|
1535
|
+
await operation(live);
|
|
1536
|
+
} catch (error) {
|
|
1537
|
+
if (live()) this.publish({ issue: this.issue(error) });
|
|
1538
|
+
} finally {
|
|
1539
|
+
if (live()) this.publish({ busy: null });
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
async refresh() {
|
|
1543
|
+
await this.perform("refresh", async (live) => {
|
|
1544
|
+
const snapshot2 = await this.unwrap(this.remote.describe());
|
|
1545
|
+
if (live()) this.publish({ snapshot: snapshot2 });
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
async open(id2) {
|
|
1549
|
+
if (this.disposed || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1550
|
+
if (id2 !== NEW_EDITOR && this.current.editor?.id === id2) return;
|
|
1551
|
+
if (this.current.dirty) {
|
|
1552
|
+
this.publish({ pendingEditor: id2 });
|
|
1553
|
+
return;
|
|
1554
|
+
}
|
|
1555
|
+
await this.loadEditor(id2);
|
|
1556
|
+
}
|
|
1557
|
+
async reload() {
|
|
1558
|
+
const editor = this.current.editor;
|
|
1559
|
+
if (editor === null || editor.revision === null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1560
|
+
if (this.current.dirty) {
|
|
1561
|
+
this.publish({ pendingEditor: editor.id });
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
await this.loadEditor(editor.id);
|
|
1565
|
+
}
|
|
1566
|
+
async loadEditor(id2) {
|
|
1567
|
+
if (id2 === NEW_EDITOR) {
|
|
1568
|
+
this.accepted = null;
|
|
1569
|
+
this.publish({ editor: { id: "new-profile", content: NEW_PROFILE_CONTENT, revision: null }, dirty: true, issue: null, notice: null, pendingEditor: null });
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
await this.perform("read", async (live) => {
|
|
1573
|
+
const document2 = await this.unwrap(this.remote.read(id2), "id");
|
|
1574
|
+
if (live()) this.accept(document2);
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
async discardAndOpen() {
|
|
1578
|
+
const wanted = this.current.pendingEditor;
|
|
1579
|
+
if (wanted === null || this.current.busy !== null) return;
|
|
1580
|
+
this.publish({ pendingEditor: null });
|
|
1581
|
+
const previous = this.current.editor;
|
|
1582
|
+
const accepted = this.accepted;
|
|
1583
|
+
await this.loadEditor(wanted);
|
|
1584
|
+
if (this.current.issue !== null && previous !== null) {
|
|
1585
|
+
this.accepted = accepted;
|
|
1586
|
+
this.publish({ editor: previous, dirty: true });
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
editId(id2) {
|
|
1590
|
+
const editor = this.current.editor;
|
|
1591
|
+
if (editor === null || editor.revision !== null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1592
|
+
let content2 = editor.content;
|
|
1593
|
+
try {
|
|
1594
|
+
content2 = applyEdits(content2, modify(content2, ["id"], id2, { formattingOptions: { insertSpaces: true, tabSize: 2 } }));
|
|
1595
|
+
} catch {
|
|
1596
|
+
}
|
|
1597
|
+
this.publish({ editor: { ...editor, id: id2, content: content2 }, dirty: true, issue: null, notice: null });
|
|
1598
|
+
}
|
|
1599
|
+
editContent(content2) {
|
|
1600
|
+
const editor = this.current.editor;
|
|
1601
|
+
if (editor === null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1602
|
+
this.publish({ editor: { ...editor, content: content2 }, dirty: this.accepted === null || this.accepted.content !== content2 || this.accepted.id !== editor.id, issue: null, notice: null });
|
|
1603
|
+
}
|
|
1604
|
+
async save() {
|
|
1605
|
+
const editor = this.current.editor;
|
|
1606
|
+
if (editor === null || !this.current.dirty || this.current.snapshot === null || this.current.busy !== null || this.current.pendingEditor !== null) return;
|
|
1607
|
+
if (!isProfileId(editor.id)) {
|
|
1608
|
+
this.publish({ issue: { kind: "domain", code: "validation", field: "id" }, notice: null });
|
|
1609
|
+
return;
|
|
1610
|
+
}
|
|
1611
|
+
await this.perform("save", async (live) => {
|
|
1612
|
+
const document2 = await this.unwrap(this.remote.save({ id: editor.id, content: editor.content, expectedRevision: editor.revision }), "content");
|
|
1613
|
+
if (!live()) return;
|
|
1614
|
+
this.accept(document2);
|
|
1615
|
+
const old = this.current.snapshot;
|
|
1616
|
+
const profiles = old.profiles.filter((item) => item.id !== document2.id);
|
|
1617
|
+
profiles.push({ id: document2.id, revision: document2.revision, ...document2.label === void 0 ? {} : { label: document2.label } });
|
|
1618
|
+
profiles.sort((a, b) => a.id.localeCompare(b.id));
|
|
1619
|
+
this.publish({ snapshot: { ...old, profiles }, notice: { key: "saved", id: document2.id } });
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
async apply() {
|
|
1623
|
+
const { editor, snapshot: snapshot2, dirty } = this.current;
|
|
1624
|
+
if (editor?.revision == null || !canReconcileSelection(snapshot2) || dirty) return;
|
|
1625
|
+
await this.perform("apply", async (live) => {
|
|
1626
|
+
const accepted = await this.unwrap(this.remote.select({ id: editor.id, expectedRevision: editor.revision, expectedSelectionRevision: snapshot2.selectionRevision }));
|
|
1627
|
+
if (live()) this.acceptSelection(accepted, { key: "applied", id: accepted.selectedId ?? void 0 });
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
async reset() {
|
|
1631
|
+
const snapshot2 = this.current.snapshot;
|
|
1632
|
+
if (!canReconcileSelection(snapshot2)) return;
|
|
1633
|
+
await this.perform("reset", async (live) => {
|
|
1634
|
+
const accepted = await this.unwrap(this.remote.select({ id: null, expectedSelectionRevision: snapshot2.selectionRevision }));
|
|
1635
|
+
if (live()) this.acceptSelection(accepted, { key: "reset" });
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
acceptSelection(snapshot2, notice) {
|
|
1639
|
+
this.publish({
|
|
1640
|
+
snapshot: snapshot2,
|
|
1641
|
+
notice: snapshot2.selectionError === void 0 ? notice : null,
|
|
1642
|
+
issue: snapshot2.selectionError === void 0 ? null : { kind: "domain", ...snapshot2.selectionError, source: "selection" }
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
};
|
|
1646
|
+
|
|
1647
|
+
// src/client/locales.ts
|
|
1648
|
+
var NS = "settings.dsmm-profiles";
|
|
1649
|
+
var en = {
|
|
1650
|
+
title: "Deepwork Profiles",
|
|
1651
|
+
description: "Save independent runtime configurations and choose which one new sessions use.",
|
|
1652
|
+
newSessions: "Apply and reset affect new sessions only. Existing sessions, including blank sessions, keep their current policy. A cold resume uses the currently applied policy.",
|
|
1653
|
+
editorSelect: "Profile to edit",
|
|
1654
|
+
choose: "Choose a profile",
|
|
1655
|
+
newDraft: "New unsaved profile",
|
|
1656
|
+
new: "New profile",
|
|
1657
|
+
profileId: "Profile ID (name)",
|
|
1658
|
+
idHint: "Use 1–64 lowercase letters, digits, hyphens or underscores. The ID cannot be changed after saving. Add an optional display label in the JSONC document.",
|
|
1659
|
+
configuration: "Runtime configuration (JSONC)",
|
|
1660
|
+
configurationHint: "Document: version 1, matching id, optional label, and settings. Supported runtime settings: defaultActive, roleRouting, workflow, guards, runtimeRecovery, and both DeepSeek families’ calibration, default-effort and max-preset policies.",
|
|
1661
|
+
structuralHint: "Roles, skills, mode names, prompt order/content, preset installation, LSP, providers and accounts belong in native deployment configuration, not profiles. Routing may reference an existing provider; never paste credentials.",
|
|
1662
|
+
save: "Save profile",
|
|
1663
|
+
saving: "Saving profile…",
|
|
1664
|
+
apply: "Apply saved profile",
|
|
1665
|
+
applying: "Applying profile…",
|
|
1666
|
+
reset: "Reset to baseline",
|
|
1667
|
+
resetting: "Resetting to baseline…",
|
|
1668
|
+
refresh: "Refresh profiles",
|
|
1669
|
+
refreshing: "Refreshing profiles…",
|
|
1670
|
+
reload: "Reload saved profile",
|
|
1671
|
+
loading: "Loading profiles…",
|
|
1672
|
+
reading: "Reading profile…",
|
|
1673
|
+
empty: "No saved profiles yet. Create a profile to start; the deployment baseline remains applied.",
|
|
1674
|
+
baseline: "Applied to new sessions: deployment baseline.",
|
|
1675
|
+
appliedProfile: "Applied to new sessions: {id} (revision {revision}).",
|
|
1676
|
+
appliedInvalid: "The stored selection cannot be confirmed. Existing sessions remain unchanged. Resolve the Host diagnostic before applying or resetting a profile.",
|
|
1677
|
+
selectionConflict: "The stored selection changed outside this Host. This Host still uses the policy shown above for new sessions. Apply a saved profile or reset to baseline to reconcile it; restarting adopts the stored selection. Existing sessions stay unchanged.",
|
|
1678
|
+
dirty: "Unsaved changes. Save before applying; saving alone does not apply this profile.",
|
|
1679
|
+
savedNotApplied: "Saved profile; this revision is not applied to new sessions.",
|
|
1680
|
+
savedApplied: "This saved revision is applied to new sessions.",
|
|
1681
|
+
saved: "Saved {id}. The applied policy was not changed.",
|
|
1682
|
+
applied: "Applied {id} for new sessions. Existing sessions were not changed.",
|
|
1683
|
+
resetDone: "Reset to the deployment baseline for new sessions. Existing sessions were not changed.",
|
|
1684
|
+
discardPrompt: "Discard the unsaved draft before changing the editor?",
|
|
1685
|
+
discard: "Discard changes",
|
|
1686
|
+
cancel: "Cancel",
|
|
1687
|
+
conflict: "The saved file or selection changed elsewhere. Your draft and the prior selection were kept. Refresh profiles, then reload the saved profile or review your draft before retrying.",
|
|
1688
|
+
validation: "This profile is not valid. Correct the field below; your draft is unchanged.",
|
|
1689
|
+
io: "The Host could not commit this operation. Your draft and the prior selection were kept. Check profile storage access, refresh, then retry.",
|
|
1690
|
+
unavailable: "The native profile service is unavailable. Your draft is kept. Refresh after the Host reconnects or Deepwork is enabled.",
|
|
1691
|
+
transport: "The native connection could not confirm this operation. Your draft is kept. Refresh the Host state before retrying; do not assume a save or apply completed.",
|
|
1692
|
+
invalidProfile: "Unavailable profile: {id}",
|
|
1693
|
+
details: "Host diagnostic",
|
|
1694
|
+
retry: "Resolve the diagnostic, refresh profiles, then retry."
|
|
1695
|
+
};
|
|
1696
|
+
var zh = {
|
|
1697
|
+
title: "Deepwork 配置档",
|
|
1698
|
+
description: "保存独立的运行时配置,并选择新会话使用的配置档。",
|
|
1699
|
+
newSessions: "应用和重置仅影响新会话。已有会话(包括空白会话)保留原策略。冷恢复使用当前已应用的策略。",
|
|
1700
|
+
editorSelect: "要编辑的配置档",
|
|
1701
|
+
choose: "选择配置档",
|
|
1702
|
+
newDraft: "新的未保存配置档",
|
|
1703
|
+
new: "新建配置档",
|
|
1704
|
+
profileId: "配置档 ID(名称)",
|
|
1705
|
+
idHint: "使用 1–64 个小写字母、数字、连字符或下划线。保存后不能修改 ID。可在 JSONC 文档中添加可选的显示名称 label。",
|
|
1706
|
+
configuration: "运行时配置(JSONC)",
|
|
1707
|
+
configurationHint: "文档包含 version: 1、相同的 id、可选 label 和 settings。支持 defaultActive、roleRouting、workflow、guards、runtimeRecovery,以及两个 DeepSeek 系列的校准、默认推理强度和最高强度预设策略。",
|
|
1708
|
+
structuralHint: "角色、技能、模式名称、提示顺序或内容、预设安装、LSP、提供商和账户由原生部署配置管理,不属于配置档。路由可引用已有提供商;请勿粘贴凭证。",
|
|
1709
|
+
save: "保存配置档",
|
|
1710
|
+
saving: "正在保存配置档…",
|
|
1711
|
+
apply: "应用已保存配置档",
|
|
1712
|
+
applying: "正在应用配置档…",
|
|
1713
|
+
reset: "重置为基线",
|
|
1714
|
+
resetting: "正在重置为基线…",
|
|
1715
|
+
refresh: "刷新配置档",
|
|
1716
|
+
refreshing: "正在刷新配置档…",
|
|
1717
|
+
reload: "重新加载已保存配置档",
|
|
1718
|
+
loading: "正在加载配置档…",
|
|
1719
|
+
reading: "正在读取配置档…",
|
|
1720
|
+
empty: "尚无已保存的配置档。可新建配置档;当前仍应用部署基线。",
|
|
1721
|
+
baseline: "新会话使用:部署基线。",
|
|
1722
|
+
appliedProfile: "新会话使用:{id}(修订 {revision})。",
|
|
1723
|
+
appliedInvalid: "无法确认保存的选择。已有会话未改变。请先解决 Host 诊断,再应用或重置配置档。",
|
|
1724
|
+
selectionConflict: "保存的选择已被此 Host 之外的操作修改。此 Host 的新会话仍使用上方策略。请应用已保存配置档或重置为基线以协调选择;重启将采用保存的选择。已有会话未改变。",
|
|
1725
|
+
dirty: "有未保存的更改。请先保存再应用;仅保存不会应用此配置档。",
|
|
1726
|
+
savedNotApplied: "已保存;此修订尚未应用到新会话。",
|
|
1727
|
+
savedApplied: "此已保存修订已应用到新会话。",
|
|
1728
|
+
saved: "已保存 {id},未改变已应用的策略。",
|
|
1729
|
+
applied: "已为新会话应用 {id},已有会话未改变。",
|
|
1730
|
+
resetDone: "已为新会话重置为部署基线,已有会话未改变。",
|
|
1731
|
+
discardPrompt: "切换编辑器之前,是否丢弃未保存的草稿?",
|
|
1732
|
+
discard: "丢弃更改",
|
|
1733
|
+
cancel: "取消",
|
|
1734
|
+
conflict: "已保存文件或选择已被其他操作修改。草稿和原选择已保留。请刷新配置档,然后重新加载已保存配置档或检查草稿后重试。",
|
|
1735
|
+
validation: "此配置档无效。请修正下方字段;草稿未改变。",
|
|
1736
|
+
io: "Host 无法提交此操作。草稿和原选择已保留。请检查配置档存储权限,刷新后重试。",
|
|
1737
|
+
unavailable: "原生配置档服务不可用。草稿已保留。Host 重新连接或启用 Deepwork 后请刷新。",
|
|
1738
|
+
transport: "原生连接无法确认此操作。草稿已保留。重试之前请刷新 Host 状态;不要假定保存或应用已完成。",
|
|
1739
|
+
invalidProfile: "不可用配置档:{id}",
|
|
1740
|
+
details: "Host 诊断",
|
|
1741
|
+
retry: "请解决诊断问题,刷新配置档后重试。"
|
|
1742
|
+
};
|
|
1743
|
+
|
|
1744
|
+
// src/client/ProfilesSection.tsx
|
|
1745
|
+
var import_react = require("react");
|
|
1746
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
1747
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1748
|
+
function issueKey(issue) {
|
|
1749
|
+
if (issue.source === "selection") return issue.code === "conflict" ? "selectionConflict" : "appliedInvalid";
|
|
1750
|
+
if (issue.kind === "assembly") return "unavailable";
|
|
1751
|
+
if (issue.kind === "transport") return "transport";
|
|
1752
|
+
return issue.code === "conflict" || issue.code === "validation" ? issue.code : "io";
|
|
1753
|
+
}
|
|
1754
|
+
function ProfilesSection(props) {
|
|
1755
|
+
const { t } = props;
|
|
1756
|
+
const state = props.useProfiles((snapshot3) => snapshot3);
|
|
1757
|
+
const prefix = (0, import_react.useId)();
|
|
1758
|
+
const selectRef = (0, import_react.useRef)(null);
|
|
1759
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
1760
|
+
const editorRef = (0, import_react.useRef)(null);
|
|
1761
|
+
const cancelRef = (0, import_react.useRef)(null);
|
|
1762
|
+
const hadConfirmation = (0, import_react.useRef)(false);
|
|
1763
|
+
const disabled = state.busy !== null || state.pendingEditor !== null;
|
|
1764
|
+
const snapshot2 = state.snapshot;
|
|
1765
|
+
const editor = state.editor;
|
|
1766
|
+
const reconcilable = canReconcileSelection(snapshot2);
|
|
1767
|
+
const selectionConflict = reconcilable && snapshot2?.selectionError?.code === "conflict";
|
|
1768
|
+
const invalid = state.issue?.kind === "domain" && state.issue.code === "validation";
|
|
1769
|
+
const idInvalid = invalid && state.issue?.field === "id";
|
|
1770
|
+
(0, import_react.useEffect)(() => {
|
|
1771
|
+
if (state.pendingEditor !== null) {
|
|
1772
|
+
cancelRef.current?.focus();
|
|
1773
|
+
hadConfirmation.current = true;
|
|
1774
|
+
} else if (hadConfirmation.current) {
|
|
1775
|
+
selectRef.current?.focus();
|
|
1776
|
+
hadConfirmation.current = false;
|
|
1777
|
+
}
|
|
1778
|
+
}, [state.pendingEditor]);
|
|
1779
|
+
(0, import_react.useEffect)(() => {
|
|
1780
|
+
if (state.issue?.kind === "domain" && state.issue.code === "validation") {
|
|
1781
|
+
if (state.issue.field === "id") inputRef.current?.focus();
|
|
1782
|
+
else editorRef.current?.focus();
|
|
1783
|
+
}
|
|
1784
|
+
}, [state.issue]);
|
|
1785
|
+
const applied = editor?.revision !== null && editor?.id === snapshot2?.selectedId && editor?.revision === snapshot2?.appliedRevision;
|
|
1786
|
+
let selection = t("baseline");
|
|
1787
|
+
if (snapshot2?.selectionError !== void 0 && !selectionConflict) selection = t("appliedInvalid");
|
|
1788
|
+
else if (snapshot2?.selectedId !== null && snapshot2?.selectedId !== void 0) selection = t("appliedProfile", { id: snapshot2.selectedId, revision: snapshot2.appliedRevision?.slice(0, 12) ?? "—" });
|
|
1789
|
+
const notice = state.notice === null ? "" : t(state.notice.key === "reset" ? "resetDone" : state.notice.key, { id: state.notice.id });
|
|
1790
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dsmm-profiles", "aria-labelledby": `${prefix}-title`, "aria-busy": state.busy !== null, children: [
|
|
1791
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { id: `${prefix}-title`, children: t("title") }),
|
|
1792
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t("description") }),
|
|
1793
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-hint", children: t("newSessions") }),
|
|
1794
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { "data-dsmm-selection": true, children: selection }),
|
|
1795
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-actions", children: [
|
|
1796
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", disabled: disabled || snapshot2 === null, onClick: () => {
|
|
1797
|
+
void props.create();
|
|
1798
|
+
}, children: t("new") }),
|
|
1799
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", disabled, onClick: () => {
|
|
1800
|
+
void props.refresh();
|
|
1801
|
+
}, children: t(state.busy === "refresh" ? "refreshing" : "refresh") }),
|
|
1802
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", disabled: disabled || !reconcilable || snapshot2?.selectedId === null && !selectionConflict, onClick: () => {
|
|
1803
|
+
void props.reset();
|
|
1804
|
+
}, children: t(state.busy === "reset" ? "resetting" : "reset") })
|
|
1805
|
+
] }),
|
|
1806
|
+
snapshot2 !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
1807
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-select`, children: t("editorSelect") }),
|
|
1808
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { ref: selectRef, id: `${prefix}-select`, disabled, value: editor?.revision == null ? "" : editor.id, onChange: (event) => {
|
|
1809
|
+
if (event.currentTarget.value) void props.open(event.currentTarget.value);
|
|
1810
|
+
}, children: [
|
|
1811
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: t(editor?.revision === null ? "newDraft" : "choose") }),
|
|
1812
|
+
snapshot2.profiles.map((profile, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("option", { value: profile.id, children: [
|
|
1813
|
+
profile.label === void 0 ? profile.id : `${profile.label} (${profile.id})`,
|
|
1814
|
+
profile.error === void 0 ? "" : ` — ${t("invalidProfile", { id: profile.id })}`
|
|
1815
|
+
] }, `${index}:${profile.id}`))
|
|
1816
|
+
] }),
|
|
1817
|
+
snapshot2.profiles.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-hint", children: t("empty") })
|
|
1818
|
+
] }),
|
|
1819
|
+
state.pendingEditor !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-confirm", role: "group", "aria-labelledby": `${prefix}-confirm`, onKeyDown: (event) => {
|
|
1820
|
+
if (event.key === "Escape") {
|
|
1821
|
+
event.preventDefault();
|
|
1822
|
+
props.cancelDiscard();
|
|
1823
|
+
}
|
|
1824
|
+
}, children: [
|
|
1825
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { id: `${prefix}-confirm`, children: t("discardPrompt") }),
|
|
1826
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-actions", children: [
|
|
1827
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", onClick: () => {
|
|
1828
|
+
void props.discardAndOpen();
|
|
1829
|
+
}, children: t("discard") }),
|
|
1830
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { ref: cancelRef, type: "button", variant: "primary", onClick: props.cancelDiscard, children: t("cancel") })
|
|
1831
|
+
] })
|
|
1832
|
+
] }),
|
|
1833
|
+
editor !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-editor", children: [
|
|
1834
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
1835
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-id`, children: t("profileId") }),
|
|
1836
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { ref: inputRef, id: `${prefix}-id`, className: "dsmm-input", value: editor.id, disabled: disabled || editor.revision !== null, "aria-invalid": idInvalid || void 0, "aria-describedby": `${prefix}-id-hint${idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editId(event.currentTarget.value) }),
|
|
1837
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })
|
|
1838
|
+
] }),
|
|
1839
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-field", children: [
|
|
1840
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: `${prefix}-content`, children: t("configuration") }),
|
|
1841
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, disabled, "aria-invalid": invalid && !idInvalid || void 0, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }),
|
|
1842
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { id: `${prefix}-content-hint`, className: "dsmm-hint", children: t("configurationHint") }),
|
|
1843
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { id: `${prefix}-structural-hint`, className: "dsmm-hint", children: t("structuralHint") })
|
|
1844
|
+
] }),
|
|
1845
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { "data-dsmm-editor-state": true, children: t(state.dirty ? "dirty" : applied ? "savedApplied" : "savedNotApplied") }),
|
|
1846
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-actions", children: [
|
|
1847
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "primary", disabled: disabled || !state.dirty || snapshot2 === null, onClick: () => {
|
|
1848
|
+
void props.save();
|
|
1849
|
+
}, children: t(state.busy === "save" ? "saving" : "save") }),
|
|
1850
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", disabled: disabled || state.dirty || editor.revision === null || !reconcilable || applied && !selectionConflict, onClick: () => {
|
|
1851
|
+
void props.apply();
|
|
1852
|
+
}, children: t(state.busy === "apply" ? "applying" : "apply") }),
|
|
1853
|
+
editor.revision !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", variant: "outline", disabled, onClick: () => {
|
|
1854
|
+
void props.reload();
|
|
1855
|
+
}, children: t("reload") })
|
|
1856
|
+
] })
|
|
1857
|
+
] }),
|
|
1858
|
+
state.issue !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: [
|
|
1859
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t(issueKey(state.issue)) }),
|
|
1860
|
+
state.issue.kind === "domain" && state.issue.message !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
1861
|
+
t("details"),
|
|
1862
|
+
": ",
|
|
1863
|
+
state.issue.message
|
|
1864
|
+
] })
|
|
1865
|
+
] }),
|
|
1866
|
+
snapshot2?.selectionError !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsmm-issue", children: [
|
|
1867
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
1868
|
+
t("details"),
|
|
1869
|
+
": ",
|
|
1870
|
+
snapshot2.selectionError.message
|
|
1871
|
+
] }),
|
|
1872
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t(selectionConflict ? "selectionConflict" : "retry") })
|
|
1873
|
+
] }),
|
|
1874
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot2 === null ? t("loading") : state.busy === "read" ? t("reading") : notice })
|
|
1875
|
+
] });
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
// src/client/styles.ts
|
|
1879
|
+
var PROFILE_STYLES = `
|
|
1880
|
+
.dsmm-profiles{width:100%;max-width:760px;min-width:0;display:flex;flex-direction:column;gap:12px;font-family:var(--dsw-font-family);font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary)}
|
|
1881
|
+
.dsmm-profiles h2{margin:0;font-size:18px;font-weight:600}
|
|
1882
|
+
.dsmm-profiles p{margin:0;overflow-wrap:anywhere}
|
|
1883
|
+
.dsmm-profiles .dsmm-hint{color:var(--dsw-alias-label-secondary)}
|
|
1884
|
+
.dsmm-profiles .dsmm-field{min-width:0;display:flex;flex-direction:column;gap:6px}
|
|
1885
|
+
.dsmm-profiles .dsmm-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
|
|
1886
|
+
.dsmm-profiles .dsmm-actions>button{max-width:100%;white-space:normal;overflow-wrap:anywhere;min-height:36px;height:auto}
|
|
1887
|
+
.dsmm-profiles .dsmm-input{width:100%;min-width:0;box-sizing:border-box;border-color:var(--dsw-alias-label-secondary)}
|
|
1888
|
+
.dsmm-profiles .dsmm-input input{width:100%;min-width:0;font:inherit;color:inherit}
|
|
1889
|
+
.dsmm-profiles select,.dsmm-profiles textarea{box-sizing:border-box;min-width:0;max-width:100%;font:inherit;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-label-secondary);border-radius:var(--dsw-radius-md)}
|
|
1890
|
+
.dsmm-profiles select{width:240px;height:32px;padding:0 10px;text-overflow:ellipsis}
|
|
1891
|
+
.dsmm-profiles textarea{width:100%;padding:12px;font-family:var(--ds-font-family-code);resize:vertical;overflow:auto;white-space:pre;}
|
|
1892
|
+
.dsmm-profiles select:hover:not(:disabled),.dsmm-profiles textarea:hover:not(:disabled){border-color:var(--dsw-alias-label-primary)}
|
|
1893
|
+
.dsmm-profiles select:active:not(:disabled){background:var(--dsw-alias-interactive-bg-active)}
|
|
1894
|
+
.dsmm-profiles :is(select,textarea,button):focus-visible,.dsmm-profiles .dsmm-input:has(input:focus-visible){outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
|
|
1895
|
+
.dsmm-profiles :is(select,textarea):disabled{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-module-platform);cursor:not-allowed}
|
|
1896
|
+
.dsmm-profiles .dsmm-editor,.dsmm-profiles .dsmm-confirm{min-width:0;display:flex;flex-direction:column;gap:12px;padding:16px;border:1px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-module-platform)}
|
|
1897
|
+
.dsmm-profiles .dsmm-issue{padding:12px;border-left:4px solid var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary);overflow-wrap:anywhere}
|
|
1898
|
+
.dsmm-profiles .dsmm-issue p+p{margin-top:8px}
|
|
1899
|
+
.dsmm-profiles .dsmm-status{min-height:22px}
|
|
1900
|
+
@media(prefers-reduced-motion:reduce){.dsmm-profiles *{transition:none!important;animation:none!important}}
|
|
1901
|
+
`;
|
|
1902
|
+
|
|
1903
|
+
// src/client/index.ts
|
|
1904
|
+
var inject = ["slots", "locale", "remote"];
|
|
1905
|
+
async function apply(ctx) {
|
|
1906
|
+
await ctx.remote.$mount(TYPERT_REMOTE);
|
|
1907
|
+
await ctx.inject(["remote.dsmmProfiles"], (profileCtx) => {
|
|
1908
|
+
const controller = new ProfilesController(profileCtx.remote.dsmmProfiles);
|
|
1909
|
+
profileCtx.effect(() => () => controller.dispose(), "dsmm: profile editor");
|
|
1910
|
+
profileCtx.effect(() => profileCtx.locale.register(NS, { en, zh }), "dsmm: profile locale");
|
|
1911
|
+
profileCtx.effect(() => {
|
|
1912
|
+
const style = document.createElement("style");
|
|
1913
|
+
style.dataset.dsmmProfiles = "";
|
|
1914
|
+
style.textContent = PROFILE_STYLES;
|
|
1915
|
+
document.head.append(style);
|
|
1916
|
+
return () => style.remove();
|
|
1917
|
+
}, "dsmm: profile styles");
|
|
1918
|
+
const t = profileCtx.locale.bind(NS);
|
|
1919
|
+
profileCtx.slots.inject("settings.section", () => profileCtx.slots.register({
|
|
1920
|
+
name: "settings.section",
|
|
1921
|
+
id: "dsmm-profiles",
|
|
1922
|
+
order: 30,
|
|
1923
|
+
label: () => t("title"),
|
|
1924
|
+
locale: NS,
|
|
1925
|
+
inject: () => ({ hooks: { profiles: controller.store }, ...controller.actions })
|
|
1926
|
+
}, ProfilesSection));
|
|
1927
|
+
void controller.refresh();
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
return module.exports; } });
|