@navaramap/core 0.0.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 (67) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +3 -0
  3. package/dist/index.d.ts +605 -0
  4. package/dist/index.js +3042 -0
  5. package/dist/index.umd.cjs +1 -0
  6. package/package.json +38 -0
  7. package/src/abstracts/index.ts +1 -0
  8. package/src/abstracts/vec3.ts +15 -0
  9. package/src/assertions.ts +15 -0
  10. package/src/batch/attribute.test.ts +20 -0
  11. package/src/batch/attribute.ts +14 -0
  12. package/src/batch/index.ts +1 -0
  13. package/src/color/Color.ts +10 -0
  14. package/src/color/ColorMap.ts +86 -0
  15. package/src/color/index.ts +3 -0
  16. package/src/color/types.ts +4 -0
  17. package/src/constants/image.ts +1 -0
  18. package/src/constants/index.ts +1 -0
  19. package/src/error.ts +11 -0
  20. package/src/event/EventManager.test.ts +539 -0
  21. package/src/event/EventManager.ts +387 -0
  22. package/src/event/TransactionManager.test.ts +126 -0
  23. package/src/event/TransactionManager.ts +78 -0
  24. package/src/event/index.ts +2 -0
  25. package/src/event/mock.ts +36 -0
  26. package/src/eventHandler.ts +52 -0
  27. package/src/globe/Globe.ts +156 -0
  28. package/src/globe/index.ts +1 -0
  29. package/src/id.ts +9 -0
  30. package/src/index.ts +15 -0
  31. package/src/namedIndexMap.test.ts +268 -0
  32. package/src/namedIndexMap.ts +50 -0
  33. package/src/observed.ts +30 -0
  34. package/src/plugin.ts +15 -0
  35. package/src/time.ts +3 -0
  36. package/src/types/buffer.ts +4 -0
  37. package/src/types/camera.ts +16 -0
  38. package/src/types/cameraFrustum.ts +5 -0
  39. package/src/types/feature.ts +1 -0
  40. package/src/types/index.ts +13 -0
  41. package/src/types/layer.ts +1 -0
  42. package/src/types/plane.ts +5 -0
  43. package/src/types/ray.ts +5 -0
  44. package/src/types/tile.ts +1 -0
  45. package/src/types/transform.ts +5 -0
  46. package/src/types/unit.ts +7 -0
  47. package/src/types/utils.ts +20 -0
  48. package/src/types/vec.ts +9 -0
  49. package/src/types/window.ts +5 -0
  50. package/src/utils/ExtentRadianF32Like.ts +17 -0
  51. package/src/utils/FloatAttributeLike.ts +17 -0
  52. package/src/utils/ReturnedConstructedTerrainMeshLike.ts +92 -0
  53. package/src/utils/TransferableMartiniLike.ts +21 -0
  54. package/src/utils/TransferableRasterDEMDataLike.ts +36 -0
  55. package/src/utils/TransferableTileLike.ts +53 -0
  56. package/src/utils/UpsamplableTerrainGeometryLike.ts +26 -0
  57. package/src/utils/Vec3Like.ts +15 -0
  58. package/src/utils/index.ts +9 -0
  59. package/src/utils/polygon/ConstructedPolygonGeometryLike.ts +70 -0
  60. package/src/utils/polygon/PolygonMaterialLike.ts +37 -0
  61. package/src/utils/polygon/TransferablePolygonBatchedFeatureLike.ts +73 -0
  62. package/src/utils/polygon/index.ts +3 -0
  63. package/src/utils/polyline/ConstructedPolylineGeometryLike.ts +77 -0
  64. package/src/utils/polyline/PolylineMaterialLike.ts +31 -0
  65. package/src/utils/polyline/TransferablePolylineBatchedFeatureLike.ts +43 -0
  66. package/src/utils/polyline/index.ts +3 -0
  67. package/src/vite-env.d.ts +1 -0
