@akanjs/client 0.0.34 → 0.0.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/client",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -10,33 +10,28 @@
10
10
  "url": "https://github.com/akan-team/akanjs.git",
11
11
  "directory": "pkgs/@akanjs/base"
12
12
  },
13
+ "main": "./index.js",
14
+ "engines": {
15
+ "node": ">=22"
16
+ },
13
17
  "dependencies": {
14
18
  "@capacitor/core": "^7.2.0",
15
19
  "@capacitor/device": "^7.0.1",
16
20
  "@capacitor/haptics": "^7.0.1",
17
21
  "@capacitor/keyboard": "^7.0.1",
18
22
  "@capacitor/preferences": "^7.0.1",
19
- "@urql/core": "^5.1.0",
20
- "@use-gesture/react": "^10.3.1",
21
- "bull": "^4.16.5",
22
- "capacitor-plugin-safe-area": "^3.0.4",
23
- "clsx": "^2.1.1",
24
- "dayjs": "^1.11.13",
25
- "express": "^4.21.2",
26
- "immer": "^10.1.1",
27
- "js-cookie": "^3.0.5",
28
- "jwt-decode": "^4.0.0",
29
- "mongoose": "^8.9.3",
30
- "next": "^15.3.0",
31
- "pluralize": "^8.0.0",
23
+ "@urql/core": "^^5.1.0",
24
+ "capacitor-plugin-safe-area": "^^3.0.4",
25
+ "clsx": "^^2.1.1",
26
+ "dayjs": "^^1.11.13",
27
+ "immer": "^^10.1.1",
28
+ "js-cookie": "^^3.0.5",
29
+ "jwt-decode": "^^4.0.0",
30
+ "next": "^15.3.2",
31
+ "pluralize": "^^8.0.0",
32
32
  "react": "^18.3.1",
33
- "react-device-detect": "^2.2.3",
34
- "react-dom": "^18.3.1",
35
- "react-spring": "^9.7.5",
36
- "reflect-metadata": "^0.2.2",
37
- "socket.io": "^4.8.1",
38
- "socket.io-client": "^4.8.1",
39
- "tunnel-ssh": "^5.2.0"
40
- },
41
- "main": "./index.js"
33
+ "react-device-detect": "^^2.2.3",
34
+ "reflect-metadata": "^^0.2.2",
35
+ "socket.io-client": "^^4.8.1"
36
+ }
42
37
  }
