Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@frui.ts/screens

Package Overview
Dependencies
Maintainers
5
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frui.ts/screens - npm Package Compare versions

Comparing version 1.0.0-alpha.8 to 1.0.0-alpha.9

89

dist/busyWatcher.js

@@ -13,21 +13,15 @@ "use strict";

exports.watchBusy = void 0;
var mobx_1 = require("mobx");
var BusyWatcher = (function () {
function BusyWatcher() {
const mobx_1 = require("mobx");
class BusyWatcher {
constructor() {
this.busyCounter = new mobx_1.ObservableMap();
}
Object.defineProperty(BusyWatcher.prototype, "isBusy", {
get: function () {
return this.busyCounter.size > 0;
},
enumerable: false,
configurable: true
});
BusyWatcher.prototype.checkBusy = function (key) {
get isBusy() {
return this.busyCounter.size > 0;
}
checkBusy(key) {
return this.busyCounter.has(key);
};
BusyWatcher.prototype.getBusyTicket = function (key) {
var _this = this;
if (key === void 0) { key = Symbol(); }
var counter = this.busyCounter.get(key);
}
getBusyTicket(key = Symbol()) {
const counter = this.busyCounter.get(key);
if (counter) {

@@ -39,11 +33,11 @@ this.busyCounter.set(key, counter + 1);

}
var isCleared = false;
return (0, mobx_1.action)(function () {
let isCleared = false;
return (0, mobx_1.action)(() => {
if (!isCleared) {
var currentCounter = _this.busyCounter.get(key);
const currentCounter = this.busyCounter.get(key);
if (!currentCounter || currentCounter === 1) {
_this.busyCounter.delete(key);
this.busyCounter.delete(key);
}
else {
_this.busyCounter.set(key, currentCounter - 1);
this.busyCounter.set(key, currentCounter - 1);
}

@@ -53,38 +47,33 @@ isCleared = true;

});
};
BusyWatcher.prototype.watch = function (watchedAction) {
var ticket = this.getBusyTicket();
}
watch(watchedAction) {
const ticket = this.getBusyTicket();
watchedAction.then(ticket, ticket);
return watchedAction;
};
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], BusyWatcher.prototype, "isBusy", null);
__decorate([
mobx_1.action.bound,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], BusyWatcher.prototype, "getBusyTicket", null);
return BusyWatcher;
}());
}
}
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], BusyWatcher.prototype, "isBusy", null);
__decorate([
mobx_1.action.bound,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], BusyWatcher.prototype, "getBusyTicket", null);
exports.default = BusyWatcher;
function watchBusy(target, propertyKey, descriptor) {
var isCustomKey = typeof target !== "object";
var key = isCustomKey ? target : Symbol();
var decorator = function (target, propertyKey, descriptor) {
var originalFunction = descriptor.value;
descriptor.value = function () {
const isCustomKey = typeof target !== "object";
const key = isCustomKey ? target : Symbol();
const decorator = (target, propertyKey, descriptor) => {
const originalFunction = descriptor.value;
descriptor.value = function (...args) {
var _a;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var ticket = (_a = this.busyWatcher) === null || _a === void 0 ? void 0 : _a.getBusyTicket(key);
var result = originalFunction.apply(this, args);
const ticket = (_a = this.busyWatcher) === null || _a === void 0 ? void 0 : _a.getBusyTicket(key);
const result = originalFunction.apply(this, args);
if (ticket) {
if (isPromise(result)) {
result.then(ticket, function (error) {
result.then(ticket, (error) => {
console.error(error);

@@ -91,0 +80,0 @@ ticket();

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TypedEventHub = (function () {
function TypedEventHub() {
class TypedEventHub {
constructor() {
this.events = new Map();
}
TypedEventHub.prototype.on = function (event, listener) {
var _this = this;
var listeners = this.ensureListeners(event);
on(event, listener) {
const listeners = this.ensureListeners(event);
listeners.push(listener);
return function () {
var listeners = _this.events.get(event);
return () => {
const listeners = this.events.get(event);
if (listeners) {
var index = listeners.indexOf(listener);
const index = listeners.indexOf(listener);
if (index >= 0) {

@@ -20,8 +19,8 @@ listeners.splice(index, 1);

};
};
TypedEventHub.prototype.getListeners = function (event) {
}
getListeners(event) {
return this.events.get(event);
};
TypedEventHub.prototype.ensureListeners = function (event) {
var existing = this.events.get(event);
}
ensureListeners(event) {
const existing = this.events.get(event);
if (existing) {

@@ -31,10 +30,9 @@ return existing;

else {
var list = [];
const list = [];
this.events.set(event, list);
return list;
}
};
return TypedEventHub;
}());
}
}
exports.default = TypedEventHub;
//# sourceMappingURL=typedEventHub.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -35,29 +20,2 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -67,170 +25,116 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
var findChildResult_1 = require("../../models/findChildResult");
var screenBase_1 = require("../../screens/screenBase");
var lifecycleScreenNavigatorBase_1 = __importDefault(require("../lifecycleScreenNavigatorBase"));
var ActiveChildConductor = (function (_super) {
__extends(ActiveChildConductor, _super);
function ActiveChildConductor() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.activeChildValue = undefined;
return _this;
const mobx_1 = require("mobx");
const findChildResult_1 = require("../../models/findChildResult");
const screenBase_1 = require("../../screens/screenBase");
const lifecycleScreenNavigatorBase_1 = __importDefault(require("../lifecycleScreenNavigatorBase"));
class ActiveChildConductor extends lifecycleScreenNavigatorBase_1.default {
constructor() {
super(...arguments);
this.activeChildValue = undefined;
}
Object.defineProperty(ActiveChildConductor.prototype, "activeChild", {
get: function () {
return this.activeChildValue;
},
enumerable: false,
configurable: true
});
ActiveChildConductor.prototype.getPrimaryChild = function () {
get activeChild() {
return this.activeChildValue;
}
getPrimaryChild() {
return (0, screenBase_1.getNavigator)(this.activeChild);
};
ActiveChildConductor.prototype.canNavigate = function (path) {
}
canNavigate(path) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var context, canChange;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
context = {
navigator: this,
screen: this.screen,
navigationParams: (_a = path[0]) === null || _a === void 0 ? void 0 : _a.params,
path: path,
};
if (!this.canChangeActiveChild) return [3, 2];
return [4, this.canChangeActiveChild(context, this.activeChild)];
case 1:
canChange = _b.sent();
if (!canChange) {
return [2, false];
}
_b.label = 2;
case 2: return [4, this.aggregateBooleanAll("canNavigate", context)];
case 3: return [2, _b.sent()];
return __awaiter(this, void 0, void 0, function* () {
const context = {
navigator: this,
screen: this.screen,
navigationParams: (_a = path[0]) === null || _a === void 0 ? void 0 : _a.params,
path,
};
if (this.canChangeActiveChild) {
const canChange = yield this.canChangeActiveChild(context, this.activeChild);
if (!canChange) {
return false;
}
});
}
return yield this.aggregateBooleanAll("canNavigate", context);
});
};
ActiveChildConductor.prototype.navigate = function (path) {
}
navigate(path) {
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function () {
var context, currentChild, childResult, currentChildNavigator, newChildNavigator;
var _this = this;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
if (!this.findNavigationChild) {
throw new Error("findNavigationChild is not implemented");
}
context = {
navigator: this,
screen: this.screen,
navigationParams: (_a = path[0]) === null || _a === void 0 ? void 0 : _a.params,
path: path,
};
if (!!this.isInitialized) return [3, 2];
return [4, this.initialize(context)];
case 1:
_d.sent();
_d.label = 2;
case 2:
if (!!this.isActive) return [3, 4];
return [4, this.activate(context)];
case 3:
_d.sent();
_d.label = 4;
case 4: return [4, this.callAll("onNavigate", context)];
case 5:
_d.sent();
currentChild = this.activeChild;
return [4, this.findNavigationChild(context, currentChild)];
case 6:
childResult = _d.sent();
if (!(currentChild !== childResult.newChild)) return [3, 8];
currentChildNavigator = (0, screenBase_1.getNavigator)(currentChild);
return [4, ((_b = currentChildNavigator === null || currentChildNavigator === void 0 ? void 0 : currentChildNavigator.deactivate) === null || _b === void 0 ? void 0 : _b.call(currentChildNavigator, !!childResult.closePrevious))];
case 7:
_d.sent();
if ((0, findChildResult_1.isChildFoundResult)(childResult) && childResult.attachToParent !== false) {
this.connectChild(childResult.newChild);
}
(0, mobx_1.runInAction)(function () { return (_this.activeChildValue = childResult.newChild); });
_d.label = 8;
case 8:
if (!(0, findChildResult_1.isChildFoundResult)(childResult)) return [3, 10];
newChildNavigator = (0, screenBase_1.getNavigator)(childResult.newChild);
return [4, (newChildNavigator === null || newChildNavigator === void 0 ? void 0 : newChildNavigator.navigate((_c = childResult.pathForChild) !== null && _c !== void 0 ? _c : path.slice(this.getNavigationStateLength())))];
case 9:
_d.sent();
_d.label = 10;
case 10: return [2];
return __awaiter(this, void 0, void 0, function* () {
if (!this.findNavigationChild) {
throw new Error("findNavigationChild is not implemented");
}
const context = {
navigator: this,
screen: this.screen,
navigationParams: (_a = path[0]) === null || _a === void 0 ? void 0 : _a.params,
path,
};
if (!this.isInitialized) {
yield this.initialize(context);
}
if (!this.isActive) {
yield this.activate(context);
}
yield this.callAll("onNavigate", context);
const currentChild = this.activeChild;
const childResult = yield this.findNavigationChild(context, currentChild);
if (currentChild !== childResult.newChild) {
const currentChildNavigator = (0, screenBase_1.getNavigator)(currentChild);
yield ((_b = currentChildNavigator === null || currentChildNavigator === void 0 ? void 0 : currentChildNavigator.deactivate) === null || _b === void 0 ? void 0 : _b.call(currentChildNavigator, !!childResult.closePrevious));
if ((0, findChildResult_1.isChildFoundResult)(childResult) && childResult.attachToParent !== false) {
this.connectChild(childResult.newChild);
}
});
(0, mobx_1.runInAction)(() => (this.activeChildValue = childResult.newChild));
}
if ((0, findChildResult_1.isChildFoundResult)(childResult)) {
const newChildNavigator = (0, screenBase_1.getNavigator)(childResult.newChild);
yield (newChildNavigator === null || newChildNavigator === void 0 ? void 0 : newChildNavigator.navigate((_c = childResult.pathForChild) !== null && _c !== void 0 ? _c : path.slice(this.getNavigationStateLength())));
}
});
};
ActiveChildConductor.prototype.canDeactivate = function (isClosing) {
}
canDeactivate(isClosing) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var context, canDeactivateFunction, canDeactivate;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
context = {
navigator: this,
screen: this.screen,
isClosing: isClosing,
};
canDeactivateFunction = (_a = (0, screenBase_1.getNavigator)(this.activeChild)) === null || _a === void 0 ? void 0 : _a.canDeactivate;
if (!canDeactivateFunction) return [3, 2];
return [4, canDeactivateFunction(isClosing)];
case 1:
canDeactivate = _b.sent();
if (!canDeactivate) {
return [2, false];
}
_b.label = 2;
case 2: return [2, this.aggregateBooleanAll("canDeactivate", context)];
return __awaiter(this, void 0, void 0, function* () {
const context = {
navigator: this,
screen: this.screen,
isClosing,
};
const canDeactivateFunction = (_a = (0, screenBase_1.getNavigator)(this.activeChild)) === null || _a === void 0 ? void 0 : _a.canDeactivate;
if (canDeactivateFunction) {
const canDeactivate = yield canDeactivateFunction(isClosing);
if (!canDeactivate) {
return false;
}
});
}
return this.aggregateBooleanAll("canDeactivate", context);
});
};
ActiveChildConductor.prototype.deactivate = function (isClosing) {
}
deactivate(isClosing) {
const _super = Object.create(null, {
deactivate: { get: () => super.deactivate }
});
var _a;
return __awaiter(this, void 0, void 0, function () {
var activeChildNavigator;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
activeChildNavigator = (0, screenBase_1.getNavigator)(this.activeChild);
return [4, ((_a = activeChildNavigator === null || activeChildNavigator === void 0 ? void 0 : activeChildNavigator.deactivate) === null || _a === void 0 ? void 0 : _a.call(activeChildNavigator, isClosing))];
case 1:
_b.sent();
return [4, _super.prototype.deactivate.call(this, isClosing)];
case 2:
_b.sent();
return [2];
}
});
return __awaiter(this, void 0, void 0, function* () {
const activeChildNavigator = (0, screenBase_1.getNavigator)(this.activeChild);
yield ((_a = activeChildNavigator === null || activeChildNavigator === void 0 ? void 0 : activeChildNavigator.deactivate) === null || _a === void 0 ? void 0 : _a.call(activeChildNavigator, isClosing));
yield _super.deactivate.call(this, isClosing);
});
};
ActiveChildConductor.prototype.connectChild = function (child) {
var navigator = (0, screenBase_1.getNavigator)(child);
}
connectChild(child) {
const navigator = (0, screenBase_1.getNavigator)(child);
if (navigator) {
navigator.parent = this;
}
};
__decorate([
mobx_1.observable.ref,
__metadata("design:type", Object)
], ActiveChildConductor.prototype, "activeChildValue", void 0);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], ActiveChildConductor.prototype, "activeChild", null);
return ActiveChildConductor;
}(lifecycleScreenNavigatorBase_1.default));
}
}
__decorate([
mobx_1.observable.ref,
__metadata("design:type", Object)
], ActiveChildConductor.prototype, "activeChildValue", void 0);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], ActiveChildConductor.prototype, "activeChild", null);
exports.default = ActiveChildConductor;
//# sourceMappingURL=activeChildConductor.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -32,29 +6,17 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
var screenBase_1 = require("../../screens/screenBase");
var lifecycleScreenNavigatorBase_1 = __importDefault(require("../lifecycleScreenNavigatorBase"));
var AllChildrenActiveConductor = (function (_super) {
__extends(AllChildrenActiveConductor, _super);
function AllChildrenActiveConductor(screen, navigationPrefix, eventHub) {
var _this = _super.call(this, screen, navigationPrefix, eventHub) || this;
_this.handleChildrenChanged = function (change) {
var e_1, _a;
const mobx_1 = require("mobx");
const screenBase_1 = require("../../screens/screenBase");
const lifecycleScreenNavigatorBase_1 = __importDefault(require("../lifecycleScreenNavigatorBase"));
class AllChildrenActiveConductor extends lifecycleScreenNavigatorBase_1.default {
constructor(screen, navigationPrefix, eventHub) {
super(screen, navigationPrefix, eventHub);
this.handleChildrenChanged = (change) => {
switch (change.type) {
case "splice":
try {
for (var _b = __values(change.added), _c = _b.next(); !_c.done; _c = _b.next()) {
var newItem = _c.value;
_this.connectChild(newItem);
}
for (const newItem of change.added) {
this.connectChild(newItem);
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
break;
case "update":
_this.connectChild(change.newValue);
this.connectChild(change.newValue);
break;

@@ -64,16 +26,14 @@ }

};
var children = mobx_1.observable.array([], { deep: false });
children.intercept(_this.handleChildrenChanged);
_this.children = children;
return _this;
const children = mobx_1.observable.array([], { deep: false });
children.intercept(this.handleChildrenChanged);
this.children = children;
}
AllChildrenActiveConductor.prototype.connectChild = function (child) {
var navigator = (0, screenBase_1.getNavigator)(child);
connectChild(child) {
const navigator = (0, screenBase_1.getNavigator)(child);
if (navigator) {
navigator.parent = this;
}
};
return AllChildrenActiveConductor;
}(lifecycleScreenNavigatorBase_1.default));
}
}
exports.default = AllChildrenActiveConductor;
//# sourceMappingURL=allChildrenActiveConductor.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -26,40 +11,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -69,50 +16,35 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
var screenBase_1 = require("../../screens/screenBase");
var activeChildConductor_1 = __importDefault(require("./activeChildConductor"));
var OneOfListActiveConductor = (function (_super) {
__extends(OneOfListActiveConductor, _super);
function OneOfListActiveConductor(screen, navigationPrefix, eventHub) {
var _this = _super.call(this, screen, navigationPrefix, eventHub) || this;
_this.preserveActiveChild = false;
_this.canChangeActiveChild = function (context, currentChild) { return __awaiter(_this, void 0, void 0, function () {
var pathElementsToSkip, newNavigationName, activeChildNavigator;
const mobx_1 = require("mobx");
const screenBase_1 = require("../../screens/screenBase");
const activeChildConductor_1 = __importDefault(require("./activeChildConductor"));
class OneOfListActiveConductor extends activeChildConductor_1.default {
constructor(screen, navigationPrefix, eventHub) {
super(screen, navigationPrefix, eventHub);
this.preserveActiveChild = false;
this.canChangeActiveChild = (context, currentChild) => __awaiter(this, void 0, void 0, function* () {
var _a;
return __generator(this, function (_b) {
pathElementsToSkip = this.getNavigationStateLength();
newNavigationName = (_a = context.path[pathElementsToSkip]) === null || _a === void 0 ? void 0 : _a.name;
activeChildNavigator = (0, screenBase_1.getNavigator)(this.activeChild);
if (!activeChildNavigator || activeChildNavigator.navigationName === newNavigationName) {
return [2, true];
}
return [2, activeChildNavigator.canDeactivate ? activeChildNavigator.canDeactivate(false) : true];
});
}); };
_this.findNavigationChild = function (context, currentChild) {
const pathElementsToSkip = this.getNavigationStateLength();
const newNavigationName = (_a = context.path[pathElementsToSkip]) === null || _a === void 0 ? void 0 : _a.name;
const activeChildNavigator = (0, screenBase_1.getNavigator)(this.activeChild);
if (!activeChildNavigator || activeChildNavigator.navigationName === newNavigationName) {
return true;
}
return activeChildNavigator.canDeactivate ? activeChildNavigator.canDeactivate(false) : true;
});
this.findNavigationChild = (context, currentChild) => {
var _a;
var pathElementsToSkip = _this.getNavigationStateLength();
var searchedNavigationName = (_a = context.path[pathElementsToSkip]) === null || _a === void 0 ? void 0 : _a.name;
var newChild = _this.findChild(searchedNavigationName);
return { newChild: newChild, closePrevious: false };
const pathElementsToSkip = this.getNavigationStateLength();
const searchedNavigationName = (_a = context.path[pathElementsToSkip]) === null || _a === void 0 ? void 0 : _a.name;
const newChild = this.findChild(searchedNavigationName);
return { newChild, closePrevious: false };
};
_this.handleChildrenChanged = function (change) {
var e_1, _a;
this.handleChildrenChanged = (change) => {
switch (change.type) {
case "splice":
try {
for (var _b = __values(change.added), _c = _b.next(); !_c.done; _c = _b.next()) {
var newItem = _c.value;
_this.connectChild(newItem);
}
for (const newItem of change.added) {
this.connectChild(newItem);
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
break;
case "update":
_this.connectChild(change.newValue);
this.connectChild(change.newValue);
break;

@@ -122,8 +54,7 @@ }

};
var children = mobx_1.observable.array([], { deep: false });
children.intercept(_this.handleChildrenChanged);
_this.children = children;
return _this;
const children = mobx_1.observable.array([], { deep: false });
children.intercept(this.handleChildrenChanged);
this.children = children;
}
OneOfListActiveConductor.prototype.findChild = function (navigationName) {
findChild(navigationName) {
var _a;

@@ -133,7 +64,6 @@ if (this.preserveActiveChild && navigationName === undefined) {

}
return navigationName !== undefined ? this.children.find(function (x) { var _a; return ((_a = (0, screenBase_1.getNavigator)(x)) === null || _a === void 0 ? void 0 : _a.navigationName) === navigationName; }) : undefined;
};
return OneOfListActiveConductor;
}(activeChildConductor_1.default));
return navigationName !== undefined ? this.children.find(x => { var _a; return ((_a = (0, screenBase_1.getNavigator)(x)) === null || _a === void 0 ? void 0 : _a.navigationName) === navigationName; }) : undefined;
}
}
exports.default = OneOfListActiveConductor;
//# sourceMappingURL=oneOfListActiveConductor.js.map

@@ -7,10 +7,10 @@ "use strict";

exports.dumpViewModelHierarchy = exports.inspectViewModelHierarchy = void 0;
var mobx_1 = require("mobx");
var screenBase_1 = require("../screens/screenBase");
var activeChildConductor_1 = __importDefault(require("./conductors/activeChildConductor"));
const mobx_1 = require("mobx");
const screenBase_1 = require("../screens/screenBase");
const activeChildConductor_1 = __importDefault(require("./conductors/activeChildConductor"));
function inspectViewModelHierarchy(vm, router) {
var _a;
var screen = vm;
var activeChild = screen.navigator instanceof activeChildConductor_1.default ? screen.navigator.activeChild : undefined;
var children = (_a = (0, screenBase_1.getNavigator)(screen)) === null || _a === void 0 ? void 0 : _a.children;
const screen = vm;
const activeChild = screen.navigator instanceof activeChildConductor_1.default ? screen.navigator.activeChild : undefined;
const children = (_a = (0, screenBase_1.getNavigator)(screen)) === null || _a === void 0 ? void 0 : _a.children;
return {

@@ -23,3 +23,3 @@ name: (0, mobx_1.get)(screen, "name"),

activeChild: activeChild ? inspectViewModelHierarchy(activeChild, router) : undefined,
children: (0, mobx_1.isArrayLike)(children) ? children.map(function (x) { return inspectViewModelHierarchy(x, router); }) : undefined,
children: (0, mobx_1.isArrayLike)(children) ? children.map(x => inspectViewModelHierarchy(x, router)) : undefined,
};

@@ -29,12 +29,12 @@ }

function dumpViewModelHierarchy(vm) {
var rows = [];
var dump = function (item) {
const rows = [];
const dump = (item) => {
var _a, _b, _c;
rows.push("/" + (item.navigationPath || "") + " - " + (item.name || item.navigationName || "") + " (" + (((_b = (_a = item.instance) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) || "") + ")");
rows.push(`/${item.navigationPath || ""} - ${item.name || item.navigationName || ""} (${((_b = (_a = item.instance) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) || ""})`);
if (item.activeChild) {
dump(item.activeChild);
}
(_c = item.children) === null || _c === void 0 ? void 0 : _c.filter(function (x) { var _a; return x.instance !== ((_a = item.activeChild) === null || _a === void 0 ? void 0 : _a.instance); }).forEach(dump);
(_c = item.children) === null || _c === void 0 ? void 0 : _c.filter(x => { var _a; return x.instance !== ((_a = item.activeChild) === null || _a === void 0 ? void 0 : _a.instance); }).forEach(dump);
};
var data = inspectViewModelHierarchy(vm);
const data = inspectViewModelHierarchy(vm);
dump(data);

@@ -41,0 +41,0 @@ return rows;

@@ -20,114 +20,42 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
var mobx_1 = require("mobx");
var LifecycleScreenNavigatorBase = (function () {
function LifecycleScreenNavigatorBase(screen, navigationPrefix, eventHub) {
var _this = this;
const mobx_1 = require("mobx");
class LifecycleScreenNavigatorBase {
constructor(screen, navigationPrefix, eventHub) {
this.parent = undefined;
this.getNavigationState = function () { return [_this.createDefaultNavigationState()]; };
this.getNavigationStateLength = function () { return 1; };
this.getNavigationState = () => [this.createDefaultNavigationState()];
this.getNavigationStateLength = () => 1;
this.isInitializedValue = false;
this.clearInitializePromise = function () { return (_this.initializePromise = undefined); };
this.clearInitializePromise = () => (this.initializePromise = undefined);
this.isActiveValue = false;
this.clearActivatePromise = function () { return (_this.activatePromise = undefined); };
this.clearDeactivatePromise = function () { return (_this.deactivatePromise = undefined); };
this.clearActivatePromise = () => (this.activatePromise = undefined);
this.clearDeactivatePromise = () => (this.deactivatePromise = undefined);
this.screenValue = screen;
this.eventHub = eventHub !== null && eventHub !== void 0 ? eventHub : screen === null || screen === void 0 ? void 0 : screen.events;
if (navigationPrefix) {
this.getNavigationState = function () { return [{ name: navigationPrefix }, _this.createDefaultNavigationState()]; };
this.getNavigationStateLength = function () { return 2; };
this.getNavigationState = () => [{ name: navigationPrefix }, this.createDefaultNavigationState()];
this.getNavigationStateLength = () => 2;
}
}
Object.defineProperty(LifecycleScreenNavigatorBase.prototype, "navigationName", {
get: function () {
var _a, _b, _c, _d, _e;
return (_e = (_c = (_a = this._navigationNameValue) !== null && _a !== void 0 ? _a : (_b = this.getNavigationName) === null || _b === void 0 ? void 0 : _b.call(this)) !== null && _c !== void 0 ? _c : (_d = this.screen) === null || _d === void 0 ? void 0 : _d.constructor.name) !== null && _e !== void 0 ? _e : "unknown";
},
set: function (value) {
this._navigationNameValue = value || undefined;
},
enumerable: false,
configurable: true
});
Object.defineProperty(LifecycleScreenNavigatorBase.prototype, "screen", {
get: function () {
return this.screenValue;
},
enumerable: false,
configurable: true
});
LifecycleScreenNavigatorBase.prototype.canNavigate = function (path) {
get navigationName() {
var _a, _b, _c, _d, _e;
return (_e = (_c = (_a = this._navigationNameValue) !== null && _a !== void 0 ? _a : (_b = this.getNavigationName) === null || _b === void 0 ? void 0 : _b.call(this)) !== null && _c !== void 0 ? _c : (_d = this.screen) === null || _d === void 0 ? void 0 : _d.constructor.name) !== null && _e !== void 0 ? _e : "unknown";
}
set navigationName(value) {
this._navigationNameValue = value || undefined;
}
get screen() {
return this.screenValue;
}
canNavigate(path) {
var _a;
var context = {
const context = {
navigator: this,
screen: this.screen,
navigationParams: (_a = path[0]) === null || _a === void 0 ? void 0 : _a.params,
path: path,
path,
};
return this.aggregateBooleanAll("canNavigate", context);
};
LifecycleScreenNavigatorBase.prototype.createDefaultNavigationState = function () {
}
createDefaultNavigationState() {
var _a;

@@ -138,268 +66,155 @@ return {

};
};
LifecycleScreenNavigatorBase.prototype.getPrimaryChild = function () {
}
getPrimaryChild() {
return undefined;
};
LifecycleScreenNavigatorBase.prototype.navigate = function (path) {
}
navigate(path) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var context;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
context = {
navigator: this,
screen: this.screen,
navigationParams: (_a = path[0]) === null || _a === void 0 ? void 0 : _a.params,
path: path,
};
if (!!this.isInitialized) return [3, 2];
return [4, this.initialize(context)];
case 1:
_b.sent();
_b.label = 2;
case 2:
if (!!this.isActive) return [3, 4];
return [4, this.activate(context)];
case 3:
_b.sent();
_b.label = 4;
case 4: return [4, this.callAll("onNavigate", context)];
case 5:
_b.sent();
return [2];
}
});
return __awaiter(this, void 0, void 0, function* () {
const context = {
navigator: this,
screen: this.screen,
navigationParams: (_a = path[0]) === null || _a === void 0 ? void 0 : _a.params,
path,
};
if (!this.isInitialized) {
yield this.initialize(context);
}
if (!this.isActive) {
yield this.activate(context);
}
yield this.callAll("onNavigate", context);
});
};
Object.defineProperty(LifecycleScreenNavigatorBase.prototype, "isInitialized", {
get: function () {
return this.isInitializedValue;
},
enumerable: false,
configurable: true
});
LifecycleScreenNavigatorBase.prototype.initialize = function (context) {
}
get isInitialized() {
return this.isInitializedValue;
}
initialize(context) {
var _a;
return ((_a = this.initializePromise) !== null && _a !== void 0 ? _a : (this.initializePromise = this.initializeInner(context).then(this.clearInitializePromise, this.clearInitializePromise)));
};
LifecycleScreenNavigatorBase.prototype.initializeInner = function (context) {
return __awaiter(this, void 0, void 0, function () {
var error_1;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4, this.callAll("onInitialize", context)];
case 1:
_a.sent();
(0, mobx_1.runInAction)(function () { return (_this.isInitializedValue = true); });
return [3, 3];
case 2:
error_1 = _a.sent();
console.error("Error while calling onInitialize", error_1);
return [3, 3];
case 3: return [2];
}
});
}
initializeInner(context) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield this.callAll("onInitialize", context);
(0, mobx_1.runInAction)(() => (this.isInitializedValue = true));
}
catch (error) {
console.error("Error while calling onInitialize", error);
}
});
};
Object.defineProperty(LifecycleScreenNavigatorBase.prototype, "isActive", {
get: function () {
return this.isActiveValue;
},
enumerable: false,
configurable: true
});
LifecycleScreenNavigatorBase.prototype.activate = function (context) {
}
get isActive() {
return this.isActiveValue;
}
activate(context) {
var _a;
return ((_a = this.activatePromise) !== null && _a !== void 0 ? _a : (this.activatePromise = this.activateInner(context).then(this.clearActivatePromise, this.clearActivatePromise)));
};
LifecycleScreenNavigatorBase.prototype.activateInner = function (context) {
return __awaiter(this, void 0, void 0, function () {
var error_2;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4, this.callAll("onActivate", context)];
case 1:
_a.sent();
(0, mobx_1.runInAction)(function () { return (_this.isActiveValue = true); });
return [3, 3];
case 2:
error_2 = _a.sent();
console.error("Error while calling onActivate", error_2);
return [3, 3];
case 3: return [2];
}
});
}
activateInner(context) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield this.callAll("onActivate", context);
(0, mobx_1.runInAction)(() => (this.isActiveValue = true));
}
catch (error) {
console.error("Error while calling onActivate", error);
}
});
};
LifecycleScreenNavigatorBase.prototype.canDeactivate = function (isClosing) {
return __awaiter(this, void 0, void 0, function () {
var context;
return __generator(this, function (_a) {
context = {
navigator: this,
screen: this.screen,
isClosing: isClosing,
};
return [2, this.aggregateBooleanAll("canDeactivate", context)];
});
}
canDeactivate(isClosing) {
return __awaiter(this, void 0, void 0, function* () {
const context = {
navigator: this,
screen: this.screen,
isClosing,
};
return this.aggregateBooleanAll("canDeactivate", context);
});
};
LifecycleScreenNavigatorBase.prototype.deactivate = function (isClosing) {
}
deactivate(isClosing) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var context;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
context = {
navigator: this,
screen: this.screen,
isClosing: isClosing,
};
if (!this.isInitialized) return [3, 2];
return [4, ((_a = this.deactivatePromise) !== null && _a !== void 0 ? _a : (this.deactivatePromise = this.deactivateInner(context).then(this.clearDeactivatePromise, this.clearDeactivatePromise)))];
case 1:
_b.sent();
_b.label = 2;
case 2: return [2];
}
});
return __awaiter(this, void 0, void 0, function* () {
const context = {
navigator: this,
screen: this.screen,
isClosing,
};
if (this.isInitialized) {
yield ((_a = this.deactivatePromise) !== null && _a !== void 0 ? _a : (this.deactivatePromise = this.deactivateInner(context).then(this.clearDeactivatePromise, this.clearDeactivatePromise)));
}
});
};
LifecycleScreenNavigatorBase.prototype.deactivateInner = function (context) {
return __awaiter(this, void 0, void 0, function () {
var error_3;
var _this = this;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 5, , 6]);
if (!(this.isActive || context.isClosing)) return [3, 2];
return [4, this.callAll("onDeactivate", context)];
case 1:
_a.sent();
(0, mobx_1.runInAction)(function () { return (_this.isActiveValue = false); });
_a.label = 2;
case 2:
if (!(context.isClosing && this.isInitialized)) return [3, 4];
return [4, this.callAll("onDispose", context)];
case 3:
_a.sent();
_a.label = 4;
case 4: return [3, 6];
case 5:
error_3 = _a.sent();
console.error("Error while calling onDeactivate", error_3);
return [3, 6];
case 6: return [2];
}
deactivateInner(context) {
return __awaiter(this, void 0, void 0, function* () {
try {
if (this.isActive || context.isClosing) {
yield this.callAll("onDeactivate", context);
(0, mobx_1.runInAction)(() => (this.isActiveValue = false));
}
});
if (context.isClosing && this.isInitialized) {
yield this.callAll("onDispose", context);
}
}
catch (error) {
console.error("Error while calling onDeactivate", error);
}
});
};
LifecycleScreenNavigatorBase.prototype.aggregateBooleanAll = function (event, context) {
}
aggregateBooleanAll(event, context) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var screenFunction, result, listeners, listeners_1, listeners_1_1, listener, result, e_1_1;
var e_1, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
screenFunction = (_a = this.screen) === null || _a === void 0 ? void 0 : _a[event];
if (!(typeof screenFunction === "function")) return [3, 2];
return [4, screenFunction.call(this.screen, context)];
case 1:
result = _d.sent();
if (result === false) {
return [2, false];
}
_d.label = 2;
case 2:
listeners = (_b = this.eventHub) === null || _b === void 0 ? void 0 : _b.getListeners(event);
if (!listeners) return [3, 10];
_d.label = 3;
case 3:
_d.trys.push([3, 8, 9, 10]);
listeners_1 = __values(listeners), listeners_1_1 = listeners_1.next();
_d.label = 4;
case 4:
if (!!listeners_1_1.done) return [3, 7];
listener = listeners_1_1.value;
return [4, listener(context)];
case 5:
result = _d.sent();
if (result === false) {
return [2, false];
}
_d.label = 6;
case 6:
listeners_1_1 = listeners_1.next();
return [3, 4];
case 7: return [3, 10];
case 8:
e_1_1 = _d.sent();
e_1 = { error: e_1_1 };
return [3, 10];
case 9:
try {
if (listeners_1_1 && !listeners_1_1.done && (_c = listeners_1.return)) _c.call(listeners_1);
}
finally { if (e_1) throw e_1.error; }
return [7];
case 10: return [2, true];
return __awaiter(this, void 0, void 0, function* () {
const screenFunction = (_a = this.screen) === null || _a === void 0 ? void 0 : _a[event];
if (typeof screenFunction === "function") {
const result = yield screenFunction.call(this.screen, context);
if (result === false) {
return false;
}
});
}
const listeners = (_b = this.eventHub) === null || _b === void 0 ? void 0 : _b.getListeners(event);
if (listeners) {
for (const listener of listeners) {
const result = yield listener(context);
if (result === false) {
return false;
}
}
}
return true;
});
};
LifecycleScreenNavigatorBase.prototype.callAll = function (event, context) {
}
callAll(event, context) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var screenFunction, screenFunctionPromise, listeners;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
screenFunction = (_a = this.screen) === null || _a === void 0 ? void 0 : _a[event];
screenFunctionPromise = typeof screenFunction === "function" ? screenFunction.call(this.screen, context) : undefined;
listeners = (_b = this.eventHub) === null || _b === void 0 ? void 0 : _b.getListeners(event);
if (!(listeners === null || listeners === void 0 ? void 0 : listeners.length)) return [3, 2];
return [4, Promise.all(__spreadArray([screenFunctionPromise], __read(listeners.map(function (x) { return x(context); })), false))];
case 1:
_c.sent();
return [3, 4];
case 2: return [4, screenFunctionPromise];
case 3:
_c.sent();
_c.label = 4;
case 4: return [2];
}
});
return __awaiter(this, void 0, void 0, function* () {
const screenFunction = (_a = this.screen) === null || _a === void 0 ? void 0 : _a[event];
const screenFunctionPromise = typeof screenFunction === "function" ? screenFunction.call(this.screen, context) : undefined;
const listeners = (_b = this.eventHub) === null || _b === void 0 ? void 0 : _b.getListeners(event);
if (listeners === null || listeners === void 0 ? void 0 : listeners.length) {
yield Promise.all([screenFunctionPromise, ...listeners.map(x => x(context))]);
}
else {
yield screenFunctionPromise;
}
});
};
__decorate([
mobx_1.observable,
__metadata("design:type", Object)
], LifecycleScreenNavigatorBase.prototype, "isInitializedValue", void 0);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], LifecycleScreenNavigatorBase.prototype, "isInitialized", null);
__decorate([
mobx_1.observable,
__metadata("design:type", Object)
], LifecycleScreenNavigatorBase.prototype, "isActiveValue", void 0);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], LifecycleScreenNavigatorBase.prototype, "isActive", null);
return LifecycleScreenNavigatorBase;
}());
}
}
__decorate([
mobx_1.observable,
__metadata("design:type", Object)
], LifecycleScreenNavigatorBase.prototype, "isInitializedValue", void 0);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], LifecycleScreenNavigatorBase.prototype, "isInitialized", null);
__decorate([
mobx_1.observable,
__metadata("design:type", Object)
], LifecycleScreenNavigatorBase.prototype, "isActiveValue", void 0);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], LifecycleScreenNavigatorBase.prototype, "isActive", null);
exports.default = LifecycleScreenNavigatorBase;
//# sourceMappingURL=lifecycleScreenNavigatorBase.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -21,11 +6,9 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var lifecycleScreenNavigatorBase_1 = __importDefault(require("./lifecycleScreenNavigatorBase"));
var SimpleScreenNavigator = (function (_super) {
__extends(SimpleScreenNavigator, _super);
function SimpleScreenNavigator(screen, navigationPrefix, eventHub) {
return _super.call(this, screen, navigationPrefix, eventHub) || this;
const lifecycleScreenNavigatorBase_1 = __importDefault(require("./lifecycleScreenNavigatorBase"));
class SimpleScreenNavigator extends lifecycleScreenNavigatorBase_1.default {
constructor(screen, navigationPrefix, eventHub) {
super(screen, navigationPrefix, eventHub);
}
return SimpleScreenNavigator;
}(lifecycleScreenNavigatorBase_1.default));
}
exports.default = SimpleScreenNavigator;
//# sourceMappingURL=simpleScreenNavigator.js.map
"use strict";
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -18,40 +7,28 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.Route = void 0;
var route_parser_1 = __importDefault(require("route-parser"));
var Route = (function () {
function Route(name, path, aliasPaths) {
const route_parser_1 = __importDefault(require("route-parser"));
class Route {
constructor(name, path, aliasPaths) {
this.name = name;
this.path = new route_parser_1.default(path);
this.aliases = aliasPaths === null || aliasPaths === void 0 ? void 0 : aliasPaths.map(function (x) { return new route_parser_1.default(x); });
this.aliases = aliasPaths === null || aliasPaths === void 0 ? void 0 : aliasPaths.map(x => new route_parser_1.default(x));
}
Route.prototype.matchPath = function (path) {
var e_1, _a;
var _b;
if ((_b = this.aliases) === null || _b === void 0 ? void 0 : _b.length) {
try {
for (var _c = __values(this.aliases), _d = _c.next(); !_d.done; _d = _c.next()) {
var router = _d.value;
var match = router.match(path);
if (match) {
return match;
}
matchPath(path) {
var _a;
if ((_a = this.aliases) === null || _a === void 0 ? void 0 : _a.length) {
for (const router of this.aliases) {
const match = router.match(path);
if (match) {
return match;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}
finally { if (e_1) throw e_1.error; }
}
}
return this.path.match(path);
};
Route.prototype.getUrl = function (params) {
}
getUrl(params) {
var _a, _b;
var route = (_b = (_a = this.aliases) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : this.path;
const route = (_b = (_a = this.aliases) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : this.path;
return route.reverse(params);
};
return Route;
}());
}
}
exports.Route = Route;
//# sourceMappingURL=route.js.map
"use strict";
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
var RouterBase = (function () {
function RouterBase(rootNavigator) {
class RouterBase {
constructor(rootNavigator) {
this.rootNavigator = rootNavigator;
}
RouterBase.prototype.getCurrentScreen = function () {
var navigator = this.rootNavigator;
getCurrentScreen() {
let navigator = this.rootNavigator;
while (navigator) {
var childNavigator = navigator.getPrimaryChild();
const childNavigator = navigator.getPrimaryChild();
if (childNavigator) {

@@ -43,32 +18,31 @@ navigator = childNavigator;

}
};
RouterBase.prototype.getCurrentPath = function () {
var path = [];
var navigator = this.rootNavigator;
}
getCurrentPath() {
const path = [];
let navigator = this.rootNavigator;
while (navigator) {
path.push.apply(path, __spreadArray([], __read(navigator.getNavigationState()), false));
path.push(...navigator.getNavigationState());
navigator = navigator.getPrimaryChild();
}
return path;
};
RouterBase.prototype.getPathForChild = function (parent, child) {
var path = [];
var childPath = child === null || child === void 0 ? void 0 : child.getNavigationState();
}
getPathForChild(parent, child) {
const path = [];
const childPath = child === null || child === void 0 ? void 0 : child.getNavigationState();
if (childPath) {
path.push.apply(path, __spreadArray([], __read(childPath), false));
path.push(...childPath);
}
var navigator = parent;
let navigator = parent;
while (navigator) {
path.unshift.apply(path, __spreadArray([], __read(navigator.getNavigationState()), false));
path.unshift(...navigator.getNavigationState());
navigator = navigator.parent;
}
return path;
};
RouterBase.prototype.cloneWithChildPath = function (path, child) {
var childPath = child === null || child === void 0 ? void 0 : child.getNavigationState();
return childPath ? __spreadArray(__spreadArray([], __read(path), false), __read(childPath), false) : path;
};
return RouterBase;
}());
}
cloneWithChildPath(path, child) {
const childPath = child === null || child === void 0 ? void 0 : child.getNavigationState();
return childPath ? [...path, ...childPath] : path;
}
}
exports.default = RouterBase;
//# sourceMappingURL=routerBase.js.map
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -26,56 +11,2 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -85,101 +16,59 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var route_1 = require("./route");
var routerBase_1 = __importDefault(require("./routerBase"));
var URL_SEPARATOR = "/";
var SEGMENT_REGEX = /^(?<name>[\w-]+)(\[(?<params>\S+)\])?$/;
var UrlRouterBase = (function (_super) {
__extends(UrlRouterBase, _super);
function UrlRouterBase() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.routes = new Map();
return _this;
const route_1 = require("./route");
const routerBase_1 = __importDefault(require("./routerBase"));
const URL_SEPARATOR = "/";
const SEGMENT_REGEX = /^(?<name>[\w-]+)(\[(?<params>\S+)\])?$/;
class UrlRouterBase extends routerBase_1.default {
constructor() {
super(...arguments);
this.routes = new Map();
}
UrlRouterBase.prototype.initialize = function () {
initialize() {
return this.updateUrl();
};
UrlRouterBase.prototype.updateUrl = function () {
return __awaiter(this, void 0, void 0, function () {
var path, url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
path = this.getCurrentPath();
if (!path.length) return [3, 2];
url = this.serializePath(path);
return [4, this.persistUrl(url)];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2];
}
});
}
updateUrl() {
return __awaiter(this, void 0, void 0, function* () {
const path = this.getCurrentPath();
if (path.length) {
const url = this.serializePath(path);
yield this.persistUrl(url);
}
});
};
UrlRouterBase.prototype.registerRoute = function (definition) {
var e_1, _a;
var names = Array.isArray(definition.name) ? definition.name : [definition.name];
try {
for (var names_1 = __values(names), names_1_1 = names_1.next(); !names_1_1.done; names_1_1 = names_1.next()) {
var name_1 = names_1_1.value;
this.routes.set(name_1, new route_1.Route(name_1, definition.path, definition.aliasPaths));
}
}
registerRoute(definition) {
const names = Array.isArray(definition.name) ? definition.name : [definition.name];
for (const name of names) {
this.routes.set(name, new route_1.Route(name, definition.path, definition.aliasPaths));
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (names_1_1 && !names_1_1.done && (_a = names_1.return)) _a.call(names_1);
}
finally { if (e_1) throw e_1.error; }
}
};
UrlRouterBase.prototype.navigate = function (path) {
}
navigate(path) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var elements, currentPath, currentUrl;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
elements = typeof path === "string" ? this.deserializePath(path) : path;
return [4, ((_a = this.rootNavigator) === null || _a === void 0 ? void 0 : _a.navigate(elements))];
case 1:
_b.sent();
currentPath = this.getCurrentPath();
currentUrl = this.serializePath(currentPath);
return [4, this.persistUrl(currentUrl)];
case 2:
_b.sent();
return [2];
}
});
return __awaiter(this, void 0, void 0, function* () {
const elements = typeof path === "string" ? this.deserializePath(path) : path;
yield ((_a = this.rootNavigator) === null || _a === void 0 ? void 0 : _a.navigate(elements));
const currentPath = this.getCurrentPath();
const currentUrl = this.serializePath(currentPath);
yield this.persistUrl(currentUrl);
});
};
UrlRouterBase.prototype.navigateToScreen = function (screen) {
var path = this.getPathForChild(screen.navigator, undefined);
}
navigateToScreen(screen) {
const path = this.getPathForChild(screen.navigator, undefined);
return this.navigate(path);
};
UrlRouterBase.prototype.navigateToParent = function (child) {
return __awaiter(this, void 0, void 0, function () {
var parentNavigator, path;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
parentNavigator = child.navigator.parent;
if (!parentNavigator) return [3, 2];
path = this.getPathForChild(parentNavigator, undefined);
return [4, this.navigate(path)];
case 1:
_a.sent();
_a.label = 2;
case 2: return [2];
}
});
}
navigateToParent(child) {
return __awaiter(this, void 0, void 0, function* () {
const parentNavigator = child.navigator.parent;
if (parentNavigator) {
const path = this.getPathForChild(parentNavigator, undefined);
yield this.navigate(path);
}
});
};
UrlRouterBase.prototype.navigateToChild = function (parent, child) {
var path = this.getPathForChild(parent.navigator, child.navigator);
}
navigateToChild(parent, child) {
const path = this.getPathForChild(parent.navigator, child.navigator);
return this.navigate(path);
};
UrlRouterBase.prototype.navigateToRoute = function (routeName, params) {
}
navigateToRoute(routeName, params) {
var _a;
var path = (_a = this.routes.get(routeName)) === null || _a === void 0 ? void 0 : _a.getUrl(params);
const path = (_a = this.routes.get(routeName)) === null || _a === void 0 ? void 0 : _a.getUrl(params);
if (path) {

@@ -190,11 +79,11 @@ return this.navigate(path);

return Promise.resolve();
};
UrlRouterBase.prototype.getUrlForScreen = function (screen) {
var path = this.getPathForChild(screen.navigator, undefined);
}
getUrlForScreen(screen) {
const path = this.getPathForChild(screen.navigator, undefined);
return this.serializePath(path);
};
UrlRouterBase.prototype.getUrlForParent = function (child) {
var parentNavigator = child.navigator.parent;
}
getUrlForParent(child) {
const parentNavigator = child.navigator.parent;
if (parentNavigator) {
var path = this.getPathForChild(parentNavigator, undefined);
const path = this.getPathForChild(parentNavigator, undefined);
return this.serializePath(path);

@@ -205,17 +94,16 @@ }

}
};
UrlRouterBase.prototype.getUrlForChild = function (parent, child) {
var path = this.getPathForChild(parent.navigator, child.navigator);
}
getUrlForChild(parent, child) {
const path = this.getPathForChild(parent.navigator, child.navigator);
return this.serializePath(path);
};
UrlRouterBase.prototype.getUrlFactoryForChild = function (parent) {
var _this = this;
var rootPath = this.getPathForChild(parent.navigator, undefined);
return function (child) {
var path = _this.cloneWithChildPath(rootPath, child.navigator);
return _this.serializePath(path);
}
getUrlFactoryForChild(parent) {
const rootPath = this.getPathForChild(parent.navigator, undefined);
return (child) => {
const path = this.cloneWithChildPath(rootPath, child.navigator);
return this.serializePath(path);
};
};
UrlRouterBase.prototype.getUrlForRoute = function (routeName, params) {
var route = this.routes.get(routeName);
}
getUrlForRoute(routeName, params) {
const route = this.routes.get(routeName);
if (route) {

@@ -225,19 +113,12 @@ return route.getUrl(params);

return false;
};
UrlRouterBase.prototype.serializePath = function (pathElements) {
var _this = this;
return URL_SEPARATOR + pathElements.map(function (x) { return _this.serializePathElement(x); }).join(URL_SEPARATOR);
};
UrlRouterBase.prototype.serializePathElement = function (element) {
}
serializePath(pathElements) {
return URL_SEPARATOR + pathElements.map(x => this.serializePathElement(x)).join(URL_SEPARATOR);
}
serializePathElement(element) {
if (element.params) {
var values = Object.entries(element.params)
.filter(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
return value !== undefined;
})
.map(function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
return key + "=" + encodeURIComponent(value);
});
return element.name + "[" + values.join(",") + "]";
const values = Object.entries(element.params)
.filter(([key, value]) => value !== undefined)
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`);
return `${element.name}[${values.join(",")}]`;
}

@@ -247,19 +128,18 @@ else {

}
};
UrlRouterBase.prototype.deserializePath = function (path) {
var _this = this;
}
deserializePath(path) {
return path
.split(URL_SEPARATOR)
.filter(function (x) { return x; })
.map(function (x) { var _a; return (_a = _this.deserializePathSegment(x)) !== null && _a !== void 0 ? _a : { name: "parse-error" }; });
};
UrlRouterBase.prototype.deserializePathSegment = function (text) {
.filter(x => x)
.map(x => { var _a; return (_a = this.deserializePathSegment(x)) !== null && _a !== void 0 ? _a : { name: "parse-error" }; });
}
deserializePathSegment(text) {
var _a;
var match = (_a = SEGMENT_REGEX.exec(text)) === null || _a === void 0 ? void 0 : _a.groups;
const match = (_a = SEGMENT_REGEX.exec(text)) === null || _a === void 0 ? void 0 : _a.groups;
if (!match) {
return undefined;
}
var paramsObject = undefined;
let paramsObject = undefined;
if (match.params) {
var pairs = match.params.split(",").map(function (x) { return decodeURIComponent(x).split("=", 2); });
const pairs = match.params.split(",").map(x => decodeURIComponent(x).split("=", 2));
paramsObject = Object.fromEntries(pairs);

@@ -271,6 +151,5 @@ }

};
};
return UrlRouterBase;
}(routerBase_1.default));
}
}
exports.default = UrlRouterBase;
//# sourceMappingURL=urlRouterBase.js.map

@@ -7,9 +7,8 @@ "use strict";

exports.getNavigator = void 0;
var typedEventHub_1 = __importDefault(require("../events/typedEventHub"));
var ScreenBase = (function () {
function ScreenBase() {
const typedEventHub_1 = __importDefault(require("../events/typedEventHub"));
class ScreenBase {
constructor() {
this.events = new typedEventHub_1.default();
}
return ScreenBase;
}());
}
exports.default = ScreenBase;

@@ -16,0 +15,0 @@ function getNavigator(target) {

@@ -6,3 +6,3 @@ {

},
"version": "1.0.0-alpha.8",
"version": "1.0.0-alpha.9",
"description": "Frui.ts core classes for application structure and navigation",

@@ -39,3 +39,3 @@ "keywords": [

"dependencies": {
"@frui.ts/helpers": "^1.0.0-alpha.8",
"@frui.ts/helpers": "^1.0.0-alpha.9",
"route-parser": "^0.0.5"

@@ -50,3 +50,3 @@ },

},
"gitHead": "e774efd68e7bd49b83461fdcae0d110c2b69da90"
"gitHead": "718298c96617555dd2121f87a2dfefb3ea16d039"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc