@atlaskit/editor-plugin-autocomplete 2.2.0 → 2.4.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 (65) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/afm-cc/tsconfig.json +0 -1
  3. package/afm-products/tsconfig.json +0 -1
  4. package/autocompletePlugin/package.json +15 -0
  5. package/autocompletePluginType/package.json +15 -0
  6. package/build/tsconfig.json +0 -1
  7. package/dist/cjs/entry-points/autocompletePlugin.js +12 -0
  8. package/dist/cjs/entry-points/autocompletePluginType.js +1 -0
  9. package/dist/cjs/entry-points/src-pm-plugins-autocomplete-plugin.js +18 -0
  10. package/dist/cjs/entry-points/src-pm-plugins-slow-lane-client.js +36 -0
  11. package/dist/cjs/entry-points/src-pm-plugins-text-predictor.js +66 -0
  12. package/dist/cjs/pm-plugins/autocomplete-plugin.js +41 -14
  13. package/dist/cjs/pm-plugins/debug-mode.js +24 -0
  14. package/dist/cjs/pm-plugins/slow-lane-client.js +42 -35
  15. package/dist/cjs/pm-plugins/text-predictor.js +12 -32
  16. package/dist/es2019/entry-points/autocompletePlugin.js +2 -0
  17. package/dist/es2019/entry-points/autocompletePluginType.js +0 -0
  18. package/dist/es2019/entry-points/src-pm-plugins-autocomplete-plugin.js +2 -0
  19. package/dist/es2019/entry-points/src-pm-plugins-slow-lane-client.js +2 -0
  20. package/dist/es2019/entry-points/src-pm-plugins-text-predictor.js +2 -0
  21. package/dist/es2019/pm-plugins/autocomplete-plugin.js +41 -14
  22. package/dist/es2019/pm-plugins/debug-mode.js +18 -0
  23. package/dist/es2019/pm-plugins/slow-lane-client.js +29 -23
  24. package/dist/es2019/pm-plugins/text-predictor.js +6 -26
  25. package/dist/esm/entry-points/autocompletePlugin.js +2 -0
  26. package/dist/esm/entry-points/autocompletePluginType.js +0 -0
  27. package/dist/esm/entry-points/src-pm-plugins-autocomplete-plugin.js +2 -0
  28. package/dist/esm/entry-points/src-pm-plugins-slow-lane-client.js +2 -0
  29. package/dist/esm/entry-points/src-pm-plugins-text-predictor.js +2 -0
  30. package/dist/esm/pm-plugins/autocomplete-plugin.js +41 -14
  31. package/dist/esm/pm-plugins/debug-mode.js +18 -0
  32. package/dist/esm/pm-plugins/slow-lane-client.js +43 -35
  33. package/dist/esm/pm-plugins/text-predictor.js +11 -31
  34. package/dist/types/entry-points/autocompletePlugin.d.ts +1 -0
  35. package/dist/types/entry-points/autocompletePluginType.d.ts +1 -0
  36. package/dist/types/entry-points/src-pm-plugins-autocomplete-plugin.d.ts +2 -0
  37. package/dist/types/entry-points/src-pm-plugins-slow-lane-client.d.ts +2 -0
  38. package/dist/types/entry-points/src-pm-plugins-text-predictor.d.ts +2 -0
  39. package/dist/types/pm-plugins/autocomplete-plugin.d.ts +1 -1
  40. package/dist/types/pm-plugins/debug-mode.d.ts +12 -0
  41. package/dist/types/pm-plugins/text-predictor.d.ts +0 -2
  42. package/dist/types-ts4.5/entry-points/autocompletePlugin.d.ts +1 -0
  43. package/dist/types-ts4.5/entry-points/autocompletePluginType.d.ts +1 -0
  44. package/dist/types-ts4.5/entry-points/src-pm-plugins-autocomplete-plugin.d.ts +2 -0
  45. package/dist/types-ts4.5/entry-points/src-pm-plugins-slow-lane-client.d.ts +2 -0
  46. package/dist/types-ts4.5/entry-points/src-pm-plugins-text-predictor.d.ts +2 -0
  47. package/dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts +1 -1
  48. package/dist/types-ts4.5/pm-plugins/debug-mode.d.ts +12 -0
  49. package/dist/types-ts4.5/pm-plugins/text-predictor.d.ts +0 -2
  50. package/package.json +3 -3
  51. package/src/entry-points/autocompletePlugin.tsx +2 -0
  52. package/src/entry-points/autocompletePluginType.ts +2 -0
  53. package/src/entry-points/src-pm-plugins-autocomplete-plugin.ts +7 -0
  54. package/src/entry-points/src-pm-plugins-slow-lane-client.ts +13 -0
  55. package/src/entry-points/src-pm-plugins-text-predictor.ts +14 -0
  56. package/src/pm-plugins/autocomplete-plugin/package.json +5 -5
  57. package/src/pm-plugins/autocomplete-plugin.ts +48 -12
  58. package/src/pm-plugins/debug-mode.ts +18 -0
  59. package/src/pm-plugins/slow-lane-client/package.json +5 -5
  60. package/src/pm-plugins/slow-lane-client.ts +53 -45
  61. package/src/pm-plugins/text-predictor/package.json +5 -5
  62. package/src/pm-plugins/text-predictor.ts +6 -30
  63. package/tsconfig.app.json +3 -1
  64. package/tsconfig.dev.json +2 -1
  65. package/afm-jira/tsconfig.json +0 -30