package/README.md DELETED
@@ -1,11 +0,0 @@
1
- # akan
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Building
6
-
7
- Run `nx build akan` to build the library.
8
-
9
- ## Running unit tests
10
-
11
- Run `nx test akan` to execute the unit tests via [Jest](https://jestjs.io).
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src";
package/src/cookie.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import { type Account, type Me, type Self } from "@akanjs/signal";
2
- import Cookies from "js-cookie";
3
- export declare const cookies: () => Map<string, {
4
- name: string;
5
- value: string;
6
- }>;
7
- export declare const setCookie: (key: string, value: string, options?: Cookies.CookieAttributes) => void;
8
- export declare const getCookie: (key: string) => string | undefined;
9
- export declare const removeCookie: (key: string, options?: {
10
- path: string;
11
- }) => boolean | undefined;
12
- export declare const headers: () => Map<string, string>;
13
- export declare const getHeader: (key: string) => string | undefined;
14
- export declare const getAccount: () => Account;
15
- export interface GetOption {
16
- unauthorize: string;
17
- }
18
- export declare function getMe<O extends GetOption | undefined>(option?: O): O extends GetOption ? Me : Me | undefined;
19
- export declare function getSelf<O extends GetOption | undefined>(option?: O): O extends GetOption ? Self : Self | undefined;
20
- interface SetAuthOption {
21
- jwt: string;
22
- }
23
- export declare const setAuth: ({ jwt }: SetAuthOption) => void;
24
- interface InitAuthOption {
25
- jwt?: string;
26
- }
27
- export declare const initAuth: ({ jwt }?: InitAuthOption) => void;
28
- export declare const resetAuth: () => void;
29
- export {};
package/src/cookie.js DELETED
@@ -1,157 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var cookie_exports = {};
29
- __export(cookie_exports, {
30
- cookies: () => cookies,
31
- getAccount: () => getAccount,
32
- getCookie: () => getCookie,
33
- getHeader: () => getHeader,
34
- getMe: () => getMe,
35
- getSelf: () => getSelf,
36
- headers: () => headers,
37
- initAuth: () => initAuth,
38
- removeCookie: () => removeCookie,
39
- resetAuth: () => resetAuth,
40
- setAuth: () => setAuth,
41
- setCookie: () => setCookie
42
- });
43
- module.exports = __toCommonJS(cookie_exports);
44
- var import_base = require("@akanjs/base");
45
- var import_common = require("@akanjs/common");
46
- var import_signal = require("@akanjs/signal");
47
- var import_signal2 = require("@akanjs/signal");
48
- var import_core = require("@capacitor/core");
49
- var import_js_cookie = __toESM(require("js-cookie"));
50
- var import_jwt_decode = require("jwt-decode");
51
- var import_react = __toESM(require("react"));
52
- var import_router = require("./router");
53
- var import_storage = require("./storage");
54
- const cookies = import_base.baseClientEnv.side === "server" ? () => {
55
- const nextHeaders = require("next/headers");
56
- const cookies2 = nextHeaders.cookies();
57
- return import_react.default.use(cookies2);
58
- } : () => {
59
- const cookie = import_js_cookie.default.get();
60
- return new Map(
61
- Object.entries(cookie).map(([key, value]) => [
62
- key,
63
- {
64
- name: key,
65
- value: typeof value === "string" && value.startsWith("j:") ? JSON.parse(value.slice(2)) : value
66
- }
67
- ])
68
- );
69
- };
70
- const setCookie = (key, value, options = { path: "/", sameSite: "none", secure: true }) => {
71
- if (import_base.baseClientEnv.side === "server")
72
- return;
73
- else
74
- void import_core.CapacitorCookies.setCookie({ key, value });
75
- };
76
- const getCookie = (key) => {
77
- if (import_base.baseClientEnv.side === "server")
78
- return cookies().get(key)?.value;
79
- else
80
- return document.cookie.split(";").find((c) => c.trim().startsWith(`${key}=`))?.split("=")[1];
81
- };
82
- const removeCookie = (key, options = { path: "/" }) => {
83
- if (import_base.baseClientEnv.side === "server")
84
- return cookies().delete(key);
85
- else {
86
- document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
87
- }
88
- };
89
- const headers = import_base.baseClientEnv.side === "server" ? () => import_react.default.use(require("next/headers").headers()) : () => /* @__PURE__ */ new Map();
90
- const getHeader = (key) => {
91
- return headers().get(key);
92
- };
93
- const getAccount = () => {
94
- const jwt = getCookie("jwt") ?? getHeader("jwt");
95
- if (!jwt)
96
- return import_signal2.defaultAccount;
97
- const account = (0, import_jwt_decode.jwtDecode)(jwt);
98
- if (account.appName !== import_base.baseEnv.appName || account.environment !== import_base.baseEnv.environment)
99
- return import_signal2.defaultAccount;
100
- return account;
101
- };
102
- function getMe(option) {
103
- const me = getAccount().me;
104
- if (!me && option) {
105
- if (option.unauthorize === "notFound")
106
- import_router.router.notFound();
107
- else if (import_base.baseClientEnv.side === "client")
108
- import_router.router.replace(option.unauthorize);
109
- else
110
- import_react.default.use(import_router.router.redirect(option.unauthorize));
111
- }
112
- return me;
113
- }
114
- function getSelf(option) {
115
- const self = getAccount().self;
116
- if (!self && option) {
117
- if (option.unauthorize === "notFound")
118
- import_router.router.notFound();
119
- else if (import_base.baseClientEnv.side === "client")
120
- import_router.router.replace(option.unauthorize);
121
- else
122
- import_react.default.use(import_router.router.redirect(option.unauthorize));
123
- }
124
- return self;
125
- }
126
- const setAuth = ({ jwt }) => {
127
- import_signal.client.setJwt(jwt);
128
- setCookie("jwt", jwt);
129
- void import_storage.storage.setItem("jwt", jwt);
130
- };
131
- const initAuth = ({ jwt } = {}) => {
132
- const token = jwt ?? cookies().get("jwt")?.value;
133
- if (token)
134
- setAuth({ jwt: token });
135
- import_signal.client.init();
136
- import_common.Logger.verbose(`JWT set from cookie: ${token}`);
137
- };
138
- const resetAuth = () => {
139
- import_signal.client.reset();
140
- removeCookie("jwt");
141
- void import_storage.storage.removeItem("jwt");
142
- };
143
- // Annotate the CommonJS export names for ESM import in node:
144
- 0 && (module.exports = {
145
- cookies,
146
- getAccount,
147
- getCookie,
148
- getHeader,
149
- getMe,
150
- getSelf,
151
- headers,
152
- initAuth,
153
- removeCookie,
154
- resetAuth,
155
- setAuth,
156
- setCookie
157
- });
@@ -1,4 +0,0 @@
1
- export declare const createFont: (data: any) => null;
2
- export default createFont;
3
- export declare const Nanum_Gothic_Coding: (data: any) => null;
4
- export declare const Noto_Sans_KR: (data: any) => null;
package/src/createFont.js DELETED
@@ -1,35 +0,0 @@
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 createFont_exports = {};
19
- __export(createFont_exports, {
20
- Nanum_Gothic_Coding: () => Nanum_Gothic_Coding,
21
- Noto_Sans_KR: () => Noto_Sans_KR,
22
- createFont: () => createFont,
23
- default: () => createFont_default
24
- });
25
- module.exports = __toCommonJS(createFont_exports);
26
- const createFont = (data) => null;
27
- var createFont_default = createFont;
28
- const Nanum_Gothic_Coding = createFont;
29
- const Noto_Sans_KR = createFont;
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- Nanum_Gothic_Coding,
33
- Noto_Sans_KR,
34
- createFont
35
- });
package/src/csrTypes.d.ts DELETED
@@ -1,178 +0,0 @@
1
- import type { ReactDOMAttributes } from "@use-gesture/react/dist/declarations/src/types";
2
- import { type ExoticComponent, type MutableRefObject } from "react";
3
- import { ReactNode } from "react";
4
- import type { AnimatedComponent, Interpolation, SpringValue } from "react-spring";
5
- import type { RouterInstance } from "./router";
6
- export type TransitionType = "none" | "fade" | "bottomUp" | "stack" | "scaleOut";
7
- export interface CsrConfig {
8
- transition?: TransitionType;
9
- safeArea?: boolean;
10
- topInset?: boolean | number;
11
- bottomInset?: boolean | number;
12
- gesture?: boolean;
13
- cache?: boolean;
14
- }
15
- export interface CsrState {
16
- transition: TransitionType;
17
- topSafeArea: number;
18
- bottomSafeArea: number;
19
- topInset: number;
20
- bottomInset: number;
21
- gesture: boolean;
22
- cache: boolean;
23
- }
24
- export declare const DEFAULT_TOP_INSET = 48;
25
- export declare const DEFAULT_BOTTOM_INSET = 60;
26
- export interface Route {
27
- csrConfig?: CsrConfig;
28
- path: string;
29
- Page?: (({ params, searchParams }: {
30
- params: any;
31
- searchParams: any;
32
- }) => ReactNode) | (({ params, searchParams }: {
33
- params: any;
34
- searchParams: any;
35
- }) => Promise<ReactNode>);
36
- Layout?: (({ children, params, searchParams }: {
37
- children: any;
38
- params: any;
39
- searchParams: any;
40
- }) => ReactNode) | (({ children, params, searchParams }: {
41
- children: any;
42
- params: any;
43
- searchParams: any;
44
- }) => Promise<ReactNode>);
45
- loader?: () => any;
46
- pageState?: PageState;
47
- children: Map<string, Route>;
48
- }
49
- export type TransitionStyle = NonNullable<AnimatedComponent<ExoticComponent>["defaultProps"]>["style"];
50
- export interface SafeAreaTransition {
51
- containerStyle: TransitionStyle;
52
- }
53
- export interface ContainerTransition {
54
- containerStyle: TransitionStyle;
55
- contentStyle: TransitionStyle;
56
- prevContentStyle: TransitionStyle;
57
- }
58
- export interface PageTransition {
59
- containerStyle: TransitionStyle;
60
- contentStyle: TransitionStyle;
61
- }
62
- export interface CsrTransitionStyles {
63
- topSafeArea: SafeAreaTransition | null;
64
- page: PageTransition | null;
65
- prevPage: PageTransition | null;
66
- topInset: ContainerTransition | null;
67
- bottomInset: ContainerTransition | null;
68
- topLeftAction: ContainerTransition | null;
69
- bottomSafeArea: SafeAreaTransition | null;
70
- }
71
- export type PageState = CsrState & {
72
- topInset: number;
73
- bottomInset: number;
74
- };
75
- export declare const defaultPageState: PageState;
76
- export interface Location {
77
- pathname: string;
78
- search: string;
79
- params: {
80
- [key: string]: string;
81
- };
82
- searchParams: {
83
- [key: string]: string | string[];
84
- };
85
- pathRoute: PathRoute;
86
- }
87
- export interface LocationState {
88
- location: Location;
89
- prevLocation: Location | null;
90
- }
91
- export interface History {
92
- type: "initial" | "forward" | "back";
93
- locations: Location[];
94
- scrollMap: Map<string, number>;
95
- idxMap: Map<string, number>;
96
- cachedLocationMap: Map<string, Location>;
97
- idx: number;
98
- }
99
- export interface RouterProps {
100
- push: (path: string) => void;
101
- replace: (path: string) => void;
102
- refresh: () => void;
103
- back: () => void | Promise<void>;
104
- }
105
- export interface RouteState {
106
- clientWidth: number;
107
- clientHeight: number;
108
- location: Location;
109
- prevLocation: Location | null;
110
- history: MutableRefObject<History>;
111
- topSafeAreaRef: MutableRefObject<HTMLDivElement | null>;
112
- bottomSafeAreaRef: MutableRefObject<HTMLDivElement | null>;
113
- prevPageContentRef: MutableRefObject<HTMLDivElement | null>;
114
- pageContentRef: MutableRefObject<HTMLDivElement | null>;
115
- frameRootRef: MutableRefObject<HTMLDivElement | null>;
116
- onBack: MutableRefObject<{
117
- [K in TransitionType]?: () => Promise<void>;
118
- }>;
119
- router: RouterInstance;
120
- pathRoutes: PathRoute[];
121
- }
122
- export type UseCsrTransition = CsrTransitionStyles & {
123
- pageBind: (...args: any[]) => ReactDOMAttributes;
124
- pageClassName: string;
125
- transDirection: "vertical" | "horizontal" | "none";
126
- transUnitRange: number[];
127
- transUnit: SpringValue<number>;
128
- transPercent: Interpolation<number>;
129
- transProgress: Interpolation<number>;
130
- };
131
- export type CsrContextType = RouteState & UseCsrTransition;
132
- export declare const csrContext: import("react").Context<CsrContextType>;
133
- export declare const useCsr: () => CsrContextType;
134
- export interface PathContextType {
135
- pageType: "current" | "prev" | "cached";
136
- location: Location;
137
- gestureEnabled: boolean;
138
- setGestureEnabled: (enabled: boolean) => void;
139
- }
140
- export declare const pathContext: import("react").Context<PathContextType>;
141
- export declare const usePathCtx: () => PathContextType;
142
- export interface PathRoute {
143
- path: string;
144
- pathSegments: string[];
145
- Page: (({ params, searchParams }: {
146
- params: any;
147
- searchParams: any;
148
- }) => ReactNode) | (({ params, searchParams }: {
149
- params: any;
150
- searchParams: any;
151
- }) => Promise<ReactNode>);
152
- pageState: PageState;
153
- RootLayouts: ((({ children, params, searchParams }: {
154
- children: any;
155
- params: any;
156
- searchParams: any;
157
- }) => ReactNode) | (({ children, params, searchParams }: {
158
- children: any;
159
- params: any;
160
- searchParams: any;
161
- }) => Promise<ReactNode>))[];
162
- Layouts: ((({ children, params, searchParams }: {
163
- children: any;
164
- params: any;
165
- searchParams: any;
166
- }) => ReactNode) | (({ children, params, searchParams }: {
167
- children: any;
168
- params: any;
169
- searchParams: any;
170
- }) => Promise<ReactNode>))[];
171
- }
172
- export interface RouteGuide {
173
- pathSegment: string;
174
- pathRoute?: PathRoute;
175
- children: {
176
- [key: string]: RouteGuide;
177
- };
178
- }
package/src/csrTypes.js DELETED
@@ -1,61 +0,0 @@
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 csrTypes_exports = {};
20
- __export(csrTypes_exports, {
21
- DEFAULT_BOTTOM_INSET: () => DEFAULT_BOTTOM_INSET,
22
- DEFAULT_TOP_INSET: () => DEFAULT_TOP_INSET,
23
- csrContext: () => csrContext,
24
- defaultPageState: () => defaultPageState,
25
- pathContext: () => pathContext,
26
- useCsr: () => useCsr,
27
- usePathCtx: () => usePathCtx
28
- });
29
- module.exports = __toCommonJS(csrTypes_exports);
30
- var import_react = require("react");
31
- const DEFAULT_TOP_INSET = 48;
32
- const DEFAULT_BOTTOM_INSET = 60;
33
- const defaultPageState = {
34
- transition: "none",
35
- topSafeArea: 0,
36
- bottomSafeArea: 0,
37
- topInset: 0,
38
- bottomInset: 0,
39
- gesture: true,
40
- cache: false
41
- };
42
- const csrContext = (0, import_react.createContext)({});
43
- const useCsr = () => {
44
- const contextValues = (0, import_react.useContext)(csrContext);
45
- return contextValues;
46
- };
47
- const pathContext = (0, import_react.createContext)({});
48
- const usePathCtx = () => {
49
- const contextValues = (0, import_react.useContext)(pathContext);
50
- return contextValues;
51
- };
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
54
- DEFAULT_BOTTOM_INSET,
55
- DEFAULT_TOP_INSET,
56
- csrContext,
57
- defaultPageState,
58
- pathContext,
59
- useCsr,
60
- usePathCtx
61
- });
package/src/device.d.ts DELETED
@@ -1,25 +0,0 @@
1
- import { type DeviceInfo } from "@capacitor/device";
2
- import type { MutableRefObject } from "react";
3
- interface DeviceInitOption {
4
- lang?: string;
5
- supportLanguages?: string[] | readonly string[];
6
- }
7
- declare class Device {
8
- #private;
9
- info: DeviceInfo;
10
- lang: string;
11
- topSafeArea: number;
12
- bottomSafeArea: number;
13
- isMobile: boolean;
14
- init({ lang, supportLanguages }?: DeviceInitOption): Promise<void>;
15
- setPageContentRef(pageContentRef: MutableRefObject<HTMLDivElement | null>): void;
16
- showKeyboard(): Promise<void>;
17
- hideKeyboard(): Promise<void>;
18
- listenKeyboardChanged(onKeyboardChanged: (height: number) => void): void;
19
- unlistenKeyboardChanged(): void;
20
- vibrate(type?: "light" | "medium" | "heavy" | number): Promise<void>;
21
- getScrollTop(): number;
22
- setScrollTop(scrollTop: number): void;
23
- }
24
- export declare const device: Device;
25
- export {};