@atlaskit/editor-plugin-autocomplete 2.5.2 → 3.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.
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-autocomplete/CANONICAL_FIX__DO_NOT_USE_ME_A",
3
+ "main": "../dist/cjs/pm-plugins/autocomplete-plugin.js",
4
+ "module": "../dist/esm/pm-plugins/autocomplete-plugin.js",
5
+ "module:es2019": "../dist/es2019/pm-plugins/autocomplete-plugin.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/pm-plugins/autocomplete-plugin.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <5.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/pm-plugins/autocomplete-plugin.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-autocomplete/CANONICAL_FIX__DO_NOT_USE_ME_B",
3
+ "main": "../dist/cjs/pm-plugins/slow-lane-client.js",
4
+ "module": "../dist/esm/pm-plugins/slow-lane-client.js",
5
+ "module:es2019": "../dist/es2019/pm-plugins/slow-lane-client.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/pm-plugins/slow-lane-client.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <5.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/pm-plugins/slow-lane-client.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-autocomplete/CANONICAL_FIX__DO_NOT_USE_ME_C",
3
+ "main": "../dist/cjs/pm-plugins/text-predictor.js",
4
+ "module": "../dist/esm/pm-plugins/text-predictor.js",
5
+ "module:es2019": "../dist/es2019/pm-plugins/text-predictor.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/pm-plugins/text-predictor.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <5.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/pm-plugins/text-predictor.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-autocomplete
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
3
9
  ## 2.5.2
4
10
 
5
11
  ### Patch Changes
@@ -18,7 +18,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
18
18
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
19
19
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
20
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); } /**
21
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); } /**
22
22
  * Local Slow Lane Client: On-device inference via @mlc-ai/web-llm.
23
23
  *
24
24
  * Drop-in replacement for the network-based slow-lane-client. Instead of
@@ -127,8 +127,8 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
127
127
  };
128
128
  var initEngine = /*#__PURE__*/function () {
129
129
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
130
- var _yield$import, CreateMLCEngine, prebuiltAppConfig, customModelRecord, appConfig, errorMsg;
131
- return _regenerator.default.wrap(function _callee$(_context) {
130
+ var _yield$import, CreateMLCEngine, prebuiltAppConfig, customModelRecord, appConfig, errorMsg, _t;
131
+ return _regenerator.default.wrap(function (_context) {
132
132
  while (1) switch (_context.prev = _context.next) {
133
133
  case 0:
134
134
  _context.prev = 0;
@@ -138,16 +138,16 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
138
138
  }
139
139
  onStatus === null || onStatus === void 0 || onStatus("Initialising model: ".concat(modelId, "\u2026"));
140
140
  if ('gpu' in navigator) {
141
- _context.next = 5;
141
+ _context.next = 1;
142
142
  break;
143
143
  }
144
144
  throw new Error('WebGPU not supported');
145
- case 5:
146
- _context.next = 7;
145
+ case 1:
146
+ _context.next = 2;
147
147
  return Promise.resolve().then(function () {
148
148
  return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_editor-plugin-autocomplete-mlc-web-llm" */'@mlc-ai/web-llm'));
149
149
  });
150
- case 7:
150
+ case 2:
151
151
  _yield$import = _context.sent;
152
152
  CreateMLCEngine = _yield$import.CreateMLCEngine;
153
153
  prebuiltAppConfig = _yield$import.prebuiltAppConfig;
@@ -167,34 +167,34 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
167
167
  appConfig = {
168
168
  model_list: [].concat((0, _toConsumableArray2.default)(prebuiltAppConfig.model_list), (0, _toConsumableArray2.default)(customModelRecord ? [customModelRecord] : []))
169
169
  };
170
- _context.next = 14;
170
+ _context.next = 3;
171
171
  return CreateMLCEngine(modelId, {
172
172
  appConfig: appConfig,
173
173
  initProgressCallback: initProgressCallback
174
174
  });
175
- case 14:
175
+ case 3:
176
176
  engine = _context.sent;
177
177
  if (!destroyed) {
178
- _context.next = 19;
178
+ _context.next = 4;
179
179
  break;
180
180
  }
181
181
  // destroy() was called while we were loading — clean up
182
182
  unloadEngine(engine);
183
183
  engine = null;
184
184
  return _context.abrupt("return");
185
- case 19:
185
+ case 4:
186
186
  ready = true;
187
187
  if ((0, _debugMode.isAutocompleteDebugEnabled)()) {
188
188
  // eslint-disable-next-line no-console
189
189
  console.log('%c[LocalSlowLane] %c✅ MLC engine loaded and ready', 'color: #9c27b0; font-weight: bold;', 'color: #4caf50;');
190
190
  }
191
191
  onStatus === null || onStatus === void 0 || onStatus('Model loaded and ready.');
192
- _context.next = 32;
192
+ _context.next = 6;
193
193
  break;
194
- case 24:
195
- _context.prev = 24;
196
- _context.t0 = _context["catch"](0);
197
- errorMsg = _context.t0 instanceof Error ? _context.t0.message : String(_context.t0);
194
+ case 5:
195
+ _context.prev = 5;
196
+ _t = _context["catch"](0);
197
+ errorMsg = _t instanceof Error ? _t.message : String(_t);
198
198
  ready = false;
199
199
  if ((0, _debugMode.isAutocompleteDebugEnabled)()) {
200
200
  // eslint-disable-next-line no-console
@@ -203,11 +203,11 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
203
203
  onStatus === null || onStatus === void 0 || onStatus("Engine initialisation failed: ".concat(errorMsg));
204
204
  engineInitPromise = null;
205
205
  initFailed = true;
206
- case 32:
206
+ case 6:
207
207
  case "end":
208
208
  return _context.stop();
209
209
  }
210
- }, _callee, null, [[0, 24]]);
210
+ }, _callee, null, [[0, 5]]);
211
211
  }));
