@atlaskit/editor-plugin-autocomplete 2.3.0 → 2.5.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 (66) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-products/tsconfig.json +3 -0
  4. package/autocompletePlugin/package.json +15 -0
  5. package/autocompletePluginType/package.json +15 -0
  6. package/dist/cjs/analytics/ufo.js +111 -0
  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 +126 -64
  13. package/dist/cjs/pm-plugins/local-slow-lane-client.js +447 -0
  14. package/dist/cjs/pm-plugins/slow-lane-client.js +45 -16
  15. package/dist/cjs/pm-plugins/text-predictor.js +72 -40
  16. package/dist/es2019/analytics/ufo.js +110 -0
  17. package/dist/es2019/entry-points/autocompletePlugin.js +2 -0
  18. package/dist/es2019/entry-points/autocompletePluginType.js +0 -0
  19. package/dist/es2019/entry-points/src-pm-plugins-autocomplete-plugin.js +2 -0
  20. package/dist/es2019/entry-points/src-pm-plugins-slow-lane-client.js +2 -0
  21. package/dist/es2019/entry-points/src-pm-plugins-text-predictor.js +2 -0
  22. package/dist/es2019/pm-plugins/autocomplete-plugin.js +132 -72
  23. package/dist/es2019/pm-plugins/local-slow-lane-client.js +355 -0
  24. package/dist/es2019/pm-plugins/slow-lane-client.js +29 -2
  25. package/dist/es2019/pm-plugins/text-predictor.js +48 -15
  26. package/dist/esm/analytics/ufo.js +105 -0
  27. package/dist/esm/entry-points/autocompletePlugin.js +2 -0
  28. package/dist/esm/entry-points/autocompletePluginType.js +0 -0
  29. package/dist/esm/entry-points/src-pm-plugins-autocomplete-plugin.js +2 -0
  30. package/dist/esm/entry-points/src-pm-plugins-slow-lane-client.js +2 -0
  31. package/dist/esm/entry-points/src-pm-plugins-text-predictor.js +2 -0
  32. package/dist/esm/pm-plugins/autocomplete-plugin.js +126 -64
  33. package/dist/esm/pm-plugins/local-slow-lane-client.js +439 -0
  34. package/dist/esm/pm-plugins/slow-lane-client.js +45 -16
  35. package/dist/esm/pm-plugins/text-predictor.js +73 -40
  36. package/dist/types/analytics/ufo.d.ts +38 -0
  37. package/dist/types/entry-points/autocompletePlugin.d.ts +1 -0
  38. package/dist/types/entry-points/autocompletePluginType.d.ts +1 -0
  39. package/dist/types/entry-points/src-pm-plugins-autocomplete-plugin.d.ts +2 -0
  40. package/dist/types/entry-points/src-pm-plugins-slow-lane-client.d.ts +2 -0
  41. package/dist/types/entry-points/src-pm-plugins-text-predictor.d.ts +2 -0
  42. package/dist/types/pm-plugins/autocomplete-plugin.d.ts +5 -0
  43. package/dist/types/pm-plugins/local-slow-lane-client.d.ts +102 -0
  44. package/dist/types-ts4.5/analytics/ufo.d.ts +38 -0
  45. package/dist/types-ts4.5/entry-points/autocompletePlugin.d.ts +1 -0
  46. package/dist/types-ts4.5/entry-points/autocompletePluginType.d.ts +1 -0
  47. package/dist/types-ts4.5/entry-points/src-pm-plugins-autocomplete-plugin.d.ts +2 -0
  48. package/dist/types-ts4.5/entry-points/src-pm-plugins-slow-lane-client.d.ts +2 -0
  49. package/dist/types-ts4.5/entry-points/src-pm-plugins-text-predictor.d.ts +2 -0
  50. package/dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts +5 -0
  51. package/dist/types-ts4.5/pm-plugins/local-slow-lane-client.d.ts +102 -0
  52. package/package.json +8 -3
  53. package/src/analytics/ufo.ts +139 -0
  54. package/src/entry-points/autocompletePlugin.tsx +2 -0
  55. package/src/entry-points/autocompletePluginType.ts +2 -0
  56. package/src/entry-points/src-pm-plugins-autocomplete-plugin.ts +7 -0
  57. package/src/entry-points/src-pm-plugins-slow-lane-client.ts +13 -0
  58. package/src/entry-points/src-pm-plugins-text-predictor.ts +14 -0
  59. package/src/pm-plugins/autocomplete-plugin/package.json +5 -5
  60. package/src/pm-plugins/autocomplete-plugin.ts +126 -64
  61. package/src/pm-plugins/local-slow-lane-client.ts +480 -0
  62. package/src/pm-plugins/slow-lane-client/package.json +5 -5
  63. package/src/pm-plugins/slow-lane-client.ts +28 -2
  64. package/src/pm-plugins/text-predictor/package.json +5 -5
  65. package/src/pm-plugins/text-predictor.ts +42 -12
  66. package/tsconfig.app.json +3 -0
