@object-ui/plugin-map 17.5.0 → 17.7.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.
@@ -0,0 +1,102 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ /**
9
+ * Initial-camera derivation for ObjectMap (objectui#4941).
10
+ *
11
+ * A map view whose query returned records must never first-paint an empty
12
+ * viewport. The camera is therefore derived from the records themselves: the
13
+ * marker set's bounding box, handed to MapLibre so it fits the box with the
14
+ * real container size (`initialViewState.bounds` -> the `bounds` /
15
+ * `fitBoundsOptions` pair on the MapLibre `Map` constructor, which overrides
16
+ * `center` / `zoom`).
17
+ *
18
+ * Two things this module deliberately does NOT do:
19
+ *
20
+ * 1. It does not rescue out-of-range record coordinates. The platform's
21
+ * `location` value is `{ lat, lng }` with longitude bounded to [-180, 180]
22
+ * by `@objectstack/spec` (`data/field-value.zod.ts`), so a longitude outside
23
+ * that range is a producer-side defect, not a dialect this renderer should
24
+ * learn to read. `ObjectMap` keeps rejecting such records and counting them
25
+ * in its "invalid coordinates" notice. The normalization here is projection
26
+ * arithmetic over already-valid values, applied to the CAMERA only.
27
+ * 2. It does not introduce any authoring surface. The only camera declaration
28
+ * read anywhere is the documented `zoom` / `center` pair of the map config
29
+ * block (`content/docs/plugins/plugin-map.mdx`), and an author who declares
30
+ * it keeps winning over everything computed here.
31
+ */
32
+ /**
33
+ * `[[west, south], [east, north]]` — the two-corner form MapLibre accepts as
34
+ * `LngLatBoundsLike`. `east` may exceed 180: that is how MapLibre expects a box
35
+ * crossing the antimeridian to be spelled (its own `adjustAntiMeridian` produces
36
+ * exactly this shape), and it is what keeps the fitted camera on the same world
37
+ * copy as the markers.
38
+ */
39
+ export type MarkerBounds = [[number, number], [number, number]];
40
+ /** Breathing room around the fitted box, in pixels. */
41
+ export declare const FIT_PADDING_PX = 48;
42
+ /**
43
+ * Ceiling for the fitted zoom. A single record — or several records at one
44
+ * address — fits a zero-width box, and an unbounded fit answers that with the
45
+ * map's maximum zoom (22): a building-level view of a style whose tiles usually
46
+ * stop far short of it. City scale is the useful answer instead.
47
+ */
48
+ export declare const FIT_MAX_ZOOM = 12;
49
+ /** Zoom used when there is nothing to fit: the whole world, not a random sea. */
50
+ export declare const EMPTY_VIEW_ZOOM = 2;
51
+ /**
52
+ * Zoom used when a partially declared camera pins the position but not the
53
+ * scale, so the box cannot drive the fit. Same value the component used before
54
+ * the fit existed.
55
+ */
56
+ export declare const UNFITTED_CENTER_ZOOM = 3;
57
+ /**
58
+ * Latitude ceiling for the fitted box. Web Mercator is unbounded at the poles,
59
+ * so a record sitting exactly at +/-90 projects to infinity and takes the whole
60
+ * camera with it. Markers themselves stay at their real latitude.
61
+ */
62
+ export declare const MAX_FIT_LATITUDE = 85;
63
+ /**
64
+ * Fold any longitude onto the [-180, 180) circle.
65
+ *
66
+ * In-range values return unchanged rather than through the modulo, which would
67
+ * round-trip them into a neighbouring float (-74.006 came back as
68
+ * -74.00599999999997) and put that drift into every fitted box.
69
+ */
70
+ export declare function normalizeLongitude(lng: number): number;
71
+ /**
72
+ * Bounding box of a marker set, along the SHORTEST arc that contains every
73
+ * marker.
74
+ *
75
+ * Why the shortest arc and not `[min(lng), max(lng)]`: the naive extremes read
76
+ * the circle as a line, so a set straddling the antimeridian (say 179 and -179,
77
+ * two degrees apart) yields a 358-degree-wide box whose midpoint is 0 — the
78
+ * antipode of the data, half a planet away. MapLibre then places the markers in
79
+ * whichever world copy is nearest their previous screen position (`smartWrap`),
80
+ * which is how a fitted-looking camera ends up showing an empty ocean with the
81
+ * records sitting on a neighbouring copy of the world.
82
+ *
83
+ * The widest EMPTY gap between adjacent longitudes is the seam to cut; what
84
+ * remains is the shortest containing arc. `west` is the first marker east of
85
+ * that seam, and the span is measured eastward from it, so the box may extend
86
+ * past 180.
87
+ *
88
+ * @param coordinates marker coordinates in MapLibre order, `[lng, lat]`
89
+ * @returns the box, or `null` when there is nothing to fit
90
+ */
91
+ export declare function computeMarkerBounds(coordinates: ReadonlyArray<readonly [number, number]>): MarkerBounds | null;
92
+ /**
93
+ * Centre of a box from {@link computeMarkerBounds}, for the paths that cannot
94
+ * hand the box to a fit (a declared zoom with no declared centre). The
95
+ * longitude is folded back onto the circle so a box crossing the antimeridian
96
+ * still yields a real centre rather than a value past 180.
97
+ */
98
+ export declare function boundsCenter(bounds: MarkerBounds): {
99
+ longitude: number;
100
+ latitude: number;
101
+ };
102
+ //# sourceMappingURL=camera.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhE,uDAAuD;AACvD,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,iFAAiF;AACjF,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGtD;AAKD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACpD,YAAY,GAAG,IAAI,CA8BrB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAM1F"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,44 @@
1
1
  import { default as React } from 'react';
