@lvce-editor/text-search-view 1.18.0 → 1.19.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.
@@ -1445,7 +1445,8 @@ const create$2 = () => {
1445
1445
  const commandQueues = new Map();
1446
1446
  const generations = Object.create(null);
1447
1447
  const states = Object.create(null);
1448
- const commandMapRef = {};
1448
+ const commandMapRef = Object.create(null);
1449
+ const commandsById = Object.create(null);
1449
1450
  const getGeneration = uid => generations[uid] || 0;
1450
1451
  const isCurrentGeneration = (uid, generation) => {
1451
1452
  return states[uid] !== undefined && getGeneration(uid) === generation;
@@ -1507,6 +1508,18 @@ const create$2 = () => {
1507
1508
  delete states[key];
1508
1509
  }
1509
1510
  },
1511
+ createDirectEventCommandMap(requestRender) {
1512
+ return {
1513
+ async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
1514
+ const fn = commandsById[command];
1515
+ if (!fn) {
1516
+ throw new Error(`Viewlet command not found: ${command}`);
1517
+ }
1518
+ await fn(uid, ...args);
1519
+ await requestRender(uid);
1520
+ }
1521
+ };
1522
+ },
1510
1523
  diff(uid, modules, numbers) {
1511
1524
  const {
1512
1525
  oldState,
@@ -1538,6 +1551,9 @@ const create$2 = () => {
1538
1551
  },
1539
1552
  registerCommands(commandMap) {
1540
1553
  Object.assign(commandMapRef, commandMap);
1554
+ for (const [key, fn] of Object.entries(commandMap)) {
1555
+ commandsById[toCommandId(key)] = fn;
1556
+ }
1541
1557
  },
1542
1558
  set(uid, oldState, newState, scheduledState) {
1543
1559
  const current = states[uid];
@@ -3390,6 +3406,10 @@ const focusSearchValueNext = state => {
3390
3406
  return focusMatchCase$1(state);
3391
3407
  };
3392
3408
 
3409
+ const getComponentState = uid => {
3410
+ return get(uid).newState;
3411
+ };
3412
+
3393
3413
  const Tab = 2;
3394
3414
  const Enter = 3;
3395
3415
  const End = 255;
@@ -7370,6 +7390,23 @@ const focusReplaceAll = state => {
7370
7390
  return focusElement(state, FocusSearchReplaceAll);
7371
7391
  };
7372
7392
 
7393
+ const applyComponentState = (currentState, state) => {
7394
+ if (!state || typeof state !== 'object' || Array.isArray(state)) {
7395
+ throw new TypeError('Text Search state must be an object');
7396
+ }
7397
+ const {
7398
+ uid
7399
+ } = state;
7400
+ const {
7401
+ uid: currentUid
7402
+ } = currentState;
7403
+ if (uid !== currentUid) {
7404
+ throw new Error(`Text Search state uid must remain ${currentUid}`);
7405
+ }
7406
+ return state;
7407
+ };
7408
+ const setComponentState = wrapCommand(applyComponentState);
7409
+
7373
7410
  const setLimit = (state, limit) => {
7374
7411
  return handleUpdate(state, {
7375
7412
  limit
@@ -7496,6 +7533,7 @@ const commandMap$1 = {
7496
7533
  'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
7497
7534
  'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
7498
7535
  'TextSearch.getCommandIds': getCommandIds,
7536
+ 'TextSearch.getComponentState': getComponentState,
7499
7537
  'TextSearch.getKeyBindings': getKeyBindings,
7500
7538
  'TextSearch.getMenuEntries': wrapGetter(getMenuEntries),
7501
7539
  'TextSearch.getMenuEntryIds': getMenuEntryIds,
@@ -7553,6 +7591,7 @@ const commandMap$1 = {
7553
7591
  'TextSearch.restoreState': restoreState,
7554
7592
  'TextSearch.saveState': wrapGetter(saveState),
7555
7593
  'TextSearch.selectIndex': wrapCommand(selectIndex),
7594
+ 'TextSearch.setComponentState': setComponentState,
7556
7595
  'TextSearch.setLimit': wrapSerialCommand(setLimit),
7557
7596
  'TextSearch.submit': wrapSerialCommand(submit),
7558
7597
  'TextSearch.terminate': terminate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-view",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Text Search View",
5
5
  "keywords": [
6
6
  "text-search"