@lvce-editor/extension-detail-view 3.16.0 → 3.17.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.
|
@@ -430,7 +430,7 @@ const set$2 = (id, fn) => {
|
|
|
430
430
|
const get$2 = id => {
|
|
431
431
|
return callbacks[id];
|
|
432
432
|
};
|
|
433
|
-
const remove = id => {
|
|
433
|
+
const remove$1 = id => {
|
|
434
434
|
delete callbacks[id];
|
|
435
435
|
};
|
|
436
436
|
let id$1 = 0;
|
|
@@ -607,7 +607,7 @@ const resolve = (id, response) => {
|
|
|
607
607
|
return;
|
|
608
608
|
}
|
|
609
609
|
fn(response);
|
|
610
|
-
remove(id);
|
|
610
|
+
remove$1(id);
|
|
611
611
|
};
|
|
612
612
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
613
613
|
const getErrorType = prettyError => {
|
|
@@ -853,13 +853,17 @@ const create$1 = () => {
|
|
|
853
853
|
oldState,
|
|
854
854
|
newState
|
|
855
855
|
};
|
|
856
|
+
},
|
|
857
|
+
remove(uid) {
|
|
858
|
+
delete states[uid];
|
|
856
859
|
}
|
|
857
860
|
};
|
|
858
861
|
};
|
|
859
862
|
|
|
860
863
|
const {
|
|
861
864
|
get: get$1,
|
|
862
|
-
set: set$1
|
|
865
|
+
set: set$1,
|
|
866
|
+
remove
|
|
863
867
|
} = create$1();
|
|
864
868
|
|
|
865
869
|
const create = (uid, uri, width, height, platform, assetDir$1) => {
|
|
@@ -882,11 +886,58 @@ const create = (uid, uri, width, height, platform, assetDir$1) => {
|
|
|
882
886
|
baseUrl: '',
|
|
883
887
|
features: [],
|
|
884
888
|
folderSize: 0,
|
|
885
|
-
assetDir: assetDir$1 || assetDir
|
|
889
|
+
assetDir: assetDir$1 || assetDir,
|
|
890
|
+
platform
|
|
886
891
|
};
|
|
887
892
|
set$1(uid, state, state);
|
|
888
893
|
};
|
|
889
894
|
|
|
895
|
+
const RenderFocus = 2;
|
|
896
|
+
const RenderItems = 3;
|
|
897
|
+
|
|
898
|
+
const diffType$1 = RenderFocus;
|
|
899
|
+
const isEqual$1 = (oldState, newState) => {
|
|
900
|
+
return oldState === newState;
|
|
901
|
+
};
|
|
902
|
+
|
|
903
|
+
const diffType = RenderItems;
|
|
904
|
+
const isEqual = (oldState, newState) => {
|
|
905
|
+
return oldState === newState;
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
const modules = [isEqual, isEqual$1];
|
|
909
|
+
const numbers = [diffType, diffType$1];
|
|
910
|
+
|
|
911
|
+
const diff = (oldState, newState) => {
|
|
912
|
+
const diffResult = [];
|
|
913
|
+
for (let i = 0; i < modules.length; i++) {
|
|
914
|
+
const fn = modules[i];
|
|
915
|
+
if (!fn(oldState, newState)) {
|
|
916
|
+
diffResult.push(numbers[i]);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
return diffResult;
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
const diff2 = uid => {
|
|
923
|
+
const {
|
|
924
|
+
oldState,
|
|
925
|
+
newState
|
|
926
|
+
} = get$1(uid);
|
|
927
|
+
const diffResult = diff(oldState, newState);
|
|
928
|
+
return diffResult;
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
const dispose = uid => {
|
|
932
|
+
remove(uid);
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
const commandIds = ['getMenuEntries', 'handleClickDisable', 'handleClickSize', 'handleClickUninstall', 'handleFeaturesClick', 'handleIconError', 'handleTabsClick', 'renderEventListeners', 'resize', 'saveState', 'selectTab', 'terminate'];
|
|
936
|
+
|
|
937
|
+
const getCommandIds = () => {
|
|
938
|
+
return commandIds;
|
|
939
|
+
};
|
|
940
|
+
|
|
890
941
|
const AdditionalDetails = 'AdditionalDetails';
|
|
891
942
|
const AdditionalDetailsEntry = 'AdditionalDetailsEntry';
|
|
892
943
|
const AdditionalDetailsTitle = 'AdditionalDetailsTitle';
|
|
@@ -2277,20 +2328,6 @@ const getFolderSize = async uri => {
|
|
|
2277
2328
|
}
|
|
2278
2329
|
};
|
|
2279
2330
|
|
|
2280
|
-
const getSavedSelectedFeature = savedState => {
|
|
2281
|
-
if (savedState && typeof savedState === 'object' && 'selectedFeature' in savedState && typeof savedState.selectedFeature === 'string') {
|
|
2282
|
-
return savedState.selectedFeature;
|
|
2283
|
-
}
|
|
2284
|
-
return Details;
|
|
2285
|
-
};
|
|
2286
|
-
|
|
2287
|
-
const getSavedSelectedTab = savedState => {
|
|
2288
|
-
if (savedState && typeof savedState === 'object' && 'selectedTab' in savedState && typeof savedState.selectedTab === 'string') {
|
|
2289
|
-
return savedState.selectedTab;
|
|
2290
|
-
}
|
|
2291
|
-
return Details;
|
|
2292
|
-
};
|
|
2293
|
-
|
|
2294
2331
|
const readFile = async uri => {
|
|
2295
2332
|
return invoke('FileSystem.readFile', uri);
|
|
2296
2333
|
};
|
|
@@ -2319,6 +2356,29 @@ const loadReadmeContent = async path => {
|
|
|
2319
2356
|
}
|
|
2320
2357
|
};
|
|
2321
2358
|
|
|
2359
|
+
const getSavedSelectedFeature = savedState => {
|
|
2360
|
+
if (savedState && typeof savedState === 'object' && 'selectedFeature' in savedState && typeof savedState.selectedFeature === 'string') {
|
|
2361
|
+
return savedState.selectedFeature;
|
|
2362
|
+
}
|
|
2363
|
+
return Details;
|
|
2364
|
+
};
|
|
2365
|
+
|
|
2366
|
+
const getSavedSelectedTab = savedState => {
|
|
2367
|
+
if (savedState && typeof savedState === 'object' && 'selectedTab' in savedState && typeof savedState.selectedTab === 'string') {
|
|
2368
|
+
return savedState.selectedTab;
|
|
2369
|
+
}
|
|
2370
|
+
return Details;
|
|
2371
|
+
};
|
|
2372
|
+
|
|
2373
|
+
const restoreState = savedState => {
|
|
2374
|
+
const selectedTab = getSavedSelectedTab(savedState);
|
|
2375
|
+
const selectedFeature = getSavedSelectedFeature(savedState);
|
|
2376
|
+
return {
|
|
2377
|
+
selectedFeature,
|
|
2378
|
+
selectedTab
|
|
2379
|
+
};
|
|
2380
|
+
};
|
|
2381
|
+
|
|
2322
2382
|
const loadContent = async (state, platform, savedState) => {
|
|
2323
2383
|
const {
|
|
2324
2384
|
uri,
|
|
@@ -2338,8 +2398,10 @@ const loadContent = async (state, platform, savedState) => {
|
|
|
2338
2398
|
const description = getDescription(extension);
|
|
2339
2399
|
const name = getName(extension);
|
|
2340
2400
|
const size = getViewletSize(width);
|
|
2341
|
-
const
|
|
2342
|
-
|
|
2401
|
+
const {
|
|
2402
|
+
selectedFeature,
|
|
2403
|
+
selectedTab
|
|
2404
|
+
} = restoreState(savedState);
|
|
2343
2405
|
const features = getFeatures(selectedFeature, extension);
|
|
2344
2406
|
const folderSize = await getFolderSize(extension.uri);
|
|
2345
2407
|
const entries = [{
|
|
@@ -2395,6 +2457,49 @@ const loadContent = async (state, platform, savedState) => {
|
|
|
2395
2457
|
};
|
|
2396
2458
|
};
|
|
2397
2459
|
|
|
2460
|
+
const loadContent2 = async (state, savedState) => {
|
|
2461
|
+
return loadContent(state, state.platform, savedState);
|
|
2462
|
+
};
|
|
2463
|
+
|
|
2464
|
+
const renderDom = async (oldState, newState) => {
|
|
2465
|
+
const dom = await getExtensionDetailVirtualDom(newState, newState.sanitizedReadmeHtml, newState.selectedTab, newState);
|
|
2466
|
+
return ['Viewlet.setDom2', dom];
|
|
2467
|
+
};
|
|
2468
|
+
|
|
2469
|
+
const renderFocus = async (oldState, newState) => {
|
|
2470
|
+
return ['Viewlet.focusElementByName', ''];
|
|
2471
|
+
};
|
|
2472
|
+
|
|
2473
|
+
const getRenderer = diffType => {
|
|
2474
|
+
switch (diffType) {
|
|
2475
|
+
case RenderItems:
|
|
2476
|
+
return renderDom;
|
|
2477
|
+
case RenderFocus:
|
|
2478
|
+
return renderFocus;
|
|
2479
|
+
default:
|
|
2480
|
+
throw new Error('unknown renderer');
|
|
2481
|
+
}
|
|
2482
|
+
};
|
|
2483
|
+
|
|
2484
|
+
const applyRender = async (oldState, newState, diffResult) => {
|
|
2485
|
+
const commands = [];
|
|
2486
|
+
for (const item of diffResult) {
|
|
2487
|
+
const fn = getRenderer(item);
|
|
2488
|
+
commands.push(await fn(oldState, newState));
|
|
2489
|
+
}
|
|
2490
|
+
return commands;
|
|
2491
|
+
};
|
|
2492
|
+
|
|
2493
|
+
const render2 = async (uid, diffResult) => {
|
|
2494
|
+
const {
|
|
2495
|
+
oldState,
|
|
2496
|
+
newState
|
|
2497
|
+
} = get$1(uid);
|
|
2498
|
+
set$1(uid, oldState, newState);
|
|
2499
|
+
const commands = await applyRender(oldState, newState, diffResult);
|
|
2500
|
+
return commands;
|
|
2501
|
+
};
|
|
2502
|
+
|
|
2398
2503
|
const renderEventListeners = () => {
|
|
2399
2504
|
return [{
|
|
2400
2505
|
name: HandleIconError,
|
|
@@ -2464,20 +2569,26 @@ const wrapCommand = fn => {
|
|
|
2464
2569
|
|
|
2465
2570
|
const commandMap = {
|
|
2466
2571
|
'ExtensionDetail.create': create,
|
|
2572
|
+
'ExtensionDetail.diff2': diff2,
|
|
2573
|
+
'ExtensionDetail.dispose': dispose,
|
|
2574
|
+
'ExtensionDetail.getCommandIds': getCommandIds,
|
|
2467
2575
|
'ExtensionDetail.getMenuEntries': getMenuEntries,
|
|
2468
|
-
'ExtensionDetail.getVirtualDom2': getExtensionDetailVirtualDom2,
|
|
2469
2576
|
'ExtensionDetail.handleClickDisable': wrapCommand(handleClickDisable),
|
|
2470
2577
|
'ExtensionDetail.handleClickSize': wrapCommand(handleClickSize),
|
|
2471
2578
|
'ExtensionDetail.handleClickUninstall': wrapCommand(handleClickUninstall),
|
|
2472
2579
|
'ExtensionDetail.handleFeaturesClick': wrapCommand(handleClickFeatures),
|
|
2473
2580
|
'ExtensionDetail.handleIconError': wrapCommand(handleIconError),
|
|
2474
2581
|
'ExtensionDetail.handleTabsClick': wrapCommand(handleTabsClick),
|
|
2475
|
-
'ExtensionDetail.
|
|
2582
|
+
'ExtensionDetail.loadContent2': wrapCommand(loadContent2),
|
|
2583
|
+
'ExtensionDetail.render2': render2,
|
|
2476
2584
|
'ExtensionDetail.renderEventListeners': renderEventListeners,
|
|
2477
2585
|
'ExtensionDetail.resize': resize,
|
|
2478
2586
|
'ExtensionDetail.saveState': saveState,
|
|
2479
2587
|
'ExtensionDetail.selectTab': wrapCommand(selectTab),
|
|
2480
|
-
'ExtensionDetail.terminate': terminate
|
|
2588
|
+
'ExtensionDetail.terminate': terminate,
|
|
2589
|
+
// deprecated
|
|
2590
|
+
'ExtensionDetail.getVirtualDom2': getExtensionDetailVirtualDom2,
|
|
2591
|
+
'ExtensionDetail.loadContent': wrapCommand(loadContent)
|
|
2481
2592
|
};
|
|
2482
2593
|
|
|
2483
2594
|
const listen = async () => {
|