Skip to content

Commit a8ff6be

Browse files
authored
Merge branch 'Acode-Foundation:main' into strings/id-lang
2 parents 56c88c4 + 657e87c commit a8ff6be

5 files changed

Lines changed: 81 additions & 19 deletions

File tree

src/components/WebComponents/wcPage.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,19 @@ class PageHandler {
220220

221221
this.$el.on("hide", this.onhide);
222222
this.$el.on("show", this.onshow);
223+
224+
// Cache scroll position on scroll event to prevent synchronous layout reading (forced reflow) during page transitions
225+
this.$el.addEventListener(
226+
"scroll",
227+
(e) => {
228+
const $body = this.$el.body;
229+
if ($body && e.target === $body) {
230+
this.scrollLeft = $body.scrollLeft;
231+
this.scrollTop = $body.scrollTop;
232+
}
233+
},
234+
{ capture: true, passive: true },
235+
);
223236
}
224237

225238
/**
@@ -228,11 +241,6 @@ class PageHandler {
228241
replaceEl() {
229242
this.$el.off("hide", this.onhide);
230243
if (!this.$el.isConnected || this.$replacement.isConnected) return;
231-
const $body = this.$el.body;
232-
if ($body) {
233-
this.scrollLeft = $body.scrollLeft;
234-
this.scrollTop = $body.scrollTop;
235-
}
236244
if (typeof this.onReplace === "function") this.onReplace();
237245
this.$el.parentElement.replaceChild(this.$replacement, this.$el);
238246
this.$el.classList.add("no-transition");

src/components/settingsPage.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,19 @@ function shouldEnableSearch(type, settingsCount) {
281281
}
282282

283283
function restoreAllSettingsPages() {
284-
Object.values(appSettings.uiSettings).forEach((page) => {
284+
getSettingsPages().forEach((page) => {
285285
page.restoreList();
286286
});
287287
}
288288

289289
function createSearchHandler(type, searchItems) {
290+
let settingsPages;
291+
290292
return (key) => {
291293
if (type === "united") {
292294
const $items = [];
293-
Object.values(appSettings.uiSettings).forEach((page) => {
295+
settingsPages ??= getSettingsPages(true);
296+
settingsPages.forEach((page) => {
294297
$items.push(...page.search(key));
295298
});
296299
return $items;
@@ -303,6 +306,16 @@ function createSearchHandler(type, searchItems) {
303306
};
304307
}
305308

309+
function getSettingsPages(includeLazyPages = false) {
310+
const keys = includeLazyPages
311+
? Object.getOwnPropertyNames(appSettings.uiSettings)
312+
: Object.keys(appSettings.uiSettings);
313+
314+
return keys
315+
.map((key) => appSettings.uiSettings[key])
316+
.filter((page) => page?.search && page?.restoreList);
317+
}
318+
306319
function createNote(note) {
307320
return (
308321
<div className="note">

src/lib/run.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,15 @@ async function run(
260260
if (pathName) {
261261
url = Url.join(pathName, reqPath);
262262
file = editorManager.getFile(url, "uri");
263-
} else if (!activeFile.uri) {
263+
} else if (!activeFile.uri && filename === reqPath) {
264264
file = activeFile;
265265
}
266266

267+
if (!url && !file) {
268+
error(reqId);
269+
return;
270+
}
271+
267272
// Handle extensionless URLs (e.g., "about" -> "about.html" or "about/index.html")
268273
if (!ext && pathName) {
269274
// Try exact match first for extensionless files (LICENSE, README, etc.)
@@ -302,7 +307,7 @@ async function run(
302307
switch (ext) {
303308
case ".htm":
304309
case ".html":
305-
if (file && file.loaded && file.isUnsaved) {
310+
if (!url || (file && file.loaded && file.isUnsaved)) {
306311
sendHTML(file.session?.doc?.toString(), reqId);
307312
} else {
308313
sendFileContent(url, reqId, MIMETYPE_HTML);
@@ -331,7 +336,7 @@ async function run(
331336
break;
332337

333338
default:
334-
if (file && file.loaded && file.isUnsaved) {
339+
if (!url || (file && file.loaded && file.isUnsaved)) {
335340
sendText(
336341
file.session?.doc?.toString(),
337342
reqId,

src/settings/mainSettings.js

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,13 +328,47 @@ export default function mainSettings() {
328328
page.show();
329329

330330
appSettings.uiSettings["main-settings"] = page;
331-
appSettings.uiSettings["app-settings"] = otherSettings();
332-
appSettings.uiSettings["file-settings"] = filesSettings();
333-
appSettings.uiSettings["backup-restore"] = backupRestore();
334-
appSettings.uiSettings["editor-settings"] = editorSettings();
335-
appSettings.uiSettings["scroll-settings"] = scrollSettings();
336-
appSettings.uiSettings["search-settings"] = searchSettings();
337-
appSettings.uiSettings["preview-settings"] = previewSettings();
338-
appSettings.uiSettings["terminal-settings"] = terminalSettings();
339-
appSettings.uiSettings["lsp-settings"] = lspSettings();
331+
332+
const lazyPages = {
333+
"app-settings": otherSettings,
334+
"file-settings": filesSettings,
335+
"backup-restore": backupRestore,
336+
"editor-settings": editorSettings,
337+
"scroll-settings": scrollSettings,
338+
"search-settings": searchSettings,
339+
"preview-settings": previewSettings,
340+
"terminal-settings": terminalSettings,
341+
"lsp-settings": lspSettings,
342+
};
343+
344+
const instantiated = {};
345+
346+
for (const [key, initializer] of Object.entries(lazyPages)) {
347+
delete appSettings.uiSettings[key];
348+
Object.defineProperty(appSettings.uiSettings, key, {
349+
get() {
350+
if (!(key in instantiated)) {
351+
instantiated[key] = initializer();
352+
Object.defineProperty(appSettings.uiSettings, key, {
353+
value: instantiated[key],
354+
writable: true,
355+
configurable: true,
356+
enumerable: true,
357+
});
358+
}
359+
return instantiated[key];
360+
},
361+
set(val) {
362+
instantiated[key] = val;
363+
Object.defineProperty(appSettings.uiSettings, key, {
364+
value: val,
365+
writable: true,
366+
configurable: true,
367+
enumerable: true,
368+
});
369+
},
370+
configurable: true,
371+
enumerable: false,
372+
});
373+
}
340374
}

utils/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ const shouldSkipAdmob = isPaidVersion();
8484
const plugins = fs.readdirSync(path.join(__dirname, "../src/plugins"));
8585
plugins.forEach((plugin) => {
8686
if (PLATFORM_FILES.includes(plugin) || plugin.startsWith(".")) return;
87+
const pluginPath = path.join(__dirname, "../src/plugins", plugin);
88+
if (!fs.lstatSync(pluginPath).isDirectory()) return;
8789
if (shouldSkipAdmob && plugin === ADMOB_PLUGIN_DIR) return;
8890
execSync(`cordova plugin add ./src/plugins/${plugin}`, { stdio: "inherit" });
8991
});

0 commit comments

Comments
 (0)