Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a70273a

Browse files
author
Akos Kitta
committed
patch the index.html only in the bundled app.
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 79053c4 commit a70273a

File tree

6 files changed

+102
-41
lines changed

6 files changed

+102
-41
lines changed

‎arduino-ide-extension/src/browser/theia/core/frontend-application.ts‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,22 @@ export class FrontendApplication extends TheiaFrontendApplication {
3636
}
3737

3838
protected getStartupIndicator(host: HTMLElement): HTMLElement | undefined {
39-
const startupElements = host.getElementsByClassName('old-theia-preload'); // https://github.com/eclipse-theia/theia/pull/10761#issuecomment-1131476318
40-
return startupElements.length === 0
41-
? undefined
42-
: (startupElements[0] as HTMLElement);
39+
let startupElement = this.doGetStartupIndicator(host, 'old-theia-preload'); // https://github.com/eclipse-theia/theia/pull/10761#issuecomment-1131476318
40+
if (!startupElement) {
41+
startupElement = this.doGetStartupIndicator(host, 'theia-preload'); // We show the new Theia spinner in dev mode.
42+
}
43+
return startupElement;
44+
}
45+
46+
private doGetStartupIndicator(
47+
host: HTMLElement,
48+
classNames: string
49+
): HTMLElement | undefined {
50+
const elements = host.getElementsByClassName(classNames);
51+
const first = elements[0];
52+
if (first instanceof HTMLElement) {
53+
return first;
54+
}
55+
return undefined;
4356
}
4457
}

‎arduino-ide-extension/src/electron-main/theia/electron-main-application.ts‎

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
9191
const workspaces: WorkspaceOptions[] | undefined = this.electronStore.get(WORKSPACES);
9292
let useDefault = true;
9393
if (workspaces && workspaces.length > 0) {
94+
console.log(
95+
`Restoring workspace roots: ${workspaces.map(({ file }) => file)}`
96+
);
9497
for (const workspace of workspaces) {
9598
if (await this.isValidSketchPath(workspace.file)) {
9699
useDefault = false;
@@ -181,7 +184,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
181184
options = this.avoidOverlap(options);
182185
let electronWindow: BrowserWindow | undefined;
183186
if (this.windows.size) {
184-
electronWindow = await super.createWindow(options);
187+
electronWindow = await this.doCreateWindow(options);
185188
} else {
186189
const { bounds } = screen.getDisplayNearestPoint(
187190
screen.getCursorScreenPoint()
@@ -221,11 +224,22 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
221224
minVisible: 2000,
222225
splashScreenOpts,
223226
},
224-
(windowOptions) => super.createWindow(windowOptions),
227+
(windowOptions) => this.doCreateWindow(windowOptions),
225228
this.splashService.onCloseRequested
226229
);
227230
}
231+
return electronWindow;
232+
}
233+
234+
private async doCreateWindow(
235+
options: TheiaBrowserWindowOptions
236+
): Promise<BrowserWindow> {
237+
const electronWindow = await super.createWindow(options);
238+
this.attachListenersToWindow(electronWindow);
239+
return electronWindow;
240+
}
228241

242+
private attachListenersToWindow(electronWindow: BrowserWindow) {
229243
electronWindow.webContents.on(
230244
'new-window',
231245
(event, url, frameName, disposition, options) => {
@@ -254,7 +268,6 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
254268
}
255269
);
256270
this.attachClosedWorkspace(electronWindow);
257-
return electronWindow;
258271
}
259272

260273
protected async startBackend(): Promise<number> {
@@ -331,12 +344,16 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
331344
if (workspace) {
332345
const workspaceUri = URI.file(workspace);
333346
const bounds = window.getNormalBounds();
347+
const now = Date.now();
348+
console.log(
349+
`Marking workspace as a closed sketch. Workspace URI: ${workspaceUri.toString()}. Date: ${now}.`
350+
);
334351
this.closedWorkspaces.push({
335352
...bounds,
336353
isMaximized: window.isMaximized(),
337354
isFullScreen: window.isFullScreen(),
338355
file: workspaceUri.fsPath,
339-
time: Date.now()
356+
time: now
340357
})
341358
}
342359
});
@@ -346,14 +363,29 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
346363
// Only add workspaces which were closed within the last second (1000 milliseconds)
347364
const threshold = Date.now() - 1000;
348365
const visited = new Set<string>();
349-
const workspaces = this.closedWorkspaces.filter(e => {
350-
if (e.time < threshold || visited.has(e.file)) {
351-
return false;
352-
}
353-
visited.add(e.file);
354-
return true;
355-
}).sort((a, b) => a.file.localeCompare(b.file));
366+
const workspaces = this.closedWorkspaces
367+
.filter((e) => {
368+
if (e.time < threshold) {
369+
console.log(
370+
`Skipped storing sketch as workspace root. Expected minimum threshold: <${threshold}>. Was: <${e.time}>.`
371+
);
372+
return false;
373+
}
374+
if (visited.has(e.file)) {
375+
console.log(
376+
`Skipped storing sketch as workspace root. Already visited: <${e.file}>.`
377+
);
378+
return false;
379+
}
380+
visited.add(e.file);
381+
console.log(`Storing the sketch as a workspace root: <${e.file}>.`);
382+
return true;
383+
})
384+
.sort((a, b) => a.file.localeCompare(b.file));
356385
this.electronStore.set(WORKSPACES, workspaces);
386+
console.log(
387+
`Stored workspaces roots: ${workspaces.map(({ file }) => file)}`
388+
);
357389

