UNPKG

vue-cesium

Version:
35 lines (30 loc) 1.25 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var useLog = require('../private/use-log.js'); var config = require('../../utils/config.js'); "use strict"; function useVueCesium(containerId) { var _a, _b, _c; const instance = vue.getCurrentInstance(); const provides = (instance == null ? void 0 : instance.parent) === null ? instance.vnode.appContext && instance.vnode.appContext.provides : (_a = instance == null ? void 0 : instance.parent) == null ? void 0 : _a.provides; if ((!provides || !(config.vcKey in provides)) && !containerId) { containerId = "cesiumContainer"; } const logger = useLog["default"](); if (instance) { if (containerId) { const $vc = (_c = (_b = instance.appContext.config.globalProperties) == null ? void 0 : _b.$VueCesium) == null ? void 0 : _c[containerId]; if (!$vc) { logger.warn(`Failed to get $vc, reason: vc-viewer with containerId: ${containerId} was not found.`); } return $vc; } else { return vue.inject(config.vcKey); } } else { logger.warn("VueCesium useVueCesium() can only be used inside setup()."); } } exports["default"] = useVueCesium; //# sourceMappingURL=index.js.map