pdf-quiz-generator/mobile/node_modules/@ionic/cli-framework-output/dist/tasks.js
Daniel dc240c31d2 Add Capacitor mobile app wrapper for PedsHub Quiz
- Configurable server URL (default: pedshub.com)
- Android + iOS platforms initialized
- Dark theme matching quiz app (#0f172a)
- Status bar and navigation bar color matched
- Auto-redirect on subsequent launches
- App ID: com.pedshub.quiz, App Name: PedsHub

Build: cd mobile && npx cap sync && npx cap open android

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-11 05:12:25 +02:00

141 lines
3.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskChain = exports.Task = exports.Spinner = exports.ICON_FAILURE = exports.ICON_SUCCESS = void 0;
const events_1 = require("events");
const isWindows = process.platform === 'win32';
exports.ICON_SUCCESS = isWindows ? '√' : '✔';
exports.ICON_FAILURE = isWindows ? '×' : '✖';
const SPINNER_FRAMES = isWindows ?
['-', '\\', '|', '/'] :
['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
class Spinner {
constructor(frames = SPINNER_FRAMES) {
this.frames = frames;
this.i = 0;
}
frame() {
return this.frames[this.i = ++this.i % this.frames.length];
}
}
exports.Spinner = Spinner;
class Task extends events_1.EventEmitter {
constructor({ msg = '', tickInterval } = {}) {
super();
this.running = false;
this._msg = '';
this._success = false;
this.msg = msg;
this.tickInterval = tickInterval;
}
get msg() {
return this._msg;
}
set msg(msg) {
this._msg = msg;
this.tick();
}
start() {
if (!this.running && this.tickInterval) {
this.intervalId = setInterval(() => { this.tick(); }, this.tickInterval);
}
this.running = true;
this._startTime = process.hrtime();
return this;
}
tick() {
this.emit('tick');
return this;
}
progress(prog, total) {
this.progressRatio = prog / total;
this.tick();
return this;
}
clear() {
if (this.intervalId) {
clearInterval(this.intervalId);
this.intervalId = undefined;
}
this.emit('clear');
return this;
}
end() {
this.running = false;
this.tick();
this.clear();
this.emit('end', {
elapsedTime: process.hrtime(this._startTime),
success: this._success,
});
return this;
}
succeed() {
if (this.running) {
this._success = true;
this.end();
this.emit('success');
}
return this;
}
fail() {
if (this.running) {
this._success = false;
this.end();
this.emit('failure');
}
return this;
}
}
exports.Task = Task;
class TaskChain extends events_1.EventEmitter {
constructor({ taskOptions = {} } = {}) {
super();
this.tasks = [];
this.taskOptions = taskOptions;
}
next(msg) {
return this.nextTask(this.createTask({ msg, ...this.taskOptions }));
}
createTask(options) {
return new Task(options);
}
nextTask(task) {
if (this.current) {
this.current.succeed();
}
this.tasks.push(task);
this.current = task;
task.start();
this.emit('next', task);
return task;
}
end() {
const task = this.current;
if (task) {
task.succeed();
}
this.current = undefined;
this.emit('end', task);
return this;
}
fail() {
const task = this.current;
if (task) {
task.fail();
}
this.emit('failure', task);
return this;
}
cleanup() {
for (const task of this.tasks) {
if (task.running) {
task.fail();
}
else {
task.clear();
}
}
return this;
}
}
exports.TaskChain = TaskChain;