@@ -20,6 +20,7 @@ import l3VocabularyData from './data/l3_vocabulary.json';
20
20
  import vocabularyData from './data/vocabulary_10k.json';
21
21
  import wordIndexData from './data/word_index_10k.json';
22
22
  // import { rankCandidates, isGrammarAllowed } from './scoring-pipeline';
23
+ import { isAutocompleteDebugEnabled } from './debug-mode';
23
24
  import { rankCandidates, STAGE1_WEIGHT, STAGE2_WEIGHT, MIN_STAGE1_SCORE } from './scoring-pipeline';
24
25
  import type { ScoringCandidate } from './scoring-pipeline';
25
26
  import { getStoredContextVector, getStoredLmLogits } from './slow-lane-client';
@@ -183,7 +184,7 @@ export const initL3Vocabulary = (l3Words: string[]): void => {
183
184
  // loses to any domain word in Stage 1, but still scores above 0.
184
185
  l3Trie.insert(word, L3_BASELINE_FREQ, 0, 0);
185
186
  }
186
- if (debugMode) {
187
+ if (isAutocompleteDebugEnabled()) {
187
188
  // eslint-disable-next-line no-console
188
189
  console.log(`[text-predictor] L3 General English loaded: ${l3Words.length} words`);
189
190
  }
@@ -199,8 +200,6 @@ let vectorStore: VectorStore | null = null;
199
200
 
200
201
  let vectorsLoadStarted = false;
201
202
 
202
- let debugMode = true;
203
-
204
203
  let lastPredictionDebug: {
205
204
  contextWords: string[];
206
205
  currentWord: string;
@@ -216,8 +215,6 @@ let lastPredictionDebug: {
216
215
  }>;
217
216
  } | null = null;
218
217
 
219
- let hasLoggedSemanticActive = false;
220
-
221
218
  /** Get vector for a word from the store. */
222
219
  const getWordVector = (word: string): Float32Array | null => {
223
220
  if (!vectorStore) {
@@ -306,18 +303,6 @@ const extractPreviousWord = (text: string): string => {
306
303
 
307
304
  // ─── Debug Helpers ───────────────────────────────────────────────────────────
308
305
 
309
- /** Enable or disable debug logging. Also checks localStorage key `autocomplete-debug`. */
310
- export const setDebugMode = (enabled: boolean): void => {
311
- debugMode = enabled;
312
- };
313
-
314
- /** Check localStorage for autocomplete-debug on first access. */
315
- const ensureDebugModeFromStorage = (): void => {
316
- if (typeof localStorage !== 'undefined' && localStorage.getItem('autocomplete-debug') === '1') {
317
- debugMode = true;
318
- }
319
- };
320
-
321
306
  /**
322
307
  * Get predictor status for debugging.
323
308
  * vectorsLoaded: true when semantic scoring is active
@@ -329,7 +314,6 @@ export const getPredictorStatus = (): {
329
314
  vectorsLoadStarted: boolean;
330
315
  wordCount: number;
331
316
  } => {
332
- ensureDebugModeFromStorage();
333
317
  return {
334
318
  vectorsLoaded: vectorStore !== null,
335
319
  wordCount: vectorStore ? Object.keys(vectorStore.wordIndex).length : 0,
@@ -356,7 +340,6 @@ export const getLastPredictionDebug = (): {
356
340
  word: string;
357
341
  }>;
358
342
  } | null => {
359
- ensureDebugModeFromStorage();
360
343
  return lastPredictionDebug;
361
344
  };
362
345
 
@@ -401,7 +384,7 @@ export const ingestDocumentPage = (pageContent: string | undefined): void => {
401
384
  }
402
385
  }
403
386
 
404
- if (debugMode && validBoostedWords.size > 0) {
387
+ if (isAutocompleteDebugEnabled() && validBoostedWords.size > 0) {
405
388
  // eslint-disable-next-line no-console
406
389
  console.groupCollapsed(
407
390
  `%c[L1 Session] %cPrimed ${validBoostedWords.size} valid dictionary words from page`,
@@ -416,8 +399,6 @@ export const ingestDocumentPage = (pageContent: string | undefined): void => {
416
399
  };
417
400
 
418
401
  export const predict = (textBefore: string): string | null => {
419
- ensureDebugModeFromStorage();
420
-
421
402
  if (!isInitialized) {
422
403
  loadDefaultVocabulary();
423
404
  }
@@ -506,7 +487,7 @@ export const predict = (textBefore: string): string | null => {
506
487
  const lmLogits = getStoredLmLogits();
507
488
 
508
489
  // Raw LM Output Logger
509
- if (debugMode && lmLogits && Object.keys(lmLogits).length > 0) {
490
+ if (isAutocompleteDebugEnabled() && lmLogits && Object.keys(lmLogits).length > 0) {
510
491
  const rawLmTop = Object.entries(lmLogits)
511
492
  .sort((a, b) => b[1] - a[1])
512
493
  .slice(0, 5)
@@ -520,10 +501,6 @@ export const predict = (textBefore: string): string | null => {
520
501
 
521
502
  const mode: 'cold' | 'warm' = contextVector ? 'warm' : 'cold';
522
503
 
523
- if (debugMode && contextVector && !hasLoggedSemanticActive) {
524
- hasLoggedSemanticActive = true;
525
- }
526
-
527
504
  // Build ScoringCandidate array from TrieNodes
528
505
  const scoringCandidates: ScoringCandidate[] = candidates.map(({ word, node }) => ({
529
506
  word,
@@ -556,7 +533,7 @@ export const predict = (textBefore: string): string | null => {
556
533
  const suggestion =
557
534
  best && best.finalScore >= MIN_SCORE_THRESHOLD ? best.word.slice(currentWord.length) : null;
558
535
 
559
- if (debugMode) {
536
+ if (isAutocompleteDebugEnabled()) {
560
537
  const latencyMs = performance.now() - t0;
561
538
  const tokens = tokenize(trimmed);
562
539
  const contextWords = tokens.slice(-CONTEXT_WORDS);
@@ -772,8 +749,7 @@ export const loadVectorsAsync = async (options?: {
772
749
  const dim = float32.length / nWords;
773
750
 
774
751
  vectorStore = { float32, wordIndex, dim };
775
- ensureDebugModeFromStorage();
776
- if (debugMode) {
752
+ if (isAutocompleteDebugEnabled()) {
777
753
  // eslint-disable-next-line no-console
778
754
  console.log('[text-predictor] Vectors loaded:', {
779
755
  wordCount: nWords,
package/tsconfig.app.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "extends": "../../../tsconfig.base.json",
3
3
  "include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.json"],
4
4
  "exclude": [
5
+ "**/*.docs.tsx",
5
6
  "**/docs/**/*",
6
7
  "**/__tests__/**/*",
7
8
  "**/vr-tests/**/*",
@@ -29,7 +30,8 @@
29
30
  "compilerOptions": {
30
31
  "composite": true,
31
32
  "outDir": "../../../tsDist/@atlaskit__editor-plugin-autocomplete/app",
32
- "resolveJsonModule": true
33
+ "resolveJsonModule": true,
34
+ "isolatedDeclarations": true
33
35
  },
34
36
  "references": [
35
37
  {
package/tsconfig.dev.json CHANGED
@@ -28,7 +28,8 @@
28
28
  "exclude": ["./dist/**/*", "./build/**/*", "./node_modules/**/*"],
29
29
  "compilerOptions": {
30
30
  "composite": true,
31
- "outDir": "../../../tsDist/@atlaskit__editor-plugin-autocomplete/dev"
31
+ "outDir": "../../../tsDist/@atlaskit__editor-plugin-autocomplete/dev",
32
+ "isolatedDeclarations": true
32
33
  },
33
34
  "references": [
34
35
  {
@@ -1,30 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.local-consumption.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../jira/tsDist/@atlaskit__editor-plugin-autocomplete/app",
6
- "rootDir": "../",
7
- "composite": true,
8
- "noCheck": true,
9
- "resolveJsonModule": true
10
- },
11
- "include": [
12
- "../src/**/*.ts",
13
- "../src/**/*.tsx"
14
- ],
15
- "exclude": [
16
- "../src/**/__tests__/*",
17
- "../src/**/*.test.*",
18
- "../src/**/test.*",
19
- "../src/**/mocks/*",
20
- "../src/**/examples.*"
21
- ],
22
- "references": [
23
- {
24
- "path": "../../editor-prosemirror/afm-jira/tsconfig.json"
25
- },
26
- {
27
- "path": "../../editor-common/afm-jira/tsconfig.json"
28
- }
29
- ]
30
- }