@omercnet/paseo-shared-browser 4.1.9 → 4.1.10-next.471.1
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.
|
@@ -111,3 +111,117 @@ describe("web canvas keyboard adapter cancellation", () => {
|
|
|
111
111
|
expect(dom.events).toHaveLength(1);
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
|
+
|
|
115
|
+
/** Android Chrome reports soft-keyboard edits as keydown 229 / "Unidentified". */
|
|
116
|
+
const ime = { ...key, key: "Unidentified", code: "", keyCode: 229 };
|
|
117
|
+
const texts = (dom: ReturnType<typeof bind>) =>
|
|
118
|
+
dom.events.flatMap((event) => (event.kind === "text" ? [event.text] : []));
|
|
119
|
+
|
|
120
|
+
/** Gboard-style composition of one word, ending with compositionend. */
|
|
121
|
+
function composeWord(dom: ReturnType<typeof bind>, word: string) {
|
|
122
|
+
dom.fire("sink", "keydown", ime);
|
|
123
|
+
dom.fire("sink", "compositionstart", { data: "" });
|
|
124
|
+
for (let index = 1; index <= word.length; index += 1) {
|
|
125
|
+
if (index > 1) dom.fire("sink", "keydown", { ...ime, isComposing: true });
|
|
126
|
+
dom.fire("sink", "beforeinput", {
|
|
127
|
+
inputType: "insertCompositionText",
|
|
128
|
+
data: word.slice(0, index),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
dom.fire("sink", "compositionend", { data: word });
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
describe("web canvas keyboard adapter Android IME sequences", () => {
|
|
135
|
+
it("commits a composed word exactly once", () => {
|
|
136
|
+
const dom = bind();
|
|
137
|
+
composeWord(dom, "hello");
|
|
138
|
+
expect(texts(dom)).toEqual(["hello"]);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("commits text an IME inserts outside a composition (space after a word)", () => {
|
|
142
|
+
const dom = bind();
|
|
143
|
+
composeWord(dom, "hello");
|
|
144
|
+
dom.fire("sink", "keydown", ime);
|
|
145
|
+
dom.fire("sink", "beforeinput", { inputType: "insertText", data: " " });
|
|
146
|
+
composeWord(dom, "world");
|
|
147
|
+
expect(texts(dom).join("")).toBe("hello world");
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("commits insertText that shares the composing keydown of a batched IME edit", () => {
|
|
151
|
+
const dom = bind();
|
|
152
|
+
dom.fire("sink", "keydown", ime);
|
|
153
|
+
dom.fire("sink", "compositionstart", { data: "" });
|
|
154
|
+
dom.fire("sink", "beforeinput", { inputType: "insertCompositionText", data: "hi" });
|
|
155
|
+
dom.fire("sink", "keydown", { ...ime, isComposing: true });
|
|
156
|
+
dom.fire("sink", "compositionend", { data: "hi" });
|
|
157
|
+
dom.fire("sink", "beforeinput", { inputType: "insertText", data: "." });
|
|
158
|
+
expect(texts(dom)).toEqual(["hi", "."]);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("commits keyboards that send every character as insertText without composition", () => {
|
|
162
|
+
const dom = bind();
|
|
163
|
+
for (const character of "abc123") {
|
|
164
|
+
dom.fire("sink", "keydown", ime);
|
|
165
|
+
dom.fire("sink", "beforeinput", { inputType: "insertText", data: character });
|
|
166
|
+
}
|
|
167
|
+
expect(texts(dom).join("")).toBe("abc123");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("keeps only the final composition after deleteContentBackward and IME correction", () => {
|
|
171
|
+
const dom = bind();
|
|
172
|
+
dom.fire("sink", "keydown", ime);
|
|
173
|
+
dom.fire("sink", "compositionstart", { data: "" });
|
|
174
|
+
dom.fire("sink", "beforeinput", { inputType: "insertCompositionText", data: "teh" });
|
|
175
|
+
dom.fire("sink", "beforeinput", { inputType: "deleteContentBackward", data: null });
|
|
176
|
+
dom.fire("sink", "beforeinput", { inputType: "insertCompositionText", data: "the" });
|
|
177
|
+
dom.fire("sink", "compositionend", { data: "the" });
|
|
178
|
+
expect(texts(dom)).toEqual(["the"]);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("commits Korean syllable compositions exactly once", () => {
|
|
182
|
+
const dom = bind();
|
|
183
|
+
composeWord(dom, "한");
|
|
184
|
+
composeWord(dom, "글");
|
|
185
|
+
expect(texts(dom).join("")).toBe("한글");
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("does not commit insertText after a physical key the adapter consumed or blocked", () => {
|
|
189
|
+
const dom = bind();
|
|
190
|
+
dom.fire("sink", "keydown", key);
|
|
191
|
+
dom.binding.reset();
|
|
192
|
+
// A held key blocked by reset reaches the browser default insertion.
|
|
193
|
+
dom.fire("sink", "keydown", { ...key, repeat: true });
|
|
194
|
+
dom.fire("sink", "beforeinput", { inputType: "insertText", data: "a" });
|
|
195
|
+
// A non-IME keydown also disarms an earlier IME edge.
|
|
196
|
+
dom.fire("sink", "keydown", ime);
|
|
197
|
+
dom.fire("sink", "keydown", { ...key, repeat: true });
|
|
198
|
+
dom.fire("sink", "beforeinput", { inputType: "insertText", data: "a" });
|
|
199
|
+
expect(texts(dom)).toEqual([]);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("drops IME insertText once reset or not in control", () => {
|
|
203
|
+
const dom = bind();
|
|
204
|
+
dom.fire("sink", "keydown", ime);
|
|
205
|
+
dom.binding.reset();
|
|
206
|
+
dom.fire("sink", "beforeinput", { inputType: "insertText", data: "x" });
|
|
207
|
+
expect(texts(dom)).toEqual([]);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it("commits every insertText of one IME keydown until the next keydown", () => {
|
|
211
|
+
const dom = bind();
|
|
212
|
+
dom.fire("sink", "keydown", ime);
|
|
213
|
+
dom.fire("sink", "beforeinput", { inputType: "insertText", data: "a" });
|
|
214
|
+
dom.fire("sink", "beforeinput", { inputType: "insertText", data: "b" });
|
|
215
|
+
expect(texts(dom)).toEqual(["a", "b"]);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it.each([
|
|
219
|
+
["Unidentified", { ...key, key: "Unidentified", code: "" }],
|
|
220
|
+
["Process", { ...key, key: "Process", code: "" }],
|
|
221
|
+
])("treats a %s keydown without keyCode 229 as an IME edge", (_name, edge) => {
|
|
222
|
+
const dom = bind();
|
|
223
|
+
dom.fire("sink", "keydown", edge);
|
|
224
|
+
dom.fire("sink", "beforeinput", { inputType: "insertText", data: "x" });
|
|
225
|
+
expect(texts(dom)).toEqual(["x"]);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
@@ -83,6 +83,11 @@ export function bindBrowserCanvasKeyboard(node: KeyboardCanvasNode, options: Bin
|
|
|
83
83
|
let composing = false;
|
|
84
84
|
let compositionAdmitted = false;
|
|
85
85
|
let altTextPending: string | null = null;
|
|
86
|
+
// Soft keyboards (Android Chrome) report committed text outside a composition,
|
|
87
|
+
// such as a space after a word or every key on non-predictive keyboards, as
|
|
88
|
+
// keydown 229/"Unidentified" followed by beforeinput insertText. That keydown
|
|
89
|
+
// carries no key to forward, so the insertion itself is the only text source.
|
|
90
|
+
let imeTextPending = false;
|
|
86
91
|
const focused = () => document.activeElement === sink || document.activeElement === node;
|
|
87
92
|
const keyboard = createBrowserCanvasKeyboard({
|
|
88
93
|
...options,
|
|
@@ -97,6 +102,7 @@ export function bindBrowserCanvasKeyboard(node: KeyboardCanvasNode, options: Bin
|
|
|
97
102
|
compositionAdmitted = false;
|
|
98
103
|
composing = false;
|
|
99
104
|
altTextPending = null;
|
|
105
|
+
imeTextPending = false;
|
|
100
106
|
sink.value = "";
|
|
101
107
|
};
|
|
102
108
|
const cancel = () => {
|
|
@@ -112,6 +118,8 @@ export function bindBrowserCanvasKeyboard(node: KeyboardCanvasNode, options: Bin
|
|
|
112
118
|
if (!focused()) {
|
|
113
119
|
return;
|
|
114
120
|
}
|
|
121
|
+
imeTextPending =
|
|
122
|
+
event.keyCode === 229 || event.key === "Process" || event.key === "Unidentified";
|
|
115
123
|
// Local paste supplies clipboard bytes separately. Sending Ctrl/Meta+V would
|
|
116
124
|
// additionally paste an unrelated remote clipboard and duplicate the action.
|
|
117
125
|
const pasteShortcut =
|
|
@@ -174,7 +182,11 @@ export function bindBrowserCanvasKeyboard(node: KeyboardCanvasNode, options: Bin
|
|
|
174
182
|
const beforeInput = (event: KeyboardDomEvent) => {
|
|
175
183
|
if (!composing && options.enabled() && focused()) {
|
|
176
184
|
consume(event);
|
|
177
|
-
if (
|
|
185
|
+
if (
|
|
186
|
+
event.inputType === "insertText" &&
|
|
187
|
+
event.data &&
|
|
188
|
+
(imeTextPending || event.data === altTextPending)
|
|
189
|
+
) {
|
|
178
190
|
commitText(event.data);
|
|
179
191
|
}
|
|
180
192
|
altTextPending = null;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omercnet/paseo-shared-browser",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.10",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@omercnet/paseo-shared-browser",
|
|
9
|
-
"version": "4.1.
|
|
9
|
+
"version": "4.1.10",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@getpaseo/plugin": "0.16.0-beta.1",
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.2",
|
package/package.json
CHANGED