@cosmicds/vue-toolkit 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +20 -1
  2. package/dist/index.common.js +32528 -31853
  3. package/dist/index.umd.js +32527 -31844
  4. package/dist/index.umd.min.js +6 -4
  5. package/dist/src/background.d.ts +4 -0
  6. package/dist/src/components/CreditLogos.vue.d.ts +27 -2
  7. package/dist/src/components/FundingAcknowledgement.vue.d.ts +21 -0
  8. package/dist/src/components/Gallery.vue.d.ts +79 -2
  9. package/dist/src/components/GeolocationButton.vue.d.ts +132 -0
  10. package/dist/src/components/IconButton.vue.d.ts +130 -2
  11. package/dist/src/components/LocationSelector.vue.d.ts +139 -2
  12. package/dist/src/components/WwtHud.vue.d.ts +69 -0
  13. package/dist/src/composables.d.ts +25 -0
  14. package/dist/src/geolocation.d.ts +31 -0
  15. package/dist/src/index.d.ts +11 -8
  16. package/dist/src/keyboard.d.ts +35 -2
  17. package/dist/src/mapbox.d.ts +98 -0
  18. package/dist/src/stories/CreditLogos.stories.d.ts +6 -0
  19. package/dist/src/stories/FundingAcknowledgement.stories.d.ts +6 -0
  20. package/dist/src/stories/Gallery.stories.d.ts +6 -0
  21. package/dist/src/stories/IconButton.stories.d.ts +6 -0
  22. package/dist/src/stories/LocationSelector.stories.d.ts +6 -0
  23. package/dist/src/stories/WwtHud.stories.d.ts +6 -0
  24. package/dist/src/types.d.ts +241 -0
  25. package/dist/src/utils.d.ts +27 -1
  26. package/dist/src/wwt-utils.d.ts +11 -0
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +32 -4
  29. package/src/background.ts +4 -0
  30. package/src/composables.ts +69 -0
  31. package/src/geolocation.ts +122 -0
  32. package/src/index.ts +23 -15
  33. package/src/keyboard.ts +39 -5
  34. package/src/mapbox.ts +227 -0
  35. package/src/types.ts +271 -0
  36. package/src/utils.ts +54 -1
  37. package/src/wwt-utils.ts +57 -0
  38. package/dist/index.common.js.map +0 -1
  39. package/dist/index.umd.js.map +0 -1
  40. package/dist/index.umd.min.js.map +0 -1
  41. package/dist/src/components/DefaultMiniCredits.vue.d.ts +0 -3
  42. package/dist/src/components/FundingAcknowledgment.vue.d.ts +0 -3
  43. package/dist/src/components/MiniDSBase.d.ts +0 -373
  44. package/dist/src/components/wwtHUD.vue.d.ts +0 -3
@@ -0,0 +1,57 @@
1
+ import { engineStore } from "@wwtelescope/engine-pinia";
2
+ import { KeyboardControlSettings } from "./keyboard";
3
+ type WWTEngineStore = ReturnType<typeof engineStore>;
4
+
5
+ function doZoom(store: WWTEngineStore, zoomIn: boolean) {
6
+ const factor = zoomIn ? 1 / 1.3 : 1.3;
7
+ store.zoom(factor);
8
+ }
9
+
10
+ function doMove(store: WWTEngineStore, x: number, y: number) {
11
+ store.move({ x, y });
12
+ }
13
+
14
+ /**
15
+ * A composable that sets up WWT keyboard controls.
16
+ * @param store The WWT engine's Pinia store
17
+ * @param element The element on which to attach the keyboard listeners. Uses the browser window if none is given
18
+ * @returns The `KeyboardControlSettings` instance that was used to create the listeners
19
+ */
20
+ export function useWWTKeyboardControls(store: WWTEngineStore, element?: Window | HTMLElement): KeyboardControlSettings {
21
+ const root = element || window;
22
+ const kcs = new KeyboardControlSettings({});
23
+ root.addEventListener(
24
+ "keydown",
25
+ kcs.makeListener("zoomIn", () => doZoom(store, true)) as EventListener
26
+ );
27
+ root.addEventListener(
28
+ "keydown",
29
+ kcs.makeListener("zoomOut", () => doZoom(store, false)) as EventListener
30
+ );
31
+ root.addEventListener(
32
+ "keydown",
33
+ kcs.makeListener("moveUp", () =>
34
+ doMove(store, 0, kcs.moveAmount)
35
+ ) as EventListener
36
+ );
37
+ root.addEventListener(
38
+ "keydown",
39
+ kcs.makeListener("moveDown", () =>
40
+ doMove(store, 0, -kcs.moveAmount)
41
+ ) as EventListener
42
+ );
43
+ root.addEventListener(
44
+ "keydown",
45
+ kcs.makeListener("moveLeft", () =>
46
+ doMove(store, kcs.moveAmount, 0)
47
+ ) as EventListener
48
+ );
49
+ root.addEventListener(
50
+ "keydown",
51
+ kcs.makeListener("moveRight", () =>
52
+ doMove(store, -kcs.moveAmount, 0)
53
+ ) as EventListener
54
+ );
55
+
56
+ return kcs;
57
+ }