@akanjs/client 0.0.53 → 0.0.55

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/src/device.cjs ADDED
@@ -0,0 +1,127 @@
1
+ "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var device_exports = {};
20
+ __export(device_exports, {
21
+ device: () => device
22
+ });
23
+ module.exports = __toCommonJS(device_exports);
24
+ var import_device = require("@capacitor/device");
25
+ var import_haptics = require("@capacitor/haptics");
26
+ var import_keyboard = require("@capacitor/keyboard");
27
+ var import_capacitor_plugin_safe_area = require("capacitor-plugin-safe-area");
28
+ var import_react_device_detect = require("react-device-detect");
29
+ class Device {
30
+ info;
31
+ lang;
32
+ topSafeArea;
33
+ bottomSafeArea;
34
+ isMobile = import_react_device_detect.isMobile;
35
+ #keyboard = import_keyboard.Keyboard;
36
+ #haptics = import_haptics.Haptics;
37
+ #pageContentRef = null;
38
+ async init({ lang, supportLanguages = [] } = {}) {
39
+ const [
40
+ info,
41
+ { value: languageCode },
42
+ {
43
+ insets: { top: topSafeArea, bottom: bottomSafeArea }
44
+ }
45
+ ] = await Promise.all([import_device.Device.getInfo(), import_device.Device.getLanguageCode(), import_capacitor_plugin_safe_area.SafeArea.getSafeAreaInsets()]);
46
+ const predefinedLangPath = window.location.pathname.split("/")[1]?.split("?")[0];
47
+ const predefinedLang = supportLanguages.find((language) => language === predefinedLangPath);
48
+ this.info = info;
49
+ this.lang = lang ?? predefinedLang ?? languageCode;
50
+ this.topSafeArea = topSafeArea;
51
+ this.bottomSafeArea = bottomSafeArea;
52
+ }
53
+ setPageContentRef(pageContentRef) {
54
+ this.#pageContentRef = pageContentRef;
55
+ }
56
+ async showKeyboard() {
57
+ if (this.info.platform === "web")
58
+ return;
59
+ await this.#keyboard.show();
60
+ }
61
+ async hideKeyboard() {
62
+ if (this.info.platform === "web")
63
+ return;
64
+ await this.#keyboard.hide();
65
+ }
66
+ listenKeyboardChanged(onKeyboardChanged) {
67
+ if (this.info.platform === "web")
68
+ return;
69
+ void this.#keyboard.addListener("keyboardWillShow", (keyboard) => {
70
+ onKeyboardChanged(keyboard.keyboardHeight);
71
+ });
72
+ void this.#keyboard.addListener("keyboardDidShow", (keyboard) => {
73
+ onKeyboardChanged(keyboard.keyboardHeight);
74
+ });
75
+ void this.#keyboard.addListener("keyboardWillHide", () => {
76
+ onKeyboardChanged(0);
77
+ });
78
+ void this.#keyboard.addListener("keyboardDidHide", () => {
79
+ onKeyboardChanged(0);
80
+ });
81
+ }
82
+ unlistenKeyboardChanged() {
83
+ if (this.info.platform === "web")
84
+ return;
85
+ void this.#keyboard.removeAllListeners();
86
+ }
87
+ async vibrate(type = "medium") {
88
+ if (typeof type === "number") {
89
+ await this.#haptics.vibrate({ duration: type });
90
+ return;
91
+ }
92
+ const handleImpact = {
93
+ light: async () => {
94
+ await this.#haptics.impact({ style: import_haptics.ImpactStyle.Light });
95
+ },
96
+ medium: async () => {
97
+ await this.#haptics.impact({ style: import_haptics.ImpactStyle.Medium });
98
+ },
99
+ heavy: async () => {
100
+ await this.#haptics.impact({ style: import_haptics.ImpactStyle.Heavy });
101
+ },
102
+ selectionStart: async () => {
103
+ await this.#haptics.selectionStart();
104
+ },
105
+ selectionChanged: async () => {
106
+ await this.#haptics.selectionChanged();
107
+ },
108
+ selectionEnd: async () => {
109
+ await this.#haptics.selectionEnd();
110
+ }
111
+ };
112
+ await handleImpact[type]();
113
+ }
114
+ getScrollTop() {
115
+ if (this.info.platform === "web")
116
+ return window.scrollY;
117
+ return this.#pageContentRef?.current?.scrollTop ?? 0;
118
+ }
119
+ setScrollTop(scrollTop) {
120
+ if (this.info.platform === "web") {
121
+ window.scrollTo({ top: scrollTop });
122
+ return;
123
+ }
124
+ return this.#pageContentRef?.current?.scrollTo({ top: scrollTop });
125
+ }
126
+ }
127
+ const device = new Device();
package/src/device.js CHANGED
@@ -1,39 +1,17 @@
1
1
  "use client";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var device_exports = {};
