@conecli/cone-render 0.10.1-shop3.97 → 0.10.1-shop3.99

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.
@@ -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
  console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
120
119
  setupMainObserver();
121
120
  console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
121
+ import Taro from '@tarojs/taro';
122
122
  'app-activity',
123
123
  'app-rank',
124
124
  'app-seckill',
125
125
  'm-coupon',
126
126
  'scene-buy',
127
127
  'light-details',
128
128
  'member-paid-center',
129
129
  'member-paid-card',
130
130
  'member-paid-bind',
131
131
  'app-introduce',
132
132
  'app-search-result',
133
133
  if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
134
134
  Taro.nextTick(() => {
135
135
  const htmlRoot = document?.documentElement;
136
136
  htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
137
137
  });
138
138
  }
139
139
  const mainConfig = {
140
140
  childList: true,
141
141
  subtree: true,
142
142
  attributes: true,
143
143
  attributeFilter: ['auto-accessible'],
144
144
  };
145
145
  const mainObserver = new MutationObserver(function (mutations) {
146
146
  mutations.forEach(function (mutation) {
147
147
  if (mutation.type === 'childList') {
148
148
  mutation.addedNodes.forEach(function (node) {
149
149
  if (node.nodeType === Node.ELEMENT_NODE) {
150
150
  if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
151
151
  updateAccessibilityLabel(node);
152
152
  }
153
153
  const accessibleElements = node.querySelectorAll
154
154
  ? node.querySelectorAll('[auto-accessible="true"]')
155
155
  : [];
156
156
  accessibleElements.forEach(function (el) {
157
157
  updateAccessibilityLabel(el);
158
158
  });
159
159
  }
160
160
  });
161
161
  }
162
162
  if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
163
163
  if (mutation.target.getAttribute('auto-accessible') === 'true') {
164
164
  updateAccessibilityLabel(mutation.target);
165
165
  }
166
166
  }
167
167
  });
168
168
  });
169
169
  mainObserver.observe(document.body, mainConfig);
170
170
  setupGlobalContentObserver();
171
171
  const contentConfig = {
172
172
  characterData: true,
173
173
  childList: true,
174
174
  subtree: true,
175
175
  };
176
176
  const lastUpdateTime = new WeakMap();
177
177
  const THROTTLE_DELAY = 2000;
178
178
 
179
179
  function shouldUpdate(element) {
180
180
  const now = Date.now();
181
181
  const lastTime = lastUpdateTime.get(element);
182
182
  if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
183
183
  lastUpdateTime.set(element, now);
184
184
  return true;
185
185
  }
186
186
  return false;
187
187
  }
188
188
  const globalContentObserver = new MutationObserver(function (mutations) {
189
189
  const affectedElements = new Set();
190
190
  mutations.forEach(function (mutation) {
191
191
  let targetElement = null;
192
192
  if (mutation.type === 'characterData') {
193
193
  targetElement = findClosestAccessibleElement(mutation.target);
194
194
  } else if (mutation.type === 'childList') {
195
195
  targetElement = findClosestAccessibleElement(mutation.target);
196
196
  }
197
197
  if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
198
198
  affectedElements.add(targetElement);
199
199
  }
200
200
  });
201
201
  affectedElements.forEach(function (element) {
202
202
  if (shouldUpdate(element)) {
203
203
  updateAccessibilityLabel(element);
204
204
  } else {
205
205
  }
206
206
  });
207
207
  });
208
208
  globalContentObserver.observe(document.body, contentConfig);
209
209
  let current = node;
210
210
  if (current.nodeType === Node.TEXT_NODE) {
211
211
  current = current.parentElement;
212
212
  }
213
213
  while (current && current !== document.body) {
214
214
  if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
215
215
  return current;
216
216
  }
217
217
  current = current.parentElement;
218
218
  }
219
219
  return null;
220
220
  if (!element) return;
221
221
  if (element.hasAttribute('aria-label')) {
222
222
  completeA11yAttributes(element);
223
223
  if (!element.getAttribute('data-auto-aria-label')) {
224
224
  return;
225
225
  }
226
226
  }
227
227
  const text = element.innerText;
228
228
  if (text) {
229
229
  const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
230
230
  element.setAttribute('aria-label', processedText);
231
231
  element.setAttribute('data-auto-aria-label', 'true');
232
232
  completeA11yAttributes(element);
233
233
  }
234
234
  if (!element.hasAttribute('role')) {
235
235
  element.setAttribute('role', 'text');
236
236
  }
237
237
  if (!element.hasAttribute('tabindex')) {
238
238
  element.setAttribute('tabindex', 0);
239
239
  }
240
240
  const routerURL = 'router://JDShopModule/isAccessibilityIsRunning';
241
241
  const callBackName = `nativeGetAccessibilityIsRunning${Date.now()}`;
242
242
  let params: any = {
243
243
  routerURL,
244
244
  routerParam: null,
245
245
  callBackName,
246
246
  };
247
247
  return new Promise((resolve) => {
248
248
  window[callBackName] = (res) => {
249
249
  const data = typeof res === 'string' ? JSON.parse(res) : res;
250
250
  console.log('无障碍router回调成功:', res);
251
251
  const isRunning = data?.data?.isAccessibilityIsRunning || false;
252
252
  resolve(isRunning);
253
253
  };
254
254
  if (isJdAndIosDevice) {
255
255
  callRouterIOS(params);
256
256
  } else if (isJdAndAndroidDevice) {
257
257
  callRouterAndroid(params);
258
258
  }
259
259
  });
260
260
  setPageLanguage();
261
261
  let isRunning;
262
262
  try {
263
263
  isRunning = await getAccessibilityIsRunning();
264
264
  } catch (e) {
265
265
  console.error('getAccessibilityIsRunning() ~~ error:', e);
266
266
  }
267
267
  if (isRunning || autoAccessiblePagesWhitelist.includes(buildType)) {
268
268
  console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
269
269
  setupMainObserver();
270
270
  } else {
271
271
  console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
272
272
  }
@@ -0,0 +1 @@
1
+ export default () => {};