@lvce-editor/extension-search-view 3.3.0 → 3.4.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.
@@ -1146,6 +1146,28 @@ const create$1 = () => {
1146
1146
  return Object.keys(states).map(key => {
1147
1147
  return Number.parseInt(key);
1148
1148
  });
1149
+ },
1150
+ clear() {
1151
+ for (const key of Object.keys(states)) {
1152
+ delete states[key];
1153
+ }
1154
+ },
1155
+ wrapCommand(fn) {
1156
+ const wrapped = async (uid, ...args) => {
1157
+ const {
1158
+ newState
1159
+ } = states[uid];
1160
+ const newerState = await fn(newState, ...args);
1161
+ if (newState === newerState) {
1162
+ return;
1163
+ }
1164
+ const latest = states[uid];
1165
+ states[uid] = {
1166
+ oldState: latest.oldState,
1167
+ newState: newerState
1168
+ };
1169
+ };
1170
+ return wrapped;
1149
1171
  }
1150
1172
  };
1151
1173
  };
@@ -1153,7 +1175,9 @@ const create$1 = () => {
1153
1175
  const {
1154
1176
  get: get$1,
1155
1177
  set: set$1,
1156
- dispose: dispose$1} = create$1();
1178
+ dispose: dispose$1,
1179
+ wrapCommand
1180
+ } = create$1();
1157
1181
 
1158
1182
  const create = (id, uri, x, y, width, height, platform, assetDir) => {
1159
1183
  const state = {
@@ -1975,14 +1999,16 @@ const getSearchFieldButtonVirtualDom = button => {
1975
1999
  const {
1976
2000
  icon,
1977
2001
  title,
1978
- enabled
2002
+ enabled,
2003
+ onClick
1979
2004
  } = button;
1980
2005
  return [{
1981
2006
  type: Div,
1982
2007
  className: getClassName$1(enabled),
1983
2008
  title,
1984
2009
  tabIndex: 0,
1985
- childCount: 1
2010
+ childCount: 1,
2011
+ onClick
1986
2012
  }, {
1987
2013
  type: Div,
1988
2014
  className: mergeClassNames(MaskIcon, icon),
@@ -2037,7 +2063,7 @@ const getExtensionHeaderVirtualDom = (placeholder, actions) => {
2037
2063
  const getInputActions = newState => {
2038
2064
  const clearEnabled = newState.searchValue.length > 0;
2039
2065
  const actions = [{
2040
- command: HandleClearSearchResults,
2066
+ onClick: HandleClearSearchResults,
2041
2067
  icon: `MaskIcon${ClearAll}`,
2042
2068
  title: clearExtensionSearchResults(),
2043
2069
  type: Button$1,
@@ -2046,7 +2072,7 @@ const getInputActions = newState => {
2046
2072
  icon: `MaskIcon${Filter}`,
2047
2073
  title: filter(),
2048
2074
  type: Button$1,
2049
- command: HandleClickFilter,
2075
+ onClick: HandleClickFilter,
2050
2076
  enabled: true
2051
2077
  }];
2052
2078
  return actions;
@@ -2378,17 +2404,6 @@ const toggleSuggest = state => {
2378
2404
  return state;
2379
2405
  };
2380
2406
 
2381
- const wrapCommand = fn => {
2382
- const wrapped = async (uid, ...args) => {
2383
- const {
2384
- newState
2385
- } = get$1(uid);
2386
- const newerState = await fn(newState, ...args);
2387
- set$1(uid, newState, newerState);
2388
- };
2389
- return wrapped;
2390
- };
2391
-
2392
2407
  const commandMap = {
2393
2408
  'SearchExtensions.clearSearchResults': wrapCommand(clearSearchResults),
2394
2409
  'SearchExtensions.closeSuggest': wrapCommand(closeSuggest),
@@ -2404,6 +2419,7 @@ const commandMap = {
2404
2419
  'SearchExtensions.getActions': getActions,
2405
2420
  'SearchExtensions.getCommandIds': getCommandIds,
2406
2421
  'SearchExtensions.getKeyBindings': getKeyBindings,
2422
+ 'SearchExtensions.getMenuEntries': getMenuEntries,
2407
2423
  'SearchExtensions.handleBlur': wrapCommand(handleBlur),
2408
2424
  'SearchExtensions.handleClick': wrapCommand(handleClick),
2409
2425
  'SearchExtensions.handleClickAt': wrapCommand(handleClickAt),
@@ -2426,12 +2442,12 @@ const commandMap = {
2426
2442
  'SearchExtensions.render3': render3,
2427
2443
  'SearchExtensions.renderActions': renderActions,
2428
2444
  'SearchExtensions.renderEventListeners': renderEventListeners,
2445
+ 'SearchExtensions.restoreState': restoreState,
2429
2446
  'SearchExtensions.saveState': saveState,
2430
2447
  'SearchExtensions.scrollDown': wrapCommand(scrollDown),
2431
2448
  'SearchExtensions.searchExtensions': searchExtensions,
2432
2449
  'SearchExtensions.selectIndex': wrapCommand(selectIndex),
2433
2450
  'SearchExtensions.setDeltaY': wrapCommand(setDeltaY),
2434
- 'SearchExtensions.getMenuEntries': getMenuEntries,
2435
2451
  'SearchExtensions.terminate': terminate,
2436
2452
  'SearchExtensions.toggleSuggest': wrapCommand(toggleSuggest)
2437
2453
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "license": "MIT",
6
6
  "author": "Lvce Editor",