@akanjs/client 0.0.39 → 0.0.41

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/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/client",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -0,0 +1,29 @@
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 {};
@@ -0,0 +1,4 @@
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;
@@ -0,0 +1,178 @@
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
+ }
@@ -0,0 +1,25 @@
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 {};
package/src/index.d.ts ADDED
@@ -0,0 +1,7 @@
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,45 @@
1
+ export 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
+ export 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
+ export declare const router: Router;
45
+ export {};
@@ -0,0 +1,5 @@
1
+ export 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
+ };
package/src/types.d.ts ADDED
@@ -0,0 +1,110 @@
1
+ import type { FetchInitForm } from "@akanjs/signal";
2
+ import { type ClassValue } from "clsx";
3
+ import type { ReactNode } from "react";
4
+ export declare const clsx: (...args: ClassValue[]) => string;
5
+ export declare const loadFonts: (fonts: {
6
+ name: string;
7
+ nextFont: any;
8
+ paths: {
9
+ src: string;
10
+ weight: number;
11
+ }[];
12
+ }[]) => ReactFont[];
13
+ export interface ModelsProps<M extends {
14
+ id: string;
15
+ }> {
16
+ className?: string;
17
+ sliceName?: string;
18
+ query?: {
19
+ [key: string]: any;
20
+ };
21
+ init?: FetchInitForm<any, M, any>;
22
+ onClickItem?: (model: M) => any;
23
+ }
24
+ export type ModelProps<T extends string, L extends {
25
+ id: string;
26
+ }> = {
27
+ [key in T]: L;
28
+ } & {
29
+ className?: string;
30
+ sliceName?: T;
31
+ onClick?: (model: L) => any;
32
+ actions?: DataAction<L>[];
33
+ columns?: DataColumn<L>[];
34
+ href?: string;
35
+ };
36
+ export interface ModelDashboardProps<Summary> {
37
+ className?: string;
38
+ summary: Summary;
39
+ queryMap?: {
40
+ [key: string]: any;
41
+ };
42
+ columns?: (keyof Summary)[];
43
+ hidePresents?: boolean;
44
+ sliceName?: string;
45
+ }
46
+ export interface ModelInsightProps<Insight> {
47
+ className?: string;
48
+ insight: Insight;
49
+ sliceName?: string;
50
+ }
51
+ export interface ModelEditProps {
52
+ sliceName?: string;
53
+ }
54
+ export interface ModelViewProps {
55
+ id?: string;
56
+ sliceName?: string;
57
+ }
58
+ export type DataAction<L> = "edit" | "view" | "remove" | {
59
+ type: string;
60
+ render: () => ReactNode;
61
+ };
62
+ export interface DataTool {
63
+ render: () => ReactNode;
64
+ }
65
+ export type DataColumn<L> = string | {
66
+ key: keyof L;
67
+ title?: string;
68
+ value?: (value: any, model: L) => string | number | boolean | undefined | null | object;
69
+ responsive?: boolean;
70
+ render?: (value: any, model: L) => ReactNode;
71
+ only?: "user" | "admin";
72
+ };
73
+ export interface DataMenuItem {
74
+ key: string;
75
+ icon: ReactNode;
76
+ label?: string;
77
+ render: () => ReactNode;
78
+ }
79
+ export interface DataMenu {
80
+ [key: string]: DataMenuItem;
81
+ }
82
+ export interface UserMenuItem {
83
+ title: string | ReactNode;
84
+ icon?: ReactNode;
85
+ path: string;
86
+ query?: any;
87
+ children?: UserMenuItem[];
88
+ onClick?: () => void;
89
+ }
90
+ export interface MenuItem {
91
+ icon?: ReactNode;
92
+ title: string | ReactNode;
93
+ href: string;
94
+ hide?: "mobile" | "pc";
95
+ children?: MenuItem[];
96
+ onClick?: () => void;
97
+ }
98
+ export interface ReactFont {
99
+ name: string;
100
+ paths: {
101
+ src: string;
102
+ weight: number;
103
+ }[];
104
+ }
105
+ export interface RootLayoutProps {
106
+ children: ReactNode;
107
+ params: Promise<{
108
+ lang: "en" | "ko";
109
+ }>;
110
+ }