212
212
  return function initEngine() {
213
213
  return _ref.apply(this, arguments);
@@ -234,18 +234,18 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
234
234
  */
235
235
  var runInference = /*#__PURE__*/function () {
236
236
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(text, requestId) {
237
- var _response$choices, response, lmLogits, logprobsContent, tokenLogprobs, token, _iterator, _step, alt, _token, logitValues, topTokens, errorMsg;
238
- return _regenerator.default.wrap(function _callee2$(_context2) {
237
+ var _response$choices, response, lmLogits, logprobsContent, tokenLogprobs, token, _iterator, _step, alt, _token, logitValues, topTokens, errorMsg, _t2;
238
+ return _regenerator.default.wrap(function (_context2) {
239
239
  while (1) switch (_context2.prev = _context2.next) {
240
240
  case 0:
241
241
  if (!(!engine || destroyed)) {
242
- _context2.next = 2;
242
+ _context2.next = 1;
243
243
  break;
244
244
  }
245
245
  return _context2.abrupt("return");
246
- case 2:
247
- _context2.prev = 2;
248
- _context2.next = 5;
246
+ case 1:
247
+ _context2.prev = 1;
248
+ _context2.next = 2;
249
249
  return engine.chat.completions.create({
250
250
  messages: [{
251
251
  role: 'user',
@@ -256,14 +256,14 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
256
256
  top_logprobs: 5,
257
257
  temperature: 0
258
258
  });
259
- case 5:
259
+ case 2:
260
260
  response = _context2.sent;
261
261
  if (!(requestId < latestRequestId || destroyed)) {
262
- _context2.next = 8;
262
+ _context2.next = 3;
263
263
  break;
264
264
  }
265
265
  return _context2.abrupt("return");
266
- case 8:
266
+ case 3:
267
267
  // ── Extract LM logits ───────────────────────────────────────
268
268
  lmLogits = {};
269
269
  logprobsContent = (_response$choices = response.choices) === null || _response$choices === void 0 || (_response$choices = _response$choices[0]) === null || _response$choices === void 0 || (_response$choices = _response$choices.logprobs) === null || _response$choices === void 0 ? void 0 : _response$choices.content;
@@ -341,17 +341,17 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
341
341
  hasVector: storedContextVector !== null,
342
342
  hasLmLogits: storedLmLogits !== null
343
343
  });
344
- _context2.next = 26;
344
+ _context2.next = 6;
345
345
  break;
346
- case 17:
347
- _context2.prev = 17;
348
- _context2.t0 = _context2["catch"](2);
346
+ case 4:
347
+ _context2.prev = 4;
348
+ _t2 = _context2["catch"](1);
349
349
  if (!(requestId < latestRequestId)) {
350
- _context2.next = 21;
350
+ _context2.next = 5;
351
351
  break;
352
352
  }
353
353
  return _context2.abrupt("return");
354
- case 21:
354
+ case 5:
355
355
  storedContextVector = null;
356
356
  storedLmLogits = null;
357
357
  onUpdate === null || onUpdate === void 0 || onUpdate({
@@ -359,16 +359,16 @@ var createLocalSlowLaneClient = exports.createLocalSlowLaneClient = function cre
359
359
  hasVector: false,
360
360
  hasLmLogits: false
361
361
  });
362
- errorMsg = _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0);
362
+ errorMsg = _t2 instanceof Error ? _t2.message : String(_t2);
363
363
  if ((0, _debugMode.isAutocompleteDebugEnabled)()) {
364
364
  // eslint-disable-next-line no-console
365
365
  console.log("%c[LocalSlowLane] %c\u274C Inference error (request #".concat(requestId, "): ").concat(errorMsg), 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
366
366
  }
367
- case 26:
367
+ case 6:
368
368
  case "end":
369
369
  return _context2.stop();
370
370
  }
371
- }, _callee2, null, [[2, 17]]);
371
+ }, _callee2, null, [[1, 4]]);
372
372
  }));
