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