@atlaskit/editor-plugin-autocomplete 0.2.0 → 0.3.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/afm-cc/tsconfig.json +1 -4
  3. package/afm-jira/tsconfig.json +1 -4
  4. package/afm-products/tsconfig.json +1 -4
  5. package/build/tsconfig.json +2 -6
  6. package/build/url-module.d.ts +8 -0
  7. package/dist/cjs/pm-plugins/autocomplete-plugin.js +11 -4
  8. package/dist/cjs/pm-plugins/scoring-pipeline.js +1 -3
  9. package/dist/cjs/pm-plugins/slow-lane-client.js +3 -1
  10. package/dist/cjs/pm-plugins/text-predictor.js +32 -22
  11. package/dist/es2019/pm-plugins/autocomplete-plugin.js +11 -3
  12. package/dist/es2019/pm-plugins/scoring-pipeline.js +0 -3
  13. package/dist/es2019/pm-plugins/slow-lane-client.js +5 -2
  14. package/dist/es2019/pm-plugins/text-predictor.js +16 -9
  15. package/dist/esm/pm-plugins/autocomplete-plugin.js +11 -3
  16. package/dist/esm/pm-plugins/scoring-pipeline.js +0 -3
  17. package/dist/esm/pm-plugins/slow-lane-client.js +3 -1
  18. package/dist/esm/pm-plugins/text-predictor.js +32 -22
  19. package/dist/types/pm-plugins/autocomplete-plugin.d.ts +1 -1
  20. package/dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts +1 -1
  21. package/package.json +1 -1
  22. package/src/pm-plugins/autocomplete-plugin.ts +19 -5
  23. package/src/pm-plugins/data/combined_l2_l3_pos_tags.json +73571 -3
  24. package/src/pm-plugins/data/ghost_pos_tags.json +43 -3
  25. package/src/pm-plugins/data/grammar_transitions_10k.json +46 -3
  26. package/src/pm-plugins/data/l3_vocabulary.json +20002 -3
  27. package/src/pm-plugins/data/vocabulary_10k.json +38794 -3
  28. package/src/pm-plugins/data/word_index_10k.json +7760 -3
  29. package/src/pm-plugins/scoring-pipeline.ts +0 -3
  30. package/src/pm-plugins/slow-lane-client.ts +4 -2
  31. package/src/pm-plugins/text-predictor.ts +18 -9
  32. package/tsconfig.app.json +3 -2
  33. package/tsconfig.json +2 -1
  34. package/src/pm-plugins/typings.d.ts +0 -12
@@ -5,9 +5,6 @@
5
5
  * when its required data isn't available (cold → warm → full warm).
6
6
  */
7
7
 
8
- // resolveJsonModule is disabled for this package (see tsconfig.json) to prevent
9
- // TypeScript from parsing LFS pointer files during CI typecheck. JSON imports
10
- // are typed via the '*.json' declaration in typings.d.ts.
11
8
  import posTagsData from './data/combined_l2_l3_pos_tags.json';
12
9
  import ghostPosTagsData from './data/ghost_pos_tags.json';
13
10
  import grammarTransitionsData from './data/grammar_transitions_10k.json';