373
373
  return function runInference(_x, _x2) {
374
374
  return _ref2.apply(this, arguments);
@@ -70,16 +70,16 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
70
70
  var inflightRequestId = null;
71
71
  var doUpdateContext = /*#__PURE__*/function () {
72
72
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(text, requestId) {
73
- var url, payload, res, data;
74
- return _regenerator.default.wrap(function _callee$(_context) {
73
+ var url, payload, res, data, _t;
74
+ return _regenerator.default.wrap(function (_context) {
75
75
  while (1) switch (_context.prev = _context.next) {
76
76
  case 0:
77
77
  if (!(!text || text.trim().length === 0)) {
78
- _context.next = 2;
78
+ _context.next = 1;
79
79
  break;
80
80
  }
81
81
  return _context.abrupt("return");
82
- case 2:
82
+ case 1:
83
83
  // eslint-disable-next-line require-unicode-regexp
84
84
  url = "".concat(baseUrl.replace(/\/$/, '')).concat(endpoint);
85
85
  payload = {
@@ -99,17 +99,17 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
99
99
  // eslint-disable-next-line no-console
100
100
  console.groupEnd();
101
101
  }
102
- _context.prev = 6;
103
- _context.next = 9;
102
+ _context.prev = 2;
103
+ _context.next = 3;
104
104
  return fetchFn(url, {
105
105
  method: 'POST',
106
106
  headers: headers,
107
107
  body: JSON.stringify(payload)
108
108
  });
109
- case 9:
109
+ case 3:
110
110
  res = _context.sent;
111
111
  if (res.ok) {
112
- _context.next = 16;
112
+ _context.next = 4;
113
113
  break;
114
114
  }
115
115
  storedContextVector = null;
@@ -123,10 +123,10 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
123
123
  console.log("%c[SlowLane] %c\u274C Request failed (".concat(res.status, ")"), 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
124
124
  }
125
125
  return _context.abrupt("return");
126
- case 16:
127
- _context.next = 18;
126
+ case 4:
127
+ _context.next = 5;
128
128
  return res.json();
129
- case 18:
129
+ case 5:
130
130
  data = _context.sent;
131
131
  if (data.semantic_vector && Array.isArray(data.semantic_vector)) {
132
132
  storedContextVector = new Float32Array(data.semantic_vector);
@@ -159,11 +159,11 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
159
159
  hasLmLogits: storedLmLogits !== null
160
160
  });
161
161
  // eslint-disable-next-line no-unused-vars
162
- _context.next = 32;
162
+ _context.next = 7;
163
163
  break;
164
- case 26:
165
- _context.prev = 26;
166
- _context.t0 = _context["catch"](6);
164
+ case 6:
165
+ _context.prev = 6;
166
+ _t = _context["catch"](2);
167
167
  storedContextVector = null;
168
168
  storedLmLogits = null;
169
169
  (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
@@ -173,17 +173,17 @@ var createSlowLaneClient = exports.createSlowLaneClient = function createSlowLan
173
173
  // eslint-disable-next-line no-console
174
174
  console.log('%c[SlowLane] %c❌ Network error — context cleared', 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
175
175
  }
176
- case 32:
177
- _context.prev = 32;
176
+ case 7:
177
+ _context.prev = 7;
178
178
  if (inflightRequestId === requestId) {
179
179
  inflightRequestId = null;
180
180
  }
181
- return _context.finish(32);
182
- case 35:
181
+ return _context.finish(7);
182
+ case 8:
183
183
  case "end":
184
184
  return _context.stop();
185
185
  }
186
- }, _callee, null, [[6, 26, 32, 35]]);
186
+ }, _callee, null, [[2, 6, 7, 8]]);
187
187
  }));
