@opendfieldmap/map 0.2.0-beta → 0.2.2-beta

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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { OEM, OEMOptions } from './types';
2
2
  export type * from './types';
3
3
  export { gameToOEMPosition, gameXZToOEMPosition, mapToGameXZPosition, oemToGamePosition, toOEMMapPosition, fromOEMMapPosition, toOEMLeafletMapPosition } from '@opendfieldmap/core';
4
- export type { OEMGamePosition, OEMGameTransform, OEMGameXZPosition, OEMMapPosition } from '@opendfieldmap/core';
4
+ export type { OEMGamePosition, OEMGameTransform, OEMGameXZPosition, OEMMapOffset, OEMMapPosition } from '@opendfieldmap/core';
5
5
  /** Creates the framework-agnostic OEM rendering kernel in a browser. */
6
6
  export declare function createOEM(container: string | HTMLElement, options: OEMOptions): Promise<OEM>;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { loadOEMManifest, validateOEMManifest } from "@opendfieldmap/core";
3
3
  import { gameToOEMPosition, gameXZToOEMPosition, mapToGameXZPosition, oemToGamePosition, toOEMMapPosition, fromOEMMapPosition, toOEMLeafletMapPosition } from "@opendfieldmap/core";
4
4
  var runtimePromise;
5
- var loadRuntime = () => runtimePromise ??= import("./runtime-QH7IV2ZV.js");
5
+ var loadRuntime = () => runtimePromise ??= import("./runtime-6E7MGGCD.js");
6
6
  if (typeof document !== "undefined") void loadRuntime();
