vasille-jsx
Version:
The same framework which is designed to build bulletproof frontends (JSX components)
112 lines (111 loc) • 3.13 kB
JavaScript
export class AbstractInspector {
addContextState(state) {
this.send(this.addContextState.name, state);
}
composeTime(time) {
this.send(this.composeTime.name, time);
}
createComponent(comp) {
this.send(this.createComponent.name, comp);
}
createCustomModel(model) {
this.send(this.createCustomModel.name, model);
}
createModel(model) {
this.send(this.createModel.name, model);
}
createNode(node) {
this.send(this.createNode.name, node);
}
createStore(store) {
this.send(this.createStore.name, store);
}
createTag(tag) {
this.send(this.createTag.name, tag);
}
destroy(data) {
this.send(this.destroy.name, data);
}
eventTrigger(call) {
this.send(this.eventTrigger.name, call);
}
functionCall(call) {
this.send(this.functionCall.name, call);
}
functionReturn(result) {
this.send(this.functionReturn.name, result);
}
functionThrows(error) {
this.send(this.functionThrows.name, error);
}
newExpression(expr) {
this.send(this.newExpression.name, expr);
}
newReference(ref) {
this.send(this.newReference.name, ref);
}
registerExecutionPosition(pos) {
this.send(this.registerExecutionPosition.name, pos);
}
registeredRoutes(routes) {
this.send(this.registeredRoutes.name, routes);
}
reportComponentError(error) {
this.send(this.reportComponentError.name, error);
}
reportComponentSlotError(error) {
this.send(this.reportComponentSlotError.name, error);
}
reportError(err) {
this.send(this.reportError.name, err);
}
reportExpressionCalculationError(error) {
this.send(this.reportExpressionCalculationError.name, error);
}
reportReferenceError(error) {
this.send(this.reportReferenceError.name, error);
}
routerActionCall(call) {
this.send(this.routerActionCall.name, call);
}
routerStateChange(change) {
this.send(this.routerStateChange.name, change);
}
routerTargetResult(data) {
this.send(this.routerTargetResult.name, data);
}
setElementParent(parent) {
this.send(this.setElementParent.name, parent);
}
updateExpression(update) {
this.send(this.updateExpression.name, update);
}
updateModel(update) {
this.send(this.updateModel.name, update);
}
updateReference(update) {
this.send(this.updateReference.name, update);
}
}
export class EarlyInspector extends AbstractInspector {
constructor() {
super(...arguments);
this.queue = [];
}
connect(inspector) {
this.inspector = inspector;
for (const item of this.queue) {
inspector[item[0]](item[1]);
}
this.queue = [];
}
send(name, data) {
if (this.inspector) {
this.inspector[name](data);
}
else {
this.queue.push([name, data]);
}
}
}
export const earlyInspector = new EarlyInspector();