188
188
  return function doUpdateContext(_x, _x2) {
189
189
  return _ref.apply(this, arguments);
@@ -691,51 +691,51 @@ var predict = exports.predict = function predict(textBefore) {
691
691
 
692
692
  var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
693
693
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
694
- var url, res, buffer, float32, wordIndex, nWords, dim;
695
- return _regenerator.default.wrap(function _callee$(_context) {
694
+ var url, res, buffer, float32, wordIndex, nWords, dim, _t, _t2;
695
+ return _regenerator.default.wrap(function (_context) {
696
696
  while (1) switch (_context.prev = _context.next) {
697
697
  case 0:
698
698
  if (!(vectorStore || vectorsLoadStarted)) {
699
- _context.next = 2;
699
+ _context.next = 1;
700
700
  break;
701
701
  }
702
702
  return _context.abrupt("return");
703
- case 2:
703
+ case 1:
704
704
  if (options !== null && options !== void 0 && options.getBinaryUrl) {
705
- _context.next = 5;
705
+ _context.next = 2;
706
706
  break;
707
707
  }
708
708
  // eslint-disable-next-line no-console
709
709
  console.warn('[text-predictor] loadVectorsAsync called without a getBinaryUrl — vectors will not load. Pass getVectorsBinaryUrl via plugin options.');
710
710
  return _context.abrupt("return");
711
- case 5:
711
+ case 2:
712
712
  vectorsLoadStarted = true;
713
713
  (0, _ufo.startExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton');
714
- _context.prev = 7;
715
- _context.next = 10;
714
+ _context.prev = 3;
715
+ _context.next = 4;
716
716
  return options.getBinaryUrl();
717
- case 10:
717
+ case 4:
718
718
  url = _context.sent;
719
- _context.next = 19;
719
+ _context.next = 6;
720
720
  break;
721
- case 13:
722
- _context.prev = 13;
723
- _context.t0 = _context["catch"](7);
721
+ case 5:
722
+ _context.prev = 5;
723
+ _t = _context["catch"](3);
724
724
  vectorsLoadStarted = false;
725
725
  (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
726
726
  errorType: 'resolve_url'
727
727
  });
728
728
  // eslint-disable-next-line no-console
729
- console.warn('[text-predictor] Failed to resolve vectors URL:', _context.t0);
729
+ console.warn('[text-predictor] Failed to resolve vectors URL:', _t);
730
730
  return _context.abrupt("return");
731
- case 19:
732
- _context.prev = 19;
733
- _context.next = 22;
731
+ case 6:
732
+ _context.prev = 6;
733
+ _context.next = 7;
734
734
  return fetch(url);
735
- case 22:
735
+ case 7:
736
736
  res = _context.sent;
737
737
  if (res.ok) {
738
- _context.next = 28;
738
+ _context.next = 8;
739
739
  break;
740
740
  }
741
741
  vectorsLoadStarted = false;
@@ -746,10 +746,10 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
746
746
  // eslint-disable-next-line no-console
747
747
  console.warn("[text-predictor] Failed to load vectors: ".concat(res.status));
748
748
  return _context.abrupt("return");
749
- case 28:
750
- _context.next = 30;
749
+ case 8:
750
+ _context.next = 9;
751
751
  return res.arrayBuffer();
752
- case 30:
752
+ case 9:
753
753
  buffer = _context.sent;
754
754
  float32 = new Float32Array(buffer);
755
755
  wordIndex = _word_index_10k.default;
@@ -773,22 +773,22 @@ var loadVectorsAsync = exports.loadVectorsAsync = /*#__PURE__*/function () {
773
773
  sizeBytes: float32.byteLength
774
774
  });
775
775
  }
776
- _context.next = 45;
776
+ _context.next = 11;
777
777
  break;
778
- case 40:
779
- _context.prev = 40;
780
- _context.t1 = _context["catch"](19);
778
+ case 10:
779
+ _context.prev = 10;
780
+ _t2 = _context["catch"](6);
781
781
  vectorsLoadStarted = false;
782
782
  (0, _ufo.failExp)(_ufo.EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
783
783
  errorType: 'network'
784
784
  });
785
785
  // eslint-disable-next-line no-console
786
- console.warn('[text-predictor] Failed to load vectors:', _context.t1);
787
- case 45:
786
+ console.warn('[text-predictor] Failed to load vectors:', _t2);
787
+ case 11:
788
788
  case "end":
789
789
  return _context.stop();
790
790
  }
791
- }, _callee, null, [[7, 13], [19, 40]]);
791
+ }, _callee, null, [[3, 5], [6, 10]]);
792
792
  }));