20
- __export(device_exports, {
21
- device: () => device
22
- });
23
- module.exports = __toCommonJS(device_exports);
24
- var import_device = require("@capacitor/device");
25
- var import_haptics = require("@capacitor/haptics");
26
- var import_keyboard = require("@capacitor/keyboard");
27
- var import_capacitor_plugin_safe_area = require("capacitor-plugin-safe-area");
28
- var import_react_device_detect = require("react-device-detect");
2
+ import { Device as CapacitorDevice } from "@capacitor/device";
3
+ import { Haptics, ImpactStyle } from "@capacitor/haptics";
4
+ import { Keyboard } from "@capacitor/keyboard";
5
+ import { SafeArea } from "capacitor-plugin-safe-area";
6
+ import { isMobile } from "react-device-detect";
29
7
  class Device {
30
8
  info;
31
9
  lang;
32
10
  topSafeArea;
33
11
  bottomSafeArea;
34
- isMobile = import_react_device_detect.isMobile;
35
- #keyboard = import_keyboard.Keyboard;
36
- #haptics = import_haptics.Haptics;
12
+ isMobile = isMobile;
13
+ #keyboard = Keyboard;
14
+ #haptics = Haptics;
37
15
  #pageContentRef = null;
38
16
  async init({ lang, supportLanguages = [] } = {}) {
39
17
  const [
@@ -42,7 +20,7 @@ class Device {
42
20
  {
43
21
  insets: { top: topSafeArea, bottom: bottomSafeArea }
44
22
  }
45
- ] = await Promise.all([import_device.Device.getInfo(), import_device.Device.getLanguageCode(), import_capacitor_plugin_safe_area.SafeArea.getSafeAreaInsets()]);
23
+ ] = await Promise.all([CapacitorDevice.getInfo(), CapacitorDevice.getLanguageCode(), SafeArea.getSafeAreaInsets()]);
46
24
  const predefinedLangPath = window.location.pathname.split("/")[1]?.split("?")[0];
47
25
  const predefinedLang = supportLanguages.find((language) => language === predefinedLangPath);
48
26
  this.info = info;
@@ -91,13 +69,13 @@ class Device {
91
69
  }
92
70
  const handleImpact = {
93
71
  light: async () => {
94
- await this.#haptics.impact({ style: import_haptics.ImpactStyle.Light });
72
+ await this.#haptics.impact({ style: ImpactStyle.Light });
95
73
  },
96
74
  medium: async () => {
97
- await this.#haptics.impact({ style: import_haptics.ImpactStyle.Medium });
75
+ await this.#haptics.impact({ style: ImpactStyle.Medium });
98
76
  },
99
77
  heavy: async () => {
100
- await this.#haptics.impact({ style: import_haptics.ImpactStyle.Heavy });
78
+ await this.#haptics.impact({ style: ImpactStyle.Heavy });
101
79
  },
102
80
  selectionStart: async () => {
103
81
  await this.#haptics.selectionStart();
@@ -125,3 +103,6 @@ class Device {
125
103
  }
126
104
  }
127
105
  const device = new Device();
106
+ export {
107
+ device
108
+ };
package/src/index.cjs ADDED
@@ -0,0 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./types"), module.exports);
18
+ __reExport(src_exports, require("./csrTypes"), module.exports);
19
+ __reExport(src_exports, require("./router"), module.exports);
20
+ __reExport(src_exports, require("./cookie"), module.exports);
21
+ __reExport(src_exports, require("./storage"), module.exports);
22
+ __reExport(src_exports, require("./device"), module.exports);
23
+ __reExport(src_exports, require("./createFont"), module.exports);
package/src/index.js CHANGED
@@ -1,23 +1,7 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var src_exports = {};
16
- module.exports = __toCommonJS(src_exports);
17
- __reExport(src_exports, require("./types"), module.exports);
18
- __reExport(src_exports, require("./csrTypes"), module.exports);
19
- __reExport(src_exports, require("./router"), module.exports);
20
- __reExport(src_exports, require("./cookie"), module.exports);
21
- __reExport(src_exports, require("./storage"), module.exports);
22
- __reExport(src_exports, require("./device"), module.exports);
23
- __reExport(src_exports, require("./createFont"), module.exports);
1
+ export * from "./types";
2
+ export * from "./csrTypes";
3
+ export * from "./router";
4
+ export * from "./cookie";
5
+ export * from "./storage";
6
+ export * from "./device";
7
+ export * from "./createFont";
@@ -0,0 +1,47 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var navigation_exports = {};
19
+ __export(navigation_exports, {
20
+ NextResponse: () => NextResponse,
21
+ notFound: () => notFound,
22
+ redirect: () => redirect,
23
+ useParams: () => useParams,
24
+ usePathname: () => usePathname,
25
+ useRouter: () => useRouter,
26
+ useSearchParams: () => useSearchParams
27
+ });
28
+ module.exports = __toCommonJS(navigation_exports);
29
+ const notFound = () => {
30
+ throw new Error("Not found");
31
+ };
32
+ const redirect = (url) => {
33
+ };
34
+ const useParams = () => {
35
+ };
36
+ const usePathname = () => {
37
+ };
38
+ const useRouter = () => {
39
+ };
40
+ const useSearchParams = () => {
41
+ };
42
+ const NextResponse = {
43
+ next: () => {
44
+ },
45
+ redirect: (url) => {
46
+ }
47
+ };
package/src/navigation.js CHANGED
@@ -1,31 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var navigation_exports = {};
19
- __export(navigation_exports, {
20
- NextResponse: () => NextResponse,
21
- notFound: () => notFound,
22
- redirect: () => redirect,
23
- useParams: () => useParams,
24
- usePathname: () => usePathname,
25
- useRouter: () => useRouter,
26
- useSearchParams: () => useSearchParams
27
- });
28
- module.exports = __toCommonJS(navigation_exports);
29
1
  const notFound = () => {
30
2
  throw new Error("Not found");
31
3
  };
@@ -45,3 +17,12 @@ const NextResponse = {
45
17
  redirect: (url) => {
46
18
  }
47
19
  };
20
+ export {
21
+ NextResponse,
22
+ notFound,
23
+ redirect,
24
+ useParams,
25
+ usePathname,
26
+ useRouter,
27
+ useSearchParams
28
+ };
package/src/router.cjs ADDED
@@ -0,0 +1,214 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var router_exports = {};
19
+ __export(router_exports, {
20
+ getPathInfo: () => getPathInfo,
21
+ router: () => router
22
+ });
23
+ module.exports = __toCommonJS(router_exports);
24
+ var import_base = require("@akanjs/base");
25
+ var import_common = require("@akanjs/common");
26
+ var import_navigation = require("next/navigation");
27
+ const getPathInfo = (href, lang, prefix) => {
28
+ const langLength = lang.length + 1;
29
+ const pathWithSubRoute = href === `/${lang}` ? "/" : href.startsWith(`/${lang}/`) ? href.slice(langLength) : href;
30
+ const prefixLength = prefix ? prefix.length + 1 : 0;
31
+ const path = !prefixLength ? pathWithSubRoute : pathWithSubRoute === `/${prefix}` ? "/" : pathWithSubRoute.startsWith(`/${prefix}`) ? pathWithSubRoute.slice(prefixLength) : pathWithSubRoute;
32
+ const subRoute = prefix ? `/${prefix}` : "";
33
+ const pathname = path.startsWith("http") ? path : path === "/" ? `/${lang}${subRoute}` : `/${lang}${subRoute}${path}`;
34
+ return { path, pathname };
35
+ };
36
+ class Router {
37
+ isInitialized = false;
38
+ #prefix = "";
39
+ #lang = "en";
40
+ #instance = {
41
+ push: (href) => {
42
+ const { pathname } = this.#getPathInfo(href);
43
+ import_common.Logger.log(`push to:${pathname}`);
44
+ if (import_base.baseClientEnv.side === "server")
45
+ void (0, import_navigation.redirect)(pathname);
46
+ },
47
+ replace: (href) => {
48
+ const { pathname } = this.#getPathInfo(href);
49
+ import_common.Logger.log(`replace to:${pathname}`);
50
+ if (import_base.baseClientEnv.side === "server")
51
+ void (0, import_navigation.redirect)(pathname);
52
+ },
53
+ back: () => {
54
+ throw new Error("back is only available in client");
55
+ },
56
+ refresh: () => {
57
+ throw new Error("refresh is only available in client");
58
+ }
59
+ };
60
+ init(options) {
61
+ this.#prefix = options.prefix ?? "";
62
+ this.#lang = options.lang ?? "en";
63
+ if (options.type === "csr")
64
+ this.#initCSRClientRouter(options);
65
+ else if (options.side === "server")
66
+ this.#initNextServerRouter(options);
67
+ else
68
+ this.#initNextClientRouter(options);
69
+ this.isInitialized = true;
70
+ import_common.Logger.verbose("Router initialized");
71
+ }
72
+ #initNextServerRouter(options) {
73
+ }
74
+ #initNextClientRouter(options) {
75
+ this.#instance = {
76
+ push: (href) => {
77
+ const { path, pathname } = this.#getPathInfo(href);
78
+ this.#postPathChange({ path, pathname });
79
+ options.router.push(pathname);
80
+ },
81
+ replace: (href) => {
82
+ const { path, pathname } = this.#getPathInfo(href);
83
+ this.#postPathChange({ path, pathname });
84
+ options.router.replace(pathname);
85
+ },
86
+ back: () => {
87
+ const { path, pathname } = this.#getPathInfo(document.referrer);
88
+ this.#postPathChange({ path, pathname });
89
+ options.router.back();
90
+ },
91
+ refresh: () => {
92
+ const { path, pathname } = this.#getPathInfo(location.pathname);
93
+ this.#postPathChange({ path, pathname });
94
+ options.router.refresh();
95
+ }
96
+ };
97
+ }
98
+ #initCSRClientRouter(options) {
99
+ this.#instance = {
100
+ push: (href) => {
101
+ const { path, pathname } = this.#getPathInfo(href);
102
+ if (location.pathname === pathname)
103
+ return;
104
+ this.#postPathChange({ path, pathname });
105
+ options.router.push(pathname);
106
+ },
107
+ replace: (href) => {
108
+ const { path, pathname } = this.#getPathInfo(href);
109
+ if (location.pathname === pathname)
110
+ return;
111
+ this.#postPathChange({ path, pathname });
112
+ options.router.replace(pathname);
113
+ },
114
+ back: () => {
115
+ const { path, pathname } = this.#getPathInfo(document.referrer);
116
+ if (location.pathname === pathname)
117
+ return;
118
+ this.#postPathChange({ path, pathname });
119
+ options.router.back();
120
+ },
121
+ refresh: () => {
122
+ const { path, pathname } = this.#getPathInfo(location.pathname);
123
+ this.#postPathChange({ path, pathname });
124
+ options.router.refresh();
125
+ }
126
+ };
127
+ }
128
+ #checkInitialized() {
129
+ if (!this.isInitialized)
130
+ throw new Error("Router is not initialized");
131
+ }
132
+ #getPathInfo(href, prefix = this.#prefix) {
133
+ return getPathInfo(href, this.#lang, prefix);
134
+ }
135
+ #postPathChange({ path, pathname }) {
136
+ import_common.Logger.log(`pathChange-start:${path}`);
137
+ window.parent.postMessage({ type: "pathChange", path, pathname }, "*");
138
+ }
139
+ push(href) {
140
+ this.#checkInitialized();
141
+ this.#instance.push(href);
142
+ return void 0;
143
+ }
144
+ replace(href) {
145
+ this.#checkInitialized();
146
+ this.#instance.replace(href);
147
+ return void 0;
148
+ }
149
+ back() {
150
+ if (import_base.baseClientEnv.side === "server")
151
+ throw new Error("back is only available in client side");
152
+ this.#checkInitialized();
153
+ this.#instance.back();
154
+ return void 0;
155
+ }
156
+ refresh() {
157
+ if (import_base.baseClientEnv.side === "server")
158
+ throw new Error("refresh is only available in client side");
159
+ this.#checkInitialized();
160
+ this.#instance.refresh();
161
+ return void 0;
162
+ }
163
+ async redirect(href) {
164
+ if (import_base.baseClientEnv.side === "server") {
165
+ const nextHeaders = require("next/headers");
166
+ const headers = await nextHeaders.headers?.() ?? /* @__PURE__ */ new Map();
167
+ const lang = headers.get("x-locale") ?? this.#lang;
168
+ const basePath = headers.get("x-base-path");
169
+ const { pathname } = getPathInfo(href, lang, basePath ?? "");
170
+ import_common.Logger.log(`redirect to:${pathname}`);
171
+ (0, import_navigation.redirect)(pathname);
172
+ } else {
173
+ const { pathname } = getPathInfo(href, this.#lang, this.#prefix);
174
+ this.#instance.replace(pathname);
175
+ }
176
+ return void 0;
177
+ }
178
+ notFound() {
179
+ this.#checkInitialized();
180
+ if (import_base.baseClientEnv.side === "server") {
181
+ import_common.Logger.log(`redirect to:/404`);
182
+ (0, import_navigation.notFound)();
183
+ } else
184
+ this.#instance.replace("/404");
185
+ return void 0;
186
+ }
187
+ setLang(lang) {
188
+ if (import_base.baseClientEnv.side === "server")
189
+ throw new Error("setLang is only available in client side");
190
+ this.#checkInitialized();
191
+ const { path } = getPathInfo(window.location.pathname, this.#lang, this.#prefix);
192
+ this.#lang = lang;
193
+ this.#instance.replace(`/${lang}${path}`);
194
+ return void 0;
195
+ }
196
+ getPath(pathname = window.location.pathname) {
197
+ if (import_base.baseClientEnv.side === "server")
198
+ throw new Error("getPath is only available in client side");
199
+ const { path } = getPathInfo(pathname, this.#lang, this.#prefix);
200
+ return path;
201
+ }
202
+ getFullPath(withLang = true) {
203
+ if (import_base.baseClientEnv.side === "server")
204
+ throw new Error("getPath is only available in client side");
205
+ return `${withLang ? `/${this.#lang}` : ""}/${this.#prefix}${this.getPath()}`;
206
+ }
207
+ getPrefix() {
208
+ return this.#prefix;
209
+ }
210
+ getPrefixedPath(path) {
211
+ return this.#prefix ? `${this.#lang ? `/${this.#lang}` : ""}/${this.#prefix}${path}` : path;
212
+ }
213
+ }
214
+ const router = new Router();