Skip to content

Commit 4d103d0

Browse files
committed
Inital commit
0 parents  commit 4d103d0

39 files changed

+4690
-0
lines changed

.eslintrc.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"parser": "@typescript-eslint/parser",
7+
"plugins": [
8+
"@typescript-eslint"
9+
],
10+
"extends": [
11+
"plugin:@typescript-eslint/recommended",
12+
"eslint:recommended",
13+
"google",
14+
"prettier"
15+
],
16+
"parserOptions": {
17+
"ecmaVersion": 2020,
18+
"sourceType": "module"
19+
},
20+
"ignorePatterns": [
21+
"preload/*.js",
22+
"init/*.js",
23+
"rollup.config.mjs"
24+
],
25+
"rules": {
26+
"no-undef": 0,
27+
"require-jsdoc": 0,
28+
"linebreak-style": 0,
29+
"no-unused-vars": 0,
30+
"@typescript-eslint/no-namespace": 0,
31+
"object-curly-spacing": [
32+
"error",
33+
"always"
34+
],
35+
"max-len": [
36+
"error",
37+
120
38+
]
39+
}
40+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
build/
3+
cache/

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.tabSize": 2
3+
}

LICENSE

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
OpenKakaoTalk
2+
Copyright (C) 2021 storycraft
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program. If not, see <http://www.gnu.org/licenses/>

index.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
<!doctype html>
3+
<html>
4+
<head>
5+
<meta charset="utf-8">
6+
<meta http-equiv="Content-Security-Policy" content="script-src 'none'; object-src 'none';">
7+
<title>OpenKakaoTalk</title>
8+
</head>
9+
<body>
10+
</body>
11+
</html>

init/common.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Created on Tue Mar 02 2021
3+
*
4+
* Copyright (c) storycraft. Licensed under the GNU General Public License v3.
5+
*/
6+
7+
const { BrowserWindow } = require('electron');
8+
9+
module.exports.initWindow = async (
10+
/** @type {import('electron').BrowserViewConstructorOptions} */
11+
opts
12+
) => {
13+
const win = new BrowserWindow(opts);
14+
15+
win.webContents.on('will-navigate', (event) => {
16+
event.preventDefault();
17+
});
18+
19+
return win;
20+
}
21+
22+
module.exports.loadWindow = (win) => {
23+
return win.loadURL(`file://${__dirname}/../index.html`);
24+
}

init/dev.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Created on Sun Feb 28 2021
3+
*
4+
* Copyright (c) storycraft. Licensed under the GNU General Public License v3.
5+
*/
6+
7+
const { app, session } = require('electron');
8+
const { initWindow, loadWindow } = require('./common');
9+
const { default: installExtension, REACT_DEVELOPER_TOOLS } = require('electron-devtools-installer');
10+
11+
async function main() {
12+
await app.whenReady();
13+
14+
await installExtension(REACT_DEVELOPER_TOOLS);
15+
session.defaultSession.getAllExtensions().forEach((ext) => {
16+
session.defaultSession.removeExtension(ext.id);
17+
session.defaultSession.loadExtension(ext.path, { allowFileAccess: true }).then();
18+
});
19+
20+
let win = await initWindow({
21+
webPreferences: {
22+
enableRemoteModule: true,
23+
nodeIntegration: true,
24+
contextIsolation: false
25+
}
26+
});
27+
await loadWindow(win);
28+
29+
win.webContents.executeJavaScript(`require(\'./preload/dev.js\');`);
30+
31+
win.webContents.openDevTools({ mode: 'detach' });
32+
}
33+
34+
main().then();