793
793
  return function loadVectorsAsync(_x) {
794
794
  return _ref6.apply(this, arguments);
@@ -121,8 +121,8 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
121
121
  };
122
122
  var initEngine = /*#__PURE__*/function () {
123
123
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
124
- var _yield$import, CreateMLCEngine, prebuiltAppConfig, customModelRecord, appConfig, errorMsg;
125
- return _regeneratorRuntime.wrap(function _callee$(_context) {
124
+ var _yield$import, CreateMLCEngine, prebuiltAppConfig, customModelRecord, appConfig, errorMsg, _t;
125
+ return _regeneratorRuntime.wrap(function (_context) {
126
126
  while (1) switch (_context.prev = _context.next) {
127
127
  case 0:
128
128
  _context.prev = 0;
@@ -132,14 +132,14 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
132
132
  }
133
133
  onStatus === null || onStatus === void 0 || onStatus("Initialising model: ".concat(modelId, "\u2026"));
134
134
  if ('gpu' in navigator) {
135
- _context.next = 5;
135
+ _context.next = 1;
136
136
  break;
137
137
  }
138
138
  throw new Error('WebGPU not supported');
139
- case 5:
140
- _context.next = 7;
139
+ case 1:
140
+ _context.next = 2;
141
141
  return import( /* webpackChunkName: "@atlaskit-internal_editor-plugin-autocomplete-mlc-web-llm" */'@mlc-ai/web-llm');
142
- case 7:
142
+ case 2:
143
143
  _yield$import = _context.sent;
144
144
  CreateMLCEngine = _yield$import.CreateMLCEngine;
145
145
  prebuiltAppConfig = _yield$import.prebuiltAppConfig;
@@ -159,34 +159,34 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
159
159
  appConfig = {
160
160
  model_list: [].concat(_toConsumableArray(prebuiltAppConfig.model_list), _toConsumableArray(customModelRecord ? [customModelRecord] : []))
161
161
  };
162
- _context.next = 14;
162
+ _context.next = 3;
163
163
  return CreateMLCEngine(modelId, {
164
164
  appConfig: appConfig,
165
165
  initProgressCallback: initProgressCallback
166
166
  });
167
- case 14:
167
+ case 3:
168
168
  engine = _context.sent;
169
169
  if (!destroyed) {
170
- _context.next = 19;
170
+ _context.next = 4;
171
171
  break;
172
172
  }
173
173
  // destroy() was called while we were loading — clean up
174
174
  unloadEngine(engine);
175
175
  engine = null;
176
176
  return _context.abrupt("return");
177
- case 19:
177
+ case 4:
178
178
  ready = true;
179
179
  if (isAutocompleteDebugEnabled()) {
180
180
  // eslint-disable-next-line no-console
181
181
  console.log('%c[LocalSlowLane] %c✅ MLC engine loaded and ready', 'color: #9c27b0; font-weight: bold;', 'color: #4caf50;');
182
182
  }
183
183
  onStatus === null || onStatus === void 0 || onStatus('Model loaded and ready.');
184
- _context.next = 32;
184
+ _context.next = 6;
185
185
  break;
186
- case 24:
187
- _context.prev = 24;
188
- _context.t0 = _context["catch"](0);
189
- errorMsg = _context.t0 instanceof Error ? _context.t0.message : String(_context.t0);
186
+ case 5:
187
+ _context.prev = 5;
188
+ _t = _context["catch"](0);
189
+ errorMsg = _t instanceof Error ? _t.message : String(_t);
190
190
  ready = false;
191
191
  if (isAutocompleteDebugEnabled()) {
192
192
  // eslint-disable-next-line no-console
@@ -195,11 +195,11 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
195
195
  onStatus === null || onStatus === void 0 || onStatus("Engine initialisation failed: ".concat(errorMsg));
196
196
  engineInitPromise = null;
197
197
  initFailed = true;
198
- case 32:
198
+ case 6:
199
199
  case "end":
200
200
  return _context.stop();
201
201
  }
202
- }, _callee, null, [[0, 24]]);
202
+ }, _callee, null, [[0, 5]]);
203
203
  }));