7
7
  async function createOEM(container, options) {
8
8
  if (typeof document === "undefined") throw new Error("createOEM must run in a browser");
@@ -20,6 +20,7 @@ async function createOEM(container, options) {
20
20
  const instance = new OEMClass(element, manifest, options);
21
21
  try {
22
22
  await instance.setFeatures(options.features ?? {});
23
+ await instance.prepareSubregionBoundaries();
23
24
  if (options.customPointsUrl !== void 0) await instance.loadCustomPoints(options.customPointsUrl);
24
25
  options.signal?.throwIfAborted();
25
26
  return instance;
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import { loadOEMManifest, validateOEMManifest } from '@opendfieldmap/core';\nimport type { OEM, OEMOptions } from './types';\nexport type * from './types';\nexport { gameToOEMPosition, gameXZToOEMPosition, mapToGameXZPosition, oemToGamePosition, toOEMMapPosition, fromOEMMapPosition, toOEMLeafletMapPosition } from '@opendfieldmap/core';\nexport type { OEMGamePosition, OEMGameTransform, OEMGameXZPosition, OEMMapPosition } from '@opendfieldmap/core';\n\ntype OEMRuntime = typeof import('./runtime');\nlet runtimePromise: Promise<OEMRuntime> | undefined;\nconst loadRuntime = (): Promise<OEMRuntime> => runtimePromise ??= import('./runtime');\n\nif (typeof document !== 'undefined') void loadRuntime();\n\n/** Creates the framework-agnostic OEM rendering kernel in a browser. */\nexport async function createOEM(container: string | HTMLElement, options: OEMOptions): Promise<OEM> {\n if (typeof document === 'undefined') throw new Error('createOEM must run in a browser');\n if (options.customPoints !== undefined && options.customPointsUrl !== undefined) {\n throw new Error('Pass either customPoints or customPointsUrl, not both');\n }\n options.signal?.throwIfAborted();\n const element = typeof container === 'string' ? document.querySelector<HTMLElement>(container) : container;\n if (!element) throw new Error(`OEM container not found: ${container}`);\n const [manifest, { OEM: OEMClass }] = await Promise.all([\n options.manifest ? validateOEMManifest(options.manifest) : loadOEMManifest(options.resources, options.signal),\n loadRuntime(),\n ]);\n options.signal?.throwIfAborted();\n const instance = new OEMClass(element, manifest, options);\n try {\n await instance.setFeatures(options.features ?? {});\n if (options.customPointsUrl !== undefined) await instance.loadCustomPoints(options.customPointsUrl);\n options.signal?.throwIfAborted();\n return instance;\n } catch (error) {\n instance.destroy();\n throw error;\n }\n}\n"],
5
- "mappings": ";AAAA,SAAS,iBAAiB,2BAA2B;AAGrD,SAAS,mBAAmB,qBAAqB,qBAAqB,mBAAmB,kBAAkB,oBAAoB,+BAA+B;AAI9J,IAAI;AACJ,IAAM,cAAc,MAA2B,mBAAmB,OAAO,uBAAW;AAEpF,IAAI,OAAO,aAAa,YAAa,MAAK,YAAY;AAGtD,eAAsB,UAAU,WAAiC,SAAmC;AAClG,MAAI,OAAO,aAAa,YAAa,OAAM,IAAI,MAAM,iCAAiC;AACtF,MAAI,QAAQ,iBAAiB,UAAa,QAAQ,oBAAoB,QAAW;AAC/E,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,UAAQ,QAAQ,eAAe;AAC/B,QAAM,UAAU,OAAO,cAAc,WAAW,SAAS,cAA2B,SAAS,IAAI;AACjG,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,4BAA4B,SAAS,EAAE;AACrE,QAAM,CAAC,UAAU,EAAE,KAAK,SAAS,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,IACtD,QAAQ,WAAW,oBAAoB,QAAQ,QAAQ,IAAI,gBAAgB,QAAQ,WAAW,QAAQ,MAAM;AAAA,IAC5G,YAAY;AAAA,EACd,CAAC;AACD,UAAQ,QAAQ,eAAe;AAC/B,QAAM,WAAW,IAAI,SAAS,SAAS,UAAU,OAAO;AACxD,MAAI;AACF,UAAM,SAAS,YAAY,QAAQ,YAAY,CAAC,CAAC;AACjD,QAAI,QAAQ,oBAAoB,OAAW,OAAM,SAAS,iBAAiB,QAAQ,eAAe;AAClG,YAAQ,QAAQ,eAAe;AAC/B,WAAO;AAAA,EACT,SAAS,OAAO;AACd,aAAS,QAAQ;AACjB,UAAM;AAAA,EACR;AACF;",
4
+ "sourcesContent": ["import { loadOEMManifest, validateOEMManifest } from '@opendfieldmap/core';\nimport type { OEM, OEMOptions } from './types';\nexport type * from './types';\nexport { gameToOEMPosition, gameXZToOEMPosition, mapToGameXZPosition, oemToGamePosition, toOEMMapPosition, fromOEMMapPosition, toOEMLeafletMapPosition } from '@opendfieldmap/core';\nexport type { OEMGamePosition, OEMGameTransform, OEMGameXZPosition, OEMMapOffset, OEMMapPosition } from '@opendfieldmap/core';\n\ntype OEMRuntime = typeof import('./runtime');\nlet runtimePromise: Promise<OEMRuntime> | undefined;\nconst loadRuntime = (): Promise<OEMRuntime> => runtimePromise ??= import('./runtime');\n\nif (typeof document !== 'undefined') void loadRuntime();\n\n/** Creates the framework-agnostic OEM rendering kernel in a browser. */\nexport async function createOEM(container: string | HTMLElement, options: OEMOptions): Promise<OEM> {\n if (typeof document === 'undefined') throw new Error('createOEM must run in a browser');\n if (options.customPoints !== undefined && options.customPointsUrl !== undefined) {\n throw new Error('Pass either customPoints or customPointsUrl, not both');\n }\n options.signal?.throwIfAborted();\n const element = typeof container === 'string' ? document.querySelector<HTMLElement>(container) : container;\n if (!element) throw new Error(`OEM container not found: ${container}`);\n const [manifest, { OEM: OEMClass }] = await Promise.all([\n options.manifest ? validateOEMManifest(options.manifest) : loadOEMManifest(options.resources, options.signal),\n loadRuntime(),\n ]);\n options.signal?.throwIfAborted();\n const instance = new OEMClass(element, manifest, options);\n try {\n await instance.setFeatures(options.features ?? {});\n await instance.prepareSubregionBoundaries();\n if (options.customPointsUrl !== undefined) await instance.loadCustomPoints(options.customPointsUrl);\n options.signal?.throwIfAborted();\n return instance;\n } catch (error) {\n instance.destroy();\n throw error;\n }\n}\n"],
5
+ "mappings": ";AAAA,SAAS,iBAAiB,2BAA2B;AAGrD,SAAS,mBAAmB,qBAAqB,qBAAqB,mBAAmB,kBAAkB,oBAAoB,+BAA+B;AAI9J,IAAI;AACJ,IAAM,cAAc,MAA2B,mBAAmB,OAAO,uBAAW;AAEpF,IAAI,OAAO,aAAa,YAAa,MAAK,YAAY;AAGtD,eAAsB,UAAU,WAAiC,SAAmC;AAClG,MAAI,OAAO,aAAa,YAAa,OAAM,IAAI,MAAM,iCAAiC;AACtF,MAAI,QAAQ,iBAAiB,UAAa,QAAQ,oBAAoB,QAAW;AAC/E,UAAM,IAAI,MAAM,uDAAuD;AAAA,EACzE;AACA,UAAQ,QAAQ,eAAe;AAC/B,QAAM,UAAU,OAAO,cAAc,WAAW,SAAS,cAA2B,SAAS,IAAI;AACjG,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,4BAA4B,SAAS,EAAE;AACrE,QAAM,CAAC,UAAU,EAAE,KAAK,SAAS,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,IACtD,QAAQ,WAAW,oBAAoB,QAAQ,QAAQ,IAAI,gBAAgB,QAAQ,WAAW,QAAQ,MAAM;AAAA,IAC5G,YAAY;AAAA,EACd,CAAC;AACD,UAAQ,QAAQ,eAAe;AAC/B,QAAM,WAAW,IAAI,SAAS,SAAS,UAAU,OAAO;AACxD,MAAI;AACF,UAAM,SAAS,YAAY,QAAQ,YAAY,CAAC,CAAC;AACjD,UAAM,SAAS,2BAA2B;AAC1C,QAAI,QAAQ,oBAAoB,OAAW,OAAM,SAAS,iBAAiB,QAAQ,eAAe;AAClG,YAAQ,QAAQ,eAAe;AAC/B,WAAO;AAAA,EACT,SAAS,OAAO;AACd,aAAS,QAAQ;AACjB,UAAM;AAAA,EACR;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,11 @@
1
+ import type { OEMBoundary } from '@opendfieldmap/core';
2
+ export type GeometryPoint = {
3
+ x: number;
4
+ z: number;
5
+ };
6
+ /** Scores a boundary for hit-testing, including polygon holes and edge distance. */
7
+ export declare const boundaryScore: (boundary: OEMBoundary, point: GeometryPoint) => {
8
+ id: string;
9
+ inside: boolean;
10
+ distance: number;
11
+ };
@@ -0,0 +1,12 @@
1
+ import type { OEMPoint, OEMPointFilter } from '@opendfieldmap/core';
2
+ import type { OEMCustomPoint } from '../types';
3
+ export declare const cloneFilter: (filter: OEMPointFilter) => OEMPointFilter;
4
+ export declare const sameFilter: (left: OEMPointFilter, right: OEMPointFilter) => boolean;
5
+ export declare const clonePoint: (point: OEMPoint) => OEMPoint;
6
+ export declare const cloneCustomPoint: (point: OEMCustomPoint) => OEMCustomPoint;
7
+ export declare const CLUSTER_SUBCATEGORIES: Set<string>;
8
+ export declare const FEATURE_NAMES: readonly ["points", "labels", "boundaries"];
9
+ export type OEMFeatureName = typeof FEATURE_NAMES[number];
10
+ export declare const BRAND_URL = "https://oem.re/";
11
+ export declare const GITHUB_URL = "https://github.com/Terra-Online/OEM-SDK";
12
+ export declare const TERMS_URL = "https://blog.opendfieldmap.org/docs/tos#intellectual-property-and-copyright";
@@ -0,0 +1 @@
1
+ export { OEM } from './oem';
@@ -0,0 +1,19 @@
1
+ import L from 'leaflet';
2
+ import type { OEMFloor, OEMRegion } from '@opendfieldmap/core';
3
+ import { SmoothTileLayer } from '../atlos/smoothTileLayer';
4
+ /** Leaflet marker with the subpixel positioning used by Atlos. */
5
+ export declare class OEMMarker extends L.Marker {
6
+ update(): this;
7
+ _animateZoom(event: {
8
+ center: L.LatLng;
9
+ zoom: number;
10
+ }): void;
11
+ }
12
+ /** Tile layer that skips coordinates absent from the published coverage index. */
13
+ export declare class CoveredTileLayer extends SmoothTileLayer {
14
+ private coverage;
15
+ private floor;
16
+ constructor(url: string, options: L.TileLayerOptions, coverage: OEMRegion['coverage'], floor: OEMFloor);
17
+ getTileUrl(coords: L.Coords): string;
18
+ _isValidTile(coords: L.Coords): boolean;
19
+ }
@@ -0,0 +1,145 @@
1
+ import 'leaflet.markercluster';
2
+ import type { OEMManifest, OEMPoint, OEMPointFilter, OEMPosition, OEMView } from '@opendfieldmap/core';
3
+ import type { OEM as OEMContract, OEMClickPointOptions, OEMCustomPoint, OEMEvents, OEMFeatures, OEMOptions, OEMZoomOptions } from '../types';
4
+ /** Leaflet-backed implementation of the public OEM interface. */
5
+ export declare class OEM implements OEMContract {
6
+ private container;
7
+ readonly manifest: OEMManifest;
8
+ private options;
9
+ destroyed: boolean;
10
+ private map;
11
+ private root;
12
+ private region;
13
+ private floorId;
14
+ private features;
15
+ private boundarySource;
16
+ private listeners;
17
+ private requests;
18
+ private baseTiles?;
19
+ private floorTiles?;
20
+ private pointsLayer;
21
+ private customPointsLayer;
22
+ private pointClusters;
23
+ private labelsLayer;
24
+ private boundariesLayer;
25
+ private points;
26
+ private customPoints;
27
+ private clickPoints;
28
+ private clickPointOptions?;
29
+ private clickPointSequence;
30
+ private customPointsRequest?;
31
+ private pointIndex?;
32
+ private pointIndexRequest?;
33
+ private pointShardRequests;
34
+ private boundaryData;
35
+ private boundaryDataRequests;
36
+ private types;
37
+ private labels;
38
+ private visibleLabelType?;
39
+ private messages;
40
+ private filter;
41
+ private markerClustering;
42
+ private locale;
43
+ private resolvedLocale;
44
+ private attributionBrand;
45
+ private attributionLink;
46
+ private observer?;
47
+ private updatingView;
48
+ private emittedView?;
49
+ private overdragFrame?;
50
+ private overdragged;
51
+ private wheel;
52
+ constructor(container: HTMLElement, manifest: OEMManifest, options: OEMOptions);
53
+ /** Prevents calls against a released map instance. */
54
+ private assertAlive;
55
+ private validateFloor;
56
+ private validatePosition;
57
+ private normalizeCustomPoints;
58
+ private normalizeClickPointOptions;
59
+ private position;
60
+ private loadOEMBoundaryData;
61
+ /** Preloads OEM subregion geometry so map clicks can resolve an exact subregion. */
62
+ prepareSubregionBoundaries(): Promise<void>;
63
+ private inferSubregionId;
64
+ private emitMapClick;
65
+ private emit;
66
+ private scheduleOverdragUpdate;
67
+ private clearOverdrag;
68
+ /** Emits one resolved view for duplicate Leaflet move and zoom events. */
69
+ private emitView;
70
+ /** Resolves the compact attribution without inheriting the map control font. */
71
+ private updateAttribution;
72
+ on<Event extends keyof OEMEvents>(event: Event, handler: (payload: OEMEvents[Event]) => void): () => void;
73
+ /** Rebuilds the base map constraints and main tile layer for one region. */
74
+ private applyRegion;
75
+ /** Converts the region's published pixel extent to Simple CRS bounds. */
76
+ private regionBounds;
77
+ /** Creates a coverage-aware layer for one region floor. */
78
+ private makeTiles;
79
+ private clampZoom;
80
+ /** Returns the current view in the OEM pixel coordinate system. */
81
+ getView(): OEMView;
82
+ /** Sets the view without exposing Leaflet's coordinate objects. */
83
+ setView(view: OEMView): void;
84
+ /** Changes zoom around the current center with an optional native transition. */
85
+ setZoom(zoom: number, options?: OEMZoomOptions): void;
86
+ /** Fits the map to an OEM pixel-coordinate extent. */
87
+ fitBounds(bounds: [OEMPosition, OEMPosition]): void;
88
+ /** Switches regions and reloads only the features currently enabled. */
89
+ setRegion(regionId: string): Promise<void>;
90
+ /** Switches the rendered floor while retaining the current region view. */
91
+ setFloor(floorId: string): void;
92
+ /** Changes label language and applies the manifest fallback chain. */
93
+ setLocale(locale: string): Promise<void>;
94
+ /** Returns both the requested and resolved locale values. */
95
+ getLocale(): {
96
+ requested: string;
97
+ resolved: string;
98
+ };
99
+ /** Changes only this instance's theme attribute. */
100
+ setTheme(theme: 'light' | 'dark'): void;
101
+ /** Enables or disables static layers and cancels disabled layer requests. */
102
+ setFeatures(features: OEMFeatures): Promise<void>;
103
+ /** Replaces host-defined points without reloading static map data. */
104
+ setCustomPoints(points: readonly OEMCustomPoint[]): void;
105
+ /** Enables or disables automatic custom-point creation from map clicks. */
106
+ setClickPointMode(options?: OEMClickPointOptions | null): void;
107
+ /** Removes only points created by the click-point mode. */
108
+ clearClickPoints(): void;
109
+ loadCustomPoints(url: string): Promise<void>;
110
+ /** Removes all host-defined points from this map instance. */
111
+ clearCustomPoints(): void;
112
+ /** Returns a loaded published point from the current region, if available. */
113
+ getPoint(pointId: string): OEMPoint | undefined;
114
+ /** Loads one published point by using the release point index when available. */
115
+ loadPoint(pointId: string): Promise<OEMPoint | undefined>;
116
+ private loadPointIndex;
117
+ private loadPointShard;
118
+ private decodePointShard;
119
+ private cancelRequest;
120
+ private cancelRequests;
121
+ private loadFeatures;
122
+ /** Loads one feature with a request token so stale responses are ignored. */
123
+ private loadFeature;
124
+ /** Applies a client-side filter without making another network request. */
125
+ setPointFilter(filter: OEMPointFilter): void;
126
+ /** Enables or disables Atlos-style marker clustering without reloading point data. */
127
+ setMarkerClustering(enabled: boolean): void;
128
+ private clearPointLayers;
129
+ private createCustomPointVisual;
130
+ private renderCustomPoints;
131
+ /** Builds the shared Atlos marker composition for points and cluster summaries. */
132
+ private createMarkerVisual;
133
+ private createPointMarker;
134
+ private createPointCluster;
135
+ /** Rebuilds visible markers and groups eligible types with Atlos clustering rules. */
136
+ private renderPoints;
137
+ /** Renders Atlos-style fill and dashed stroke layers for published subregions. */
138
+ private renderBoundaries;
139
+ /** Renders Atlos site or subregion labels according to the current zoom. */
140
+ private renderLabels;
141
+ /** Recalculates Leaflet dimensions after the host element changes size. */
142
+ resize(): void;
143
+ /** Releases listeners, observers, pending requests, layers and DOM nodes. */
144
+ destroy: () => void;
145
+ }