@react-native-ohos/cookies 6.3.0 → 6.3.1-beta.1
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/LICENSE +21 -21
- package/README.md +14 -14
- package/harmony/rn_cookies/BuildProfile.ets +17 -17
- package/harmony/rn_cookies/build-profile.json5 +28 -28
- package/harmony/rn_cookies/hvigorfile.ts +6 -6
- package/harmony/rn_cookies/obfuscation-rules.txt +17 -17
- package/harmony/rn_cookies/oh-package.json5 +11 -11
- package/harmony/rn_cookies/src/main/cpp/CMakeLists.txt +9 -9
- package/harmony/rn_cookies/src/main/cpp/CookiesPackage.h +19 -19
- package/harmony/rn_cookies/src/main/cpp/CookiesTurboModule.cpp +57 -57
- package/harmony/rn_cookies/src/main/cpp/CookiesTurboModule.h +25 -25
- package/harmony/rn_cookies/src/main/cpp/generated/RNOH/generated/BaseReactNativeCookiesPackage.h +72 -72
- package/harmony/rn_cookies/src/main/cpp/generated/RNOH/generated/turbo_modules/RTNCookies.cpp +21 -21
- package/harmony/rn_cookies/src/main/cpp/generated/RNOH/generated/turbo_modules/RTNCookies.h +16 -16
- package/harmony/rn_cookies/src/main/cpp/generated/react/renderer/components/react_native_cookies/ComponentDescriptors.h +24 -24
- package/harmony/rn_cookies/src/main/cpp/generated/react/renderer/components/react_native_cookies/EventEmitters.cpp +16 -16
- package/harmony/rn_cookies/src/main/cpp/generated/react/renderer/components/react_native_cookies/EventEmitters.h +17 -17
- package/harmony/rn_cookies/src/main/cpp/generated/react/renderer/components/react_native_cookies/Props.cpp +19 -19
- package/harmony/rn_cookies/src/main/cpp/generated/react/renderer/components/react_native_cookies/Props.h +18 -18
- package/harmony/rn_cookies/src/main/cpp/generated/react/renderer/components/react_native_cookies/ShadowNodes.cpp +17 -17
- package/harmony/rn_cookies/src/main/cpp/generated/react/renderer/components/react_native_cookies/ShadowNodes.h +23 -23
- package/harmony/rn_cookies/src/main/cpp/generated/react/renderer/components/react_native_cookies/States.cpp +16 -16
- package/harmony/rn_cookies/src/main/cpp/generated/react/renderer/components/react_native_cookies/States.h +18 -18
- package/harmony/rn_cookies/src/main/ets/CookiesModule.ts +199 -177
- package/harmony/rn_cookies/src/main/ets/CookiesPackage.ts +26 -26
- package/harmony/rn_cookies/src/main/ets/Logger.ets +63 -63
- package/harmony/rn_cookies/src/main/ets/generated/components/ts.ts +5 -5
- package/harmony/rn_cookies/src/main/ets/generated/index.ets +5 -5
- package/harmony/rn_cookies/src/main/ets/generated/ts.ts +6 -6
- package/harmony/rn_cookies/src/main/ets/generated/turboModules/RTNCookies.ts +26 -26
- package/harmony/rn_cookies/src/main/ets/generated/turboModules/ts.ts +5 -5
- package/harmony/rn_cookies/src/main/module.json5 +11 -11
- package/harmony/rn_cookies/src/main/resources/base/element/string.json +8 -8
- package/harmony/rn_cookies/src/main/resources/en_US/element/string.json +8 -8
- package/harmony/rn_cookies/src/main/resources/zh_CN/element/string.json +8 -8
- package/harmony/rn_cookies/src/test/List.test.ets +4 -4
- package/harmony/rn_cookies/src/test/LocalUnit.test.ets +32 -32
- package/harmony/rn_cookies/ts.ts +1 -1
- package/harmony/rn_cookies.har +0 -0
- package/index.d.ts +42 -42
- package/index.js +62 -62
- package/package.json +55 -55
- package/react-native-cookies.podspec +18 -18
- package/src/NativeRTNCookies.tsx +60 -60
|
@@ -1,177 +1,199 @@
|
|
|
1
|
-
// Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
2
|
-
// Use of this source code is governed by a Apache-2.0 license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
import { TurboModule } from '@rnoh/react-native-openharmony/ts';
|
|
6
|
-
import web_webview from '@ohos.web.webview';
|
|
7
|
-
|
|
8
|
-
export interface Cookie {
|
|
9
|
-
name: string;
|
|
10
|
-
value: string;
|
|
11
|
-
path?: string;
|
|
12
|
-
domain?: string;
|
|
13
|
-
version?: string;
|
|
14
|
-
expires?: string;
|
|
15
|
-
secure?: boolean;
|
|
16
|
-
httpOnly?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface Cookies {
|
|
20
|
-
[key: string]: Cookie;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class CookiesModule extends TurboModule {
|
|
24
|
-
clearAll(useWebKit?: boolean): Promise<boolean> {
|
|
25
|
-
try {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return new Promise((resolve) => {
|
|
32
|
-
resolve(
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
web_webview.WebCookieManager.
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
1
|
+
// Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
2
|
+
// Use of this source code is governed by a Apache-2.0 license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import { TurboModule } from '@rnoh/react-native-openharmony/ts';
|
|
6
|
+
import web_webview from '@ohos.web.webview';
|
|
7
|
+
|
|
8
|
+
export interface Cookie {
|
|
9
|
+
name: string;
|
|
10
|
+
value: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
domain?: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
expires?: string;
|
|
15
|
+
secure?: boolean;
|
|
16
|
+
httpOnly?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Cookies {
|
|
20
|
+
[key: string]: Cookie;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class CookiesModule extends TurboModule {
|
|
24
|
+
clearAll(useWebKit?: boolean): Promise<boolean> {
|
|
25
|
+
try {
|
|
26
|
+
web_webview.WebCookieManager.clearAllCookiesSync();
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
resolve(true);
|
|
29
|
+
});
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return new Promise((resolve) => {
|
|
32
|
+
resolve(false);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async get(url: string, useWebKit?: boolean): Promise<Cookies> {
|
|
38
|
+
if ((url === '') || (url === undefined) || (url === null)) {
|
|
39
|
+
return Promise.reject(new Error('url is invalid'));
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
let result: string = '';
|
|
43
|
+
if (useWebKit) {
|
|
44
|
+
result = await web_webview.WebCookieManager.fetchCookie(url);
|
|
45
|
+
} else {
|
|
46
|
+
result = web_webview.WebCookieManager.fetchCookieSync(url);
|
|
47
|
+
}
|
|
48
|
+
if (result === '') {
|
|
49
|
+
console.warn('未查询到cookie');
|
|
50
|
+
return {}
|
|
51
|
+
}
|
|
52
|
+
const cookies: Cookies = {};
|
|
53
|
+
const pairs = result.split(';');
|
|
54
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
55
|
+
const trimmed = pairs[i].trim();
|
|
56
|
+
const eqIndex = trimmed.indexOf('=');
|
|
57
|
+
if (eqIndex <= 0) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const name = trimmed.substring(0, eqIndex).trim();
|
|
61
|
+
const value = trimmed.substring(eqIndex + 1);
|
|
62
|
+
if (name.length === 0) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
cookies[name] = { name: name, value: value } as Cookie;
|
|
66
|
+
}
|
|
67
|
+
return cookies;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
return Promise.reject(error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
isEmpty(value: string | undefined): boolean {
|
|
74
|
+
return value == null || value.length === 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Build a Set-Cookie value string per RFC 6265 (aligned with Android toRFC6265string):
|
|
79
|
+
* name=value; expires=...; domain=...; path=...; secure; httponly
|
|
80
|
+
*/
|
|
81
|
+
buildRFC6265CookieString(url: string, cookie: Cookie): string {
|
|
82
|
+
const urlMatch = url.match(/^https?:\/\/([^/?#]+)(?:[/?#]|$)/i);
|
|
83
|
+
if (!urlMatch) {
|
|
84
|
+
throw new Error('Invalid URL: It may be missing a protocol (ex. http:// or https://).');
|
|
85
|
+
}
|
|
86
|
+
const topLevelDomain = urlMatch[1];
|
|
87
|
+
if (this.isEmpty(topLevelDomain)) {
|
|
88
|
+
throw new Error('Invalid URL: It may be missing a protocol (ex. http:// or https://).');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let cookieBuilder = `${cookie.name}=${cookie.value}`;
|
|
92
|
+
|
|
93
|
+
if (!this.isEmpty(cookie.expires)) {
|
|
94
|
+
cookieBuilder += `; expires=${cookie.expires}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let domain: string;
|
|
98
|
+
if (!this.isEmpty(cookie.domain)) {
|
|
99
|
+
domain = cookie.domain!;
|
|
100
|
+
if (domain.startsWith('.')) {
|
|
101
|
+
domain = domain.substring(1);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const isDomainMatch = topLevelDomain === domain || topLevelDomain.endsWith('.' + domain);
|
|
105
|
+
if (!isDomainMatch) {
|
|
106
|
+
throw new Error(`Cookie URL host ${topLevelDomain} and domain ${domain} mismatched. The cookie won't set correctly.`);
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
domain = topLevelDomain;
|
|
110
|
+
}
|
|
111
|
+
cookieBuilder += `; domain=${domain}`;
|
|
112
|
+
|
|
113
|
+
if (!this.isEmpty(cookie.path)) {
|
|
114
|
+
cookieBuilder += `; path=${cookie.path}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (cookie.secure === true) {
|
|
118
|
+
cookieBuilder += '; secure';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (cookie.httpOnly === true) {
|
|
122
|
+
cookieBuilder += '; httponly';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return cookieBuilder;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async set(url: string, cookie: Cookie, useWebKit?: boolean): Promise<boolean> {
|
|
129
|
+
try {
|
|
130
|
+
const cookieString = this.buildRFC6265CookieString(url, cookie);
|
|
131
|
+
if (useWebKit) {
|
|
132
|
+
await web_webview.WebCookieManager.configCookie(url, cookieString);
|
|
133
|
+
} else {
|
|
134
|
+
web_webview.WebCookieManager.configCookieSync(url, cookieString, false);
|
|
135
|
+
}
|
|
136
|
+
return Promise.resolve(true);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
console.warn('set() failed:', error);
|
|
139
|
+
return Promise.resolve(false);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async clearByName(url: string, name: string, useWebKit?: boolean): Promise<boolean> {
|
|
144
|
+
if (this.isEmpty(url) || this.isEmpty(name)) {
|
|
145
|
+
return Promise.resolve(false);
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
let cookieStr = '';
|
|
149
|
+
if (useWebKit) {
|
|
150
|
+
cookieStr = await web_webview.WebCookieManager.fetchCookie(url);
|
|
151
|
+
} else {
|
|
152
|
+
cookieStr = web_webview.WebCookieManager.fetchCookieSync(url);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const cookieExist = cookieStr.split(';').some((pair) => {
|
|
156
|
+
const trimmed = pair.trim();
|
|
157
|
+
const eqIndex = trimmed.indexOf('=');
|
|
158
|
+
if (eqIndex <= 0) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return trimmed.substring(0, eqIndex).trim() === name;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
if (!cookieExist) {
|
|
165
|
+
return Promise.resolve(true);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Delete by overwriting with an expired cookie (RFC 6265). Omit path so the platform derives it from the URL.
|
|
169
|
+
const expiredCookieString = this.buildRFC6265CookieString(url, {
|
|
170
|
+
name: name,
|
|
171
|
+
value: '',
|
|
172
|
+
expires: 'Thu, 01 Jan 1970 00:00:00 GMT',
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
if (useWebKit) {
|
|
176
|
+
await web_webview.WebCookieManager.configCookie(url, expiredCookieString);
|
|
177
|
+
} else {
|
|
178
|
+
web_webview.WebCookieManager.configCookieSync(url, expiredCookieString, false);
|
|
179
|
+
}
|
|
180
|
+
return Promise.resolve(true);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
console.warn('clearByName() failed:', error);
|
|
183
|
+
return Promise.resolve(false);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
removeSessionCookies(): Promise<boolean>{
|
|
188
|
+
try {
|
|
189
|
+
web_webview.WebCookieManager.clearSessionCookieSync();
|
|
190
|
+
return new Promise((resolve) => {
|
|
191
|
+
resolve(true);
|
|
192
|
+
});
|
|
193
|
+
} catch(error) {
|
|
194
|
+
return new Promise((resolve) => {
|
|
195
|
+
resolve(false);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
// Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
2
|
-
// Use of this source code is governed by a Apache-2.0 license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
|
|
6
|
-
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
7
|
-
import { CookiesModule } from './CookiesModule';
|
|
8
|
-
|
|
9
|
-
class CookiesModulesFactory extends TurboModulesFactory {
|
|
10
|
-
createTurboModule(name: string): TurboModule | null {
|
|
11
|
-
if (name === 'RTNCookies') {
|
|
12
|
-
return new CookiesModule(this.ctx)
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
hasTurboModule(name: string): boolean {
|
|
18
|
-
return name === 'RTNCookies';
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class CookiesPackage extends RNPackage {
|
|
23
|
-
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
|
24
|
-
return new CookiesModulesFactory(ctx);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
1
|
+
// Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
|
|
2
|
+
// Use of this source code is governed by a Apache-2.0 license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
|
|
6
|
+
import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
|
|
7
|
+
import { CookiesModule } from './CookiesModule';
|
|
8
|
+
|
|
9
|
+
class CookiesModulesFactory extends TurboModulesFactory {
|
|
10
|
+
createTurboModule(name: string): TurboModule | null {
|
|
11
|
+
if (name === 'RTNCookies') {
|
|
12
|
+
return new CookiesModule(this.ctx)
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
hasTurboModule(name: string): boolean {
|
|
18
|
+
return name === 'RTNCookies';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class CookiesPackage extends RNPackage {
|
|
23
|
+
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
|
24
|
+
return new CookiesModulesFactory(ctx);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import hilog from '@ohos.hilog';
|
|
26
|
-
|
|
27
|
-
class Logger {
|
|
28
|
-
private domain: number;
|
|
29
|
-
private prefix: string;
|
|
30
|
-
private format: string = '%{public}s, %{public}s';
|
|
31
|
-
private isDebug: boolean;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* constructor.
|
|
35
|
-
*
|
|
36
|
-
* @param Prefix Identifies the log tag.
|
|
37
|
-
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
|
|
38
|
-
*/
|
|
39
|
-
constructor(prefix: string = 'RNCookies', domain: number = 0xFF00, isDebug = false) {
|
|
40
|
-
this.prefix = prefix;
|
|
41
|
-
this.domain = domain;
|
|
42
|
-
this.isDebug = isDebug;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
debug(...args: string[]): void {
|
|
46
|
-
if (this.isDebug) {
|
|
47
|
-
hilog.debug(this.domain, this.prefix, this.format, args);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
info(...args: string[]): void {
|
|
52
|
-
hilog.info(this.domain, this.prefix, this.format, args);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
warn(...args: string[]): void {
|
|
56
|
-
hilog.warn(this.domain, this.prefix, this.format, args);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
error(...args: string[]): void {
|
|
60
|
-
hilog.error(this.domain, this.prefix, this.format, args);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import hilog from '@ohos.hilog';
|
|
26
|
+
|
|
27
|
+
class Logger {
|
|
28
|
+
private domain: number;
|
|
29
|
+
private prefix: string;
|
|
30
|
+
private format: string = '%{public}s, %{public}s';
|
|
31
|
+
private isDebug: boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* constructor.
|
|
35
|
+
*
|
|
36
|
+
* @param Prefix Identifies the log tag.
|
|
37
|
+
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
|
|
38
|
+
*/
|
|
39
|
+
constructor(prefix: string = 'RNCookies', domain: number = 0xFF00, isDebug = false) {
|
|
40
|
+
this.prefix = prefix;
|
|
41
|
+
this.domain = domain;
|
|
42
|
+
this.isDebug = isDebug;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
debug(...args: string[]): void {
|
|
46
|
+
if (this.isDebug) {
|
|
47
|
+
hilog.debug(this.domain, this.prefix, this.format, args);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
info(...args: string[]): void {
|
|
52
|
+
hilog.info(this.domain, this.prefix, this.format, args);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
warn(...args: string[]): void {
|
|
56
|
+
hilog.warn(this.domain, this.prefix, this.format, args);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
error(...args: string[]): void {
|
|
60
|
+
hilog.error(this.domain, this.prefix, this.format, args);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
64
|
export default new Logger('RNCookies', 0xFF00, false)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export {}
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export {}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export * from "./ts"
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from "./ts"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export * as RNC from "./components/ts"
|
|
6
|
-
export * as TM from "./turboModules/ts"
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * as RNC from "./components/ts"
|
|
6
|
+
export * as TM from "./turboModules/ts"
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
|
6
|
-
|
|
7
|
-
export namespace RTNCookies {
|
|
8
|
-
export const NAME = 'RTNCookies' as const
|
|
9
|
-
|
|
10
|
-
export type Cookie = {name: string, value: string, path?: string, domain?: string, version?: string, expires?: string, secure?: boolean, httpOnly?: boolean}
|
|
11
|
-
|
|
12
|
-
export interface Spec {
|
|
13
|
-
clearAll(useWebKit: boolean): Promise<boolean>;
|
|
14
|
-
|
|
15
|
-
get(url: string, useWebKit: boolean): Promise<void>;
|
|
16
|
-
|
|
17
|
-
set(url: string, cookie: Cookie, useWebKit: boolean): Promise<boolean>;
|
|
18
|
-
|
|
19
|
-
clearByName(url: string, name: string, useWebKit: boolean): Promise<boolean>;
|
|
20
|
-
|
|
21
|
-
flush(): Promise<boolean>;
|
|
22
|
-
|
|
23
|
-
removeSessionCookies(): Promise<boolean>;
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Tag } from "@rnoh/react-native-openharmony/ts"
|
|
6
|
+
|
|
7
|
+
export namespace RTNCookies {
|
|
8
|
+
export const NAME = 'RTNCookies' as const
|
|
9
|
+
|
|
10
|
+
export type Cookie = {name: string, value: string, path?: string, domain?: string, version?: string, expires?: string, secure?: boolean, httpOnly?: boolean}
|
|
11
|
+
|
|
12
|
+
export interface Spec {
|
|
13
|
+
clearAll(useWebKit: boolean): Promise<boolean>;
|
|
14
|
+
|
|
15
|
+
get(url: string, useWebKit: boolean): Promise<void>;
|
|
16
|
+
|
|
17
|
+
set(url: string, cookie: Cookie, useWebKit: boolean): Promise<boolean>;
|
|
18
|
+
|
|
19
|
+
clearByName(url: string, name: string, useWebKit: boolean): Promise<boolean>;
|
|
20
|
+
|
|
21
|
+
flush(): Promise<boolean>;
|
|
22
|
+
|
|
23
|
+
removeSessionCookies(): Promise<boolean>;
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
}
|