204
204
  return function initEngine() {
205
205
  return _ref.apply(this, arguments);
@@ -226,18 +226,18 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
226
226
  */
227
227
  var runInference = /*#__PURE__*/function () {
228
228
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(text, requestId) {
229
- var _response$choices, response, lmLogits, logprobsContent, tokenLogprobs, token, _iterator, _step, alt, _token, logitValues, topTokens, errorMsg;
230
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
229
+ var _response$choices, response, lmLogits, logprobsContent, tokenLogprobs, token, _iterator, _step, alt, _token, logitValues, topTokens, errorMsg, _t2;
230
+ return _regeneratorRuntime.wrap(function (_context2) {
231
231
  while (1) switch (_context2.prev = _context2.next) {
232
232
  case 0:
233
233
  if (!(!engine || destroyed)) {
234
- _context2.next = 2;
234
+ _context2.next = 1;
235
235
  break;
236
236
  }
237
237
  return _context2.abrupt("return");
238
- case 2:
239
- _context2.prev = 2;
240
- _context2.next = 5;
238
+ case 1:
239
+ _context2.prev = 1;
240
+ _context2.next = 2;
241
241
  return engine.chat.completions.create({
242
242
  messages: [{
243
243
  role: 'user',
@@ -248,14 +248,14 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
248
248
  top_logprobs: 5,
249
249
  temperature: 0
250
250
  });
251
- case 5:
251
+ case 2:
252
252
  response = _context2.sent;
253
253
  if (!(requestId < latestRequestId || destroyed)) {
254
- _context2.next = 8;
254
+ _context2.next = 3;
255
255
  break;
256
256
  }
257
257
  return _context2.abrupt("return");
258
- case 8:
258
+ case 3:
259
259
  // ── Extract LM logits ───────────────────────────────────────
260
260
  lmLogits = {};
261
261
  logprobsContent = (_response$choices = response.choices) === null || _response$choices === void 0 || (_response$choices = _response$choices[0]) === null || _response$choices === void 0 || (_response$choices = _response$choices.logprobs) === null || _response$choices === void 0 ? void 0 : _response$choices.content;
@@ -333,17 +333,17 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
333
333
  hasVector: storedContextVector !== null,
334
334
  hasLmLogits: storedLmLogits !== null
335
335
  });
336
- _context2.next = 26;
336
+ _context2.next = 6;
337
337
  break;
338
- case 17:
339
- _context2.prev = 17;
340
- _context2.t0 = _context2["catch"](2);
338
+ case 4:
339
+ _context2.prev = 4;
340
+ _t2 = _context2["catch"](1);
341
341
  if (!(requestId < latestRequestId)) {
342
- _context2.next = 21;
342
+ _context2.next = 5;
343
343
  break;
344
344
  }
345
345
  return _context2.abrupt("return");
346
- case 21:
346
+ case 5:
347
347
  storedContextVector = null;
348
348
  storedLmLogits = null;
349
349
  onUpdate === null || onUpdate === void 0 || onUpdate({
@@ -351,16 +351,16 @@ export var createLocalSlowLaneClient = function createLocalSlowLaneClient() {
351
351
  hasVector: false,
352
352
  hasLmLogits: false
353
353
  });
354
- errorMsg = _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0);
354
+ errorMsg = _t2 instanceof Error ? _t2.message : String(_t2);
355
355
  if (isAutocompleteDebugEnabled()) {
356
356
  // eslint-disable-next-line no-console
357
357
  console.log("%c[LocalSlowLane] %c\u274C Inference error (request #".concat(requestId, "): ").concat(errorMsg), 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
358
358
  }
359
- case 26:
359
+ case 6:
360
360
  case "end":
361
361
  return _context2.stop();
362
362
  }
363
- }, _callee2, null, [[2, 17]]);
363
+ }, _callee2, null, [[1, 4]]);
364
364
  }));
