estreui 1.2.2 → 1.2.4
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/README.md +10 -0
- package/index.html +8 -1
- package/package.json +9 -5
- package/scripts/alienese.js +282 -275
- package/scripts/boot.js +107 -67
- package/scripts/doctre.js +330 -6
- package/scripts/estreU0EEOZ.js +64 -6
- package/scripts/estreUi-core.js +555 -0
- package/scripts/estreUi-dialog.js +511 -0
- package/scripts/estreUi-handles.js +7243 -0
- package/scripts/estreUi-interaction.js +1374 -0
- package/scripts/estreUi-main.js +1667 -0
- package/scripts/estreUi-notation.js +596 -0
- package/scripts/estreUi-pageManager.js +625 -0
- package/scripts/estreUi-pageModel.js +4317 -0
- package/scripts/modernism.js +44 -3
- package/serviceWorker.js +10 -3
- package/scripts/estreUi.js +0 -16294
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
/*
|
|
2
|
+
EstreUI rimwork — Page Manager
|
|
3
|
+
Part of the split from estreUi.js (roadmap #002 phase 2).
|
|
4
|
+
|
|
5
|
+
This file is loaded as a plain <script> tag and shares the global scope
|
|
6
|
+
with the other estreUi-*.js files. Load order matters: see index.html.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// MODULE: Page Manager -- EstreUiPageManager, EstreUiCustomPageManager
|
|
10
|
+
// ======================================================================
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Pages operation manager
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Internal page manager handling page navigation, showing, hiding, and closing.
|
|
18
|
+
* Pages are identified by PID (Page IDentifier) strings, with `!` prefix (managed) and `*` prefix (external) alias mapping.
|
|
19
|
+
* @class
|
|
20
|
+
*/
|
|
21
|
+
class EstreUiPageManager {
|
|
22
|
+
|
|
23
|
+
// class property
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// static methods
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// constants
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// instnace property
|
|
33
|
+
/** @type {Object<string, EstreUiPage>} PID → EstreUiPage instance map. */
|
|
34
|
+
#pages = {};
|
|
35
|
+
|
|
36
|
+
/** @type {Object<string, EstreUiPage>} */
|
|
37
|
+
get pages() { return this.#pages; }
|
|
38
|
+
|
|
39
|
+
/** @type {Object<string, string>} Built-in managed page alias → actual PID mapping. Access via `!alert`, `!confirm`, etc. */
|
|
40
|
+
#managedPidMap = {
|
|
41
|
+
get appbar() { return "$s&h=appbar"; },
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
get popupBrowser() { return "$i&o=functional#popupBrowser^"; },
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
get toastAlert() { return "$i&o=toastUpSlide#alert^"; },
|
|
49
|
+
get toastConfirm() { return "$i&o=toastUpSlide#confirm^"; },
|
|
50
|
+
get toastPrompt() { return "$i&o=toastUpSlide#prompt^"; },
|
|
51
|
+
get toastOption() { return "$i&o=toastUpSlide#option^"; },
|
|
52
|
+
get toastSelection() { return "$i&o=toastUpSlide#selection^"; },
|
|
53
|
+
get toastDials() { return "$i&o=toastUpSlide#dials^"; },
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
get onRunning() { return "$i&o=interaction#onRunning^"; },
|
|
57
|
+
get onProgress() { return "$i&o=interaction#onProgress^"; },
|
|
58
|
+
|
|
59
|
+
get alert() { return "$i&o=interaction#alert^"; },
|
|
60
|
+
get confirm() { return "$i&o=interaction#confirm^"; },
|
|
61
|
+
get prompt() { return "$i&o=interaction#prompt^"; },
|
|
62
|
+
get option() { return "$i&o=interaction#option^"; },
|
|
63
|
+
get selection() { return "$i&o=interaction#selection^"; },
|
|
64
|
+
|
|
65
|
+
get popNoti() { return "$i&o=notification#noti@noti^"; },
|
|
66
|
+
get popNote() { return "$i&o=notification#note@note^"; },
|
|
67
|
+
|
|
68
|
+
get timeline() { return "$s&o=operation#root@timeline"; },
|
|
69
|
+
get quickPanel() { return "$s&o=operation#root@quickPanel"; },
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @type {Object<string, string>|null} External (custom) page alias → actual PID mapping. Access via `*home`, etc. Set by EstreUiCustomPageManager.init(). */
|
|
73
|
+
#extPidMap = null;
|
|
74
|
+
/** @type {Object<string, string>|null} */
|
|
75
|
+
get extPidMap() { return this.#extPidMap; }
|
|
76
|
+
/** @param {Object<string, string>} value — Can only be set once. */
|
|
77
|
+
set extPidMap(value) {
|
|
78
|
+
if (this.#extPidMap == null) this.#extPidMap = value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
constructor() {}
|
|
82
|
+
|
|
83
|
+
/** Initialization hook. Override in subclasses. */
|
|
84
|
+
init() {
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Registers an EstreUiPage instance with the manager.
|
|
90
|
+
* @param {EstreUiPage} euiPage - The page object to register.
|
|
91
|
+
*/
|
|
92
|
+
register(euiPage) {
|
|
93
|
+
const pid = euiPage.pid;
|
|
94
|
+
if (this.#pages[pid] == null) {
|
|
95
|
+
this.#pages[pid] = euiPage;
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Finds a full PID from a PID with the statement prefix (`$i`, `$s`) omitted.
|
|
103
|
+
* @param {string|null} pid - Full or partial PID.
|
|
104
|
+
* @returns {string|null} The matching full PID, or null.
|
|
105
|
+
*/
|
|
106
|
+
findPid(pid) {
|
|
107
|
+
if (pid == null) return null;
|
|
108
|
+
else if (this.get(pid) != null) return pid;
|
|
109
|
+
else if (this.get("$i" + pid) != null) return "$i" + pid;
|
|
110
|
+
else if (this.get("$s" + pid) != null) return "$s" + pid;
|
|
111
|
+
else if (this.get("$i" + pid + "^") != null) return "$i" + pid + "^";
|
|
112
|
+
else if (this.get("$s" + pid + "^") != null) return "$s" + pid + "^";
|
|
113
|
+
else return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Looks up a page by PID.
|
|
118
|
+
* @param {string} pid - Full PID.
|
|
119
|
+
* @returns {EstreUiPage|undefined}
|
|
120
|
+
*/
|
|
121
|
+
get(pid) {
|
|
122
|
+
return this.pages[pid];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Looks up a page by component ID.
|
|
127
|
+
* @param {string} id - Component ID.
|
|
128
|
+
* @param {string} [sectionBound="blind"] - Section bound ("main"|"blind"|"menu"|"overlay"|"header").
|
|
129
|
+
* @param {string} [statement] - "static" or "instant".
|
|
130
|
+
* @returns {EstreUiPage|null}
|
|
131
|
+
*/
|
|
132
|
+
getComponent(id, sectionBound = "blind", statement) {
|
|
133
|
+
var pid = this.findPid(EstreUiPage.getPidComponent(id, sectionBound, statement));
|
|
134
|
+
if (pid != null) return this.get(pid);
|
|
135
|
+
else return null;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Looks up a page by container ID.
|
|
140
|
+
* @param {string} id - Container ID.
|
|
141
|
+
* @param {string} componentId - Parent component ID.
|
|
142
|
+
* @param {string} [sectionBound] - Section bound.
|
|
143
|
+
* @param {string} [statement] - "static" or "instant".
|
|
144
|
+
* @returns {EstreUiPage|null}
|
|
145
|
+
*/
|
|
146
|
+
getContainer(id, componentId, sectionBound, statement) {
|
|
147
|
+
var pid = this.findPid(EstreUiPage.getPidContainer(id, componentId, sectionBound, statement));
|
|
148
|
+
if (pid != null) return this.get(pid);
|
|
149
|
+
else return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Looks up a page by article ID.
|
|
154
|
+
* @param {string} id - Article ID.
|
|
155
|
+
* @param {string} containerId - Parent container ID.
|
|
156
|
+
* @param {string} componentId - Parent component ID.
|
|
157
|
+
* @param {string} [sectionBound] - Section bound.
|
|
158
|
+
* @param {string} [statement] - "static" or "instant".
|
|
159
|
+
* @returns {EstreUiPage|null}
|
|
160
|
+
*/
|
|
161
|
+
getArticle(id, containerId, componentId, sectionBound, statement) {
|
|
162
|
+
var pid = this.findPid(EstreUiPage.getPidArticle(id, containerId, componentId, sectionBound, statement));
|
|
163
|
+
if (pid != null) return this.get(pid);
|
|
164
|
+
else return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Returns the total number of step article pages.
|
|
169
|
+
* @param {string} articleStepsId - Base ID for the step articles (e.g. "step").
|
|
170
|
+
* @param {string} containerId - Parent container ID.
|
|
171
|
+
* @param {string} componentId - Parent component ID.
|
|
172
|
+
* @param {string} [sectionBound] - Section bound.
|
|
173
|
+
* @returns {number} Number of step pages.
|
|
174
|
+
*/
|
|
175
|
+
getStepPagesLength(articleStepsId, containerId, componentId, sectionBound) {
|
|
176
|
+
var pid0 = this.findPid(EstreUiPage.getPidArticle(articleStepsId + "%0", containerId, componentId, sectionBound));
|
|
177
|
+
var pidPrefix = pid0.split("%")[0];
|
|
178
|
+
var length = 0;
|
|
179
|
+
for (var pid in this.pages) if (pid.indexOf(pidPrefix) === 0) length++;
|
|
180
|
+
|
|
181
|
+
return length;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Navigates (brings) a page by PID. Creates (opens) the component/container/article if absent, or shows it if already present.
|
|
186
|
+
* `!` prefix resolves via managedPidMap, `*` prefix via extPidMap.
|
|
187
|
+
* @param {string} pid - Full PID, or `!`/`*` prefixed alias.
|
|
188
|
+
* @param {EstreIntent} [intent] - Intent data passed to the page handler.
|
|
189
|
+
* @param {string|string[]} [instanceOrigin] - Instance origin for multi-instance pages.
|
|
190
|
+
* @returns {*|null|false} Result for the target hostType. null if page not found, false if cannot open.
|
|
191
|
+
*/
|
|
192
|
+
bringPage(pid, intent, instanceOrigin) {
|
|
193
|
+
if (pid.indexOf("!") > -1) pid = this.#managedPidMap[pid.replace(/^\!/, "")];
|
|
194
|
+
if (pid == null) return null;
|
|
195
|
+
if (pid.indexOf("*") > -1) pid = this.extPidMap[pid.replace(/^\*/, "")];
|
|
196
|
+
if (pid == null) return null;
|
|
197
|
+
if (pid.indexOf("$") < 0) pid = this.findPid(pid);
|
|
198
|
+
const page = this.get(pid);
|
|
199
|
+
if (page == null) return null;
|
|
200
|
+
page.setInstanceOrigin(instanceOrigin);
|
|
201
|
+
const sections = page.sections;
|
|
202
|
+
if (sections == null) return null;
|
|
203
|
+
|
|
204
|
+
if (intent?.bringOnBack != n && intent.bringOnBack.hostType == n) intent.bringOnBack.hostType = page.hostType;
|
|
205
|
+
|
|
206
|
+
//check open component
|
|
207
|
+
const isIntentNone = typeof intent == UNDEFINED;
|
|
208
|
+
const componentInstanceOrigin = page.componentInstanceOrigin;
|
|
209
|
+
var componentIntentPushed = false;
|
|
210
|
+
var component = sections[page.componentInstanceId];
|
|
211
|
+
var existComponent = false;
|
|
212
|
+
if (component == null) {
|
|
213
|
+
if (page.componentIsInatant) {
|
|
214
|
+
if (page.isMenu) {
|
|
215
|
+
if (page.isComponent) {
|
|
216
|
+
component = estreUi.openMenuArea(page.component, intent, componentInstanceOrigin);
|
|
217
|
+
componentIntentPushed = true;
|
|
218
|
+
} else component = estreUi.openMenuArea(page.component, u, componentInstanceOrigin);
|
|
219
|
+
} else if (page.isBlinded) {
|
|
220
|
+
if (page.isComponent) {
|
|
221
|
+
component = estreUi.openInstantBlinded(page.component, intent, componentInstanceOrigin);
|
|
222
|
+
componentIntentPushed = true;
|
|
223
|
+
} else component = estreUi.openInstantBlinded(page.component, u, componentInstanceOrigin);
|
|
224
|
+
} else if (page.isOverlay) {
|
|
225
|
+
if (page.isComponent) {
|
|
226
|
+
component = estreUi.openManagedOverlay(page.component, intent, componentInstanceOrigin);
|
|
227
|
+
componentIntentPushed = true;
|
|
228
|
+
} else component = estreUi.openManagedOverlay(page.component, u, componentInstanceOrigin);
|
|
229
|
+
} else if (page.isHeader) {
|
|
230
|
+
if (page.isComponent) {
|
|
231
|
+
component = estreUi.openHeaderBar(page.component, intent, componentInstanceOrigin);
|
|
232
|
+
componentIntentPushed = true;
|
|
233
|
+
} else component = estreUi.openHeaderBar(page.component, u, componentInstanceOrigin);
|
|
234
|
+
} else return false;
|
|
235
|
+
} else return false;
|
|
236
|
+
} else existComponent = true;
|
|
237
|
+
if (component == null) return null;
|
|
238
|
+
const containerInstanceOrigin = page.containerInstanceOrigin;
|
|
239
|
+
const articleInstanceOrigin = page.articleInstanceOrigin;
|
|
240
|
+
var containerIntentPushed = false;
|
|
241
|
+
var articleIntentPushed = false;
|
|
242
|
+
var container = null;
|
|
243
|
+
var article = null;
|
|
244
|
+
var existContainer = false;
|
|
245
|
+
var existArticle = false;
|
|
246
|
+
if (page.container != null) {
|
|
247
|
+
//check open container
|
|
248
|
+
container = component.containers[page.containerInstanceId];
|
|
249
|
+
if (container == null) {
|
|
250
|
+
if (page.containerIsInatant) {
|
|
251
|
+
if (page.isArticle || page.isContainer || page.container == "root") {
|
|
252
|
+
container = component.openContainer(page.container, intent, containerInstanceOrigin);
|
|
253
|
+
containerIntentPushed = true;
|
|
254
|
+
} else container = component.openContainer(page.container, u, containerInstanceOrigin);
|
|
255
|
+
} else if (page.isContainer) return false;//static container is cannot open
|
|
256
|
+
else {
|
|
257
|
+
|
|
258
|
+
}
|
|
259
|
+
} else existContainer = true;
|
|
260
|
+
if (container == null) return null;
|
|
261
|
+
|
|
262
|
+
if (page.article != null) {
|
|
263
|
+
//check open article
|
|
264
|
+
article = container.articles[page.articleInstanceId];
|
|
265
|
+
if (article == null) {
|
|
266
|
+
if (page.articleIsInatant) {
|
|
267
|
+
if (page.isArticle || page.article == "main") {
|
|
268
|
+
article = container.openArticle(page.article, intent, articleInstanceOrigin);
|
|
269
|
+
articleIntentPushed = true;
|
|
270
|
+
} else article = container.openArticle(page.article, u, articleInstanceOrigin);
|
|
271
|
+
} else return false;//static article is cannot open
|
|
272
|
+
} else existArticle = true;
|
|
273
|
+
if (article == null) return null;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
var success = true;
|
|
277
|
+
var targetProcessed = { component: null, container: null, article: null };
|
|
278
|
+
const isRootMain = page.container == "root" && page.article == "main";
|
|
279
|
+
switch (page.hostType) {
|
|
280
|
+
case "article":
|
|
281
|
+
if (!isIntentNone && existArticle && (page.isArticle || page.article == "main")) targetProcessed.article = container.showArticle(page.article, intent, articleInstanceOrigin);
|
|
282
|
+
else targetProcessed.article = article.show();
|
|
283
|
+
success = targetProcessed.article;
|
|
284
|
+
// falls through
|
|
285
|
+
case "container":
|
|
286
|
+
if (success) {
|
|
287
|
+
if (!isIntentNone && existContainer && (page.isContainer || isRootMain)) targetProcessed.container = component.showContainer(page.container, intent, containerInstanceOrigin);
|
|
288
|
+
else targetProcessed.container = container.show();
|
|
289
|
+
success = targetProcessed.container;
|
|
290
|
+
}
|
|
291
|
+
// falls through
|
|
292
|
+
case "component":
|
|
293
|
+
if (success) {
|
|
294
|
+
if (page.isHeader) {
|
|
295
|
+
if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showHeaderBar(page.component, intent, componentInstanceOrigin);
|
|
296
|
+
else targetProcessed.component = estreUi.showHeaderBar(page.component, u, componentInstanceOrigin);
|
|
297
|
+
} else if (page.isMenu) {
|
|
298
|
+
if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showMenuArea(page.component, intent, componentInstanceOrigin);
|
|
299
|
+
else targetProcessed.component = estreUi.showMenuArea(page.component, u, componentInstanceOrigin);
|
|
300
|
+
} else if (page.isOverlay) {
|
|
301
|
+
if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showManagedOverlay(page.component, intent, componentInstanceOrigin);
|
|
302
|
+
else targetProcessed.component = estreUi.showManagedOverlay(page.component, u, componentInstanceOrigin);
|
|
303
|
+
} else if (page.isBlinded) {
|
|
304
|
+
if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showInstantBlinded(page.component, intent, componentInstanceOrigin);
|
|
305
|
+
else targetProcessed.component = estreUi.showInstantBlinded(page.component, u, componentInstanceOrigin);
|
|
306
|
+
} else if (component.isModal) {
|
|
307
|
+
if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.openModalTab(page.component, component, intent, componentInstanceOrigin);
|
|
308
|
+
else targetProcessed.component = estreUi.openModalTab(page.component, u, componentInstanceOrigin);
|
|
309
|
+
} else {
|
|
310
|
+
if (!isIntentNone && existComponent && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.switchRootTab(page.component, intent, componentInstanceOrigin);
|
|
311
|
+
else targetProcessed.component = estreUi.mainCurrentOnTop == component || estreUi.switchRootTab(page.component, u, componentInstanceOrigin);
|
|
312
|
+
}
|
|
313
|
+
success = targetProcessed.component;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (window.isVerbosely) console.log("[bringPage] targetProcessed: ", targetProcessed);
|
|
317
|
+
return targetProcessed[page.hostType];
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Shows an already-existing page. Returns null if the component/container/article does not exist.
|
|
322
|
+
* @param {string} pid - Full PID, or `!`/`*` prefixed alias.
|
|
323
|
+
* @param {EstreIntent} [intent] - Intent data passed to the page handler.
|
|
324
|
+
* @param {string|string[]} [instanceOrigin] - Instance origin for multi-instance pages.
|
|
325
|
+
* @returns {*|null} Result for the target hostType. null if page not found.
|
|
326
|
+
*/
|
|
327
|
+
showPage(pid, intent, instanceOrigin) {
|
|
328
|
+
if (pid.indexOf("!") > -1) pid = this.#managedPidMap[pid.replace(/^\!/, "")];
|
|
329
|
+
if (pid == null) return null;
|
|
330
|
+
if (pid.indexOf("*") > -1) pid = this.extPidMap[pid.replace(/^\*/, "")];
|
|
331
|
+
if (pid == null) return null;
|
|
332
|
+
if (pid.indexOf("$") < 0) pid = this.findPid(pid);
|
|
333
|
+
const page = this.get(pid);
|
|
334
|
+
if (page == null) return null;
|
|
335
|
+
page.setInstanceOrigin(instanceOrigin);
|
|
336
|
+
const sections = page.sections;
|
|
337
|
+
if (sections == null) return null;
|
|
338
|
+
|
|
339
|
+
if (intent?.bringOnBack != n && intent.bringOnBack.hostType == n) intent.bringOnBack.hostType = page.hostType;
|
|
340
|
+
|
|
341
|
+
const isIntentNone = typeof intent == UNDEFINED;
|
|
342
|
+
var component = sections[page.componentInstanceId];
|
|
343
|
+
if (component == null) return null;
|
|
344
|
+
const componentInstanceOrigin = page.componentInstanceOrigin;
|
|
345
|
+
const containerInstanceOrigin = page.containerInstanceOrigin;
|
|
346
|
+
const articleInstanceOrigin = page.articleInstanceOrigin;
|
|
347
|
+
var container = null;
|
|
348
|
+
var article = null;
|
|
349
|
+
if (page.container != null) {
|
|
350
|
+
container = component.containers[page.containerInstanceId];
|
|
351
|
+
if (container == null) return null;
|
|
352
|
+
if (page.article != null) {
|
|
353
|
+
article = container.articles[page.articleInstanceId];
|
|
354
|
+
if (article == null) return null;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
var success = true;
|
|
358
|
+
var targetProcessed = { component: null, container: null, article: null };
|
|
359
|
+
switch (page.hostType) {
|
|
360
|
+
case "article":
|
|
361
|
+
if (!isIntentNone && (page.isArticle || page.article == "main")) targetProcessed.article = container.showArticle(page.article, intent, articleInstanceOrigin);
|
|
362
|
+
else targetProcessed.article = article.show();
|
|
363
|
+
success = targetProcessed.article;
|
|
364
|
+
// falls through
|
|
365
|
+
case "container":
|
|
366
|
+
if (success) {
|
|
367
|
+
if (!isIntentNone && (page.isContainer || (page.article == "main" && page.container == "root"))) targetProcessed.container = component.showContainer(page.container, intent, containerInstanceOrigin);
|
|
368
|
+
else targetProcessed.container = container.show();
|
|
369
|
+
success = targetProcessed.container;
|
|
370
|
+
}
|
|
371
|
+
// falls through
|
|
372
|
+
case "component":
|
|
373
|
+
if (success) {
|
|
374
|
+
const isRootMain = page.container == "root" && page.article == "main";
|
|
375
|
+
if (page.isOverlay) {
|
|
376
|
+
if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showManagedOverlay(page.component, intent, componentInstanceOrigin);
|
|
377
|
+
else targetProcessed.component = estreUi.showManagedOverlay(page.component, u, componentInstanceOrigin);
|
|
378
|
+
} else if (page.isMenu) {
|
|
379
|
+
if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showMenuArea(page.component, intent, componentInstanceOrigin);
|
|
380
|
+
else targetProcessed.component = estreUi.showMenuArea(page.component, u, componentInstanceOrigin);
|
|
381
|
+
} else if (page.isBlinded) {
|
|
382
|
+
if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.showInstantBlinded(page.component, intent, componentInstanceOrigin);
|
|
383
|
+
else targetProcessed.component = estreUi.showInstantBlinded(page.component, u, componentInstanceOrigin);
|
|
384
|
+
} else if (component.isModal) {
|
|
385
|
+
if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.openModalTab(page.component, component, intent, componentInstanceOrigin);
|
|
386
|
+
else targetProcessed.component = estreUi.openModalTab(page.component, component, u, componentInstanceOrigin);
|
|
387
|
+
} else {
|
|
388
|
+
if (!isIntentNone && (page.isComponent || isRootMain)) targetProcessed.component = estreUi.switchRootTab(page.component, intent, componentInstanceOrigin);
|
|
389
|
+
else targetProcessed.component = estreUi.mainCurrentOnTop == component || estreUi.switchRootTab(page.component, intent, u, componentInstanceOrigin);
|
|
390
|
+
}
|
|
391
|
+
success = targetProcessed.component;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (window.isVerbosely) console.log("[showPage] targetProcessed: ", targetProcessed);
|
|
395
|
+
return targetProcessed[page.hostType];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Attempts showPage first; falls back to bringPage if the result is falsy.
|
|
400
|
+
* @param {string} pid - Full PID, or `!`/`*` prefixed alias.
|
|
401
|
+
* @param {EstreIntent} [intent] - Intent data passed to the page handler.
|
|
402
|
+
* @param {string|string[]} [instanceOrigin] - Instance origin for multi-instance pages.
|
|
403
|
+
* @returns {*|null|false}
|
|
404
|
+
*/
|
|
405
|
+
showOrBringPage(pid, intent, instanceOrigin) {
|
|
406
|
+
return this.showPage(pid, intent, instanceOrigin) || this.bringPage(pid, intent, instanceOrigin);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Hides a page. Sequentially hides the article/container/component based on hostType.
|
|
411
|
+
* @param {string} pid - Full PID, or `!`/`*` prefixed alias.
|
|
412
|
+
* @param {boolean} [hideHost=false] - If true, also hides the parent host.
|
|
413
|
+
* @param {string|string[]|null} [instanceOrigin=null] - Instance origin for multi-instance pages.
|
|
414
|
+
* @returns {*|null} Result for the target hostType.
|
|
415
|
+
*/
|
|
416
|
+
hidePage(pid, hideHost = false, instanceOrigin = null) {
|
|
417
|
+
if (pid.indexOf("!") > -1) pid = this.#managedPidMap[pid.replace(/^\!/, "")];
|
|
418
|
+
if (pid == null) return null;
|
|
419
|
+
if (pid.indexOf("*") > -1) pid = this.extPidMap[pid.replace(/^\*/, "")];
|
|
420
|
+
if (pid == null) return null;
|
|
421
|
+
if (pid.indexOf("$") < 0) pid = this.findPid(pid);
|
|
422
|
+
const page = this.get(pid);
|
|
423
|
+
if (page == null) return null;
|
|
424
|
+
page.setInstanceOrigin(instanceOrigin);
|
|
425
|
+
const sections = page.sections;
|
|
426
|
+
if (sections == null) return null;
|
|
427
|
+
|
|
428
|
+
var component = sections[page.componentInstanceId];
|
|
429
|
+
if (component == null) return null;
|
|
430
|
+
var container = null;
|
|
431
|
+
var article = null;
|
|
432
|
+
const componentInstanceOrigin = page.componentInstanceOrigin;
|
|
433
|
+
const containerInstanceOrigin = page.containerInstanceOrigin;
|
|
434
|
+
const articleInstanceOrigin = page.articleInstanceOrigin;
|
|
435
|
+
var targetProcessed = { component: null, container: null, article: null };
|
|
436
|
+
if (page.container != null) {
|
|
437
|
+
container = component.containers[page.containerInstanceId];
|
|
438
|
+
if (container != null) {
|
|
439
|
+
if (page.article != null) {
|
|
440
|
+
article = container.articles[page.articleInstanceId];
|
|
441
|
+
if (article != null) {
|
|
442
|
+
targetProcessed.article = article.hide();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (page.isContainer || hideHost || (page.isArticle && page.articleIsStatic && container.isArticlesAllyStatic)) {
|
|
446
|
+
targetProcessed.container = container.hide();
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (page.isComponent || hideHost || (!page.isComponent && page.containerIsStatic && component.isContainersAllyStatic)) {
|
|
451
|
+
if (page.isOverlay || page.isMenu || page.isBlinded) {
|
|
452
|
+
targetProcessed.component = component.hide();
|
|
453
|
+
} else if (component.isModal) {
|
|
454
|
+
targetProcessed.component = estreUi.closeModalTab(page.component, $(component));
|
|
455
|
+
} else {
|
|
456
|
+
targetProcessed.component = estreUi.switchRootTab("home");
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (window.isVerbosely) console.log("[hidePage] targetProcessed: ", targetProcessed);
|
|
460
|
+
return targetProcessed[page.hostType];
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Closes a page (async). Sequentially closes the article/container/component based on hostType.
|
|
465
|
+
* @param {string} pid - Full PID, or `!`/`*` prefixed alias.
|
|
466
|
+
* @param {boolean} [closeHost=false] - If true, also closes the parent host.
|
|
467
|
+
* @param {string|string[]} [instanceOrigin] - Instance origin for multi-instance pages.
|
|
468
|
+
* @returns {Promise<*|null>} Result for the target hostType.
|
|
469
|
+
*/
|
|
470
|
+
closePage(pid, closeHost = false, instanceOrigin) {
|
|
471
|
+
return postPromise(resolve => {
|
|
472
|
+
postQueue(async _ => {
|
|
473
|
+
if (pid.indexOf("!") > -1) pid = this.#managedPidMap[pid.replace(/^\!/, "")];
|
|
474
|
+
if (pid == null) return resolve(null);
|
|
475
|
+
if (pid.indexOf("*") > -1) pid = this.extPidMap[pid.replace(/^\*/, "")];
|
|
476
|
+
if (pid == null) return resolve(null);
|
|
477
|
+
if (pid.indexOf("$") < 0) pid = this.findPid(pid);
|
|
478
|
+
const page = this.get(pid);
|
|
479
|
+
if (page == null) return resolve(null);
|
|
480
|
+
page.setInstanceOrigin(instanceOrigin);
|
|
481
|
+
const sections = page.sections;
|
|
482
|
+
if (sections == null) return resolve(null);
|
|
483
|
+
|
|
484
|
+
var component = sections[page.componentInstanceId];
|
|
485
|
+
if (component == null) return resolve(null);
|
|
486
|
+
var container = null;
|
|
487
|
+
var article = null;
|
|
488
|
+
const componentInstanceOrigin = page.componentInstanceOrigin;
|
|
489
|
+
const containerInstanceOrigin = page.containerInstanceOrigin;
|
|
490
|
+
const articleInstanceOrigin = page.articleInstanceOrigin;
|
|
491
|
+
var targetProcessed = { component: null, container: null, article: null };
|
|
492
|
+
if (page.container != null) {
|
|
493
|
+
container = component.containers[page.containerInstanceId];
|
|
494
|
+
if (container != null) {
|
|
495
|
+
if (page.article != null) {
|
|
496
|
+
article = container.articles[page.articleInstanceId];
|
|
497
|
+
if (article != null) {
|
|
498
|
+
targetProcessed.article = await container.closeArticle(page.article, articleInstanceOrigin);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (page.isContainer || closeHost || (page.isArticle && page.articleIsStatic && container.isArticlesAllyStatic)) {
|
|
502
|
+
targetProcessed.container = await component.closeContainer(page.container, containerInstanceOrigin);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
if (page.isComponent || closeHost || (!page.isComponent && page.containerIsStatic && component.isContainersAllyStatic)) {
|
|
507
|
+
if (page.isOverlay) {
|
|
508
|
+
targetProcessed.component = await estreUi.closeManagedOverlay(page.component, componentInstanceOrigin);
|
|
509
|
+
} else if (page.isMenu) {
|
|
510
|
+
targetProcessed.component = await estreUi.closeMenuArea(page.component, componentInstanceOrigin);
|
|
511
|
+
} else if (page.isBlinded) {
|
|
512
|
+
targetProcessed.component = await estreUi.closeInstantBlinded(page.component, componentInstanceOrigin);
|
|
513
|
+
} else if (component.isModal) {
|
|
514
|
+
targetProcessed.component = await estreUi.closeModalTab(page.component, $(component), componentInstanceOrigin);
|
|
515
|
+
} else {
|
|
516
|
+
targetProcessed.component = await estreUi.switchRootTab("home");
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (window.isVerbosely) console.log("[closePage] targetProcessed: ", targetProcessed);
|
|
520
|
+
resolve(targetProcessed[page.hostType]);
|
|
521
|
+
});
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const pageManager = new EstreUiPageManager();
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Base format for project-specific custom page managers.
|
|
532
|
+
* Registers extPidMap and pageHandlers, delegating page navigation via `*` prefixed aliases.
|
|
533
|
+
* @class
|
|
534
|
+
*/
|
|
535
|
+
class EstreUiCustomPageManager {
|
|
536
|
+
|
|
537
|
+
// class property
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
// static methods
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
// constants
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
// instnace property
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
constructor() {}
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Initializes the custom page manager. Must be called after estreUi initialization.
|
|
554
|
+
* @param {Object<string, string>} extPidMap - Alias → actual PID mapping (e.g. `{ home: "$s&m=home#root@main" }`).
|
|
555
|
+
* @param {Object<string, EstrePageHandler>} pageHandlers - Alias → page handler instance mapping.
|
|
556
|
+
* @returns {this} this for chaining.
|
|
557
|
+
*/
|
|
558
|
+
init(extPidMap, pageHandlers) {
|
|
559
|
+
pageManager.extPidMap = extPidMap;
|
|
560
|
+
EstreUiPage.registerProvider(pageHandlers);
|
|
561
|
+
for (var id in pageHandlers) EstreUiPage.registerHandler(extPidMap[id], pageHandlers[id]);
|
|
562
|
+
|
|
563
|
+
return this;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Brings a page by external alias ID.
|
|
569
|
+
* @param {string} id - Alias registered in extPidMap.
|
|
570
|
+
* @param {EstreIntent} [intent] - Intent data passed to the page handler.
|
|
571
|
+
* @param {string|string[]} [instanceOrigin] - Multi-instance origin.
|
|
572
|
+
* @returns {*|null|false}
|
|
573
|
+
*/
|
|
574
|
+
bringPage(id, intent, instanceOrigin) {
|
|
575
|
+
return pageManager.bringPage("*" + id, intent, instanceOrigin);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Shows a page by external alias ID.
|
|
580
|
+
* @param {string} id - Alias registered in extPidMap.
|
|
581
|
+
* @param {EstreIntent} [intent] - Intent data.
|
|
582
|
+
* @param {string|string[]} [instanceOrigin] - Multi-instance origin.
|
|
583
|
+
* @returns {*|null}
|
|
584
|
+
*/
|
|
585
|
+
showPage(id, intent, instanceOrigin) {
|
|
586
|
+
return pageManager.showPage("*" + id, intent, instanceOrigin);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Attempts showPage; falls back to bringPage on failure.
|
|
591
|
+
* @param {string} id - Alias registered in extPidMap.
|
|
592
|
+
* @param {EstreIntent} [intent] - Intent data.
|
|
593
|
+
* @param {string|string[]} [instanceOrigin] - Multi-instance origin.
|
|
594
|
+
* @returns {*|null|false}
|
|
595
|
+
*/
|
|
596
|
+
showOrBringPage(id, intent, instanceOrigin) {
|
|
597
|
+
return pageManager.showOrBringPage("*" + id, intent, instanceOrigin);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Hides a page by external alias ID.
|
|
602
|
+
* @param {string} id - Alias registered in extPidMap.
|
|
603
|
+
* @param {boolean} [hideHost=false] - Whether to also hide the parent host.
|
|
604
|
+
* @param {string|string[]|null} [instanceOrigin=null] - Multi-instance origin.
|
|
605
|
+
* @returns {*|null}
|
|
606
|
+
*/
|
|
607
|
+
hidePage(id, hideHost = false, instanceOrigin = null) {
|
|
608
|
+
return pageManager.hidePage("*" + id, hideHost, instanceOrigin);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Closes a page by external alias ID (async).
|
|
613
|
+
* @param {string} id - Alias registered in extPidMap.
|
|
614
|
+
* @param {boolean} [closeHost=false] - Whether to also close the parent host.
|
|
615
|
+
* @param {string|string[]|null} [instanceOrigin=null] - Multi-instance origin.
|
|
616
|
+
* @returns {Promise<*|null>}
|
|
617
|
+
*/
|
|
618
|
+
closePage(id, closeHost = false, instanceOrigin = null) {
|
|
619
|
+
return pageManager.closePage("*" + id, closeHost, instanceOrigin);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
// ======================================================================
|