@api-client/ui 0.1.1 → 0.1.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/build/src/bindings/base/IoThread.d.ts +2 -2
- package/build/src/bindings/base/IoThread.d.ts.map +1 -1
- package/build/src/bindings/base/IoThread.js +4 -4
- package/build/src/bindings/base/IoThread.js.map +1 -1
- package/build/src/bindings/base/PlatformBindings.js +2 -2
- package/build/src/bindings/base/PlatformBindings.js.map +1 -1
- package/build/src/core/Activity.d.ts +3 -3
- package/build/src/core/Activity.d.ts.map +1 -1
- package/build/src/core/Activity.js +8 -7
- package/build/src/core/Activity.js.map +1 -1
- package/build/src/core/ActivityManager.d.ts +9 -0
- package/build/src/core/ActivityManager.d.ts.map +1 -1
- package/build/src/core/ActivityManager.js +57 -12
- package/build/src/core/ActivityManager.js.map +1 -1
- package/build/src/core/Application.d.ts +1 -0
- package/build/src/core/Application.d.ts.map +1 -1
- package/build/src/core/Application.js +3 -0
- package/build/src/core/Application.js.map +1 -1
- package/build/src/core/Fragment.d.ts +9 -3
- package/build/src/core/Fragment.d.ts.map +1 -1
- package/build/src/core/Fragment.js +17 -8
- package/build/src/core/Fragment.js.map +1 -1
- package/build/src/core/FragmentManager.d.ts +17 -0
- package/build/src/core/FragmentManager.d.ts.map +1 -1
- package/build/src/core/FragmentManager.js +58 -2
- package/build/src/core/FragmentManager.js.map +1 -1
- package/build/src/core/renderer/Renderer.d.ts +4 -1
- package/build/src/core/renderer/Renderer.d.ts.map +1 -1
- package/build/src/core/renderer/Renderer.js +3 -0
- package/build/src/core/renderer/Renderer.js.map +1 -1
- package/build/src/elements/data-table/DataTable.d.ts +7 -0
- package/build/src/elements/data-table/DataTable.d.ts.map +1 -1
- package/build/src/elements/data-table/DataTable.js +8 -0
- package/build/src/elements/data-table/DataTable.js.map +1 -1
- package/package.json +1 -1
- package/src/bindings/base/IoThread.ts +7 -7
- package/src/bindings/base/PlatformBindings.ts +3 -3
- package/src/core/Activity.ts +8 -7
- package/src/core/ActivityManager.ts +58 -12
- package/src/core/Application.ts +4 -0
- package/src/core/Fragment.ts +18 -8
- package/src/core/FragmentManager.ts +61 -3
- package/src/core/renderer/Renderer.ts +4 -1
- package/src/elements/data-table/DataTable.ts +7 -0
- package/test/core/activity.spec.ts +235 -2
- package/test/core/activity_manager.spec.ts +544 -0
- package/test/core/application.spec.ts +218 -0
- package/test/core/fragment.spec.ts +472 -0
- package/test/core/fragment_manager.spec.ts +404 -0
- package/web-test-runner.config.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Exception } from '@api-client/core/exceptions/exception.js';
|
|
2
2
|
import { type IoEvent, type IoCommand, type IoNotification } from './PlatformBindings.js';
|
|
3
3
|
/**
|
|
4
4
|
* The base IO thread class containing the communication logic with the clients.
|
|
@@ -19,7 +19,7 @@ export declare abstract class IoThread {
|
|
|
19
19
|
* To be called by the IO thread implementation when receiving a message from the client.
|
|
20
20
|
*/
|
|
21
21
|
protected handleMessage(event: IoCommand | IoEvent): void;
|
|
22
|
-
protected notifyError(id: number, error:
|
|
22
|
+
protected notifyError(id: number, error: Exception): void;
|
|
23
23
|
protected getFunction(fn: string): Function | undefined;
|
|
24
24
|
/**
|
|
25
25
|
* Calls the function on self, creates a response event, and dispatches it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IoThread.d.ts","sourceRoot":"","sources":["../../../../src/bindings/base/IoThread.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"IoThread.d.ts","sourceRoot":"","sources":["../../../../src/bindings/base/IoThread.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AACpE,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEzF;;GAEG;AACH,8BAAsB,QAAQ;IAC5B;;OAEG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAEpC;;;;;OAKG;IACH,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAE7D;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,IAAI;IA0CzD,SAAS,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;IAWzD,SAAS,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAiBvD;;;;;;OAMG;cAEa,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBhF;;;;;OAKG;IACH,SAAS,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAQjE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
|
-
import {
|
|
3
|
+
import { Exception } from '@api-client/core/exceptions/exception.js';
|
|
4
4
|
/**
|
|
5
5
|
* The base IO thread class containing the communication logic with the clients.
|
|
6
6
|
*/
|
|
@@ -23,7 +23,7 @@ export class IoThread {
|
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
if (typeof fn !== 'string' || !fn) {
|
|
26
|
-
const err = new
|
|
26
|
+
const err = new Exception('Invalid message received on the io-channel. The second argument must be a function name to call.', { status: 400 });
|
|
27
27
|
this.notifyError(id, err);
|
|
28
28
|
console.warn(err.message);
|
|
29
29
|
return;
|
|
@@ -31,7 +31,7 @@ export class IoThread {
|
|
|
31
31
|
const callable = this.getFunction(fn);
|
|
32
32
|
const isFunction = typeof callable === 'function';
|
|
33
33
|
if (!isFunction) {
|
|
34
|
-
const err = new
|
|
34
|
+
const err = new Exception(`Invalid message received on the io-channel. The function "${fn}" is either not implemented or invalid.`, { status: 400 });
|
|
35
35
|
this.notifyError(id, err);
|
|
36
36
|
console.warn(err.message);
|
|
37
37
|
return;
|
|
@@ -86,7 +86,7 @@ export class IoThread {
|
|
|
86
86
|
catch (e) {
|
|
87
87
|
event.type = 'error';
|
|
88
88
|
event.message = e.message;
|
|
89
|
-
if (e.
|
|
89
|
+
if (e.status) {
|
|
90
90
|
event.result = e;
|
|
91
91
|
}
|
|
92
92
|
this.postMessage(event);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IoThread.js","sourceRoot":"","sources":["../../../../src/bindings/base/IoThread.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,+BAA+B;AAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"IoThread.js","sourceRoot":"","sources":["../../../../src/bindings/base/IoThread.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,+BAA+B;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAGpE;;GAEG;AACH,MAAM,OAAgB,QAAQ;IAc5B;;OAEG;IACO,aAAa,CAAC,KAA0B;QAChD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,qDAAqD,EAAE,KAAK,CAAC,CAAA;YAC1E,OAAM;QACR,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC9B,wBAAwB;YACxB,OAAM;QACR,CAAC;QACD,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,KAAK,CAAA;QAE9B,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAA;YAC5F,OAAM;QACR,CAAC;QAED,IAAI,OAAO,EAA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slint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-console */\nimport { Exception } from '@api-client/core/exceptions/exception.js'\nimport { type IoEvent, type IoCommand, type IoNotification } from './PlatformBindings.js'\n\n/**\n * The base IO thread class containing the communication logic with the clients.\n */\nexport abstract class IoThread {\n /**\n * Initializes the communication channel with the clients.\n */\n abstract initialize(): Promise<void>\n\n /**\n * The IO thread must implement this method to send the message to the client with\n * their particular implementation of message passing.\n *\n * @param message The message to send.\n */\n abstract postMessage(message: IoNotification | IoEvent): void\n\n /**\n * To be called by the IO thread implementation when receiving a message from the client.\n */\n protected handleMessage(event: IoCommand | IoEvent): void {\n if (!event.kind) {\n console.warn('Invalid message received on the app-config-channel.', event)\n return\n }\n if (event.kind === 'IO#Event') {\n // message sent by self.\n return\n }\n const { args, fn, id } = event\n\n if (typeof id !== 'number') {\n console.warn('Invalid message received on the app-config-channel. The id must be a number.')\n return\n }\n\n if (typeof fn !== 'string' || !fn) {\n const err = new Exception(\n 'Invalid message received on the io-channel. The second argument must be a function name to call.',\n { status: 400 }\n )\n this.notifyError(id, err)\n console.warn(err.message)\n return\n }\n\n const callable = this.getFunction(fn)\n const isFunction = typeof callable === 'function'\n\n if (!isFunction) {\n const err = new Exception(\n `Invalid message received on the io-channel. The function \"${fn}\" is either not implemented or invalid.`,\n { status: 400 }\n )\n this.notifyError(id, err)\n console.warn(err.message)\n return\n }\n\n this.call(callable, id, args)\n }\n\n protected notifyError(id: number, error: Exception): void {\n const event: IoEvent = {\n kind: 'IO#Event',\n id,\n type: 'error',\n result: error,\n }\n this.postMessage(event)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n protected getFunction(fn: string): Function | undefined {\n const path = fn.trim().split('.')\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: any = this\n path.forEach((key) => {\n if (!current) {\n return\n }\n const scope = current\n current = current[key as any]\n if (current && current.bind) {\n current = current.bind(scope)\n }\n })\n return current\n }\n\n /**\n * Calls the function on self, creates a response event, and dispatches it.\n *\n * @param fnName The function name to call.\n * @param id The request id sent back to the client.\n * @param args The function arguments.\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n protected async call(callable: Function, id: number, args: any[]): Promise<void> {\n const event: IoEvent = {\n kind: 'IO#Event',\n id,\n type: 'result',\n }\n try {\n const promise = (callable as (...init: any[]) => Promise<any>)(...args)\n event.result = await promise\n this.postMessage(event)\n } catch (e) {\n event.type = 'error'\n event.message = (e as Error).message\n if ((e as Exception).status) {\n event.result = e\n }\n this.postMessage(event)\n }\n }\n\n /**\n * Sends a message to the clients that is a request to send a client DOM event.\n *\n * @param eventPath The path in the `Events` prototype.\n * @param args The arguments to call the event with.\n */\n protected notifyClients(eventPath: string, ...args: any[]): void {\n const info: IoNotification = {\n kind: 'IO#Notification',\n args,\n path: eventPath,\n }\n this.postMessage(info)\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
2
|
-
import {
|
|
2
|
+
import { Exception } from '@api-client/core/exceptions/exception.js';
|
|
3
3
|
import { Events } from '../../events/Events.js';
|
|
4
4
|
/**
|
|
5
5
|
* A base class for all platform bindings.
|
|
@@ -122,7 +122,7 @@ export class PlatformBindings {
|
|
|
122
122
|
else if (type === 'error') {
|
|
123
123
|
const apiErr = result;
|
|
124
124
|
if (apiErr && apiErr.code) {
|
|
125
|
-
info.reject(
|
|
125
|
+
info.reject(Exception.fromRawException(apiErr, 'Unknown exception'));
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
128
|
info.reject(new Error(message));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformBindings.js","sourceRoot":"","sources":["../../../../src/bindings/base/PlatformBindings.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,QAAQ,EAAkB,MAAM,0CAA0C,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AA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H,CAAC;IAED;;;;;;;OAOG;IACO,MAAM,CAAC,KAAqB;QACpC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,OAAO,GAAG,MAAiB,CAAA;QAC/B,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,KAAK,CAAC,KAAK,EAAE,CAAA;QACf,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,2DAA2D;YAC3D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAA;gBAC/C,OAAM;YACR,CAAC;YACD,2DAA2D;YAC3D,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;QACD,CAAC;QAAC,OAAoB,CAAC,GAAG,IAAI,CAAC,CAAA;IACjC,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-function-type */\nimport { ApiError, type IApiError } from '@api-client/core/runtime/store/Errors.js'\nimport { Events } from '../../events/Events.js'\n\n/**\n * A command sent from the client to a IO thread.\n */\nexport interface IoCommand {\n kind: 'IO#Command'\n id: number\n fn: string\n args: unknown[]\n}\n\n/**\n * An event dispatched from the IO thread to the clients.\n */\nexport interface IoEvent {\n kind: 'IO#Event'\n id: number\n type: 'error' | 'result'\n message?: string\n result?: unknown\n}\n\n/**\n * A special kind of an event from the IO thread to the clients that asks to notify the client\n * using the events system.\n */\nexport interface IoNotification {\n kind: 'IO#Notification'\n path: string\n args: unknown[]\n}\n\n/**\n * Events queue on the client side.\n * This is used when communication with the IO thread via Promises is impossible and event based.\n * The client wraps the execution into a promise and pushes this schema into the queue.\n * When the event is dispatched by the IO thread it resolves/rejects cached promise.\n */\nexport interface QueueItem {\n id: number\n resolve: (value: unknown) => void\n reject: (reason?: Error) => void\n // helpful for debugging\n fn: string\n args: unknown[]\n}\n\n/**\n * A base class for all platform bindings.\n *\n * Platform bindings is the way how the application runs a platform specific logic.\n *\n * For example, it implements how the application stores the state or implements file picker / file saver.\n * Depending on the platform (Electron, web, Chrome, more?) it uses different set of bindings\n * defined in the target application. This creates a framework for the bindings to exist.\n *\n * The IO thread can be any process that is separated from the browser tab context.\n * Can be a WebWorker, ServiceWorker, of an API call to a server.\n * When communication with the binding is not possible via the Promise API\n * this system should be used to communicate with the background page.\n *\n * ```typescript\n * class MyBinding extends ParentBaseBinding {\n * channel: BroadcastChannel;\n * constructor() {\n * super();\n * this.channel = new BroadcastChannel('my-channel');\n * }\n *\n * doStuff(arg: any): Promise<any> {\n * return this.invoke('doStuff', 'own argument', arg);\n * }\n * }\n * ```\n *\n * This assumes that the IO thread has the `doStuff` function implemented.\n * The IO thread extends the `IoThread` class which has the defined the communication logic.\n */\nexport abstract class PlatformBindings {\n /**\n * Used with the queue as the identifier of the request.\n * USe the `getId()` to read a unique request id.\n */\n private id = 0\n\n protected queue: QueueItem[] = []\n\n /**\n * Initializes the bindings.\n */\n abstract initialize(): Promise<void>\n\n /**\n * @returns A unique for the current session id.\n */\n protected getId(): number {\n this.id += 1\n return this.id\n }\n\n /**\n * This method to be implemented by child classes that uses the events system to communicate with the\n * IO thread. The argument is the prepared command message ready to be sent to the IO thread.\n * Specific implementation of the communication channel is left to the child class.\n *\n * @param cmd The command to send to the IO thread.\n */\n protected abstract sendIoCommand(cmd: IoCommand): void\n\n /**\n * Invokes a function in the IO thread.\n *\n * @param fn The function name to invoke (or an identifier understood by the IO thread)\n * @param args The function arguments to pass.\n * @returns A promise that should be returned to the client's application logic.\n * The promise is resolved when the IO thread sends an event with the same identifier generated with this call.\n */\n protected invoke(fn: string, ...args: unknown[]): Promise<unknown> {\n return new Promise((resolve, reject) => {\n const id = this.getId()\n const item = {\n resolve,\n reject,\n id,\n fn,\n args,\n }\n this.queue.push(item)\n const cmd: IoCommand = {\n id,\n fn,\n args,\n kind: 'IO#Command',\n }\n this.sendIoCommand(cmd)\n })\n }\n\n /**\n * To be called by the child class when the IO thread send an event.\n * It recognizes the type of the message sent by the IO thread an performs the requested operation.\n *\n * @param message The message sent by the IO thread.\n */\n protected handleIoMessage(message: IoCommand | IoEvent | IoNotification): void {\n if (!message.kind) {\n // eslint-disable-next-line no-console\n console.warn('Invalid message received on the app-config-channel.', message)\n return\n }\n if (message.kind === 'IO#Command') {\n // message sent by self.\n return\n }\n if (message.kind === 'IO#Notification') {\n this.notify(message)\n } else if (message.kind === 'IO#Event') {\n this.resolve(message)\n }\n }\n\n /**\n * Resolves a pending promise stored in the `queue`.\n *\n * @param event The IO thread event\n */\n protected resolve(event: IoEvent): void {\n const { id, type, message, result } = event\n if (typeof id !== 'number') {\n // eslint-disable-next-line no-console\n console.warn(`Unknown event from the IO thread. Id is not a number.`, event)\n return\n }\n const index = this.queue.findIndex((i) => i.id === id)\n if (index < 0) {\n // this might be used by another tab.\n return\n }\n const info = this.queue[index]\n this.queue.splice(index, 1)\n\n if (type === 'result') {\n info.resolve(result)\n } else if (type === 'error') {\n const apiErr = result as IApiError | undefined\n if (apiErr && apiErr.code) {\n info.reject(new ApiError(apiErr))\n } else {\n info.reject(new Error(message))\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(`Unknown event from the IO thread`, event)\n }\n }\n\n /**\n * Notifies this tab about something using the `Events` definition.\n *\n * This expects that the event has the path to the event function,\n * for example `Events.Config.Environment.State.created`.\n *\n * @param event The IO thread event\n */\n protected notify(event: IoNotification): void {\n const { path, args } = event\n const parts = path.split('.')\n let current = Events as unknown\n if (parts[0] === 'Events') {\n parts.shift()\n }\n for (const part of parts) {\n // @ts-expect-error It's dynamic access to a deep property.\n if (!current[part]) {\n // eslint-disable-next-line no-console\n console.warn(`Invalid notification path`, path)\n return\n }\n // @ts-expect-error It's dynamic access to a deep property.\n current = current[part]\n }\n ;(current as Function)(...args)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PlatformBindings.js","sourceRoot":"","sources":["../../../../src/bindings/base/PlatformBindings.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,OAAO,EAAE,SAAS,EAAwB,MAAM,0CAA0C,CAAA;AAC1F,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAgD/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAgB,gBAAgB;IACpC;;;OAGG;IACK,EAAE,GAAG,CAAC,CAAA;IAEJ,KAAK,GAAgB,EAAE,CAAA;IAOjC;;OAEG;IACO,KAAK;QACb,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;QACZ,OAAO,IAAI,CAAC,EAAE,CAAA;IAChB,CAAC;IAWD;;;;;;;OAOG;IACO,MAAM,CAAC,EAAU,EAAE,GAAG,IAAe;QAC7C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,CAAA;YACvB,MAAM,IAAI,GAAG;gBACX,OAAO;gBACP,MAAM;gBACN,EAAE;gBACF,EAAE;gBACF,IAAI;aACL,CAAA;YACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACrB,MAAM,GAAG,GAAc;gBACrB,EAAE;gBACF,EAAE;gBACF,IAAI;gBACJ,IAAI,EAAE,YAAY;aACnB,CAAA;YACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACO,eAAe,CAAC,OAA6C;QACrE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAClB,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,qDAAqD,EAAE,OAAO,CAAC,CAAA;YAC5E,OAAM;QACR,CAAC;QACD,IA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BAAgB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;YACtE,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;YACjC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACO,MAAM,CAAC,KAAqB;QACpC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,CAAA;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,OAAO,GAAG,MAAiB,CAAA;QAC/B,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,KAAK,CAAC,KAAK,EAAE,CAAA;QACf,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,2DAA2D;YAC3D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnB,sCAAsC;gBACtC,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAA;gBAC/C,OAAM;YACR,CAAC;YACD,2DAA2D;YAC3D,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;QACD,CAAC;QAAC,OAAoB,CAAC,GAAG,IAAI,CAAC,CAAA;IACjC,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-function-type */\nimport { Exception, type ExceptionSchema } from '@api-client/core/exceptions/exception.js'\nimport { Events } from '../../events/Events.js'\n\n/**\n * A command sent from the client to a IO thread.\n */\nexport interface IoCommand {\n kind: 'IO#Command'\n id: number\n fn: string\n args: unknown[]\n}\n\n/**\n * An event dispatched from the IO thread to the clients.\n */\nexport interface IoEvent {\n kind: 'IO#Event'\n id: number\n type: 'error' | 'result'\n message?: string\n result?: unknown\n}\n\n/**\n * A special kind of an event from the IO thread to the clients that asks to notify the client\n * using the events system.\n */\nexport interface IoNotification {\n kind: 'IO#Notification'\n path: string\n args: unknown[]\n}\n\n/**\n * Events queue on the client side.\n * This is used when communication with the IO thread via Promises is impossible and event based.\n * The client wraps the execution into a promise and pushes this schema into the queue.\n * When the event is dispatched by the IO thread it resolves/rejects cached promise.\n */\nexport interface QueueItem {\n id: number\n resolve: (value: unknown) => void\n reject: (reason?: Error) => void\n // helpful for debugging\n fn: string\n args: unknown[]\n}\n\n/**\n * A base class for all platform bindings.\n *\n * Platform bindings is the way how the application runs a platform specific logic.\n *\n * For example, it implements how the application stores the state or implements file picker / file saver.\n * Depending on the platform (Electron, web, Chrome, more?) it uses different set of bindings\n * defined in the target application. This creates a framework for the bindings to exist.\n *\n * The IO thread can be any process that is separated from the browser tab context.\n * Can be a WebWorker, ServiceWorker, of an API call to a server.\n * When communication with the binding is not possible via the Promise API\n * this system should be used to communicate with the background page.\n *\n * ```typescript\n * class MyBinding extends ParentBaseBinding {\n * channel: BroadcastChannel;\n * constructor() {\n * super();\n * this.channel = new BroadcastChannel('my-channel');\n * }\n *\n * doStuff(arg: any): Promise<any> {\n * return this.invoke('doStuff', 'own argument', arg);\n * }\n * }\n * ```\n *\n * This assumes that the IO thread has the `doStuff` function implemented.\n * The IO thread extends the `IoThread` class which has the defined the communication logic.\n */\nexport abstract class PlatformBindings {\n /**\n * Used with the queue as the identifier of the request.\n * USe the `getId()` to read a unique request id.\n */\n private id = 0\n\n protected queue: QueueItem[] = []\n\n /**\n * Initializes the bindings.\n */\n abstract initialize(): Promise<void>\n\n /**\n * @returns A unique for the current session id.\n */\n protected getId(): number {\n this.id += 1\n return this.id\n }\n\n /**\n * This method to be implemented by child classes that uses the events system to communicate with the\n * IO thread. The argument is the prepared command message ready to be sent to the IO thread.\n * Specific implementation of the communication channel is left to the child class.\n *\n * @param cmd The command to send to the IO thread.\n */\n protected abstract sendIoCommand(cmd: IoCommand): void\n\n /**\n * Invokes a function in the IO thread.\n *\n * @param fn The function name to invoke (or an identifier understood by the IO thread)\n * @param args The function arguments to pass.\n * @returns A promise that should be returned to the client's application logic.\n * The promise is resolved when the IO thread sends an event with the same identifier generated with this call.\n */\n protected invoke(fn: string, ...args: unknown[]): Promise<unknown> {\n return new Promise((resolve, reject) => {\n const id = this.getId()\n const item = {\n resolve,\n reject,\n id,\n fn,\n args,\n }\n this.queue.push(item)\n const cmd: IoCommand = {\n id,\n fn,\n args,\n kind: 'IO#Command',\n }\n this.sendIoCommand(cmd)\n })\n }\n\n /**\n * To be called by the child class when the IO thread send an event.\n * It recognizes the type of the message sent by the IO thread an performs the requested operation.\n *\n * @param message The message sent by the IO thread.\n */\n protected handleIoMessage(message: IoCommand | IoEvent | IoNotification): void {\n if (!message.kind) {\n // eslint-disable-next-line no-console\n console.warn('Invalid message received on the app-config-channel.', message)\n return\n }\n if (message.kind === 'IO#Command') {\n // message sent by self.\n return\n }\n if (message.kind === 'IO#Notification') {\n this.notify(message)\n } else if (message.kind === 'IO#Event') {\n this.resolve(message)\n }\n }\n\n /**\n * Resolves a pending promise stored in the `queue`.\n *\n * @param event The IO thread event\n */\n protected resolve(event: IoEvent): void {\n const { id, type, message, result } = event\n if (typeof id !== 'number') {\n // eslint-disable-next-line no-console\n console.warn(`Unknown event from the IO thread. Id is not a number.`, event)\n return\n }\n const index = this.queue.findIndex((i) => i.id === id)\n if (index < 0) {\n // this might be used by another tab.\n return\n }\n const info = this.queue[index]\n this.queue.splice(index, 1)\n\n if (type === 'result') {\n info.resolve(result)\n } else if (type === 'error') {\n const apiErr = result as ExceptionSchema | undefined\n if (apiErr && apiErr.code) {\n info.reject(Exception.fromRawException(apiErr, 'Unknown exception'))\n } else {\n info.reject(new Error(message))\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(`Unknown event from the IO thread`, event)\n }\n }\n\n /**\n * Notifies this tab about something using the `Events` definition.\n *\n * This expects that the event has the path to the event function,\n * for example `Events.Config.Environment.State.created`.\n *\n * @param event The IO thread event\n */\n protected notify(event: IoNotification): void {\n const { path, args } = event\n const parts = path.split('.')\n let current = Events as unknown\n if (parts[0] === 'Events') {\n parts.shift()\n }\n for (const part of parts) {\n // @ts-expect-error It's dynamic access to a deep property.\n if (!current[part]) {\n // eslint-disable-next-line no-console\n console.warn(`Invalid notification path`, path)\n return\n }\n // @ts-expect-error It's dynamic access to a deep property.\n current = current[part]\n }\n ;(current as Function)(...args)\n }\n}\n"]}
|
|
@@ -143,9 +143,9 @@ export declare class Activity extends EventTarget {
|
|
|
143
143
|
* @param key The name of the fragment
|
|
144
144
|
* @param fragment The fragment to register.
|
|
145
145
|
*/
|
|
146
|
-
addFragment(key: string, fragment: Fragment, data?: unknown): void
|
|
147
|
-
showFragment(key: string, root?: HTMLElement): void
|
|
148
|
-
hideFragment(key: string): void
|
|
146
|
+
addFragment(key: string, fragment: Fragment, data?: unknown): Promise<void>;
|
|
147
|
+
showFragment(key: string, root?: HTMLElement): Promise<void>;
|
|
148
|
+
hideFragment(key: string): Promise<void>;
|
|
149
149
|
/**
|
|
150
150
|
* Unifies Fragment and Activity interfaces.
|
|
151
151
|
* @returns `this`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Activity.d.ts","sourceRoot":"","sources":["../../../src/core/Activity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,wBAAwB,EAA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c,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIrC,SAAS,IAAI,OAAO,GAAG,SAAS;IAIhC;;;;;;;;;;;;;;OAcG;IAEG,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,cAAc,GAAG,wBAAwB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAUtG"}
|
|
@@ -138,6 +138,7 @@ let Activity = (() => {
|
|
|
138
138
|
*/
|
|
139
139
|
onDestroy() {
|
|
140
140
|
this.dispatchEvent(new CustomEvent('activity:destroy', { detail: null }));
|
|
141
|
+
this.manager.onDestroy();
|
|
141
142
|
}
|
|
142
143
|
/**
|
|
143
144
|
* Called when a new intent is delivered
|
|
@@ -188,16 +189,16 @@ let Activity = (() => {
|
|
|
188
189
|
* @param key The name of the fragment
|
|
189
190
|
* @param fragment The fragment to register.
|
|
190
191
|
*/
|
|
191
|
-
addFragment(key, fragment, data) {
|
|
192
|
-
this.manager.attachFragment(key, fragment, this, data);
|
|
192
|
+
async addFragment(key, fragment, data) {
|
|
193
|
+
await this.manager.attachFragment(key, fragment, this, data);
|
|
193
194
|
}
|
|
194
|
-
showFragment(key, root) {
|
|
195
|
-
this.manager.showFragment(key, root);
|
|
195
|
+
async showFragment(key, root) {
|
|
196
|
+
await this.manager.showFragment(key, root);
|
|
196
197
|
}
|
|
197
|
-
hideFragment(key) {
|
|
198
|
+
async hideFragment(key) {
|
|
198
199
|
const fragment = this.manager.findFragment(key);
|
|
199
200
|
if (fragment) {
|
|
200
|
-
this.manager.hideFragment(fragment);
|
|
201
|
+
await this.manager.hideFragment(fragment);
|
|
201
202
|
}
|
|
202
203
|
}
|
|
203
204
|
/**
|
|
@@ -297,7 +298,7 @@ let Activity = (() => {
|
|
|
297
298
|
await this.startActivityForResult(info.intent);
|
|
298
299
|
}
|
|
299
300
|
else if (event.type === EventTypes.Intent.startActivity) {
|
|
300
|
-
this.startActivity(event.detail.intent);
|
|
301
|
+
await this.startActivity(event.detail.intent);
|
|
301
302
|
}
|
|
302
303
|
else {
|
|
303
304
|
throw new Error(`Unrecognized intent event: ${event.type}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Activity.js","sourceRoot":"","sources":["../../../src/core/Activity.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,OAAO,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,sBAAsB,CAAA;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAGtD,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD;;;;;;;;;;;;;GAaG;IACU,QAAQ;sBAAS,WAAW;;;iBAA5B,QAAS,SAAQ,WAAW;;;6CAsStC,KAAK;YACN,sMAAM,iBAAiB,6DAStB;;;QA/SD;;;;WAIG;QACH,UAAU,GANC,mDAAQ,CAMK;QACxB;;;;WAIG;QACH,MAAM,CAAC,MAAM,CAAS;QAEf,KAAK,GAAkB,aAAa,CAAC,WAAW,CAAA;QAC7C,MAAM,CAAa;QAC7B;;WAEG;QACO,OAAO,CAAiB;QACxB,UAAU,CAAU;QAEpB,QAAQ,GAAG,YAAY,CAAC,eAAe,CAAA;QAEjD,IAAI,UAAU;YACZ,OAAO,IAAI,CAAC,QAAQ,CAAA;QACtB,CAAC;QAED;;;;WAIG;QACO,mBAAmB,GAAa,EAAE,CAAA;QAE5C,YAAY,MAAmB;YAC7B,KAAK,EAAE,CAAA;YACP,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;YACpB,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAA;QAC1C,CAAC;QAED;;;;;;;;;WASG;QACH,QAAQ,CAAC,MAAe;YACtB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,MAA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,KAA6D;YACnF,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC;gBAC5D,MAAM,IAAI,GAAG,KAAK,CAAC,MAAkC,CAAA;gBACrD,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAChD,CAAC;iBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;gBAC1D,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACzC,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;YAC7D,CAAC;QACH,CAAC;;;SAhTU,QAAQ","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { nothing, TemplateResult } from 'lit'\nimport { ActivityState, IntentResult, type Intent } from './ActivityManager.js'\nimport { FragmentManager } from './FragmentManager.js'\nimport type { Fragment } from './Fragment.js'\nimport type { Application, UpdateRequest } from './Application.js'\nimport { bound } from '../decorators/bound.js'\nimport type { ActivityDetail, ActivityWithResultDetail } from '../events/IntentEvents.js'\nimport { EventTypes } from '../events/EventTypes.js'\n\n/**\n * `Activity` is a crucial component of your app. An application sends an intent\n * to bring the activity. If it's found, the activity gets to the foreground and start its activity.\n *\n * **Lifecycle**\n *\n * - `onCreated()` - fires when the system first creates the activity.\n * - `onStart()` - the activity becomes visible to the user as the app prepares for\n * the activity to enter the foreground and become interactive.\n * - `onResume()` - the state in which the app interacts with the user.\n * - `onPause()` - the first indication that the user is leaving your activity.\n * - `onStop()` - your activity is no longer visible to the user.\n * - `onDestroy()`- is called before the activity is destroyed\n */\nexport class Activity extends EventTarget {\n /**\n * To be set by an activity to replace the default render root.\n * This is particularly useful when the activity is a modal dialog\n * and the content should be rendered outside the application's render root.\n */\n renderRoot?: HTMLElement\n /**\n * An activity can define its action name that does not change.\n * It then should be used as the activity registration key.\n * This way other activities/fragments can use it to call the activity.\n */\n static action?: string\n\n public state: ActivityState = ActivityState.Initialized\n protected parent: Application\n /**\n * The fragment manager that manages fragments in this activity.\n */\n protected manager: FragmentManager\n protected resultData?: unknown\n\n protected exitCode = IntentResult.RESULT_CANCELED\n\n get resultCode(): IntentResult {\n return this.exitCode\n }\n\n /**\n * When starting an new activity for result, we add the request code here\n * so that the manager can track which activity originally called the\n * activity for result.\n */\n protected pendingRequestCodes: number[] = []\n\n constructor(parent: Application) {\n super()\n this.parent = parent\n this.manager = new FragmentManager(this)\n }\n\n /**\n * Called when the activity is starting. This is where most initialization should go.\n * You can call `finish()` from within this function, in which case `onDestroy()` will be\n * immediately called after `onCreate()` without any of the rest of the activity lifecycle\n * (`onStart()`, `onResume()`, `onPause()`, etc) executing.\n *\n * In the `onCreate()` method, perform basic activity startup logic that happens only once\n * for the entire life of the activity.\n * @param intent Optional intent data.\n */\n onCreate(intent?: Intent): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:create', { detail: intent }))\n }\n\n /**\n * Called when the activity becomes visible.\n * As `onCreate()` exits, the activity enters the `Started` state, and the activity becomes visible\n * to the user. This callback contains what amounts to the activity’s final preparations for coming\n * to the foreground and becoming interactive.\n *\n * Called after `onCreate()`. It will usually be followed by onResume().\n * This is a good place to begin running animations, etc.\n * You can call `finish()` from within this function, in which case `onStop()` will be\n * immediately called after `onStart()` without the lifecycle transitions\n * in-between (`onResume()`, `onPause()`, etc) executing.\n */\n onStart(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:start', { detail: null }))\n }\n\n /**\n * Called when the activity gains focus.\n * Called after the `onPause()`. This is usually a hint for your activity to start interacting\n * with the user, which is a good indicator that the activity became active and ready to receive input.\n * This sometimes could also be a transit state toward another resting state.\n * For instance, an activity may be relaunched to `onPause()` due to configuration changes and\n * the activity was visible, but wasn't the top-most activity of an activity task.\n * The `render()` function is always called after this callback.\n */\n onResume(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:resume', { detail: null }))\n }\n\n /**\n * Called when the activity loses focus.\n * Called as part of the activity lifecycle when the user no longer actively interacts with the activity,\n * but it is still visible on screen. The counterpart to `onResume()`.\n *\n * When activity B is launched in front of activity A, this callback will be invoked on A.\n * B will not be created until A's `onPause()` returns, so be sure to not do anything lengthy here.\n *\n * This callback is mostly used for saving any persistent state the activity is editing,\n * to present a \"edit in place\" model to the user and making sure nothing is lost if there are\n * not enough resources to start the new activity without first killing this one.\n * This is also a good place to stop things that consume a noticeable amount of CPU in order\n * to make the switch to the next activity as fast as possible.\n */\n onPause(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:pause', { detail: null }))\n }\n\n /**\n * Called when you are no longer visible to the user.\n * You will next receive either onRestart(), onDestroy(), or nothing, depending on later user activity.\n * This is a good place to stop refreshing UI, running animations and other visual things.\n */\n onStop(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:stop', { detail: null }))\n }\n\n onRestart(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:restart', { detail: null }))\n }\n\n /**\n * Perform any final cleanup before an activity is destroyed.\n * This can happen because the activity is finishing (someone called finish() on it).\n */\n onDestroy(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:destroy', { detail: null }))\n }\n\n /**\n * Called when a new intent is delivered\n * @param intent New intent data.\n */\n onNewIntent(intent: Intent): void | Promise<void> {\n //\n }\n\n /**\n * Called by the renderer when the activity is rendered for the first time.\n */\n onFirstRender(): void {\n //\n }\n\n /**\n * A function called when it should render the view.\n */\n render(): TemplateResult | typeof nothing {\n return nothing\n }\n\n /**\n * Finishes the activity.\n */\n async finish(): Promise<void> {\n await this.getApplication().manager.finishActivity(this)\n }\n\n /**\n * When the activity changes its state it should call the\n * `requestUpdate()` method to inform the parent application to\n * perform the render operation.\n * The function dispatches the `activity:update` custom event\n * that is handled by the parent application.\n *\n * Note, the application may choose to not call the render procedure\n * (for example, when the activity is not visible). The rendering\n * function is asynchronous. The only way to know the activity is being rendered,\n * is when the `render()` method if called.\n */\n requestUpdate(opts: UpdateRequest = {}): void {\n const { activity = true } = opts\n if (activity) {\n this.manager.updateActiveFragments()\n }\n this.parent.requestUpdate(opts)\n }\n\n /**\n * Registers a new fragment.\n * @param key The name of the fragment\n * @param fragment The fragment to register.\n */\n addFragment(key: string, fragment: Fragment, data?: unknown): void {\n this.manager.attachFragment(key, fragment, this, data)\n }\n\n showFragment(key: string, root?: HTMLElement): void {\n this.manager.showFragment(key, root)\n }\n\n hideFragment(key: string): void {\n const fragment = this.manager.findFragment(key)\n if (fragment) {\n this.manager.hideFragment(fragment)\n }\n }\n\n /**\n * Unifies Fragment and Activity interfaces.\n * @returns `this`\n */\n getApplication(): Application {\n return this.parent\n }\n\n /**\n * A shortcut to the `manager` function.\n * @param intent The intent to start\n */\n startActivity(intent: Intent): Promise<void> {\n return this.parent.manager.startActivity(intent)\n }\n\n /**\n * Starts a new activity for a result.\n * @param intent The intent that created this activity.\n * @returns The request code created with this call.\n */\n async startActivityForResult(intent: Intent): Promise<number> {\n const { manager } = this.getApplication()\n const code = manager.createRequestCode()\n this.pendingRequestCodes.push(code)\n await manager.startActivityForResult(intent, code)\n return code\n }\n\n /**\n * Call this method to return data to the activity that started this activity.\n * @param data The data to return.\n */\n setResult(resultCode: IntentResult, data?: unknown): void {\n this.exitCode = resultCode\n this.resultData = data\n }\n\n /**\n * Called when an activity you launched exits, giving you the `requestCode` you started it with,\n * the `resultCode` it returned, and any additional data from it. The `resultCode` will be `RESULT_CANCELED`\n * if the activity explicitly returned that, didn't return any result, or crashed during its operation.\n *\n * An activity can never receive a result in the resumed state. You can count on `onResume()` being called\n * after this method, though not necessarily immediately after. If the activity was resumed,\n * it will be paused and the result will be delivered, followed by `onResume()`.\n *\n * @param requestCode The request code passed to startActivityForResult.\n * @param data The result from the activity.\n * @param intent The intent that was used to start the activity.\n */\n async onActivityResult(requestCode: number, resultCode: IntentResult, intent: Intent): Promise<void> {\n const index = this.pendingRequestCodes.indexOf(requestCode)\n if (index !== -1) {\n this.pendingRequestCodes.splice(index, 1)\n }\n // First we check whether any of the fragments has the code.\n const fragment = this.manager.findByRequestCode(requestCode)\n if (fragment) {\n return fragment.onActivityResult(requestCode, resultCode, intent)\n }\n if (this.constructor === Activity) {\n // eslint-disable-next-line no-console\n console.info(\n `Activity#onActivityResult not implemented. Request code: ${requestCode}, result code: ${resultCode}`,\n intent\n )\n }\n }\n\n getActivity(): Activity {\n return this\n }\n\n /**\n * Checks whether this activity initiated the activity for result.\n * @param code The request code to look for.\n * @returns `true` if the activity has the request code.\n */\n hasRequestCode(code: number): boolean {\n return this.pendingRequestCodes.includes(code)\n }\n\n getResult(): unknown | undefined {\n return this.resultData\n }\n\n /**\n * A handler for the intent event dispatched by web components hosted by this activity.\n *\n * **Usage example:**\n *\n * ```ts\n * <custom-element @startactivity=\"${this.handleIntentEvent}\"></custom-element>\n * <custom-element @startactivityforresult=\"${this.handleIntentEvent}\"></custom-element>\n * ```\n *\n * @param event The event that was dispatched.\n * @returns A promise that resolves when the intent is handled.\n * @throws An error if the activity has no activity.\n * @throws An error if the event type is not recognized.\n */\n @bound\n async handleIntentEvent(event: CustomEvent<ActivityDetail | ActivityWithResultDetail>): Promise<void> {\n if (event.type === EventTypes.Intent.startActivityForResult) {\n const info = event.detail as ActivityWithResultDetail\n await this.startActivityForResult(info.intent)\n } else if (event.type === EventTypes.Intent.startActivity) {\n this.startActivity(event.detail.intent)\n } else {\n throw new Error(`Unrecognized intent event: ${event.type}`)\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Activity.js","sourceRoot":"","sources":["../../../src/core/Activity.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,OAAO,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,sBAAsB,CAAA;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAs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AM,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;gBAC1D,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YAC/C,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;YAC7D,CAAC;QACH,CAAC;;;SAjTU,QAAQ","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { nothing, TemplateResult } from 'lit'\nimport { ActivityState, IntentResult, type Intent } from './ActivityManager.js'\nimport { FragmentManager } from './FragmentManager.js'\nimport type { Fragment } from './Fragment.js'\nimport type { Application, UpdateRequest } from './Application.js'\nimport { bound } from '../decorators/bound.js'\nimport type { ActivityDetail, ActivityWithResultDetail } from '../events/IntentEvents.js'\nimport { EventTypes } from '../events/EventTypes.js'\n\n/**\n * `Activity` is a crucial component of your app. An application sends an intent\n * to bring the activity. If it's found, the activity gets to the foreground and start its activity.\n *\n * **Lifecycle**\n *\n * - `onCreated()` - fires when the system first creates the activity.\n * - `onStart()` - the activity becomes visible to the user as the app prepares for\n * the activity to enter the foreground and become interactive.\n * - `onResume()` - the state in which the app interacts with the user.\n * - `onPause()` - the first indication that the user is leaving your activity.\n * - `onStop()` - your activity is no longer visible to the user.\n * - `onDestroy()`- is called before the activity is destroyed\n */\nexport class Activity extends EventTarget {\n /**\n * To be set by an activity to replace the default render root.\n * This is particularly useful when the activity is a modal dialog\n * and the content should be rendered outside the application's render root.\n */\n renderRoot?: HTMLElement\n /**\n * An activity can define its action name that does not change.\n * It then should be used as the activity registration key.\n * This way other activities/fragments can use it to call the activity.\n */\n static action?: string\n\n public state: ActivityState = ActivityState.Initialized\n protected parent: Application\n /**\n * The fragment manager that manages fragments in this activity.\n */\n protected manager: FragmentManager\n protected resultData?: unknown\n\n protected exitCode = IntentResult.RESULT_CANCELED\n\n get resultCode(): IntentResult {\n return this.exitCode\n }\n\n /**\n * When starting an new activity for result, we add the request code here\n * so that the manager can track which activity originally called the\n * activity for result.\n */\n protected pendingRequestCodes: number[] = []\n\n constructor(parent: Application) {\n super()\n this.parent = parent\n this.manager = new FragmentManager(this)\n }\n\n /**\n * Called when the activity is starting. This is where most initialization should go.\n * You can call `finish()` from within this function, in which case `onDestroy()` will be\n * immediately called after `onCreate()` without any of the rest of the activity lifecycle\n * (`onStart()`, `onResume()`, `onPause()`, etc) executing.\n *\n * In the `onCreate()` method, perform basic activity startup logic that happens only once\n * for the entire life of the activity.\n * @param intent Optional intent data.\n */\n onCreate(intent?: Intent): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:create', { detail: intent }))\n }\n\n /**\n * Called when the activity becomes visible.\n * As `onCreate()` exits, the activity enters the `Started` state, and the activity becomes visible\n * to the user. This callback contains what amounts to the activity’s final preparations for coming\n * to the foreground and becoming interactive.\n *\n * Called after `onCreate()`. It will usually be followed by onResume().\n * This is a good place to begin running animations, etc.\n * You can call `finish()` from within this function, in which case `onStop()` will be\n * immediately called after `onStart()` without the lifecycle transitions\n * in-between (`onResume()`, `onPause()`, etc) executing.\n */\n onStart(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:start', { detail: null }))\n }\n\n /**\n * Called when the activity gains focus.\n * Called after the `onPause()`. This is usually a hint for your activity to start interacting\n * with the user, which is a good indicator that the activity became active and ready to receive input.\n * This sometimes could also be a transit state toward another resting state.\n * For instance, an activity may be relaunched to `onPause()` due to configuration changes and\n * the activity was visible, but wasn't the top-most activity of an activity task.\n * The `render()` function is always called after this callback.\n */\n onResume(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:resume', { detail: null }))\n }\n\n /**\n * Called when the activity loses focus.\n * Called as part of the activity lifecycle when the user no longer actively interacts with the activity,\n * but it is still visible on screen. The counterpart to `onResume()`.\n *\n * When activity B is launched in front of activity A, this callback will be invoked on A.\n * B will not be created until A's `onPause()` returns, so be sure to not do anything lengthy here.\n *\n * This callback is mostly used for saving any persistent state the activity is editing,\n * to present a \"edit in place\" model to the user and making sure nothing is lost if there are\n * not enough resources to start the new activity without first killing this one.\n * This is also a good place to stop things that consume a noticeable amount of CPU in order\n * to make the switch to the next activity as fast as possible.\n */\n onPause(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:pause', { detail: null }))\n }\n\n /**\n * Called when you are no longer visible to the user.\n * You will next receive either onRestart(), onDestroy(), or nothing, depending on later user activity.\n * This is a good place to stop refreshing UI, running animations and other visual things.\n */\n onStop(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:stop', { detail: null }))\n }\n\n onRestart(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:restart', { detail: null }))\n }\n\n /**\n * Perform any final cleanup before an activity is destroyed.\n * This can happen because the activity is finishing (someone called finish() on it).\n */\n onDestroy(): void | Promise<void> {\n this.dispatchEvent(new CustomEvent('activity:destroy', { detail: null }))\n this.manager.onDestroy()\n }\n\n /**\n * Called when a new intent is delivered\n * @param intent New intent data.\n */\n onNewIntent(intent: Intent): void | Promise<void> {\n //\n }\n\n /**\n * Called by the renderer when the activity is rendered for the first time.\n */\n onFirstRender(): void {\n //\n }\n\n /**\n * A function called when it should render the view.\n */\n render(): TemplateResult | typeof nothing {\n return nothing\n }\n\n /**\n * Finishes the activity.\n */\n async finish(): Promise<void> {\n await this.getApplication().manager.finishActivity(this)\n }\n\n /**\n * When the activity changes its state it should call the\n * `requestUpdate()` method to inform the parent application to\n * perform the render operation.\n * The function dispatches the `activity:update` custom event\n * that is handled by the parent application.\n *\n * Note, the application may choose to not call the render procedure\n * (for example, when the activity is not visible). The rendering\n * function is asynchronous. The only way to know the activity is being rendered,\n * is when the `render()` method if called.\n */\n requestUpdate(opts: UpdateRequest = {}): void {\n const { activity = true } = opts\n if (activity) {\n this.manager.updateActiveFragments()\n }\n this.parent.requestUpdate(opts)\n }\n\n /**\n * Registers a new fragment.\n * @param key The name of the fragment\n * @param fragment The fragment to register.\n */\n async addFragment(key: string, fragment: Fragment, data?: unknown): Promise<void> {\n await this.manager.attachFragment(key, fragment, this, data)\n }\n\n async showFragment(key: string, root?: HTMLElement): Promise<void> {\n await this.manager.showFragment(key, root)\n }\n\n async hideFragment(key: string): Promise<void> {\n const fragment = this.manager.findFragment(key)\n if (fragment) {\n await this.manager.hideFragment(fragment)\n }\n }\n\n /**\n * Unifies Fragment and Activity interfaces.\n * @returns `this`\n */\n getApplication(): Application {\n return this.parent\n }\n\n /**\n * A shortcut to the `manager` function.\n * @param intent The intent to start\n */\n startActivity(intent: Intent): Promise<void> {\n return this.parent.manager.startActivity(intent)\n }\n\n /**\n * Starts a new activity for a result.\n * @param intent The intent that created this activity.\n * @returns The request code created with this call.\n */\n async startActivityForResult(intent: Intent): Promise<number> {\n const { manager } = this.getApplication()\n const code = manager.createRequestCode()\n this.pendingRequestCodes.push(code)\n await manager.startActivityForResult(intent, code)\n return code\n }\n\n /**\n * Call this method to return data to the activity that started this activity.\n * @param data The data to return.\n */\n setResult(resultCode: IntentResult, data?: unknown): void {\n this.exitCode = resultCode\n this.resultData = data\n }\n\n /**\n * Called when an activity you launched exits, giving you the `requestCode` you started it with,\n * the `resultCode` it returned, and any additional data from it. The `resultCode` will be `RESULT_CANCELED`\n * if the activity explicitly returned that, didn't return any result, or crashed during its operation.\n *\n * An activity can never receive a result in the resumed state. You can count on `onResume()` being called\n * after this method, though not necessarily immediately after. If the activity was resumed,\n * it will be paused and the result will be delivered, followed by `onResume()`.\n *\n * @param requestCode The request code passed to startActivityForResult.\n * @param data The result from the activity.\n * @param intent The intent that was used to start the activity.\n */\n async onActivityResult(requestCode: number, resultCode: IntentResult, intent: Intent): Promise<void> {\n const index = this.pendingRequestCodes.indexOf(requestCode)\n if (index !== -1) {\n this.pendingRequestCodes.splice(index, 1)\n }\n // First we check whether any of the fragments has the code.\n const fragment = this.manager.findByRequestCode(requestCode)\n if (fragment) {\n return fragment.onActivityResult(requestCode, resultCode, intent)\n }\n if (this.constructor === Activity) {\n // eslint-disable-next-line no-console\n console.info(\n `Activity#onActivityResult not implemented. Request code: ${requestCode}, result code: ${resultCode}`,\n intent\n )\n }\n }\n\n getActivity(): Activity {\n return this\n }\n\n /**\n * Checks whether this activity initiated the activity for result.\n * @param code The request code to look for.\n * @returns `true` if the activity has the request code.\n */\n hasRequestCode(code: number): boolean {\n return this.pendingRequestCodes.includes(code)\n }\n\n getResult(): unknown | undefined {\n return this.resultData\n }\n\n /**\n * A handler for the intent event dispatched by web components hosted by this activity.\n *\n * **Usage example:**\n *\n * ```ts\n * <custom-element @startactivity=\"${this.handleIntentEvent}\"></custom-element>\n * <custom-element @startactivityforresult=\"${this.handleIntentEvent}\"></custom-element>\n * ```\n *\n * @param event The event that was dispatched.\n * @returns A promise that resolves when the intent is handled.\n * @throws An error if the activity has no activity.\n * @throws An error if the event type is not recognized.\n */\n @bound\n async handleIntentEvent(event: CustomEvent<ActivityDetail | ActivityWithResultDetail>): Promise<void> {\n if (event.type === EventTypes.Intent.startActivityForResult) {\n const info = event.detail as ActivityWithResultDetail\n await this.startActivityForResult(info.intent)\n } else if (event.type === EventTypes.Intent.startActivity) {\n await this.startActivity(event.detail.intent)\n } else {\n throw new Error(`Unrecognized intent event: ${event.type}`)\n }\n }\n}\n"]}
|
|
@@ -105,6 +105,15 @@ export declare class ActivityManager {
|
|
|
105
105
|
private bringLastActivityToFront;
|
|
106
106
|
getTopActivity(): Activity | undefined;
|
|
107
107
|
getCurrentActivity(): Activity | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Sets the styles for the current activity.
|
|
110
|
+
* This method adds or removes CSS classes based on the activity's class name
|
|
111
|
+
* and action, allowing for dynamic styling based on the active activity.
|
|
112
|
+
* @param activity The activity to set styles for.
|
|
113
|
+
* If not provided, it will not set any styles.
|
|
114
|
+
* If the activity is the same as the current one, it does nothing.
|
|
115
|
+
*/
|
|
116
|
+
setupStyles(activity?: Activity, oldActivity?: Activity): void;
|
|
108
117
|
/**
|
|
109
118
|
* A helper method to handle the transition between activities, ensuring
|
|
110
119
|
* lifecycle methods are called in the correct order (pause the previous activity,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActivityManager.d.ts","sourceRoot":"","sources":["../../../src/core/ActivityManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD,oBAAY,aAAa;IACvB,WAAW,IAAA;IACX,OAAO,IAAA;IACP,OAAO,IAAA;IACP,OAAO,IAAA;IACP,MAAM,IAAA;IACN,OAAO,IAAA;IACP,SAAS,IAAA;CACV;AAED,oBAAY,WAAW;IACrB;;OAEG;IAEH,KAAK,IAAS;IACd;;OAEG;IAEH,SAAS,IAAS;IAClB;;;;;OAKG;IAEH,WAAW,IAAS;CACrB;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,oBAAY,YAAY;IACtB,eAAe,IAAA;IACf,SAAS,IAAA;CACV;AA0BD;;;;;;;;;GASG;AACH,qBAAa,eAAe;;IAC1B,OAAO,CAAC,eAAe,CAAC,CAAU;IAElC;;OAEG;IACH,OAAO,CAAC,eAAe,CAAqC;IAE5D;;;OAGG;IACH,OAAO,CAAC,aAAa,CAA2B;IAEhD;;;OAGG;IACH,OAAO,CAAC,kBAAkB,CAA2B;IAErD,OAAO,CAAC,kBAAkB;gBAMd,MAAM,EAAE,WAAW;IAK/B,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,QAAQ,GAAG,IAAI;IAiBtE;;;;;;;;;OASG;IACG,cAAc,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185,22 +185,22 @@ export class ActivityManager {
|
|
|
185
185
|
async startActivityForResult(intent, requestCode) {
|
|
186
186
|
intent.requestCode = requestCode;
|
|
187
187
|
const byReference = (intent.flags ?? 0) & IntentFlags.ByReference;
|
|
188
|
-
const
|
|
188
|
+
const shallowCopy = { ...intent };
|
|
189
|
+
const data = shallowCopy.data;
|
|
189
190
|
if (byReference) {
|
|
190
|
-
delete
|
|
191
|
+
delete shallowCopy.data;
|
|
191
192
|
}
|
|
192
|
-
const
|
|
193
|
-
if (data &&
|
|
194
|
-
|
|
193
|
+
const deepCopy = structuredClone(shallowCopy);
|
|
194
|
+
if (data && byReference) {
|
|
195
|
+
deepCopy.data = data;
|
|
195
196
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
intent.flags = intent.flags & IntentFlags.ForResult;
|
|
197
|
+
if (deepCopy.flags) {
|
|
198
|
+
deepCopy.flags = deepCopy.flags | IntentFlags.ForResult;
|
|
199
199
|
}
|
|
200
200
|
else {
|
|
201
|
-
|
|
201
|
+
deepCopy.flags = IntentFlags.ForResult;
|
|
202
202
|
}
|
|
203
|
-
await this.startActivity(
|
|
203
|
+
await this.startActivity(deepCopy);
|
|
204
204
|
}
|
|
205
205
|
isDestroyed(activity) {
|
|
206
206
|
return activity.state === ActivityState.Destroyed;
|
|
@@ -209,6 +209,7 @@ export class ActivityManager {
|
|
|
209
209
|
* @param activity The activity to finish.
|
|
210
210
|
*/
|
|
211
211
|
async finishActivity(activity) {
|
|
212
|
+
this.setupStyles(undefined, activity);
|
|
212
213
|
const isModal = this.modalActivityStack.some((entry) => entry.activity === activity);
|
|
213
214
|
const stack = isModal ? this.modalActivityStack : this.activityStack;
|
|
214
215
|
const index = stack.findIndex((entry) => entry.activity === activity);
|
|
@@ -280,6 +281,37 @@ export class ActivityManager {
|
|
|
280
281
|
getCurrentActivity() {
|
|
281
282
|
return this.currentActivity;
|
|
282
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Sets the styles for the current activity.
|
|
286
|
+
* This method adds or removes CSS classes based on the activity's class name
|
|
287
|
+
* and action, allowing for dynamic styling based on the active activity.
|
|
288
|
+
* @param activity The activity to set styles for.
|
|
289
|
+
* If not provided, it will not set any styles.
|
|
290
|
+
* If the activity is the same as the current one, it does nothing.
|
|
291
|
+
*/
|
|
292
|
+
setupStyles(activity, oldActivity) {
|
|
293
|
+
if (activity === oldActivity) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const root = document?.documentElement;
|
|
297
|
+
if (!root) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (oldActivity) {
|
|
301
|
+
const ctor = oldActivity.constructor;
|
|
302
|
+
root.classList.remove(ctor.name.toLowerCase());
|
|
303
|
+
if (ctor.action) {
|
|
304
|
+
root.classList.remove(ctor.action.replace(/\//g, '-'));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (activity) {
|
|
308
|
+
const ctor = activity.constructor;
|
|
309
|
+
root.classList.add(ctor.name.toLowerCase());
|
|
310
|
+
if (ctor.action) {
|
|
311
|
+
root.classList.add(ctor.action.replace(/\//g, '-'));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
283
315
|
/**
|
|
284
316
|
* A helper method to handle the transition between activities, ensuring
|
|
285
317
|
* lifecycle methods are called in the correct order (pause the previous activity,
|
|
@@ -288,9 +320,12 @@ export class ActivityManager {
|
|
|
288
320
|
* @param activity The activity to bring to the foreground.
|
|
289
321
|
*/
|
|
290
322
|
async updateCurrentActivity(activity, isModal) {
|
|
323
|
+
this.setupStyles(activity, this.currentActivity);
|
|
291
324
|
if (this.currentActivity &&
|
|
292
325
|
this.currentActivity !== activity &&
|
|
293
|
-
this.currentActivity.state !== ActivityState.Destroyed
|
|
326
|
+
this.currentActivity.state !== ActivityState.Destroyed &&
|
|
327
|
+
// Make sure we don't pause the current activity if it's already paused.
|
|
328
|
+
this.currentActivity.state !== ActivityState.Paused) {
|
|
294
329
|
await this.currentActivity.onPause();
|
|
295
330
|
this.currentActivity.state = ActivityState.Paused;
|
|
296
331
|
}
|
|
@@ -338,7 +373,17 @@ export class ActivityManager {
|
|
|
338
373
|
// the activity finished and the manager already took care of this situation.
|
|
339
374
|
return;
|
|
340
375
|
}
|
|
341
|
-
|
|
376
|
+
await activity.onStart();
|
|
377
|
+
if (this.isDestroyed(activity)) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
activity.state = ActivityState.Started;
|
|
381
|
+
await activity.onResume();
|
|
382
|
+
if (this.isDestroyed(activity)) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
activity.state = ActivityState.Resumed;
|
|
386
|
+
activity.requestUpdate();
|
|
342
387
|
}
|
|
343
388
|
if (!isModal) {
|
|
344
389
|
// With a modal activity, it renders directly to the `<body>` and renders outside
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActivityManager.js","sourceRoot":"","sources":["../../../src/core/ActivityManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,CAAN,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,+DAAW,CAAA;IACX,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,qDAAM,CAAA;IACN,uDAAO,CAAA;IACP,2DAAS,CAAA;AACX,CAAC,EARW,aAAa,KAAb,aAAa,QAQxB;AAED,MAAM,CAAN,IAAY,WAmBX;AAnBD,WAAY,WAAW;IACrB;;OAEG;IACH,yEAAyE;IACzE,+CAAc,CAAA;IACd;;OAEG;IACH,yEAAyE;IACzE,uDAAkB,CAAA;IAClB;;;;;OAKG;IACH,yEAAyE;IACzE,2DAAoB,CAAA;AACtB,CAAC,EAnBW,WAAW,KAAX,WAAW,QAmBtB;AAaD,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qEAAe,CAAA;IACf,yDAAS,CAAA;AACX,CAAC,EAHW,YAAY,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C;YAC1D,6CAA6C;YAC7C,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACjD,CAAC;QACD,0DAA0D;IAC5D,CAAC;IAED,iBAAiB;QACf,MAAM,GAAG,GAAG,IAAI,CAAA;QAChB,MAAM,GAAG,GAAG,IAAI,CAAA;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;IACtD,CAAC;IAED,kBAAkB,CAAC,MAAc;QAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,EAAE,QAAQ,CAAA;IAC9E,CAAC;CACF","sourcesContent":["import type { Activity } from './Activity.js'\nimport type { Application } from './Application.js'\nimport { navigateScreen } from './ApplicationRoute.js'\n\nexport enum ActivityState {\n Initialized,\n Created,\n Started,\n Resumed,\n Paused,\n Stopped,\n Destroyed,\n}\n\nexport enum IntentFlags {\n /**\n * Marks that the activity should be rendered as a modal.\n */\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Modal = 1 << 0,\n /**\n * The activity is started for result.\n */\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n ForResult = 1 << 1,\n /**\n * When set, the intent data is passed by reference.\n * By default the activity manager makes a copy of the intent data.\n * This is useful when the data is large and you want to avoid copying it\n * or when you want to share the same data between activities.\n */\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n ByReference = 1 << 2,\n}\n\nexport interface Intent {\n action: string\n data?: unknown\n category?: string[]\n flags?: number\n /**\n * The request code used to distinguish between different activities.\n */\n requestCode?: number\n}\n\nexport enum IntentResult {\n RESULT_CANCELED,\n RESULT_OK,\n}\n\n/**\n * Defines the information stored for each activity on the stack:\n * the Activity instance, a unique id, and optionally the Intent that started the activity\n * (useful for restoring state).\n */\ninterface ActivityStackEntry {\n /**\n * The instance of the activity.\n */\n activity: Activity\n /**\n * Activity's unique ID.\n */\n id: string\n /**\n * The intent that started the activity.\n */\n intent: Intent\n /**\n * The action name the activity is registered for.\n */\n action: string\n}\n\n/**\n * Manages application activities.\n *\n * An activity is a screen or a portion of a rendered screen that has its own\n * lifecycle methods and routing.\n *\n * An activity is registered by its class definition. Because of that, activities\n * cannot have constructors that require own parameters. Activities have to be\n * self contained or use the event system to request data.\n */\nexport class ActivityManager {\n private currentActivity?: Activity\n\n /**\n * Stores activity *classes* by unique ID (action name).\n */\n private activityClasses = new Map<string, typeof Activity>()\n\n /**\n * Represents the activity stack. It is used to manage\n * the UI state after calling the back action.\n */\n private activityStack: ActivityStackEntry[] = []\n\n /**\n * A stack of activities that are rendered over other activities\n * in a dialog.\n */\n private modalActivityStack: ActivityStackEntry[] = []\n\n private generateActivityId(): string {\n return Math.random().toString(36).substring(2, 15)\n }\n\n #parent: Application\n\n constructor(parent: Application) {\n this.#parent = parent\n // this.reflectEvent = this.reflectEvent.bind(this)\n }\n\n registerActivity(action: string, activityClass: typeof Activity): void {\n if (this.activityClasses.has(action)) {\n // eslint-disable-next-line no-console\n console.warn(`Activity with action \"${action}\" already registered.`, new Error().stack)\n }\n this.activityClasses.set(action, activityClass)\n }\n\n // protected reflectEvent<T extends Event>(event: T): T {\n // const copy = Reflect.construct(event.constructor, [event.type, event])\n // const dispatched = this.#parent.events.dispatchEvent(copy)\n // if (!dispatched) {\n // event.preventDefault()\n // }\n // return copy\n // }\n\n /**\n * Creates an activity and pushes it into the stack, but it does not initialize any of the lifecycle methods.\n * It is a way to put an activity at some place of the stack,\n * but it will be only initialized when other activities finis.\n *\n * Note, if you add an uninitialized activity and you won't add more activities then this activity may never run.\n * Make sure that there's always another activity.\n *\n * @param intent The intent that created this activity.\n */\n async createActivity(intent: Intent): Promise<void> {\n const activity = this.buildActivity(intent)\n const activityId = this.generateActivityId()\n const stackEntry: ActivityStackEntry = { activity, id: activityId, intent, action: intent.action }\n this.activityStack.push(stackEntry)\n }\n\n setupRoute(intent: Intent): void {\n if (intent.data) {\n const typed = intent.data as { uri?: string }\n if (typed.uri) {\n navigateScreen(typed.uri)\n }\n }\n }\n\n /**\n * Starts a new activity and brings it to the foreground.\n *\n * @param intent The intent that created this activity.\n */\n async startActivity(intent: Intent): Promise<void> {\n const { currentActivity, activityStack } = this\n const lastIndex = activityStack.findLastIndex((entry) => entry.action === intent.action)\n // if the activity is in the history list, we bring it up and update intent.\n if (lastIndex > -1) {\n const info = activityStack[lastIndex]\n activityStack.splice(lastIndex, 1)\n activityStack.push({\n id: info.id,\n activity: info.activity,\n action: info.action,\n intent,\n })\n await info.activity.onNewIntent(intent)\n // TODO: Check if the activity is destroyed.\n this.setupRoute(intent)\n // this.currentActivity = info.activity\n await this.updateCurrentActivity(info.activity, false)\n return\n }\n const activity = this.buildActivity(intent)\n if (currentActivity) {\n await currentActivity.onPause()\n currentActivity.state = ActivityState.Paused\n }\n\n const activityId = this.generateActivityId()\n const stackEntry: ActivityStackEntry = { activity, id: activityId, intent, action: intent.action }\n // Modal activities are pretty much the same as regular activities but are rendered on top\n // of other activities. We keep track of them on another stack as all modal activities must\n // finish before returning to the regular stack.\n const isModal = (intent.flags ?? 0) & IntentFlags.Modal\n if (isModal) {\n this.modalActivityStack.push(stackEntry)\n } else {\n this.activityStack.push(stackEntry)\n }\n await activity.onCreate(intent)\n if (this.isDestroyed(activity)) {\n // the activity finished and the manager already took care of this situation.\n return\n }\n activity.state = ActivityState.Created\n\n await this.updateCurrentActivity(activity, !!isModal)\n if (this.isDestroyed(activity)) {\n // the activity finished and the manager already took care of this situation.\n return\n }\n this.setupRoute(intent)\n }\n\n private buildActivity(intent: Intent): Activity {\n const action = intent.action\n if (!this.activityClasses.has(action)) {\n throw new Error(`No activity class registered for action: ${action}`)\n }\n\n const ActivityClass = this.activityClasses.get(action)\n if (!ActivityClass) {\n throw new Error(`No activity class registered for action: ${action}`)\n }\n\n // We use the container to resolve dependencies, if any.\n // const activity = (await container.make(ActivityClass, [this.#parent])) as Activity\n return new ActivityClass(this.#parent)\n }\n\n /**\n * Starts an activity that should return a result to the calling activity.\n * The result should be a unique number across the application.\n * @param intent The intent to start the activity.\n * @param requestCode The request code used to match the activity result.\n */\n async startActivityForResult(intent: Intent, requestCode: number): Promise<void> {\n intent.requestCode = requestCode\n const byReference = (intent.flags ?? 0) & IntentFlags.ByReference\n const data = intent.data\n if (byReference) {\n delete intent.data\n }\n const intentCopy = structuredClone(intent)\n if (data && !byReference) {\n intentCopy.data = data\n }\n intent.requestCode = requestCode\n if (intent.flags) {\n intent.flags = intent.flags & IntentFlags.ForResult\n } else {\n intent.flags = IntentFlags.ForResult\n }\n await this.startActivity(intentCopy)\n }\n\n isDestroyed(activity: Activity): boolean {\n return activity.state === ActivityState.Destroyed\n }\n\n /**\n * @param activity The activity to finish.\n */\n async finishActivity(activity: Activity): Promise<void> {\n const isModal = this.modalActivityStack.some((entry) => entry.activity === activity)\n const stack = isModal ? this.modalActivityStack : this.activityStack\n const index = stack.findIndex((entry) => entry.activity === activity)\n if (index !== -1) {\n const stackEntry = stack.splice(index, 1)[0]\n\n await stackEntry.activity.onPause()\n stackEntry.activity.state = ActivityState.Paused\n await stackEntry.activity.onStop()\n stackEntry.activity.state = ActivityState.Stopped\n await stackEntry.activity.onDestroy()\n stackEntry.activity.state = ActivityState.Destroyed\n\n await this.manageActivityResult(stackEntry.activity, stackEntry.intent)\n\n // Resume the previous activity\n await this.bringLastActivityToFront()\n } else {\n if (activity.state === ActivityState.Created) {\n await activity.onStop()\n activity.state = ActivityState.Stopped\n }\n await activity.onDestroy()\n activity.state = ActivityState.Destroyed\n // This can happen when an activity finishes in one of the callback methods,\n // before it is added to the stack. In that case, we bring the last activity back to the front.\n await this.bringLastActivityToFront()\n }\n this.#parent.requestUpdate()\n }\n\n private async manageActivityResult(activity: Activity, intent: Intent): Promise<void> {\n const { flags = 0, requestCode = -1 } = intent\n if (flags & IntentFlags.ForResult) {\n const all = [...this.activityStack, ...this.modalActivityStack]\n const target = all.find((entry) => entry.activity.hasRequestCode(requestCode))\n if (target) {\n if (target.activity.state === ActivityState.Destroyed) {\n return\n }\n if (target.activity.state === ActivityState.Resumed) {\n await target.activity.onPause()\n target.activity.state = ActivityState.Paused\n }\n const intentCopy = structuredClone(intent)\n intentCopy.data = activity.getResult()\n await target.activity.onActivityResult(requestCode, activity.resultCode, intentCopy)\n }\n }\n }\n\n private async bringLastActivityToFront(): Promise<void> {\n if (this.modalActivityStack.length > 0) {\n const previousEntry = this.modalActivityStack[this.activityStack.length - 1]\n await this.updateCurrentActivity(previousEntry.activity, false)\n } else if (this.activityStack.length > 0) {\n const previousEntry = this.activityStack[this.activityStack.length - 1]\n await this.updateCurrentActivity(previousEntry.activity, false)\n } else {\n this.currentActivity = undefined // No more activities\n }\n }\n\n getTopActivity(): Activity | undefined {\n const topModal = this.modalActivityStack.findLast((a) => a.activity.state === ActivityState.Resumed)\n if (topModal) {\n return topModal.activity\n }\n const top = this.activityStack.findLast((a) => a.activity.state === ActivityState.Resumed)\n return top ? top.activity : undefined\n }\n\n getCurrentActivity(): Activity | undefined {\n return this.currentActivity\n }\n\n /**\n * A helper method to handle the transition between activities, ensuring\n * lifecycle methods are called in the correct order (pause the previous activity,\n * then start/resume the new one). This centralizes lifecycle management.\n *\n * @param activity The activity to bring to the foreground.\n */\n private async updateCurrentActivity(activity: Activity, isModal: boolean): Promise<void> {\n if (\n this.currentActivity &&\n this.currentActivity !== activity &&\n this.currentActivity.state !== ActivityState.Destroyed\n ) {\n await this.currentActivity.onPause()\n this.currentActivity.state = ActivityState.Paused\n }\n if (activity.state === ActivityState.Paused) {\n await activity.onResume()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Resumed\n activity.requestUpdate()\n } else if (activity.state === ActivityState.Stopped) {\n await activity.onRestart()\n activity.state = ActivityState.Resumed\n } else if (activity.state === ActivityState.Destroyed) {\n throw new Error(`Invalid state. The activity is already destroyed.`)\n } else if (activity.state === ActivityState.Created) {\n await activity.onStart()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Started\n await activity.onResume()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Resumed\n activity.requestUpdate()\n } else if (activity.state === ActivityState.Started) {\n await activity.onResume()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Resumed\n activity.requestUpdate()\n } else if (activity.state === ActivityState.Initialized) {\n // TODO: Figure out intent passing here.\n await activity.onCreate()\n activity.state = ActivityState.Created\n if (this.isDestroyed(activity)) {\n // the activity finished and the manager already took care of this situation.\n return\n }\n // await this.updateCurrentActivity(activity)\n }\n if (!isModal) {\n // With a modal activity, it renders directly to the `<body>` and renders outside\n // of the normal rendering flow. We keep the previous activity rendered.\n this.currentActivity = activity\n }\n }\n\n /**\n * Allows navigating back through the activity stack.\n * Call `ActivityManager.navigateBack()` when the user performs a back action\n * (e.g., clicks a back button).\n */\n async navigateBack(): Promise<void> {\n if (this.activityStack.length > 1 && this.currentActivity) {\n // Finish current, which will resume previous\n await this.finishActivity(this.currentActivity)\n }\n // Else do nothing (or display a message, or exit the app)\n }\n\n createRequestCode(): number {\n const min = 1000\n const max = 9999\n return Math.floor(Math.random() * (max - min) + min)\n }\n\n findActiveActivity(action: string): Activity | undefined {\n return this.activityStack.find((entry) => entry.action === action)?.activity\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ActivityManager.js","sourceRoot":"","sources":["../../../src/core/ActivityManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,CAAN,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,+DAAW,CAAA;IACX,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,qDAAM,CAAA;IACN,uDAAO,CAAA;IACP,2DAAS,CAAA;AACX,CAAC,EARW,aAAa,KAAb,aAAa,QAQx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'./Application.js'\nimport { navigateScreen } from './ApplicationRoute.js'\n\nexport enum ActivityState {\n Initialized,\n Created,\n Started,\n Resumed,\n Paused,\n Stopped,\n Destroyed,\n}\n\nexport enum IntentFlags {\n /**\n * Marks that the activity should be rendered as a modal.\n */\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n Modal = 1 << 0,\n /**\n * The activity is started for result.\n */\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n ForResult = 1 << 1,\n /**\n * When set, the intent data is passed by reference.\n * By default the activity manager makes a copy of the intent data.\n * This is useful when the data is large and you want to avoid copying it\n * or when you want to share the same data between activities.\n */\n // eslint-disable-next-line @typescript-eslint/prefer-literal-enum-member\n ByReference = 1 << 2,\n}\n\nexport interface Intent {\n action: string\n data?: unknown\n category?: string[]\n flags?: number\n /**\n * The request code used to distinguish between different activities.\n */\n requestCode?: number\n}\n\nexport enum IntentResult {\n RESULT_CANCELED,\n RESULT_OK,\n}\n\n/**\n * Defines the information stored for each activity on the stack:\n * the Activity instance, a unique id, and optionally the Intent that started the activity\n * (useful for restoring state).\n */\ninterface ActivityStackEntry {\n /**\n * The instance of the activity.\n */\n activity: Activity\n /**\n * Activity's unique ID.\n */\n id: string\n /**\n * The intent that started the activity.\n */\n intent: Intent\n /**\n * The action name the activity is registered for.\n */\n action: string\n}\n\n/**\n * Manages application activities.\n *\n * An activity is a screen or a portion of a rendered screen that has its own\n * lifecycle methods and routing.\n *\n * An activity is registered by its class definition. Because of that, activities\n * cannot have constructors that require own parameters. Activities have to be\n * self contained or use the event system to request data.\n */\nexport class ActivityManager {\n private currentActivity?: Activity\n\n /**\n * Stores activity *classes* by unique ID (action name).\n */\n private activityClasses = new Map<string, typeof Activity>()\n\n /**\n * Represents the activity stack. It is used to manage\n * the UI state after calling the back action.\n */\n private activityStack: ActivityStackEntry[] = []\n\n /**\n * A stack of activities that are rendered over other activities\n * in a dialog.\n */\n private modalActivityStack: ActivityStackEntry[] = []\n\n private generateActivityId(): string {\n return Math.random().toString(36).substring(2, 15)\n }\n\n #parent: Application\n\n constructor(parent: Application) {\n this.#parent = parent\n // this.reflectEvent = this.reflectEvent.bind(this)\n }\n\n registerActivity(action: string, activityClass: typeof Activity): void {\n if (this.activityClasses.has(action)) {\n // eslint-disable-next-line no-console\n console.warn(`Activity with action \"${action}\" already registered.`, new Error().stack)\n }\n this.activityClasses.set(action, activityClass)\n }\n\n // protected reflectEvent<T extends Event>(event: T): T {\n // const copy = Reflect.construct(event.constructor, [event.type, event])\n // const dispatched = this.#parent.events.dispatchEvent(copy)\n // if (!dispatched) {\n // event.preventDefault()\n // }\n // return copy\n // }\n\n /**\n * Creates an activity and pushes it into the stack, but it does not initialize any of the lifecycle methods.\n * It is a way to put an activity at some place of the stack,\n * but it will be only initialized when other activities finis.\n *\n * Note, if you add an uninitialized activity and you won't add more activities then this activity may never run.\n * Make sure that there's always another activity.\n *\n * @param intent The intent that created this activity.\n */\n async createActivity(intent: Intent): Promise<void> {\n const activity = this.buildActivity(intent)\n const activityId = this.generateActivityId()\n const stackEntry: ActivityStackEntry = { activity, id: activityId, intent, action: intent.action }\n this.activityStack.push(stackEntry)\n }\n\n setupRoute(intent: Intent): void {\n if (intent.data) {\n const typed = intent.data as { uri?: string }\n if (typed.uri) {\n navigateScreen(typed.uri)\n }\n }\n }\n\n /**\n * Starts a new activity and brings it to the foreground.\n *\n * @param intent The intent that created this activity.\n */\n async startActivity(intent: Intent): Promise<void> {\n const { currentActivity, activityStack } = this\n const lastIndex = activityStack.findLastIndex((entry) => entry.action === intent.action)\n // if the activity is in the history list, we bring it up and update intent.\n if (lastIndex > -1) {\n const info = activityStack[lastIndex]\n activityStack.splice(lastIndex, 1)\n activityStack.push({\n id: info.id,\n activity: info.activity,\n action: info.action,\n intent,\n })\n await info.activity.onNewIntent(intent)\n // TODO: Check if the activity is destroyed.\n this.setupRoute(intent)\n // this.currentActivity = info.activity\n await this.updateCurrentActivity(info.activity, false)\n return\n }\n const activity = this.buildActivity(intent)\n if (currentActivity) {\n await currentActivity.onPause()\n currentActivity.state = ActivityState.Paused\n }\n\n const activityId = this.generateActivityId()\n const stackEntry: ActivityStackEntry = { activity, id: activityId, intent, action: intent.action }\n // Modal activities are pretty much the same as regular activities but are rendered on top\n // of other activities. We keep track of them on another stack as all modal activities must\n // finish before returning to the regular stack.\n const isModal = (intent.flags ?? 0) & IntentFlags.Modal\n if (isModal) {\n this.modalActivityStack.push(stackEntry)\n } else {\n this.activityStack.push(stackEntry)\n }\n await activity.onCreate(intent)\n if (this.isDestroyed(activity)) {\n // the activity finished and the manager already took care of this situation.\n return\n }\n activity.state = ActivityState.Created\n\n await this.updateCurrentActivity(activity, !!isModal)\n if (this.isDestroyed(activity)) {\n // the activity finished and the manager already took care of this situation.\n return\n }\n this.setupRoute(intent)\n }\n\n private buildActivity(intent: Intent): Activity {\n const action = intent.action\n if (!this.activityClasses.has(action)) {\n throw new Error(`No activity class registered for action: ${action}`)\n }\n\n const ActivityClass = this.activityClasses.get(action)\n if (!ActivityClass) {\n throw new Error(`No activity class registered for action: ${action}`)\n }\n\n // We use the container to resolve dependencies, if any.\n // const activity = (await container.make(ActivityClass, [this.#parent])) as Activity\n return new ActivityClass(this.#parent)\n }\n\n /**\n * Starts an activity that should return a result to the calling activity.\n * The result should be a unique number across the application.\n * @param intent The intent to start the activity.\n * @param requestCode The request code used to match the activity result.\n */\n async startActivityForResult(intent: Intent, requestCode: number): Promise<void> {\n intent.requestCode = requestCode\n const byReference = (intent.flags ?? 0) & IntentFlags.ByReference\n const shallowCopy = { ...intent }\n const data = shallowCopy.data\n if (byReference) {\n delete shallowCopy.data\n }\n const deepCopy = structuredClone(shallowCopy)\n if (data && byReference) {\n deepCopy.data = data\n }\n if (deepCopy.flags) {\n deepCopy.flags = deepCopy.flags | IntentFlags.ForResult\n } else {\n deepCopy.flags = IntentFlags.ForResult\n }\n await this.startActivity(deepCopy)\n }\n\n isDestroyed(activity: Activity): boolean {\n return activity.state === ActivityState.Destroyed\n }\n\n /**\n * @param activity The activity to finish.\n */\n async finishActivity(activity: Activity): Promise<void> {\n this.setupStyles(undefined, activity)\n const isModal = this.modalActivityStack.some((entry) => entry.activity === activity)\n const stack = isModal ? this.modalActivityStack : this.activityStack\n const index = stack.findIndex((entry) => entry.activity === activity)\n if (index !== -1) {\n const stackEntry = stack.splice(index, 1)[0]\n\n await stackEntry.activity.onPause()\n stackEntry.activity.state = ActivityState.Paused\n await stackEntry.activity.onStop()\n stackEntry.activity.state = ActivityState.Stopped\n await stackEntry.activity.onDestroy()\n stackEntry.activity.state = ActivityState.Destroyed\n\n await this.manageActivityResult(stackEntry.activity, stackEntry.intent)\n\n // Resume the previous activity\n await this.bringLastActivityToFront()\n } else {\n if (activity.state === ActivityState.Created) {\n await activity.onStop()\n activity.state = ActivityState.Stopped\n }\n await activity.onDestroy()\n activity.state = ActivityState.Destroyed\n // This can happen when an activity finishes in one of the callback methods,\n // before it is added to the stack. In that case, we bring the last activity back to the front.\n await this.bringLastActivityToFront()\n }\n this.#parent.requestUpdate()\n }\n\n private async manageActivityResult(activity: Activity, intent: Intent): Promise<void> {\n const { flags = 0, requestCode = -1 } = intent\n if (flags & IntentFlags.ForResult) {\n const all = [...this.activityStack, ...this.modalActivityStack]\n const target = all.find((entry) => entry.activity.hasRequestCode(requestCode))\n if (target) {\n if (target.activity.state === ActivityState.Destroyed) {\n return\n }\n if (target.activity.state === ActivityState.Resumed) {\n await target.activity.onPause()\n target.activity.state = ActivityState.Paused\n }\n const intentCopy = structuredClone(intent)\n intentCopy.data = activity.getResult()\n await target.activity.onActivityResult(requestCode, activity.resultCode, intentCopy)\n }\n }\n }\n\n private async bringLastActivityToFront(): Promise<void> {\n if (this.modalActivityStack.length > 0) {\n const previousEntry = this.modalActivityStack[this.activityStack.length - 1]\n await this.updateCurrentActivity(previousEntry.activity, false)\n } else if (this.activityStack.length > 0) {\n const previousEntry = this.activityStack[this.activityStack.length - 1]\n await this.updateCurrentActivity(previousEntry.activity, false)\n } else {\n this.currentActivity = undefined // No more activities\n }\n }\n\n getTopActivity(): Activity | undefined {\n const topModal = this.modalActivityStack.findLast((a) => a.activity.state === ActivityState.Resumed)\n if (topModal) {\n return topModal.activity\n }\n const top = this.activityStack.findLast((a) => a.activity.state === ActivityState.Resumed)\n return top ? top.activity : undefined\n }\n\n getCurrentActivity(): Activity | undefined {\n return this.currentActivity\n }\n\n /**\n * Sets the styles for the current activity.\n * This method adds or removes CSS classes based on the activity's class name\n * and action, allowing for dynamic styling based on the active activity.\n * @param activity The activity to set styles for.\n * If not provided, it will not set any styles.\n * If the activity is the same as the current one, it does nothing.\n */\n setupStyles(activity?: Activity, oldActivity?: Activity): void {\n if (activity === oldActivity) {\n return\n }\n const root = document?.documentElement\n if (!root) {\n return\n }\n if (oldActivity) {\n const ctor = oldActivity.constructor as typeof Activity\n root.classList.remove(ctor.name.toLowerCase())\n if (ctor.action) {\n root.classList.remove(ctor.action.replace(/\\//g, '-'))\n }\n }\n if (activity) {\n const ctor = activity.constructor as typeof Activity\n root.classList.add(ctor.name.toLowerCase())\n if (ctor.action) {\n root.classList.add(ctor.action.replace(/\\//g, '-'))\n }\n }\n }\n\n /**\n * A helper method to handle the transition between activities, ensuring\n * lifecycle methods are called in the correct order (pause the previous activity,\n * then start/resume the new one). This centralizes lifecycle management.\n *\n * @param activity The activity to bring to the foreground.\n */\n private async updateCurrentActivity(activity: Activity, isModal: boolean): Promise<void> {\n this.setupStyles(activity, this.currentActivity)\n if (\n this.currentActivity &&\n this.currentActivity !== activity &&\n this.currentActivity.state !== ActivityState.Destroyed &&\n // Make sure we don't pause the current activity if it's already paused.\n this.currentActivity.state !== ActivityState.Paused\n ) {\n await this.currentActivity.onPause()\n this.currentActivity.state = ActivityState.Paused\n }\n if (activity.state === ActivityState.Paused) {\n await activity.onResume()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Resumed\n activity.requestUpdate()\n } else if (activity.state === ActivityState.Stopped) {\n await activity.onRestart()\n activity.state = ActivityState.Resumed\n } else if (activity.state === ActivityState.Destroyed) {\n throw new Error(`Invalid state. The activity is already destroyed.`)\n } else if (activity.state === ActivityState.Created) {\n await activity.onStart()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Started\n await activity.onResume()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Resumed\n activity.requestUpdate()\n } else if (activity.state === ActivityState.Started) {\n await activity.onResume()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Resumed\n activity.requestUpdate()\n } else if (activity.state === ActivityState.Initialized) {\n // TODO: Figure out intent passing here.\n await activity.onCreate()\n activity.state = ActivityState.Created\n if (this.isDestroyed(activity)) {\n // the activity finished and the manager already took care of this situation.\n return\n }\n await activity.onStart()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Started\n await activity.onResume()\n if (this.isDestroyed(activity)) {\n return\n }\n activity.state = ActivityState.Resumed\n activity.requestUpdate()\n }\n if (!isModal) {\n // With a modal activity, it renders directly to the `<body>` and renders outside\n // of the normal rendering flow. We keep the previous activity rendered.\n this.currentActivity = activity\n }\n }\n\n /**\n * Allows navigating back through the activity stack.\n * Call `ActivityManager.navigateBack()` when the user performs a back action\n * (e.g., clicks a back button).\n */\n async navigateBack(): Promise<void> {\n if (this.activityStack.length > 1 && this.currentActivity) {\n // Finish current, which will resume previous\n await this.finishActivity(this.currentActivity)\n }\n // Else do nothing (or display a message, or exit the app)\n }\n\n createRequestCode(): number {\n const min = 1000\n const max = 9999\n return Math.floor(Math.random() * (max - min) + min)\n }\n\n findActiveActivity(action: string): Activity | undefined {\n return this.activityStack.find((entry) => entry.action === action)?.activity\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../../src/core/Application.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAClD,OAAO,EAAE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