@@ -0,0 +1,156 @@
1
+ import type { Globe as GlobeWasm } from "@navaramap/engine";
2
+
3
+ import { ColorMap, Color } from "../color";
4
+ import type { RemoveFreeRecursively } from "../types";
5
+ /**
6
+ * Handler for accessing individual Globe properties from WASM.
7
+ * This provides a reference-based interface instead of copying the entire Globe object.
8
+ */
9
+ export type GlobeHandler = {
10
+ getTransparent: () => boolean | undefined;
11
+ getMaxSse: () => number | undefined;
12
+ getSegments: () => number | undefined;
13
+ getColor: () => Color | undefined;
14
+ getHideUnderground: () => boolean | undefined;
15
+ getUseNormal: () => boolean | undefined;
16
+ getOpacity: () => number | undefined;
17
+ getWireframe: () => boolean | undefined;
18
+ getElevationColormap: () => Float32Array | undefined;
19
+ setTransparent: (value: boolean) => void;
20
+ setMaxSse: (value: number) => void;
21
+ setSegments: (value: number) => void;
22
+ setColor: (value: Color) => void;
23
+ setHideUnderground: (value: boolean) => void;
24
+ setUseNormal: (value: boolean) => void;
25
+ setOpacity: (value: number) => void;
26
+ setWireframe: (value: boolean) => void;
27
+ setElevationColormap: (value: ColorMap) => void;
28
+ };
29
+
30
+ export type GlobeOptions = Partial<
31
+ Omit<GlobeWasm, "constructor" | "free" | "elevationColormap" | "color">
32
+ > & {
33
+ elevationColormap?: ColorMap;
34
+ color?: Color;
35
+ };
36
+
37
+ /**
38
+ * Globe configuration manager.
39
+ *
40
+ * Provides an interface for accessing and modifying globe properties
41
+ * that are shared across different material types (VectorTile, RasterTile, RasterTerrain).
42
+ */
43
+ export class Globe implements Omit<
44
+ RemoveFreeRecursively<GlobeWasm>,
45
+ "elevationColormap" | "color"
46
+ > {
47
+ private handler: GlobeHandler;
48
+ private _elevationColormap?: ColorMap;
49
+
50
+ constructor(handler: GlobeHandler, options?: GlobeOptions) {
51
+ this.handler = handler;
52
+ this.setOptions(options);
53
+ }
54
+
55
+ setOptions(options?: GlobeOptions) {
56
+ if (options?.maxSse != null) {
57
+ this.maxSse = options.maxSse;
58
+ }
59
+ if (options?.segments != null) {
60
+ this.segments = options.segments;
61
+ }
62
+ if (options?.color != null) {
63
+ this.color = options.color;
64
+ }
65
+ if (options?.hideUnderground != null) {
66
+ this.hideUnderground = options.hideUnderground;
67
+ }
68
+ if (options?.useNormal != null) {
69
+ this.useNormal = options.useNormal;
70
+ }
71
+ if (options?.transparent != null) {
72
+ this.transparent = options.transparent;
73
+ }
74
+ if (options?.opacity != null) {
75
+ this.opacity = options.opacity;
76
+ }
77
+ if (options?.wireframe != null) {
78
+ this.wireframe = options.wireframe;
79
+ }
80
+ if (options?.elevationColormap != null) {
81
+ this.elevationColormap = options.elevationColormap;
82
+ }
83
+ }
84
+
85
+ get maxSse(): number {
86
+ return this.handler.getMaxSse() ?? 2.0;
87
+ }
88
+
89
+ set maxSse(value: number) {
90
+ this.handler.setMaxSse(value);
91
+ }
92
+
93
+ get segments(): number {
94
+ return this.handler.getSegments() ?? 64;
95
+ }
96
+ set segments(value: number) {
97
+ this.handler.setSegments(value);
98
+ }
99
+
100
+ get color(): Color | undefined {
101
+ return this.handler.getColor();
102
+ }
103
+
104
+ set color(value: Color) {
105
+ this.handler.setColor(value);
106
+ }
107
+
108
+ get hideUnderground(): boolean {
109
+ return this.handler.getHideUnderground() ?? true;
110
+ }
111
+
112
+ set hideUnderground(value: boolean) {
113
+ this.handler.setHideUnderground(value);
114
+ }
115
+
116
+ get useNormal(): boolean {
117
+ return this.handler.getUseNormal() ?? false;
118
+ }
119
+
120
+ set useNormal(value: boolean) {
121
+ this.handler.setUseNormal(value);
122
+ }
123
+
124
+ get transparent(): boolean {
125
+ return this.handler.getTransparent() ?? false;
126
+ }
127
+
128
+ set transparent(value: boolean) {
129
+ this.handler.setTransparent(value);
130
+ }
131
+
132
+ get opacity(): number {
133
+ return this.handler.getOpacity() ?? 1.0;
134
+ }
135
+
136
+ set opacity(value: number) {
137
+ this.handler.setOpacity(value);
138
+ }
139
+
140
+ get wireframe(): boolean {
141
+ return this.handler.getWireframe() ?? false;
142
+ }
143
+
144
+ set wireframe(value: boolean) {
145
+ this.handler.setWireframe(value);
146
+ }
147
+
148
+ get elevationColormap(): ColorMap | undefined {
149
+ return this._elevationColormap;
150
+ }
151
+
152
+ set elevationColormap(value: ColorMap) {
153
+ this._elevationColormap = value;
154
+ this.handler.setElevationColormap(value);
155
+ }
156
+ }
@@ -0,0 +1 @@
1
+ export * from "./Globe";
package/src/id.ts ADDED
@@ -0,0 +1,9 @@
1
+ import type { EntityEvent } from "@navaramap/engine";
2
+
3
+ export function generate_id_from_entity(entity: EntityEvent) {
4
+ return `${entity.ind}_${entity.gen}`;
5
+ }
6
+
7
+ export function isEntityEvent(v: unknown): v is EntityEvent {
8
+ return !!v && typeof v === "object" && "ind" in v && "gen" in v;
9
+ }
package/src/index.ts ADDED
@@ -0,0 +1,15 @@
1
+ export * from "./id";
2
+ export * from "./event";
3
+ export * from "./assertions";
4
+ export * from "./utils";
5
+ export * from "./constants";
6
+ export * from "./eventHandler";
7
+ export * from "./batch";
8
+ export * from "./error";
9
+ export * from "./types";
10
+ export * from "./namedIndexMap";
11
+ export * from "./observed";
12
+ export * from "./abstracts";
13
+ export * from "./color";
14
+ export * from "./globe";
15
+ export * from "./plugin";
@@ -0,0 +1,268 @@
1
+ import { describe, it, expect, beforeEach } from "vitest";
2
+
3
+ import { NamedIndexMap } from "./namedIndexMap";
4
+
5
+ type TestItem = {
6
+ name: string;
7
+ value: number;
8
+ };
9
+
10
+ describe("NamedIndexMap", () => {
11
+ let map: NamedIndexMap<TestItem>;
12
+
13
+ beforeEach(() => {
14
+ map = new NamedIndexMap<TestItem>();
15
+ });
16
+
17
+ describe("add", () => {
18
+ it("should add items to the list and indexMap", () => {
19
+ const item1 = { name: "first", value: 1 };
20
+ const item2 = { name: "second", value: 2 };
21
+
22
+ map.add(item1);
23
+ map.add(item2);
24
+
25
+ expect(map.list).toEqual([item1, item2]);
26
+ expect(map.indexMap).toEqual({ first: 0, second: 1 });
27
+ });
28
+
29
+ it("should throw error for duplicate names", () => {
30
+ const item1 = { name: "duplicate", value: 1 };
31
+ const item2 = { name: "duplicate", value: 2 };
32
+
33
+ map.add(item1);
34
+ expect(() => map.add(item2)).toThrow("duplicate name: duplicate");
35
+ });
36
+ });
37
+
38
+ describe("insertBefore", () => {
39
+ beforeEach(() => {
40
+ map.add({ name: "first", value: 1 });
41
+ map.add({ name: "second", value: 2 });
42
+ map.add({ name: "third", value: 3 });
43
+ });
44
+
45
+ it("should insert item before target", () => {
46
+ const newItem = { name: "new", value: 10 };
47
+ map.insertBefore("second", newItem);
48
+
49
+ expect(map.list.map((item) => item.name)).toEqual([
50
+ "first",
51
+ "new",
52
+ "second",
53
+ "third",
54
+ ]);
55
+ expect(map.indexMap).toEqual({ first: 0, new: 1, second: 2, third: 3 });
56
+ });
57
+
58
+ it("should insert before first item", () => {
59
+ const newItem = { name: "new", value: 10 };
60
+ map.insertBefore("first", newItem);
61
+
62
+ expect(map.list.map((item) => item.name)).toEqual([
63
+ "new",
64
+ "first",
65
+ "second",
66
+ "third",
67
+ ]);
68
+ expect(map.indexMap).toEqual({ new: 0, first: 1, second: 2, third: 3 });
69
+ });
70
+
71
+ it("should throw error for non-existent target", () => {
72
+ const newItem = { name: "new", value: 10 };
73
+ expect(() => map.insertBefore("nonexistent", newItem)).toThrow(
74
+ "target not found: nonexistent",
75
+ );
76
+ });
77
+
78
+ it("should throw error for duplicate name", () => {
79
+ const newItem = { name: "first", value: 10 };
80
+ expect(() => map.insertBefore("second", newItem)).toThrow(
81
+ "duplicate name: first",
82
+ );
83
+ });
84
+ });
85
+
86
+ describe("insertAfter", () => {
87
+ beforeEach(() => {
88
+ map.add({ name: "first", value: 1 });
89
+ map.add({ name: "second", value: 2 });
90
+ map.add({ name: "third", value: 3 });
91
+ });
92
+
93
+ it("should insert item after target", () => {
94
+ const newItem = { name: "new", value: 10 };
95
+ map.insertAfter("second", newItem);
96
+
97
+ expect(map.list.map((item) => item.name)).toEqual([
98
+ "first",
99
+ "second",
100
+ "new",
101
+ "third",
102
+ ]);
103
+ expect(map.indexMap).toEqual({ first: 0, second: 1, new: 2, third: 3 });
104
+ });
105
+
106
+ it("should insert after last item", () => {
107
+ const newItem = { name: "new", value: 10 };
108
+ map.insertAfter("third", newItem);
109
+
110
+ expect(map.list.map((item) => item.name)).toEqual([
111
+ "first",
112
+ "second",
113
+ "third",
114
+ "new",
115
+ ]);
116
+ expect(map.indexMap).toEqual({ first: 0, second: 1, third: 2, new: 3 });
117
+ });
118
+
119
+ it("should throw error for non-existent target", () => {
120
+ const newItem = { name: "new", value: 10 };
121
+ expect(() => map.insertAfter("nonexistent", newItem)).toThrow(
122
+ "target not found: nonexistent",
123
+ );
124
+ });
125
+
126
+ it("should throw error for duplicate name", () => {
127
+ const newItem = { name: "second", value: 10 };
128
+ expect(() => map.insertAfter("first", newItem)).toThrow(
129
+ "duplicate name: second",
130
+ );
131
+ });
132
+ });
133
+
134
+ describe("insertAt", () => {
135
+ beforeEach(() => {
136
+ map.add({ name: "first", value: 1 });
137
+ map.add({ name: "second", value: 2 });
138
+ map.add({ name: "third", value: 3 });
139
+ });
140
+
141
+ it("should insert at beginning", () => {
142
+ const newItem = { name: "new", value: 10 };
143
+ (map as any).insertAt(0, newItem);
144
+
145
+ expect(map.list.map((item) => item.name)).toEqual([
146
+ "new",
147
+ "first",
148
+ "second",
149
+ "third",
150
+ ]);
151
+ expect(map.indexMap).toEqual({ new: 0, first: 1, second: 2, third: 3 });
152
+ });
153
+
154
+ it("should insert at middle", () => {
155
+ const newItem = { name: "new", value: 10 };
156
+ (map as any).insertAt(2, newItem);
157
+
158
+ expect(map.list.map((item) => item.name)).toEqual([
159
+ "first",
160
+ "second",
161
+ "new",
162
+ "third",
163
+ ]);
164
+ expect(map.indexMap).toEqual({ first: 0, second: 1, new: 2, third: 3 });
165
+ });
166
+
167
+ it("should insert at end", () => {
168
+ const newItem = { name: "new", value: 10 };
169
+ (map as any).insertAt(3, newItem);
170
+
171
+ expect(map.list.map((item) => item.name)).toEqual([
172
+ "first",
173
+ "second",
174
+ "third",
175
+ "new",
176
+ ]);
177
+ expect(map.indexMap).toEqual({ first: 0, second: 1, third: 2, new: 3 });
178
+ });
179
+
180
+ it("should throw error for negative index", () => {
181
+ const newItem = { name: "new", value: 10 };
182
+ expect(() => (map as any).insertAt(-1, newItem)).toThrow(
183
+ "index out of range: -1",
184
+ );
185
+ });
186
+
187
+ it("should throw error for index greater than length", () => {
188
+ const newItem = { name: "new", value: 10 };
189
+ expect(() => (map as any).insertAt(4, newItem)).toThrow(
190
+ "index out of range: 4",
191
+ );
192
+ });
193
+
194
+ it("should throw error for duplicate name", () => {
195
+ const newItem = { name: "first", value: 10 };
196
+ expect(() => (map as any).insertAt(1, newItem)).toThrow(
197
+ "duplicate name: first",
198
+ );
199
+ });
200
+ });
201
+
202
+ describe("findIndex", () => {
203
+ beforeEach(() => {
204
+ map.add({ name: "first", value: 1 });
205
+ map.add({ name: "second", value: 2 });
206
+ });
207
+
208
+ it("should return correct index for existing name", () => {
209
+ expect((map as any).findIndex("first")).toBe(0);
210
+ expect((map as any).findIndex("second")).toBe(1);
211
+ });
212
+
213
+ it("should throw error for non-existent name", () => {
214
+ expect(() => (map as any).findIndex("nonexistent")).toThrow(
215
+ "target not found: nonexistent",
216
+ );
217
+ });
218
+ });
219
+
220
+ describe("assertUnique", () => {
221
+ beforeEach(() => {
222
+ map.add({ name: "existing", value: 1 });
223
+ });
224
+
225
+ it("should not throw for unique name", () => {
226
+ expect(() => (map as any).assertUnique("unique")).not.toThrow();
227
+ });
228
+
229
+ it("should throw for duplicate name", () => {
230
+ expect(() => (map as any).assertUnique("existing")).toThrow(
231
+ "duplicate name: existing",
232
+ );
233
+ });
234
+ });
235
+
236
+ describe("edge cases", () => {
237
+ it("should handle empty map", () => {
238
+ expect(map.list).toEqual([]);
239
+ expect(map.indexMap).toEqual({});
240
+ });
241
+
242
+ it("should handle single item", () => {
243
+ const item = { name: "single", value: 1 };
244
+ map.add(item);
245
+
246
+ expect(map.list).toEqual([item]);
247
+ expect(map.indexMap).toEqual({ single: 0 });
248
+ });
249
+
250
+ it("should maintain correct indices after multiple insertions", () => {
251
+ map.add({ name: "a", value: 1 });
252
+ map.add({ name: "b", value: 2 });
253
+ map.add({ name: "c", value: 3 });
254
+
255
+ map.insertBefore("b", { name: "x", value: 10 });
256
+ map.insertAfter("c", { name: "y", value: 20 });
257
+
258
+ expect(map.list.map((item) => item.name)).toEqual([
259
+ "a",
260
+ "x",
261
+ "b",
262
+ "c",
263
+ "y",
264
+ ]);
265
+ expect(map.indexMap).toEqual({ a: 0, x: 1, b: 2, c: 3, y: 4 });
266
+ });
267
+ });
268
+ });
@@ -0,0 +1,50 @@
1
+ export class NamedIndexMap<T extends { name: string }> {
2
+ list: T[] = [];
3
+ indexMap: Record<string, number> = {};
4
+
5
+ add(v: T): void {
6
+ this.assertUnique(v.name);
7
+ const idx = this.list.length;
8
+ this.list.push(v);
9
+ this.indexMap[v.name] = idx;
10
+ }
11
+
12
+ insertBefore(targetName: string, v: T): number {
13
+ const idx = this.findIndex(targetName);
14
+ return this.insertAt(idx, v);
15
+ }
16
+
17
+ insertAfter(targetName: string, v: T): number {
18
+ const idx = this.findIndex(targetName);
19
+ return this.insertAt(idx + 1, v);
20
+ }
21
+
22
+ private insertAt(index: number, v: T): number {
23
+ this.assertUnique(v.name);
24
+ if (index < 0 || index > this.list.length) {
25
+ throw new RangeError(`index out of range: ${index}`);
26
+ }
27
+
28
+ this.list.splice(index, 0, v);
29
+
30
+ for (let i = index; i < this.list.length; i++) {
31
+ this.indexMap[this.list[i].name] = i;
32
+ }
33
+
34
+ return index;
35
+ }
36
+
37
+ private findIndex(name: string): number {
38
+ const idx = this.indexMap[name];
39
+ if (idx === undefined) {
40
+ throw new Error(`target not found: ${name}`);
41
+ }
42
+ return idx;
43
+ }
44
+
45
+ private assertUnique(name: string): void {
46
+ if (this.indexMap[name] !== undefined) {
47
+ throw new Error(`duplicate name: ${name}`);
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,30 @@
1
+ import { EventHandler } from "./eventHandler";
2
+
3
+ export type ObservedEvent<T> = {
4
+ changed: (v: T) => void;
5
+ };
6
+
7
+ export class Observed<T> extends EventHandler<ObservedEvent<T>> {
8
+ private _value: T;
9
+ constructor(v: T) {
10
+ super();
11
+ this._value = v;
12
+ }
13
+
14
+ get value() {
15
+ return this._value;
16
+ }
17
+
18
+ set value(v: T) {
19
+ this._value = v;
20
+ this.emit("changed", v);
21
+ }
22
+
23
+ changed(f: (v: T) => void) {
24
+ const wrap = (v: T) => {
25
+ f(v);
26
+ this.off("changed", wrap);
27
+ };
28
+ this.on("changed", wrap);
29
+ }
30
+ }
package/src/plugin.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Base `Plugin` abstract class.
3
+ * This class doesn't have a logic, but has interfaces.
4
+ * ```
5
+ * class MyPlugin extends Plugin<ThreeView<MyCustomDescriptions>, ViewContext> {
6
+ * async init(view, ctx) {
7
+ * // ...
8
+ * }
9
+ * }
10
+ * ```
11
+ */
12
+ // DO NOT add a logic to this class as much as possible.
13
+ export abstract class Plugin<TView = unknown, TCtx = unknown> {
14
+ abstract init(view: TView, ctx: TCtx): Promise<void>;
15
+ }
package/src/time.ts ADDED
@@ -0,0 +1,3 @@
1
+ export function wait(t: number) {
2
+ return new Promise((r) => setTimeout(r, t));
3
+ }
@@ -0,0 +1,4 @@
1
+ export type TypedArrayLike = {
2
+ [index: number]: number;
3
+ readonly length: number;
4
+ };
@@ -0,0 +1,16 @@
1
+ import type { CameraOrientation as EngineCameraOrientation } from "@navaramap/engine";
2
+
3
+ import type { LatLngHeight } from "./unit";
4
+ import type { NormalizeWASMClass } from "./utils";
5
+
6
+ export type CameraOrientation = Partial<
7
+ NormalizeWASMClass<EngineCameraOrientation>
8
+ >;
9
+
10
+ export type CameraPosition = Partial<LatLngHeight> &
11
+ CameraOrientation & {
12
+ /** Distance from the target point (lng/lat/height) along the camera forward direction (meters).
13
+ * When specified, the camera is placed so its forward ray reaches the target point from this distance.
14
+ * If `height` is omitted, the target elevation defaults to 0 (sea level). */
15
+ distance?: number;
16
+ };
@@ -0,0 +1,5 @@
1
+ import type { CameraFrustum as EngineCameraFrustum } from "@navaramap/engine-api";
2
+
3
+ import type { NormalizeWASMClass } from "./utils";
4
+
5
+ export type CameraFrustum = Required<NormalizeWASMClass<EngineCameraFrustum>>;
@@ -0,0 +1 @@
1
+ export type FeatureSetId = bigint;
@@ -0,0 +1,13 @@
1
+ export * from "./buffer";
2
+ export * from "./feature";
3
+ export * from "./tile";
4
+ export * from "./camera";
5
+ export * from "./utils";
6
+ export * from "./unit";
7
+ export * from "./window";
8
+ export * from "./transform";
9
+ export * from "./cameraFrustum";
10
+ export * from "./plane";
11
+ export * from "./ray";
12
+ export * from "./vec";
13
+ export * from "./layer";
@@ -0,0 +1 @@
1
+ export type LayerId = string;
@@ -0,0 +1,5 @@
1
+ import type { Plane as EnginePlane } from "@navaramap/engine-api";
2
+
3
+ import type { NormalizeWASMClass } from "./utils";
4
+
5
+ export type Plane = Required<NormalizeWASMClass<EnginePlane>>;
@@ -0,0 +1,5 @@
1
+ import type { Ray as EngineRay } from "@navaramap/engine-api";
2
+
3
+ import type { NormalizeWASMClass } from "./utils";
4
+
5
+ export type Ray = Required<NormalizeWASMClass<EngineRay>>;
@@ -0,0 +1 @@
1
+ export type TileHandle = bigint;
@@ -0,0 +1,5 @@
1
+ import type { Transform as EngineTransform } from "@navaramap/engine-api";
2
+
3
+ import type { NormalizeWASMClass } from "./utils";
4
+
5
+ export type Transform = Required<NormalizeWASMClass<EngineTransform>>;
@@ -0,0 +1,7 @@
1
+ import type { LLE } from "@navaramap/engine";
2
+
3
+ import type { NormalizeWASMClass } from "./utils";
4
+
5
+ export type XYZ = { x: number; y: number; z: number };
6
+ export type LatLngHeight = Required<NormalizeWASMClass<LLE>>;
7
+ export type LatLng = Omit<LatLngHeight, "height">;
@@ -0,0 +1,20 @@
1
+ export type Nullable<T> = T | null | undefined;
2
+
3
+ export type RemoveFreeRecursively<T> = T extends { free: unknown }
4
+ ? {
5
+ [K in keyof T as K extends "free" | symbol | number
6
+ ? never
7
+ : K]: RemoveFreeRecursively<T[K]>;
8
+ }
9
+ : T;
10
+
11
+ // wasm-bindgen generate a getter and setter, so need to extract it as a property.
12
+ export type ExtractProperties<T> = {
13
+ [K in keyof T]?: T[K] extends (...args: any) => any
14
+ ? ReturnType<T[K]> extends (...args: any) => any
15
+ ? ExtractProperties<ReturnType<T[K]>>
16
+ : ReturnType<T[K]>
17
+ : Partial<T[K]>;
18
+ };
19
+
20
+ export type NormalizeWASMClass<C> = ExtractProperties<RemoveFreeRecursively<C>>;
@@ -0,0 +1,9 @@
1
+ import type {
2
+ Vec2 as EngineVec2,
3
+ Vec3 as EngineVec3,
4
+ } from "@navaramap/engine-api";
5
+
6
+ import type { NormalizeWASMClass } from "./utils";
7
+
8
+ export type Vec2 = Required<NormalizeWASMClass<EngineVec2>>;
9
+ export type Vec3 = Required<NormalizeWASMClass<EngineVec3>>;
@@ -0,0 +1,5 @@
1
+ import type { Window as EngineWindow } from "@navaramap/engine";
2
+
3
+ import type { NormalizeWASMClass } from "./utils";
4
+
5
+ export type Window = Required<NormalizeWASMClass<EngineWindow>>;