Skip to content

Commit

Permalink
chore: github
Browse files Browse the repository at this point in the history
  • Loading branch information
luke358 committed Jan 20, 2024
1 parent f3fa1a0 commit c1c2ca2
Show file tree
Hide file tree
Showing 49 changed files with 1,444 additions and 192 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ release
# lockfile
package-lock.json
pnpm-lock.yaml
yarn.lock
yarn.lock

recipes/all.json
recipes/archives

.vscode

preload/recipe.js
23 changes: 0 additions & 23 deletions .vscode/.debug.script.mjs

This file was deleted.

6 changes: 0 additions & 6 deletions .vscode/extensions.json

This file was deleted.

53 changes: 0 additions & 53 deletions .vscode/launch.json

This file was deleted.

13 changes: 0 additions & 13 deletions .vscode/settings.json

This file was deleted.

31 changes: 0 additions & 31 deletions .vscode/tasks.json

This file was deleted.

4 changes: 3 additions & 1 deletion components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
import '@vue/runtime-core'

export {}

declare module 'vue' {
declare module '@vue/runtime-core' {
export interface GlobalComponents {
AddServiceDrawer: typeof import('./src/components/AddServiceDrawer.vue')['default']
ContextMenuPopover: typeof import('./src/components/ContextMenuPopover.vue')['default']
Expand Down
15 changes: 14 additions & 1 deletion electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@
},
"files": [
"dist-electron",
"dist"
"dist",
"preload/recipe.js"
],
"extraResources": [
{
"from": "./recipes/archives",
"to": "app.asar.unpacked/recipes",
"filter": ["**/*"]
},
{
"from": "./recipes/all.json",
"to": "app.asar.unpacked/recipes/all.json",
"filter": ["**/*"]
}
],
"mac": {
"artifactName": "${productName}_${version}.${ext}",
Expand Down
8 changes: 6 additions & 2 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { release } from 'node:os'
import { join } from 'node:path'
import { BrowserWindow, app, ipcMain, shell } from 'electron'
import { attachTitlebarToWindow, setupTitlebar } from 'custom-electron-titlebar/main'
import * as remoteMain from '@electron/remote/main';

remoteMain.initialize();
// The built directory structure
//
// ├─┬ dist-electron
Expand Down Expand Up @@ -61,7 +63,7 @@ async function createWindow() {
// Consider using contextBridge.exposeInMainWorld
// Read more on https://www.electronjs.org/docs/latest/tutorial/context-isolation
nodeIntegration: true,
contextIsolation: true,
contextIsolation: false,
webviewTag: true,
plugins: true,
},
Expand Down Expand Up @@ -91,6 +93,8 @@ async function createWindow() {
win?.webContents.send('main-process-message', new Date().toLocaleString())
})

remoteMain.enable(win.webContents)

// Make all links open with the browser, not with the application
win.webContents.setWindowOpenHandler(({ url }) => {
if (url.startsWith('https:'))
Expand All @@ -101,7 +105,7 @@ async function createWindow() {
attachTitlebarToWindow(win)

win.webContents.on('will-attach-webview', (e, webPreferences) => {
// webPreferences.preload = join(__dirname, '../../preload/recipe.js')
webPreferences.preload = join(__dirname, '../../preload/recipe.js')
})
}

Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@
"scripts": {
"dev": "vite --port 5555",
"build": "vue-tsc --noEmit && vite build && electron-builder",
"recipe": "esbuild ./preload/recipe.ts --outfile=./preload/recipe.js --format=cjs",
"recipe": "esbuild ./preload/recipe.ts --bundle --packages=external --outfile=./preload/recipe.js --format=cjs",
"preview": "vite preview",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@electron/remote": "^2.1.1",
"@iconify-json/carbon": "^1.1.17",
"@iconify-json/ic": "^1.1.13",
"@iconify-json/ion": "^1.1.10",
"@vueuse/core": "^10.1.2",
"axios": "^1.4.0",
"cors": "^2.8.5",
"custom-electron-titlebar": "^4.2.2",
"element-plus": "^2.3.6",
"express": "^4.18.2",
"fast-folder-size": "^2.2.0",
"lodash-es": "^4.17.21",
"ms": "^2.1.3",
"nanoid": "^5.0.1",
Expand All @@ -44,14 +48,19 @@
},
"devDependencies": {
"@antfu/eslint-config": "^2.6.2",
"@types/express": "^4.17.21",
"@types/lodash-es": "^4.17.7",
"@types/ms": "^0.7.31",
"@vitejs/plugin-vue": "^4.2.3",
"electron": "^28.1.0",
"electron-builder": "^24.6.3",
"esbuild": "^0.19.11",
"eslint": "^8.41.0",
"fs-extra": "^11.2.0",
"image-size": "^1.1.1",
"sass": "^1.62.1",
"simple-git": "^3.22.0",
"targz": "^1.0.1",
"typescript": "^5.0.4",
"unocss": "^0.58.2",
"unplugin-auto-import": "^0.17.3",
Expand Down
69 changes: 37 additions & 32 deletions preload/recipe.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var import_node_path = require("node:path");

// preload/recipe.ts
var import_electron2 = require("electron");

// preload/badge.ts
var import_electron = require("electron");
var import_badge = __toESM(require("./badge"));
const noop = () => {
var BadgeHandler = class {
safeParseInt(text) {
if (text === void 0 || text === null) {
return 0;
}
const parsedNumber = Number.parseInt(text.toString(), 10);
const adjustedNumber = Number.isNaN(parsedNumber) ? 0 : parsedNumber;
return Math.max(adjustedNumber, 0);
}
setBadge(direct, indirect) {
const count = {
direct: this.safeParseInt(direct),
indirect: this.safeParseInt(indirect)
};
import_electron.ipcRenderer.sendToHost("message-counts", count);
}
};
const badgeHandler = new import_badge.default();
import_electron.contextBridge.exposeInMainWorld("API", {

// preload/recipe.ts
var badgeHandler = new BadgeHandler();
console.log("qqqqq ddddd ccccc vvvvv ssss");
import_electron2.contextBridge.exposeInMainWorld("API", {
open: window.open,
setBadge: (direct, indirect) => badgeHandler.setBadge(direct, indirect),
safeParseInt: (text) => badgeHandler.safeParseInt(text)
Expand All @@ -36,25 +35,31 @@ import_electron.contextBridge.exposeInMainWorld("API", {
// notificationsHandler.displayNotification(title, options),
// getDisplayMediaSelector,
});
class RecipeController {
var RecipeController = class {
ipcEvents = {
"initialize-recipe": "loadRecipeModule",
"find-in-page": "openFindInPage"
};
constructor() {
this.initialize();
}
async initialize() {
for (const channel of Object.keys(this.ipcEvents)) {
import_electron.ipcRenderer.on(channel, (...args) => {
import_electron2.ipcRenderer.on(channel, (...args) => {
this[this.ipcEvents[channel]](...args);
});
}
setTimeout(() => {
import_electron2.ipcRenderer.sendToHost("hello");
}, 100);
}
loadRecipeModule(_event, config, recipe) {
const modulePath = (0, import_node_path.join)(recipe.path, "webview.js");
delete require.cache[require.resolve(modulePath)];
console.log(recipe, "reeeeee");
try {
} catch (error) {
console.error("Recipe initialization failed", error);
}
}
}
};
console.log("new RecipeController();");
new RecipeController();
Loading

0 comments on commit c1c2ca2

Please sign in to comment.