Skip to content

Commit

Permalink
Merge branch 'main' into plugin-script-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
hal-shu-sato authored Aug 26, 2023
2 parents edf42b8 + 1328ce4 commit fbb2c6d
Show file tree
Hide file tree
Showing 12 changed files with 1,172 additions and 744 deletions.
2 changes: 1 addition & 1 deletion docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GEM
execjs
coffee-script-source (1.11.1)
colorator (1.1.0)
commonmarker (0.23.9)
commonmarker (0.23.10)
concurrent-ruby (1.2.0)
dnsruby (1.61.9)
simpleidn (~> 0.1)
Expand Down
66 changes: 33 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,83 +31,83 @@
},
"dependencies": {
"7zip-bin": "^5.2.0",
"bootstrap": "^5.2.3",
"bootstrap": "^5.3.1",
"bootstrap-dark-5": "^1.1.3",
"bootstrap-icons": "^1.10.4",
"bootstrap-icons": "^1.10.5",
"clipboard": "^2.0.11",
"compare-versions": "^5.0.3",
"dot-prop": "^7.2.0",
"compare-versions": "^6.1.0",
"dot-prop": "^8.0.2",
"electron-debug": "^3.2.0",
"electron-dl": "^3.5.0",
"electron-log": "^4.4.8",
"electron-prompt": "^1.7.0",
"electron-squirrel-startup": "^1.0.0",
"electron-store": "^8.1.0",
"electron-window-state": "^5.0.3",
"fast-xml-parser": "^4.2.0",
"fast-xml-parser": "^4.2.7",
"fs-extra": "^11.1.1",
"list.js": "^2.3.1",
"matcher": "^5.0.0",
"node-7z": "^3.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"source-map-support": "^0.5.21",
"ssri": "^10.0.3",
"ssri": "^10.0.5",
"update-electron-app": "^2.0.1",
"win-7zip": "^0.1.1"
},
"devDependencies": {
"@commitlint/cli": "^17.6.0",
"@commitlint/config-conventional": "^17.6.1",
"@electron-forge/cli": "^6.1.1",
"@electron-forge/maker-deb": "^6.1.1",
"@electron-forge/maker-rpm": "^6.1.1",
"@electron-forge/maker-squirrel": "^6.1.1",
"@electron-forge/maker-zip": "^6.1.1",
"@electron-forge/plugin-auto-unpack-natives": "^6.1.1",
"@electron-forge/plugin-webpack": "6.1.1",
"@electron-forge/publisher-github": "^6.1.1",
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@electron-forge/cli": "^6.4.1",
"@electron-forge/maker-deb": "^6.4.1",
"@electron-forge/maker-rpm": "^6.4.1",
"@electron-forge/maker-squirrel": "^6.4.1",
"@electron-forge/maker-zip": "^6.4.1",
"@electron-forge/plugin-auto-unpack-natives": "^6.4.1",
"@electron-forge/plugin-webpack": "6.4.1",
"@electron-forge/publisher-github": "^6.4.1",
"@types/bootstrap": "^5.2.6",
"@types/electron-prompt": "^1.6.1",
"@types/electron-window-state": "^5.0.0",
"@types/fs-extra": "^11.0.1",
"@types/list.js": "^2.3.1",
"@types/node-7z": "^2.1.5",
"@types/react": "^18.0.35",
"@types/react-dom": "^18.0.11",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/ssri": "^7.1.1",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vercel/webpack-asset-relocator-loader": "1.7.3",
"apm-schema": "team-apm/apm-schema#v3.2.1",
"commitizen": "^4.3.0",
"conventional-github-releaser": "^3.1.5",
"cross-env": "^7.0.3",
"css-loader": "^6.7.3",
"css-loader": "^6.8.1",
"cz-conventional-changelog": "3.3.0",
"cz-conventional-changelog-ja": "^0.0.2",
"electron": "^22.3.5",
"eslint": "^8.38.0",
"electron": "^23.3.3",
"eslint": "^8.47.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^41.1.1",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsdoc": "^46.5.0",
"eslint-webpack-plugin": "^4.0.1",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"html-loader": "^4.2.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.1",
"mini-css-extract-plugin": "^2.7.5",
"lint-staged": "^14.0.1",
"mini-css-extract-plugin": "^2.7.6",
"node-loader": "^2.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.7",
"prettier": "^2.8.8",
"prettier-plugin-md-nocjsp": "^1.5.1",
"standard-version": "^9.5.0",
"style-loader": "^3.3.2",
"ts-loader": "^9.4.2",
"style-loader": "^3.3.3",
"ts-loader": "^9.4.4",
"ts-node": "^10.9.1",
"typescript": "~5.0.4"
"typescript": "~5.2.2"
},
"config": {
"commitizen": {
Expand Down
9 changes: 9 additions & 0 deletions src/lib/ipcWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,12 @@ export async function openBrowser(url: string, type: 'core' | 'package') {
history: string[];
} | null;
}

/**
* Writes the text into the clipboard as plain text.
*
* @param {string} text - plain text.
*/
export async function clipboardWriteText(text: string) {
await ipcRenderer.invoke('clipboard-writeText', text);
}
90 changes: 75 additions & 15 deletions src/lib/updatableList.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,53 @@
import List from 'list.js';

interface ListItemMaybeFound extends List.ListItem {
found?: boolean;
}
export interface UpdatableList extends List {
sortState: {
value: string;
options: { order: string };
};
filterFunction: (item: List.ListItem) => boolean;
searchFunction: (
items: ListItemMaybeFound[],
searchString: string
) => Promise<string>;
update: (searchFunction?: UpdatableList['searchFunction']) => void;
}

/**
* Keep the state of the table even after update() is executed
*
* @param {string | HTMLElement} element id of the list area
* @param {{regex, searchFunction}} apmCustomSearch add different search methods
* @param {RegExp} apmCustomSearch.regex condition for activating the search method
* @param {UpdatableList['searchFunction']} apmCustomSearch.searchFunction synchronously set `found` flag on the items, then return the string asynchronously.
* @param {List.ListOptions} options option parameters
* @param {object[]} values values to add to the list
* @returns {List} List.js List
*/
function createList(
element: string | HTMLElement,
apmCustomSearch: {
regex: RegExp;
searchFunction: UpdatableList['searchFunction'];
},
options?: List.ListOptions,
values?: object[]
): List {
) {
const searchBox = document.getElementsByClassName(
'fuzzy-search-wrapped'
)?.[0] as HTMLInputElement;
const searchAlertRoot = document.getElementById(
'custom-search-alert'
) as HTMLDivElement;
const searchAlertTemplate = document.getElementById(
'alert-template'
) as HTMLDivElement;

const parentList = new List(element, options, values);
const updatableList = Object.create(parentList);
const updatableList = Object.create(parentList) as UpdatableList;

const prepareSortState = () => {
const sortAsc = Array.from(
Expand All @@ -38,34 +71,61 @@ function createList(
options: { order: 'desc' },
};
};

parentList.on('sortComplete', prepareSortState);
prepareSortState();

updatableList.filter = (filterFunction: (item: List.ListItem) => boolean) => {
updatableList.filterFunction = filterFunction;
parentList.filter(filterFunction);
};

updatableList.update = () => {
parentList.update();

updatableList.filterFunction &&
parentList.filter(updatableList.filterFunction);

const searchString = (
document.getElementsByClassName('fuzzy-search')?.[0] as HTMLInputElement
).value;
searchString && parentList.fuzzySearch(searchString);
const doSearch = async () => {
searchAlertRoot.innerHTML = null;
const searchString = searchBox.value.trim();
if (apmCustomSearch.regex.test(searchString)) {
let searchFunctionPromise: Promise<string>;
parentList.search(
searchString,
((escapedSearchString: string) =>
(searchFunctionPromise = updatableList.searchFunction(
parentList.items as List.ListItem[],
escapedSearchString.replaceAll('\\', '')
))) as never
);
const alertString = await searchFunctionPromise;
if (alertString) {
const searchAlert = searchAlertTemplate.cloneNode(
true
) as HTMLDivElement;
searchAlert.removeAttribute('id');
(
searchAlert.getElementsByClassName(
'alert-text'
)?.[0] as HTMLDivElement
).innerText = alertString;
searchAlertRoot.appendChild(searchAlert);
}
} else parentList.fuzzySearch(searchString);

// This is a workaround for a problem in sort.js where the sort symbol (▼) disappears after a search.
updatableList.sortState &&
parentList.sort(
updatableList.sortState.value,
updatableList.sortState.options
);
};
searchBox.addEventListener('input', async () => await doSearch());

prepareSortState();
updatableList.update();
updatableList.update = async (searchFunction?) => {
parentList.update();

updatableList.filterFunction &&
parentList.filter(updatableList.filterFunction);

searchFunction && (updatableList.searchFunction = searchFunction);
await doSearch();
};
updatableList.update(apmCustomSearch.searchFunction);

return updatableList;
}
Expand Down
7 changes: 6 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { execSync } from 'child_process';
import {
app,
BrowserWindow,
clipboard,
dialog,
ipcMain,
Menu,
nativeTheme,
net,
shell,
nativeTheme,
} from 'electron';
import debug from 'electron-debug';
import { download } from 'electron-dl';
Expand Down Expand Up @@ -283,6 +284,10 @@ ipcMain.handle('get-nicommons-data', (event, id) => {
});
});

ipcMain.handle('clipboard-writeText', async (event, text) => {
clipboard.writeText(text);
});

const allowedHosts: string[] = [];

app.on(
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/main/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import log from 'electron-log';
import fs, { copy, existsSync } from 'fs-extra';
import path from 'path';
import { safeRemove } from '../../lib/safeRemove';

export const programs = ['aviutl', 'exedit'] as const;
export const programsDisp = { aviutl: 'AviUtl', exedit: '拡張編集' };

type Files = {
filename: string;
isUninstallOnly?: boolean;
Expand Down
12 changes: 4 additions & 8 deletions src/renderer/main/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ import replaceText from '../../lib/replaceText';
import { addAviUtlShortcut, removeAviUtlShortcut } from '../../lib/shortcut';
import unzip from '../../lib/unzip';
import migration2to3 from '../../migration/migration2to3';
import { install, verifyFilesByCount } from './common';
import { install, programs, programsDisp, verifyFilesByCount } from './common';
import packageMain from './package';
import packageUtil from './packageUtil';
const store = new Store();
type ProgramName = 'aviutl' | 'exedit';

const programs: ProgramName[] = ['aviutl', 'exedit'];
const programsDisp = ['AviUtl', '拡張編集'];

// Functions to be exported

Expand Down Expand Up @@ -113,11 +109,11 @@ async function displayInstalledVersion(instPath: string) {
if (isInstalled[p]) {
const pTag = document.createElement('span');
pTag.classList.add('text-muted');
pTag.innerText = '✔' + programsDisp[programs.indexOf(p)];
pTag.innerText = '✔' + programsDisp[p];
batchInstallElm.appendChild(pTag);
return [pTag];
} else {
return [document.createTextNode(programsDisp[programs.indexOf(p)])];
return [document.createTextNode(programsDisp[p])];
}
})
.reduce((a, b) => [].concat(a, document.createTextNode(' + '), b))
Expand Down Expand Up @@ -363,7 +359,7 @@ async function changeInstallationPath(instPath: string) {
*/
async function installProgram(
btn: HTMLButtonElement,
program: ProgramName,
program: (typeof programs)[number],
version: string,
instPath: string
) {
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/main/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ div#packages-table-overlay {
height: 100%;
background-color: rgba(127, 127, 127, 0.5);
}
.zindex-lower-dropdown {
z-index: 990;
}
.sort:after {
content: '';
float: right;
margin-top: 0.5em;
margin-top: 0.4em;
margin-left: 0.2em;
border-width: 0 0.3em;
border-style: solid;
border-color: transparent;
Expand Down
Loading

0 comments on commit fbb2c6d

Please sign in to comment.