@wework/floormap-sdk
Advanced tools
Comparing version 1.1.0-rc3 to 1.1.0-rc4
@@ -10,2 +10,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _size from "lodash/size"; | ||
import _map from "lodash/map"; | ||
import nanoid from 'nanoid'; | ||
@@ -31,2 +32,17 @@ import Extension from "../extensions/Extension"; | ||
_defineProperty(this, "retrieveExtensionDataById", function (uuid) { | ||
var data = {}; | ||
_forEach(_this.extensions, function (extension) { | ||
var extensionId = extension.getId(); | ||
var extensionData = extension.getDataById(uuid); | ||
if (extensionData) { | ||
data[extensionId] = extensionData; | ||
} | ||
}); | ||
return data; | ||
}); | ||
_defineProperty(this, "updateViewport", _debounce(function () { | ||
@@ -45,17 +61,6 @@ _this.renderer.updateWindowDimension({ | ||
var data = _this.datasource.getSpaceById(id) || _this.datasource.getObjectById(id); | ||
var data = _this.getSpaceById(id); | ||
if (data) { | ||
eventPayload.data = _extends({}, data); | ||
eventPayload.data = data; | ||
_forEach(_this.extensions, function (extension) { | ||
var extensionId = extension.getId(); | ||
var extensionData = extension.getDataById(id); | ||
if (extensionData) { | ||
eventPayload.data[extensionId] = extensionData; | ||
} | ||
}); | ||
} | ||
_this.eventEmitter.emit(event.type, eventPayload); | ||
@@ -126,2 +131,4 @@ }); | ||
_regeneratorRuntime.mark(function _callee(options) { | ||
var _this2 = this; | ||
var buildingId, floorId, loadPromises, result, loadResult, building, floor, spaces, objects, error, onLoadResult, onLoadErrors; | ||
@@ -224,3 +231,10 @@ return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 30: | ||
// didLoad hooks call | ||
// Merge space data with extension data | ||
result.spaces = _map(result.spaces, function (space) { | ||
return _extends({}, space, _this2.retrieveExtensionDataById(space.uuid)); | ||
}); | ||
result.objects = _map(result.objects, function (object) { | ||
return _extends({}, object, _this2.retrieveExtensionDataById(object.uuid)); | ||
}); // didLoad hooks call | ||
this.hooks.didLoad.forEach(function (listener) { | ||
@@ -231,3 +245,3 @@ listener(result); | ||
case 32: | ||
case 34: | ||
case "end": | ||
@@ -489,3 +503,3 @@ return _context.stop(); | ||
_proto.showDeskLayout = function showDeskLayout(show) { | ||
var _this2 = this; | ||
var _this3 = this; | ||
@@ -506,3 +520,3 @@ if (show === this.isDeskLayoutEnabled) { | ||
_each(objects, function (object) { | ||
var space = _this2.datasource.getSpaceById(object.spaceUUID); | ||
var space = _this3.datasource.getSpaceById(object.spaceUUID); | ||
@@ -579,3 +593,3 @@ var objectPayload = { | ||
_proto.applyStyle = function applyStyle(styleObjects, done) { | ||
var _this3 = this; | ||
var _this4 = this; | ||
@@ -595,9 +609,9 @@ var objects = [styleObjects]; | ||
var styleObject = _this3.styleManager.applyStyle(id, style, key); | ||
var styleObject = _this4.styleManager.applyStyle(id, style, key); | ||
var space = _this3.datasource.getSpaceById(id); | ||
var space = _this4.datasource.getSpaceById(id); | ||
var object = _this3.datasource.getObjectById(id); | ||
var object = _this4.datasource.getObjectById(id); | ||
if (!_this3.isRendering) { | ||
if (!_this4.isRendering) { | ||
if (styleObject && (space || object)) { | ||
@@ -626,3 +640,3 @@ renderObjects.push({ | ||
_proto.revertStyle = function revertStyle(styleObjects, done) { | ||
var _this4 = this; | ||
var _this5 = this; | ||
@@ -641,9 +655,9 @@ var objects = [styleObjects]; | ||
var styleObject = _this4.styleManager.revertStyle(id, key); | ||
var styleObject = _this5.styleManager.revertStyle(id, key); | ||
var space = _this4.datasource.getSpaceById(id); | ||
var space = _this5.datasource.getSpaceById(id); | ||
var object = _this4.datasource.getObjectById(id); | ||
var object = _this5.datasource.getObjectById(id); | ||
if (!_this4.isRendering) { | ||
if (!_this5.isRendering) { | ||
if (styleObject && (space || object)) { | ||
@@ -671,3 +685,3 @@ renderObjects.push({ | ||
_proto.resetStyle = function resetStyle(styleObjects, done) { | ||
var _this5 = this; | ||
var _this6 = this; | ||
@@ -685,9 +699,9 @@ var objects = [styleObjects]; | ||
var styleObject = _this5.styleManager.resetStyle(id); | ||
var styleObject = _this6.styleManager.resetStyle(id); | ||
var space = _this5.datasource.getSpaceById(id); | ||
var space = _this6.datasource.getSpaceById(id); | ||
var object = _this5.datasource.getObjectById(id); | ||
var object = _this6.datasource.getObjectById(id); | ||
if (!_this5.isRendering) { | ||
if (!_this6.isRendering) { | ||
if (styleObject && (space || object)) { | ||
@@ -733,3 +747,3 @@ renderObjects.push({ | ||
_proto.updateSpaceText = function updateSpaceText(payloads) { | ||
var _this6 = this; | ||
var _this7 = this; | ||
@@ -745,3 +759,3 @@ var objects = payloads.map(function (p) { | ||
setTimeout(function () { | ||
_this6.renderer.draw('', true); | ||
_this7.renderer.draw('', true); | ||
}); | ||
@@ -825,3 +839,6 @@ } | ||
_proto.getSpaceById = function getSpaceById(uuid) { | ||
return this.datasource.getSpaceById(uuid) || this.datasource.getObjectById(uuid); | ||
var space = this.datasource.getSpaceById(uuid) || this.datasource.getObjectById(uuid); | ||
if (!space) return undefined; | ||
var extensionData = this.retrieveExtensionDataById(space.uuid); | ||
return _extends({}, space, extensionData); | ||
} // -- Data Update | ||
@@ -864,4 +881,8 @@ | ||
this.eventEmitter.emit('datachange', eventPayload); | ||
} // -- Hooks | ||
} | ||
/** @private */ | ||
; | ||
// -- Hooks | ||
/** | ||
@@ -885,12 +906,10 @@ * Hook: onLoad fucntion | ||
*/ | ||
; | ||
_proto.onLoad = function onLoad(listener) { | ||
var _this7 = this; | ||
var _this8 = this; | ||
this.hooks.onLoad.push(listener); | ||
return function () { | ||
var index = _this7.hooks.onLoad.indexOf(listener); | ||
var index = _this8.hooks.onLoad.indexOf(listener); | ||
_this7.hooks.onLoad.splice(index, 1); | ||
_this8.hooks.onLoad.splice(index, 1); | ||
}; | ||
@@ -916,9 +935,9 @@ } | ||
_proto.didLoad = function didLoad(listener) { | ||
var _this8 = this; | ||
var _this9 = this; | ||
this.hooks.didLoad.push(listener); | ||
return function () { | ||
var index = _this8.hooks.didLoad.indexOf(listener); | ||
var index = _this9.hooks.didLoad.indexOf(listener); | ||
_this8.hooks.didLoad.splice(index, 1); | ||
_this9.hooks.didLoad.splice(index, 1); | ||
}; | ||
@@ -946,9 +965,9 @@ } | ||
_proto.onRender = function onRender(listener) { | ||
var _this9 = this; | ||
var _this10 = this; | ||
this.hooks.onRender.push(listener); | ||
return function () { | ||
var index = _this9.hooks.onRender.indexOf(listener); | ||
var index = _this10.hooks.onRender.indexOf(listener); | ||
_this9.hooks.onRender.splice(index, 1); | ||
_this10.hooks.onRender.splice(index, 1); | ||
}; | ||
@@ -973,9 +992,9 @@ } | ||
_proto.didRender = function didRender(listener) { | ||
var _this10 = this; | ||
var _this11 = this; | ||
this.hooks.didRender.push(listener); | ||
return function () { | ||
var index = _this10.hooks.didRender.indexOf(listener); | ||
var index = _this11.hooks.didRender.indexOf(listener); | ||
_this10.hooks.didRender.splice(index, 1); | ||
_this11.hooks.didRender.splice(index, 1); | ||
}; | ||
@@ -1000,9 +1019,9 @@ } | ||
_proto.onError = function onError(listener) { | ||
var _this11 = this; | ||
var _this12 = this; | ||
this.hooks.onError.push(listener); | ||
return function () { | ||
var index = _this11.hooks.onError.indexOf(listener); | ||
var index = _this12.hooks.onError.indexOf(listener); | ||
_this11.hooks.onError.splice(index, 1); | ||
_this12.hooks.onError.splice(index, 1); | ||
}; | ||
@@ -1017,3 +1036,3 @@ } | ||
_proto.addObject = function addObject(payload) { | ||
var _this12 = this; | ||
var _this13 = this; | ||
@@ -1024,3 +1043,3 @@ var ignorePositionTypes = ['MESH', 'LINE']; | ||
if (object.spaceUUID && !object.position && !ignorePositionTypes.includes(object.type)) { | ||
var space = _this12.datasource.getSpaceById(object.spaceUUID); | ||
var space = _this13.datasource.getSpaceById(object.spaceUUID); | ||
@@ -1077,3 +1096,3 @@ if (!space) { | ||
_proto.removeObject = function removeObject(objectsOrIds) { | ||
var _this13 = this; | ||
var _this14 = this; | ||
@@ -1099,3 +1118,3 @@ var objects = Array.isArray(objectsOrIds) ? objectsOrIds : [objectsOrIds]; // const idsToRemove = [] | ||
_this13.renderer.remove(id); | ||
_this14.renderer.remove(id); | ||
}); | ||
@@ -1197,3 +1216,3 @@ } | ||
_proto.tearDown = function tearDown() { | ||
var _this14 = this; | ||
var _this15 = this; | ||
@@ -1211,3 +1230,3 @@ window.removeEventListener('resize', this.updateViewport); | ||
Object.keys(this.extensions).forEach(function (key) { | ||
_this14.removeExtension(_this14.extensions[key]); | ||
_this15.removeExtension(_this15.extensions[key]); | ||
}); | ||
@@ -1262,3 +1281,3 @@ this.rendererEventHandlerMap = {}; | ||
_proto.performRender = function performRender(payload) { | ||
var _this15 = this; | ||
var _this16 = this; | ||
@@ -1330,12 +1349,12 @@ // Render Objects | ||
setTimeout(function () { | ||
var pendingObjects = [].concat(_this15.pendingRenderObjects); | ||
_this15.pendingRenderObjects = []; | ||
applyInstancing(renderObjects, _this15.renderer); | ||
var pendingObjects = [].concat(_this16.pendingRenderObjects); | ||
_this16.pendingRenderObjects = []; | ||
applyInstancing(renderObjects, _this16.renderer); | ||
_this15.renderer.draw([].concat(renderObjects, spaceRenderObjects, pendingObjects), true, function () { | ||
_this15.setRotation(_this15.currentRotation.azimuthAngle, _this15.currentRotation.polarAngle); | ||
_this16.renderer.draw([].concat(renderObjects, spaceRenderObjects, pendingObjects), true, function () { | ||
_this16.setRotation(_this16.currentRotation.azimuthAngle, _this16.currentRotation.polarAngle); | ||
_this15.fitContent(_this15.currentFitContent); | ||
_this16.fitContent(_this16.currentFitContent); | ||
_this15.fitContent(_this15.currentFitContent); // eslint-disable-next-line no-restricted-syntax | ||
_this16.fitContent(_this16.currentFitContent); // eslint-disable-next-line no-restricted-syntax | ||
@@ -1355,3 +1374,3 @@ | ||
_proto.getSpaceRenderObjects = function getSpaceRenderObjects() { | ||
var _this16 = this; | ||
var _this17 = this; | ||
@@ -1370,3 +1389,3 @@ // Render Space | ||
var styleObject = _this16.styleManager.createStyle(space.uuid, space, style); | ||
var styleObject = _this17.styleManager.createStyle(space.uuid, space, style); | ||
@@ -1387,3 +1406,3 @@ objectsToRender.push.apply(objectsToRender, [_extends({}, spaceRenderObj, { | ||
_proto.getDeskRenderObjects = function getDeskRenderObjects() { | ||
var _this17 = this; | ||
var _this18 = this; | ||
@@ -1394,3 +1413,3 @@ var objectsToRender = []; | ||
_each(objects, function (object) { | ||
var space = _this17.datasource.getSpaceById(object.spaceUUID); | ||
var space = _this18.datasource.getSpaceById(object.spaceUUID); | ||
@@ -1403,3 +1422,3 @@ var objs = getObjectRenderObject(object, space); | ||
var styleObject = _this17.styleManager.createStyle(object.uuid, object, style); // Dedicated Desk and Shared Office Desk: | ||
var styleObject = _this18.styleManager.createStyle(object.uuid, object, style); // Dedicated Desk and Shared Office Desk: | ||
// - Desk and Chair in dedicated desk room always show | ||
@@ -1409,4 +1428,4 @@ // - Desk is always interactable | ||
spaceRenderObj.visible = _this17.isDeskLayoutEnabled; | ||
spaceRenderObj.interactable = _this17.isDeskLayoutInteractable; | ||
spaceRenderObj.visible = _this18.isDeskLayoutEnabled; | ||
spaceRenderObj.interactable = _this18.isDeskLayoutInteractable; | ||
@@ -1413,0 +1432,0 @@ if (space && DEDICATED_ROOM_TYPES.includes(space.subType)) { |
@@ -26,2 +26,4 @@ "use strict"; | ||
var _map2 = _interopRequireDefault(require("lodash/map")); | ||
var _nanoid = _interopRequireDefault(require("nanoid")); | ||
@@ -54,2 +56,14 @@ | ||
(0, _defineProperty2.default)(this, "retrieveExtensionDataById", function (uuid) { | ||
var data = {}; | ||
(0, _forEach2.default)(_this.extensions, function (extension) { | ||
var extensionId = extension.getId(); | ||
var extensionData = extension.getDataById(uuid); | ||
if (extensionData) { | ||
data[extensionId] = extensionData; | ||
} | ||
}); | ||
return data; | ||
}); | ||
(0, _defineProperty2.default)(this, "updateViewport", (0, _debounce2.default)(function () { | ||
@@ -66,16 +80,6 @@ _this.renderer.updateWindowDimension({ | ||
var data = _this.datasource.getSpaceById(id) || _this.datasource.getObjectById(id); | ||
var data = _this.getSpaceById(id); | ||
if (data) { | ||
eventPayload.data = (0, _extends2.default)({}, data); | ||
(0, _forEach2.default)(_this.extensions, function (extension) { | ||
var extensionId = extension.getId(); | ||
var extensionData = extension.getDataById(id); | ||
eventPayload.data = data; | ||
if (extensionData) { | ||
eventPayload.data[extensionId] = extensionData; | ||
} | ||
}); | ||
} | ||
_this.eventEmitter.emit(event.type, eventPayload); | ||
@@ -145,2 +149,4 @@ }); | ||
_regenerator.default.mark(function _callee(options) { | ||
var _this2 = this; | ||
var buildingId, floorId, loadPromises, result, loadResult, building, floor, spaces, objects, error, onLoadResult, onLoadErrors; | ||
@@ -243,3 +249,10 @@ return _regenerator.default.wrap(function _callee$(_context) { | ||
case 30: | ||
// didLoad hooks call | ||
// Merge space data with extension data | ||
result.spaces = (0, _map2.default)(result.spaces, function (space) { | ||
return (0, _extends2.default)({}, space, _this2.retrieveExtensionDataById(space.uuid)); | ||
}); | ||
result.objects = (0, _map2.default)(result.objects, function (object) { | ||
return (0, _extends2.default)({}, object, _this2.retrieveExtensionDataById(object.uuid)); | ||
}); // didLoad hooks call | ||
this.hooks.didLoad.forEach(function (listener) { | ||
@@ -250,3 +263,3 @@ listener(result); | ||
case 32: | ||
case 34: | ||
case "end": | ||
@@ -508,3 +521,3 @@ return _context.stop(); | ||
_proto.showDeskLayout = function showDeskLayout(show) { | ||
var _this2 = this; | ||
var _this3 = this; | ||
@@ -524,3 +537,3 @@ if (show === this.isDeskLayoutEnabled) { | ||
(0, _each2.default)(objects, function (object) { | ||
var space = _this2.datasource.getSpaceById(object.spaceUUID); | ||
var space = _this3.datasource.getSpaceById(object.spaceUUID); | ||
@@ -594,3 +607,3 @@ var objectPayload = { | ||
_proto.applyStyle = function applyStyle(styleObjects, done) { | ||
var _this3 = this; | ||
var _this4 = this; | ||
@@ -610,9 +623,9 @@ var objects = [styleObjects]; | ||
var styleObject = _this3.styleManager.applyStyle(id, style, key); | ||
var styleObject = _this4.styleManager.applyStyle(id, style, key); | ||
var space = _this3.datasource.getSpaceById(id); | ||
var space = _this4.datasource.getSpaceById(id); | ||
var object = _this3.datasource.getObjectById(id); | ||
var object = _this4.datasource.getObjectById(id); | ||
if (!_this3.isRendering) { | ||
if (!_this4.isRendering) { | ||
if (styleObject && (space || object)) { | ||
@@ -641,3 +654,3 @@ renderObjects.push({ | ||
_proto.revertStyle = function revertStyle(styleObjects, done) { | ||
var _this4 = this; | ||
var _this5 = this; | ||
@@ -656,9 +669,9 @@ var objects = [styleObjects]; | ||
var styleObject = _this4.styleManager.revertStyle(id, key); | ||
var styleObject = _this5.styleManager.revertStyle(id, key); | ||
var space = _this4.datasource.getSpaceById(id); | ||
var space = _this5.datasource.getSpaceById(id); | ||
var object = _this4.datasource.getObjectById(id); | ||
var object = _this5.datasource.getObjectById(id); | ||
if (!_this4.isRendering) { | ||
if (!_this5.isRendering) { | ||
if (styleObject && (space || object)) { | ||
@@ -686,3 +699,3 @@ renderObjects.push({ | ||
_proto.resetStyle = function resetStyle(styleObjects, done) { | ||
var _this5 = this; | ||
var _this6 = this; | ||
@@ -700,9 +713,9 @@ var objects = [styleObjects]; | ||
var styleObject = _this5.styleManager.resetStyle(id); | ||
var styleObject = _this6.styleManager.resetStyle(id); | ||
var space = _this5.datasource.getSpaceById(id); | ||
var space = _this6.datasource.getSpaceById(id); | ||
var object = _this5.datasource.getObjectById(id); | ||
var object = _this6.datasource.getObjectById(id); | ||
if (!_this5.isRendering) { | ||
if (!_this6.isRendering) { | ||
if (styleObject && (space || object)) { | ||
@@ -748,3 +761,3 @@ renderObjects.push({ | ||
_proto.updateSpaceText = function updateSpaceText(payloads) { | ||
var _this6 = this; | ||
var _this7 = this; | ||
@@ -760,3 +773,3 @@ var objects = payloads.map(function (p) { | ||
setTimeout(function () { | ||
_this6.renderer.draw('', true); | ||
_this7.renderer.draw('', true); | ||
}); | ||
@@ -840,3 +853,6 @@ } | ||
_proto.getSpaceById = function getSpaceById(uuid) { | ||
return this.datasource.getSpaceById(uuid) || this.datasource.getObjectById(uuid); | ||
var space = this.datasource.getSpaceById(uuid) || this.datasource.getObjectById(uuid); | ||
if (!space) return undefined; | ||
var extensionData = this.retrieveExtensionDataById(space.uuid); | ||
return (0, _extends2.default)({}, space, extensionData); | ||
} // -- Data Update | ||
@@ -877,4 +893,8 @@ | ||
this.eventEmitter.emit('datachange', eventPayload); | ||
} // -- Hooks | ||
} | ||
/** @private */ | ||
; | ||
// -- Hooks | ||
/** | ||
@@ -898,12 +918,10 @@ * Hook: onLoad fucntion | ||
*/ | ||
; | ||
_proto.onLoad = function onLoad(listener) { | ||
var _this7 = this; | ||
var _this8 = this; | ||
this.hooks.onLoad.push(listener); | ||
return function () { | ||
var index = _this7.hooks.onLoad.indexOf(listener); | ||
var index = _this8.hooks.onLoad.indexOf(listener); | ||
_this7.hooks.onLoad.splice(index, 1); | ||
_this8.hooks.onLoad.splice(index, 1); | ||
}; | ||
@@ -929,9 +947,9 @@ } | ||
_proto.didLoad = function didLoad(listener) { | ||
var _this8 = this; | ||
var _this9 = this; | ||
this.hooks.didLoad.push(listener); | ||
return function () { | ||
var index = _this8.hooks.didLoad.indexOf(listener); | ||
var index = _this9.hooks.didLoad.indexOf(listener); | ||
_this8.hooks.didLoad.splice(index, 1); | ||
_this9.hooks.didLoad.splice(index, 1); | ||
}; | ||
@@ -959,9 +977,9 @@ } | ||
_proto.onRender = function onRender(listener) { | ||
var _this9 = this; | ||
var _this10 = this; | ||
this.hooks.onRender.push(listener); | ||
return function () { | ||
var index = _this9.hooks.onRender.indexOf(listener); | ||
var index = _this10.hooks.onRender.indexOf(listener); | ||
_this9.hooks.onRender.splice(index, 1); | ||
_this10.hooks.onRender.splice(index, 1); | ||
}; | ||
@@ -986,9 +1004,9 @@ } | ||
_proto.didRender = function didRender(listener) { | ||
var _this10 = this; | ||
var _this11 = this; | ||
this.hooks.didRender.push(listener); | ||
return function () { | ||
var index = _this10.hooks.didRender.indexOf(listener); | ||
var index = _this11.hooks.didRender.indexOf(listener); | ||
_this10.hooks.didRender.splice(index, 1); | ||
_this11.hooks.didRender.splice(index, 1); | ||
}; | ||
@@ -1013,9 +1031,9 @@ } | ||
_proto.onError = function onError(listener) { | ||
var _this11 = this; | ||
var _this12 = this; | ||
this.hooks.onError.push(listener); | ||
return function () { | ||
var index = _this11.hooks.onError.indexOf(listener); | ||
var index = _this12.hooks.onError.indexOf(listener); | ||
_this11.hooks.onError.splice(index, 1); | ||
_this12.hooks.onError.splice(index, 1); | ||
}; | ||
@@ -1030,3 +1048,3 @@ } | ||
_proto.addObject = function addObject(payload) { | ||
var _this12 = this; | ||
var _this13 = this; | ||
@@ -1037,3 +1055,3 @@ var ignorePositionTypes = ['MESH', 'LINE']; | ||
if (object.spaceUUID && !object.position && !ignorePositionTypes.includes(object.type)) { | ||
var space = _this12.datasource.getSpaceById(object.spaceUUID); | ||
var space = _this13.datasource.getSpaceById(object.spaceUUID); | ||
@@ -1090,3 +1108,3 @@ if (!space) { | ||
_proto.removeObject = function removeObject(objectsOrIds) { | ||
var _this13 = this; | ||
var _this14 = this; | ||
@@ -1112,3 +1130,3 @@ var objects = Array.isArray(objectsOrIds) ? objectsOrIds : [objectsOrIds]; // const idsToRemove = [] | ||
_this13.renderer.remove(id); | ||
_this14.renderer.remove(id); | ||
}); | ||
@@ -1210,3 +1228,3 @@ } | ||
_proto.tearDown = function tearDown() { | ||
var _this14 = this; | ||
var _this15 = this; | ||
@@ -1224,3 +1242,3 @@ window.removeEventListener('resize', this.updateViewport); | ||
Object.keys(this.extensions).forEach(function (key) { | ||
_this14.removeExtension(_this14.extensions[key]); | ||
_this15.removeExtension(_this15.extensions[key]); | ||
}); | ||
@@ -1275,3 +1293,3 @@ this.rendererEventHandlerMap = {}; | ||
_proto.performRender = function performRender(payload) { | ||
var _this15 = this; | ||
var _this16 = this; | ||
@@ -1343,12 +1361,12 @@ // Render Objects | ||
setTimeout(function () { | ||
var pendingObjects = [].concat(_this15.pendingRenderObjects); | ||
_this15.pendingRenderObjects = []; | ||
(0, _floormapUtils.applyInstancing)(renderObjects, _this15.renderer); | ||
var pendingObjects = [].concat(_this16.pendingRenderObjects); | ||
_this16.pendingRenderObjects = []; | ||
(0, _floormapUtils.applyInstancing)(renderObjects, _this16.renderer); | ||
_this15.renderer.draw([].concat(renderObjects, spaceRenderObjects, pendingObjects), true, function () { | ||
_this15.setRotation(_this15.currentRotation.azimuthAngle, _this15.currentRotation.polarAngle); | ||
_this16.renderer.draw([].concat(renderObjects, spaceRenderObjects, pendingObjects), true, function () { | ||
_this16.setRotation(_this16.currentRotation.azimuthAngle, _this16.currentRotation.polarAngle); | ||
_this15.fitContent(_this15.currentFitContent); | ||
_this16.fitContent(_this16.currentFitContent); | ||
_this15.fitContent(_this15.currentFitContent); // eslint-disable-next-line no-restricted-syntax | ||
_this16.fitContent(_this16.currentFitContent); // eslint-disable-next-line no-restricted-syntax | ||
@@ -1368,3 +1386,3 @@ | ||
_proto.getSpaceRenderObjects = function getSpaceRenderObjects() { | ||
var _this16 = this; | ||
var _this17 = this; | ||
@@ -1382,3 +1400,3 @@ // Render Space | ||
var styleObject = _this16.styleManager.createStyle(space.uuid, space, style); | ||
var styleObject = _this17.styleManager.createStyle(space.uuid, space, style); | ||
@@ -1398,3 +1416,3 @@ objectsToRender.push.apply(objectsToRender, [(0, _extends2.default)({}, spaceRenderObj, { | ||
_proto.getDeskRenderObjects = function getDeskRenderObjects() { | ||
var _this17 = this; | ||
var _this18 = this; | ||
@@ -1404,3 +1422,3 @@ var objectsToRender = []; | ||
(0, _each2.default)(objects, function (object) { | ||
var space = _this17.datasource.getSpaceById(object.spaceUUID); | ||
var space = _this18.datasource.getSpaceById(object.spaceUUID); | ||
@@ -1413,3 +1431,3 @@ var objs = (0, _render2.getObjectRenderObject)(object, space); | ||
var styleObject = _this17.styleManager.createStyle(object.uuid, object, style); // Dedicated Desk and Shared Office Desk: | ||
var styleObject = _this18.styleManager.createStyle(object.uuid, object, style); // Dedicated Desk and Shared Office Desk: | ||
// - Desk and Chair in dedicated desk room always show | ||
@@ -1419,4 +1437,4 @@ // - Desk is always interactable | ||
spaceRenderObj.visible = _this17.isDeskLayoutEnabled; | ||
spaceRenderObj.interactable = _this17.isDeskLayoutInteractable; | ||
spaceRenderObj.visible = _this18.isDeskLayoutEnabled; | ||
spaceRenderObj.interactable = _this18.isDeskLayoutInteractable; | ||
@@ -1423,0 +1441,0 @@ if (space && DEDICATED_ROOM_TYPES.includes(space.subType)) { |
{ | ||
"name": "@wework/floormap-sdk", | ||
"version": "1.1.0-rc3", | ||
"version": "1.1.0-rc4", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "module": "es/index.js", |
@@ -167,2 +167,12 @@ /* eslint-disable no-param-reassign */ | ||
// Merge space data with extension data | ||
result.spaces = _.map(result.spaces, space => ({ | ||
...space, | ||
...this.retrieveExtensionDataById(space.uuid), | ||
})) | ||
result.objects = _.map(result.objects, object => ({ | ||
...object, | ||
...this.retrieveExtensionDataById(object.uuid), | ||
})) | ||
// didLoad hooks call | ||
@@ -556,3 +566,10 @@ this.hooks.didLoad.forEach((listener) => { | ||
getSpaceById(uuid) { | ||
return this.datasource.getSpaceById(uuid) || this.datasource.getObjectById(uuid) | ||
const space = this.datasource.getSpaceById(uuid) || this.datasource.getObjectById(uuid) | ||
if (!space) return undefined | ||
const extensionData = this.retrieveExtensionDataById(space.uuid) | ||
return { | ||
...space, | ||
...extensionData, | ||
} | ||
} | ||
@@ -591,2 +608,15 @@ | ||
/** @private */ | ||
retrieveExtensionDataById = (uuid) => { | ||
const data = {} | ||
_.forEach(this.extensions, (extension) => { | ||
const extensionId = extension.getId() | ||
const extensionData = extension.getDataById(uuid) | ||
if (extensionData) { | ||
data[extensionId] = extensionData | ||
} | ||
}) | ||
return data | ||
} | ||
// -- Hooks | ||
@@ -1052,14 +1082,4 @@ | ||
const eventPayload = { ...event } | ||
const data = this.datasource.getSpaceById(id) || this.datasource.getObjectById(id) | ||
if (data) { | ||
eventPayload.data = { ...data } | ||
_.forEach(this.extensions, (extension) => { | ||
const extensionId = extension.getId() | ||
const extensionData = extension.getDataById(id) | ||
if (extensionData) { | ||
eventPayload.data[extensionId] = extensionData | ||
} | ||
}) | ||
} | ||
const data = this.getSpaceById(id) | ||
eventPayload.data = data | ||
this.eventEmitter.emit(event.type, eventPayload) | ||
@@ -1066,0 +1086,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10551670
45486