@honua/react 0.1.12 → 0.1.13

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 (190) hide show
  1. package/columnar/apache-arrow.d.ts +17 -0
  2. package/columnar/apache-arrow.d.ts.map +1 -0
  3. package/columnar/apache-arrow.js +1036 -0
  4. package/columnar/batch-cache-conformance.d.ts +66 -0
  5. package/columnar/batch-cache-conformance.d.ts.map +1 -0
  6. package/columnar/batch-cache-conformance.js +317 -0
  7. package/columnar/batch-cache-indexeddb.d.ts +31 -0
  8. package/columnar/batch-cache-indexeddb.d.ts.map +1 -0
  9. package/columnar/batch-cache-indexeddb.js +148 -0
  10. package/columnar/batch-cache.d.ts +298 -0
  11. package/columnar/batch-cache.d.ts.map +1 -0
  12. package/columnar/batch-cache.js +757 -0
  13. package/columnar/geoarrow-aggregate.d.ts +178 -0
  14. package/columnar/geoarrow-aggregate.d.ts.map +1 -0
  15. package/columnar/geoarrow-aggregate.js +976 -0
  16. package/columnar/geoarrow-patch.d.ts +382 -0
  17. package/columnar/geoarrow-patch.d.ts.map +1 -0
  18. package/columnar/geoarrow-patch.js +1656 -0
  19. package/columnar/geoarrow-reproject.d.ts +22 -0
  20. package/columnar/geoarrow-reproject.d.ts.map +1 -0
  21. package/columnar/geoarrow-reproject.js +119 -0
  22. package/columnar/geoarrow-serialization.d.ts +68 -0
  23. package/columnar/geoarrow-serialization.d.ts.map +1 -0
  24. package/columnar/geoarrow-serialization.js +331 -0
  25. package/columnar/geoarrow-types.d.ts +271 -0
  26. package/columnar/geoarrow-types.d.ts.map +1 -0
  27. package/columnar/geoarrow-types.js +15 -0
  28. package/columnar/geoarrow.d.ts +52 -0
  29. package/columnar/geoarrow.d.ts.map +1 -0
  30. package/columnar/geoarrow.js +1469 -0
  31. package/columnar/index.d.ts +43 -0
  32. package/columnar/index.d.ts.map +1 -0
  33. package/columnar/index.js +29 -0
  34. package/columnar/operators.d.ts +70 -0
  35. package/columnar/operators.d.ts.map +1 -0
  36. package/columnar/operators.js +307 -0
  37. package/columnar/result.d.ts +369 -0
  38. package/columnar/result.d.ts.map +1 -0
  39. package/columnar/result.js +815 -0
  40. package/columnar/telemetry.d.ts +152 -0
  41. package/columnar/telemetry.d.ts.map +1 -0
  42. package/columnar/telemetry.js +265 -0
  43. package/columnar/transfer.d.ts +28 -0
  44. package/columnar/transfer.d.ts.map +1 -0
  45. package/columnar/transfer.js +669 -0
  46. package/columnar/types.d.ts +175 -0
  47. package/columnar/types.d.ts.map +1 -0
  48. package/columnar/types.js +22 -0
  49. package/columnar/worker.d.ts +157 -0
  50. package/columnar/worker.d.ts.map +1 -0
  51. package/columnar/worker.js +1059 -0
  52. package/connect-url-safety.d.ts +53 -0
  53. package/connect-url-safety.js +189 -0
  54. package/contract/pmtiles.d.ts +6 -5
  55. package/contract/pmtiles.d.ts.map +1 -1
  56. package/contract/pmtiles.js +30 -5
  57. package/core/client.d.ts.map +1 -1
  58. package/core/client.js +87 -19
  59. package/core/deprecation-notice.d.ts +28 -0
  60. package/core/deprecation-notice.d.ts.map +1 -0
  61. package/core/deprecation-notice.js +22 -0
  62. package/core/esri-geojson.d.ts.map +1 -1
  63. package/core/esri-geojson.js +10 -6
  64. package/core/optional-grpc-peer.d.ts +15 -0
  65. package/core/optional-grpc-peer.d.ts.map +1 -0
  66. package/core/optional-grpc-peer.js +60 -0
  67. package/esri-compat/basemap-gallery.d.ts +2 -0
  68. package/esri-compat/basemap-gallery.d.ts.map +1 -1
  69. package/esri-compat/basemap-gallery.js +12 -0
  70. package/esri-compat/basemap.d.ts +4 -0
  71. package/esri-compat/basemap.d.ts.map +1 -1
  72. package/esri-compat/basemap.js +70 -0
  73. package/esri-compat/bookmarks.d.ts +2 -0
  74. package/esri-compat/bookmarks.d.ts.map +1 -1
  75. package/esri-compat/bookmarks.js +12 -0
  76. package/esri-compat/controls.d.ts +18 -0
  77. package/esri-compat/controls.d.ts.map +1 -1
  78. package/esri-compat/controls.js +120 -57
  79. package/esri-compat/directions.d.ts +4 -0
  80. package/esri-compat/directions.d.ts.map +1 -1
  81. package/esri-compat/directions.js +30 -20
  82. package/esri-compat/editor.d.ts +4 -0
  83. package/esri-compat/editor.d.ts.map +1 -1
  84. package/esri-compat/editor.js +16 -0
  85. package/esri-compat/esri-config.d.ts +2 -1
  86. package/esri-compat/esri-config.d.ts.map +1 -1
  87. package/esri-compat/feature-effect.d.ts +23 -0
  88. package/esri-compat/feature-effect.d.ts.map +1 -0
  89. package/esri-compat/feature-effect.js +12 -0
  90. package/esri-compat/feature-form.d.ts +6 -0
  91. package/esri-compat/feature-form.d.ts.map +1 -1
  92. package/esri-compat/feature-form.js +63 -0
  93. package/esri-compat/feature-layer.d.ts +21 -2
  94. package/esri-compat/feature-layer.d.ts.map +1 -1
  95. package/esri-compat/feature-layer.js +172 -1
  96. package/esri-compat/feature-table.d.ts +5 -0
  97. package/esri-compat/feature-table.d.ts.map +1 -1
  98. package/esri-compat/feature-table.js +23 -0
  99. package/esri-compat/identity-manager.d.ts +1 -1
  100. package/esri-compat/identity-manager.js +1 -1
  101. package/esri-compat/legend.d.ts +2 -0
  102. package/esri-compat/legend.d.ts.map +1 -1
  103. package/esri-compat/legend.js +98 -0
  104. package/esri-compat/locator.d.ts +1 -1
  105. package/esri-compat/locator.js +1 -1
  106. package/esri-compat/map-view-mount.d.ts +1 -0
  107. package/esri-compat/map-view-mount.d.ts.map +1 -1
  108. package/esri-compat/map-view-mount.js +46 -25
  109. package/esri-compat/map-view.d.ts +13 -0
  110. package/esri-compat/map-view.d.ts.map +1 -1
  111. package/esri-compat/map-view.js +94 -8
  112. package/esri-compat/map.d.ts +5 -1
  113. package/esri-compat/map.d.ts.map +1 -1
  114. package/esri-compat/map.js +10 -0
  115. package/esri-compat/measurement.d.ts +2 -0
  116. package/esri-compat/measurement.d.ts.map +1 -1
  117. package/esri-compat/measurement.js +14 -0
  118. package/esri-compat/point.d.ts +7 -0
  119. package/esri-compat/point.d.ts.map +1 -1
  120. package/esri-compat/point.js +33 -3
  121. package/esri-compat/popup.d.ts +2 -0
  122. package/esri-compat/popup.d.ts.map +1 -1
  123. package/esri-compat/popup.js +12 -0
  124. package/esri-compat/portal.d.ts +1 -1
  125. package/esri-compat/portal.js +1 -1
  126. package/esri-compat/print.d.ts +3 -0
  127. package/esri-compat/print.d.ts.map +1 -1
  128. package/esri-compat/print.js +15 -0
  129. package/esri-compat/search.d.ts +4 -0
  130. package/esri-compat/search.d.ts.map +1 -1
  131. package/esri-compat/search.js +25 -28
  132. package/esri-compat/sketch.d.ts +2 -0
  133. package/esri-compat/sketch.d.ts.map +1 -1
  134. package/esri-compat/sketch.js +12 -0
  135. package/esri-compat/widget-host.d.ts +46 -17
  136. package/esri-compat/widget-host.d.ts.map +1 -1
  137. package/esri-compat/widget-host.js +84 -20
  138. package/esri-compat/widget-shell-hosts.d.ts +61 -0
  139. package/esri-compat/widget-shell-hosts.d.ts.map +1 -0
  140. package/esri-compat/widget-shell-hosts.js +76 -0
  141. package/geocoding/index.d.ts +114 -0
  142. package/geocoding/index.d.ts.map +1 -0
  143. package/geocoding/index.js +293 -0
  144. package/geocoding/provider-http.d.ts +37 -0
  145. package/geocoding/provider-http.d.ts.map +1 -0
  146. package/geocoding/provider-http.js +93 -0
  147. package/geocoding/provider.d.ts +145 -0
  148. package/geocoding/provider.d.ts.map +1 -0
  149. package/geocoding/provider.js +41 -0
  150. package/geocoding/providers/honua.d.ts +28 -0
  151. package/geocoding/providers/honua.d.ts.map +1 -0
  152. package/geocoding/providers/honua.js +68 -0
  153. package/geocoding/providers/nominatim.d.ts +47 -0
  154. package/geocoding/providers/nominatim.d.ts.map +1 -0
  155. package/geocoding/providers/nominatim.js +105 -0
  156. package/geocoding/providers/pelias.d.ts +40 -0
  157. package/geocoding/providers/pelias.d.ts.map +1 -0
  158. package/geocoding/providers/pelias.js +115 -0
  159. package/geocoding/providers/photon.d.ts +39 -0
  160. package/geocoding/providers/photon.d.ts.map +1 -0
  161. package/geocoding/providers/photon.js +107 -0
  162. package/geometry/convert.d.ts +13 -0
  163. package/geometry/convert.d.ts.map +1 -0
  164. package/geometry/convert.js +12 -0
  165. package/geometry/index.d.ts +17 -0
  166. package/geometry/index.d.ts.map +1 -0
  167. package/geometry/index.js +15 -0
  168. package/geometry/internal.d.ts +25 -0
  169. package/geometry/internal.d.ts.map +1 -0
  170. package/geometry/internal.js +40 -0
  171. package/geometry/ops.d.ts +71 -0
  172. package/geometry/ops.d.ts.map +1 -0
  173. package/geometry/ops.js +147 -0
  174. package/geometry/project.d.ts +40 -0
  175. package/geometry/project.d.ts.map +1 -0
  176. package/geometry/project.js +88 -0
  177. package/geometry/types.d.ts +36 -0
  178. package/geometry/types.d.ts.map +1 -0
  179. package/geometry/types.js +12 -0
  180. package/kernel/renderer.d.ts +82 -0
  181. package/kernel/renderer.js +1 -0
  182. package/offline/digest.d.ts +15 -0
  183. package/offline/digest.js +58 -0
  184. package/offline/quota.d.ts +161 -0
  185. package/offline/quota.js +370 -0
  186. package/offline/types.d.ts +349 -0
  187. package/offline/types.js +75 -0
  188. package/package.json +14 -2
  189. package/widget-capabilities.d.ts +67 -0
  190. package/widget-capabilities.js +152 -0
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Internal bridge between the SDK's GeoJSON contract types and the `geojson`
3
+ * declarations that the `@turf/*` packages are typed against. The two are
4
+ * structurally identical for the primitive geometry types the geometry package
5
+ * supports, so the conversions are erased casts — kept in one place so the ops
6
+ * modules stay free of scattered `as unknown as` noise.
7
+ *
8
+ * @internal
9
+ * @module
10
+ */
11
+ /** Narrow an input to its bare geometry, unwrapping a `Feature` if needed. */
12
+ export function inputToGeometry(input) {
13
+ if (input.type === "Feature") {
14
+ const geometry = input.geometry;
15
+ if (!geometry) {
16
+ throw new TypeError("@honua/geometry: feature has no geometry");
17
+ }
18
+ return geometry;
19
+ }
20
+ if (input.type === "FeatureCollection") {
21
+ throw new TypeError("@honua/geometry: expected a geometry or Feature, received a FeatureCollection");
22
+ }
23
+ return input;
24
+ }
25
+ /** Present an SDK geometry to turf as a `geojson` geometry. */
26
+ export function toTurfGeometry(geometry) {
27
+ return geometry;
28
+ }
29
+ /** Present an SDK geometry input to turf as a `geojson` value. */
30
+ export function toTurfInput(input) {
31
+ return input;
32
+ }
33
+ /** Convert a turf geometry back into an SDK geometry. */
34
+ export function fromTurfGeometry(geometry) {
35
+ return geometry;
36
+ }
37
+ /** Convert a turf feature back into an SDK feature. */
38
+ export function fromTurfFeature(feature) {
39
+ return feature;
40
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Curated, tree-shakeable wrappers over the individual `@turf/*` packages,
3
+ * typed against the SDK's GeoJSON contract.
4
+ *
5
+ * Each function wraps exactly one turf package so a consumer importing a single
6
+ * op (e.g. `import { buffer } from "@honua/geometry"`) only pulls that op's turf
7
+ * dependency into their bundle. Nothing here is reimplemented — the algorithms
8
+ * live in turf; this module only adapts types and defaults.
9
+ *
10
+ * All turf area/length/buffer math is **geodesic** (great-circle on a sphere)
11
+ * and assumes coordinates are WGS84 longitude/latitude degrees, matching turf's
12
+ * contract. See `docs/geometry.md` for the planar-vs-geodesic caveats that
13
+ * matter when bridging Esri geometries.
14
+ *
15
+ * @module
16
+ */
17
+ import type { GeoJsonFeature } from "../core/types.js";
18
+ import type { GeoJsonGeometry, GeoJsonPoint } from "../expr/expression.js";
19
+ import type { GeometryInput, LinearUnit } from "./types.js";
20
+ /**
21
+ * Buffer a geometry by `radius` (default unit: meters). Wraps `@turf/buffer`.
22
+ * Returns `null` when turf cannot produce a buffer (e.g. an empty geometry).
23
+ */
24
+ export declare function buffer(input: GeometryInput, radius: number, unit?: LinearUnit): GeoJsonGeometry | null;
25
+ /** Geodesic area of a polygonal geometry in square meters. Wraps `@turf/area`. */
26
+ export declare function area(input: GeometryInput): number;
27
+ /**
28
+ * Geodesic length of a line (or polygon perimeter) in `unit` (default meters).
29
+ * Wraps `@turf/length`.
30
+ */
31
+ export declare function length(input: GeometryInput, unit?: LinearUnit): number;
32
+ /** Centroid of a geometry as a GeoJSON `Point`. Wraps `@turf/centroid`. */
33
+ export declare function centroid(input: GeometryInput): GeoJsonPoint;
34
+ /** Bounding box `[minX, minY, maxX, maxY]` of a geometry. Wraps `@turf/bbox`. */
35
+ export declare function bbox(input: GeometryInput): [number, number, number, number];
36
+ /**
37
+ * Ramer–Douglas–Peucker simplification. `tolerance` is in the geometry's
38
+ * coordinate units; `highQuality` trades speed for fidelity. Wraps
39
+ * `@turf/simplify`.
40
+ */
41
+ export declare function simplify(input: GeometryInput, tolerance: number, highQuality?: boolean): GeoJsonGeometry;
42
+ /** True if `a` and `b` share any point. Wraps `@turf/boolean-intersects`. */
43
+ export declare function booleanIntersects(a: GeometryInput, b: GeometryInput): boolean;
44
+ /** True if `a` completely contains `b`. Wraps `@turf/boolean-contains`. */
45
+ export declare function booleanContains(a: GeometryInput, b: GeometryInput): boolean;
46
+ /** True if `a` is completely within `b`. Wraps `@turf/boolean-within`. */
47
+ export declare function booleanWithin(a: GeometryInput, b: GeometryInput): boolean;
48
+ /**
49
+ * Polygon union of two or more polygonal geometries. Wraps `@turf/union`.
50
+ * Returns `null` when the inputs do not combine into a polygon.
51
+ */
52
+ export declare function union(...polygons: readonly GeometryInput[]): GeoJsonGeometry | null;
53
+ /**
54
+ * Polygon intersection of two polygonal geometries. Wraps `@turf/intersect`.
55
+ * Returns `null` when the polygons do not overlap.
56
+ */
57
+ export declare function intersect(a: GeometryInput, b: GeometryInput): GeoJsonGeometry | null;
58
+ /**
59
+ * Polygon difference `a − b`. Wraps `@turf/difference`. Returns `null` when the
60
+ * subtraction removes the whole polygon.
61
+ */
62
+ export declare function difference(a: GeometryInput, b: GeometryInput): GeoJsonGeometry | null;
63
+ /** Convex hull of a geometry. Wraps `@turf/convex`. Returns `null` if undefined. */
64
+ export declare function convex(input: GeometryInput): GeoJsonGeometry | null;
65
+ /**
66
+ * Nearest point in `points` to `target`, as a GeoJSON `Feature<Point>` carrying
67
+ * turf's `featureIndex` / `distanceToPoint` properties. Wraps
68
+ * `@turf/nearest-point`.
69
+ */
70
+ export declare function nearestPoint(target: GeoJsonPoint, points: readonly GeoJsonPoint[]): GeoJsonFeature;
71
+ //# sourceMappingURL=ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../../src/geometry/ops.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA0BH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE3E,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAmB5D;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,UAAqB,GAAG,eAAe,GAAG,IAAI,CAUhH;AAED,kFAAkF;AAClF,wBAAgB,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAEjD;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,GAAE,UAAqB,GAAG,MAAM,CAEhF;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,CAE3D;AAED,iFAAiF;AACjF,wBAAgB,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAG3E;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,UAAQ,GAAG,eAAe,CAItG;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAE7E;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAE3E;AAED,0EAA0E;AAC1E,wBAAgB,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,OAAO,CAEzE;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,eAAe,GAAG,IAAI,CAMnF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,eAAe,GAAG,IAAI,CAGpF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,GAAG,eAAe,GAAG,IAAI,CAGrF;AAED,oFAAoF;AACpF,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,eAAe,GAAG,IAAI,CAGnE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,cAAc,CAWlG"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Curated, tree-shakeable wrappers over the individual `@turf/*` packages,
3
+ * typed against the SDK's GeoJSON contract.
4
+ *
5
+ * Each function wraps exactly one turf package so a consumer importing a single
6
+ * op (e.g. `import { buffer } from "@honua/geometry"`) only pulls that op's turf
7
+ * dependency into their bundle. Nothing here is reimplemented — the algorithms
8
+ * live in turf; this module only adapts types and defaults.
9
+ *
10
+ * All turf area/length/buffer math is **geodesic** (great-circle on a sphere)
11
+ * and assumes coordinates are WGS84 longitude/latitude degrees, matching turf's
12
+ * contract. See `docs/geometry.md` for the planar-vs-geodesic caveats that
13
+ * matter when bridging Esri geometries.
14
+ *
15
+ * @module
16
+ */
17
+ import { area as turfArea } from "@turf/area";
18
+ import { bbox as turfBbox } from "@turf/bbox";
19
+ import { booleanContains as turfBooleanContains } from "@turf/boolean-contains";
20
+ import { booleanIntersects as turfBooleanIntersects } from "@turf/boolean-intersects";
21
+ import { booleanWithin as turfBooleanWithin } from "@turf/boolean-within";
22
+ import { buffer as turfBuffer } from "@turf/buffer";
23
+ import { centroid as turfCentroid } from "@turf/centroid";
24
+ import { convex as turfConvex } from "@turf/convex";
25
+ import { difference as turfDifference } from "@turf/difference";
26
+ import { intersect as turfIntersect } from "@turf/intersect";
27
+ import { length as turfLength } from "@turf/length";
28
+ import { nearestPoint as turfNearestPoint } from "@turf/nearest-point";
29
+ import { simplify as turfSimplify } from "@turf/simplify";
30
+ import { union as turfUnion } from "@turf/union";
31
+ import { fromTurfFeature, fromTurfGeometry, inputToGeometry, toTurfGeometry, toTurfInput } from "./internal.js";
32
+ function toPolygonFeatureCollection(inputs) {
33
+ return {
34
+ type: "FeatureCollection",
35
+ features: inputs.map((input) => ({
36
+ type: "Feature",
37
+ properties: {},
38
+ geometry: toTurfGeometry(inputToGeometry(input)),
39
+ })),
40
+ };
41
+ }
42
+ /**
43
+ * Buffer a geometry by `radius` (default unit: meters). Wraps `@turf/buffer`.
44
+ * Returns `null` when turf cannot produce a buffer (e.g. an empty geometry).
45
+ */
46
+ export function buffer(input, radius, unit = "meters") {
47
+ // A single Feature/Geometry input yields a single buffered Feature (never a
48
+ // collection), so the return narrows to `Feature | undefined`.
49
+ const feature = {
50
+ type: "Feature",
51
+ properties: {},
52
+ geometry: toTurfGeometry(inputToGeometry(input)),
53
+ };
54
+ const result = turfBuffer(feature, radius, { units: unit });
55
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
56
+ }
57
+ /** Geodesic area of a polygonal geometry in square meters. Wraps `@turf/area`. */
58
+ export function area(input) {
59
+ return turfArea(toTurfInput(input));
60
+ }
61
+ /**
62
+ * Geodesic length of a line (or polygon perimeter) in `unit` (default meters).
63
+ * Wraps `@turf/length`.
64
+ */
65
+ export function length(input, unit = "meters") {
66
+ return turfLength(toTurfInput(input), { units: unit });
67
+ }
68
+ /** Centroid of a geometry as a GeoJSON `Point`. Wraps `@turf/centroid`. */
69
+ export function centroid(input) {
70
+ return fromTurfGeometry(turfCentroid(toTurfInput(input)).geometry);
71
+ }
72
+ /** Bounding box `[minX, minY, maxX, maxY]` of a geometry. Wraps `@turf/bbox`. */
73
+ export function bbox(input) {
74
+ const [minX, minY, maxX, maxY] = turfBbox(toTurfInput(input));
75
+ return [minX, minY, maxX, maxY];
76
+ }
77
+ /**
78
+ * Ramer–Douglas–Peucker simplification. `tolerance` is in the geometry's
79
+ * coordinate units; `highQuality` trades speed for fidelity. Wraps
80
+ * `@turf/simplify`.
81
+ */
82
+ export function simplify(input, tolerance, highQuality = false) {
83
+ const geometry = toTurfGeometry(inputToGeometry(input));
84
+ const simplified = turfSimplify(geometry, { tolerance, highQuality, mutate: false });
85
+ return fromTurfGeometry(simplified);
86
+ }
87
+ /** True if `a` and `b` share any point. Wraps `@turf/boolean-intersects`. */
88
+ export function booleanIntersects(a, b) {
89
+ return turfBooleanIntersects(toTurfGeometry(inputToGeometry(a)), toTurfGeometry(inputToGeometry(b)));
90
+ }
91
+ /** True if `a` completely contains `b`. Wraps `@turf/boolean-contains`. */
92
+ export function booleanContains(a, b) {
93
+ return turfBooleanContains(toTurfGeometry(inputToGeometry(a)), toTurfGeometry(inputToGeometry(b)));
94
+ }
95
+ /** True if `a` is completely within `b`. Wraps `@turf/boolean-within`. */
96
+ export function booleanWithin(a, b) {
97
+ return turfBooleanWithin(toTurfGeometry(inputToGeometry(a)), toTurfGeometry(inputToGeometry(b)));
98
+ }
99
+ /**
100
+ * Polygon union of two or more polygonal geometries. Wraps `@turf/union`.
101
+ * Returns `null` when the inputs do not combine into a polygon.
102
+ */
103
+ export function union(...polygons) {
104
+ if (polygons.length === 0) {
105
+ return null;
106
+ }
107
+ const result = turfUnion(toPolygonFeatureCollection(polygons));
108
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
109
+ }
110
+ /**
111
+ * Polygon intersection of two polygonal geometries. Wraps `@turf/intersect`.
112
+ * Returns `null` when the polygons do not overlap.
113
+ */
114
+ export function intersect(a, b) {
115
+ const result = turfIntersect(toPolygonFeatureCollection([a, b]));
116
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
117
+ }
118
+ /**
119
+ * Polygon difference `a − b`. Wraps `@turf/difference`. Returns `null` when the
120
+ * subtraction removes the whole polygon.
121
+ */
122
+ export function difference(a, b) {
123
+ const result = turfDifference(toPolygonFeatureCollection([a, b]));
124
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
125
+ }
126
+ /** Convex hull of a geometry. Wraps `@turf/convex`. Returns `null` if undefined. */
127
+ export function convex(input) {
128
+ const result = turfConvex(toTurfInput(input));
129
+ return result?.geometry ? fromTurfGeometry(result.geometry) : null;
130
+ }
131
+ /**
132
+ * Nearest point in `points` to `target`, as a GeoJSON `Feature<Point>` carrying
133
+ * turf's `featureIndex` / `distanceToPoint` properties. Wraps
134
+ * `@turf/nearest-point`.
135
+ */
136
+ export function nearestPoint(target, points) {
137
+ const collection = {
138
+ type: "FeatureCollection",
139
+ features: points.map((point) => ({
140
+ type: "Feature",
141
+ properties: {},
142
+ geometry: toTurfGeometry(point),
143
+ })),
144
+ };
145
+ const nearest = turfNearestPoint(toTurfGeometry(target), collection);
146
+ return fromTurfFeature(nearest);
147
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Reprojection helpers backed by `proj4`.
3
+ *
4
+ * Only EPSG:4326 (WGS84) and EPSG:3857 (Web Mercator) are needed by default —
5
+ * both are built into proj4, so this module registers **nothing** at import
6
+ * time and stays side-effect-free for tree-shaking. Additional coordinate
7
+ * systems are registered on demand via {@link defineProjection}.
8
+ *
9
+ * @module
10
+ */
11
+ import type { GeoJsonGeometry } from "../expr/expression.js";
12
+ import type { GeometryInput } from "./types.js";
13
+ /**
14
+ * Normalize a CRS identifier into a proj4-resolvable string. Accepts:
15
+ * - a numeric EPSG code (`4326`, `102100`),
16
+ * - an `"EPSG:xxxx"` string,
17
+ * - a raw proj4/WKT definition string (passed through untouched).
18
+ */
19
+ export declare function normalizeCrs(code: number | string): string;
20
+ /**
21
+ * Register a coordinate system so {@link project} (and the `toWgs84` /
22
+ * `toWebMercator` fast paths) can resolve it. Idempotent; safe to call at app
23
+ * startup or lazily before the first `project` call.
24
+ *
25
+ * @param code EPSG code or name to register the definition under.
26
+ * @param proj4def A proj4 or WKT definition string.
27
+ */
28
+ export declare function defineProjection(code: number | string, proj4def: string): void;
29
+ /**
30
+ * Reproject a geometry from `fromCrs` to `toCrs`. CRS arguments accept EPSG
31
+ * codes, `"EPSG:xxxx"` strings, or raw proj4 definitions. Returns a new
32
+ * geometry; the input is never mutated. A no-op (deep clone) when the two CRS
33
+ * resolve to the same definition.
34
+ */
35
+ export declare function project(input: GeometryInput, fromCrs: number | string, toCrs: number | string): GeoJsonGeometry;
36
+ /** Fast path: reproject a geometry from `fromCrs` into WGS84 (EPSG:4326). */
37
+ export declare function toWgs84(input: GeometryInput, fromCrs: number | string): GeoJsonGeometry;
38
+ /** Fast path: reproject a geometry from `fromCrs` into Web Mercator (EPSG:3857). */
39
+ export declare function toWebMercator(input: GeometryInput, fromCrs: number | string): GeoJsonGeometry;
40
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/geometry/project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKhD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAc1D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE9E;AAqBD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAY/G;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAEvF;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAE7F"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Reprojection helpers backed by `proj4`.
3
+ *
4
+ * Only EPSG:4326 (WGS84) and EPSG:3857 (Web Mercator) are needed by default —
5
+ * both are built into proj4, so this module registers **nothing** at import
6
+ * time and stays side-effect-free for tree-shaking. Additional coordinate
7
+ * systems are registered on demand via {@link defineProjection}.
8
+ *
9
+ * @module
10
+ */
11
+ import proj4 from "proj4";
12
+ import { inputToGeometry } from "./internal.js";
13
+ /** EPSG codes that are aliases for Web Mercator across Esri/OGC usage. */
14
+ const WEB_MERCATOR_ALIASES = new Set([3857, 3785, 900913, 102100, 102113]);
15
+ /**
16
+ * Normalize a CRS identifier into a proj4-resolvable string. Accepts:
17
+ * - a numeric EPSG code (`4326`, `102100`),
18
+ * - an `"EPSG:xxxx"` string,
19
+ * - a raw proj4/WKT definition string (passed through untouched).
20
+ */
21
+ export function normalizeCrs(code) {
22
+ if (typeof code === "number") {
23
+ return WEB_MERCATOR_ALIASES.has(code) ? "EPSG:3857" : `EPSG:${code}`;
24
+ }
25
+ const trimmed = code.trim();
26
+ // A definition string (proj4 or WKT), not a code — hand it to proj4 as-is.
27
+ if (trimmed.includes("+proj") || trimmed.includes("PROJCS") || trimmed.includes("GEOGCS")) {
28
+ return trimmed;
29
+ }
30
+ const epsgMatch = /^epsg:(\d+)$/i.exec(trimmed);
31
+ if (epsgMatch) {
32
+ return normalizeCrs(Number(epsgMatch[1]));
33
+ }
34
+ return trimmed;
35
+ }
36
+ /**
37
+ * Register a coordinate system so {@link project} (and the `toWgs84` /
38
+ * `toWebMercator` fast paths) can resolve it. Idempotent; safe to call at app
39
+ * startup or lazily before the first `project` call.
40
+ *
41
+ * @param code EPSG code or name to register the definition under.
42
+ * @param proj4def A proj4 or WKT definition string.
43
+ */
44
+ export function defineProjection(code, proj4def) {
45
+ proj4.defs(normalizeCrs(code), proj4def);
46
+ }
47
+ function projectPosition(position, converter) {
48
+ const [x, y, ...rest] = position;
49
+ const projected = converter.forward([x, y]);
50
+ return [projected[0], projected[1], ...rest];
51
+ }
52
+ function projectCoordinates(coordinates, converter) {
53
+ if (!Array.isArray(coordinates)) {
54
+ return coordinates;
55
+ }
56
+ // A bare position is an array of finite numbers.
57
+ if (typeof coordinates[0] === "number") {
58
+ return projectPosition(coordinates, converter);
59
+ }
60
+ return coordinates.map((entry) => projectCoordinates(entry, converter));
61
+ }
62
+ /**
63
+ * Reproject a geometry from `fromCrs` to `toCrs`. CRS arguments accept EPSG
64
+ * codes, `"EPSG:xxxx"` strings, or raw proj4 definitions. Returns a new
65
+ * geometry; the input is never mutated. A no-op (deep clone) when the two CRS
66
+ * resolve to the same definition.
67
+ */
68
+ export function project(input, fromCrs, toCrs) {
69
+ const geometry = inputToGeometry(input);
70
+ const from = normalizeCrs(fromCrs);
71
+ const to = normalizeCrs(toCrs);
72
+ if (from === to) {
73
+ return structuredClone(geometry);
74
+ }
75
+ const converter = proj4(from, to);
76
+ return {
77
+ ...geometry,
78
+ coordinates: projectCoordinates(geometry.coordinates, converter),
79
+ };
80
+ }
81
+ /** Fast path: reproject a geometry from `fromCrs` into WGS84 (EPSG:4326). */
82
+ export function toWgs84(input, fromCrs) {
83
+ return project(input, fromCrs, "EPSG:4326");
84
+ }
85
+ /** Fast path: reproject a geometry from `fromCrs` into Web Mercator (EPSG:3857). */
86
+ export function toWebMercator(input, fromCrs) {
87
+ return project(input, fromCrs, "EPSG:3857");
88
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Public GeoJSON and unit types for `@honua/geometry`.
3
+ *
4
+ * The geometry operations are typed against the SDK's own GeoJSON contract
5
+ * (`src/expr/expression.ts` geometry union + `src/core/types.ts`
6
+ * {@link GeoJsonFeature}) rather than pulling in the `@types/geojson`
7
+ * declarations as a public surface. Internally the turf wrappers bridge to the
8
+ * `geojson` types, but consumers only ever see Honua's own types.
9
+ *
10
+ * @module
11
+ */
12
+ export type { GeoJsonGeometry, GeoJsonPoint, GeoJsonMultiPoint, GeoJsonLineString, GeoJsonMultiLineString, GeoJsonPolygon, GeoJsonMultiPolygon, } from "../expr/expression.js";
13
+ export type { GeoJsonFeature } from "../core/types.js";
14
+ import type { GeoJsonFeature } from "../core/types.js";
15
+ import type { GeoJsonGeometry } from "../expr/expression.js";
16
+ /**
17
+ * A GeoJSON `FeatureCollection` typed against the SDK feature type. The SDK
18
+ * contract intentionally ships only `GeoJsonFeature`; the geometry package adds
19
+ * the collection wrapper it needs for union/nearest-point style operations.
20
+ */
21
+ export interface GeoJsonFeatureCollection {
22
+ type: "FeatureCollection";
23
+ features: GeoJsonFeature[];
24
+ }
25
+ /**
26
+ * Anything the geometry ops accept as an input shape: a bare geometry, a
27
+ * `Feature`, or a `FeatureCollection`. Operations always return the SDK
28
+ * geometry (or feature) types.
29
+ */
30
+ export type GeometryInput = GeoJsonGeometry | GeoJsonFeature | GeoJsonFeatureCollection;
31
+ /**
32
+ * Linear distance units understood by {@link buffer} and {@link length}. This is
33
+ * the subset of turf's unit vocabulary that has an unambiguous geodesic meaning.
34
+ */
35
+ export type LinearUnit = "meters" | "kilometers" | "miles" | "feet" | "yards" | "nauticalmiles";
36
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/geometry/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,EACd,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,cAAc,GAAG,wBAAwB,CAAC;AAExF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,eAAe,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Public GeoJSON and unit types for `@honua/geometry`.
3
+ *
4
+ * The geometry operations are typed against the SDK's own GeoJSON contract
5
+ * (`src/expr/expression.ts` geometry union + `src/core/types.ts`
6
+ * {@link GeoJsonFeature}) rather than pulling in the `@types/geojson`
7
+ * declarations as a public surface. Internally the turf wrappers bridge to the
8
+ * `geojson` types, but consumers only ever see Honua's own types.
9
+ *
10
+ * @module
11
+ */
12
+ export {};
@@ -0,0 +1,82 @@
1
+ import type { CapabilityPolicy, Query, Source, SourceId } from "../contract/types.js";
2
+ import type { ExecuteQueryPlanOptions, QueryExecutionPlanV1, QueryFallbackPolicy, QueryPlanCacheOptions, QueryPlanningEstimates } from "../query-planner/types.js";
3
+ /** Built-in renderers are conveniences; namespaced adapters may extend this vocabulary. */
4
+ export type RendererKind = "maplibre" | (string & {});
5
+ export type RendererEnvironment = "browser" | "node" | "worker";
6
+ export type RendererOwnership = "owned" | "borrowed";
7
+ export type RendererTarget = string | object;
8
+ /** Stable, renderer-neutral diagnostic exposed by one mounted handle. */
9
+ export interface RendererDiagnostic {
10
+ readonly code: string;
11
+ readonly severity: "info" | "warning" | "error";
12
+ readonly message: string;
13
+ readonly strategy?: string;
14
+ }
15
+ /** Refresh controls shared by every renderer session. */
16
+ export interface MountedMapRefreshOptions {
17
+ readonly signal?: AbortSignal;
18
+ }
19
+ /**
20
+ * Request passed to an injected renderer adapter.
21
+ *
22
+ * The adapter may ask for a query plan only when its existing strategy needs
23
+ * materialized features. Planning is memoized and performs no result I/O.
24
+ */
25
+ export interface RendererMountRequest<T = Record<string, unknown>, TOptions = unknown> {
26
+ readonly source: Source<T>;
27
+ readonly rendererOptions?: TOptions;
28
+ readonly style?: "auto" | Readonly<Record<string, unknown>>;
29
+ readonly ownership: RendererOwnership;
30
+ readonly signal: AbortSignal;
31
+ /** Distinguishes the kernel's safe default query from caller-authored filtering intent. */
32
+ readonly queryIntent: "default" | "explicit";
33
+ readonly queryPlan?: QueryExecutionPlanV1;
34
+ readonly execution: ExecuteQueryPlanOptions;
35
+ planQuery(): Promise<QueryExecutionPlanV1>;
36
+ }
37
+ /** Renderer-owned leaf session adopted by the connection lifecycle. */
38
+ export interface RendererSession<TRaw = unknown> {
39
+ readonly raw: TRaw;
40
+ readonly ready: Promise<void>;
41
+ readonly diagnostics: readonly RendererDiagnostic[];
42
+ refresh(options?: MountedMapRefreshOptions): Promise<void>;
43
+ dispose(): void | Promise<void>;
44
+ }
45
+ /**
46
+ * Minimal executable renderer seam. Heavy peers are injected as values and
47
+ * are never imported by the kernel.
48
+ */
49
+ export interface RendererAdapter<TKind extends RendererKind = RendererKind, TRaw = unknown, TOptions = unknown> {
50
+ readonly kind: TKind;
51
+ readonly environments: readonly RendererEnvironment[];
52
+ readonly peer: unknown;
53
+ defaultOwnership(target: RendererTarget): RendererOwnership;
54
+ mount<T = Record<string, unknown>>(target: RendererTarget, request: RendererMountRequest<T, TOptions>): Promise<RendererSession<TRaw>>;
55
+ }
56
+ /** Connection-level planning and renderer controls for one mount. */
57
+ export interface MountOptions<T = Record<string, unknown>, TKind extends RendererKind = RendererKind, TRaw = unknown, TRendererOptions = unknown> {
58
+ readonly renderer: RendererAdapter<TKind, TRaw, TRendererOptions>;
59
+ readonly sourceId?: SourceId;
60
+ /** A raw query is bounded before planning; an accepted plan is executed without replanning. */
61
+ readonly query?: Readonly<Query<T>> | QueryExecutionPlanV1;
62
+ readonly capabilityPolicy?: CapabilityPolicy;
63
+ readonly fallback?: QueryFallbackPolicy;
64
+ readonly estimates?: QueryPlanningEstimates;
65
+ readonly cache?: QueryPlanCacheOptions;
66
+ readonly rendererOptions?: TRendererOptions;
67
+ readonly style?: "auto" | Readonly<Record<string, unknown>>;
68
+ /** Defaults to owned for a selector/element target and borrowed for an existing host object. */
69
+ readonly ownership?: RendererOwnership;
70
+ readonly signal?: AbortSignal;
71
+ }
72
+ /** Connection-owned map lifecycle with a typed raw escape hatch. */
73
+ export interface MountedMap<TKind extends RendererKind = RendererKind, TRaw = unknown> extends AsyncDisposable {
74
+ readonly id: string;
75
+ readonly renderer: TKind;
76
+ readonly ready: Promise<void>;
77
+ readonly diagnostics: readonly RendererDiagnostic[];
78
+ raw(kind: TKind): TRaw | undefined;
79
+ refresh(options?: MountedMapRefreshOptions): Promise<void>;
80
+ dispose(): Promise<void>;
81
+ }
82
+ //# sourceMappingURL=renderer.d.ts.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ /** Code-unit ordering, the deterministic sort used by every persisted identity. */
2
+ export declare function compareCodeUnits(left: string, right: string): number;
3
+ /**
4
+ * Serialize `value` with sorted own keys and no `undefined` members.
5
+ *
6
+ * The output is the digest pre-image for region and resource identity, so it is
7
+ * deliberately strict: an `undefined` anywhere would silently disappear from the
8
+ * identity and let two different selections collide.
9
+ */
10
+ export declare function canonicalJson(value: unknown): string;
11
+ /** Portable Web Crypto SHA-256 over UTF-8 text or raw bytes. */
12
+ export declare function sha256(value: string | Uint8Array): Promise<`sha256:${string}`>;
13
+ /** Domain-separated digest of a canonical identity object. */
14
+ export declare function identityDigest(namespace: string, value: unknown): Promise<`sha256:${string}`>;
15
+ //# sourceMappingURL=digest.d.ts.map
@@ -0,0 +1,58 @@
1
+ import { HonuaOfflineRegionError } from "./types.js";
2
+ /**
3
+ * Deterministic identity primitives shared by every offline module.
4
+ *
5
+ * Manifest identity, snapshot resource identity, and the read path all have to
6
+ * agree byte-for-byte on what "the same selection" means, so the canonical
7
+ * serialization and the digest live in one module rather than being reimplemented
8
+ * per layer. Nothing here reads storage or accepts a request URL.
9
+ */
10
+ const encoder = new TextEncoder();
11
+ /** Code-unit ordering, the deterministic sort used by every persisted identity. */
12
+ export function compareCodeUnits(left, right) {
13
+ return left < right ? -1 : left > right ? 1 : 0;
14
+ }
15
+ /**
16
+ * Serialize `value` with sorted own keys and no `undefined` members.
17
+ *
18
+ * The output is the digest pre-image for region and resource identity, so it is
19
+ * deliberately strict: an `undefined` anywhere would silently disappear from the
20
+ * identity and let two different selections collide.
21
+ */
22
+ export function canonicalJson(value) {
23
+ if (value === null || typeof value !== "object") {
24
+ const encoded = JSON.stringify(value);
25
+ if (encoded === undefined) {
26
+ throw new HonuaOfflineRegionError("invalid-manifest", "Offline identity cannot contain undefined values.", {
27
+ path: "identity",
28
+ });
29
+ }
30
+ return encoded;
31
+ }
32
+ if (Array.isArray(value))
33
+ return `[${value.map(canonicalJson).join(",")}]`;
34
+ const entries = [];
35
+ for (const key in value) {
36
+ if (Object.hasOwn(value, key))
37
+ entries.push([key, value[key]]);
38
+ }
39
+ entries.sort(([left], [right]) => compareCodeUnits(left, right));
40
+ return `{${entries.map(([key, child]) => `${JSON.stringify(key)}:${canonicalJson(child)}`).join(",")}}`;
41
+ }
42
+ /** Portable Web Crypto SHA-256 over UTF-8 text or raw bytes. */
43
+ export async function sha256(value) {
44
+ const subtle = globalThis.crypto?.subtle;
45
+ if (!subtle) {
46
+ throw new HonuaOfflineRegionError("invalid-manifest", "Offline region identity and integrity require Web Crypto SHA-256.", { path: "crypto" });
47
+ }
48
+ const bytes = typeof value === "string" ? encoder.encode(value) : value;
49
+ const digestInput = bytes.buffer instanceof ArrayBuffer
50
+ ? bytes
51
+ : Uint8Array.from(bytes);
52
+ const digest = await subtle.digest("SHA-256", digestInput);
53
+ return `sha256:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
54
+ }
55
+ /** Domain-separated digest of a canonical identity object. */
56
+ export async function identityDigest(namespace, value) {
57
+ return sha256(`${namespace}:v1:${canonicalJson(value)}`);
58
+ }