@conecli/cone-render 0.10.1-shop3.117 → 0.10.1-shop3.118
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/dist/common/accessibility.h5.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/common/index.h5.ts +1 -1
- package/dist/components/base/CountDownForApp/index.module.scss +52 -0
- package/dist/components/base/CountDownForApp/index.tsx +1 -0
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.h5.ts +1 -1
- package/dist/jumpEventReport/web/report.ts +1 -1
- package/dist/open/components/index.ts +1 -1
- package/dist/service/requestServer.h5.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
1
|
'app-activity',
|
|
3
2
|
'app-rank',
|
|
4
3
|
'app-seckill',
|
|
5
4
|
'm-coupon',
|
|
6
5
|
'scene-buy',
|
|
7
6
|
'light-details',
|
|
8
7
|
'member-paid-center',
|
|
9
8
|
'member-paid-card',
|
|
10
9
|
'member-paid-bind',
|
|
11
10
|
'app-introduce',
|
|
12
11
|
'app-search-result',
|
|
13
12
|
if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
|
|
14
13
|
Taro.nextTick(() => {
|
|
15
14
|
const htmlRoot = document?.documentElement;
|
|
16
15
|
htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
|
|
17
16
|
});
|
|
18
17
|
}
|
|
19
18
|
const mainConfig = {
|
|
20
19
|
childList: true,
|
|
21
20
|
subtree: true,
|
|
22
21
|
attributes: true,
|
|
23
22
|
attributeFilter: ['auto-accessible'],
|
|
24
23
|
};
|
|
25
24
|
const mainObserver = new MutationObserver(function (mutations) {
|
|
26
25
|
mutations.forEach(function (mutation) {
|
|
27
26
|
if (mutation.type === 'childList') {
|
|
28
27
|
mutation.addedNodes.forEach(function (node) {
|
|
29
28
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
30
29
|
if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
|
|
31
30
|
updateAccessibilityLabel(node);
|
|
32
31
|
}
|
|
33
32
|
const accessibleElements = node.querySelectorAll
|
|
34
33
|
? node.querySelectorAll('[auto-accessible="true"]')
|
|
35
34
|
: [];
|
|
36
35
|
accessibleElements.forEach(function (el) {
|
|
37
36
|
updateAccessibilityLabel(el);
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
39
|
});
|
|
41
40
|
}
|
|
42
41
|
if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
|
|
43
42
|
if (mutation.target.getAttribute('auto-accessible') === 'true') {
|
|
44
43
|
updateAccessibilityLabel(mutation.target);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
});
|
|
48
47
|
});
|
|
49
48
|
mainObserver.observe(document.body, mainConfig);
|
|
50
49
|
setupGlobalContentObserver();
|
|
51
50
|
const contentConfig = {
|
|
52
51
|
characterData: true,
|
|
53
52
|
childList: true,
|
|
54
53
|
subtree: true,
|
|
55
54
|
};
|
|
56
55
|
const lastUpdateTime = new WeakMap();
|
|
57
56
|
const THROTTLE_DELAY = 2000;
|
|
58
57
|
|
|
59
58
|
function shouldUpdate(element) {
|
|
60
59
|
const now = Date.now();
|
|
61
60
|
const lastTime = lastUpdateTime.get(element);
|
|
62
61
|
if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
|
|
63
62
|
lastUpdateTime.set(element, now);
|
|
64
63
|
return true;
|
|
65
64
|
}
|
|
66
65
|
return false;
|
|
67
66
|
}
|
|
68
67
|
const globalContentObserver = new MutationObserver(function (mutations) {
|
|
69
68
|
const affectedElements = new Set();
|
|
70
69
|
mutations.forEach(function (mutation) {
|
|
71
70
|
let targetElement = null;
|
|
72
71
|
if (mutation.type === 'characterData') {
|
|
73
72
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
74
73
|
} else if (mutation.type === 'childList') {
|
|
75
74
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
76
75
|
}
|
|
77
76
|
if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
|
|
78
77
|
affectedElements.add(targetElement);
|
|
79
78
|
}
|
|
80
79
|
});
|
|
81
80
|
affectedElements.forEach(function (element) {
|
|
82
81
|
if (shouldUpdate(element)) {
|
|
83
82
|
updateAccessibilityLabel(element);
|
|
84
83
|
} else {
|
|
85
84
|
}
|
|
86
85
|
});
|
|
87
86
|
});
|
|
88
87
|
globalContentObserver.observe(document.body, contentConfig);
|
|
89
88
|
let current = node;
|
|
90
89
|
if (current.nodeType === Node.TEXT_NODE) {
|
|
91
90
|
current = current.parentElement;
|
|
92
91
|
}
|
|
93
92
|
while (current && current !== document.body) {
|
|
94
93
|
if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
|
|
95
94
|
return current;
|
|
96
95
|
}
|
|
97
96
|
current = current.parentElement;
|
|
98
97
|
}
|
|
99
98
|
return null;
|
|
100
99
|
if (!element) return;
|
|
101
100
|
if (element.hasAttribute('aria-label')) {
|
|
102
101
|
completeA11yAttributes(element);
|
|
103
102
|
if (!element.getAttribute('data-auto-aria-label')) {
|
|
104
103
|
return;
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
106
|
const text = element.innerText;
|
|
108
107
|
if (text) {
|
|
109
108
|
const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
|
|
110
109
|
element.setAttribute('aria-label', processedText);
|
|
111
110
|
element.setAttribute('data-auto-aria-label', 'true');
|
|
112
111
|
completeA11yAttributes(element);
|
|
113
112
|
}
|
|
114
113
|
if (!element.hasAttribute('role')) {
|
|
115
114
|
element.setAttribute('role', 'text');
|
|
116
115
|
}
|
|
117
116
|
if (!element.hasAttribute('tabindex')) {
|
|
118
117
|
element.setAttribute('tabindex', 0);
|
|
119
118
|
}
|
|
120
119
|
const routerURL = 'router://JDShopModule/isAccessibilityIsRunning';
|
|
121
120
|
const callBackName = `nativeGetAccessibilityIsRunning${Date.now()}`;
|
|
122
121
|
let params: any = {
|
|
123
122
|
routerURL,
|
|
124
123
|
routerParam: null,
|
|
125
124
|
callBackName,
|
|
126
125
|
};
|
|
127
126
|
return Promise.race([
|
|
128
127
|
new Promise((resolve) => { setTimeout(() => resolve(false), 1000) }),
|
|
129
128
|
new Promise((resolve) => {
|
|
130
129
|
window[callBackName] = (res) => {
|
|
131
130
|
let data;
|
|
132
131
|
try {
|
|
133
132
|
data = typeof res === 'string' ? JSON.parse(res) : res;
|
|
134
133
|
} catch (e) {
|
|
135
134
|
console.error('JSON parse error:', e);
|
|
136
135
|
data = {};
|
|
137
136
|
}
|
|
138
137
|
console.log('无障碍router回调成功:', res);
|
|
139
138
|
const isRunning = data?.data?.isAccessibilityIsRunning || false;
|
|
140
139
|
resolve(isRunning);
|
|
141
140
|
};
|
|
142
141
|
if (isJdAndIosDevice) {
|
|
143
142
|
callRouterIOS(params);
|
|
144
143
|
} else if (isJdAndAndroidDevice) {
|
|
145
144
|
callRouterAndroid(params);
|
|
146
145
|
} else if (isJdAndHarmonyDevice) {
|
|
147
146
|
const plugin = 'JdShopPlugin';
|
|
148
147
|
const action = Message_Type.GET_ACCESSIBILITY_IS_RUNNING;
|
|
149
148
|
params = {
|
|
150
149
|
...params,
|
|
151
150
|
routerURL: '',
|
|
152
151
|
routerParam: {
|
|
153
152
|
type: action,
|
|
154
153
|
callBackName,
|
|
155
154
|
},
|
|
156
155
|
};
|
|
157
156
|
window.XWebView &&
|
|
158
157
|
window.XWebView.callNative(
|
|
159
158
|
plugin,
|
|
160
159
|
action,
|
|
161
160
|
JSON.stringify(params),
|
|
162
161
|
callBackName,
|
|
163
162
|
`${callBackName}HarmonyOS`,
|
|
164
163
|
);
|
|
165
164
|
} else {
|
|
166
165
|
resolve(false);
|
|
167
166
|
}
|
|
168
167
|
})
|
|
169
168
|
])
|
|
170
169
|
setPageLanguage();
|
|
171
170
|
let isRunning;
|
|
172
171
|
try {
|
|
173
172
|
isRunning = await getAccessibilityIsRunning();
|
|
174
173
|
} catch (e) {
|
|
175
174
|
console.error('getAccessibilityIsRunning() ~~ error:', e);
|
|
176
175
|
}
|
|
177
176
|
if (isRunning || autoAccessiblePagesWhitelist.includes(buildType)) {
|
|
178
177
|
console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
|
|
179
178
|
setupMainObserver();
|
|
180
179
|
} else {
|
|
181
180
|
console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
|
|
182
181
|
}
|
|
182
|
+
import Taro from '@tarojs/taro';
|
|
183
183
|
'app-activity',
|
|
184
184
|
'app-rank',
|
|
185
185
|
'app-seckill',
|
|
186
186
|
'm-coupon',
|
|
187
187
|
'scene-buy',
|
|
188
188
|
'light-details',
|
|
189
189
|
'member-paid-center',
|
|
190
190
|
'member-paid-card',
|
|
191
191
|
'member-paid-bind',
|
|
192
192
|
'app-introduce',
|
|
193
193
|
if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
|
|
194
194
|
Taro.nextTick(() => {
|
|
195
195
|
const htmlRoot = document?.documentElement;
|
|
196
196
|
htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
const mainConfig = {
|
|
200
200
|
childList: true,
|
|
201
201
|
subtree: true,
|
|
202
202
|
attributes: true,
|
|
203
203
|
attributeFilter: ['auto-accessible'],
|
|
204
204
|
};
|
|
205
205
|
const mainObserver = new MutationObserver(function (mutations) {
|
|
206
206
|
mutations.forEach(function (mutation) {
|
|
207
207
|
if (mutation.type === 'childList') {
|
|
208
208
|
mutation.addedNodes.forEach(function (node) {
|
|
209
209
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
210
210
|
if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
|
|
211
211
|
updateAccessibilityLabel(node);
|
|
212
212
|
}
|
|
213
213
|
const accessibleElements = node.querySelectorAll
|
|
214
214
|
? node.querySelectorAll('[auto-accessible="true"]')
|
|
215
215
|
: [];
|
|
216
216
|
accessibleElements.forEach(function (el) {
|
|
217
217
|
updateAccessibilityLabel(el);
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
222
|
if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
|
|
223
223
|
if (mutation.target.getAttribute('auto-accessible') === 'true') {
|
|
224
224
|
updateAccessibilityLabel(mutation.target);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
mainObserver.observe(document.body, mainConfig);
|
|
230
230
|
setupGlobalContentObserver();
|
|
231
231
|
const contentConfig = {
|
|
232
232
|
characterData: true,
|
|
233
233
|
childList: true,
|
|
234
234
|
subtree: true,
|
|
235
235
|
};
|
|
236
236
|
const lastUpdateTime = new WeakMap();
|
|
237
237
|
const THROTTLE_DELAY = 2000;
|
|
238
238
|
|
|
239
239
|
function shouldUpdate(element) {
|
|
240
240
|
const now = Date.now();
|
|
241
241
|
const lastTime = lastUpdateTime.get(element);
|
|
242
242
|
if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
|
|
243
243
|
lastUpdateTime.set(element, now);
|
|
244
244
|
return true;
|
|
245
245
|
}
|
|
246
246
|
return false;
|
|
247
247
|
}
|
|
248
248
|
const globalContentObserver = new MutationObserver(function (mutations) {
|
|
249
249
|
const affectedElements = new Set();
|
|
250
250
|
mutations.forEach(function (mutation) {
|
|
251
251
|
let targetElement = null;
|
|
252
252
|
if (mutation.type === 'characterData') {
|
|
253
253
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
254
254
|
} else if (mutation.type === 'childList') {
|
|
255
255
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
256
256
|
}
|
|
257
257
|
if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
|
|
258
258
|
affectedElements.add(targetElement);
|
|
259
259
|
}
|
|
260
260
|
});
|
|
261
261
|
affectedElements.forEach(function (element) {
|
|
262
262
|
if (shouldUpdate(element)) {
|
|
263
263
|
updateAccessibilityLabel(element);
|
|
264
264
|
} else {
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
267
|
});
|
|
268
268
|
globalContentObserver.observe(document.body, contentConfig);
|
|
269
269
|
let current = node;
|
|
270
270
|
if (current.nodeType === Node.TEXT_NODE) {
|
|
271
271
|
current = current.parentElement;
|
|
272
272
|
}
|
|
273
273
|
while (current && current !== document.body) {
|
|
274
274
|
if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
|
|
275
275
|
return current;
|
|
276
276
|
}
|
|
277
277
|
current = current.parentElement;
|
|
278
278
|
}
|
|
279
279
|
return null;
|
|
280
280
|
if (!element) return;
|
|
281
281
|
if (element.hasAttribute('aria-label')) {
|
|
282
282
|
completeA11yAttributes(element);
|
|
283
283
|
if (!element.getAttribute('data-auto-aria-label')) {
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
const text = element.innerText;
|
|
288
288
|
if (text) {
|
|
289
289
|
const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
|
|
290
290
|
element.setAttribute('aria-label', processedText);
|
|
291
291
|
element.setAttribute('data-auto-aria-label', 'true');
|
|
292
292
|
completeA11yAttributes(element);
|
|
293
293
|
}
|
|
294
294
|
if (!element.hasAttribute('role')) {
|
|
295
295
|
element.setAttribute('role', 'text');
|
|
296
296
|
}
|
|
297
297
|
if (!element.hasAttribute('tabindex')) {
|
|
298
298
|
element.setAttribute('tabindex', 0);
|
|
299
299
|
}
|
|
300
300
|
const routerURL = 'router://JDShopModule/isAccessibilityIsRunning';
|
|
301
301
|
const callBackName = `nativeGetAccessibilityIsRunning${Date.now()}`;
|
|
302
302
|
let params: any = {
|
|
303
303
|
routerURL,
|
|
304
304
|
routerParam: null,
|
|
305
305
|
callBackName,
|
|
306
306
|
};
|
|
307
307
|
return Promise.race([
|
|
308
308
|
new Promise((resolve) => {
|
|
309
309
|
setTimeout(() => resolve(false), 1000);
|
|
310
310
|
}),
|
|
311
311
|
new Promise((resolve) => {
|
|
312
312
|
window[callBackName] = (res) => {
|
|
313
313
|
let data;
|
|
314
314
|
try {
|
|
315
315
|
data = typeof res === 'string' ? JSON.parse(res) : res;
|
|
316
316
|
} catch (e) {
|
|
317
317
|
console.error('JSON parse error:', e);
|
|
318
318
|
data = {};
|
|
319
319
|
}
|
|
320
320
|
console.log('无障碍router回调成功:', res);
|
|
321
321
|
const isRunning = data?.data?.isAccessibilityIsRunning || false;
|
|
322
322
|
resolve(isRunning);
|
|
323
323
|
};
|
|
324
324
|
if (isJdAndIosDevice) {
|
|
325
325
|
callRouterIOS(params);
|
|
326
326
|
} else if (isJdAndAndroidDevice) {
|
|
327
327
|
callRouterAndroid(params);
|
|
328
328
|
} else if (isJdAndHarmonyDevice) {
|
|
329
329
|
const plugin = 'JdShopPlugin';
|
|
330
330
|
const action = Message_Type.GET_ACCESSIBILITY_IS_RUNNING;
|
|
331
331
|
params = {
|
|
332
332
|
...params,
|
|
333
333
|
routerURL: '',
|
|
334
334
|
routerParam: {
|
|
335
335
|
type: action,
|
|
336
336
|
callBackName,
|
|
337
337
|
},
|
|
338
338
|
};
|
|
339
339
|
window.XWebView &&
|
|
340
340
|
window.XWebView.callNative(
|
|
341
341
|
plugin,
|
|
342
342
|
action,
|
|
343
343
|
JSON.stringify(params),
|
|
344
344
|
callBackName,
|
|
345
345
|
`${callBackName}HarmonyOS`,
|
|
346
346
|
);
|
|
347
347
|
} else {
|
|
348
348
|
resolve(false);
|
|
349
349
|
}
|
|
350
350
|
}),
|
|
351
351
|
]);
|
|
352
352
|
setPageLanguage();
|
|
353
353
|
let isRunning;
|
|
354
354
|
try {
|
|
355
355
|
isRunning = await getAccessibilityIsRunning();
|
|
356
356
|
} catch (e) {
|
|
357
357
|
console.error('getAccessibilityIsRunning() ~~ error:', e);
|
|
358
358
|
}
|
|
359
359
|
if (isRunning || autoAccessiblePagesWhitelist.includes(buildType)) {
|
|
360
360
|
console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
|
|
361
361
|
setupMainObserver();
|
|
362
362
|
} else {
|
|
363
363
|
console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
|
|
364
364
|
}
|