@atlaskit/editor-plugin-autocomplete 2.5.1 → 2.5.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-autocomplete
2
2
 
3
+ ## 2.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`a87ba03d22d27`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a87ba03d22d27) -
8
+ Fix typecheck
9
+ - Updated dependencies
10
+
3
11
  ## 2.5.1
4
12
 
5
13
  ### Patch Changes
@@ -45,11 +45,6 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
45
45
  * The client exposes getContextVector() and getLmLogits() which are populated
46
46
  * asynchronously after each updateContext() call.
47
47
  */
48
- var startsWithAsciiLetter = function startsWithAsciiLetter(value) {
49
- var firstChar = value.charCodeAt(0);
50
- return firstChar >= 65 && firstChar <= 90 || firstChar >= 97 && firstChar <= 122;
51
- };
52
-
53
48
  // ─── Types ───────────────────────────────────────────────────────────────────
54
49
 
55
50
  // Same return type as createSlowLaneClient for drop-in compatibility
@@ -275,8 +270,8 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
275
270
  if (logprobsContent && logprobsContent.length > 0) {
276
271
  tokenLogprobs = logprobsContent[0]; // Add the top token
277
272
  if (tokenLogprobs.token) {
278
- token = tokenLogprobs.token.trim().toLowerCase();
279
- if (token.length > 0 && startsWithAsciiLetter(token)) {
273
+ token = tokenLogprobs.token.trim().toLowerCase(); // @ts-ignore TS1501: Unicode regex flag requires a newer TS target than the declaration build uses.
274
+ if (token.length > 0 && /^[a-z\u017F\u212A]/i.test(token)) {
280
275
  lmLogits[token] = Math.exp(tokenLogprobs.logprob);
281
276
  }
282
277
  }
@@ -287,8 +282,8 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
287
282
  try {
288
283
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
289
284
  alt = _step.value;
290
- _token = alt.token.trim().toLowerCase();
291
- if (_token.length > 0 && startsWithAsciiLetter(_token)) {
285
+ _token = alt.token.trim().toLowerCase(); // @ts-ignore TS1501: Unicode regex flag requires a newer TS target than the declaration build uses.
286
+ if (_token.length > 0 && /^[a-z\u017F\u212A]/i.test(_token)) {
292
287
  lmLogits[_token] = Math.exp(alt.logprob);
293
288
  }
294
289
  }
@@ -28,10 +28,6 @@
28
28
 
29
29
  import { isAutocompleteDebugEnabled } from './debug-mode';
30
30
  import { isWordBoundary } from './slow-lane-client';
31
- const startsWithAsciiLetter = value => {
32
- const firstChar = value.charCodeAt(0);
33
- return firstChar >= 65 && firstChar <= 90 || firstChar >= 97 && firstChar <= 122;
34
- };
35
31
 
36
32
  // ─── Types ───────────────────────────────────────────────────────────────────
37
33
 
@@ -122,8 +118,6 @@ export const createLocalSlowLaneClient = (config = {}) => {
122
118
  if (!('gpu' in navigator)) {
123
119
  throw new Error('WebGPU not supported');
124
120
  }
125
-
126
- // eslint-disable-next-line @repo/internal/import/no-unresolved, import/dynamic-import-chunkname -- runtime dependency declared in package.json and lazily loaded for webgpu support
127
121
  const {
128
122
  CreateMLCEngine,
129
123
  prebuiltAppConfig
@@ -225,7 +219,8 @@ export const createLocalSlowLaneClient = (config = {}) => {
225
219
  // Add the top token
226
220
  if (tokenLogprobs.token) {
227
221
  const token = tokenLogprobs.token.trim().toLowerCase();
228
- if (token.length > 0 && startsWithAsciiLetter(token)) {
222
+ // @ts-ignore TS1501: Unicode regex flag requires a newer TS target than the declaration build uses.
223
+ if (token.length > 0 && /^[a-z]/iu.test(token)) {
229
224
  lmLogits[token] = Math.exp(tokenLogprobs.logprob);
230
225
  }
231
226
  }
@@ -234,7 +229,8 @@ export const createLocalSlowLaneClient = (config = {}) => {
234
229
  if (tokenLogprobs.top_logprobs) {
235
230
  for (const alt of tokenLogprobs.top_logprobs) {
236
231
  const token = alt.token.trim().toLowerCase();
237
- if (token.length > 0 && startsWithAsciiLetter(token)) {
232
+ // @ts-ignore TS1501: Unicode regex flag requires a newer TS target than the declaration build uses.
233
+ if (token.length > 0 && /^[a-z]/iu.test(token)) {
238
234
  lmLogits[token] = Math.exp(alt.logprob);
239
235
  }
240
236
  }
@@ -38,10 +38,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
38
38
 
39
39
  import { isAutocompleteDebugEnabled } from './debug-mode';
40
40
  import { isWordBoundary } from './slow-lane-client';
41
- var startsWithAsciiLetter = function startsWithAsciiLetter(value) {
42
- var firstChar = value.charCodeAt(0);
43
- return firstChar >= 65 && firstChar <= 90 || firstChar >= 97 && firstChar <= 122;
44
- };
45
41
 
46
42
  // ─── Types ───────────────────────────────────────────────────────────────────
47
43
 
@@ -266,8 +262,8 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
266
262
  if (logprobsContent && logprobsContent.length > 0) {
267
263
  tokenLogprobs = logprobsContent[0]; // Add the top token
268
264
  if (tokenLogprobs.token) {
269
- token = tokenLogprobs.token.trim().toLowerCase();
270
- if (token.length > 0 && startsWithAsciiLetter(token)) {
265
+ token = tokenLogprobs.token.trim().toLowerCase(); // @ts-ignore TS1501: Unicode regex flag requires a newer TS target than the declaration build uses.
266
+ if (token.length > 0 && /^[a-z\u017F\u212A]/i.test(token)) {
271
267
  lmLogits[token] = Math.exp(tokenLogprobs.logprob);
272
268
  }
273
269
  }
@@ -278,8 +274,8 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
278
274
  try {
279
275
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
280
276
  alt = _step.value;
281
- _token = alt.token.trim().toLowerCase();
282
- if (_token.length > 0 && startsWithAsciiLetter(_token)) {
277
+ _token = alt.token.trim().toLowerCase(); // @ts-ignore TS1501: Unicode regex flag requires a newer TS target than the declaration build uses.
278
+ if (_token.length > 0 && /^[a-z\u017F\u212A]/i.test(_token)) {
283
279
  lmLogits[_token] = Math.exp(alt.logprob);
284
280
  }
285
281
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-autocomplete",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "description": "Client-side text autocomplete plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,7 +35,7 @@
35
35
  "wink-nlp": "^2.4.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@atlaskit/editor-common": "^114.44.0",
38
+ "@atlaskit/editor-common": "^114.47.0",
39
39
  "@atlaskit/editor-plugin-analytics": "^10.1.0",
40
40
  "react": "^18.2.0"
41
41
  },
@@ -33,12 +33,6 @@ import { isWordBoundary } from './slow-lane-client';
33
33
 
34
34
  type WebLlmModelRecord = NonNullable<AppConfig['model_list']>[number];
35
35
 
36
- const startsWithAsciiLetter = (value: string): boolean => {
37
- const firstChar = value.charCodeAt(0);
38
-
39
- return (firstChar >= 65 && firstChar <= 90) || (firstChar >= 97 && firstChar <= 122);
40
- };
41
-
42
36
  // ─── Types ───────────────────────────────────────────────────────────────────
43
37
 
44
38
  export interface LocalSlowLaneClientConfig {
@@ -195,7 +189,6 @@ export const createLocalSlowLaneClient = (
195
189
  throw new Error('WebGPU not supported');
196
190
  }
197
191
 
198
- // eslint-disable-next-line @repo/internal/import/no-unresolved, import/dynamic-import-chunkname -- runtime dependency declared in package.json and lazily loaded for webgpu support
199
192
  const { CreateMLCEngine, prebuiltAppConfig } = await import(
200
193
  /* webpackChunkName: "@atlaskit-internal_editor-plugin-autocomplete-mlc-web-llm" */ '@mlc-ai/web-llm'
201
194
  );
@@ -319,7 +312,8 @@ export const createLocalSlowLaneClient = (
319
312
  // Add the top token
320
313
  if (tokenLogprobs.token) {
321
314
  const token = tokenLogprobs.token.trim().toLowerCase();
322
- if (token.length > 0 && startsWithAsciiLetter(token)) {
315
+ // @ts-ignore TS1501: Unicode regex flag requires a newer TS target than the declaration build uses.
316
+ if (token.length > 0 && /^[a-z]/iu.test(token)) {
323
317
  lmLogits[token] = Math.exp(tokenLogprobs.logprob);
324
318
  }
325
319
  }
@@ -328,7 +322,8 @@ export const createLocalSlowLaneClient = (
328
322
  if (tokenLogprobs.top_logprobs) {
329
323
  for (const alt of tokenLogprobs.top_logprobs) {
330
324
  const token = alt.token.trim().toLowerCase();
331
- if (token.length > 0 && startsWithAsciiLetter(token)) {
325
+ // @ts-ignore TS1501: Unicode regex flag requires a newer TS target than the declaration build uses.
326
+ if (token.length > 0 && /^[a-z]/iu.test(token)) {
332
327
  lmLogits[token] = Math.exp(alt.logprob);
333
328
  }
334
329
  }