init/index.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Created on Sun Feb 28 2021
3+
*
4+
* Copyright (c) storycraft. Licensed under the GNU General Public License v3.
5+
*/
6+
7+
const { app } = require('electron');
8+
const { initWindow, loadWindow } = require('./common');
9+
10+
async function main() {
11+
await app.whenReady();
12+
13+
const win = await initWindow({
14+
webPreferences: {
15+
enableRemoteModule: true,
16+
nodeIntegration: false,
17+
contextIsolation: true,
18+
devTools: false,
19+
preload: `${__dirname}/../preload/index.js`
20+
},
21+
});
22+
23+
win.setMenu(null);
24+
await loadWindow(win);
25+
}
26+
27+
main().then();

package.json

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "open-kakaotalk-electron",
3+
"version": "0.0.1",
4+
"description": "Open KakaoTalk made with electron",
5+
"main": "init/index.js",
6+
"scripts": {
7+
"test": "node_modules/.bin/electron ./testing/index.js",
8+
"start": "node_modules/.bin/electron ./init/index.js",
9+
"dev:electron": "node_modules/.bin/electron ./init/dev.js",
10+
"dev:rollup": "node_modules/.bin/rollup -c",
11+
"dev": "npm run dev:rollup && npm run dev:electron",
12+
"build": "npm run build:rollup && npm run build:electron",
13+
"build:electron": "node index.js",
14+
"build:rollup": "node_modules/.bin/rollup -c",
15+
"postinstall": "node_modules/.bin/patch-package",
16+
"fix": "node_modules/.bin/eslint --fix src/**/*"
17+
},
18+
"eslintConfig": {
19+
"extends": "react-app"
20+
},
21+
"author": "storycraft",
22+
"window": {
23+
"id": "open-kakao-talk"
24+
},
25+
"domain": "openkakaotalk",
26+
"license": "GPL-3.0-or-later",
27+
"devDependencies": {
28+
"@rollup/plugin-commonjs": "^17.1.0",
29+
"@rollup/plugin-json": "^4.1.0",
30+
"@rollup/plugin-node-resolve": "^11.2.0",
31+
"@rollup/plugin-typescript": "^8.2.0",
32+
"@rollup/plugin-url": "^6.0.0",
33+
"@types/node": "^14.14.31",
34+
"@types/react": "^17.0.2",
35+
"@types/react-dom": "^17.0.1",
36+
"@types/styled-components": "^5.1.7",
37+
"@typescript-eslint/eslint-plugin": "^4.15.2",
38+
"@typescript-eslint/parser": "^4.15.2",
39+
"concurrently": "^6.0.0",
40+
"electron-devtools-installer": "^3.1.1",
41+
"eslint": "^7.20.0",
42+
"eslint-config-google": "^0.14.0",
43+
"eslint-config-prettier": "^8.1.0",
44+
"mocha": "^8.3.0",
45+
"patch-package": "^6.2.2",
46+
"rollup": "^2.40.0",
47+
"ts-node": "^9.1.1",
48+
"typescript": "^4.2.2"
49+
},
50+
"dependencies": {
51+
"electron": "^11.3.0",
52+
"nedb": "^1.8.0",
53+
"node-kakao": "^4.0.6",
54+
"react": "^17.0.1",
55+
"react-async": "^10.0.1",
56+
"react-dom": "^17.0.1",
57+
"styled-components": "^5.2.1"
58+
}
59+
}