365
365
  return function runInference(_x, _x2) {
366
366
  return _ref2.apply(this, arguments);
@@ -64,16 +64,16 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
64
64
  var inflightRequestId = null;
65
65
  var doUpdateContext = /*#__PURE__*/function () {
66
66
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(text, requestId) {
67
- var url, payload, res, data;
68
- return _regeneratorRuntime.wrap(function _callee$(_context) {
67
+ var url, payload, res, data, _t;
68
+ return _regeneratorRuntime.wrap(function (_context) {
69
69
  while (1) switch (_context.prev = _context.next) {
70
70
  case 0:
71
71
  if (!(!text || text.trim().length === 0)) {
72
- _context.next = 2;
72
+ _context.next = 1;
73
73
  break;
74
74
  }
75
75
  return _context.abrupt("return");
76
- case 2:
76
+ case 1:
77
77
  // eslint-disable-next-line require-unicode-regexp
78
78
  url = "".concat(baseUrl.replace(/\/$/, '')).concat(endpoint);
79
79
  payload = {
@@ -93,17 +93,17 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
93
93
  // eslint-disable-next-line no-console
94
94
  console.groupEnd();
95
95
  }
96
- _context.prev = 6;
97
- _context.next = 9;
96
+ _context.prev = 2;
97
+ _context.next = 3;
98
98
  return fetchFn(url, {
99
99
  method: 'POST',
100
100
  headers: headers,
101
101
  body: JSON.stringify(payload)
102
102
  });
103
- case 9:
103
+ case 3:
104
104
  res = _context.sent;
105
105
  if (res.ok) {
106
- _context.next = 16;
106
+ _context.next = 4;
107
107
  break;
108
108
  }
109
109
  storedContextVector = null;
@@ -117,10 +117,10 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
117
117
  console.log("%c[SlowLane] %c\u274C Request failed (".concat(res.status, ")"), 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
118
118
  }
119
119
  return _context.abrupt("return");
120
- case 16:
121
- _context.next = 18;
120
+ case 4:
121
+ _context.next = 5;
122
122
  return res.json();
123
- case 18:
123
+ case 5:
124
124
  data = _context.sent;
125
125
  if (data.semantic_vector && Array.isArray(data.semantic_vector)) {
126
126
  storedContextVector = new Float32Array(data.semantic_vector);
@@ -153,11 +153,11 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
153
153
  hasLmLogits: storedLmLogits !== null
154
154
  });
155
155
  // eslint-disable-next-line no-unused-vars
156
- _context.next = 32;
156
+ _context.next = 7;
157
157
  break;
158
- case 26:
159
- _context.prev = 26;
160
- _context.t0 = _context["catch"](6);
158
+ case 6:
159
+ _context.prev = 6;
160
+ _t = _context["catch"](2);
161
161
  storedContextVector = null;
162
162
  storedLmLogits = null;
163
163
  failExp(EXPERIENCE_NAME.SLOW_LANE_FETCH, requestId, {
@@ -167,17 +167,17 @@ export var createSlowLaneClient = function createSlowLaneClient(config) {
167
167
  // eslint-disable-next-line no-console
168
168
  console.log('%c[SlowLane] %c❌ Network error — context cleared', 'color: #9c27b0; font-weight: bold;', 'color: #f44336;');
169
169
  }
170
- case 32:
171
- _context.prev = 32;
170
+ case 7:
171
+ _context.prev = 7;
172
172
  if (inflightRequestId === requestId) {
173
173
  inflightRequestId = null;
174
174
  }
175
- return _context.finish(32);
176
- case 35:
175
+ return _context.finish(7);
176
+ case 8:
177
177
  case "end":
178
178
  return _context.stop();
179
179
  }
180
- }, _callee, null, [[6, 26, 32, 35]]);
180
+ }, _callee, null, [[2, 6, 7, 8]]);
181
181
  }));
182
182
  return function doUpdateContext(_x, _x2) {
183
183
  return _ref.apply(this, arguments);
@@ -689,51 +689,51 @@ export var predict = function predict(textBefore) {
689
689
 
690
690
  export var loadVectorsAsync = /*#__PURE__*/function () {
691
691
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
692
- var url, res, buffer, float32, wordIndex, nWords, dim;
693
- return _regeneratorRuntime.wrap(function _callee$(_context) {
692
+ var url, res, buffer, float32, wordIndex, nWords, dim, _t, _t2;
693
+ return _regeneratorRuntime.wrap(function (_context) {
694
694
  while (1) switch (_context.prev = _context.next) {
695
695
  case 0:
696
696
  if (!(vectorStore || vectorsLoadStarted)) {
697
- _context.next = 2;
697
+ _context.next = 1;
698
698
  break;
699
699
  }
700
700
  return _context.abrupt("return");
701
- case 2:
701
+ case 1:
702
702
  if (options !== null && options !== void 0 && options.getBinaryUrl) {
703
- _context.next = 5;
703
+ _context.next = 2;
704
704
  break;
705
705
  }
706
706
  // eslint-disable-next-line no-console
707
707
  console.warn('[text-predictor] loadVectorsAsync called without a getBinaryUrl — vectors will not load. Pass getVectorsBinaryUrl via plugin options.');
708
708
  return _context.abrupt("return");
709
- case 5:
709
+ case 2:
710
710
  vectorsLoadStarted = true;
711
711
  startExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton');
712
- _context.prev = 7;
713
- _context.next = 10;
712
+ _context.prev = 3;
713
+ _context.next = 4;
714
714
  return options.getBinaryUrl();
715
- case 10:
715
+ case 4:
716
716
  url = _context.sent;
717
- _context.next = 19;
717
+ _context.next = 6;
718
718
  break;
719
- case 13:
720
- _context.prev = 13;
721
- _context.t0 = _context["catch"](7);
719
+ case 5:
720
+ _context.prev = 5;
721
+ _t = _context["catch"](3);
722
722
  vectorsLoadStarted = false;
723
723
  failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
724
724
  errorType: 'resolve_url'
725
725
  });
726
726
  // eslint-disable-next-line no-console
727
- console.warn('[text-predictor] Failed to resolve vectors URL:', _context.t0);
727
+ console.warn('[text-predictor] Failed to resolve vectors URL:', _t);
728
728
  return _context.abrupt("return");
729
- case 19:
730
- _context.prev = 19;
731
- _context.next = 22;
729
+ case 6:
730
+ _context.prev = 6;
731
+ _context.next = 7;
732
732
  return fetch(url);
733
- case 22:
733
+ case 7:
734
734
  res = _context.sent;
735
735
  if (res.ok) {
736
- _context.next = 28;
736
+ _context.next = 8;
737
737
  break;
738
738
  }
739
739
  vectorsLoadStarted = false;
@@ -744,10 +744,10 @@ export var loadVectorsAsync = /*#__PURE__*/function () {
744
744
  // eslint-disable-next-line no-console
745
745
  console.warn("[text-predictor] Failed to load vectors: ".concat(res.status));
746
746
  return _context.abrupt("return");
747
- case 28:
748
- _context.next = 30;
747
+ case 8:
748
+ _context.next = 9;
749
749
  return res.arrayBuffer();
750
- case 30:
750
+ case 9:
751
751
  buffer = _context.sent;
752
752
  float32 = new Float32Array(buffer);
753
753
  wordIndex = wordIndexData;
@@ -771,22 +771,22 @@ export var loadVectorsAsync = /*#__PURE__*/function () {
771
771
  sizeBytes: float32.byteLength
772
772
  });
773
773
  }
774
- _context.next = 45;
774
+ _context.next = 11;
775
775
  break;
776
- case 40:
777
- _context.prev = 40;
778
- _context.t1 = _context["catch"](19);
776
+ case 10:
777
+ _context.prev = 10;
778
+ _t2 = _context["catch"](6);
779
779
  vectorsLoadStarted = false;
780
780
  failExp(EXPERIENCE_NAME.LOAD_VECTORS, 'singleton', {
781
781
  errorType: 'network'
782
782
  });
783
783
  // eslint-disable-next-line no-console
784
- console.warn('[text-predictor] Failed to load vectors:', _context.t1);
785
- case 45:
784
+ console.warn('[text-predictor] Failed to load vectors:', _t2);
785
+ case 11:
786
786
  case "end":
787
787
  return _context.stop();
788
788
  }
789
- }, _callee, null, [[7, 13], [19, 40]]);
789
+ }, _callee, null, [[3, 5], [6, 10]]);
790
790
  }));
791
791
  return function loadVectorsAsync(_x) {
792
792
  return _ref6.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-autocomplete",
3
- "version": "2.5.2",
3
+ "version": "3.0.0",
4
4
  "description": "Client-side text autocomplete plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -35,8 +35,8 @@
35
35
  "wink-nlp": "^2.4.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@atlaskit/editor-common": "^114.47.0",
39
- "@atlaskit/editor-plugin-analytics": "^10.1.0",
38
+ "@atlaskit/editor-common": "^115.0.0",
39
+ "@atlaskit/editor-plugin-analytics": "^11.0.0",
40
40
  "react": "^18.2.0"
41
41
  },
42
42
  "techstack": {