@@ -23,7 +23,8 @@ export interface TypeaheadEncodingsResponse {
23
23
 
24
24
  // ─── Constants ───────────────────────────────────────────────────────────────
25
25
 
26
- const WORD_BOUNDARY_CHARS = /[\s.,;:!?]/u;
26
+ // eslint-disable-next-line require-unicode-regexp
27
+ const WORD_BOUNDARY_CHARS = /[\s.,;:!?]/;
27
28
  const DEFAULT_DEBOUNCE_MS = 300;
28
29
 
29
30
  /**
@@ -87,7 +88,8 @@ export const createSlowLaneClient = (
87
88
  return;
88
89
  }
89
90
 
90
- const url = `${baseUrl.replace(/\/$/u, '')}${endpoint}`;
91
+ // eslint-disable-next-line require-unicode-regexp
92
+ const url = `${baseUrl.replace(/\/$/, '')}${endpoint}`;
91
93
  const payload: TypeaheadEncodingsRequest = {
92
94
  text,
93
95
  session_id: sessionId,
@@ -26,7 +26,8 @@ import { getStoredContextVector, getStoredLmLogits } from './slow-lane-client';
26
26
 
27
27
  // ─── Constants ───────────────────────────────────────────────────────────────
28
28
 
29
- const PUNCTUATION_BOUNDARY_REGEX = /^[.,;:!?()\[\]{}"'`]+|[.,;:!?()\[\]{}"'`]+$/gu;
29
+ // eslint-disable-next-line require-unicode-regexp
30
+ const PUNCTUATION_BOUNDARY_REGEX = /^[.,;:!?()\[\]{}"'`]+|[.,;:!?()\[\]{}"'`]+$/g;
30
31
 
31
32
  const MIN_PREFIX_LENGTH = 3;
32
33
  const MAX_CANDIDATES = 200;
@@ -278,8 +279,8 @@ const getContextVectorForScoring = (textBefore: string): Float32Array | null =>
278
279
 
279
280
  const tokenize = (text: string): string[] => {
280
281
  const tokens: string[] = [];
281
- // eslint-disable-next-line @atlassian/perf-linting/no-expensive-split-replace
282
- for (const raw of text.toLowerCase().split(/\s+/u)) {
282
+ // eslint-disable-next-line require-unicode-regexp, @atlassian/perf-linting/no-expensive-split-replace
283
+ for (const raw of text.toLowerCase().split(/\s+/)) {
283
284
  // eslint-disable-next-line @atlassian/perf-linting/no-expensive-split-replace
284
285
  const clean = raw.replace(PUNCTUATION_BOUNDARY_REGEX, '');
285
286
  if (clean.length >= 2) {
@@ -291,13 +292,15 @@ const tokenize = (text: string): string[] => {
291
292
 
292
293
  const extractPreviousWord = (text: string): string => {
293
294
  // 1. Split the text by newlines or punctuation (. ? !)
294
- const sentences = text.split(/[\n.?!]+/u);
295
+ // eslint-disable-next-line require-unicode-regexp
296
+ const sentences = text.split(/[\n.?!]+/);
295
297
 
296
298
  // 2. Only look at the current sentence/line the user is typing in
297
299
  const currentSentence = sentences[sentences.length - 1];
298
300
 
299
301
  // 3. Extract the previous word as normal
300
- const words = currentSentence.trimEnd().split(/\s+/u);
302
+ // eslint-disable-next-line require-unicode-regexp
303
+ const words = currentSentence.trimEnd().split(/\s+/);
301
304
  return words.length >= 2 ? words[words.length - 2] : '';
302
305
  };
303
306
 
@@ -459,7 +462,8 @@ export const predict = (textBefore: string): string | null => {
459
462
  // }
460
463
 
461
464
  // ── Step 2: Prefix completion (≥3 chars typed) ──────────────────────────
462
- if (textBefore.length > 0 && /\s$/u.test(textBefore)) {
465
+ // eslint-disable-next-line require-unicode-regexp
466
+ if (textBefore.length > 0 && /\s$/.test(textBefore)) {
463
467
  return null;
464
468
  }
465
469
 
@@ -710,15 +714,20 @@ interface VocabularyJson {
710
714
  >;
711
715
  }
712
716
 
713
- const DEFAULT_VECTORS_URL = '/data/word-vectors_10k.bin';
714
-
715
717
  export const loadVectorsAsync = async (options?: { vectorsUrl?: string }): Promise<void> => {
716
718
  if (vectorStore || vectorsLoadStarted) {
717
719
  return;
718
720
  }
721
+ if (!options?.vectorsUrl) {
722
+ // eslint-disable-next-line no-console
723
+ console.warn(
724
+ '[text-predictor] loadVectorsAsync called without a vectorsUrl — vectors will not load. Pass vectorsUrl via plugin options.',
725
+ );
726
+ return;
727
+ }
719
728
  vectorsLoadStarted = true;
720
729
 
721
- const url = options?.vectorsUrl ?? DEFAULT_VECTORS_URL;
730
+ const url = options.vectorsUrl;
722
731
  try {
723
732
  const res = await fetch(url);
724
733
  if (!res.ok) {
package/tsconfig.app.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "extends": "../../../tsconfig.base.json",
3
- "include": ["./src/**/*.ts", "./src/**/*.tsx"],
3
+ "files": ["./build/url-module.d.ts"],
4
+ "include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.json"],
4
5
  "exclude": [
5
6
  "**/docs/**/*",
6
7
  "**/__tests__/**/*",
@@ -29,7 +30,7 @@
29
30
  "compilerOptions": {
30
31
  "composite": true,
31
32
  "outDir": "../../../tsDist/@atlaskit__editor-plugin-autocomplete/app",
32
- "resolveJsonModule": false
33
+ "resolveJsonModule": true
33
34
  },
34
35
  "references": [
35
36
  {
package/tsconfig.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "extends": "../../../tsconfig.json",
3
+ "files": ["./build/url-module.d.ts"],
3
4
  "include": [
4
5
  "src/**/*.ts",
5
6
  "src/**/*.tsx"
6
7
  ],
7
8
  "compilerOptions": {
8
- "resolveJsonModule": false
9
+ "resolveJsonModule": true
9
10
  }
10
11
  }
@@ -1,12 +0,0 @@
1
- /**
2
- * Wildcard declaration for JSON module imports.
3
- *
4
- * resolveJsonModule is disabled for this package (see tsconfig.json) to prevent
5
- * TypeScript from attempting to parse Git LFS pointer files as JSON during CI
6
- * typecheck. This declaration provides the module type instead.
7
- */
8
- declare module '*.json' {
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- const value: any;
11
- export default value;
12
- }