2
- import { ObjectMap, ObjectMapProps } from './ObjectMap';
2
+ import { ObjectMap, ObjectMapProps } from './ObjectMap.js';
3
3
  export { ObjectMap };
4
4
  export type { ObjectMapProps };
5
5
  export declare const ObjectMapRenderer: React.FC<any>;
6
+ /**
7
+ * ⛔ The bare `map` node type key is RETIRED (objectui#10393, executing the
8
+ * objectui#8008 family ruling of 2026-09-09, route 3). `object-map` is the one
9
+ * spelling this plugin serves.
10
+ *
11
+ * ## What was here, and why it went
12
+ *
13
+ * `ComponentRegistry.register('map', ObjectMapRenderer, { namespace: 'view',
14
+ * ... })` — a second key on the SAME renderer, which stored both `view:map`
15
+ * and the bare `map` fallback. The declared face admitted only one of the two:
16
+ * `ObjectMapSchema.type` is the literal `'object-map'` and `AnyComponentSchema`
17
+ * has no `map` arm, so a node authored `type: 'map'` failed validation
18
+ * (`invalid_union`) while the registry mounted it. Two published faces,
19
+ * opposite verdicts — the shape objectui#8008 retired for `gantt`.
20
+ *
21
+ * ## Why unregistering is the whole retirement here — measured, not assumed
22
+ *
23
+ * ⚠️ `BaseSchema` closes with `[key: string]: any` and `BaseSchemaCore` ends
24
+ * `.passthrough()`, so a dropped MEMBER KEY is KEPT, not refused (the
25
+ * objectui#7664 failure). That hazard needs a schema face to arise on, and this
26
+ * TYPE NAME never had one: in `@object-ui/types` the literal `'map'` appears
27
+ * only in the stored view-type unions (`NamedListView.type`,
28
+ * `defaultViewType`), never as a component node type, against a firing control
29
+ * of two for `object-map` (`objectql.ts` + its Zod mirror). There is no arm to
30
+ * convert into a named refusal, so unregistering IS the retirement.
31
+ *
32
+ * ## ⛔ Two layers, and only one of them moved
33
+ *
34
+ * The string `map` also names a STORED `NamedListView.type` — the value
35
+ * `CreateViewDialog` writes and every tenant's database holds. That layer is
36
+ * untouched: `plugin-view`'s `ObjectView` and `plugin-list`'s `ListView` each
37
+ * map a stored `map` view onto the node type they emit (their `case 'map'`
38
+ * branches), and both already emit `object-map`. ⇒ Every map view any user
39
+ * ever created through the console already renders through the surviving
40
+ * spelling; this retirement moves zero stored documents.
41
+ *
42
+ * Pinned in `src/index.bareMapKeyRetired-10393.test.tsx`.
43
+ */
6
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,CAAC;AAwB/B,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAgB3C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,CAAC;AAwB/B,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAgB1C,CAAC;AAmEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG"}