hinacode 0.2.0-alpha.2 → 0.2.0-alpha.3
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.
package/out/main/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { existsSync, renameSync } from "node:fs";
|
|
2
2
|
import { join, delimiter } from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { createRequire } from "node:module";
|
|
4
|
+
import { nativeImage, Menu, shell, clipboard, dialog, Notification, BrowserWindow, ipcMain, app, nativeTheme, protocol, safeStorage, powerMonitor, net, session } from "electron";
|
|
5
|
+
import { Z as TaggedError, j as String$1, _ as promise, t as tryPromise, g as gen, $ as ClientSettings, a0 as Environments, a1 as projectFileRequest, a2 as attachmentRequest, a3 as githubAssetId, a4 as externalUrl, k as andThen, p as flatMap, a5 as catch_, h as sync, a6 as catchDefect, a7 as succeed, a8 as callback, a9 as timeoutOrElse, aa as seconds, ab as EVENT_CHANNEL, ac as RPC_CHANNEL, ad as isTrustedSender, ae as route, af as map, v as void_, ag as logWarning, u as unsupported, E as Events, ah as runFork, r as repeat, a as spaced, f as forkScoped, U as Updates, s as suspend, e as effect, ai as ignore, z as hydratePath, aj as ATTACHMENT_PROTOCOL, ak as GITHUB_ASSET_PROTOCOL, al as PROJECT_FILE_PROTOCOL, am as decodeUnknownOption, an as RpcMethods, N as succeed$1, ao as Keyring, A as make$1, B as makeAppLayer, ap as isInside, aq as GitHub, ar as Files, as as BROWSER_PARTITION, at as LIQUID_GLASS_ARGUMENT, au as lockDownWebview, av as getOrUndefined, aw as isAllowedNavigation } from "./chunks/shellPath-zO68cje6.js";
|
|
7
6
|
import { execFile, spawn } from "node:child_process";
|
|
8
7
|
import { access } from "node:fs/promises";
|
|
9
8
|
import { homedir } from "node:os";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
11
|
import updater from "electron-updater";
|
|
12
12
|
import { join as join$1 } from "path";
|
|
@@ -29,30 +29,650 @@ import "node:stream/promises";
|
|
|
29
29
|
import "node:zlib";
|
|
30
30
|
import "node:net";
|
|
31
31
|
import "node:tls";
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
const URLPattern = {};
|
|
33
|
+
const baseLocale = "en";
|
|
34
|
+
const locales = (
|
|
35
|
+
/** @type {const} */
|
|
36
|
+
["en", "zh-TW", "ja"]
|
|
37
|
+
);
|
|
38
|
+
const strategy = [
|
|
39
|
+
"globalVariable",
|
|
40
|
+
"baseLocale"
|
|
41
|
+
];
|
|
42
|
+
const routeStrategies = [];
|
|
43
|
+
const isServer = typeof window === "undefined";
|
|
44
|
+
globalThis.__paraglide = /** @type {any} */
|
|
45
|
+
globalThis.__paraglide ?? {};
|
|
46
|
+
globalThis.__paraglide.ssr = /** @type {any} */
|
|
47
|
+
globalThis.__paraglide.ssr ?? {};
|
|
48
|
+
let _locale;
|
|
49
|
+
let localeInitiallySet = false;
|
|
50
|
+
let getLocale = () => {
|
|
51
|
+
let strategyToUse = strategy;
|
|
52
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
53
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
55
|
+
const resolved = resolveLocaleWithStrategies(strategyToUse);
|
|
56
|
+
if (resolved) {
|
|
57
|
+
if (!localeInitiallySet) {
|
|
58
|
+
_locale = resolved;
|
|
59
|
+
localeInitiallySet = true;
|
|
60
|
+
setLocale(resolved, { reload: false });
|
|
61
|
+
}
|
|
62
|
+
return resolved;
|
|
63
|
+
}
|
|
64
|
+
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
65
|
+
};
|
|
66
|
+
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
67
|
+
let locale;
|
|
68
|
+
for (const strat of strategyToUse) {
|
|
69
|
+
if (strat === "baseLocale") {
|
|
70
|
+
locale = baseLocale;
|
|
71
|
+
} else if (strat === "globalVariable" && _locale !== void 0) {
|
|
72
|
+
locale = _locale;
|
|
73
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
74
|
+
const handler = customClientStrategies.get(strat);
|
|
75
|
+
if (handler) {
|
|
76
|
+
const result = handler.getLocale();
|
|
77
|
+
if (result instanceof Promise) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (result !== void 0) {
|
|
81
|
+
return assertIsLocale(result);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const matchedLocale = toLocale(locale);
|
|
86
|
+
if (matchedLocale) {
|
|
87
|
+
return matchedLocale;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return void 0;
|
|
91
|
+
}
|
|
92
|
+
const navigateOrReload = (newLocation) => {
|
|
93
|
+
{
|
|
94
|
+
window.location.reload();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
let setLocale = (newLocale, options) => {
|
|
98
|
+
const optionsWithDefaults = {
|
|
99
|
+
reload: true,
|
|
100
|
+
...options
|
|
101
|
+
};
|
|
102
|
+
let currentLocale;
|
|
103
|
+
try {
|
|
104
|
+
currentLocale = getLocale();
|
|
105
|
+
} catch {
|
|
106
|
+
}
|
|
107
|
+
const customSetLocalePromises = [];
|
|
108
|
+
let strategyToUse = strategy;
|
|
109
|
+
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
110
|
+
strategyToUse = getStrategyForUrl(window.location.href);
|
|
111
|
+
}
|
|
112
|
+
for (const strat of strategyToUse) {
|
|
113
|
+
if (strat === "globalVariable") {
|
|
114
|
+
_locale = newLocale;
|
|
115
|
+
} else if (strat === "baseLocale") {
|
|
116
|
+
continue;
|
|
117
|
+
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
118
|
+
const handler = customClientStrategies.get(strat);
|
|
119
|
+
if (handler) {
|
|
120
|
+
let result = handler.setLocale(newLocale);
|
|
121
|
+
if (result instanceof Promise) {
|
|
122
|
+
result = result.catch((error) => {
|
|
123
|
+
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
124
|
+
cause: error
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
customSetLocalePromises.push(result);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const runReload = () => {
|
|
133
|
+
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
134
|
+
navigateOrReload();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
if (customSetLocalePromises.length) {
|
|
138
|
+
return Promise.all(customSetLocalePromises).then(() => {
|
|
139
|
+
runReload();
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
runReload();
|
|
143
|
+
return;
|
|
144
|
+
};
|
|
145
|
+
let getUrlOrigin = () => {
|
|
146
|
+
if (typeof window !== "undefined") {
|
|
147
|
+
return window.location.origin;
|
|
148
|
+
}
|
|
149
|
+
return "http://fallback.com";
|
|
150
|
+
};
|
|
151
|
+
function toLocale(value) {
|
|
152
|
+
if (typeof value !== "string") {
|
|
153
|
+
return void 0;
|
|
154
|
+
}
|
|
155
|
+
const lowerValue = value.toLowerCase();
|
|
156
|
+
for (const locale of locales) {
|
|
157
|
+
if (locale.toLowerCase() === lowerValue) {
|
|
158
|
+
return locale;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return void 0;
|
|
162
|
+
}
|
|
163
|
+
function assertIsLocale(input) {
|
|
164
|
+
const locale = toLocale(input);
|
|
165
|
+
if (locale)
|
|
166
|
+
return locale;
|
|
167
|
+
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
168
|
+
}
|
|
169
|
+
function normalizeTrailingSlash(url) {
|
|
170
|
+
{
|
|
171
|
+
return url;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function getUrlPattern(pattern, url) {
|
|
175
|
+
return new URLPattern(pattern, url.href);
|
|
176
|
+
}
|
|
177
|
+
function getRoutingConfigVersion() {
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
function getRouteStrategyCandidates(_url) {
|
|
181
|
+
return routeStrategies;
|
|
182
|
+
}
|
|
183
|
+
function execUrlPattern(pattern, url) {
|
|
184
|
+
{
|
|
185
|
+
return pattern.exec(url.href);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function deLocalizeUrl(url) {
|
|
189
|
+
{
|
|
190
|
+
return deLocalizeUrlDefaultPattern(url);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function deLocalizeUrlDefaultPattern(url) {
|
|
194
|
+
const urlObj = normalizeTrailingSlash(typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url));
|
|
195
|
+
const pathSegments = urlObj.pathname.replace(/^\/+/, "").split("/");
|
|
196
|
+
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
197
|
+
urlObj.pathname = "/" + pathSegments.slice(1).join("/");
|
|
198
|
+
}
|
|
199
|
+
return normalizeTrailingSlash(urlObj);
|
|
200
|
+
}
|
|
201
|
+
let cachedRouteConfigVersion = -1;
|
|
202
|
+
let cachedRouteStrategyUrl;
|
|
203
|
+
let cachedRouteStrategy;
|
|
204
|
+
function findMatchingRouteStrategy(url) {
|
|
205
|
+
if (routeStrategies.length === 0) {
|
|
206
|
+
return void 0;
|
|
207
|
+
}
|
|
208
|
+
const urlString = typeof url === "string" ? url : url.href;
|
|
209
|
+
const configVersion = getRoutingConfigVersion();
|
|
210
|
+
if (cachedRouteStrategyUrl === urlString && cachedRouteConfigVersion === configVersion) {
|
|
211
|
+
return cachedRouteStrategy;
|
|
212
|
+
}
|
|
213
|
+
const publicUrl = normalizeTrailingSlash(new URL(urlString, "http://example.com"));
|
|
214
|
+
const canonicalUrl = deLocalizeUrl(publicUrl);
|
|
215
|
+
const candidateUrls = canonicalUrl.href === publicUrl.href ? [publicUrl] : [publicUrl, canonicalUrl];
|
|
216
|
+
let match;
|
|
217
|
+
for (const candidateUrl of candidateUrls) {
|
|
218
|
+
for (const routeStrategy of getRouteStrategyCandidates()) {
|
|
219
|
+
const pattern = getUrlPattern(routeStrategy.match, candidateUrl);
|
|
220
|
+
if (execUrlPattern(pattern, candidateUrl)) {
|
|
221
|
+
match = routeStrategy;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (match)
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
cachedRouteConfigVersion = configVersion;
|
|
229
|
+
cachedRouteStrategyUrl = urlString;
|
|
230
|
+
cachedRouteStrategy = match;
|
|
231
|
+
return match;
|
|
232
|
+
}
|
|
233
|
+
function getStrategyForUrl(url) {
|
|
234
|
+
const routeStrategy = findMatchingRouteStrategy(url);
|
|
235
|
+
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
236
|
+
return routeStrategy.strategy;
|
|
237
|
+
}
|
|
238
|
+
return strategy;
|
|
239
|
+
}
|
|
240
|
+
const customClientStrategies = /* @__PURE__ */ new Map();
|
|
241
|
+
function isCustomStrategy(strategy2) {
|
|
242
|
+
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
243
|
+
}
|
|
244
|
+
const en_context_menu_copy = (
|
|
245
|
+
/** @type {(inputs: Context_Menu_CopyInputs) => LocalizedString} */
|
|
246
|
+
() => {
|
|
247
|
+
return (
|
|
248
|
+
/** @type {LocalizedString} */
|
|
249
|
+
`Copy`
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
const zh_tw2_context_menu_copy = (
|
|
254
|
+
/** @type {(inputs: Context_Menu_CopyInputs) => LocalizedString} */
|
|
255
|
+
() => {
|
|
256
|
+
return (
|
|
257
|
+
/** @type {LocalizedString} */
|
|
258
|
+
`複製`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
const ja_context_menu_copy = (
|
|
263
|
+
/** @type {(inputs: Context_Menu_CopyInputs) => LocalizedString} */
|
|
264
|
+
() => {
|
|
265
|
+
return (
|
|
266
|
+
/** @type {LocalizedString} */
|
|
267
|
+
`コピー`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
const context_menu_copy = (
|
|
272
|
+
/** @type {((inputs?: Context_Menu_CopyInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Context_Menu_CopyInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
273
|
+
((inputs = {}, options = {}) => {
|
|
274
|
+
const locale = options.locale ?? getLocale();
|
|
275
|
+
if (locale === "zh-TW") return zh_tw2_context_menu_copy();
|
|
276
|
+
if (locale === "ja") return ja_context_menu_copy();
|
|
277
|
+
return en_context_menu_copy();
|
|
278
|
+
})
|
|
279
|
+
);
|
|
280
|
+
const en_context_menu_cut = (
|
|
281
|
+
/** @type {(inputs: Context_Menu_CutInputs) => LocalizedString} */
|
|
282
|
+
() => {
|
|
283
|
+
return (
|
|
284
|
+
/** @type {LocalizedString} */
|
|
285
|
+
`Cut`
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
);
|
|
289
|
+
const zh_tw2_context_menu_cut = (
|
|
290
|
+
/** @type {(inputs: Context_Menu_CutInputs) => LocalizedString} */
|
|
291
|
+
() => {
|
|
292
|
+
return (
|
|
293
|
+
/** @type {LocalizedString} */
|
|
294
|
+
`剪下`
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
const ja_context_menu_cut = (
|
|
299
|
+
/** @type {(inputs: Context_Menu_CutInputs) => LocalizedString} */
|
|
300
|
+
() => {
|
|
301
|
+
return (
|
|
302
|
+
/** @type {LocalizedString} */
|
|
303
|
+
`切り取り`
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
const context_menu_cut = (
|
|
308
|
+
/** @type {((inputs?: Context_Menu_CutInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Context_Menu_CutInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
309
|
+
((inputs = {}, options = {}) => {
|
|
310
|
+
const locale = options.locale ?? getLocale();
|
|
311
|
+
if (locale === "zh-TW") return zh_tw2_context_menu_cut();
|
|
312
|
+
if (locale === "ja") return ja_context_menu_cut();
|
|
313
|
+
return en_context_menu_cut();
|
|
314
|
+
})
|
|
315
|
+
);
|
|
316
|
+
const en_context_menu_paste = (
|
|
317
|
+
/** @type {(inputs: Context_Menu_PasteInputs) => LocalizedString} */
|
|
318
|
+
() => {
|
|
319
|
+
return (
|
|
320
|
+
/** @type {LocalizedString} */
|
|
321
|
+
`Paste`
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
const zh_tw2_context_menu_paste = (
|
|
326
|
+
/** @type {(inputs: Context_Menu_PasteInputs) => LocalizedString} */
|
|
327
|
+
() => {
|
|
328
|
+
return (
|
|
329
|
+
/** @type {LocalizedString} */
|
|
330
|
+
`貼上`
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
const ja_context_menu_paste = (
|
|
335
|
+
/** @type {(inputs: Context_Menu_PasteInputs) => LocalizedString} */
|
|
336
|
+
() => {
|
|
337
|
+
return (
|
|
338
|
+
/** @type {LocalizedString} */
|
|
339
|
+
`貼り付け`
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
const context_menu_paste = (
|
|
344
|
+
/** @type {((inputs?: Context_Menu_PasteInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Context_Menu_PasteInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
345
|
+
((inputs = {}, options = {}) => {
|
|
346
|
+
const locale = options.locale ?? getLocale();
|
|
347
|
+
if (locale === "zh-TW") return zh_tw2_context_menu_paste();
|
|
348
|
+
if (locale === "ja") return ja_context_menu_paste();
|
|
349
|
+
return en_context_menu_paste();
|
|
350
|
+
})
|
|
351
|
+
);
|
|
352
|
+
const en_context_menu_select_all = (
|
|
353
|
+
/** @type {(inputs: Context_Menu_Select_AllInputs) => LocalizedString} */
|
|
354
|
+
() => {
|
|
355
|
+
return (
|
|
356
|
+
/** @type {LocalizedString} */
|
|
357
|
+
`Select all`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
);
|
|
361
|
+
const zh_tw2_context_menu_select_all = (
|
|
362
|
+
/** @type {(inputs: Context_Menu_Select_AllInputs) => LocalizedString} */
|
|
363
|
+
() => {
|
|
364
|
+
return (
|
|
365
|
+
/** @type {LocalizedString} */
|
|
366
|
+
`全選`
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
const ja_context_menu_select_all = (
|
|
371
|
+
/** @type {(inputs: Context_Menu_Select_AllInputs) => LocalizedString} */
|
|
372
|
+
() => {
|
|
373
|
+
return (
|
|
374
|
+
/** @type {LocalizedString} */
|
|
375
|
+
`すべて選択`
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
);
|
|
379
|
+
const context_menu_select_all = (
|
|
380
|
+
/** @type {((inputs?: Context_Menu_Select_AllInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Context_Menu_Select_AllInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
381
|
+
((inputs = {}, options = {}) => {
|
|
382
|
+
const locale = options.locale ?? getLocale();
|
|
383
|
+
if (locale === "zh-TW") return zh_tw2_context_menu_select_all();
|
|
384
|
+
if (locale === "ja") return ja_context_menu_select_all();
|
|
385
|
+
return en_context_menu_select_all();
|
|
386
|
+
})
|
|
387
|
+
);
|
|
388
|
+
const en_explorer_copy_path = (
|
|
389
|
+
/** @type {(inputs: Explorer_Copy_PathInputs) => LocalizedString} */
|
|
390
|
+
() => {
|
|
391
|
+
return (
|
|
392
|
+
/** @type {LocalizedString} */
|
|
393
|
+
`Copy path`
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
);
|
|
397
|
+
const zh_tw2_explorer_copy_path = (
|
|
398
|
+
/** @type {(inputs: Explorer_Copy_PathInputs) => LocalizedString} */
|
|
399
|
+
() => {
|
|
400
|
+
return (
|
|
401
|
+
/** @type {LocalizedString} */
|
|
402
|
+
`複製路徑`
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
const ja_explorer_copy_path = (
|
|
407
|
+
/** @type {(inputs: Explorer_Copy_PathInputs) => LocalizedString} */
|
|
408
|
+
() => {
|
|
409
|
+
return (
|
|
410
|
+
/** @type {LocalizedString} */
|
|
411
|
+
`パスをコピー`
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
const explorer_copy_path = (
|
|
416
|
+
/** @type {((inputs?: Explorer_Copy_PathInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Explorer_Copy_PathInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
417
|
+
((inputs = {}, options = {}) => {
|
|
418
|
+
const locale = options.locale ?? getLocale();
|
|
419
|
+
if (locale === "zh-TW") return zh_tw2_explorer_copy_path();
|
|
420
|
+
if (locale === "ja") return ja_explorer_copy_path();
|
|
421
|
+
return en_explorer_copy_path();
|
|
422
|
+
})
|
|
423
|
+
);
|
|
424
|
+
const en_markdown_copy_image = (
|
|
425
|
+
/** @type {(inputs: Markdown_Copy_ImageInputs) => LocalizedString} */
|
|
426
|
+
() => {
|
|
427
|
+
return (
|
|
428
|
+
/** @type {LocalizedString} */
|
|
429
|
+
`Copy image`
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
const zh_tw2_markdown_copy_image = (
|
|
434
|
+
/** @type {(inputs: Markdown_Copy_ImageInputs) => LocalizedString} */
|
|
435
|
+
() => {
|
|
436
|
+
return (
|
|
437
|
+
/** @type {LocalizedString} */
|
|
438
|
+
`複製圖片`
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
);
|
|
442
|
+
const ja_markdown_copy_image = (
|
|
443
|
+
/** @type {(inputs: Markdown_Copy_ImageInputs) => LocalizedString} */
|
|
444
|
+
() => {
|
|
445
|
+
return (
|
|
446
|
+
/** @type {LocalizedString} */
|
|
447
|
+
`画像をコピー`
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
const markdown_copy_image = (
|
|
452
|
+
/** @type {((inputs?: Markdown_Copy_ImageInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Markdown_Copy_ImageInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
453
|
+
((inputs = {}, options = {}) => {
|
|
454
|
+
const locale = options.locale ?? getLocale();
|
|
455
|
+
if (locale === "zh-TW") return zh_tw2_markdown_copy_image();
|
|
456
|
+
if (locale === "ja") return ja_markdown_copy_image();
|
|
457
|
+
return en_markdown_copy_image();
|
|
458
|
+
})
|
|
459
|
+
);
|
|
460
|
+
const en_markdown_copy_image_address = (
|
|
461
|
+
/** @type {(inputs: Markdown_Copy_Image_AddressInputs) => LocalizedString} */
|
|
462
|
+
() => {
|
|
463
|
+
return (
|
|
464
|
+
/** @type {LocalizedString} */
|
|
465
|
+
`Copy image address`
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
const zh_tw2_markdown_copy_image_address = (
|
|
470
|
+
/** @type {(inputs: Markdown_Copy_Image_AddressInputs) => LocalizedString} */
|
|
471
|
+
() => {
|
|
472
|
+
return (
|
|
473
|
+
/** @type {LocalizedString} */
|
|
474
|
+
`複製圖片網址`
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
const ja_markdown_copy_image_address = (
|
|
479
|
+
/** @type {(inputs: Markdown_Copy_Image_AddressInputs) => LocalizedString} */
|
|
480
|
+
() => {
|
|
481
|
+
return (
|
|
482
|
+
/** @type {LocalizedString} */
|
|
483
|
+
`画像のアドレスをコピー`
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
const markdown_copy_image_address = (
|
|
488
|
+
/** @type {((inputs?: Markdown_Copy_Image_AddressInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Markdown_Copy_Image_AddressInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
489
|
+
((inputs = {}, options = {}) => {
|
|
490
|
+
const locale = options.locale ?? getLocale();
|
|
491
|
+
if (locale === "zh-TW") return zh_tw2_markdown_copy_image_address();
|
|
492
|
+
if (locale === "ja") return ja_markdown_copy_image_address();
|
|
493
|
+
return en_markdown_copy_image_address();
|
|
494
|
+
})
|
|
495
|
+
);
|
|
496
|
+
const en_markdown_copy_link = (
|
|
497
|
+
/** @type {(inputs: Markdown_Copy_LinkInputs) => LocalizedString} */
|
|
498
|
+
() => {
|
|
499
|
+
return (
|
|
500
|
+
/** @type {LocalizedString} */
|
|
501
|
+
`Copy link`
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
);
|
|
505
|
+
const zh_tw2_markdown_copy_link = (
|
|
506
|
+
/** @type {(inputs: Markdown_Copy_LinkInputs) => LocalizedString} */
|
|
507
|
+
() => {
|
|
508
|
+
return (
|
|
509
|
+
/** @type {LocalizedString} */
|
|
510
|
+
`複製連結`
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
const ja_markdown_copy_link = (
|
|
515
|
+
/** @type {(inputs: Markdown_Copy_LinkInputs) => LocalizedString} */
|
|
516
|
+
() => {
|
|
517
|
+
return (
|
|
518
|
+
/** @type {LocalizedString} */
|
|
519
|
+
`リンクをコピー`
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
);
|
|
523
|
+
const markdown_copy_link = (
|
|
524
|
+
/** @type {((inputs?: Markdown_Copy_LinkInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Markdown_Copy_LinkInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
525
|
+
((inputs = {}, options = {}) => {
|
|
526
|
+
const locale = options.locale ?? getLocale();
|
|
527
|
+
if (locale === "zh-TW") return zh_tw2_markdown_copy_link();
|
|
528
|
+
if (locale === "ja") return ja_markdown_copy_link();
|
|
529
|
+
return en_markdown_copy_link();
|
|
530
|
+
})
|
|
531
|
+
);
|
|
532
|
+
const en_markdown_open_link = (
|
|
533
|
+
/** @type {(inputs: Markdown_Open_LinkInputs) => LocalizedString} */
|
|
534
|
+
() => {
|
|
535
|
+
return (
|
|
536
|
+
/** @type {LocalizedString} */
|
|
537
|
+
`Open link`
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
);
|
|
541
|
+
const zh_tw2_markdown_open_link = (
|
|
542
|
+
/** @type {(inputs: Markdown_Open_LinkInputs) => LocalizedString} */
|
|
543
|
+
() => {
|
|
544
|
+
return (
|
|
545
|
+
/** @type {LocalizedString} */
|
|
546
|
+
`開啟連結`
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
const ja_markdown_open_link = (
|
|
551
|
+
/** @type {(inputs: Markdown_Open_LinkInputs) => LocalizedString} */
|
|
552
|
+
() => {
|
|
553
|
+
return (
|
|
554
|
+
/** @type {LocalizedString} */
|
|
555
|
+
`リンクを開く`
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
const markdown_open_link = (
|
|
560
|
+
/** @type {((inputs?: Markdown_Open_LinkInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Markdown_Open_LinkInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
561
|
+
((inputs = {}, options = {}) => {
|
|
562
|
+
const locale = options.locale ?? getLocale();
|
|
563
|
+
if (locale === "zh-TW") return zh_tw2_markdown_open_link();
|
|
564
|
+
if (locale === "ja") return ja_markdown_open_link();
|
|
565
|
+
return en_markdown_open_link();
|
|
566
|
+
})
|
|
567
|
+
);
|
|
568
|
+
const en_open_with = (
|
|
569
|
+
/** @type {(inputs: Open_WithInputs) => LocalizedString} */
|
|
570
|
+
() => {
|
|
571
|
+
return (
|
|
572
|
+
/** @type {LocalizedString} */
|
|
573
|
+
`Open with`
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
);
|
|
577
|
+
const zh_tw2_open_with = (
|
|
578
|
+
/** @type {(inputs: Open_WithInputs) => LocalizedString} */
|
|
579
|
+
() => {
|
|
580
|
+
return (
|
|
581
|
+
/** @type {LocalizedString} */
|
|
582
|
+
`開啟方式`
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
const ja_open_with = (
|
|
587
|
+
/** @type {(inputs: Open_WithInputs) => LocalizedString} */
|
|
588
|
+
() => {
|
|
589
|
+
return (
|
|
590
|
+
/** @type {LocalizedString} */
|
|
591
|
+
`このアプリで開く`
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
);
|
|
595
|
+
const open_with = (
|
|
596
|
+
/** @type {((inputs?: Open_WithInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Open_WithInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
597
|
+
((inputs = {}, options = {}) => {
|
|
598
|
+
const locale = options.locale ?? getLocale();
|
|
599
|
+
if (locale === "zh-TW") return zh_tw2_open_with();
|
|
600
|
+
if (locale === "ja") return ja_open_with();
|
|
601
|
+
return en_open_with();
|
|
602
|
+
})
|
|
603
|
+
);
|
|
604
|
+
const en_open_with_failed = (
|
|
605
|
+
/** @type {(inputs: Open_With_FailedInputs) => LocalizedString} */
|
|
606
|
+
(i) => {
|
|
607
|
+
return (
|
|
608
|
+
/** @type {LocalizedString} */
|
|
609
|
+
`Could not open in ${i?.app}: ${i?.message}`
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
const zh_tw2_open_with_failed = (
|
|
614
|
+
/** @type {(inputs: Open_With_FailedInputs) => LocalizedString} */
|
|
615
|
+
(i) => {
|
|
616
|
+
return (
|
|
617
|
+
/** @type {LocalizedString} */
|
|
618
|
+
`無法在 ${i?.app} 中開啟:${i?.message}`
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
);
|
|
622
|
+
const ja_open_with_failed = (
|
|
623
|
+
/** @type {(inputs: Open_With_FailedInputs) => LocalizedString} */
|
|
624
|
+
(i) => {
|
|
625
|
+
return (
|
|
626
|
+
/** @type {LocalizedString} */
|
|
627
|
+
`${i?.app} で開けませんでした:${i?.message}`
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
);
|
|
631
|
+
const open_with_failed = (
|
|
632
|
+
/** @type {((inputs: Open_With_FailedInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Open_With_FailedInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
633
|
+
((inputs, options = {}) => {
|
|
634
|
+
const locale = options.locale ?? getLocale();
|
|
635
|
+
if (locale === "zh-TW") return zh_tw2_open_with_failed(inputs);
|
|
636
|
+
if (locale === "ja") return ja_open_with_failed(inputs);
|
|
637
|
+
return en_open_with_failed(inputs);
|
|
638
|
+
})
|
|
639
|
+
);
|
|
640
|
+
const en_panel_reveal = (
|
|
641
|
+
/** @type {(inputs: Panel_RevealInputs) => LocalizedString} */
|
|
642
|
+
() => {
|
|
643
|
+
return (
|
|
644
|
+
/** @type {LocalizedString} */
|
|
645
|
+
`Show in folder`
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
const zh_tw2_panel_reveal = (
|
|
650
|
+
/** @type {(inputs: Panel_RevealInputs) => LocalizedString} */
|
|
651
|
+
() => {
|
|
652
|
+
return (
|
|
653
|
+
/** @type {LocalizedString} */
|
|
654
|
+
`在資料夾中顯示`
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
);
|
|
658
|
+
const ja_panel_reveal = (
|
|
659
|
+
/** @type {(inputs: Panel_RevealInputs) => LocalizedString} */
|
|
660
|
+
() => {
|
|
661
|
+
return (
|
|
662
|
+
/** @type {LocalizedString} */
|
|
663
|
+
`フォルダを表示`
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
);
|
|
667
|
+
const panel_reveal = (
|
|
668
|
+
/** @type {((inputs?: Panel_RevealInputs, options?: { locale?: "en" | "zh-TW" | "ja" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Panel_RevealInputs, { locale?: "en" | "zh-TW" | "ja" }, {}>} */
|
|
669
|
+
((inputs = {}, options = {}) => {
|
|
670
|
+
const locale = options.locale ?? getLocale();
|
|
671
|
+
if (locale === "zh-TW") return zh_tw2_panel_reveal();
|
|
672
|
+
if (locale === "ja") return ja_panel_reveal();
|
|
673
|
+
return en_panel_reveal();
|
|
674
|
+
})
|
|
675
|
+
);
|
|
56
676
|
const launchers = {
|
|
57
677
|
vscode: { name: "VS Code", bundle: "Visual Studio Code.app", cli: "code", opensFiles: true },
|
|
58
678
|
cursor: { name: "Cursor", bundle: "Cursor.app", cli: "cursor", opensFiles: true },
|
|
@@ -125,18 +745,138 @@ const openWith = (path, id) => tryPromise({
|
|
|
125
745
|
},
|
|
126
746
|
catch: (cause) => new OpenerError({ message: cause instanceof Error ? cause.message : String(cause) })
|
|
127
747
|
});
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
748
|
+
const imageOrigin = (src, cloudOfRoot) => {
|
|
749
|
+
const project = projectFileRequest(src);
|
|
750
|
+
if (project !== null)
|
|
751
|
+
return { kind: "file", path: join(project.root, project.path), local: cloudOfRoot(project.root) === void 0 };
|
|
752
|
+
const attachment = attachmentRequest(src);
|
|
753
|
+
if (attachment !== null) return { kind: "file", path: attachment.path, local: attachment.environment === null };
|
|
754
|
+
const asset = githubAssetId(src);
|
|
755
|
+
return { kind: "web", address: asset === null ? src : `https://github.com/user-attachments/assets/${asset}` };
|
|
756
|
+
};
|
|
757
|
+
const openerIcon = (opener) => opener.icon === null ? void 0 : nativeImage.createFromDataURL(opener.icon).resize({ width: 16, height: 16 });
|
|
758
|
+
const linkItems = ({ params, locale, appUrl: appUrl2 }) => {
|
|
759
|
+
const { linkURL } = params;
|
|
760
|
+
if (linkURL === "" || linkURL.startsWith(new URL(".", appUrl2).href)) return [];
|
|
761
|
+
const web = externalUrl(linkURL);
|
|
762
|
+
return [
|
|
763
|
+
...web === null ? [] : [{ label: markdown_open_link({}, { locale }), click: () => void shell.openExternal(web) }],
|
|
764
|
+
{ label: markdown_copy_link({}, { locale }), click: () => void clipboard.writeText(linkURL) }
|
|
765
|
+
];
|
|
766
|
+
};
|
|
767
|
+
const imageItems = ({ window: window2, params, locale, image, openers, open }) => {
|
|
768
|
+
if (image === null) return [];
|
|
769
|
+
const copy = [
|
|
770
|
+
{ label: markdown_copy_image({}, { locale }), click: () => window2.webContents.copyImageAt(params.x, params.y) },
|
|
771
|
+
image.kind === "file" ? { label: explorer_copy_path({}, { locale }), click: () => void clipboard.writeText(image.path) } : { label: markdown_copy_image_address({}, { locale }), click: () => void clipboard.writeText(image.address) }
|
|
772
|
+
];
|
|
773
|
+
if (image.kind === "web" || !image.local) return copy;
|
|
774
|
+
const { path } = image;
|
|
775
|
+
const apps = openers.map((opener) => ({
|
|
776
|
+
label: opener.name,
|
|
777
|
+
icon: openerIcon(opener),
|
|
778
|
+
click: () => open(path, opener)
|
|
779
|
+
}));
|
|
780
|
+
return [
|
|
781
|
+
...copy,
|
|
782
|
+
{ type: "separator" },
|
|
783
|
+
{
|
|
784
|
+
label: open_with({}, { locale }),
|
|
785
|
+
submenu: [
|
|
786
|
+
...apps,
|
|
787
|
+
...apps.length > 0 ? [{ type: "separator" }] : [],
|
|
788
|
+
{ label: panel_reveal({}, { locale }), click: () => shell.showItemInFolder(path) }
|
|
789
|
+
]
|
|
790
|
+
}
|
|
791
|
+
];
|
|
792
|
+
};
|
|
793
|
+
const textItems = ({ window: window2, params, locale }) => {
|
|
794
|
+
const page = window2.webContents;
|
|
795
|
+
const copy = { label: context_menu_copy({}, { locale }), click: () => page.copy() };
|
|
796
|
+
const { isEditable, editFlags, selectionText } = params;
|
|
797
|
+
if (isEditable)
|
|
798
|
+
return [
|
|
799
|
+
{ label: context_menu_cut({}, { locale }), enabled: editFlags.canCut, click: () => page.cut() },
|
|
800
|
+
{ ...copy, enabled: editFlags.canCopy },
|
|
801
|
+
{ label: context_menu_paste({}, { locale }), enabled: editFlags.canPaste, click: () => page.paste() },
|
|
802
|
+
{ type: "separator" },
|
|
803
|
+
{
|
|
804
|
+
label: context_menu_select_all({}, { locale }),
|
|
805
|
+
enabled: editFlags.canSelectAll,
|
|
806
|
+
click: () => page.selectAll()
|
|
807
|
+
}
|
|
808
|
+
];
|
|
809
|
+
return selectionText.trim() === "" ? [] : [copy];
|
|
810
|
+
};
|
|
811
|
+
const contextMenuTemplate = (context) => [linkItems(context), imageItems(context), textItems(context)].filter((section) => section.length > 0).flatMap((section, index) => index === 0 ? section : [{ type: "separator" }, ...section]);
|
|
812
|
+
const handleContextMenu = (window2, runtime, appUrl2) => window2.webContents.on("context-menu", (_event, params) => {
|
|
813
|
+
const show = gen(function* () {
|
|
814
|
+
const { locale } = yield* (yield* ClientSettings).get;
|
|
815
|
+
const environments = yield* Environments;
|
|
816
|
+
const image = params.mediaType === "image" && params.srcURL !== "" && !params.srcURL.startsWith("data:") ? imageOrigin(params.srcURL, (root) => environments.owner("root", root)) : null;
|
|
817
|
+
const openers = image?.kind === "file" && image.local ? yield* listOpeners : [];
|
|
818
|
+
const template = contextMenuTemplate({
|
|
819
|
+
window: window2,
|
|
820
|
+
params,
|
|
821
|
+
locale,
|
|
822
|
+
appUrl: appUrl2,
|
|
823
|
+
image,
|
|
824
|
+
openers: openers.filter((opener) => opener.opensFiles),
|
|
825
|
+
open: (path, opener) => void runtime.runPromise(
|
|
826
|
+
openWith(path, opener.id).pipe(
|
|
827
|
+
andThen(flatMap(ClientSettings, (settings) => settings.set({ openWith: opener.id }))),
|
|
828
|
+
catch_(
|
|
829
|
+
(error) => promise(
|
|
830
|
+
() => dialog.showMessageBox(window2, {
|
|
831
|
+
type: "error",
|
|
832
|
+
message: open_with_failed({ app: opener.name, message: error.message }, { locale })
|
|
833
|
+
})
|
|
834
|
+
)
|
|
835
|
+
)
|
|
836
|
+
)
|
|
837
|
+
)
|
|
838
|
+
});
|
|
839
|
+
if (template.length > 0) Menu.buildFromTemplate(template).popup({ window: window2 });
|
|
840
|
+
});
|
|
841
|
+
void runtime.runPromise(show).catch((cause) => console.error("context menu failed", cause));
|
|
842
|
+
});
|
|
843
|
+
const require$2 = createRequire(import.meta.url);
|
|
844
|
+
const notificationPermission = sync(() => {
|
|
845
|
+
if (process.platform !== "darwin") return "unknown";
|
|
846
|
+
const { getAuthStatus } = require$2("node-mac-permissions");
|
|
847
|
+
const status = getAuthStatus("notifications");
|
|
848
|
+
switch (status) {
|
|
849
|
+
case "authorized":
|
|
850
|
+
case "provisional":
|
|
851
|
+
return "granted";
|
|
852
|
+
case "denied":
|
|
853
|
+
case "restricted":
|
|
854
|
+
return "denied";
|
|
855
|
+
case "not determined":
|
|
856
|
+
return "notDetermined";
|
|
857
|
+
default:
|
|
858
|
+
return "unknown";
|
|
859
|
+
}
|
|
860
|
+
}).pipe(catchDefect(() => succeed("unknown")));
|
|
861
|
+
const askNotificationPermission = (title, body) => callback((resume) => {
|
|
862
|
+
const notification = new Notification({ title, body, silent: true });
|
|
863
|
+
notification.once("show", () => resume(succeed("shown")));
|
|
864
|
+
notification.once("failed", () => resume(succeed("refused")));
|
|
865
|
+
notification.show();
|
|
866
|
+
}).pipe(timeoutOrElse({ duration: seconds(10), orElse: () => succeed("noAnswer") }));
|
|
867
|
+
const bringToFront = (window2) => {
|
|
868
|
+
if (window2.isMinimized()) window2.restore();
|
|
869
|
+
window2.show();
|
|
131
870
|
app.focus({ steal: true });
|
|
132
|
-
|
|
871
|
+
window2.focus();
|
|
133
872
|
};
|
|
134
|
-
const showOpenDialog = (
|
|
135
|
-
const desktopCalls = (
|
|
136
|
-
show: sync(() =>
|
|
873
|
+
const showOpenDialog = (window2, options) => promise(() => window2 ? dialog.showOpenDialog(window2, options) : dialog.showOpenDialog(options));
|
|
874
|
+
const desktopCalls = (window2) => ({
|
|
875
|
+
show: sync(() => window2?.show()),
|
|
137
876
|
focus: sync(() => {
|
|
138
|
-
if (
|
|
877
|
+
if (window2) bringToFront(window2);
|
|
139
878
|
}),
|
|
879
|
+
setBadgeCount: (count) => sync(() => app.setBadgeCount(count)),
|
|
140
880
|
setColorScheme: (scheme) => sync(() => {
|
|
141
881
|
nativeTheme.themeSource = scheme;
|
|
142
882
|
}),
|
|
@@ -150,16 +890,16 @@ const desktopCalls = (window) => ({
|
|
|
150
890
|
openers: listOpeners,
|
|
151
891
|
openWith,
|
|
152
892
|
pickFolder: map(
|
|
153
|
-
showOpenDialog(
|
|
893
|
+
showOpenDialog(window2, { properties: ["openDirectory", "createDirectory"] }),
|
|
154
894
|
(result) => result.canceled ? null : result.filePaths[0] ?? null
|
|
155
895
|
),
|
|
156
896
|
pickFiles: map(
|
|
157
|
-
showOpenDialog(
|
|
897
|
+
showOpenDialog(window2, { properties: ["openFile", "multiSelections"] }),
|
|
158
898
|
(result) => result.canceled ? [] : result.filePaths
|
|
159
899
|
),
|
|
160
900
|
notificationPermission,
|
|
161
901
|
askNotificationPermission,
|
|
162
|
-
screenOwner:
|
|
902
|
+
screenOwner: window2?.webContents ?? null
|
|
163
903
|
});
|
|
164
904
|
const untrustedSender = {
|
|
165
905
|
error: { tag: "UntrustedSender", message: "RPC is only available to the HinaCode window" }
|
|
@@ -171,7 +911,7 @@ const registerIpc = (runtime, appUrl2) => {
|
|
|
171
911
|
);
|
|
172
912
|
};
|
|
173
913
|
const sendToWindows = (encoded) => {
|
|
174
|
-
for (const
|
|
914
|
+
for (const window2 of BrowserWindow.getAllWindows()) window2.webContents.send(EVENT_CHANNEL, encoded);
|
|
175
915
|
};
|
|
176
916
|
const binary = join(import.meta.dirname, "../../tools/resource-monitor/bin/resource-monitor");
|
|
177
917
|
const startResourceMonitor = (userData) => {
|
|
@@ -260,9 +1000,9 @@ const sandboxed = (response) => {
|
|
|
260
1000
|
return new Response(response.body, { status: response.status, headers });
|
|
261
1001
|
};
|
|
262
1002
|
const serveAttachments = (runtime, attachmentsRoot) => protocol.handle(ATTACHMENT_PROTOCOL, async (request) => {
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
const environment =
|
|
1003
|
+
const target = attachmentRequest(request.url);
|
|
1004
|
+
if (target === null) return new Response(null, { status: 404 });
|
|
1005
|
+
const { path, environment } = target;
|
|
266
1006
|
if (environment !== null)
|
|
267
1007
|
return fetchFromCloud(runtime, environment, { method: "attachments.read", payload: { path } });
|
|
268
1008
|
if (!isInside(attachmentsRoot, path)) return new Response(null, { status: 403 });
|
|
@@ -326,8 +1066,8 @@ const limitBrowserPermissions = () => {
|
|
|
326
1066
|
);
|
|
327
1067
|
browser.setPermissionCheckHandler((_page, permission) => permission === "clipboard-sanitized-write");
|
|
328
1068
|
};
|
|
329
|
-
const createWindow = () => {
|
|
330
|
-
const
|
|
1069
|
+
const createWindow = (runtime) => {
|
|
1070
|
+
const window2 = new BrowserWindow({
|
|
331
1071
|
width: 1280,
|
|
332
1072
|
height: 820,
|
|
333
1073
|
minWidth: 720,
|
|
@@ -347,8 +1087,8 @@ const createWindow = () => {
|
|
|
347
1087
|
additionalArguments: liquidGlass ? [LIQUID_GLASS_ARGUMENT] : []
|
|
348
1088
|
}
|
|
349
1089
|
});
|
|
350
|
-
liquidGlass?.addView(
|
|
351
|
-
|
|
1090
|
+
liquidGlass?.addView(window2.getNativeWindowHandle());
|
|
1091
|
+
window2.webContents.setWindowOpenHandler(({ url }) => {
|
|
352
1092
|
const external = externalUrl(url);
|
|
353
1093
|
if (external) void shell.openExternal(external);
|
|
354
1094
|
return { action: "deny" };
|
|
@@ -356,13 +1096,14 @@ const createWindow = () => {
|
|
|
356
1096
|
const stayInApp = (event) => {
|
|
357
1097
|
if (!isAllowedNavigation(event.url, event.isMainFrame, appUrl)) event.preventDefault();
|
|
358
1098
|
};
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
1099
|
+
window2.webContents.on("will-frame-navigate", stayInApp);
|
|
1100
|
+
window2.webContents.on("will-redirect", stayInApp);
|
|
1101
|
+
window2.webContents.on("will-attach-webview", (event, preferences, params) => {
|
|
362
1102
|
if (!lockDownWebview(preferences, params)) event.preventDefault();
|
|
363
1103
|
});
|
|
364
|
-
|
|
365
|
-
|
|
1104
|
+
window2.webContents.on("did-attach-webview", (_event, page) => keepOnTheWeb(page));
|
|
1105
|
+
handleContextMenu(window2, runtime, appUrl);
|
|
1106
|
+
void window2.loadURL(appUrl);
|
|
366
1107
|
};
|
|
367
1108
|
const setMacMenu = () => Menu.setApplicationMenu(
|
|
368
1109
|
Menu.buildFromTemplate([
|
|
@@ -428,14 +1169,14 @@ app.whenReady().then(async () => {
|
|
|
428
1169
|
serveProjectFiles(runtime);
|
|
429
1170
|
limitBrowserPermissions();
|
|
430
1171
|
app.on("activate", () => {
|
|
431
|
-
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
|
1172
|
+
if (BrowserWindow.getAllWindows().length === 0) createWindow(runtime);
|
|
432
1173
|
});
|
|
433
1174
|
app.on("second-instance", () => {
|
|
434
|
-
const [
|
|
435
|
-
if (
|
|
436
|
-
else createWindow();
|
|
1175
|
+
const [window2] = BrowserWindow.getAllWindows();
|
|
1176
|
+
if (window2) bringToFront(window2);
|
|
1177
|
+
else createWindow(runtime);
|
|
437
1178
|
});
|
|
438
|
-
createWindow();
|
|
1179
|
+
createWindow(runtime);
|
|
439
1180
|
});
|
|
440
1181
|
app.on("window-all-closed", () => {
|
|
441
1182
|
if (process.platform !== "darwin") app.quit();
|