358390
super.onWillQuit(event);
359391
}

‎electron-app/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"electron": "^15.3.5"
3030
},
3131
"scripts": {
32-
"prepare": "theia build --mode development && node ./scripts/patch-theia-preload.js ./lib/index.html",
32+
"prepare": "theia build --mode development",
3333
"start": "theia start --plugins=local-dir:../plugins",
3434
"watch": "theia build --watch --mode development"
3535
},
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Patch the Theia spinner: https://github.com/eclipse-theia/theia/pull/10761#issuecomment-1131476318
2+
// Replaces the `theia-preload` selector with `old-theia-preload` in the generated `index.html`.
3+
let arg = process.argv.splice(2)[0]
4+
if (!arg) {
5+
console.error("The path to the index.html to patch is missing. Use 'node patch-theia-preload.js ./path/to/index.html'")
6+
process.exit(1)
7+
}
8+
(async () => {
9+
const { promises: fs } = require('fs')
10+
const path = require('path')
11+
const index = path.isAbsolute(arg) ? arg : path.join(process.cwd(), arg)
12+
console.log(`>>> Patching 'theia-preload' with 'old-theia-preload' in ${index}.`)
13+
const content = await fs.readFile(index, { encoding: 'utf-8' })
14+
await fs.writeFile(index, content.replace(/theia-preload/g, 'old-theia-preload'), { encoding: 'utf-8' })
15+
console.log(`<<< Successfully patched index.html.`)
16+
})()

