@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.
- package/CHANGELOG.md +8 -0
- package/afm-cc/tsconfig.json +1 -4
- package/afm-jira/tsconfig.json +1 -4
- package/afm-products/tsconfig.json +1 -4
- package/build/tsconfig.json +2 -6
- package/build/url-module.d.ts +8 -0
- package/dist/cjs/pm-plugins/autocomplete-plugin.js +11 -4
- package/dist/cjs/pm-plugins/scoring-pipeline.js +1 -3
- package/dist/cjs/pm-plugins/slow-lane-client.js +3 -1
- package/dist/cjs/pm-plugins/text-predictor.js +32 -22
- package/dist/es2019/pm-plugins/autocomplete-plugin.js +11 -3
- package/dist/es2019/pm-plugins/scoring-pipeline.js +0 -3
- package/dist/es2019/pm-plugins/slow-lane-client.js +5 -2
- package/dist/es2019/pm-plugins/text-predictor.js +16 -9
- package/dist/esm/pm-plugins/autocomplete-plugin.js +11 -3
- package/dist/esm/pm-plugins/scoring-pipeline.js +0 -3
- package/dist/esm/pm-plugins/slow-lane-client.js +3 -1
- package/dist/esm/pm-plugins/text-predictor.js +32 -22
- package/dist/types/pm-plugins/autocomplete-plugin.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts +1 -1
- package/package.json +1 -1
- package/src/pm-plugins/autocomplete-plugin.ts +19 -5
- package/src/pm-plugins/data/combined_l2_l3_pos_tags.json +73571 -3
- package/src/pm-plugins/data/ghost_pos_tags.json +43 -3
- package/src/pm-plugins/data/grammar_transitions_10k.json +46 -3
- package/src/pm-plugins/data/l3_vocabulary.json +20002 -3
- package/src/pm-plugins/data/vocabulary_10k.json +38794 -3
- package/src/pm-plugins/data/word_index_10k.json +7760 -3
- package/src/pm-plugins/scoring-pipeline.ts +0 -3
- package/src/pm-plugins/slow-lane-client.ts +4 -2
- package/src/pm-plugins/text-predictor.ts +18 -9
- package/tsconfig.app.json +3 -2
- package/tsconfig.json +2 -1
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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+/
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
"
|
|
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":
|
|
33
|
+
"resolveJsonModule": true
|
|
33
34
|
},
|
|
34
35
|
"references": [
|
|
35
36
|
{
|
package/tsconfig.json
CHANGED
|
@@ -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
|
-
}
|