tandem-front-end
Version:
Visual editor for web components
1,310 lines (1,205 loc) • 1.36 MB
JavaScript
/******/ (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 = "./src/paperclip.worker.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "../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) {
throw new Error("Module build failed: Error: ENOENT: no such file or directory, open '/Users/crcn/Developer/work/tandem/public/packages/common/lib/index.js'");
/***/ }),
/***/ "../fsbox/index.js":
/*!*************************!*\
!*** ../fsbox/index.js ***!
\*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! ./lib */ "../fsbox/lib/index.js");
/***/ }),
/***/ "../fsbox/lib/actions.js":
/*!*******************************!*\
!*** ../fsbox/lib/actions.js ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FS_SANDBOX_ITEM_LOADING = "FS_SANDBOX_ITEM_LOADING";
exports.FS_SANDBOX_ITEM_LOADED = "FS_SANDBOX_ITEM_LOADED";
exports.FS_SANDBOX_ITEM_SAVED = "FS_SANDBOX_ITEM_SAVED";
exports.FS_SANDBOX_ITEM_SAVING = "FS_SANDBOX_ITEM_SAVING";
exports.FILE_CHANGED = "FILE_CHANGED";
var FileChangedEventType;
(function (FileChangedEventType) {
FileChangedEventType["UNLINK"] = "unlink";
FileChangedEventType["ADD"] = "add";
FileChangedEventType["UNLINK_DIR"] = "unlinkDir";
FileChangedEventType["ADD_DIR"] = "addDir";
FileChangedEventType["CHANGE"] = "change";
})(FileChangedEventType = exports.FileChangedEventType || (exports.FileChangedEventType = {}));
exports.fsSandboxItemLoaded = function (uri, content, mimeType) { return ({
uri: uri,
content: content,
mimeType: mimeType,
type: exports.FS_SANDBOX_ITEM_LOADED
}); };
exports.fsSandboxItemLoading = function (uri) { return ({
uri: uri,
type: exports.FS_SANDBOX_ITEM_LOADING
}); };
exports.fsSandboxItemSaving = function (uri) { return ({
uri: uri,
type: exports.FS_SANDBOX_ITEM_SAVING
}); };
exports.fsSandboxItemSaved = function (uri) { return ({
uri: uri,
type: exports.FS_SANDBOX_ITEM_SAVED
}); };
exports.fileChanged = function (eventType, uri) { return ({
type: exports.FILE_CHANGED,
eventType: eventType,
uri: uri
}); };
//# sourceMappingURL=actions.js.map
/***/ }),
/***/ "../fsbox/lib/index.js":
/*!*****************************!*\
!*** ../fsbox/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__(/*! ./saga */ "../fsbox/lib/saga.js"));
__export(__webpack_require__(/*! ./reducer */ "../fsbox/lib/reducer.js"));
__export(__webpack_require__(/*! ./state */ "../fsbox/lib/state.js"));
__export(__webpack_require__(/*! ./actions */ "../fsbox/lib/actions.js"));
//# sourceMappingURL=index.js.map
/***/ }),
/***/ "../fsbox/lib/reducer.js":
/*!*******************************!*\
!*** ../fsbox/lib/reducer.js ***!
\*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var state_1 = __webpack_require__(/*! ./state */ "../fsbox/lib/state.js");
var actions_1 = __webpack_require__(/*! ./actions */ "../fsbox/lib/actions.js");
exports.fsSandboxReducer = function (state, action) {
switch (action.type) {
case actions_1.FS_SANDBOX_ITEM_LOADING: {
var uri = action.uri;
return state_1.updateFileCacheItem({ status: state_1.FileCacheItemStatus.LOADING }, uri, state);
}
case actions_1.FS_SANDBOX_ITEM_LOADED: {
var _a = action, uri = _a.uri, content = _a.content, mimeType = _a.mimeType;
return state_1.updateFileCacheItem({ status: state_1.FileCacheItemStatus.LOADED, content: content, mimeType: mimeType }, uri, state);
}
case actions_1.FS_SANDBOX_ITEM_SAVING: {
var uri = action.uri;
return state_1.updateFileCacheItem({ status: state_1.FileCacheItemStatus.SAVING }, uri, state);
}
case actions_1.FS_SANDBOX_ITEM_SAVED: {
var uri = action.uri;
return state_1.updateFileCacheItem({ status: state_1.FileCacheItemStatus.LOADED, dirty: false }, uri, state);
}
}
return state;
};
//# sourceMappingURL=reducer.js.map
/***/ }),
/***/ "../fsbox/lib/saga.js":
/*!****************************!*\
!*** ../fsbox/lib/saga.js ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
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 _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var path = __webpack_require__(/*! path */ "./node_modules/path-browserify/index.js");
var effects_1 = __webpack_require__(/*! redux-saga/effects */ "./node_modules/redux-saga/es/effects.js");
var state_1 = __webpack_require__(/*! ./state */ "../fsbox/lib/state.js");
var actions_1 = __webpack_require__(/*! ./actions */ "../fsbox/lib/actions.js");
exports.setReaderMimetype = function (mimeType, extensions) { return function (readFile) { return function (uri) { return __awaiter(_this, void 0, void 0, function () {
var content;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (extensions.indexOf(path.extname(uri)) === -1) {
return [2 /*return*/, readFile(uri)];
}
return [4 /*yield*/, readFile(uri)];
case 1:
content = (_a.sent()).content;
return [2 /*return*/, { content: content, mimeType: mimeType }];
}
});
}); }; }; };
exports.createFSSandboxSaga = function (_a) {
var readFile = _a.readFile, writeFile = _a.writeFile;
return function () {
function handleUpdatedFile(item) {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(item.status === state_1.FileCacheItemStatus.CREATED)) return [3 /*break*/, 2];
return [4 /*yield*/, effects_1.call(loadFile, item.uri)];
case 1:
_a.sent();
return [3 /*break*/, 4];
case 2:
if (!(item.status === state_1.FileCacheItemStatus.SAVE_REQUESTED)) return [3 /*break*/, 4];
return [4 /*yield*/, effects_1.call(saveFile, item)];
case 3:
_a.sent();
_a.label = 4;
case 4: return [2 /*return*/];
}
});
}
function loadFile(uri) {
var _a, content, mimeType;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, effects_1.put(actions_1.fsSandboxItemLoading(uri))];
case 1:
_b.sent();
return [4 /*yield*/, effects_1.call(readFile, uri)];
case 2:
_a = _b.sent(), content = _a.content, mimeType = _a.mimeType;
return [4 /*yield*/, effects_1.put(actions_1.fsSandboxItemLoaded(uri, content, mimeType))];
case 3:
_b.sent();
return [2 /*return*/];
}
});
}
function saveFile(_a) {
var uri = _a.uri, content = _a.content;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, effects_1.put(actions_1.fsSandboxItemSaving(uri))];
case 1:
_b.sent();
return [4 /*yield*/, effects_1.call(writeFile, uri, content)];
case 2:
_b.sent();
return [4 /*yield*/, effects_1.put(actions_1.fsSandboxItemSaved(uri))];
case 3:
_b.sent();
return [2 /*return*/];
}
});
}
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, effects_1.fork(function handleFileChanges() {
var prevState, state, updatedFiles, uri, _a, _b, _i, uri;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (false) {}
return [4 /*yield*/, effects_1.take()];
case 1:
_c.sent();
return [4 /*yield*/, effects_1.select()];
case 2:
state = _c.sent();
if (prevState && state.fileCache === prevState.fileCache) {
return [3 /*break*/, 0];
}
updatedFiles = {};
for (uri in state.fileCache) {
if (!prevState || prevState.fileCache[uri] !== state.fileCache[uri]) {
updatedFiles[uri] = state.fileCache[uri];
}
}
prevState = state;
_a = [];
for (_b in updatedFiles)
_a.push(_b);
_i = 0;
_c.label = 3;
case 3:
if (!(_i < _a.length)) return [3 /*break*/, 6];
uri = _a[_i];
return [4 /*yield*/, effects_1.spawn(handleUpdatedFile, updatedFiles[uri])];
case 4:
_c.sent();
_c.label = 5;
case 5:
_i++;
return [3 /*break*/, 3];
case 6: return [3 /*break*/, 0];
case 7: return [2 /*return*/];
}
});
})];
case 1:
_a.sent();
return [4 /*yield*/, effects_1.fork(function handleLocalChanges() {
var _loop_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_loop_1 = function () {
var uri, state;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, effects_1.take(function (action) {
return (action.type === actions_1.FILE_CHANGED &&
action.eventType === actions_1.FileChangedEventType.CHANGE);
})];
case 1:
uri = (_a.sent()).uri;
return [4 /*yield*/, effects_1.select()];
case 2:
state = _a.sent();
// This will happen if FileChanged is fired on a FS item that isn't also in cache. I.e:
// the changed FS item has not _explicitly_ been added via queueOpenFile
if (!state.fileCache[uri]) {
return [2 /*return*/, "continue"];
}
return [4 /*yield*/, effects_1.spawn(function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, effects_1.call(loadFile, uri)];
case 1:
_a.sent();
return [2 /*return*/];
}
});
})];
case 3:
_a.sent();
return [2 /*return*/];
}
});
};
_a.label = 1;
case 1:
if (false) {}
return [5 /*yield**/, _loop_1()];
case 2:
_a.sent();
return [3 /*break*/, 1];
case 3: return [2 /*return*/];
}
});
})];
case 2:
_a.sent();
return [2 /*return*/];
}
});
};
};
//# sourceMappingURL=saga.js.map
/***/ }),
/***/ "../fsbox/lib/state.js":
/*!*****************************!*\
!*** ../fsbox/lib/state.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 tandem_common_1 = __webpack_require__(/*! tandem-common */ "../common/index.js");
var mime = __webpack_require__(/*! mime-types */ "./node_modules/mime-types/index.js");
var FileCacheItemStatus;
(function (FileCacheItemStatus) {
FileCacheItemStatus[FileCacheItemStatus["CREATED"] = 0] = "CREATED";
FileCacheItemStatus[FileCacheItemStatus["LOADING"] = 1] = "LOADING";
FileCacheItemStatus[FileCacheItemStatus["LOADED"] = 2] = "LOADED";
FileCacheItemStatus[FileCacheItemStatus["SAVE_REQUESTED"] = 3] = "SAVE_REQUESTED";
FileCacheItemStatus[FileCacheItemStatus["SAVING"] = 4] = "SAVING";
})(FileCacheItemStatus = exports.FileCacheItemStatus || (exports.FileCacheItemStatus = {}));
exports.queueOpenFile = function (uri, state) {
var _a;
// should always create new file for queueOpen since reducer
// code may depend on newly loaded content
return __assign({}, state, { fileCache: __assign({}, state.fileCache, (_a = {}, _a[uri] = createFileCacheItem(uri), _a)) });
};
exports.queueOpenFiles = function (uris, state) { return uris.reduce(function (state, uri) { return exports.queueOpenFile(uri, state); }, state); };
exports.getFSItem = function (uri, state) {
return state.fileCache[uri];
};
exports.isImageUri = function (uri) {
return /^image\//.test(mime.lookup(uri) || "");
};
exports.isSvgUri = function (uri) { return /\.svg$/.test(uri); };
exports.queueSaveFile = function (uri, state) {
return exports.updateFileCacheItem({ status: FileCacheItemStatus.SAVE_REQUESTED }, uri, state);
};
exports.fsCacheBusy = tandem_common_1.memoize(function (fileCache) {
return Object.values(fileCache).some(function (item) { return item.status !== FileCacheItemStatus.LOADED; });
});
exports.getFileCacheItemsByMimetype = function (mimeType, state) {
var items = [];
for (var uri in state) {
var item = state[uri];
if (item.mimeType === mimeType) {
items.push(item);
}
}
return items;
};
exports.hasFileCacheItem = function (uri, state) {
return Boolean(state.fileCache[uri]);
};
exports.updateFileCacheItem = function (properties, uri, state) {
var _a;
return (__assign({}, state, { fileCache: __assign({}, state.fileCache, (_a = {}, _a[uri] = __assign({}, state.fileCache[uri], properties, { dirty: state.fileCache[uri].dirty || Boolean(properties.content) }), _a)) }));
};
var createFileCacheItem = function (uri) { return ({
uri: uri,
status: FileCacheItemStatus.CREATED,
content: null,
mimeType: null
}); };
exports.getFileCacheItemDataUrl = tandem_common_1.memoize(function (_a) {
var mimeType = _a.mimeType, content = _a.content;
return "data:" + mimeType + ";base64, " + content.toString("base64");
});
//# sourceMappingURL=state.js.map
/***/ }),
/***/ "../paperclip-migrator/000-001.js":
/*!****************************************!*\
!*** ../paperclip-migrator/000-001.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
const { merge } = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
module.exports = (module) => {
return merge({}, module, {
id: module.id || (Math.round(Math.random() * 9999999999) + "." + Date.now()),
version: "0.0.1",
children: module.children && module.children.map(mapModuleChild) || []
});
}
const mapModuleChild = (child) => {
if (child.name === "component") {
return mapComponent(child);
}
return child;
}
const mapComponent = (component) => merge({}, component, {
attributes: {
core: {
name: component.attributes.core.id,
id: null
}
}
});
/***/ }),
/***/ "../paperclip-migrator/001-002.js":
/*!****************************************!*\
!*** ../paperclip-migrator/001-002.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
const { generateUID } = __webpack_require__(/*! tandem-common */ "../common/index.js");
const { merge, values } = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
module.exports = (module) => {
const mapModule = ({ id, attributes, children }) => ({
id: id,
name: "module",
imports: attributes && values(attributes.xmlns || {}) || [],
version: "0.0.2",
children: children.map(mapModuleChild)
});
const mapModuleChild = (child) => {
return {
id: generateUID(),
name: "frame",
bounds: child.attributes.editor && child.attributes.editor.bounds,
children: [mapFrameChild(child)]
};
}
const mapFrameChild = (child) => {
switch(child.name) {
case "component": return mapComponent(child);
default: mapVisibleNode(child);
}
};
const mapComponent = ({ id, attributes, children }) => ({
id,
name: "component",
is: "div",
style: {},
attributes: {},
label: attributes.core.label,
container: attributes.core.container,
children: children[0].children.map(mapVisibleNode)
});
const getComponentInstanceId = (componentName) => {
const component = module.children.find(component => component.attributes.core.name === componentName);
return component && component.id;
}
const mapVisibleNode = (node) => {
switch(node.name) {
case "element": return mapElement(node);
case "text": return mapText(node);
default: return mapComponentInstance(node);
}
};
const mapElement = ({ id, name, attributes, children }) => ({
id,
name: "element",
label: attributes.core.label,
style: attributes.core.style || {},
slot: attributes.core.slot,
container: attributes.core.container,
attributes: {},
is: attributes.core.nativeType && attributes.core.nativeType !== "element" ? attributes.core.nativeType : "div",
children: children.map(mapVisibleNode)
});
const mapText = ({ id, name, attributes }) => ({
id,
name: "text",
label: attributes.core.label,
value: attributes.core.value,
style: attributes.core.style || {},
children: []
});
const mapComponentInstance = ({ id, name, attributes, children }) => ({
id,
name: "component-instance",
is: getComponentInstanceId(name) || name,
variant: [],
style: attributes.core.style,
container: attributes.core.container,
children: children.map(mapVisibleNode)
});
return mapModule(module);
}
/***/ }),
/***/ "../paperclip-migrator/002-003.js":
/*!****************************************!*\
!*** ../paperclip-migrator/002-003.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = (module) => {
const mapModule = (module) => {
return {
id: module.id,
version: "0.0.3",
metadata: {},
name: "module",
children: module.children.map(mapFrame)
};
};
const mapFrame = (frame) => {
const firstChild = mapNode(frame.children[0]);
return Object.assign({}, firstChild, {
metadata: {
bounds: frame.bounds
}
});
};
const mapNode = (node) => Object.assign({}, node, {
metadata: {},
attributes: node.attributes || {},
children: node.children.map(mapNode)
});
return mapModule(module);
};
/***/ }),
/***/ "../paperclip-migrator/003-004.js":
/*!****************************************!*\
!*** ../paperclip-migrator/003-004.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = (module) => {
const mapModule = (module) => {
return {
id: module.id,
version: "0.0.4",
metadata: {},
name: "module",
children: module.children.map(mapNode).filter(Boolean)
};
};
const mapNode = (node) => {
if (node.name === "override" && node.propertyName === "label") {
return null;
}
return Object.assign({}, node, {
children: node.children.map(mapNode).filter(Boolean)
});
};
return mapModule(module);
};
/***/ }),
/***/ "../paperclip-migrator/004-005.js":
/*!****************************************!*\
!*** ../paperclip-migrator/004-005.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = (module) => {
const mapModule = (module) => {
return {
id: module.id,
version: "0.0.5",
metadata: {},
name: "module",
children: module.children.map(mapNode)
};
};
const mapNode = (node) => {
if (node.name === "component-instance" || node.name === "component") {
return Object.assign({}, node, {
variant: node.variant || {}
});
}
return node;
};
return mapModule(module);
};
/***/ }),
/***/ "../paperclip-migrator/005-006.js":
/*!****************************************!*\
!*** ../paperclip-migrator/005-006.js ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = (module) => {
const mapModule = (module) => {
return {
id: module.id,
version: "0.0.6",
metadata: {},
name: "module",
children: module.children.map(mapNode)
};
};
const mapNode = (node) => {
if (node.name === "media-query") {
return {
id: node.id,
children: node.children,
metadata: node.metadata,
label: node.label,
name: "query",
type: 0,
condition: {
minWidth: node.minWidth,
maxWidth: node.maxWidth
}
}
}
if (node.name === "variant-trigger" && node.source && node.source.type === 0) {
return {
id: node.id,
children: node.children,
metadata: node.metadata,
label: node.label,
name: "variant-trigger",
targetVariantId: node.targetVariantId,
source: {
type: 0,
queryId: node.source.mediaQueryId
}
}
}
return {
...node,
children: node.children.map(mapNode)
};
};
return mapModule(module);
};
/***/ }),
/***/ "../paperclip-migrator/index.js":
/*!**************************************!*\
!*** ../paperclip-migrator/index.js ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
const _000_001 = __webpack_require__(/*! ./000-001 */ "../paperclip-migrator/000-001.js");
const _001_002 = __webpack_require__(/*! ./001-002 */ "../paperclip-migrator/001-002.js");
const _002_003 = __webpack_require__(/*! ./002-003 */ "../paperclip-migrator/002-003.js");
const _003_004 = __webpack_require__(/*! ./003-004 */ "../paperclip-migrator/003-004.js");
const _004_005 = __webpack_require__(/*! ./004-005 */ "../paperclip-migrator/004-005.js");
const _005_006 = __webpack_require__(/*! ./005-006 */ "../paperclip-migrator/005-006.js");
const migrators = {
"0.0.0": _000_001,
"0.0.1": _001_002,
"0.0.2": _002_003,
"0.0.3": _003_004,
"0.0.4": _004_005,
"0.0.5": _005_006
};
module.exports = (oldModule) => {
const migrate = migrators[oldModule.version || "0.0.0"];
return migrate ? module.exports(migrate(oldModule)) : oldModule;
};
/***/ }),
/***/ "../paperclip/index.js":
/*!*****************************!*\
!*** ../paperclip/index.js ***!
\*****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! ./lib */ "../paperclip/lib/index.js");
/***/ }),
/***/ "../paperclip/lib/actions.js":
/*!***********************************!*\
!*** ../paperclip/lib/actions.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PC_SYNTHETIC_FRAME_RENDERED = "PC_SYNTHETIC_FRAME_RENDERED";
exports.PC_DEPENDENCY_GRAPH_LOADED = "PC_DEPENDENCY_GRAPH_LOADED";
exports.PC_SOURCE_FILE_URIS_RECEIVED = "PC_SOURCE_FILE_URIS_RECEIVED";
exports.PC_SYNTHETIC_FRAME_CONTAINER_CREATED = "PC_SYNTHETIC_FRAME_CONTAINER_CREATED";
exports.PC_RUNTIME_EVALUATED = "PC_RUNTIME_EVALUATED";
exports.pcFrameRendered = function (frame, computed) { return ({
type: exports.PC_SYNTHETIC_FRAME_RENDERED,
frame: frame,
computed: computed
}); };
exports.pcDependencyGraphLoaded = function (graph) { return ({
graph: graph,
type: exports.PC_DEPENDENCY_GRAPH_LOADED
}); };
exports.pcSourceFileUrisReceived = function (uris) { return ({
uris: uris,
type: exports.PC_SOURCE_FILE_URIS_RECEIVED
}); };
exports.pcFrameContainerCreated = function (frame, $container) { return ({
frame: frame,
$container: $container,
type: exports.PC_SYNTHETIC_FRAME_CONTAINER_CREATED
}); };
exports.pcRuntimeEvaluated = function (newDocuments, diffs, allDocuments, catchingUp) { return ({
newDocuments: newDocuments,
diffs: diffs,
catchingUp: catchingUp,
allDocuments: allDocuments,
type: exports.PC_RUNTIME_EVALUATED
}); };
//# sourceMappingURL=actions.js.map
/***/ }),
/***/ "../paperclip/lib/config.js":
/*!**********************************!*\
!*** ../paperclip/lib/config.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 fs = __webpack_require__(/*! fs */ "./node_modules/null-loader/index.js?fs");
var path = __webpack_require__(/*! path */ "./node_modules/path-browserify/index.js");
var dsl_1 = __webpack_require__(/*! ./dsl */ "../paperclip/lib/dsl.js");
var graph_1 = __webpack_require__(/*! ./graph */ "../paperclip/lib/graph.js");
var constants_1 = __webpack_require__(/*! ./constants */ "../paperclip/lib/constants.js");
var tandem_common_1 = __webpack_require__(/*! tandem-common */ "../common/index.js");
var DEFAULT_EXCLUDES = ["node_modules"];
exports.createPCConfig = function (rootDir, exclude) {
if (exclude === void 0) { exclude = DEFAULT_EXCLUDES; }
return ({
rootDir: rootDir,
exclude: exclude
});
};
exports.DEFAULT_CONFIG = exports.createPCConfig(".");
exports.openPCConfig = function (dir) {
var cdir = dir;
while (1) {
var possibleDir = (cdir = path.dirname(cdir));
if (!cdir) {
break;
}
var tdProjectBasename = fs
.readdirSync(possibleDir)
.find(function (name) { return name.indexOf(constants_1.PAPERCLIP_CONFIG_DEFAULT_EXTENSION) !== -1; });
if (tdProjectBasename) {
return {
directory: tandem_common_1.normalizeFilePath(possibleDir),
config: JSON.parse(fs.readFileSync(path.join(possibleDir, tdProjectBasename), "utf8"))
};
}
}
return { directory: dir, config: exports.DEFAULT_CONFIG };
};
exports.findPaperclipSourceFiles = function (config, cwd) {
var pcFilePaths = [];
exports.walkPCRootDirectory(config, cwd, function (filePath) {
if (graph_1.isPaperclipUri(filePath)) {
pcFilePaths.push(filePath);
}
});
return pcFilePaths;
};
exports.walkPCRootDirectory = function (_a, cwd, each) {
var rootDir = _a.rootDir, exclude = _a.exclude;
var excludeRegexp = new RegExp(exclude.join("|"));
var pcFilePaths = [];
if (rootDir.charAt(0) === ".") {
rootDir = path.resolve(cwd, rootDir);
}
walkFiles(rootDir, function (filePath, isDirectory) {
if (excludeRegexp.test(filePath)) {
return false;
}
each(filePath, isDirectory);
});
};
var walkFiles = function (filePath, each) {
var isDirectory = fs.lstatSync(filePath).isDirectory();
if (each(filePath, isDirectory) === false) {
return;
}
if (!isDirectory) {
return;
}
var subpaths = fs
.readdirSync(filePath)
.map(function (basename) { return tandem_common_1.normalizeFilePath(path.join(filePath, basename)); });
for (var i = 0, length_1 = subpaths.length; i < length_1; i++) {
walkFiles(subpaths[i], each);
}
};
exports.loadFSDependencyGraphSync = function (config, cwd, mapModule) {
return exports.findPaperclipSourceFiles(config, cwd).reduce(function (config, sourceFilePath) {
var _a;
var uri = tandem_common_1.addProtocol(tandem_common_1.FILE_PROTOCOL, sourceFilePath);
var content = fs.readFileSync(sourceFilePath, "utf8") || "{}";
return __assign({}, config, (_a = {}, _a[uri] = dsl_1.createPCDependency(uri, mapModule(JSON.parse(content))), _a));
}, {});
};
//# sourceMappingURL=config.js.map
/***/ }),
/***/ "../paperclip/lib/constants.js":
/*!*************************************!*\
!*** ../paperclip/lib/constants.js ***!
\*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PAPERCLIP_MIME_TYPE = "application/paperclip";
exports.PAPERCLIP_DEFAULT_EXTENSIONS = [".pc"];
exports.PAPERCLIP_CONFIG_DEFAULT_EXTENSION = ".tdproject";
//# sourceMappingURL=constants.js.map
/***/ }),
/***/ "../paperclip/lib/dom-renderer.js":
/*!****************************************!*\
!*** ../paperclip/lib/dom-renderer.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 lodash_1 = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
var tandem_common_1 = __webpack_require__(/*! tandem-common */ "../common/index.js");
var ot_1 = __webpack_require__(/*! ./ot */ "../paperclip/lib/ot.js");
var dsl_1 = __webpack_require__(/*! ./dsl */ "../paperclip/lib/dsl.js");
var SVG_XMLNS = "http://www.w3.org/2000/svg";
exports.renderDOM = function (native, synthetic, document) {
if (document === void 0) { document = window.document; }
while (native.childNodes.length) {
native.removeChild(native.childNodes[0]);
}
var nativeMap = {};
// Not ethat we cannot render directly to the element passed in
// since we need to assume that its type is immutable (like body)
// applySyntheticNodeProps(native, synthetic, nativeMap, true);
native.appendChild(createNativeNode(synthetic, document, nativeMap, true));
return nativeMap;
};
exports.waitForDOMReady = function (map) {
var loadableElements = Object.values(map).filter(function (element) {
return /img/.test(element.nodeName);
});
return Promise.all(loadableElements.map(function (element) {
return new Promise(function (resolve) {
element.onload = resolve;
});
}));
};
exports.computeDisplayInfo = function (map) {
var computed = {};
for (var id in map) {
var node = map[id];
var rect = node.getBoundingClientRect();
if (node.nodeType === 1) {
computed[id] = {
style: window.getComputedStyle(node),
bounds: {
left: rect.left,
top: rect.top,
right: rect.right,
bottom: rect.bottom
}
};
}
}
return computed;
};
var setStyleConstraintsIfRoot = function (synthetic, nativeElement, isContentNode) {
if (isContentNode) {
nativeElement.style.position = "fixed";
if (nativeElement.tagName === "SPAN") {
nativeElement.style.display = "block";
}
nativeElement.style.top = "0px";
nativeElement.style.left = "0px";
nativeElement.style.width = "100%";
nativeElement.style.height = "100%";
nativeElement.style.minHeight = "unset";
nativeElement.style.minWidth = "unset";
nativeElement.style.maxWidth = "unset";
nativeElement.style.maxHeight = "unset";
nativeElement.style.boxSizing = "border-box";
}
};
var setAttribute = function (target, name, value) {
if (name === "style") {
console.warn("\"style\" attribute present in attributes.");
return;
}
if (name.indexOf(":") !== -1) {
var _a = name.split(":"), xmlns = _a[0], key = _a[1];
target.setAttributeNS(xmlns, key, value);
}
else {
target.setAttribute(name, value);
}
};
var SVG_STYlE_KEY_MAP = {
background: "fill"
};
var setStyle = function (target, style) {
var normalizedStyle = normalizeStyle(style);
var cstyle;
if (target.namespaceURI === SVG_XMLNS) {
cstyle = {};
for (var key in normalizedStyle) {
cstyle[SVG_STYlE_KEY_MAP[key] || key] = normalizedStyle[key];
}
}
else {
cstyle = normalizedStyle;
}
Object.assign(target.style, cstyle);
};
var createNativeNode = function (synthetic, document, map, isContentNode, xmlns) {
var isText = synthetic.name === dsl_1.PCSourceTagNames.TEXT;
var attrs = synthetic.attributes || tandem_common_1.EMPTY_OBJECT;
var tagName = isText
? "span"
: synthetic.name || "div";
if (attrs.xmlns) {
xmlns = attrs.xmlns;
}
var nativeElement = (xmlns
? document.createElementNS(xmlns, tagName)
: document.createElement(tagName));
applySyntheticNodeProps(nativeElement, synthetic, map, isContentNode, nativeElement.namespaceURI);
return (map[synthetic.id] = nativeElement);
};
var applySyntheticNodeProps = function (nativeElement, synthetic, map, isContentNode, xmlns) {
var isText = synthetic.name === dsl_1.PCSourceTagNames.TEXT;
var attrs = synthetic.attributes || tandem_common_1.EMPTY_OBJECT;
for (var name_1 in attrs) {
setAttribute(nativeElement, name_1, attrs[name_1]);
}
if (synthetic.style) {
setStyle(nativeElement, synthetic.style);
}
setStyleConstraintsIfRoot(synthetic, nativeElement, isContentNode);
if (isText) {
nativeElement.appendChild(document.createTextNode(synthetic.value));
}
else {
for (var i = 0, length_1 = synthetic.children.length; i < length_1; i++) {
var childSynthetic = synthetic.children[i];
nativeElement.appendChild(createNativeNode(childSynthetic, document, map, false, xmlns));
}
}
makeElementClickable(nativeElement, synthetic, isContentNode);
return (map[synthetic.id] = nativeElement);
};
var removeElementsFromMap = function (synthetic, map) {
map[synthetic.id] = undefined;
for (var i = 0, length_2 = synthetic.children.length; i < length_2; i++) {
removeElementsFromMap(synthetic, map);
}
};
exports.patchDOM = function (transforms, synthetic, root, map) {
var newMap = map;
var newSyntheticTree = synthetic;
for (var _i = 0, transforms_1 = transforms; _i < transforms_1.length; _i++) {
var transform = transforms_1[_i];
var oldSyntheticTarget = tandem_common_1.getTreeNodeFromPath(transform.nodePath, newSyntheticTree);
var isContentNode = transform.nodePath.length === 0;
var target = newMap[oldSyntheticTarget.id];
newSyntheticTree = ot_1.patchTreeNode([transform], newSyntheticTree);
var syntheticTarget = tandem_common_1.getTreeNodeFromPath(transform.nodePath, newSyntheticTree);
switch (transform.type) {
case ot_1.TreeNodeOperationalTransformType.SET_PROPERTY: {
var _a = transform, name_2 = _a.name, value = _a.value;
if (name_2 === "style") {
resetElementStyle(target, syntheticTarget);
setStyleConstraintsIfRoot(syntheticTarget, target, isContentNode);
makeElementClickable(target, syntheticTarget, isContentNode);
}
else if (name_2 === "attributes") {
for (var key in value) {
if (!value[key]) {
target.removeAttribute(key);
}
else {
setAttribute(target, key, value[key]);
}
}
}
else if (name_2 === "name") {
var parent_1 = target.parentNode;
if (newMap === map) {
newMap = __assign({}, map);
}
var xmlnsTransform = transforms.find(function (transform) {
return transform.type ===
ot_1.TreeNodeOperationalTransformType.SET_PROPERTY &&
transform.name === "attributes" &&
transform.value.xmlns;
});
var newTarget = createNativeNode(tandem_common_1.getTreeNodeFromPath(transform.nodePath, newSyntheticTree), root.ownerDocument, newMap, isContentNode, xmlnsTransform && xmlnsTransform.value.xmlns);
parent_1.insertBefore(newTarget, target);
parent_1.removeChild(target);
}
else if (syntheticTarget.name === "text" && name_2 === "value") {
target.childNodes[0].nodeValue = value;
}
break;
}
case ot_1.TreeNodeOperationalTransformType.INSERT_CHILD: {
var _b = transform, child = _b.child, index = _b.index;
if (newMap === map) {
newMap = __assign({}, map);
}
var nativeChild = createNativeNode(child, root.ownerDocument, newMap, false, target.namespaceURI);
removeClickableStyle(target, syntheticTarget);
insertChild(target, nativeChild, index);
break;
}
case ot_1.TreeNodeOperationalTransformType.REMOVE_CHILD: {
var index = transform.index;
target.removeChild(target.childNodes[index]);
if (target.childNodes.length === 0) {
makeElementClickable(target, syntheticTarget, isContentNode);
}
break;
}
case ot_1.TreeNodeOperationalTransformType.MOVE_CHILD: {
var _c = transform, oldIndex = _c.oldIndex, newIndex = _c.newIndex;
var child = target.childNodes[oldIndex];
target.removeChild(child);
insertChild(target, child, newIndex);
break;
}
default: {
throw new Error("OT not supported yet");
}
}
}
return newMap;
};
var EMPTY_ELEMENT_STYLE_NAMES = [
"box-sizing",
"display",
"background",
"background-image",
"font-family",
"font-weight",
"white-space",
"position",
"text-decoration",
"letter-spacing",
"color",
"border-radius",
"box-sizing",
"box-shadow",
"border-top-left-radius",
"border-top-right-radius",
"border-bottom-left-radius",
"border-bottom-right-radius",
"border-left",
"border-right",
"border-top",
"border-bottom",
"line-height",