@atlaskit/editor-plugin-autocomplete 8.0.0 → 9.0.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.
- package/CHANGELOG.md +80 -0
- package/dist/cjs/analytics/ufo.js +2 -1
- package/dist/cjs/pm-plugins/artifact-loader.js +135 -0
- package/dist/cjs/pm-plugins/artifacts-manifest.js +3 -0
- package/dist/cjs/pm-plugins/autocomplete-plugin.js +416 -129
- package/dist/cjs/pm-plugins/canonical-lm-scoring.js +371 -0
- package/dist/cjs/pm-plugins/debug-mode.js +90 -7
- package/dist/cjs/pm-plugins/ghost-text-decoration.js +12 -3
- package/dist/cjs/pm-plugins/local-slow-lane-client.js +1202 -453
- package/dist/cjs/pm-plugins/scoring-pipeline.js +164 -19
- package/dist/cjs/pm-plugins/slow-lane-client.js +100 -37
- package/dist/cjs/pm-plugins/text-predictor.js +1951 -273
- package/dist/es2019/analytics/ufo.js +2 -0
- package/dist/es2019/pm-plugins/artifact-loader.js +70 -0
- package/dist/es2019/pm-plugins/artifacts-manifest.js +3 -0
- package/dist/es2019/pm-plugins/autocomplete-plugin.js +425 -130
- package/dist/es2019/pm-plugins/canonical-lm-scoring.js +270 -0
- package/dist/es2019/pm-plugins/debug-mode.js +87 -7
- package/dist/es2019/pm-plugins/ghost-text-decoration.js +12 -3
- package/dist/es2019/pm-plugins/local-slow-lane-client.js +940 -326
- package/dist/es2019/pm-plugins/scoring-pipeline.js +137 -13
- package/dist/es2019/pm-plugins/slow-lane-client.js +94 -37
- package/dist/es2019/pm-plugins/text-predictor.js +1603 -199
- package/dist/esm/analytics/ufo.js +2 -1
- package/dist/esm/pm-plugins/artifact-loader.js +128 -0
- package/dist/esm/pm-plugins/artifacts-manifest.js +3 -0
- package/dist/esm/pm-plugins/autocomplete-plugin.js +419 -132
- package/dist/esm/pm-plugins/canonical-lm-scoring.js +364 -0
- package/dist/esm/pm-plugins/debug-mode.js +89 -6
- package/dist/esm/pm-plugins/ghost-text-decoration.js +12 -3
- package/dist/esm/pm-plugins/local-slow-lane-client.js +1200 -451
- package/dist/esm/pm-plugins/scoring-pipeline.js +163 -18
- package/dist/esm/pm-plugins/slow-lane-client.js +100 -37
- package/dist/esm/pm-plugins/text-predictor.js +1953 -277
- package/dist/types/analytics/ufo.d.ts +1 -0
- package/dist/types/pm-plugins/artifact-loader.d.ts +44 -0
- package/dist/types/pm-plugins/artifacts-manifest.d.ts +3 -0
- package/dist/types/pm-plugins/autocomplete-plugin.d.ts +39 -0
- package/dist/types/pm-plugins/canonical-lm-scoring.d.ts +158 -0
- package/dist/types/pm-plugins/debug-mode.d.ts +36 -1
- package/dist/types/pm-plugins/ghost-text-decoration.d.ts +5 -2
- package/dist/types/pm-plugins/local-slow-lane-client.d.ts +87 -54
- package/dist/types/pm-plugins/scoring-pipeline.d.ts +33 -1
- package/dist/types/pm-plugins/slow-lane-client.d.ts +51 -3
- package/dist/types/pm-plugins/text-predictor.d.ts +120 -2
- package/package.json +2 -2
- package/src/analytics/ufo.ts +5 -0
- package/src/pm-plugins/artifact-loader.ts +92 -0
- package/src/pm-plugins/artifacts-manifest.ts +3 -0
- package/src/pm-plugins/autocomplete-plugin.ts +517 -133
- package/src/pm-plugins/canonical-lm-scoring.ts +412 -0
- package/src/pm-plugins/debug-mode.ts +109 -7
- package/src/pm-plugins/ghost-text-decoration.ts +13 -4
- package/src/pm-plugins/local-slow-lane-client.ts +1302 -386
- package/src/pm-plugins/scoring-pipeline.ts +167 -17
- package/src/pm-plugins/slow-lane-client.ts +147 -62
- package/src/pm-plugins/text-predictor.ts +2006 -255
- package/CANONICAL_FIX__DO_NOT_USE_ME_A/package.json +0 -8
- package/CANONICAL_FIX__DO_NOT_USE_ME_B/package.json +0 -8
- package/CANONICAL_FIX__DO_NOT_USE_ME_C/package.json +0 -8
- package/dist/cjs/entry-points/src-pm-plugins-autocomplete-plugin.js +0 -18
- package/dist/cjs/entry-points/src-pm-plugins-slow-lane-client.js +0 -36
- package/dist/cjs/entry-points/src-pm-plugins-text-predictor.js +0 -66
- package/dist/es2019/entry-points/src-pm-plugins-autocomplete-plugin.js +0 -2
- package/dist/es2019/entry-points/src-pm-plugins-slow-lane-client.js +0 -2
- package/dist/es2019/entry-points/src-pm-plugins-text-predictor.js +0 -2
- package/dist/esm/entry-points/src-pm-plugins-autocomplete-plugin.js +0 -2
- package/dist/esm/entry-points/src-pm-plugins-slow-lane-client.js +0 -2
- package/dist/esm/entry-points/src-pm-plugins-text-predictor.js +0 -2
- package/dist/types/entry-points/src-pm-plugins-autocomplete-plugin.d.ts +0 -2
- package/dist/types/entry-points/src-pm-plugins-slow-lane-client.d.ts +0 -2
- package/dist/types/entry-points/src-pm-plugins-text-predictor.d.ts +0 -2
- package/scripts/gen_first_token_to_words.py +0 -170
- package/src/entry-points/src-pm-plugins-autocomplete-plugin.ts +0 -7
- package/src/entry-points/src-pm-plugins-slow-lane-client.ts +0 -13
- package/src/entry-points/src-pm-plugins-text-predictor.ts +0 -14
- package/src/pm-plugins/autocomplete-plugin/package.json +0 -8
- package/src/pm-plugins/slow-lane-client/package.json +0 -8
- 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',
|