{"version":3,"file":"index.mjs","sources":["../../../../../../packages/components/datasources/custom/index.ts"],"sourcesContent":["/*\n * @Author: zouyaoji@https://github.com/zouyaoji\n * @Date: 2021-09-16 09:28:13\n * @LastEditTime: 2022-04-06 15:00:23\n * @LastEditors: zouyaoji\n * @Description:\n * @FilePath: \\vue-cesium@next\\packages\\components\\datasources\\custom\\index.ts\n */\nimport type { PropType, VNode } from 'vue'\nimport { createCommentVNode, defineComponent, getCurrentInstance, h } from 'vue'\nimport type { VcComponentInternalInstance, VcComponentPublicInstance, VcDatasource, VcPickEvent, VcReadyObject } from '@vue-cesium/utils/types'\nimport { useDatasources } from '@vue-cesium/composables'\nimport { kebabCase } from '@vue-cesium/utils/util'\nimport { hSlot } from '@vue-cesium/utils/private/render'\nimport { show, enableMouseEvent } from '@vue-cesium/utils/cesium-props'\nimport { VcEntityProps } from '../../entity'\nimport { datasourceEmits } from '@vue-cesium/utils/emits'\n\nexport const customDatasourceProps = {\n  ...show,\n  ...enableMouseEvent,\n  entities: {\n    type: Array as PropType<Array<VcEntityProps>>,\n    default: () => []\n  },\n  name: String,\n  destroy: {\n    type: Boolean,\n    default: false\n  }\n}\nexport default defineComponent({\n  name: 'VcDatasourceCustom',\n  props: customDatasourceProps,\n  emits: datasourceEmits,\n  setup(props: VcDatasourceCustomProps, ctx) {\n    // state\n    const instance = getCurrentInstance() as VcComponentInternalInstance\n    instance.cesiumClass = 'CustomDataSource'\n    useDatasources(props, ctx, instance)\n\n    instance.createCesiumObject = async () => {\n      return new Cesium.CustomDataSource(props.name)\n    }\n\n    return () =>\n      ctx.slots.default\n        ? h(\n            'i',\n            {\n              class: kebabCase(instance.proxy?.$options.name || ''),\n              style: { display: 'none !important' }\n            },\n            hSlot(ctx.slots.default)\n          )\n        : createCommentVNode(kebabCase(instance.proxy?.$options.name || ''))\n  }\n})\n\nexport type VcDatasourceCustomProps = {\n  /**\n   * Specify whether the data source is displayed.\n   * Default value: true\n   */\n  show?: boolean\n  /**\n   * Specify whether to respond to mouse pick events.\n   * Default value: true\n   */\n  enableMouseEvent?: boolean\n  /**\n   * Specify the collection of entities to be added to this data source.\n   */\n  entities?: Array<VcEntityProps>\n  /**\n   * A human-readable name for this instance.\n   */\n  name?: string\n  /**\n   * Whether to destroy the data source in addition to removing it.\n   * Default value: false\n   */\n  destroy?: boolean\n  /**\n   * Triggers before the VcDatasourceCustom is loaded.\n   */\n  onBeforeLoad?: (instance: VcComponentInternalInstance) => void\n  /**\n   * Triggers when the VcDatasourceCustom is successfully loaded.\n   */\n  onReady?: (readyObject: VcReadyObject) => void\n  /**\n   * Triggers when the component load failed.\n   */\n  onUnready?: (e: any) => void\n  /**\n   * Triggers when the VcDatasourceCustom is destroyed.\n   */\n  onDestroyed?: (instance: VcComponentInternalInstance) => void\n  /**\n   * Triggers when the mouse is pressed on this datasource.\n   */\n  onMousedown?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse bounces up on this datasource.\n   */\n  onMouseup?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse clicks on this datasource.\n   */\n  onClick?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse clicks outside this datasource.\n   */\n  onClickout?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the left mouse button double-clicks this datasource.\n   */\n  onDblclick?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse moves on this datasource.\n   */\n  onMousemove?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse moves over to this datasource.\n   */\n  onMouseover?: (evt: VcPickEvent) => void\n  /**\n   * Triggers when the mouse moves out of this datasource.\n   */\n  onMouseout?: (evt: VcPickEvent) => void\n  /**\n   * Triggers whenever a new property is assigned. datasource.clock.\n   */\n  onDefinitionChanged?: (property: Cesium.Property) => void\n  /**\n   *  Triggers when a new cluster will be displayed. datasource.clustering.\n   */\n  onClusterEvent?: (\n    entities: Array<Cesium.Entity>,\n    cluster: { billboard: Cesium.Billboard; label: Cesium.Label; point: Cesium.PointPrimitive }\n  ) => void\n  /**\n   * Triggers when entities are added or removed from the collection.datasource.entities\n   */\n  onCollectionChanged?: (\n    collection: Cesium.EntityCollection,\n    addedArray: Array<Cesium.Entity>,\n    removedArray: Array<Cesium.Entity>,\n    changedArray: Array<Cesium.Entity>\n  ) => void\n  /**\n   * Triggerswhen the underlying data changes.\n   */\n  onChangedEvent?: (datasource: VcDatasource) => void\n  /**\n   * Triggers if an error is encountered during processing.\n   */\n  onErrorEvent?: (datasource: VcDatasource, error: any) => void\n  /**\n   * Triggers when the data source either starts or stops loading.\n   */\n  onLoadingEvent?: (datasource: VcDatasource, isLoading: boolean) => void\n}\n\nexport type VcDatasourceCustomRef = VcComponentPublicInstance<VcDatasourceCustomProps>\n\nexport interface VcDatasourceCustomSlots {\n  /**\n   * Slot for vc-entity.\n   */\n  default: () => VNode[]\n}\n"],"names":[],"mappings":";;;;;;;;;AAkBO,MAAM,qBAAwB,GAAA;AAAA,EACnC,GAAG,IAAA;AAAA,EACH,GAAG,gBAAA;AAAA,EACH,QAAU,EAAA;AAAA,IACR,IAAM,EAAA,KAAA;AAAA,IACN,OAAA,EAAS,MAAM,EAAC;AAAA,GAClB;AAAA,EACA,IAAM,EAAA,MAAA;AAAA,EACN,OAAS,EAAA;AAAA,IACP,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,KAAA;AAAA,GACX;AACF,EAAA;AACA,uBAAe,eAAgB,CAAA;AAAA,EAC7B,IAAM,EAAA,oBAAA;AAAA,EACN,KAAO,EAAA,qBAAA;AAAA,EACP,KAAO,EAAA,eAAA;AAAA,EACP,KAAA,CAAM,OAAgC,GAAK,EAAA;AAEzC,IAAA,MAAM,WAAW,kBAAmB,EAAA,CAAA;AACpC,IAAA,QAAA,CAAS,WAAc,GAAA,kBAAA,CAAA;AACvB,IAAe,cAAA,CAAA,KAAA,EAAO,KAAK,QAAQ,CAAA,CAAA;AAEnC,IAAA,QAAA,CAAS,qBAAqB,YAAY;AACxC,MAAA,OAAO,IAAI,MAAA,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