@maplat/ui 0.11.11 → 0.12.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.
@@ -3335,7 +3335,7 @@ This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;
3335
3335
  registerRoute(
3336
3336
  /(?:maps\/.+\.json|pwa\/.+|pois\/.+\.json|apps\/.+\.json|tmbs\/.+\.jpg|images\/.+\.(?:png|jpg))$/,
3337
3337
  new StaleWhileRevalidate({
3338
- cacheName: `resourcesCache-${"2026-01-08-09-43"}`,
3338
+ cacheName: `resourcesCache-${"2026-01-12-04-59"}`,
3339
3339
  plugins: [
3340
3340
  new ExpirationPlugin({
3341
3341
  maxAgeSeconds: 86400,
package/dist/types.d.ts CHANGED
@@ -1,185 +1,195 @@
1
- import { Swiper as SwiperClass } from 'swiper';
2
- import { Control } from 'ol/control';
3
- import { MaplatUi } from './index';
4
- export interface MaplatAppOption {
5
- appid?: string;
6
- fake?: boolean;
7
- pwaManifest?: boolean | string;
8
- pwaWorker?: string;
9
- pwaScope?: string;
10
- overlay?: boolean;
11
- enableHideMarker?: boolean;
12
- enableMarkerList?: boolean;
13
- enableBorder?: boolean;
14
- enableCache?: boolean;
15
- stateUrl?: boolean;
16
- enableShare?: boolean;
17
- enablePoiHtmlNoScroll?: boolean;
18
- disableNoimage?: boolean;
19
- alwaysGpsOn?: boolean;
20
- mobileIF?: boolean;
21
- debug?: boolean;
22
- appEnvelope?: boolean;
23
- mapboxToken?: string;
24
- googleApiKey?: string;
25
- lang?: string;
26
- restore?: RestoreState;
27
- restoreSession?: boolean;
28
- presentationMode?: boolean;
29
- northTop?: boolean;
30
- mapboxgl?: unknown;
31
- maplibregl?: unknown;
32
- markerList?: boolean;
33
- icon?: string;
34
- translateUI?: boolean;
35
- }
36
- export interface RestoreState {
37
- mapID?: string;
38
- backgroundID?: string;
39
- transparency?: number;
40
- position?: {
41
- rotation?: number;
42
- zoom?: number;
43
- x?: number;
44
- y?: number;
45
- };
46
- showBorder?: boolean;
47
- hideMarker?: boolean;
48
- hideLayer?: string;
49
- openedMarker?: string;
50
- }
51
- export interface MapSource {
52
- mapID: string;
53
- title?: string;
54
- officialTitle?: string;
55
- label?: string;
56
- width?: number;
57
- height?: number;
58
- envelope?: {
59
- geometry: {
60
- coordinates: number[][][];
61
- };
62
- };
63
- envelopeColor?: string;
64
- envelopeAreaIndex?: number;
65
- xy2SysCoord?: (xy: number[]) => Promise<number[]> | number[];
66
- thumbnail?: string;
67
- }
68
- export type MediaObject = {
69
- src: string;
70
- thumbnail?: string;
71
- type?: string;
72
- caption?: string;
73
- desc?: string;
74
- "fit-to-container"?: boolean;
75
- "debug-mode"?: boolean;
76
- "camera-position"?: string;
77
- "camera-target"?: string;
78
- "show-texture"?: boolean;
79
- [key: string]: unknown;
80
- };
81
- export type MediaSetting = string | MediaObject;
82
- export interface MarkerData {
83
- markerId: string;
84
- lnglat?: number[];
85
- title?: string;
86
- icon?: string;
87
- description?: string;
88
- images?: string[];
89
- image?: MediaSetting | MediaSetting[];
90
- media?: MediaSetting | MediaSetting[];
91
- address?: string;
92
- desc?: string;
93
- url?: string;
94
- html?: string;
95
- directgo?: string | {
96
- href: string;
97
- blank?: boolean;
98
- };
99
- namespaceID?: string;
100
- name?: string;
101
- }
102
- export interface ClickMarkersEvent {
103
- pixel: number[];
104
- coord: number[];
105
- list: MarkerData[];
106
- }
107
- export interface ContextMenuInterface {
108
- clear: () => void;
109
- extend: (items: unknown[]) => void;
110
- on: (event: string, handler: (e: unknown) => void) => void;
111
- un: (event: string, handler: (e: unknown) => void) => void;
112
- Internal?: {
113
- openMenu: (pixel: number[], coord: number[]) => void;
114
- closeMenu: () => void;
115
- opened: boolean;
116
- };
117
- }
118
- export interface ClickMarkersEvent {
119
- pixel: number[];
120
- coord: number[];
121
- list: MarkerData[];
122
- }
123
- export type EventCallback = (event: unknown) => void;
124
- export type SwiperInstance = SwiperClass;
125
- export type SliderControl = Control & {
126
- get(prop: string): number;
127
- set(prop: string, value: number): void;
128
- element?: HTMLElement;
129
- setEnable(flag: boolean): void;
130
- };
131
- export interface RGB {
132
- red: number;
133
- green: number;
134
- blue: number;
135
- }
136
- export interface ControlOptions {
137
- target?: HTMLElement | string;
138
- render?: (event: import('ol').MapEvent) => void;
139
- className?: string;
140
- tipLabel?: string;
141
- initialValue?: number;
142
- character?: string;
143
- callback?: (this: Control) => void;
144
- long_callback?: (this: Control) => void;
145
- cls?: string;
146
- ui?: MaplatUi;
147
- zoomInLabel?: string | HTMLElement;
148
- zoomOutLabel?: string | HTMLElement;
149
- autoHide?: boolean;
150
- label?: string | HTMLElement;
151
- reverse?: boolean;
152
- }
153
- export interface ContextMenuItem {
154
- text?: string;
155
- classname?: string;
156
- icon?: string;
157
- callback?: (obj: {
158
- coordinate: number[];
159
- data: unknown;
160
- }, map: unknown) => void;
161
- data?: unknown;
162
- items?: ContextMenuItem[];
163
- separator?: boolean;
164
- }
165
- export interface ContextMenuOptions {
166
- width?: number;
167
- defaultItems?: boolean;
168
- items?: ContextMenuItem[];
169
- eventType?: string;
170
- }
171
- export interface ContextMenuInternalItem {
172
- id: string;
173
- submenu: number;
174
- separator: boolean;
175
- callback?: (obj: {
176
- coordinate: number[];
177
- data: unknown;
178
- }, map: unknown) => void;
179
- data?: unknown;
180
- }
181
- export interface ContextMenuEvent {
182
- type: string;
183
- pixel?: number[];
184
- coordinate?: number[];
185
- }
1
+ import { Swiper as SwiperClass } from 'swiper';
2
+ import { Control } from 'ol/control';
3
+ import { MaplatUi } from './index';
4
+ export interface MaplatAppOption {
5
+ appid?: string;
6
+ fake?: boolean;
7
+ pwaManifest?: boolean | string;
8
+ pwaWorker?: string;
9
+ pwaScope?: string;
10
+ overlay?: boolean;
11
+ enableHideMarker?: boolean;
12
+ enableMarkerList?: boolean;
13
+ enableBorder?: boolean;
14
+ enableCache?: boolean;
15
+ stateUrl?: boolean;
16
+ enableShare?: boolean;
17
+ enablePoiHtmlNoScroll?: boolean;
18
+ disableNoimage?: boolean;
19
+ alwaysGpsOn?: boolean;
20
+ mobileIF?: boolean;
21
+ debug?: boolean;
22
+ appEnvelope?: boolean;
23
+ mapboxToken?: string;
24
+ googleApiKey?: string;
25
+ lang?: string;
26
+ restore?: RestoreState;
27
+ restoreSession?: boolean;
28
+ presentationMode?: boolean;
29
+ northTop?: boolean;
30
+ mapboxgl?: unknown;
31
+ maplibregl?: unknown;
32
+ markerList?: boolean;
33
+ icon?: string;
34
+ translateUI?: boolean;
35
+ uiHooks?: MaplatUiHooks;
36
+ }
37
+ export interface MaplatUiHooks {
38
+ onSettingLoaded?: (context: unknown) => Promise<unknown> | unknown;
39
+ onAppdataReady?: (context: unknown) => Promise<unknown> | unknown;
40
+ onUiConfigure?: (context: unknown) => Promise<unknown> | unknown;
41
+ onCoreDomReady?: (context: unknown) => Promise<unknown> | unknown;
42
+ onUiDomReady?: (context: unknown) => Promise<unknown> | unknown;
43
+ onCoreReady?: (context: unknown) => Promise<unknown> | unknown;
44
+ onUiReady?: (context: unknown) => Promise<unknown> | unknown;
45
+ }
46
+ export interface RestoreState {
47
+ mapID?: string;
48
+ backgroundID?: string;
49
+ transparency?: number;
50
+ position?: {
51
+ rotation?: number;
52
+ zoom?: number;
53
+ x?: number;
54
+ y?: number;
55
+ };
56
+ showBorder?: boolean;
57
+ hideMarker?: boolean;
58
+ hideLayer?: string;
59
+ openedMarker?: string;
60
+ }
61
+ export interface MapSource {
62
+ mapID: string;
63
+ title?: string;
64
+ officialTitle?: string;
65
+ label?: string;
66
+ width?: number;
67
+ height?: number;
68
+ envelope?: {
69
+ geometry: {
70
+ coordinates: number[][][];
71
+ };
72
+ };
73
+ envelopeColor?: string;
74
+ envelopeAreaIndex?: number;
75
+ xy2SysCoord?: (xy: number[]) => Promise<number[]> | number[];
76
+ thumbnail?: string;
77
+ }
78
+ export type MediaObject = {
79
+ src: string;
80
+ thumbnail?: string;
81
+ type?: string;
82
+ caption?: string;
83
+ desc?: string;
84
+ "fit-to-container"?: boolean;
85
+ "debug-mode"?: boolean;
86
+ "camera-position"?: string;
87
+ "camera-target"?: string;
88
+ "show-texture"?: boolean;
89
+ [key: string]: unknown;
90
+ };
91
+ export type MediaSetting = string | MediaObject;
92
+ export interface MarkerData {
93
+ markerId: string;
94
+ lnglat?: number[];
95
+ title?: string;
96
+ icon?: string;
97
+ description?: string;
98
+ images?: string[];
99
+ image?: MediaSetting | MediaSetting[];
100
+ media?: MediaSetting | MediaSetting[];
101
+ address?: string;
102
+ desc?: string;
103
+ url?: string;
104
+ html?: string;
105
+ directgo?: string | {
106
+ href: string;
107
+ blank?: boolean;
108
+ };
109
+ namespaceID?: string;
110
+ name?: string;
111
+ }
112
+ export interface ClickMarkersEvent {
113
+ pixel: number[];
114
+ coord: number[];
115
+ list: MarkerData[];
116
+ }
117
+ export interface ContextMenuInterface {
118
+ clear: () => void;
119
+ extend: (items: unknown[]) => void;
120
+ on: (event: string, handler: (e: unknown) => void) => void;
121
+ un: (event: string, handler: (e: unknown) => void) => void;
122
+ Internal?: {
123
+ openMenu: (pixel: number[], coord: number[]) => void;
124
+ closeMenu: () => void;
125
+ opened: boolean;
126
+ };
127
+ }
128
+ export interface ClickMarkersEvent {
129
+ pixel: number[];
130
+ coord: number[];
131
+ list: MarkerData[];
132
+ }
133
+ export type EventCallback = (event: unknown) => void;
134
+ export type SwiperInstance = SwiperClass;
135
+ export type SliderControl = Control & {
136
+ get(prop: string): number;
137
+ set(prop: string, value: number): void;
138
+ element?: HTMLElement;
139
+ setEnable(flag: boolean): void;
140
+ };
141
+ export interface RGB {
142
+ red: number;
143
+ green: number;
144
+ blue: number;
145
+ }
146
+ export interface ControlOptions {
147
+ target?: HTMLElement | string;
148
+ render?: (event: import('ol').MapEvent) => void;
149
+ className?: string;
150
+ tipLabel?: string;
151
+ initialValue?: number;
152
+ character?: string;
153
+ callback?: (this: Control) => void;
154
+ long_callback?: (this: Control) => void;
155
+ cls?: string;
156
+ ui?: MaplatUi;
157
+ zoomInLabel?: string | HTMLElement;
158
+ zoomOutLabel?: string | HTMLElement;
159
+ autoHide?: boolean;
160
+ label?: string | HTMLElement;
161
+ reverse?: boolean;
162
+ }
163
+ export interface ContextMenuItem {
164
+ text?: string;
165
+ classname?: string;
166
+ icon?: string;
167
+ callback?: (obj: {
168
+ coordinate: number[];
169
+ data: unknown;
170
+ }, map: unknown) => void;
171
+ data?: unknown;
172
+ items?: ContextMenuItem[];
173
+ separator?: boolean;
174
+ }
175
+ export interface ContextMenuOptions {
176
+ width?: number;
177
+ defaultItems?: boolean;
178
+ items?: ContextMenuItem[];
179
+ eventType?: string;
180
+ }
181
+ export interface ContextMenuInternalItem {
182
+ id: string;
183
+ submenu: number;
184
+ separator: boolean;
185
+ callback?: (obj: {
186
+ coordinate: number[];
187
+ data: unknown;
188
+ }, map: unknown) => void;
189
+ data?: unknown;
190
+ }
191
+ export interface ContextMenuEvent {
192
+ type: string;
193
+ pixel?: number[];
194
+ coordinate?: number[];
195
+ }
@@ -1,13 +1,13 @@
1
- import * as bsn from "bootstrap.native";
2
- export declare function createElement(domStr: string): ChildNode[];
3
- export declare function prepareModal(modalElm: Element | HTMLElement, options?: any): bsn.Modal;
4
- export declare function resolveRelativeLink(file: string, fallbackPath: string | null): string;
5
- export declare function ellips(mapDivDocument: HTMLElement): void;
6
- export declare function isMaplatSource(source: unknown): source is {
7
- setGPSMarkerAsync: () => unknown;
8
- constructor: {
9
- isBasemap_?: boolean;
10
- };
11
- };
12
- export declare function isBasemap(source: unknown): boolean;
13
- export declare function encBytes(bytes: number): string;
1
+ import * as bsn from "bootstrap.native";
2
+ export declare function createElement(domStr: string): ChildNode[];
3
+ export declare function prepareModal(modalElm: Element | HTMLElement, options?: any): bsn.Modal;
4
+ export declare function resolveRelativeLink(file: string, fallbackPath: string | null): string;
5
+ export declare function ellips(mapDivDocument: HTMLElement): void;
6
+ export declare function isMaplatSource(source: unknown): source is {
7
+ setGPSMarkerAsync: () => unknown;
8
+ constructor: {
9
+ isBasemap_?: boolean;
10
+ };
11
+ };
12
+ export declare function isBasemap(source: unknown): boolean;
13
+ export declare function encBytes(bytes: number): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maplat/ui",
3
- "version": "0.11.11",
3
+ "version": "0.12.0",
4
4
  "description": "Maplat is the cool Historical Map/Illustrated Map Viewer.\nIt can transform each map coordinates with nonlinear but homeomorphic projection and makes possible that the maps can collaborate with GPS/accurate maps, without distorting original maps.",
5
5
  "type": "module",
6
6
  "main": "dist/maplat_ui.umd.js",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@c4h/chuci": "^0.2.5",
38
38
  "@c4h/weiwudi": "^0.2.1",
39
- "@maplat/core": "^0.12.6",
39
+ "@maplat/core": "0.13.0",
40
40
  "@turf/turf": "^7.3.1",
41
41
  "@types/page": "^1.11.9",
42
42
  "bootstrap.native": "^5.1.6",
@@ -0,0 +1,35 @@
1
+ const browserLanguage = (): string => {
2
+ const navigator = window.navigator;
3
+ const ua = navigator.userAgent.toLowerCase();
4
+
5
+ try {
6
+ let lang;
7
+ // Chrome
8
+ if (ua.indexOf("chrome") != -1) {
9
+ lang = (
10
+ navigator.languages[0] ||
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ (navigator as any).browserLanguage ||
13
+ navigator.language ||
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ (navigator as any).userLanguage
16
+ ).split(";");
17
+ return lang[0];
18
+ }
19
+ // Other
20
+ else {
21
+ lang = // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ (
23
+ (navigator as any).browserLanguage ||
24
+ navigator.language ||
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ (navigator as any).userLanguage
27
+ ).split(";");
28
+ return lang[0];
29
+ }
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ } catch (_e) {
32
+ return "";
33
+ }
34
+ };
35
+ export default browserLanguage;
package/src/index.ts CHANGED
@@ -77,6 +77,7 @@ export class MaplatUi extends EventTarget {
77
77
  lastClickCoordinate: Coordinate | undefined;
78
78
  lastGPSError: string | undefined;
79
79
  selectedMarkerNamespaceID: string | undefined;
80
+ lang = "ja";
80
81
 
81
82
  _t?: TFunction<"translation", undefined>;
82
83
  i18n?: i18n;
@@ -185,7 +186,6 @@ export class MaplatUi extends EventTarget {
185
186
  }
186
187
 
187
188
  this.restoring = false;
188
- console.log(`[Debug] Calling updateUrl from ChangeMap`);
189
189
  this.updateUrl();
190
190
  }
191
191
  if (this.waitReadyBridge) {
@@ -223,16 +223,24 @@ export class MaplatUi extends EventTarget {
223
223
  if (!dataFragment || typeof dataFragment === "string")
224
224
  return dataFragment as string;
225
225
  const langs = Object.keys(dataFragment);
226
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
227
- let key = langs.reduce((prev: any, curr, idx, arr) => {
228
- if (curr == this.core!.appLang) {
229
- prev = [dataFragment[curr], true];
230
- } else if (!prev || (curr == "en" && !prev[1])) {
231
- prev = [dataFragment[curr], false];
232
- }
233
- if (idx == arr.length - 1) return prev[0];
234
- return prev;
235
- }, undefined);
226
+
227
+ let key = langs.reduce(
228
+ (
229
+ prev: string | [string, boolean] | undefined,
230
+ curr: string,
231
+ idx: number,
232
+ arr: string[]
233
+ ) => {
234
+ if (curr == this.lang) {
235
+ prev = [dataFragment[curr], true];
236
+ } else if (!prev || (curr == "en" && !prev[1])) {
237
+ prev = [dataFragment[curr], false];
238
+ }
239
+ if (idx == arr.length - 1) return prev[0];
240
+ return prev;
241
+ },
242
+ undefined
243
+ );
236
244
 
237
245
  key = typeof key === "string" ? key : `${key}`;
238
246
  if (