@akanjs/client 0.0.39 → 0.0.40

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.js ADDED
@@ -0,0 +1,140 @@
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var device_exports = {};
21
+ __export(device_exports, {
22
+ device: () => device
23
+ });
24
+ module.exports = __toCommonJS(device_exports);
25
+ var import_device = require("@capacitor/device");
26
+ var import_haptics = require("@capacitor/haptics");
27
+ var import_keyboard = require("@capacitor/keyboard");
28
+ var import_capacitor_plugin_safe_area = require("capacitor-plugin-safe-area");
29
+ var import_react_device_detect = require("react-device-detect");
30
+ let Device = class Device2 {
31
+ static {
32
+ __name(this, "Device");
33
+ }
34
+ info;
35
+ lang;
36
+ topSafeArea;
37
+ bottomSafeArea;
38
+ isMobile = import_react_device_detect.isMobile;
39
+ #keyboard = import_keyboard.Keyboard;
40
+ #haptics = import_haptics.Haptics;
41
+ #pageContentRef = null;
42
+ async init({ lang, supportLanguages = [] } = {}) {
43
+ const [info, { value: languageCode }, { insets: { top: topSafeArea, bottom: bottomSafeArea } }] = await Promise.all([
44
+ import_device.Device.getInfo(),
45
+ import_device.Device.getLanguageCode(),
46
+ import_capacitor_plugin_safe_area.SafeArea.getSafeAreaInsets()
47
+ ]);
48
+ const predefinedLangPath = window.location.pathname.split("/")[1]?.split("?")[0];
49
+ const predefinedLang = supportLanguages.find((language) => language === predefinedLangPath);
50
+ this.info = info;
51
+ this.lang = lang ?? predefinedLang ?? languageCode;
52
+ this.topSafeArea = topSafeArea;
53
+ this.bottomSafeArea = bottomSafeArea;
54
+ }
55
+ setPageContentRef(pageContentRef) {
56
+ this.#pageContentRef = pageContentRef;
57
+ }
58
+ async showKeyboard() {
59
+ if (this.info.platform === "web") return;
60
+ await this.#keyboard.show();
61
+ }
62
+ async hideKeyboard() {
63
+ if (this.info.platform === "web") return;
64
+ await this.#keyboard.hide();
65
+ }
66
+ listenKeyboardChanged(onKeyboardChanged) {
67
+ if (this.info.platform === "web") return;
68
+ void this.#keyboard.addListener("keyboardWillShow", (keyboard) => {
69
+ onKeyboardChanged(keyboard.keyboardHeight);
70
+ });
71
+ void this.#keyboard.addListener("keyboardDidShow", (keyboard) => {
72
+ onKeyboardChanged(keyboard.keyboardHeight);
73
+ });
74
+ void this.#keyboard.addListener("keyboardWillHide", () => {
75
+ onKeyboardChanged(0);
76
+ });
77
+ void this.#keyboard.addListener("keyboardDidHide", () => {
78
+ onKeyboardChanged(0);
79
+ });
80
+ }
81
+ unlistenKeyboardChanged() {
82
+ if (this.info.platform === "web") return;
83
+ void this.#keyboard.removeAllListeners();
84
+ }
85
+ async vibrate(type = "medium") {
86
+ if (typeof type === "number") {
87
+ await this.#haptics.vibrate({
88
+ duration: type
89
+ });
90
+ return;
91
+ }
92
+ const handleImpact = {
93
+ light: /* @__PURE__ */ __name(async () => {
94
+ await this.#haptics.impact({
95
+ style: import_haptics.ImpactStyle.Light
96
+ });
97
+ }, "light"),
98
+ medium: /* @__PURE__ */ __name(async () => {
99
+ await this.#haptics.impact({
100
+ style: import_haptics.ImpactStyle.Medium
101
+ });
102
+ }, "medium"),
103
+ heavy: /* @__PURE__ */ __name(async () => {
104
+ await this.#haptics.impact({
105
+ style: import_haptics.ImpactStyle.Heavy
106
+ });
107
+ }, "heavy"),
108
+ selectionStart: /* @__PURE__ */ __name(async () => {
109
+ await this.#haptics.selectionStart();
110
+ }, "selectionStart"),
111
+ selectionChanged: /* @__PURE__ */ __name(async () => {
112
+ await this.#haptics.selectionChanged();
113
+ }, "selectionChanged"),
114
+ selectionEnd: /* @__PURE__ */ __name(async () => {
115
+ await this.#haptics.selectionEnd();
116
+ }, "selectionEnd")
117
+ };
118
+ await handleImpact[type]();
119
+ }
120
+ getScrollTop() {
121
+ if (this.info.platform === "web") return window.scrollY;
122
+ return this.#pageContentRef?.current?.scrollTop ?? 0;
123
+ }
124
+ setScrollTop(scrollTop) {
125
+ if (this.info.platform === "web") {
126
+ window.scrollTo({
127
+ top: scrollTop
128
+ });
129
+ return;
130
+ }
131
+ return this.#pageContentRef?.current?.scrollTo({
132
+ top: scrollTop
133
+ });
134
+ }
135
+ };
136
+ const device = new Device();
137
+ // Annotate the CommonJS export names for ESM import in node:
138
+ 0 && (module.exports = {
139
+ device
140
+ });
package/src/index.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export { DataAction, DataColumn, DataMenu, DataMenuItem, DataTool, MenuItem, ModelDashboardProps, ModelEditProps, ModelInsightProps, ModelProps, ModelViewProps, ModelsProps, ReactFont, RootLayoutProps, UserMenuItem, clsx, loadFonts } from './types.js';
2
+ export { ContainerTransition, CsrConfig, CsrContextType, CsrState, CsrTransitionStyles, DEFAULT_BOTTOM_INSET, DEFAULT_TOP_INSET, History, Location, LocationState, PageState, PageTransition, PathContextType, PathRoute, Route, RouteGuide, RouteState, RouterProps, SafeAreaTransition, TransitionStyle, TransitionType, UseCsrTransition, csrContext, defaultPageState, pathContext, useCsr, usePathCtx } from './csrTypes.js';
3
+ export { RouterInstance, getPathInfo, router } from './router.js';
4
+ export { GetOption, cookies, getAccount, getCookie, getHeader, getMe, getSelf, headers, initAuth, removeCookie, resetAuth, setAuth, setCookie } from './cookie.js';
5
+ export { storage } from './storage.js';
6
+ export { device } from './device.js';
7
+ export { Nanum_Gothic_Coding, Noto_Sans_KR, default as createFont } from './createFont.js';
8
+ import 'dayjs';
9
+ import 'clsx';
10
+ import 'react';
11
+ import '@use-gesture/react/dist/declarations/src/types';
12
+ import 'react-spring';
13
+ import 'js-cookie';
14
+ import '@capacitor/device';
package/src/index.js ADDED
@@ -0,0 +1,33 @@
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);
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ ...require("./types"),
27
+ ...require("./csrTypes"),
28
+ ...require("./router"),
29
+ ...require("./cookie"),
30
+ ...require("./storage"),
31
+ ...require("./device"),
32
+ ...require("./createFont")
33
+ });
@@ -0,0 +1,12 @@
1
+ declare const notFound: () => never;
2
+ declare const redirect: (url: string) => void;
3
+ declare const useParams: () => void;
4
+ declare const usePathname: () => void;
5
+ declare const useRouter: () => void;
6
+ declare const useSearchParams: () => void;
7
+ declare const NextResponse: {
8
+ next: () => void;
9
+ redirect: (url: string) => void;
10
+ };
11
+
12
+ export { NextResponse, notFound, redirect, useParams, usePathname, useRouter, useSearchParams };
@@ -0,0 +1,58 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 navigation_exports = {};
20
+ __export(navigation_exports, {
21
+ NextResponse: () => NextResponse,
22
+ notFound: () => notFound,
23
+ redirect: () => redirect,
24
+ useParams: () => useParams,
25
+ usePathname: () => usePathname,
26
+ useRouter: () => useRouter,
27
+ useSearchParams: () => useSearchParams
28
+ });
29
+ module.exports = __toCommonJS(navigation_exports);
30
+ const notFound = /* @__PURE__ */ __name(() => {
31
+ throw new Error("Not found");
32
+ }, "notFound");
33
+ const redirect = /* @__PURE__ */ __name((url) => {
34
+ }, "redirect");
35
+ const useParams = /* @__PURE__ */ __name(() => {
36
+ }, "useParams");
37
+ const usePathname = /* @__PURE__ */ __name(() => {
38
+ }, "usePathname");
39
+ const useRouter = /* @__PURE__ */ __name(() => {
40
+ }, "useRouter");
41
+ const useSearchParams = /* @__PURE__ */ __name(() => {
42
+ }, "useSearchParams");
43
+ const NextResponse = {
44
+ next: /* @__PURE__ */ __name(() => {
45
+ }, "next"),
46
+ redirect: /* @__PURE__ */ __name((url) => {
47
+ }, "redirect")
48
+ };
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ NextResponse,
52
+ notFound,
53
+ redirect,
54
+ useParams,
55
+ usePathname,
56
+ useRouter,
57
+ useSearchParams
58
+ });
@@ -0,0 +1,46 @@
1
+ interface RouterInstance {
2
+ push: (href: string) => void;
3
+ replace: (href: string) => void;
4
+ back: () => void;
5
+ refresh: () => void;
6
+ }
7
+ interface RouterOptions {
8
+ prefix?: string;
9
+ lang?: string;
10
+ }
11
+ interface NextServerRouterOption extends RouterOptions {
12
+ type: "next";
13
+ side: "server";
14
+ }
15
+ interface NextClientRouterOption extends RouterOptions {
16
+ type: "next";
17
+ side: "client";
18
+ router: RouterInstance;
19
+ }
20
+ interface CSRClientRouterOption extends RouterOptions {
21
+ type: "csr";
22
+ router: RouterInstance;
23
+ }
24
+ declare const getPathInfo: (href: string, lang: string, prefix: string) => {
25
+ path: string;
26
+ pathname: string;
27
+ };
28
+ declare class Router {
29
+ #private;
30
+ isInitialized: boolean;
31
+ init(options: NextClientRouterOption | NextServerRouterOption | CSRClientRouterOption): void;
32
+ push(href: string): never;
33
+ replace(href: string): never;
34
+ back(): never;
35
+ refresh(): never;
36
+ redirect(href: string): Promise<never>;
37
+ notFound(): never;
38
+ setLang(lang: string): never;
39
+ getPath(pathname?: string): string;
40
+ getFullPath(withLang?: boolean): string;
41
+ getPrefix(): string;
42
+ getPrefixedPath(path: string): string;
43
+ }
44
+ declare const router: Router;
45
+
46
+ export { type RouterInstance, getPathInfo, router };
package/src/router.js ADDED
@@ -0,0 +1,239 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 router_exports = {};
20
+ __export(router_exports, {
21
+ getPathInfo: () => getPathInfo,
22
+ router: () => router
23
+ });
24
+ module.exports = __toCommonJS(router_exports);
25
+ var import_base = require("@akanjs/base");
26
+ var import_common = require("@akanjs/common");
27
+ var import_navigation = require("next/navigation");
28
+ const getPathInfo = /* @__PURE__ */ __name((href, lang, prefix) => {
29
+ const langLength = lang.length + 1;
30
+ const pathWithSubRoute = href === `/${lang}` ? "/" : href.startsWith(`/${lang}/`) ? href.slice(langLength) : href;
31
+ const prefixLength = prefix ? prefix.length + 1 : 0;
32
+ const path = !prefixLength ? pathWithSubRoute : pathWithSubRoute === `/${prefix}` ? "/" : pathWithSubRoute.startsWith(`/${prefix}`) ? pathWithSubRoute.slice(prefixLength) : pathWithSubRoute;
33
+ const subRoute = prefix ? `/${prefix}` : "";
34
+ const pathname = path.startsWith("http") ? path : path === "/" ? `/${lang}${subRoute}` : `/${lang}${subRoute}${path}`;
35
+ return {
36
+ path,
37
+ pathname
38
+ };
39
+ }, "getPathInfo");
40
+ let Router = class Router2 {
41
+ static {
42
+ __name(this, "Router");
43
+ }
44
+ isInitialized = false;
45
+ #prefix = "";
46
+ #lang = "en";
47
+ #instance = {
48
+ push: /* @__PURE__ */ __name((href) => {
49
+ const { pathname } = this.#getPathInfo(href);
50
+ import_common.Logger.log(`push to:${pathname}`);
51
+ if (import_base.baseClientEnv.side === "server") void (0, import_navigation.redirect)(pathname);
52
+ }, "push"),
53
+ replace: /* @__PURE__ */ __name((href) => {
54
+ const { pathname } = this.#getPathInfo(href);
55
+ import_common.Logger.log(`replace to:${pathname}`);
56
+ if (import_base.baseClientEnv.side === "server") void (0, import_navigation.redirect)(pathname);
57
+ }, "replace"),
58
+ back: /* @__PURE__ */ __name(() => {
59
+ throw new Error("back is only available in client");
60
+ }, "back"),
61
+ refresh: /* @__PURE__ */ __name(() => {
62
+ throw new Error("refresh is only available in client");
63
+ }, "refresh")
64
+ };
65
+ init(options) {
66
+ this.#prefix = options.prefix ?? "";
67
+ this.#lang = options.lang ?? "en";
68
+ if (options.type === "csr") this.#initCSRClientRouter(options);
69
+ else if (options.side === "server") this.#initNextServerRouter(options);
70
+ else this.#initNextClientRouter(options);
71
+ this.isInitialized = true;
72
+ import_common.Logger.verbose("Router initialized");
73
+ }
74
+ #initNextServerRouter(options) {
75
+ }
76
+ #initNextClientRouter(options) {
77
+ this.#instance = {
78
+ push: /* @__PURE__ */ __name((href) => {
79
+ const { path, pathname } = this.#getPathInfo(href);
80
+ this.#postPathChange({
81
+ path,
82
+ pathname
83
+ });
84
+ options.router.push(pathname);
85
+ }, "push"),
86
+ replace: /* @__PURE__ */ __name((href) => {
87
+ const { path, pathname } = this.#getPathInfo(href);
88
+ this.#postPathChange({
89
+ path,
90
+ pathname
91
+ });
92
+ options.router.replace(pathname);
93
+ }, "replace"),
94
+ back: /* @__PURE__ */ __name(() => {
95
+ const { path, pathname } = this.#getPathInfo(document.referrer);
96
+ this.#postPathChange({
97
+ path,
98
+ pathname
99
+ });
100
+ options.router.back();
101
+ }, "back"),
102
+ refresh: /* @__PURE__ */ __name(() => {
103
+ const { path, pathname } = this.#getPathInfo(location.pathname);
104
+ this.#postPathChange({
105
+ path,
106
+ pathname
107
+ });
108
+ options.router.refresh();
109
+ }, "refresh")
110
+ };
111
+ }
112
+ #initCSRClientRouter(options) {
113
+ this.#instance = {
114
+ push: /* @__PURE__ */ __name((href) => {
115
+ const { path, pathname } = this.#getPathInfo(href);
116
+ if (location.pathname === pathname) return;
117
+ this.#postPathChange({
118
+ path,
119
+ pathname
120
+ });
121
+ options.router.push(pathname);
122
+ }, "push"),
123
+ replace: /* @__PURE__ */ __name((href) => {
124
+ const { path, pathname } = this.#getPathInfo(href);
125
+ if (location.pathname === pathname) return;
126
+ this.#postPathChange({
127
+ path,
128
+ pathname
129
+ });
130
+ options.router.replace(pathname);
131
+ }, "replace"),
132
+ back: /* @__PURE__ */ __name(() => {
133
+ const { path, pathname } = this.#getPathInfo(document.referrer);
134
+ if (location.pathname === pathname) return;
135
+ this.#postPathChange({
136
+ path,
137
+ pathname
138
+ });
139
+ options.router.back();
140
+ }, "back"),
141
+ refresh: /* @__PURE__ */ __name(() => {
142
+ const { path, pathname } = this.#getPathInfo(location.pathname);
143
+ this.#postPathChange({
144
+ path,
145
+ pathname
146
+ });
147
+ options.router.refresh();
148
+ }, "refresh")
149
+ };
150
+ }
151
+ #checkInitialized() {
152
+ if (!this.isInitialized) throw new Error("Router is not initialized");
153
+ }
154
+ #getPathInfo(href, prefix = this.#prefix) {
155
+ return getPathInfo(href, this.#lang, prefix);
156
+ }
157
+ #postPathChange({ path, pathname }) {
158
+ import_common.Logger.log(`pathChange-start:${path}`);
159
+ window.parent.postMessage({
160
+ type: "pathChange",
161
+ path,
162
+ pathname
163
+ }, "*");
164
+ }
165
+ push(href) {
166
+ this.#checkInitialized();
167
+ this.#instance.push(href);
168
+ return void 0;
169
+ }
170
+ replace(href) {
171
+ this.#checkInitialized();
172
+ this.#instance.replace(href);
173
+ return void 0;
174
+ }
175
+ back() {
176
+ if (import_base.baseClientEnv.side === "server") throw new Error("back is only available in client side");
177
+ this.#checkInitialized();
178
+ this.#instance.back();
179
+ return void 0;
180
+ }
181
+ refresh() {
182
+ if (import_base.baseClientEnv.side === "server") throw new Error("refresh is only available in client side");
183
+ this.#checkInitialized();
184
+ this.#instance.refresh();
185
+ return void 0;
186
+ }
187
+ async redirect(href) {
188
+ if (import_base.baseClientEnv.side === "server") {
189
+ const nextHeaders = require("next/headers");
190
+ const headers = await nextHeaders.headers?.() ?? /* @__PURE__ */ new Map();
191
+ const lang = headers.get("x-locale") ?? this.#lang;
192
+ const basePath = headers.get("x-base-path");
193
+ const { pathname } = getPathInfo(href, lang, basePath ?? "");
194
+ import_common.Logger.log(`redirect to:${pathname}`);
195
+ (0, import_navigation.redirect)(pathname);
196
+ } else {
197
+ const { pathname } = getPathInfo(href, this.#lang, this.#prefix);
198
+ this.#instance.replace(pathname);
199
+ }
200
+ return void 0;
201
+ }
202
+ notFound() {
203
+ this.#checkInitialized();
204
+ if (import_base.baseClientEnv.side === "server") {
205
+ import_common.Logger.log(`redirect to:/404`);
206
+ (0, import_navigation.notFound)();
207
+ } else this.#instance.replace("/404");
208
+ return void 0;
209
+ }
210
+ setLang(lang) {
211
+ if (import_base.baseClientEnv.side === "server") throw new Error("setLang is only available in client side");
212
+ this.#checkInitialized();
213
+ const { path } = getPathInfo(window.location.pathname, this.#lang, this.#prefix);
214
+ this.#lang = lang;
215
+ this.#instance.replace(`/${lang}${path}`);
216
+ return void 0;
217
+ }
218
+ getPath(pathname = window.location.pathname) {
219
+ if (import_base.baseClientEnv.side === "server") throw new Error("getPath is only available in client side");
220
+ const { path } = getPathInfo(pathname, this.#lang, this.#prefix);
221
+ return path;
222
+ }
223
+ getFullPath(withLang = true) {
224
+ if (import_base.baseClientEnv.side === "server") throw new Error("getPath is only available in client side");
225
+ return `${withLang ? `/${this.#lang}` : ""}/${this.#prefix}${this.getPath()}`;
226
+ }
227
+ getPrefix() {
228
+ return this.#prefix;
229
+ }
230
+ getPrefixedPath(path) {
231
+ return this.#prefix ? `${this.#lang ? `/${this.#lang}` : ""}/${this.#prefix}${path}` : path;
232
+ }
233
+ };
234
+ const router = new Router();
235
+ // Annotate the CommonJS export names for ESM import in node:
236
+ 0 && (module.exports = {
237
+ getPathInfo,
238
+ router
239
+ });
@@ -0,0 +1,7 @@
1
+ declare const storage: {
2
+ getItem: (key: string) => Promise<string | null | undefined>;
3
+ setItem: (key: string, value: string) => Promise<void>;
4
+ removeItem: (key: string) => Promise<void> | undefined;
5
+ };
6
+
7
+ export { storage };
package/src/storage.js ADDED
@@ -0,0 +1,60 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 storage_exports = {};
20
+ __export(storage_exports, {
21
+ storage: () => storage
22
+ });
23
+ module.exports = __toCommonJS(storage_exports);
24
+ var import_base = require("@akanjs/base");
25
+ var import_preferences = require("@capacitor/preferences");
26
+ const storage = {
27
+ getItem: /* @__PURE__ */ __name(async (key) => {
28
+ if (import_base.baseClientEnv.side === "server") return;
29
+ if (import_base.baseClientEnv.renderMode === "ssr") return localStorage.getItem(key);
30
+ else return (await import_preferences.Preferences.get({
31
+ key
32
+ })).value;
33
+ }, "getItem"),
34
+ setItem: /* @__PURE__ */ __name(async (key, value) => {
35
+ if (import_base.baseClientEnv.side === "server") return;
36
+ if (import_base.baseClientEnv.renderMode === "ssr") {
37
+ localStorage.setItem(key, value);
38
+ return;
39
+ } else {
40
+ await import_preferences.Preferences.set({
41
+ key,
42
+ value
43
+ });
44
+ return;
45
+ }
46
+ }, "setItem"),
47
+ removeItem: /* @__PURE__ */ __name((key) => {
48
+ if (import_base.baseClientEnv.side === "server") return;
49
+ if (import_base.baseClientEnv.renderMode === "ssr") {
50
+ localStorage.removeItem(key);
51
+ return;
52
+ } else return import_preferences.Preferences.remove({
53
+ key
54
+ });
55
+ }, "removeItem")
56
+ };
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ storage
60
+ });