‎electron/build/template-package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"package": "cross-env DEBUG=* && electron-builder --publish=never",
2626
"package:publish": "cross-env DEBUG=* && electron-builder --publish=always",
2727
"download:plugins": "theia download:plugins",
28-
"patch": "ncp ./patch/main.js ./src-gen/backend/main.js && node ../../electron-app/scripts/patch-theia-preload.js ./lib/index.html"
28+
"patch": "ncp ./patch/main.js ./src-gen/backend/main.js && node ./scripts/patch-theia-preload.js ./lib/index.html"
2929
},
3030
"engines": {
3131
"node": ">=14.0.0 <15"

‎yarn.lock‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4408,7 +4408,7 @@ array-ify@^1.0.0:
44084408
resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece"
44094409
integrity sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==
44104410

4411-
array-includes@^3.1.4:
4411+
array-includes@^3.1.4, array-includes@^3.1.5:
44124412
version "3.1.5"
44134413
resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.5.tgz#2c320010db8d31031fd2a5f6b3bbd4b1aad31bdb"
44144414
integrity sha512-iSDYZMMyTPkiFasVqfuAQnWAYcvO/SeBSCGKePoEthjp4LEMTe4uLc7b025o4jAZpHhihh8xPo99TNWUWWkGDQ==
@@ -4450,7 +4450,7 @@ array-unique@^0.3.2:
44504450
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"
44514451
integrity sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==
44524452

4453-
array.prototype.flatmap@^1.2.5:
4453+
array.prototype.flatmap@^1.3.0:
44544454
version "1.3.0"
44554455
resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.0.tgz#a7e8ed4225f4788a70cd910abcf0791e76a5534f"
44564456
integrity sha512-PZC9/8TKAIxcWKdyeb77EzULHPrIX/tIZebLJUQOMR1OwYosT8yggdfWScfTBCDj5utONvOuPQQumYsU2ULbkg==
@@ -5023,7 +5023,7 @@ cacache@^15.2.0:
50235023
tar "^6.0.2"
50245024
unique-filename "^1.1.1"
50255025

5026-
cacache@^16.0.2:
5026+
cacache@^16.1.0:
50275027
version "16.1.0"
50285028
resolved "https://registry.yarnpkg.com/cacache/-/cacache-16.1.0.tgz#87a6bae558a511c9cb2a13768073e240ca76153a"
50295029
integrity sha512-Pk4aQkwCW82A4jGKFvcGkQFqZcMspfP9YWq9Pr87/ldDvlWf718zeI6KWCdKt/jeihu6BytHRUicJPB1K2k8EQ==
@@ -6822,24 +6822,24 @@ eslint-plugin-react-hooks@^4.2.0:
68226822
integrity sha512-8k1gRt7D7h03kd+SAAlzXkQwWK22BnK6GKZG+FJA6BAGy22CFvl8kCIXKpVux0cCxMWDQUPqSok0LKaZ0aOcCw==
68236823

68246824
eslint-plugin-react@^7.24.0:
6825-
version "7.29.4"
6826-
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.29.4.tgz#4717de5227f55f3801a5fd51a16a4fa22b5914d2"
6827-
integrity sha512-CVCXajliVh509PcZYRFyu/BoUEz452+jtQJq2b3Bae4v3xBUWPLCmtmBM+ZinG4MzwmxJgJ2M5rMqhqLVn7MtQ==
6825+
version "7.30.0"
6826+
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.30.0.tgz#8e7b1b2934b8426ac067a0febade1b13bd7064e3"
6827+
integrity sha512-RgwH7hjW48BleKsYyHK5vUAvxtE9SMPDKmcPRQgtRCYaZA0XQPt5FSkrU3nhz5ifzMZcA8opwmRJ2cmOO8tr5A==
68286828
dependencies:
6829-
array-includes "^3.1.4"
6830-
array.prototype.flatmap "^1.2.5"
6829+
array-includes "^3.1.5"
6830+
array.prototype.flatmap "^1.3.0"
68316831
doctrine "^2.1.0"
68326832
estraverse "^5.3.0"
68336833
jsx-ast-utils "^2.4.1 || ^3.0.0"
68346834
minimatch "^3.1.2"
68356835
object.entries "^1.1.5"
68366836
object.fromentries "^2.0.5"
6837-
object.hasown "^1.1.0"
6837+
object.hasown "^1.1.1"
68386838
object.values "^1.1.5"
68396839
prop-types "^15.8.1"
68406840
resolve "^2.0.0-next.3"
68416841
semver "^6.3.0"
6842-
string.prototype.matchall "^4.0.6"
6842+
string.prototype.matchall "^4.0.7"
68436843

68446844
eslint-plugin-unused-imports@^1.1.1:
68456845
version "1.1.5"
@@ -9503,9 +9503,9 @@ keyv@^3.0.0:
95039503
json-buffer "3.0.0"
95049504

95059505
keyv@^4.0.0:
9506-
version "4.2.8"
9507-
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.2.8.tgz#6c91189fe6134d8a526cb360566693c095fcfb60"
9508-
integrity sha512-IZZo6krhHWPhgsP5mBkEdPopVPN/stgCnBVuqi6dda/Nm5mDTOSVTrFMkWqlJsDum+B0YSe887tNxdjDWkO7aQ==
9506+
version "4.2.9"
9507+
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.2.9.tgz#b8f25d4968b583ed7f07fceadab646d4baadad6b"
9508+
integrity sha512-vqRBrN4xQHud7UMAGzGGFbt96MtGB9pb0OOg8Dhtq5RtiswCb1pCFq878iqC4hdeOP6eDPnCoFxA+2TXx427Ow==
95099509
dependencies:
95109510
compress-brotli "^1.3.8"
95119511
json-buffer "3.0.1"
@@ -10027,12 +10027,12 @@ make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0:
1002710027
semver "^6.0.0"
1002810028

1002910029
make-fetch-happen@^10.0.3:
10030-
version "10.1.3"
10031-
resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-10.1.3.tgz#d7ecd4a22563b2c05b74735eda46569da26a46f6"
10032-
integrity sha512-s/UjmGjUHn9m52cctFhN2ITObbT+axoUhgeir8xGrOlPbKDyJsdhQzb8PGncPQQ28uduHybFJ6Iumy2OZnreXw==
10030+
version "10.1.4"
10031+
resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-10.1.4.tgz#b68a64367d2c402f24edc48308ff193d11fc2618"
10032+
integrity sha512-hU1w68PqfH7FdMgjbiziJoACY0edlbIZ0CyKnpcEruVdCjsUrN+qoenOCIayNqVBK7toSWwbDxvQlrhH0gjRdg==
1003310033
dependencies:
1003410034
agentkeepalive "^4.2.1"
10035-
cacache "^16.0.2"
10035+
cacache "^16.1.0"
1003610036
http-cache-semantics "^4.1.0"
1003710037
http-proxy-agent "^5.0.0"
1003810038
https-proxy-agent "^5.0.0"
@@ -10910,7 +10910,7 @@ nano@^9.0.5:
1091010910
qs "^6.9.4"
1091110911
tough-cookie "^4.0.0"
1091210912

10913-
nanoid@^3.3.3:
10913+
nanoid@^3.3.4:
1091410914
version "3.3.4"
1091510915
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab"
1091610916
integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==
@@ -11396,7 +11396,7 @@ object.getownpropertydescriptors@^2.0.3:
1139611396
define-properties "^1.1.3"
1139711397
es-abstract "^1.19.1"
1139811398

11399-
object.hasown@^1.1.0:
11399+
object.hasown@^1.1.1:
1140011400
version "1.1.1"
1140111401
resolved "https://registry.yarnpkg.com/object.hasown/-/object.hasown-1.1.1.tgz#ad1eecc60d03f49460600430d97f23882cf592a3"
1140211402
integrity sha512-LYLe4tivNQzq4JdaWW6WO3HMZZJWzkkH8fnI6EebWl0VZth2wL2Lovm74ep2/gZzlaTdV62JZHEqHQ2yVn8Q/A==
@@ -12069,11 +12069,11 @@ postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0:
1206912069
integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==
1207012070

1207112071
postcss@^8.4.7:
12072-
version "8.4.13"
12073-
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.13.tgz#7c87bc268e79f7f86524235821dfdf9f73e5d575"
12074-
integrity sha512-jtL6eTBrza5MPzy8oJLFuUscHDXTV5KcLlqAWHl5q5WYRfnNRGSmOZmOZ1T6Gy7A99mOZfqungmZMpMmCVJ8ZA==
12072+
version "8.4.14"
12073+
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.14.tgz#ee9274d5622b4858c1007a74d76e42e56fd21caf"
12074+
integrity sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==
1207512075
dependencies:
12076-
nanoid "^3.3.3"
12076+
nanoid "^3.3.4"
1207712077
picocolors "^1.0.0"
1207812078
source-map-js "^1.0.2"
1207912079

@@ -13965,7 +13965,7 @@ string-width@^3.0.0, string-width@^3.1.0:
1396513965
is-fullwidth-code-point "^2.0.0"
1396613966
strip-ansi "^5.1.0"
1396713967

13968-
string.prototype.matchall@^4.0.6:
13968+
string.prototype.matchall@^4.0.7:
1396913969
version "4.0.7"
1397013970
resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz#8e6ecb0d8a1fb1fda470d81acecb2dba057a481d"
1397113971
integrity sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg==

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /