@craft-native/ts-maps 0.0.92 → 0.0.94
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.
- package/dist/FilesystemTileBackend.d.ts +47 -0
- package/dist/FilesystemTileBackend.d.ts.map +1 -0
- package/dist/MapView.d.ts +91 -0
- package/dist/MapView.d.ts.map +1 -0
- package/dist/adapters.d.ts +60 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +18451 -0
- package/dist/bridge-protocol.d.ts +100 -0
- package/dist/bridge-protocol.d.ts.map +1 -0
- package/dist/bridge-protocol.js +17 -0
- package/dist/capabilities.d.ts +44 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20190 -0
- package/dist/offlineRegion.d.ts +60 -0
- package/dist/offlineRegion.d.ts.map +1 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +53 -0
- package/package.json +1 -1
- package/LICENSE.md +0 -21
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared protocol constants and types for the bridge between the Zig
|
|
3
|
+
* `MapView` core and the ts-maps runtime.
|
|
4
|
+
*
|
|
5
|
+
* @module @craft-native/ts-maps/bridge-protocol
|
|
6
|
+
*/
|
|
7
|
+
import type { Coordinate, MapCamera, MapCircle, MapConfiguration, MapMarker, MapPolygon, MapPolyline, MapRegion } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Namespace used when emitting and listening for bridge messages. Matches
|
|
10
|
+
* the Zig enum tag for `MapProvider.ts_maps`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const BRIDGE_NAMESPACE: 'ts_maps';
|
|
13
|
+
/** Method names the Zig core can invoke on the TypeScript side. */
|
|
14
|
+
export type MapBridgeMethod = 'setCamera' | 'setRegion' | 'addMarker' | 'removeMarker' | 'addPolyline' | 'addPolygon' | 'addCircle' | 'fitToMarkers' | 'selectMarker' | 'deselectAll' | 'setConfiguration';
|
|
15
|
+
/**
|
|
16
|
+
* Typed request envelope. The `method` discriminates the `params` shape.
|
|
17
|
+
* The union below gives per-method type narrowing.
|
|
18
|
+
*/
|
|
19
|
+
export interface MapBridgeRequest {
|
|
20
|
+
method: MapBridgeMethod;
|
|
21
|
+
params: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/** Strongly typed request variants for each supported method. */
|
|
24
|
+
export type TypedMapBridgeRequest = {
|
|
25
|
+
method: 'setCamera';
|
|
26
|
+
params: {
|
|
27
|
+
camera: MapCamera;
|
|
28
|
+
animated?: boolean;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
method: 'setRegion';
|
|
32
|
+
params: {
|
|
33
|
+
region: MapRegion;
|
|
34
|
+
animated?: boolean;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
method: 'addMarker';
|
|
38
|
+
params: {
|
|
39
|
+
marker: MapMarker;
|
|
40
|
+
};
|
|
41
|
+
} | {
|
|
42
|
+
method: 'removeMarker';
|
|
43
|
+
params: {
|
|
44
|
+
id: number;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
method: 'addPolyline';
|
|
48
|
+
params: {
|
|
49
|
+
polyline: MapPolyline;
|
|
50
|
+
};
|
|
51
|
+
} | {
|
|
52
|
+
method: 'addPolygon';
|
|
53
|
+
params: {
|
|
54
|
+
polygon: MapPolygon;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
method: 'addCircle';
|
|
58
|
+
params: {
|
|
59
|
+
circle: MapCircle;
|
|
60
|
+
};
|
|
61
|
+
} | {
|
|
62
|
+
method: 'fitToMarkers';
|
|
63
|
+
params: {
|
|
64
|
+
padding?: number;
|
|
65
|
+
};
|
|
66
|
+
} | {
|
|
67
|
+
method: 'selectMarker';
|
|
68
|
+
params: {
|
|
69
|
+
id: number;
|
|
70
|
+
};
|
|
71
|
+
} | {
|
|
72
|
+
method: 'deselectAll';
|
|
73
|
+
params: Record<string, never>;
|
|
74
|
+
} | {
|
|
75
|
+
method: 'setConfiguration';
|
|
76
|
+
params: {
|
|
77
|
+
configuration: MapConfiguration;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/** Events emitted by the ts-maps runtime back to the Zig core. */
|
|
81
|
+
export type MapBridgeEvent = {
|
|
82
|
+
type: 'tap';
|
|
83
|
+
coordinate: Coordinate;
|
|
84
|
+
} | {
|
|
85
|
+
type: 'markerTap';
|
|
86
|
+
markerId: number;
|
|
87
|
+
coordinate: Coordinate;
|
|
88
|
+
} | {
|
|
89
|
+
type: 'regionChanged';
|
|
90
|
+
region: MapRegion;
|
|
91
|
+
} | {
|
|
92
|
+
type: 'cameraChanged';
|
|
93
|
+
camera: MapCamera;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Build the full event name used on the bridge (e.g. `map:tap`).
|
|
97
|
+
* Centralized so both sides agree on the exact string.
|
|
98
|
+
*/
|
|
99
|
+
export declare function mapEventName(type: MapBridgeEvent['type']): string;
|
|
100
|
+
//# sourceMappingURL=bridge-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-protocol.d.ts","sourceRoot":"","sources":["../../../src/bridge-protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,WAAW,EACX,SAAS,EACV,MAAM,YAAY,CAAA;AAEnB;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAG,SAAkB,CAAA;AAElD,mEAAmE;AACnE,MAAM,MAAM,eAAe,GACvB,WAAW,GACX,WAAW,GACX,WAAW,GACX,cAAc,GACd,aAAa,GACb,YAAY,GACZ,WAAW,GACX,cAAc,GACd,cAAc,GACd,aAAa,GACb,kBAAkB,CAAA;AAEtB;;;GAGG;AACH,MAAM,W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AE,KAAK,CAAC,CAAA;CAAE,GACxD;IAAE,MAAM,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE;QAAE,aAAa,EAAE,gBAAgB,CAAA;KAAE,CAAA;CAAE,CAAA;AAE/E,kEAAkE;AAClE,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,GAC/D;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAAE,CAAA;AAEhD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,MAAM,CAEjE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/bridge-protocol.ts
|
|
10
|
+
var BRIDGE_NAMESPACE = "ts_maps";
|
|
11
|
+
function mapEventName(type) {
|
|
12
|
+
return `map:${type}`;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
mapEventName,
|
|
16
|
+
BRIDGE_NAMESPACE
|
|
17
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime capability probe for Craft apps hosting `ts-maps` inside a
|
|
3
|
+
* WebView. The map renderer prefers WebGL2 and falls back to Canvas2D
|
|
4
|
+
* when it isn't available; this helper exposes the probe so the host
|
|
5
|
+
* app can pick the right renderer up front (and surface the decision to
|
|
6
|
+
* users on older devices).
|
|
7
|
+
*
|
|
8
|
+
* All checks are side-effect-free and safe to call during render: the
|
|
9
|
+
* probe creates a throw-away canvas, asks for the relevant context, and
|
|
10
|
+
* discards it.
|
|
11
|
+
*
|
|
12
|
+
* @module @craft-native/ts-maps/capabilities
|
|
13
|
+
*/
|
|
14
|
+
export interface MapRendererCapabilities {
|
|
15
|
+
/** WebGL2 context is obtainable. */
|
|
16
|
+
webgl2: boolean;
|
|
17
|
+
/** WebGL1 context is obtainable (fallback). */
|
|
18
|
+
webgl1: boolean;
|
|
19
|
+
/** `OffscreenCanvas` exists on the global scope. */
|
|
20
|
+
offscreenCanvas: boolean;
|
|
21
|
+
/** `navigator.hardwareConcurrency` — tile-worker parallelism hint. */
|
|
22
|
+
hardwareConcurrency: number;
|
|
23
|
+
/** `window.devicePixelRatio` — retina-like displays report >1. */
|
|
24
|
+
devicePixelRatio: number;
|
|
25
|
+
/** Pointer events are supported (required for the two-finger gestures). */
|
|
26
|
+
pointerEvents: boolean;
|
|
27
|
+
/** Touch events are supported (used as a pointer-event fallback). */
|
|
28
|
+
touchEvents: boolean;
|
|
29
|
+
/** Best renderer given the probe result. */
|
|
30
|
+
preferredRenderer: 'webgl' | 'canvas2d';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Probe the host runtime. Safe to call in any environment — when neither
|
|
34
|
+
* `window` nor `document` is available (Node / SSR) the probe returns a
|
|
35
|
+
* conservative zero-capabilities object.
|
|
36
|
+
*/
|
|
37
|
+
export declare function probeCapabilities(): MapRendererCapabilities;
|
|
38
|
+
/**
|
|
39
|
+
* True when the probe thinks this host can run the WebGL-backed renderer
|
|
40
|
+
* comfortably. Callers typically use this to gate advanced features like
|
|
41
|
+
* fill-extrusion or hillshade on cheap older phones.
|
|
42
|
+
*/
|
|
43
|
+
export declare function supportsAdvancedRendering(caps?: MapRendererCapabilities): boolean;
|
|
44
|
+
//# sourceMappingURL=capabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,uBAAuB;IACtC,oCAAoC;IACpC,MAAM,EAAE,OAAO,CAAA;IACf,+CAA+C;IAC/C,MAAM,EAAE,OAAO,CAAA;IACf,oDAAoD;IACpD,eAAe,EAAE,OAAO,CAAA;IACxB,sEAAsE;IACtE,mBAAmB,EAAE,MAAM,CAAA;IAC3B,kEAAkE;IAClE,gBAAgB,EAAE,MAAM,CAAA;IACxB,2EAA2E;IAC3E,aAAa,EAAE,OAAO,CAAA;IACtB,qEAAqE;IACrE,WAAW,EAAE,OAAO,CAAA;IACpB,4CAA4C;IAC5C,iBAAiB,EAAE,OAAO,GAAG,UAAU,CAAA;CACxC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,uBAAuB,CAkD3D;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAGjF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@craft-native/ts-maps` — SDK binding that lets Craft apps render
|
|
3
|
+
* interactive maps via the in-house `ts-maps` runtime. Pairs with the
|
|
4
|
+
* `MapProvider.ts_maps` variant in `packages/zig/src/maps.zig`.
|
|
5
|
+
*
|
|
6
|
+
* Re-exports the full ts-maps public API plus Craft-native helpers
|
|
7
|
+
* (`createMapView`, type mirrors, adapters, bridge protocol).
|
|
8
|
+
*
|
|
9
|
+
* @module @craft-native/ts-maps
|
|
10
|
+
*/
|
|
11
|
+
export * from 'ts-maps';
|
|
12
|
+
export { createMapView, type ComponentProps, type MapViewInstance, type MapViewProps, } from './MapView.js';
|
|
13
|
+
export { defaultMapCamera, defaultMapConfiguration, markerColorHex, strokePatternDashes, type BoundingBox, type Coordinate, type CoordinateSpan, type MapCamera, type MapCircle, type MapConfiguration, type MapEvent, type MapMarker, type MapPolygon, type MapPolyline, type MapProvider, type MapRegion, type MapType, type MarkerColor, type StrokePattern, type UserTrackingMode, } from './types.js';
|
|
14
|
+
export { boundsToCraftRegion, cameraToCamera, craftBoundingBoxToBounds, craftCameraToOptions, craftCircleToCircle, craftCoordToLatLng, craftMarkerToMarker, craftPolygonToPolygon, craftPolylineToPolyline, craftRegionToBounds, latLngToCraftCoord, regionFromBounds, type TsMapsCameraOptions, } from './adapters.js';
|
|
15
|
+
export { BRIDGE_NAMESPACE, mapEventName, type MapBridgeEvent, type MapBridgeMethod, type MapBridgeRequest, type TypedMapBridgeRequest, } from './bridge-protocol.js';
|
|
16
|
+
export { createFilesystemBackend, type FilesystemBackendOptions, } from './FilesystemTileBackend.js';
|
|
17
|
+
export { createFilesystemTileCache, saveOfflineRegionToFilesystem, type FilesystemOfflineRegionOptions, } from './offlineRegion.js';
|
|
18
|
+
export { probeCapabilities, supportsAdvancedRendering, type MapRendererCapabilities, } from './capabilities.js';
|
|
19
|
+
export { createMap } from 'ts-maps';
|
|
20
|
+
/**
|
|
21
|
+
* Provider tag matching `MapProvider.ts_maps` in the Zig core. Useful when
|
|
22
|
+
* building a `MapConfiguration` programmatically without magic strings.
|
|
23
|
+
*/
|
|
24
|
+
export declare const tsMapsProvider: 'ts_maps';
|
|
25
|
+
/**
|
|
26
|
+
* Alias preserved for callers that imported the two helpers by spec name.
|
|
27
|
+
* `coordinateFromLatLng(LatLng) -> Coordinate`, `latLngFromCoordinate(Coordinate) -> LatLng`.
|
|
28
|
+
*/
|
|
29
|
+
export { latLngToCraftCoord as coordinateFromLatLng } from './adapters.js';
|
|
30
|
+
export { craftCoordToLatLng as latLngFromCoordinate } from './adapters.js';
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,cAAc,SAAS,CAAA;AAGvB,OAAO,EACL,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAA;AAGnB,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,mBAAmB,GACzB,MAAM,eAAe,CAAA;AAGtB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EACL,uBAAuB,EACvB,KAAK,wBAAwB,GAC9B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,KAAK,8BAA8B,GACpC,MAAM,oBAAoB,CAAA;AAI3B,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,uBAAuB,GAC7B,MAAM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