You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @Author: Caven
  3. * @Date: 2021-03-13 13:15:38
  4. */
  5. import * as turf from '@turf/turf'
  6. const install = function(DC) {
  7. if (!DC) {
  8. throw new Error('Missing DC Base Package')
  9. }
  10. /**
  11. * start
  12. */
  13. DC.ready = callback => {
  14. try {
  15. if (!DC.Initialized) {
  16. // load components
  17. DC.init(() => {
  18. try {
  19. DC.Namespace['turf'] = turf
  20. DC.mixin(require('./src/components.js').default)
  21. DC.Initialized = true
  22. callback && callback()
  23. } catch (e) {
  24. // eslint-disable-next-line no-console
  25. console.error(e)
  26. DC.Initialized = false
  27. }
  28. })
  29. } else {
  30. callback && callback()
  31. }
  32. } catch (e) {
  33. // eslint-disable-next-line no-console
  34. console.error(e)
  35. DC.Initialized = false
  36. throw e
  37. }
  38. }
  39. }
  40. /* istanbul ignore if */
  41. if (typeof window !== 'undefined' && window.DC) {
  42. install(window.DC)
  43. }
  44. export default {
  45. version: __VERSION__,
  46. compile_time: __TIME__,
  47. install
  48. }