patches/axios+0.21.1.patch

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/node_modules/axios/lib/defaults.js b/node_modules/axios/lib/defaults.js
2+
index 2b2a1a7..0ad241d 100644
3+
--- a/node_modules/axios/lib/defaults.js
4+
+++ b/node_modules/axios/lib/defaults.js
5+
@@ -14,15 +14,7 @@ function setContentTypeIfUnset(headers, value) {
6+
}
7+
8+
function getDefaultAdapter() {
9+
- var adapter;
10+
- if (typeof XMLHttpRequest !== 'undefined') {
11+
- // For browsers use XHR adapter
12+
- adapter = require('./adapters/xhr');
13+
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
14+
- // For node use HTTP adapter
15+
- adapter = require('./adapters/http');
16+
- }
17+
- return adapter;
18+
+ return require('./adapters/http');
19+
}
20+
21+
var defaults = {

preload/common.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Created on Mon Mar 01 2021
3+
*
4+
* Copyright (c) storycraft. Licensed under the GNU General Public License v3.
5+
*/
6+
const { app } = require('electron').remote;
7+
const path = require('path');
8+
9+
module.exports.getAppDataPath = function() {
10+
return path.join(app.getPath('userData'), 'app');
11+
}
12+
13+
module.exports.start = (
14+
/** @type {import('../src/app').OpenKakaoTalkOpts} */
15+
options
16+
) => {
17+
return require('../build/index').start(options);
18+
}

preload/dev.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Created on Mon Mar 01 2021
3+
*
4+
* Copyright (c) storycraft. Licensed under the GNU General Public License v3.
5+
*/
6+
7+
const { getAppDataPath, start } = require('./common');
8+
9+
start({
10+
uuid: 'Y7DkNkMrpxZ5FhenqnvZ+l1k4l6DyPd2ZHSd6Rus0+HyO6Kxh4n+3IlbDMr9SfnMHvNDtDUrwHfWPadHOs2d2P==',
11+
name: 'A',
12+
appDataPath: getAppDataPath()
13+
}).then();

preload/index.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Created on Mon Mar 01 2021
3+
*
4+
* Copyright (c) storycraft. Licensed under the GNU General Public License v3.
5+
*/
6+
7+
/*
8+
* Created on Fri Feb 26 2021
9+
*
10+
* Copyright (c) storycraft. Licensed under the GNU General Public License v3.
11+
*/
12+
13+
const { util } = require('node-kakao');
14+
const os = require('os');
15+
const { getAppDataPath, start } = require('./common');
16+
17+
/**
18+
* 현재 기기의 디바이스 id를 만들거나 가져옴
19+
*/
20+
function getCurrentDeviceUUID() {
21+
let id = window.localStorage.getItem('dev_id');
22+
if (!id) {
23+
id = util.randomWin32DeviceUUID();
24+
window.localStorage.setItem('dev_id', id);
25+
}
26+
27+
return id;
28+
}
29+
30+
/**
31+
* 현재 기기의 디바이스 name을 가져옴
32+
*/
33+
function getCurrentDeviceName () {
34+
if (os.platform() === 'win32') {
35+
return os.hostname();
36+
}
37+
38+
return `${os.userInfo().username}@${os.hostname()}`;
39+
}
40+
41+
start({
42+
uuid: getCurrentDeviceUUID(),
43+
name: getCurrentDeviceName(),
44+
appDataPath: getAppDataPath()
45+
}).then();

rollup.config.mjs

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Created on Sat Feb 27 2021
3+
*
4+
* Copyright (c) storycraft. Licensed under the GNU General Public License v3.
5+
*/
6+
7+
import nodeResolve from '@rollup/plugin-node-resolve';
8+
import commonjs from '@rollup/plugin-commonjs';
9+
import typescript from '@rollup/plugin-typescript';
10+
import json from '@rollup/plugin-json';
11+
import url from '@rollup/plugin-url';
12+
13+
const plugins = [
14+
nodeResolve({
15+
preferBuiltins: true
16+
}),
17+
commonjs({
18+
ignoreGlobal: true
19+
}),
20+
url(),
21+
json(),
22+
typescript()
23+
];
24+
25+
/** @type {import('rollup').InputOptions} */
26+
const opts = {
27+
input: 'src/index.ts',
28+
preserveEntrySignatures: true,
29+
external: [
30+
31+
],
32+
shimMissingExports: false,
33+
output: [
34+
{
35+
dir: 'build',
36+
format: 'cjs',
37+
exports: 'named',
38+
preserveModules: true,
39+
preserveModulesRoot: 'src',
40+
sourcemap: false
41+
},
42+
],
43+
plugins,
44+
};
45+
46+
export default () => {
47+
return opts;
48+
};

0 commit comments

Comments
 (0)