@inflatable-cookie/longhorn 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/package.json +205 -0
- package/src/agent-control/index.ts +20 -0
- package/src/agent-control/inject.ts +4 -0
- package/src/agent-control/shim.ts +722 -0
- package/src/bridge/direct.ts +22 -0
- package/src/bridge/generated/fields.ts +32 -0
- package/src/bridge/generated/protocol.ts +218 -0
- package/src/bridge/generated/variant-fields.ts +10 -0
- package/src/bridge/index.ts +15 -0
- package/src/bridge/job.ts +51 -0
- package/src/bridge/loopback.ts +84 -0
- package/src/bridge/operation.ts +166 -0
- package/src/bridge/router.ts +71 -0
- package/src/bridge/runtime/connection.ts +318 -0
- package/src/bridge/runtime/policy.ts +89 -0
- package/src/bridge/runtime/retry.ts +60 -0
- package/src/bridge/runtime.ts +3 -0
- package/src/bridge/session.ts +67 -0
- package/src/bridge/stream/connection.ts +146 -0
- package/src/bridge/stream/source.ts +61 -0
- package/src/bridge/stream/tracker.ts +109 -0
- package/src/bridge/stream.ts +6 -0
- package/src/bridge/supervision.ts +204 -0
- package/src/bridge/validation/base.ts +164 -0
- package/src/bridge/validation/jobs.ts +105 -0
- package/src/bridge/validation/negotiation.ts +242 -0
- package/src/bridge/validation/operations.ts +213 -0
- package/src/bridge/validation/streams.ts +47 -0
- package/src/bridge/validation.ts +5 -0
- package/src/commands/client.ts +124 -0
- package/src/commands/controller.ts +411 -0
- package/src/commands/generated/fields.ts +43 -0
- package/src/commands/generated/protocol.ts +876 -0
- package/src/commands/generated/variant-fields.ts +88 -0
- package/src/commands/index.ts +13 -0
- package/src/commands/keyboard.ts +361 -0
- package/src/commands/ports.ts +82 -0
- package/src/commands/projectors.ts +306 -0
- package/src/commands/validation.ts +444 -0
- package/src/config/client.ts +215 -0
- package/src/config/generated/base.ts +714 -0
- package/src/config/generated/fields.ts +54 -0
- package/src/config/generated/label-template.ts +14 -0
- package/src/config/generated/labels.ts +30 -0
- package/src/config/generated/protocol.ts +3 -0
- package/src/config/generated/restore.ts +658 -0
- package/src/config/generated/variant-fields.ts +129 -0
- package/src/config/index.ts +12 -0
- package/src/config/names.ts +19 -0
- package/src/config/validation/commands.ts +155 -0
- package/src/config/validation/outcomes.ts +243 -0
- package/src/config/validation/primitives.ts +174 -0
- package/src/config/validation/projection.ts +351 -0
- package/src/config/validation.ts +7 -0
- package/src/core/connection.ts +252 -0
- package/src/core/index.ts +2 -0
- package/src/core/transport.ts +24 -0
- package/src/history/client.ts +65 -0
- package/src/history/controller.ts +385 -0
- package/src/history/direct.ts +21 -0
- package/src/history/generated/fields.ts +18 -0
- package/src/history/generated/protocol.ts +389 -0
- package/src/history/generated/variant-fields.ts +27 -0
- package/src/history/index.ts +13 -0
- package/src/history/ports.ts +31 -0
- package/src/history/serialized.ts +38 -0
- package/src/history/validation.ts +334 -0
- package/src/history-tree/client.ts +16 -0
- package/src/history-tree/controller.ts +199 -0
- package/src/history-tree/direct.ts +3 -0
- package/src/history-tree/generated/fields.ts +26 -0
- package/src/history-tree/generated/protocol.ts +711 -0
- package/src/history-tree/generated/variant-fields.ts +39 -0
- package/src/history-tree/index.ts +13 -0
- package/src/history-tree/ports.ts +43 -0
- package/src/history-tree/serialized.ts +15 -0
- package/src/history-tree/validation.ts +269 -0
- package/src/layout/generated/protocol.ts +289 -0
- package/src/layout/index.ts +4 -0
- package/src/layout/ratio.ts +22 -0
- package/src/layout/validation.ts +110 -0
- package/src/layout/visibility.ts +30 -0
- package/src/licence/client.ts +32 -0
- package/src/licence/controller.ts +301 -0
- package/src/licence/direct.ts +3 -0
- package/src/licence/generated/fields.ts +17 -0
- package/src/licence/generated/key-conformance.json +42 -0
- package/src/licence/generated/protocol.ts +249 -0
- package/src/licence/generated/variant-fields.ts +34 -0
- package/src/licence/index.ts +14 -0
- package/src/licence/key.ts +125 -0
- package/src/licence/ports.ts +39 -0
- package/src/licence/serialized.ts +13 -0
- package/src/licence/validation.ts +226 -0
- package/src/native-content/client.ts +474 -0
- package/src/native-content/direct.ts +16 -0
- package/src/native-content/generated/fields.ts +32 -0
- package/src/native-content/generated/protocol.ts +498 -0
- package/src/native-content/generated/variant-fields.ts +77 -0
- package/src/native-content/index.ts +12 -0
- package/src/native-content/ports.ts +46 -0
- package/src/native-content/serialized.ts +50 -0
- package/src/native-content/validation/base.ts +194 -0
- package/src/native-content/validation/messages.ts +192 -0
- package/src/native-content/validation/state.ts +404 -0
- package/src/native-content/validation.ts +7 -0
- package/src/notifications/client.ts +106 -0
- package/src/notifications/controller.ts +240 -0
- package/src/notifications/direct.ts +12 -0
- package/src/notifications/generated/fields.ts +19 -0
- package/src/notifications/generated/labels.ts +20 -0
- package/src/notifications/generated/protocol.ts +522 -0
- package/src/notifications/generated/variant-fields.ts +37 -0
- package/src/notifications/index.ts +16 -0
- package/src/notifications/ports.ts +22 -0
- package/src/notifications/serialized.ts +27 -0
- package/src/notifications/toast.ts +41 -0
- package/src/notifications/tone.ts +27 -0
- package/src/notifications/validation.ts +246 -0
- package/src/operation/bridge.ts +168 -0
- package/src/operation/client.ts +167 -0
- package/src/operation/controller.ts +321 -0
- package/src/operation/direct.ts +15 -0
- package/src/operation/generated/fields.ts +20 -0
- package/src/operation/generated/labels.ts +15 -0
- package/src/operation/generated/protocol.ts +762 -0
- package/src/operation/generated/variant-fields.ts +60 -0
- package/src/operation/index.ts +14 -0
- package/src/operation/ports.ts +29 -0
- package/src/operation/serialized.ts +39 -0
- package/src/operation/validation.ts +479 -0
- package/src/settings/client.ts +142 -0
- package/src/settings/connection.ts +246 -0
- package/src/settings/generated/fields.ts +34 -0
- package/src/settings/generated/protocol.ts +668 -0
- package/src/settings/generated/variant-fields.ts +26 -0
- package/src/settings/index.ts +12 -0
- package/src/settings/names.ts +8 -0
- package/src/settings/registry.ts +141 -0
- package/src/settings/validation/authority.ts +66 -0
- package/src/settings/validation/command.ts +165 -0
- package/src/settings/validation/error.ts +33 -0
- package/src/settings/validation/primitives.ts +203 -0
- package/src/settings/validation/projection.ts +50 -0
- package/src/settings/validation/registry.ts +170 -0
- package/src/settings/validation.ts +4 -0
- package/src/surface-transfer/client.ts +54 -0
- package/src/surface-transfer/generated/fields.ts +12 -0
- package/src/surface-transfer/generated/protocol.ts +61 -0
- package/src/surface-transfer/generated/variant-fields.ts +30 -0
- package/src/surface-transfer/index.ts +9 -0
- package/src/surface-transfer/validation.ts +209 -0
- package/src/surfaces/client.ts +140 -0
- package/src/surfaces/generated/fields.ts +19 -0
- package/src/surfaces/generated/protocol.ts +217 -0
- package/src/surfaces/generated/variant-fields.ts +42 -0
- package/src/surfaces/index.ts +9 -0
- package/src/surfaces/validation.ts +199 -0
- package/src/transfer/client.ts +133 -0
- package/src/transfer/connection.ts +87 -0
- package/src/transfer/generated/fields.ts +23 -0
- package/src/transfer/generated/protocol.ts +171 -0
- package/src/transfer/generated/variant-fields.ts +45 -0
- package/src/transfer/index.ts +11 -0
- package/src/transfer/payload.ts +71 -0
- package/src/transfer/validation.ts +282 -0
- package/src/update/client.ts +29 -0
- package/src/update/controller.ts +255 -0
- package/src/update/direct.ts +3 -0
- package/src/update/generated/fields.ts +14 -0
- package/src/update/generated/protocol.ts +238 -0
- package/src/update/generated/variant-fields.ts +44 -0
- package/src/update/index.ts +14 -0
- package/src/update/ports.ts +36 -0
- package/src/update/serialized.ts +12 -0
- package/src/update/validation.ts +191 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CommandAvailability,
|
|
3
|
+
CommandAvailabilitySnapshot,
|
|
4
|
+
CommandCatalogueSnapshot,
|
|
5
|
+
CommandDiscoveryRecord,
|
|
6
|
+
CommandEffectiveBinding,
|
|
7
|
+
CommandId,
|
|
8
|
+
CommandKeyChord,
|
|
9
|
+
CommandKeymapConflict,
|
|
10
|
+
CommandKeymapSnapshot,
|
|
11
|
+
CommandPlatform,
|
|
12
|
+
CommandSearchHit,
|
|
13
|
+
CommandShortcutRecord,
|
|
14
|
+
} from "./generated/protocol.ts";
|
|
15
|
+
|
|
16
|
+
export interface CommandJoinedState {
|
|
17
|
+
readonly catalogue: CommandCatalogueSnapshot;
|
|
18
|
+
readonly keymap: CommandKeymapSnapshot;
|
|
19
|
+
readonly availability: CommandAvailabilitySnapshot;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CommandProjectionRecord {
|
|
23
|
+
readonly id: CommandId;
|
|
24
|
+
readonly label: string;
|
|
25
|
+
readonly description: string | null;
|
|
26
|
+
readonly categoryPath: readonly string[];
|
|
27
|
+
readonly keywords: readonly string[];
|
|
28
|
+
readonly icon: string | null;
|
|
29
|
+
readonly availability: CommandAvailability;
|
|
30
|
+
readonly shortcuts: readonly CommandShortcutRecord[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CommandSettingsRecord extends CommandProjectionRecord {
|
|
34
|
+
readonly bindings: readonly CommandEffectiveBinding[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CommandSurfaceProjection {
|
|
38
|
+
readonly palette: readonly CommandProjectionRecord[];
|
|
39
|
+
readonly menu: readonly CommandProjectionRecord[];
|
|
40
|
+
readonly help: readonly CommandProjectionRecord[];
|
|
41
|
+
readonly settings: readonly CommandSettingsRecord[];
|
|
42
|
+
readonly shortcuts: readonly CommandShortcutRecord[];
|
|
43
|
+
readonly reverseLookup: ReadonlyMap<CommandId, readonly CommandShortcutRecord[]>;
|
|
44
|
+
readonly conflicts: readonly CommandKeymapConflict[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const AVAILABLE: CommandAvailability = {
|
|
48
|
+
state: "available",
|
|
49
|
+
reason: null,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export function joinCommandState(
|
|
53
|
+
catalogue: CommandCatalogueSnapshot,
|
|
54
|
+
keymap: CommandKeymapSnapshot,
|
|
55
|
+
availability: CommandAvailabilitySnapshot,
|
|
56
|
+
): CommandJoinedState {
|
|
57
|
+
if (
|
|
58
|
+
keymap.registryGeneration !== catalogue.registryGeneration ||
|
|
59
|
+
availability.registryGeneration !== catalogue.registryGeneration
|
|
60
|
+
) {
|
|
61
|
+
throw new CommandProjectionConsistencyError(
|
|
62
|
+
"catalogue, keymap, and availability generations differ",
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (keymap.registryDigest !== catalogue.registryDigest) {
|
|
66
|
+
throw new CommandProjectionConsistencyError(
|
|
67
|
+
"catalogue and keymap registry digests differ",
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const known = new Set(catalogue.commands.map(({ id }) => id));
|
|
71
|
+
const records = new Set<string>();
|
|
72
|
+
for (const record of availability.records) {
|
|
73
|
+
if (!known.has(record.commandId) || records.has(record.commandId)) {
|
|
74
|
+
throw new CommandProjectionConsistencyError(
|
|
75
|
+
`availability has unknown or duplicate command ${record.commandId}`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
records.add(record.commandId);
|
|
79
|
+
}
|
|
80
|
+
if (records.size !== known.size) {
|
|
81
|
+
throw new CommandProjectionConsistencyError(
|
|
82
|
+
"availability is not complete for the sealed catalogue",
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return { catalogue, keymap, availability };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function projectCommandSurfaces(
|
|
89
|
+
state: CommandJoinedState,
|
|
90
|
+
platform: CommandPlatform,
|
|
91
|
+
): CommandSurfaceProjection {
|
|
92
|
+
const availability = new Map(
|
|
93
|
+
state.availability.records.map((record) => [
|
|
94
|
+
record.commandId,
|
|
95
|
+
record.availability,
|
|
96
|
+
]),
|
|
97
|
+
);
|
|
98
|
+
const reverseLookup = new Map<CommandId, readonly CommandShortcutRecord[]>();
|
|
99
|
+
const shortcuts: CommandShortcutRecord[] = [];
|
|
100
|
+
for (const command of state.catalogue.commands) {
|
|
101
|
+
const records = shortcutsForCommand(state.keymap, command.id, platform);
|
|
102
|
+
reverseLookup.set(command.id, records);
|
|
103
|
+
shortcuts.push(...records);
|
|
104
|
+
}
|
|
105
|
+
const project = (record: CommandDiscoveryRecord): CommandProjectionRecord => ({
|
|
106
|
+
id: record.id,
|
|
107
|
+
label: record.label,
|
|
108
|
+
description: record.description,
|
|
109
|
+
categoryPath: record.categoryPath,
|
|
110
|
+
keywords: record.keywords,
|
|
111
|
+
icon: record.icon,
|
|
112
|
+
availability: availability.get(record.id) ?? AVAILABLE,
|
|
113
|
+
shortcuts: reverseLookup.get(record.id) ?? [],
|
|
114
|
+
});
|
|
115
|
+
const visible = state.catalogue.commands.filter(
|
|
116
|
+
({ visibility }) => !visibility.hidden,
|
|
117
|
+
);
|
|
118
|
+
return {
|
|
119
|
+
palette: visible
|
|
120
|
+
.filter(({ visibility }) => visibility.palette)
|
|
121
|
+
.map(project)
|
|
122
|
+
.filter(({ availability }) => availability.state !== "hidden"),
|
|
123
|
+
menu: visible
|
|
124
|
+
.filter(({ visibility }) => visibility.menu)
|
|
125
|
+
.map(project)
|
|
126
|
+
.filter(({ availability }) => availability.state !== "hidden"),
|
|
127
|
+
help: visible
|
|
128
|
+
.filter(({ visibility }) => visibility.help)
|
|
129
|
+
.map(project)
|
|
130
|
+
.filter(({ availability }) => availability.state !== "hidden"),
|
|
131
|
+
settings: visible
|
|
132
|
+
.filter(({ visibility }) => visibility.settings)
|
|
133
|
+
.map((record) => ({
|
|
134
|
+
...project(record),
|
|
135
|
+
bindings: state.keymap.bindings.filter(
|
|
136
|
+
({ invocation }) => invocation.commandId === record.id,
|
|
137
|
+
),
|
|
138
|
+
})),
|
|
139
|
+
shortcuts,
|
|
140
|
+
reverseLookup,
|
|
141
|
+
conflicts: state.keymap.conflicts,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function searchCommands(
|
|
146
|
+
records: readonly CommandDiscoveryRecord[],
|
|
147
|
+
query: string,
|
|
148
|
+
): readonly CommandSearchHit[] {
|
|
149
|
+
const terms = query.split(/\s+/u).filter(Boolean).map((term) => term.toLowerCase());
|
|
150
|
+
return records
|
|
151
|
+
.flatMap((record) => {
|
|
152
|
+
const score = scoreRecord(record, terms);
|
|
153
|
+
return score === undefined ? [] : [{ record, score }];
|
|
154
|
+
})
|
|
155
|
+
.sort(
|
|
156
|
+
(left, right) =>
|
|
157
|
+
left.score - right.score ||
|
|
158
|
+
compareUnicodeScalars(
|
|
159
|
+
left.record.label.toLowerCase(),
|
|
160
|
+
right.record.label.toLowerCase(),
|
|
161
|
+
) ||
|
|
162
|
+
compareUnicodeScalars(left.record.id, right.record.id),
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function shortcutsForCommand(
|
|
167
|
+
keymap: CommandKeymapSnapshot,
|
|
168
|
+
commandId: CommandId,
|
|
169
|
+
platform: CommandPlatform,
|
|
170
|
+
): readonly CommandShortcutRecord[] {
|
|
171
|
+
return keymap.bindings
|
|
172
|
+
.filter(
|
|
173
|
+
(binding) =>
|
|
174
|
+
binding.invocation.commandId === commandId &&
|
|
175
|
+
includesPlatform(binding.platform, platform),
|
|
176
|
+
)
|
|
177
|
+
.map((binding) => {
|
|
178
|
+
const chord = resolveTrigger(binding, platform);
|
|
179
|
+
return {
|
|
180
|
+
bindingId: binding.id,
|
|
181
|
+
source: binding.source,
|
|
182
|
+
contextId: binding.contextId,
|
|
183
|
+
chord,
|
|
184
|
+
label: shortcutLabel(chord, platform),
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function shortcutLabel(
|
|
190
|
+
chord: CommandKeyChord,
|
|
191
|
+
platform: CommandPlatform,
|
|
192
|
+
): string {
|
|
193
|
+
const key = keyLabel(chord.code);
|
|
194
|
+
if (platform === "macOs") {
|
|
195
|
+
return [
|
|
196
|
+
chord.modifiers.control ? "⌃" : "",
|
|
197
|
+
chord.modifiers.alt ? "⌥" : "",
|
|
198
|
+
chord.modifiers.shift ? "⇧" : "",
|
|
199
|
+
chord.modifiers.meta ? "⌘" : "",
|
|
200
|
+
key,
|
|
201
|
+
].join("");
|
|
202
|
+
}
|
|
203
|
+
return [
|
|
204
|
+
chord.modifiers.control ? "Ctrl" : undefined,
|
|
205
|
+
chord.modifiers.alt ? "Alt" : undefined,
|
|
206
|
+
chord.modifiers.shift ? "Shift" : undefined,
|
|
207
|
+
chord.modifiers.meta ? "Meta" : undefined,
|
|
208
|
+
key,
|
|
209
|
+
]
|
|
210
|
+
.filter((part): part is string => part !== undefined)
|
|
211
|
+
.join("+");
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export class CommandProjectionConsistencyError extends Error {
|
|
215
|
+
constructor(message: string) {
|
|
216
|
+
super(message);
|
|
217
|
+
this.name = "CommandProjectionConsistencyError";
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function scoreRecord(
|
|
222
|
+
record: CommandDiscoveryRecord,
|
|
223
|
+
terms: readonly string[],
|
|
224
|
+
): number | undefined {
|
|
225
|
+
if (terms.length === 0) return 0;
|
|
226
|
+
const label = record.label.toLowerCase();
|
|
227
|
+
const description = record.description?.toLowerCase() ?? "";
|
|
228
|
+
const keywords = record.keywords.map((keyword) => keyword.toLowerCase());
|
|
229
|
+
let score = 0;
|
|
230
|
+
for (const term of terms) {
|
|
231
|
+
const termScore =
|
|
232
|
+
label === term
|
|
233
|
+
? 0
|
|
234
|
+
: label.startsWith(term)
|
|
235
|
+
? 10
|
|
236
|
+
: label.includes(term)
|
|
237
|
+
? 20
|
|
238
|
+
: keywords.some((keyword) => keyword === term)
|
|
239
|
+
? 30
|
|
240
|
+
: keywords.some((keyword) => keyword.startsWith(term))
|
|
241
|
+
? 40
|
|
242
|
+
: keywords.some((keyword) => keyword.includes(term))
|
|
243
|
+
? 50
|
|
244
|
+
: record.categoryPath.some((category) => category.includes(term))
|
|
245
|
+
? 60
|
|
246
|
+
: record.id.includes(term)
|
|
247
|
+
? 70
|
|
248
|
+
: description.includes(term)
|
|
249
|
+
? 80
|
|
250
|
+
: undefined;
|
|
251
|
+
if (termScore === undefined) return undefined;
|
|
252
|
+
score = Math.min(0xffff_ffff, score + termScore);
|
|
253
|
+
}
|
|
254
|
+
return score;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function includesPlatform(
|
|
258
|
+
scope: CommandEffectiveBinding["platform"],
|
|
259
|
+
platform: CommandPlatform,
|
|
260
|
+
): boolean {
|
|
261
|
+
return scope === "any" || scope === platform;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function resolveTrigger(
|
|
265
|
+
binding: CommandEffectiveBinding,
|
|
266
|
+
platform: CommandPlatform,
|
|
267
|
+
): CommandKeyChord {
|
|
268
|
+
const { modifiers } = binding.trigger;
|
|
269
|
+
return {
|
|
270
|
+
code: binding.trigger.code,
|
|
271
|
+
modifiers: {
|
|
272
|
+
control:
|
|
273
|
+
modifiers.control ||
|
|
274
|
+
(modifiers.primary && (platform === "windows" || platform === "linux")),
|
|
275
|
+
alt: modifiers.alt,
|
|
276
|
+
shift: modifiers.shift,
|
|
277
|
+
meta: modifiers.meta || (modifiers.primary && platform === "macOs"),
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function keyLabel(code: string): string {
|
|
283
|
+
if (code.length === 4 && code.startsWith("Key")) return code.slice(3);
|
|
284
|
+
if (code.length === 6 && code.startsWith("Digit")) return code.slice(5);
|
|
285
|
+
return (
|
|
286
|
+
{
|
|
287
|
+
ArrowUp: "↑",
|
|
288
|
+
ArrowDown: "↓",
|
|
289
|
+
ArrowLeft: "←",
|
|
290
|
+
ArrowRight: "→",
|
|
291
|
+
Escape: "Esc",
|
|
292
|
+
}[code] ?? code
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function compareUnicodeScalars(left: string, right: string): number {
|
|
297
|
+
const leftValues = [...left];
|
|
298
|
+
const rightValues = [...right];
|
|
299
|
+
const length = Math.min(leftValues.length, rightValues.length);
|
|
300
|
+
for (let index = 0; index < length; index += 1) {
|
|
301
|
+
const leftCode = leftValues[index]!.codePointAt(0)!;
|
|
302
|
+
const rightCode = rightValues[index]!.codePointAt(0)!;
|
|
303
|
+
if (leftCode !== rightCode) return leftCode - rightCode;
|
|
304
|
+
}
|
|
305
|
+
return leftValues.length - rightValues.length;
|
|
306
|
+
}
|