@atlaskit/editor-plugin-autocomplete 8.0.0 → 9.1.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 (79) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/dist/cjs/analytics/ufo.js +2 -1
  3. package/dist/cjs/pm-plugins/artifact-loader.js +135 -0
  4. package/dist/cjs/pm-plugins/artifacts-manifest.js +3 -0
  5. package/dist/cjs/pm-plugins/autocomplete-plugin.js +498 -160
  6. package/dist/cjs/pm-plugins/canonical-lm-scoring.js +371 -0
  7. package/dist/cjs/pm-plugins/debug-mode.js +105 -7
  8. package/dist/cjs/pm-plugins/ghost-text-decoration.js +12 -3
  9. package/dist/cjs/pm-plugins/local-slow-lane-client.js +1202 -453
  10. package/dist/cjs/pm-plugins/scoring-pipeline.js +164 -19
  11. package/dist/cjs/pm-plugins/slow-lane-client.js +100 -37
  12. package/dist/cjs/pm-plugins/text-predictor.js +2099 -309
  13. package/dist/es2019/analytics/ufo.js +2 -0
  14. package/dist/es2019/pm-plugins/artifact-loader.js +70 -0
  15. package/dist/es2019/pm-plugins/artifacts-manifest.js +3 -0
  16. package/dist/es2019/pm-plugins/autocomplete-plugin.js +489 -152
  17. package/dist/es2019/pm-plugins/canonical-lm-scoring.js +270 -0
  18. package/dist/es2019/pm-plugins/debug-mode.js +102 -7
  19. package/dist/es2019/pm-plugins/ghost-text-decoration.js +12 -3
  20. package/dist/es2019/pm-plugins/local-slow-lane-client.js +940 -326
  21. package/dist/es2019/pm-plugins/scoring-pipeline.js +137 -13
  22. package/dist/es2019/pm-plugins/slow-lane-client.js +94 -37
  23. package/dist/es2019/pm-plugins/text-predictor.js +1692 -200
  24. package/dist/esm/analytics/ufo.js +2 -1
  25. package/dist/esm/pm-plugins/artifact-loader.js +128 -0
  26. package/dist/esm/pm-plugins/artifacts-manifest.js +3 -0
  27. package/dist/esm/pm-plugins/autocomplete-plugin.js +501 -163
  28. package/dist/esm/pm-plugins/canonical-lm-scoring.js +364 -0
  29. package/dist/esm/pm-plugins/debug-mode.js +104 -6
  30. package/dist/esm/pm-plugins/ghost-text-decoration.js +12 -3
  31. package/dist/esm/pm-plugins/local-slow-lane-client.js +1200 -451
  32. package/dist/esm/pm-plugins/scoring-pipeline.js +163 -18
  33. package/dist/esm/pm-plugins/slow-lane-client.js +100 -37
  34. package/dist/esm/pm-plugins/text-predictor.js +2101 -313
  35. package/dist/types/analytics/ufo.d.ts +1 -0
  36. package/dist/types/pm-plugins/artifact-loader.d.ts +44 -0
  37. package/dist/types/pm-plugins/artifacts-manifest.d.ts +3 -0
  38. package/dist/types/pm-plugins/autocomplete-plugin.d.ts +39 -0
  39. package/dist/types/pm-plugins/canonical-lm-scoring.d.ts +158 -0
  40. package/dist/types/pm-plugins/debug-mode.d.ts +55 -1
  41. package/dist/types/pm-plugins/ghost-text-decoration.d.ts +5 -2
  42. package/dist/types/pm-plugins/local-slow-lane-client.d.ts +87 -54
  43. package/dist/types/pm-plugins/scoring-pipeline.d.ts +33 -1
  44. package/dist/types/pm-plugins/slow-lane-client.d.ts +51 -3
  45. package/dist/types/pm-plugins/text-predictor.d.ts +156 -3
  46. package/package.json +2 -2
  47. package/src/analytics/ufo.ts +5 -0
  48. package/src/pm-plugins/artifact-loader.ts +92 -0
  49. package/src/pm-plugins/artifacts-manifest.ts +3 -0
  50. package/src/pm-plugins/autocomplete-plugin.ts +584 -154
  51. package/src/pm-plugins/canonical-lm-scoring.ts +412 -0
  52. package/src/pm-plugins/debug-mode.ts +134 -7
  53. package/src/pm-plugins/ghost-text-decoration.ts +13 -4
  54. package/src/pm-plugins/local-slow-lane-client.ts +1302 -386
  55. package/src/pm-plugins/scoring-pipeline.ts +167 -17
  56. package/src/pm-plugins/slow-lane-client.ts +147 -62
  57. package/src/pm-plugins/text-predictor.ts +2119 -254
  58. package/CANONICAL_FIX__DO_NOT_USE_ME_A/package.json +0 -8
  59. package/CANONICAL_FIX__DO_NOT_USE_ME_B/package.json +0 -8
  60. package/CANONICAL_FIX__DO_NOT_USE_ME_C/package.json +0 -8
  61. package/dist/cjs/entry-points/src-pm-plugins-autocomplete-plugin.js +0 -18
  62. package/dist/cjs/entry-points/src-pm-plugins-slow-lane-client.js +0 -36
  63. package/dist/cjs/entry-points/src-pm-plugins-text-predictor.js +0 -66
  64. package/dist/es2019/entry-points/src-pm-plugins-autocomplete-plugin.js +0 -2
  65. package/dist/es2019/entry-points/src-pm-plugins-slow-lane-client.js +0 -2
  66. package/dist/es2019/entry-points/src-pm-plugins-text-predictor.js +0 -2
  67. package/dist/esm/entry-points/src-pm-plugins-autocomplete-plugin.js +0 -2
  68. package/dist/esm/entry-points/src-pm-plugins-slow-lane-client.js +0 -2
  69. package/dist/esm/entry-points/src-pm-plugins-text-predictor.js +0 -2
  70. package/dist/types/entry-points/src-pm-plugins-autocomplete-plugin.d.ts +0 -2
  71. package/dist/types/entry-points/src-pm-plugins-slow-lane-client.d.ts +0 -2
  72. package/dist/types/entry-points/src-pm-plugins-text-predictor.d.ts +0 -2
  73. package/scripts/gen_first_token_to_words.py +0 -170
  74. package/src/entry-points/src-pm-plugins-autocomplete-plugin.ts +0 -7
  75. package/src/entry-points/src-pm-plugins-slow-lane-client.ts +0 -13
  76. package/src/entry-points/src-pm-plugins-text-predictor.ts +0 -14
  77. package/src/pm-plugins/autocomplete-plugin/package.json +0 -8
  78. package/src/pm-plugins/slow-lane-client/package.json +0 -8
  79. package/src/pm-plugins/text-predictor/package.json +0 -8
