UNPKG

@adpt/core

Version:
69 lines 2.43 kB
"use strict"; /* * Copyright 2018-2019 Unbounded Systems, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); function buildPrinter() { let depth = 0; let buildPass = 0; function el(elem) { return elem ? elem.displayName : "null"; } function i() { return " ".repeat(depth * 2); } return function _buildPrinter(op) { if (op.type === "start") buildPass = op.buildPass; let msg = `BUILD ${buildPass} [${op.type}]: `; msg += " ".repeat(13 - op.type.length); switch (op.type) { case "start": depth = 0; msg += i() + `root: ${el(op.root)}`; break; case "step": msg += i() + `${el(op.oldElem)} => ${el(op.newElem)}` + ` style: ${op.style ? op.style.selector : "none"}`; break; case "elementBuilt": msg += i() + `${el(op.oldElem)} => ${el(op.newElem)}`; break; case "descend": msg += i() + `${el(op.descendFrom)}.${el(op.descendTo)}`; depth++; break; case "ascend": depth--; msg += i() + `${el(op.ascendTo)} <= ${el(op.ascendFrom)}`; break; case "defer": case "buildDeferred": case "elementDone": msg += i() + `${el(op.elem)}`; break; case "done": msg += i() + `root: ${el(op.root)}`; break; case "error": msg += i() + op.error.toString(); break; } // tslint:disable-next-line:no-console console.log(msg); }; } exports.buildPrinter = buildPrinter; //# sourceMappingURL=dom_build_data_recorder.js.map