UNPKG

tandem-front-end

Version:

Visual editor for web components

1,315 lines (1,256 loc) 6.95 MB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else { var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(window, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ /******/ ({ /***/ "../common/index.js": /*!**************************!*\ !*** ../common/index.js ***! \**************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(/*! ./lib */ "../common/lib/index.js"); /***/ }), /***/ "../common/lib/index.js": /*!******************************!*\ !*** ../common/lib/index.js ***! \******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); __export(__webpack_require__(/*! ./redux */ "../common/lib/redux/index.js")); __export(__webpack_require__(/*! ./state */ "../common/lib/state/index.js")); __export(__webpack_require__(/*! ./utils */ "../common/lib/utils/index.js")); //# sourceMappingURL=index.js.map /***/ }), /***/ "../common/lib/redux/actions.js": /*!**************************************!*\ !*** ../common/lib/redux/actions.js ***! \**************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isPublicAction = function (action) { return action["@@public"] === true; }; exports.publicActionCreator = function (createAction) { return (function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var action = createAction.apply(void 0, args); action["@@public"] = true; return action; }); }; //# sourceMappingURL=actions.js.map /***/ }), /***/ "../common/lib/redux/index.js": /*!************************************!*\ !*** ../common/lib/redux/index.js ***! \************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); __export(__webpack_require__(/*! ./actions */ "../common/lib/redux/actions.js")); //# sourceMappingURL=index.js.map /***/ }), /***/ "../common/lib/state/file.js": /*!***********************************!*\ !*** ../common/lib/state/file.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var tree_1 = __webpack_require__(/*! ./tree */ "../common/lib/state/tree.js"); var memoization_1 = __webpack_require__(/*! ../utils/memoization */ "../common/lib/utils/memoization.js"); var path = __webpack_require__(/*! path */ "./node_modules/path-browserify/index.js"); var uid_1 = __webpack_require__(/*! ../utils/uid */ "../common/lib/utils/uid.js"); var lodash_1 = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"); var protocol_1 = __webpack_require__(/*! ../utils/protocol */ "../common/lib/utils/protocol.js"); var __1 = __webpack_require__(/*! .. */ "../common/lib/index.js"); var FSItemNamespaces; (function (FSItemNamespaces) { FSItemNamespaces["CORE"] = "core"; })(FSItemNamespaces = exports.FSItemNamespaces || (exports.FSItemNamespaces = {})); var FSItemTagNames; (function (FSItemTagNames) { FSItemTagNames["FILE"] = "file"; FSItemTagNames["DIRECTORY"] = "directory"; })(FSItemTagNames = exports.FSItemTagNames || (exports.FSItemTagNames = {})); var FileAttributeNames; (function (FileAttributeNames) { FileAttributeNames["URI"] = "uri"; FileAttributeNames["EXPANDED"] = "expanded"; FileAttributeNames["BASENAME"] = "basename"; FileAttributeNames["SELECTED"] = "selected"; })(FileAttributeNames = exports.FileAttributeNames || (exports.FileAttributeNames = {})); exports.isFile = function (node) { return node.name === FSItemTagNames.FILE; }; exports.isDirectory = function (node) { return node.name === FSItemTagNames.DIRECTORY; }; exports.createFile = function (uri) { return ({ id: uid_1.generateUID(), name: FSItemTagNames.FILE, uri: uri, children: [] }); }; exports.createDirectory = function (uri, children, expanded) { if (children === void 0) { children = []; } return ({ id: uid_1.generateUID(), name: FSItemTagNames.DIRECTORY, expanded: expanded, uri: uri, children: children || [] }); }; var getFileName = function (current) { return path.basename(current.uri); }; exports.getFilePath = memoization_1.memoize(function (file, directory) { var childParentMap = tree_1.getChildParentMap(directory); var path = []; var current = file; while (current) { path.unshift(getFileName(current)); current = childParentMap[current.id]; } return path.join("/"); }); exports.getFilePathFromNodePath = function (path, directory) { return exports.getFilePath(tree_1.getTreeNodeFromPath(path, directory), directory); }; exports.getFileFromUri = function (uri, root) { return tree_1.findNestedNode(root, function (child) { return child.uri === uri; }); }; exports.getFilesWithExtension = memoization_1.memoize(function (extension, directory) { var tester = new RegExp(extension + "$"); return tree_1.filterNestedNodes(directory, function (file) { return exports.isFile(file) && tester.test(getFileName(file)); }); }); exports.convertFlatFilesToNested = function (files) { var splitParts = files.map(function (_a) { var filePath = _a[0], isDirectory = _a[1]; return [filePath.split(/[\\/]/), isDirectory]; }); var sortedFiles = splitParts .sort(function (a, b) { var ap = a[0], aid = a[1]; var bp = b[0], bid = b[1]; if (ap.length > bp.length) { return -1; } else if (ap.length < bp.length) { return 1; } // same length, just check if it's a directory return aid ? 1 : -1; }) .map(function (_a) { var parts = _a[0], isDirectory = _a[1]; return [parts.join("/"), isDirectory]; }); var pool = {}; var highest; var highestDirname; for (var _i = 0, sortedFiles_1 = sortedFiles; _i < sortedFiles_1.length; _i++) { var _a = sortedFiles_1[_i], filePath = _a[0], isDirectory_1 = _a[1]; var uri = protocol_1.addProtocol(protocol_1.FILE_PROTOCOL, filePath); if (isDirectory_1) { highest = exports.createDirectory(uri, exports.sortFSItems(pool[uri] || __1.EMPTY_ARRAY)); } else { highest = exports.createFile(uri); } highestDirname = path.dirname(uri); if (!pool[highestDirname]) { pool[highestDirname] = []; } pool[highestDirname].push(highest); } return exports.sortFSItems(pool[highestDirname]); }; exports.convertFlatFilesToNested2 = function (items) { var splitParts = items.map(function (item) { return [ protocol_1.stripProtocol(item.uri).split(/[\\/]/), item.name === FSItemTagNames.DIRECTORY, item ]; }); var sortedFiles = splitParts .sort(function (a, b) { var ap = a[0], aid = a[1]; var bp = b[0], bid = b[1]; if (ap.length > bp.length) { return -1; } else if (ap.length < bp.length) { return 1; } // same length, just check if it's a directory return aid ? 1 : -1; }) .map(function (_a) { var parts = _a[0], isDirectory = _a[1]; return [parts.join("/"), isDirectory]; }); var pool = {}; var highest; var highestDirname; for (var _i = 0, sortedFiles_2 = sortedFiles; _i < sortedFiles_2.length; _i++) { var _a = sortedFiles_2[_i], filePath = _a[0], isDirectory_2 = _a[1]; var uri = protocol_1.addProtocol(protocol_1.FILE_PROTOCOL, filePath); if (isDirectory_2) { highest = exports.createDirectory(uri, exports.sortFSItems(pool[uri] || __1.EMPTY_ARRAY)); } else { highest = exports.createFile(uri); } highestDirname = path.dirname(uri); if (!pool[highestDirname]) { pool[highestDirname] = []; } pool[highestDirname].push(highest); } var highestPool = pool[highestDirname]; return exports.updateFSItemAlts(highestPool.length === 1 && highestPool[0].name === FSItemTagNames.DIRECTORY ? highestPool[0] : exports.createDirectory(highestDirname, exports.sortFSItems(highestPool), true)); }; exports.mergeFSItems = function () { var items = []; for (var _i = 0; _i < arguments.length; _i++) { items[_i] = arguments[_i]; } var flattenedItems = lodash_1.uniqBy(items.reduce(function (allItems, item) { return allItems.concat(tree_1.flattenTreeNode(item)); }, __1.EMPTY_ARRAY), function (item) { return item.uri; }); var itemMap = {}; for (var _a = 0, flattenedItems_1 = flattenedItems; _a < flattenedItems_1.length; _a++) { var item = flattenedItems_1[_a]; itemMap[item.uri] = item; } var mapTree = function (node) { var existing = itemMap[node.uri]; if (!existing) { return node; } if (node.name === FSItemTagNames.DIRECTORY) { return __assign({}, node, existing, { children: node.children.map(mapTree) }); } else { return existing; } }; return exports.updateFSItemAlts(mapTree(exports.convertFlatFilesToNested2(flattenedItems))); }; exports.updateFSItemAlts = function (root) { var flattened = tree_1.flattenTreeNode(root).filter(function (node) { return tree_1.getParentTreeNode(node.id, root) && tree_1.getParentTreeNode(node.id, root).expanded; }); var map = function (node) { var alt = flattened.indexOf(node) % 2 !== 0; var children = node.children; if (node.expanded) { children = node.children.map(map); } if (node.alt !== alt || node.children !== children) { return __assign({}, node, { alt: alt, children: children }); } return node; }; return map(root); }; exports.sortFSItems = function (files) { return files.slice().sort(function (a, b) { return a.name === FSItemTagNames.FILE && b.name === FSItemTagNames.DIRECTORY ? 1 : a.name === FSItemTagNames.DIRECTORY && b.name === FSItemTagNames.FILE ? -1 : a.uri < b.uri ? -1 : 1; }); }; //# sourceMappingURL=file.js.map /***/ }), /***/ "../common/lib/state/geom.js": /*!***********************************!*\ !*** ../common/lib/state/geom.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); // import { getV } from "../struct"; var memoization_1 = __webpack_require__(/*! ../utils/memoization */ "../common/lib/utils/memoization.js"); exports.createBounds = function (left, right, top, bottom) { return ({ left: left, right: right, top: top, bottom: bottom }); }; exports.moveBounds = function (bounds, _a) { var left = _a.left, top = _a.top; return (__assign({}, bounds, { left: left, top: top, right: left + bounds.right - bounds.left, bottom: top + bounds.bottom - bounds.top })); }; exports.mapBounds = function (bounds, map) { return (__assign({}, bounds, { left: map(bounds.left, "left"), right: map(bounds.right, "right"), top: map(bounds.top, "top"), bottom: map(bounds.bottom, "bottom") })); }; exports.roundBounds = function (bounds) { return exports.mapBounds(bounds, function (v) { return Math.round(v); }); }; exports.createZeroBounds = function () { return exports.createBounds(0, 0, 0, 0); }; exports.shiftPoint = function (point, delta) { return ({ left: point.left + delta.left, top: point.top + delta.top }); }; exports.shiftBounds = function (bounds, _a) { var left = _a.left, top = _a.top; return (__assign({}, bounds, { left: bounds.left + left, top: bounds.top + top, right: bounds.right + left, bottom: bounds.bottom + top })); }; exports.resizeBounds = function (bounds, _a) { var width = _a.width, height = _a.height; return (__assign({}, bounds, { left: bounds.left, top: bounds.top, right: bounds.left + width, bottom: bounds.top + height })); }; exports.flipPoint = function (point) { return ({ left: -point.left, top: -point.top }); }; exports.pointToBounds = function (point) { return ({ left: point.left, top: point.top, right: point.left, bottom: point.top }); }; exports.keepBoundsAspectRatio = function (newBounds, oldBounds, anchor, centerPoint) { if (centerPoint === void 0) { centerPoint = anchor; } var newBoundsSize = exports.getBoundsSize(newBounds); var oldBoundsSize = exports.getBoundsSize(oldBounds); var left = newBounds.left; var top = newBounds.top; var width = newBoundsSize.width; var height = newBoundsSize.height; if (anchor.top === 0 || anchor.top === 1) { var perc = height / oldBoundsSize.height; width = oldBoundsSize.width * perc; left = oldBounds.left + (oldBoundsSize.width - width) * (1 - centerPoint.left); } else if (anchor.top === 0.5) { var perc = width / oldBoundsSize.width; height = oldBoundsSize.height * perc; top = oldBounds.top + (oldBoundsSize.height - height) * (1 - centerPoint.top); } return { left: left, top: top, right: left + width, bottom: top + height }; }; exports.keepBoundsCenter = function (newBounds, oldBounds, anchor) { var newBoundsSize = exports.getBoundsSize(newBounds); var oldBoundsSize = exports.getBoundsSize(oldBounds); var left = oldBounds.left; var top = oldBounds.top; var width = oldBoundsSize.width; var height = oldBoundsSize.height; var delta = { left: newBounds.left - oldBounds.left, top: newBounds.top - oldBounds.top }; if (anchor.top === 0) { top += delta.top; height += delta.top; height = oldBounds.top - newBounds.top; } if (anchor.top === 1) { var hdiff = oldBoundsSize.height - newBoundsSize.height; top += hdiff; height -= hdiff; } if (anchor.left === 0) { left += delta.left; top += delta.top; width += oldBounds.left - newBounds.left; } if (anchor.left === 1) { width += delta.left; var wdiff = oldBoundsSize.width - newBoundsSize.width; left += wdiff; width -= wdiff; } return { left: left, top: top, right: left + width, bottom: top + height }; }; exports.zoomBounds = function (bounds, zoom) { return (__assign({}, bounds, { left: bounds.left * zoom, top: bounds.top * zoom, right: bounds.right * zoom, bottom: bounds.bottom * zoom })); }; exports.zoomPoint = function (point, zoom) { return (__assign({}, point, { left: point.left * zoom, top: point.top * zoom })); }; exports.boundsFromRect = function (_a) { var width = _a.width, height = _a.height; return ({ left: 0, top: 0, right: width, bottom: height }); }; exports.getBoundsWidth = function (bounds) { return bounds.right - bounds.left; }; exports.getBoundsHeight = function (bounds) { return bounds.bottom - bounds.top; }; exports.getBoundsSize = memoization_1.memoize(function (bounds) { return ({ width: exports.getBoundsWidth(bounds), height: exports.getBoundsHeight(bounds) }); }); exports.getBoundsPoint = memoization_1.memoize(function (bounds) { return ({ left: bounds.left, top: bounds.top }); }); exports.scaleInnerBounds = function (inner, oldBounds, newBounds) { var oldBoundsSize = exports.getBoundsSize(oldBounds); var newBoundsSize = exports.getBoundsSize(newBounds); var innerBoundsSize = exports.getBoundsSize(inner); var percLeft = (inner.left - oldBounds.left) / oldBoundsSize.width; var percTop = (inner.top - oldBounds.top) / oldBoundsSize.height; var percWidth = innerBoundsSize.width / oldBoundsSize.width; var percHeight = innerBoundsSize.height / oldBoundsSize.height; var left = newBounds.left + newBoundsSize.width * percLeft; var top = newBounds.top + newBoundsSize.height * percTop; var right = left + newBoundsSize.width * percWidth; var bottom = top + newBoundsSize.height * percHeight; return { left: left, top: top, right: right, bottom: bottom }; }; exports.isBounds = function (bounds) { return bounds && bounds.left != null && bounds.top != null && bounds.right != null && bounds.bottom != null; }; exports.filterBounded = function (values) { return values.filter(function (value) { return exports.isBounds(value.bounds); }); }; exports.mergeBounds = function () { var allBounds = []; for (var _i = 0; _i < arguments.length; _i++) { allBounds[_i] = arguments[_i]; } var left = Infinity; var bottom = -Infinity; var top = Infinity; var right = -Infinity; for (var _a = 0, allBounds_1 = allBounds; _a < allBounds_1.length; _a++) { var bounds = allBounds_1[_a]; left = Math.min(left, bounds.left); right = Math.max(right, bounds.right); top = Math.min(top, bounds.top); bottom = Math.max(bottom, bounds.bottom); } return exports.createBounds(left, right, top, bottom); }; exports.centerTransformZoom = function (translate, bounds, nz, point) { var oz = translate.zoom; var zd = nz / oz; var v1w = bounds.right - bounds.left; var v1h = bounds.bottom - bounds.top; // center is based on the mouse position var v1px = point ? point.left / v1w : 0.5; var v1py = point ? point.top / v1h : 0.5; // calculate v1 center x & y var v1cx = v1w * v1px; var v1cy = v1h * v1py; // old screen width & height var v2ow = v1w * oz; var v2oh = v1h * oz; // old offset pane left var v2ox = translate.left; var v2oy = translate.top; // new width of view 2 var v2nw = v1w * nz; var v2nh = v1h * nz; // get the offset px & py of view 2 var v2px = (v1cx - v2ox) / v2ow; var v2py = (v1cy - v2oy) / v2oh; var left = v1w * v1px - v2nw * v2px; var top = v1h * v1py - v2nh * v2py; return { left: left, top: top, zoom: nz }; }; exports.boundsIntersect = function (a, b) { return !(a.left > b.right || a.right < b.left || a.top > b.bottom || a.bottom < a.top); }; exports.pointIntersectsBounds = function (point, bounds) { return !(point.left < bounds.left || point.left > bounds.right || point.top < bounds.top || point.top > bounds.bottom); }; exports.getSmallestBounds = function () { var bounds = []; for (var _i = 0; _i < arguments.length; _i++) { bounds[_i] = arguments[_i]; } return bounds.reduce(function (a, b) { var asize = exports.getBoundsSize(a); var bsize = exports.getBoundsSize(b); return asize.width * asize.height < bsize.width * bsize.height ? a : b; }, { left: Infinity, right: Infinity, top: Infinity, bottom: Infinity }); }; //# sourceMappingURL=geom.js.map /***/ }), /***/ "../common/lib/state/index.js": /*!************************************!*\ !*** ../common/lib/state/index.js ***! \************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); __export(__webpack_require__(/*! ./file */ "../common/lib/state/file.js")); __export(__webpack_require__(/*! ./tree */ "../common/lib/state/tree.js")); __export(__webpack_require__(/*! ./geom */ "../common/lib/state/geom.js")); //# sourceMappingURL=index.js.map /***/ }), /***/ "../common/lib/state/tree.js": /*!***********************************!*\ !*** ../common/lib/state/tree.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var memoization_1 = __webpack_require__(/*! ../utils/memoization */ "../common/lib/utils/memoization.js"); var crc32 = __webpack_require__(/*! crc32 */ "./node_modules/crc32/lib/crc32.js"); var array_1 = __webpack_require__(/*! ../utils/array */ "../common/lib/utils/array/index.js"); var uid_1 = __webpack_require__(/*! ../utils/uid */ "../common/lib/utils/uid.js"); var uid_2 = __webpack_require__(/*! ../utils/uid */ "../common/lib/utils/uid.js"); var object_1 = __webpack_require__(/*! ../utils/object */ "../common/lib/utils/object.js"); var TreeMoveOffset; (function (TreeMoveOffset) { TreeMoveOffset[TreeMoveOffset["PREPEND"] = 0] = "PREPEND"; TreeMoveOffset[TreeMoveOffset["APPEND"] = Number.MAX_SAFE_INTEGER] = "APPEND"; TreeMoveOffset[TreeMoveOffset["BEFORE"] = -1] = "BEFORE"; TreeMoveOffset[TreeMoveOffset["AFTER"] = 1] = "AFTER"; })(TreeMoveOffset = exports.TreeMoveOffset || (exports.TreeMoveOffset = {})); exports.findNestedNode = memoization_1.memoize(function (current, filter) { if (filter(current)) { return current; } var children = current.children; for (var i = 0, length_1 = children.length; i < length_1; i++) { var foundChild = exports.findNestedNode(children[i], filter); if (foundChild) { return foundChild; } } }); exports.createTreeNode = function (name, children) { if (children === void 0) { children = []; } return ({ id: uid_2.generateUID(), name: name, children: children }); }; exports.createNodeNameMatcher = memoization_1.memoize(function (name) { return function (node) { return node.name === name; }; }); exports.filterNestedNodes = memoization_1.memoize(function (current, filter, found) { if (found === void 0) { found = []; } if (filter(current)) { found.push(current); } var children = current.children; for (var i = 0, length_2 = children.length; i < length_2; i++) { exports.filterNestedNodes(current.children[i], filter, found); } return found; }); exports.getChildParentMap = memoization_1.memoize(function (current) { var idMap = exports.getTreeNodeIdMap(current); var parentChildMap = {}; for (var id in idMap) { var parent_1 = idMap[id]; for (var _i = 0, _a = parent_1.children; _i < _a.length; _i++) { var child = _a[_i]; parentChildMap[child.id] = parent_1; } } return parentChildMap; }); exports.getNodeNameMap = memoization_1.memoize(function (node) { var _a; var map = (_a = {}, _a[node.name] = [node], _a); for (var i = 0, length_3 = node.children.length; i < length_3; i++) { var childMap = exports.getNodeNameMap(node.children[i]); for (var name_1 in childMap) { map[name_1] = map[name_1] ? map[name_1].concat(childMap[name_1]) : childMap[name_1]; } } return map; }); exports.getTreeNodesByName = function (name, node) { return exports.getNodeNameMap(node)[name] || object_1.EMPTY_ARRAY; }; exports.getTreeNodeIdMap = memoization_1.memoize(function (current) { var _a; if (!current.id) { throw new Error("ID missing from node"); } var map = (_a = {}, _a[current.id] = current, _a); Object.assign.apply(Object, [map].concat(current.children.map(exports.getTreeNodeIdMap))); return map; }); exports.flattenTreeNode = memoization_1.memoize(function (current) { var treeNodeMap = exports.getTreeNodeIdMap(current); return Object.values(treeNodeMap); }); exports.getTreeNodePath = memoization_1.memoize(function (nodeId, root) { var childParentMap = exports.getChildParentMap(root); var idMap = exports.getTreeNodeIdMap(root); var current = idMap[nodeId]; var path = []; while (1) { var parent_2 = childParentMap[current.id]; if (!parent_2) break; var i = parent_2.children.indexOf(current); if (i === -1) { throw new Error("parent child mismatch. Likely id collision"); } path.unshift(i); current = parent_2; } return path; }); exports.findTreeNodeParent = function (nodeId, root, filter) { var path = exports.getTreeNodePath(nodeId, root); if (!path.length) return null; for (var i = path.length; i--;) { var parent_3 = exports.getTreeNodeFromPath(path.slice(0, i), root); if (filter(parent_3)) { return parent_3; } } }; exports.getTreeNodeAncestors = function (nodeId, root) { return exports.filterTreeNodeParents(nodeId, root, function () { return true; }); }; exports.filterTreeNodeParents = function (nodeId, root, filter) { var parents = []; var path = exports.getTreeNodePath(nodeId, root); if (!path.length) return null; for (var i = path.length; i--;) { var parent_4 = exports.getTreeNodeFromPath(path.slice(0, i), root); if (filter(parent_4)) { parents.push(parent_4); } } return parents; }; exports.findNodeByTagName = memoization_1.memoize(function (root, name, namespace) { return exports.findNestedNode(root, function (child) { return child.name === name && child.namespace == namespace; }); }); exports.getTreeNodeFromPath = memoization_1.memoize(function (path, root) { var current = root; for (var i = 0, length_4 = path.length; i < length_4; i++) { current = current.children[path[i]]; } return current; }); exports.getNestedTreeNodeById = function (id, root) { return exports.getTreeNodeIdMap(root)[id]; }; exports.containsNestedTreeNodeById = function (id, root) { return Boolean(exports.getTreeNodeIdMap(root)[id]); }; exports.getTreeNodeHeight = function (id, root) { return exports.getTreeNodePath(id, root).length; }; exports.generateTreeChecksum = memoization_1.memoize(function (root) { return crc32(JSON.stringify(root)); }); exports.getTreeNodeUidGenerator = memoization_1.memoize(function (root) { var rightMostTreeNode = exports.getRightMostTreeNode(root); return uid_1.createUIDGenerator(crc32(rightMostTreeNode.id)); }); exports.getRightMostTreeNode = function (current) { return current.children.length ? exports.getRightMostTreeNode(current.children[current.children.length - 1]) : current; }; exports.removeNestedTreeNode = function (nestedChild, current) { return exports.removeNestedTreeNodeFromPath(exports.getTreeNodePath(nestedChild.id, current), current); }; exports.removeNestedTreeNodeFromPath = function (path, current) { return exports.updateNestedNodeFromPath(path, current, function (child) { return null; }); }; exports.updateNestedNode = function (nestedChild, current, updater) { return exports.updateNestedNodeFromPath(exports.getTreeNodePath(nestedChild.id, current), current, updater); }; exports.replaceNestedNode = function (newChild, oldChildId, root) { return newChild ? exports.updateNestedNodeFromPath(exports.getTreeNodePath(oldChildId, root), root, function () { return newChild; }) : exports.removeNestedTreeNode(exports.getNestedTreeNodeById(oldChildId, root), root); }; exports.updateNestedNodeFromPath = function (path, current, updater, depth) { if (depth === void 0) { depth = 0; } if (depth === path.length) { return updater(current); } var updatedChild = exports.updateNestedNodeFromPath(path, current.children[path[depth]], updater, depth + 1); return __assign({}, current, { children: updatedChild ? array_1.arraySplice(current.children, path[depth], 1, updatedChild) : array_1.arraySplice(current.children, path[depth], 1) }); }; exports.updateNestedNodeTrail = function (path, current, updater, depth) { if (depth === void 0) { depth = 0; } if (depth !== path.length) { var updatedChild = exports.updateNestedNodeTrail(path, current.children[path[depth]], updater, depth + 1); current = __assign({}, current, { children: updatedChild ? array_1.arraySplice(current.children, path[depth], 1, updatedChild) : array_1.arraySplice(current.children, path[depth], 1) }); } return updater(current, depth, path); }; exports.appendChildNode = function (child, parent) { return exports.insertChildNode(child, parent.children.length, parent); }; exports.insertChildNode = function (child, index, parent) { return (__assign({}, parent, { children: array_1.arraySplice(parent.children, index, 0, child) })); }; exports.dropChildNode = function (child, offset, relative, root) { if (offset === TreeMoveOffset.APPEND) { return exports.updateNestedNode(relative, root, function (relative) { return exports.appendChildNode(child, relative); }); } else { var parent_5 = exports.getParentTreeNode(relative.id, root); var index_1 = parent_5.children.findIndex(function (child) { return child.id === relative.id; }) + (offset === TreeMoveOffset.BEFORE ? 0 : 1); return exports.updateNestedNode(parent_5, root, function () { return exports.insertChildNode(child, index_1, parent_5); }); } }; exports.reduceTree = function (node, reducer, initial) { var value = reducer(initial, node); for (var i = 0, length_5 = node.children.length; i < length_5; i++) { value = exports.reduceTree(node.children[i], reducer, value); } return value; }; exports.cloneTreeNode = function (node, generateID) { if (generateID === void 0) { generateID = function (node) { return uid_2.generateUID(); }; } return (__assign({}, node, { id: generateID(node), children: node.children.map(function (child) { return exports.cloneTreeNode(child, generateID); }) })); }; exports.getParentTreeNode = function (nodeId, root) { return exports.getChildParentMap(root)[nodeId]; }; exports.addTreeNodeIds = function (node, seed) { if (seed === void 0) { seed = ""; } return node.id ? node : exports.cloneTreeNode(node); }; //# sourceMappingURL=tree.js.map /***/ }), /***/ "../common/lib/utils/array/immutable.js": /*!**********************************************!*\ !*** ../common/lib/utils/array/immutable.js ***! \**********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.arraySplice = function (target, index, count) { if (count === void 0) { count = 1; } var replacements = []; for (var _i = 3; _i < arguments.length; _i++) { replacements[_i - 3] = arguments[_i]; } return target.slice(0, index).concat(replacements, target.slice(index + count)); }; exports.arrayRemove = function (target, value) { var i = target.indexOf(value); return exports.arraySplice(target, i, 1); }; //# sourceMappingURL=immutable.js.map /***/ }), /***/ "../common/lib/utils/array/index.js": /*!******************************************!*\ !*** ../common/lib/utils/array/index.js ***! \******************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "__esModule", { value: true }); __export(__webpack_require__(/*! ./immutable */ "../common/lib/utils/array/immutable.js")); __export(__webpack_require__(/*! ./ot */ "../common/lib/utils/array/ot.js")); //# sourceMappingURL=index.js.map /***/ }), /***/ "../common/lib/utils/array/ot.js": /*!***************************************!*\ !*** ../common/lib/utils/array/ot.js ***! \***************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "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 (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var ArrayOperationalTransformType; (function (ArrayOperationalTransformType) { ArrayOperationalTransformType.INSERT = "insert"; ArrayOperationalTransformType.UPDATE = "update"; ArrayOperationalTransformType.DELETE = "delete"; })(ArrayOperationalTransformType = exports.ArrayOperationalTransformType || (exports.ArrayOperationalTransformType = {})); var ArrayOperationalTransform = /** @class */ (function () { function ArrayOperationalTransform(type) { this.type = type; } return ArrayOperationalTransform; }()); exports.ArrayOperationalTransform = ArrayOperationalTransform; var ArrayInsertMutation = /** @class */ (function (_super) { __extends(ArrayInsertMutation, _super); function ArrayInsertMutation(index, value) { var _this = _super.call(this, ArrayOperationalTransformType.INSERT) || this; _this.index = index; _this.value = value; return _this; } return ArrayInsertMutation; }(ArrayOperationalTransform)); exports.ArrayInsertMutation = ArrayInsertMutation; var ArrayDeleteMutation = /** @class */ (function (_super) { __extends(ArrayDeleteMutation, _super); function ArrayDeleteMutation(value, index) { var _this = _super.call(this, ArrayOperationalTransformType.DELETE) || this; _this.value = value; _this.index = index; return _this; } return ArrayDeleteMutation; }(ArrayOperationalTransform)); exports.ArrayDeleteMutation = ArrayDeleteMutation; var ArrayUpdateMutation = /** @class */ (function (_super) { __extends(ArrayUpdateMutation, _super); function ArrayUpdateMutation(originalOldIndex, patchedOldIndex, newValue, index) { var _this = _super.call(this, ArrayOperationalTransformType.UPDATE) || this; _this.originalOldIndex = originalOldIndex; _this.patchedOldIndex = patchedOldIndex; _this.newValue = newValue; _this.index = index; return _this; } return ArrayUpdateMutation; }(ArrayOperationalTransform)); exports.ArrayUpdateMutation = ArrayUpdateMutation; function diffArray(oldArray, newArray, countDiffs) { // model used to figure out the proper mutation indices var model = [].concat(oldArray); // remaining old values to be matched with new values. Remainders get deleted. var oldPool = [].concat(oldArray); // remaining new values. Remainders get inserted. var newPool = [].concat(newArray); var mutations = []; var matches = []; for (var i = 0, n = oldPool.length; i < n; i++) { var oldValue = oldPool[i]; var bestNewValue = void 0; var fewestDiffCount = Infinity; // there may be multiple matches, so look for the best one for (var j = 0, n2 = newPool.length; j < n2; j++) { var newValue = newPool[j]; // -1 = no match, 0 = no change, > 0 = num diffs var diffCount = countDiffs(oldValue, newValue); if (~diffCount && diffCount < fewestDiffCount) { bestNewValue = newValue; fewestDiffCount = diffCount; } // 0 = exact match, so break here. if (fewestDiffCount === 0) break; } // subtract matches from both old & new pools and store // them for later use if (bestNewValue != null) { oldPool.splice(i--, 1); n--; newPool.splice(newPool.indexOf(bestNewValue), 1); // need to manually set array indice here to ensure that the order // of operations is correct when mutating the target array. matches[newArray.indexOf(bestNewValue)] = [oldValue, bestNewValue]; } } for (var i = oldPool.length; i--;) { var oldValue = oldPool[i]; var index = oldArray.indexOf(oldValue); mutations.push(new ArrayDeleteMutation(oldValue, index)); model.splice(index, 1); } // sneak the inserts into the matches so that they're // ordered propertly along with the updates - particularly moves. for (var i = 0, n = newPool.length; i < n; i++) { var newValue = newPool[i]; var index = newArray.indexOf(newValue); matches[index] = [undefined, newValue]; } // apply updates last using indicies from the old array model. This ensures // that mutations are properly applied to whatever target array. for (var i = 0, n = matches.length; i < n; i++) { var match = matches[i]; // there will be empty values since we're manually setting indices on the array above if (match == null) continue; var _a = matches[i], oldValue = _a[0], newValue = _a[1]; var newIndex = i; // insert if (oldValue == null) { mutations.push(new ArrayInsertMutation(newIndex, newValue)); model.splice(newIndex, 0, newValue); // updated } else { var oldIndex = model.indexOf(oldValue); mutations.push(new ArrayUpdateMutation(oldArray.indexOf(oldValue), oldIndex, newValue, newIndex)); if (oldIndex !== newIndex) { model.splice(oldIndex, 1); model.splice(newIndex, 0, oldValue); } } } return mutations; } exports.diffArray = diffArray; function patchArray(target, ots, mapUpdate, mapInsert) { if (mapInsert === void 0) { mapInsert = function (b) { return b; }; } if (!ots.length) { return target; } var newTarget = target.slice(); for (var _i = 0, ots_1 = ots; _i < ots_1.length; _i++) { var ot = ots_1[_i]; switch (ot.type) { case ArrayOperationalTransformType.INSERT: { var _a = ot, value = _a.value, index = _a.index; newTarget.splice(index, 0, mapInsert(value)); break; } case ArrayOperationalTransformType.DELETE: { var index = ot.index; newTarget.splice(index, 1); } case ArrayOperationalTransformType.UPDATE: { var _b = ot, patchedOldIndex = _b.patchedOldIndex, newValue = _b.newValue, index = _b.index; var oldValue = target[patchedOldIndex]; var patchedValue = mapUpdate(oldValue, newValue); if (patchedValue !== oldValue || patchedOldIndex !== index) { if (patchedOldIndex !== index) { newTarget.splice(patchedOldIndex, 1); } newTarget.splice(index, 0, patchedValue); } } } } return newTarget; } exports.patchArray = patchArray; //# sourceMappingURL=ot.js.map /***/ }), /***/ "../common/lib/utils/dnd.js": /*!**********************************!*\ !*** ../common/lib/utils/dnd.js ***! \**********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var lodash_1 = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"); exports.startDOMDrag = function (startEvent, onStart, update, stop) { if (stop === void 0) { stop = undefined; } var sx = startEvent.clientX; var sy = startEvent.clientY; var doc = startEvent.target.ownerDocument; var _animating; var _started; // slight delay to prevent accidental drag from firing // if the user does some other mouse interaction such as a double click. var drag = lodash_1.throttle(function (event) { if (!_started) { _started = true; onStart(event); } event.preventDefault(); update(event, { delta: { x: event.clientX - sx, y: event.clientY - sy } }); }, 10); function onMouseUp(event) { doc.removeEventListener("mousemove", drag); doc.removeEventListener("mouseup", onMouseUp); if (stop && _started) { stop(event, { delta: { x: event.clientX - sx, y: event.clientY - sy } }); } } doc.addEventListener("mousemove", drag); doc.addEventListener("mouseup", onMouseUp); }; //# sourceMappingURL=dnd.js.map /***/ }), /***/ "../common/lib/utils/file.js": /*!***********************************!*\ !*** ../common/lib/utils/file.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveFilePath = function (relativePath, fromPath) { var pp1 = fromPath.split(/[\\/]/); var pp2 = relativePath.split(/[\\/]/); pp1.pop(); if (pp2[0] === ".") { pp2.shift(); } else { while (pp2[0] === "..") { pp2.shift(); pp1.pop(); } } return pp1.concat(pp2).join("/"); }; exports.normalizeFilePath = function (filePath) { return filePath.replace(/[\\]/g, "/").replace("C:/", "/"); }; //# sourceMappingURL=file.js.map /***/ }), /***/ "../common/lib/utils/html.js": /*!***********************************!*\ !*** ../common/lib/utils/html.js ***! \***********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.stringifyStyle = function (style) { var buffer = ""; for (var name_1 in style) { if (style[name_1] == null) continue; buffer += name_1 + ":" + style[name_1] + ";"; } return buffer; }; //# sourceMappingURL=html.js.map /***/ }), /***/ "../common/lib/utils/iframe.js": /*!*************************************!*\ !*** ../common/lib/utils/iframe.js ***! \*************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var transform_1 = __webpack_require__(/*! ./transform */ "../common/lib/utils/transform.js"); function bubbleHTMLIframeEvents(iframe, options) { if (options === void 0) { options = {}; } var window = iframe.contentWindow; var body = window.document.childNodes[0]; var translateMousePositions = options.translateMousePositions !== false; // TODO - this should be in its own util function function bubbleEvent(event) { if (/key|input/.test(event.type) && options.ignoreInputEvents && (/textarea|input/i.test(event.target.nodeName) || event.target.contentEditable === "true")) { return; } var clonedEvent = new Event(event.type, { bubbles: true, cancelable: true }); var rect = iframe.getBoundingClientRect(); var actualRect = transform_1.calculateAbsoluteBounds(iframe); var zoom = rect.width / (actualRect.right - actualRect.left); for (var key in event) { var value = event[key]; if (typeof value === "function") { value = value.bind(event); } if (translateMousePositions) { if (key === "pageX" || key === "clientX") { value = rect.left + value * zoom; } if (key === "pageY" || key === "client