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