@react-native-ohos/cookies 6.3.0 → 6.4.0-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/Index.ets +4 -1
- 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 +177 -177
- package/harmony/rn_cookies/src/main/ets/{CookiesPackage.ts → CookiesPackage.ets} +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.ets +2 -0
- package/harmony/rn_cookies.har +0 -0
- package/index.d.ts +42 -42
- package/index.js +62 -62
- package/package.json +61 -55
- package/react-native-cookies.podspec +18 -18
- package/src/NativeRTNCookies.tsx +60 -60
- package/harmony/rn_cookies/ts.ts +0 -2
|
@@ -1,177 +1,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
|
-
if (useWebKit) {
|
|
27
|
-
web_webview.WebCookieManager.clearAllCookies();
|
|
28
|
-
} else {
|
|
29
|
-
web_webview.WebCookieManager.clearAllCookiesSync();
|
|
30
|
-
}
|
|
31
|
-
return new Promise((resolve) => {
|
|
32
|
-
resolve(true);
|
|
33
|
-
});
|
|
34
|
-
} catch (error) {
|
|
35
|
-
return new Promise((resolve) => {
|
|
36
|
-
resolve(false);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async get(url: string, useWebKit?: boolean): Promise<Cookies> {
|
|
42
|
-
if ((url === '') || (url === undefined) || (url === null)) {
|
|
43
|
-
return new Promise((resolve) => {
|
|
44
|
-
let cookies: Cookies = { 'cookies': {name: 'error', value: 'url有误'} };
|
|
45
|
-
resolve(cookies);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
let result: string = '';
|
|
50
|
-
if (useWebKit) {
|
|
51
|
-
result = await web_webview.WebCookieManager.fetchCookie(url);
|
|
52
|
-
} else {
|
|
53
|
-
result = web_webview.WebCookieManager.fetchCookieSync(url);
|
|
54
|
-
}
|
|
55
|
-
return new Promise((resolve) => {
|
|
56
|
-
if (result === '') {
|
|
57
|
-
let cookies: Cookies = { 'cookies': {name: 'error', value: '未查询到cookie'} };
|
|
58
|
-
resolve(cookies);
|
|
59
|
-
} else {
|
|
60
|
-
let queryCookieArray: Array<string> = result.split(';');
|
|
61
|
-
let cookies: Cookies = {};
|
|
62
|
-
for (let i = 0 ; i < queryCookieArray.length; i++) {
|
|
63
|
-
let name = queryCookieArray[i].split('=')[0];
|
|
64
|
-
let value = queryCookieArray[i].split('=')[1];
|
|
65
|
-
cookies[name] = { name: name, value: value } as Cookie;
|
|
66
|
-
}
|
|
67
|
-
resolve(cookies);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
} catch (error) {
|
|
71
|
-
return new Promise((resolve) => {
|
|
72
|
-
let cookies: Cookies = { 'cookie': {name: 'error', value: JSON.stringify(error)} }
|
|
73
|
-
resolve(cookies);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
isEmpty(value:string) {
|
|
79
|
-
return value == null || value.length === 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async set(url: string, cookie: Cookie, useWebKit?: boolean): Promise<boolean>{
|
|
83
|
-
try {
|
|
84
|
-
|
|
85
|
-
let cookieBuilder:string = cookie.name + '=' + cookie.value
|
|
86
|
-
Object.keys(cookie).forEach((key)=>{
|
|
87
|
-
if(key !== "name" && key !== "value" && key !== "domain"){
|
|
88
|
-
cookieBuilder+= `; ${key}=${cookie[key]}`
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
const topLevelDomain = url.match(/^https?:\/\/([^/?#]+)(?:[/?#]|$)/i)[1];
|
|
93
|
-
if (cookie.hasOwnProperty("domain") && !this.isEmpty(cookie.domain)) {
|
|
94
|
-
let domain = cookie.domain;
|
|
95
|
-
if (domain.startsWith(".")) {
|
|
96
|
-
domain = domain.substring(1);
|
|
97
|
-
}
|
|
98
|
-
if (topLevelDomain !==domain ) {
|
|
99
|
-
throw new Error(`Cookie URL host ${topLevelDomain} and domain ${domain} mismatched. The cookie won't set correctly.`);
|
|
100
|
-
}
|
|
101
|
-
cookieBuilder+=`; domain=${domain}`
|
|
102
|
-
} else {
|
|
103
|
-
cookieBuilder +=`; domain=${topLevelDomain}`
|
|
104
|
-
}
|
|
105
|
-
if (useWebKit) {
|
|
106
|
-
await web_webview.WebCookieManager.configCookie(url, cookieBuilder);
|
|
107
|
-
} else {
|
|
108
|
-
web_webview.WebCookieManager.configCookieSync(url, cookieBuilder,false);
|
|
109
|
-
}
|
|
110
|
-
return new Promise((resolve) => {
|
|
111
|
-
resolve(true);
|
|
112
|
-
});
|
|
113
|
-
} catch(error) {
|
|
114
|
-
return new Promise((resolve) => {
|
|
115
|
-
resolve(false);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
async clearByName(url: string, name: string, useWebKit?: boolean): Promise<boolean>{
|
|
121
|
-
if ((url === '') || (url === undefined) || (url === null)) {
|
|
122
|
-
return new Promise((resolve) => {
|
|
123
|
-
resolve(false);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
try {
|
|
127
|
-
let cookieExist = false;
|
|
128
|
-
let cookieStr: string = '';
|
|
129
|
-
let cookies: Array<string> = [];
|
|
130
|
-
if (useWebKit) {
|
|
131
|
-
cookieStr = await web_webview.WebCookieManager.fetchCookie(url);
|
|
132
|
-
} else {
|
|
133
|
-
cookieStr = web_webview.WebCookieManager.fetchCookieSync(url);
|
|
134
|
-
}
|
|
135
|
-
cookies = cookieStr.split(';');
|
|
136
|
-
for (let i = 0 ; i < cookies.length; i++) {
|
|
137
|
-
if (cookies[i].split('=')[0].trim() === name) {
|
|
138
|
-
cookieExist = true;
|
|
139
|
-
cookies.splice(i, 1);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if (!cookieExist) {
|
|
143
|
-
return new Promise((resolve) => {
|
|
144
|
-
resolve(true);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (useWebKit) {
|
|
148
|
-
await web_webview.WebCookieManager.clearAllCookies();
|
|
149
|
-
} else {
|
|
150
|
-
web_webview.WebCookieManager.clearAllCookiesSync();
|
|
151
|
-
}
|
|
152
|
-
cookies.forEach((item) => {
|
|
153
|
-
web_webview.WebCookieManager.configCookie(url, item);
|
|
154
|
-
})
|
|
155
|
-
return new Promise((resolve) => {
|
|
156
|
-
resolve(true);
|
|
157
|
-
});
|
|
158
|
-
} catch(error) {
|
|
159
|
-
return new Promise((resolve) => {
|
|
160
|
-
resolve(false);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
removeSessionCookies(): Promise<boolean>{
|
|
166
|
-
try {
|
|
167
|
-
web_webview.WebCookieManager.clearSessionCookieSync();
|
|
168
|
-
return new Promise((resolve) => {
|
|
169
|
-
resolve(true);
|
|
170
|
-
});
|
|
171
|
-
} catch(error) {
|
|
172
|
-
return new Promise((resolve) => {
|
|
173
|
-
resolve(false);
|
|
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
|
+
if (useWebKit) {
|
|
27
|
+
web_webview.WebCookieManager.clearAllCookies();
|
|
28
|
+
} else {
|
|
29
|
+
web_webview.WebCookieManager.clearAllCookiesSync();
|
|
30
|
+
}
|
|
31
|
+
return new Promise((resolve) => {
|
|
32
|
+
resolve(true);
|
|
33
|
+
});
|
|
34
|
+
} catch (error) {
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
resolve(false);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async get(url: string, useWebKit?: boolean): Promise<Cookies> {
|
|
42
|
+
if ((url === '') || (url === undefined) || (url === null)) {
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
let cookies: Cookies = { 'cookies': {name: 'error', value: 'url有误'} };
|
|
45
|
+
resolve(cookies);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
let result: string = '';
|
|
50
|
+
if (useWebKit) {
|
|
51
|
+
result = await web_webview.WebCookieManager.fetchCookie(url);
|
|
52
|
+
} else {
|
|
53
|
+
result = web_webview.WebCookieManager.fetchCookieSync(url);
|
|
54
|
+
}
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
if (result === '') {
|
|
57
|
+
let cookies: Cookies = { 'cookies': {name: 'error', value: '未查询到cookie'} };
|
|
58
|
+
resolve(cookies);
|
|
59
|
+
} else {
|
|
60
|
+
let queryCookieArray: Array<string> = result.split(';');
|
|
61
|
+
let cookies: Cookies = {};
|
|
62
|
+
for (let i = 0 ; i < queryCookieArray.length; i++) {
|
|
63
|
+
let name = queryCookieArray[i].split('=')[0];
|
|
64
|
+
let value = queryCookieArray[i].split('=')[1];
|
|
65
|
+
cookies[name] = { name: name, value: value } as Cookie;
|
|
66
|
+
}
|
|
67
|
+
resolve(cookies);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
} catch (error) {
|
|
71
|
+
return new Promise((resolve) => {
|
|
72
|
+
let cookies: Cookies = { 'cookie': {name: 'error', value: JSON.stringify(error)} }
|
|
73
|
+
resolve(cookies);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
isEmpty(value:string) {
|
|
79
|
+
return value == null || value.length === 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async set(url: string, cookie: Cookie, useWebKit?: boolean): Promise<boolean>{
|
|
83
|
+
try {
|
|
84
|
+
|
|
85
|
+
let cookieBuilder:string = cookie.name + '=' + cookie.value
|
|
86
|
+
Object.keys(cookie).forEach((key)=>{
|
|
87
|
+
if(key !== "name" && key !== "value" && key !== "domain"){
|
|
88
|
+
cookieBuilder+= `; ${key}=${cookie[key]}`
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
const topLevelDomain = url.match(/^https?:\/\/([^/?#]+)(?:[/?#]|$)/i)[1];
|
|
93
|
+
if (cookie.hasOwnProperty("domain") && !this.isEmpty(cookie.domain)) {
|
|
94
|
+
let domain = cookie.domain;
|
|
95
|
+
if (domain.startsWith(".")) {
|
|
96
|
+
domain = domain.substring(1);
|
|
97
|
+
}
|
|
98
|
+
if (topLevelDomain !==domain ) {
|
|
99
|
+
throw new Error(`Cookie URL host ${topLevelDomain} and domain ${domain} mismatched. The cookie won't set correctly.`);
|
|
100
|
+
}
|
|
101
|
+
cookieBuilder+=`; domain=${domain}`
|
|
102
|
+
} else {
|
|
103
|
+
cookieBuilder +=`; domain=${topLevelDomain}`
|
|
104
|
+
}
|
|
105
|
+
if (useWebKit) {
|
|
106
|
+
await web_webview.WebCookieManager.configCookie(url, cookieBuilder);
|
|
107
|
+
} else {
|
|
108
|
+
web_webview.WebCookieManager.configCookieSync(url, cookieBuilder,false);
|
|
109
|
+
}
|
|
110
|
+
return new Promise((resolve) => {
|
|
111
|
+
resolve(true);
|
|
112
|
+
});
|
|
113
|
+
} catch(error) {
|
|
114
|
+
return new Promise((resolve) => {
|
|
115
|
+
resolve(false);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async clearByName(url: string, name: string, useWebKit?: boolean): Promise<boolean>{
|
|
121
|
+
if ((url === '') || (url === undefined) || (url === null)) {
|
|
122
|
+
return new Promise((resolve) => {
|
|
123
|
+
resolve(false);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
let cookieExist = false;
|
|
128
|
+
let cookieStr: string = '';
|
|
129
|
+
let cookies: Array<string> = [];
|
|
130
|
+
if (useWebKit) {
|
|
131
|
+
cookieStr = await web_webview.WebCookieManager.fetchCookie(url);
|
|
132
|
+
} else {
|
|
133
|
+
cookieStr = web_webview.WebCookieManager.fetchCookieSync(url);
|
|
134
|
+
}
|
|
135
|
+
cookies = cookieStr.split(';');
|
|
136
|
+
for (let i = 0 ; i < cookies.length; i++) {
|
|
137
|
+
if (cookies[i].split('=')[0].trim() === name) {
|
|
138
|
+
cookieExist = true;
|
|
139
|
+
cookies.splice(i, 1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (!cookieExist) {
|
|
143
|
+
return new Promise((resolve) => {
|
|
144
|
+
resolve(true);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (useWebKit) {
|
|
148
|
+
await web_webview.WebCookieManager.clearAllCookies();
|
|
149
|
+
} else {
|
|
150
|
+
web_webview.WebCookieManager.clearAllCookiesSync();
|
|
151
|
+
}
|
|
152
|
+
cookies.forEach((item) => {
|
|
153
|
+
web_webview.WebCookieManager.configCookie(url, item);
|
|
154
|
+
})
|
|
155
|
+
return new Promise((resolve) => {
|
|
156
|
+
resolve(true);
|
|
157
|
+
});
|
|
158
|
+
} catch(error) {
|
|
159
|
+
return new Promise((resolve) => {
|
|
160
|
+
resolve(false);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
removeSessionCookies(): Promise<boolean>{
|
|
166
|
+
try {
|
|
167
|
+
web_webview.WebCookieManager.clearSessionCookieSync();
|
|
168
|
+
return new Promise((resolve) => {
|
|
169
|
+
resolve(true);
|
|
170
|
+
});
|
|
171
|
+
} catch(error) {
|
|
172
|
+
return new Promise((resolve) => {
|
|
173
|
+
resolve(false);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -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
|
|
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
|
+
import { RNOHPackage } from '@rnoh/react-native-openharmony'
|
|
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 RNOHPackage {
|
|
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
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export * from "./RTNCookies"
|
|
1
|
+
/**
|
|
2
|
+
* This code was generated by "react-native codegen-lib-harmony"
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from "./RTNCookies"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"module": {
|
|
3
|
-
"name": "rn_cookies",
|
|
4
|
-
"type": "har",
|
|
5
|
-
"deviceTypes": [
|
|
6
|
-
"default",
|
|
7
|
-
"tablet",
|
|
8
|
-
"2in1"
|
|
9
|
-
]
|
|
10
|
-
}
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"module": {
|
|
3
|
+
"name": "rn_cookies",
|
|
4
|
+
"type": "har",
|
|
5
|
+
"deviceTypes": [
|
|
6
|
+
"default",
|
|
7
|
+
"tablet",
|
|
8
|
+
"2in1"
|
|
9
|
+
]
|
|
10
|
+
}
|
|
11
|
+
}
|