@@ -15,6 +15,8 @@
15
15
  * via incrementSessionFreq(), called on word boundaries from the plugin.
16
16
  */
17
17
 
18
+ import { EXPERIENCE_NAME, failExp, startExp, succeedExp } from '../analytics/ufo';
19
+
18
20
  // import bigramsData from './data/bigrams.json';
19
21
  import l3VocabularyData from './data/l3_vocabulary.json';
20
22
  import vocabularyData from './data/vocabulary_10k.json';
@@ -723,12 +725,14 @@ export const loadVectorsAsync = async (options?: {
723
725
  return;
724
726
  }
725
727
  vectorsLoadStarted = true;
728
+ startExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton');
726
729
 
727
730
  let url: string;
728
731
  try {
729
732
  url = await options.getBinaryUrl();
730
733
  } catch (e) {
731
734
  vectorsLoadStarted = false;
735
+ failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', { errorType: 'resolve_url' });
732
736
  // eslint-disable-next-line no-console
733
737
  console.warn('[text-predictor] Failed to resolve vectors URL:', e);
734
738
  return;
@@ -738,6 +742,10 @@ export const loadVectorsAsync = async (options?: {
738
742
  const res = await fetch(url);
739
743
  if (!res.ok) {
740
744
  vectorsLoadStarted = false;
745
+ failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
746
+ status: res.status,
747
+ errorType: 'http_error',
748
+ });
741
749
  // eslint-disable-next-line no-console
742
750
  console.warn(`[text-predictor] Failed to load vectors: ${res.status}`);
743
751
  return;
@@ -749,6 +757,11 @@ export const loadVectorsAsync = async (options?: {
749
757
  const dim = float32.length / nWords;
750
758
 
751
759
  vectorStore = { float32, wordIndex, dim };
760
+ succeedExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
761
+ wordCount: nWords,
762
+ dim,
763
+ sizeBytes: float32.byteLength,
764
+ });
752
765
  if (isAutocompleteDebugEnabled()) {
753
766
  // eslint-disable-next-line no-console
754
767
  console.log('[text-predictor] Vectors loaded:', {
@@ -759,6 +772,7 @@ export const loadVectorsAsync = async (options?: {
759
772
  }
760
773
  } catch (e) {
761
774
  vectorsLoadStarted = false;
775
+ failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', { errorType: 'network' });
762
776
  // eslint-disable-next-line no-console
763
777
  console.warn('[text-predictor] Failed to load vectors:', e);
764
778
  }
@@ -769,17 +783,33 @@ export const initVectors = (store: VectorStore): void => {
769
783
  };
770
784
 
771
785
  export const loadDefaultVocabulary = (): void => {
772
- // 1. Load the Atlassian Domain (L2)
773
- const data = vocabularyData as VocabularyJson;
774
- const terms = Object.entries(data.words).map(([word, stats]) => ({
775
- word,
776
- freq: stats.freq,
777
- docFreq: stats.doc_freq,
778
- authorFreq: stats.author_freq,
779
- }));
780
- initVocabulary({ terms });
786
+ if (isInitialized) {
787
+ return;
788
+ }
789
+
790
+ startExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton');
781
791
 
782
- // 2. Load General English (L3)
783
- const l3Words = l3VocabularyData as string[];
784
- initL3Vocabulary(l3Words);
792
+ try {
793
+ // 1. Load the Atlassian Domain (L2)
794
+ const data = vocabularyData as VocabularyJson;
795
+ const terms = Object.entries(data.words).map(([word, stats]) => ({
796
+ word,
797
+ freq: stats.freq,
798
+ docFreq: stats.doc_freq,
799
+ authorFreq: stats.author_freq,
800
+ }));
801
+ initVocabulary({ terms });
802
+
803
+ // 2. Load General English (L3)
804
+ const l3Words = l3VocabularyData as string[];
805
+ initL3Vocabulary(l3Words);
806
+
807
+ succeedExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', {
808
+ l2WordCount: terms.length,
809
+ l3WordCount: l3Words.length,
810
+ });
811
+ } catch (e) {
812
+ failExp(EXPERIENCE_NAME.LOAD_VOCABULARY, 'singleton', { errorType: 'parse_error' });
813
+ throw e;
814
+ }
785
815
  };
package/tsconfig.app.json CHANGED
@@ -42,6 +42,9 @@
42
42
  },
43
43
  {
44
44
  "path": "../editor-prosemirror/tsconfig.app.json"
45
+ },
46
+ {
47
+ "path": "../../data/ufo-external/tsconfig.app.json"
45
48
  }
46
49
  ]
47
50
  }