@@ -32,6 +32,7 @@ export const EXPERIENCE_NAME = {
32
32
  SLOW_LANE_FETCH: 'slow-lane-fetch',
33
33
  LOAD_VOCABULARY: 'load-vocabulary',
34
34
  LOAD_VECTORS: 'load-vectors',
35
+ LOAD_PHRASES: 'load-phrases',
35
36
  LOAD_GRAMMAR: 'load-grammar'
36
37
  };
37
38
  const isUfoEnabled = () => {
@@ -56,6 +57,7 @@ const experiences = {
56
57
  [EXPERIENCE_NAME.SLOW_LANE_FETCH]: new ConcurrentExperience(EXPERIENCE_NAME.SLOW_LANE_FETCH, operationConfig),
57
58
  [EXPERIENCE_NAME.LOAD_VOCABULARY]: new ConcurrentExperience(EXPERIENCE_NAME.LOAD_VOCABULARY, operationConfig),
58
59
  [EXPERIENCE_NAME.LOAD_VECTORS]: new ConcurrentExperience(EXPERIENCE_NAME.LOAD_VECTORS, operationConfig),
60
+ [EXPERIENCE_NAME.LOAD_PHRASES]: new ConcurrentExperience(EXPERIENCE_NAME.LOAD_PHRASES, operationConfig),
59
61
  [EXPERIENCE_NAME.LOAD_GRAMMAR]: new ConcurrentExperience(EXPERIENCE_NAME.LOAD_GRAMMAR, operationConfig)
60
62
  };
61
63
  export const startExp = (name, id, metadata) => {
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Validation and diagnostics layer over the artifacts manifest.
3
+ *
4
+ * `artifacts-manifest` owns *where* a payload comes from (one manifest request,
5
+ * then a presigned CDN download). This module owns *whether the payload is
6
+ * usable*: every loader declares the shape it expects, so a mis-published
7
+ * artifact fails at the boundary with the artifact's name rather than surfacing
8
+ * later as an empty trie or a silent no-op in scoring.
9
+ */
10
+
11
+ import { fetchArtifactJson, getArtifactUrl } from './artifacts-manifest';
12
+ import { ctcTag } from './debug-mode';
13
+ const TRAILING_SLASH_REGEX = /\/$/u;
14
+ const DEFAULT_BASE_URL = '';
15
+ const AUTOCOMPLETE_GATEWAY_BASE = '/gateway/api/v1/autocomplete';
16
+ /**
17
+ * Build a URL for one of the autocomplete gateway's own endpoints (e.g. the
18
+ * network slow lane). Model artifacts do NOT go through here — they are served
19
+ * from the CDN via the manifest.
20
+ */
21
+ export const buildAutocompleteGatewayUrl = (path, baseUrl = DEFAULT_BASE_URL) => {
22
+ const normalizedBase = baseUrl.replace(TRAILING_SLASH_REGEX, '');
23
+ return `${normalizedBase}${AUTOCOMPLETE_GATEWAY_BASE}${path}`;
24
+ };
25
+
26
+ /**
27
+ * Download a JSON artifact and assert its shape before handing it to a loader.
28
+ *
29
+ * :params:
30
+ * artifactName: Manifest key for the artifact
31
+ * options.label: Name used in diagnostics; defaults to the manifest key
32
+ * options.summarize: Renders a short size/count summary for the debug log
33
+ * options.validate: Type guard the payload must satisfy
34
+ * :returns:
35
+ * The parsed, validated payload
36
+ */
37
+ export const fetchAutocompleteArtifactJson = async (artifactName, options = {}) => {
38
+ var _options$label, _options$summarize;
39
+ const label = (_options$label = options.label) !== null && _options$label !== void 0 ? _options$label : artifactName;
40
+ // Presigned CDN URLs carry an auth token, so only the artifact name is logged.
41
+ ctcTag('init', `↓ loading ${label}`);
42
+ const payload = await fetchArtifactJson(artifactName);
43
+ if (options.validate && !options.validate(payload)) {
44
+ throw new Error(`[autocomplete-artifacts] ${label} payload shape was invalid`);
45
+ }
46
+ const summary = (_options$summarize = options.summarize) === null || _options$summarize === void 0 ? void 0 : _options$summarize.call(options, payload);
47
+ ctcTag('init', `✓ loaded ${label}${summary ? ` (${summary})` : ''}`);
48
+ return payload;
49
+ };
50
+
51
+ /**
52
+ * Download a binary artifact (the word-vectors blob) as an ArrayBuffer.
53
+ *
54
+ * :params:
55
+ * artifactName: Manifest key for the artifact
56
+ * label: Name used in diagnostics; defaults to the manifest key
57
+ * :returns:
58
+ * The raw bytes of the artifact
59
+ */
60
+ export const fetchAutocompleteArtifactBinary = async (artifactName, label = artifactName) => {
61
+ ctcTag('init', `↓ loading ${label}`);
62
+ const url = await getArtifactUrl(artifactName);
63
+ const response = await fetch(url);
64
+ if (!response.ok) {
65
+ throw new Error(`[autocomplete-artifacts] Failed to fetch ${label}: ${response.status}`);
66
+ }
67
+ const payload = await response.arrayBuffer();
68
+ ctcTag('init', `✓ loaded ${label} (${payload.byteLength} bytes)`);
69
+ return payload;
70
+ };
@@ -20,10 +20,13 @@ import { isAutocompleteDebugEnabled } from './debug-mode';
20
20
  * hyphenated, unlike the underscored filenames the artifacts are generated from.
21
21
  */
22
22
  export const ARTIFACT_NAME = {
23
+ BIGRAMS: 'bigrams.json',
23
24
  FIRST_TOKEN_TO_WORDS: 'first-token-to-words.json',
24
25
  GHOST_POS_TAGS: 'ghost-pos-tags.json',
25
26
  GRAMMAR_TRANSITIONS: 'grammar-transitions-10k.json',
26
27
  L3_VOCABULARY: 'l3-vocabulary.json',
28
+ PHRASE_CONTINUATION_TOKENS: 'phrase-continuation-tokens.json',
29
+ PHRASES: 'phrases.json',
27
30
  POS_TAGS: 'combined-l2-l3-pos-tags.json',
28
31
  VOCABULARY: 'vocabulary-10k.json',
29
32
  WORD_INDEX: 'word-index-10k.json',