@conecli/cone-render 0.10.1-shop3.84 → 0.10.1-shop3.86

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
  if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
9
8
  Taro.nextTick(() => {
10
9
  const htmlRoot = document?.documentElement;
11
10
  htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
12
11
  });
13
12
  }
14
13
  const mainConfig = {
15
14
  childList: true,
16
15
  subtree: true,
17
16
  attributes: true,
18
17
  attributeFilter: ['auto-accessible'],
19
18
  };
20
19
  const mainObserver = new MutationObserver(function (mutations) {
21
20
  mutations.forEach(function (mutation) {
22
21
  if (mutation.type === 'childList') {
23
22
  mutation.addedNodes.forEach(function (node) {
24
23
  if (node.nodeType === Node.ELEMENT_NODE) {
25
24
  if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
26
25
  updateAccessibilityLabel(node);
27
26
  }
28
27
  const accessibleElements = node.querySelectorAll
29
28
  ? node.querySelectorAll('[auto-accessible="true"]')
30
29
  : [];
31
30
  accessibleElements.forEach(function (el) {
32
31
  updateAccessibilityLabel(el);
33
32
  });
34
33
  }
35
34
  });
36
35
  }
37
36
  if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
38
37
  if (mutation.target.getAttribute('auto-accessible') === 'true') {
39
38
  updateAccessibilityLabel(mutation.target);
40
39
  }
41
40
  }
42
41
  });
43
42
  });
44
43
  mainObserver.observe(document.body, mainConfig);
45
44
  setupGlobalContentObserver();
46
45
  const contentConfig = {
47
46
  characterData: true,
48
47
  childList: true,
49
48
  subtree: true,
50
49
  };
51
50
  const lastUpdateTime = new WeakMap();
52
51
  const THROTTLE_DELAY = 2000;
53
52
 
54
53
  function shouldUpdate(element) {
55
54
  const now = Date.now();
56
55
  const lastTime = lastUpdateTime.get(element);
57
56
  if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
58
57
  lastUpdateTime.set(element, now);
59
58
  return true;
60
59
  }
61
60
  return false;
62
61
  }
63
62
  const globalContentObserver = new MutationObserver(function (mutations) {
64
63
  const affectedElements = new Set();
65
64
  mutations.forEach(function (mutation) {
66
65
  let targetElement = null;
67
66
  if (mutation.type === 'characterData') {
68
67
  targetElement = findClosestAccessibleElement(mutation.target);
69
68
  } else if (mutation.type === 'childList') {
70
69
  targetElement = findClosestAccessibleElement(mutation.target);
71
70
  }
72
71
  if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
73
72
  affectedElements.add(targetElement);
74
73
  }
75
74
  });
76
75
  affectedElements.forEach(function (element) {
77
76
  if (shouldUpdate(element)) {
78
77
  updateAccessibilityLabel(element);
79
78
  } else {
80
79
  }
81
80
  });
82
81
  });
83
82
  globalContentObserver.observe(document.body, contentConfig);
84
83
  let current = node;
85
84
  if (current.nodeType === Node.TEXT_NODE) {
86
85
  current = current.parentElement;
87
86
  }
88
87
  while (current && current !== document.body) {
89
88
  if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
90
89
  return current;
91
90
  }
92
91
  current = current.parentElement;
93
92
  }
94
93
  return null;
95
94
  if (!element) return;
96
95
  if (element.hasAttribute('aria-label')) {
97
96
  completeA11yAttributes(element);
98
97
  if (!element.getAttribute('data-auto-aria-label')) {
99
98
  return;
100
99
  }
101
100
  }
102
101
  const text = element.innerText;
103
102
  if (text) {
104
103
  const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
105
104
  element.setAttribute('aria-label', processedText);
106
105
  element.setAttribute('data-auto-aria-label', 'true');
107
106
  completeA11yAttributes(element);
108
107
  }
109
108
  if (!element.hasAttribute('role')) {
110
109
  element.setAttribute('role', 'text');
111
110
  }
112
111
  if (!element.hasAttribute('tabindex')) {
113
112
  element.setAttribute('tabindex', 0);
114
113
  }
115
114
  console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
116
115
  setupMainObserver();
117
116
  console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
117
+ import Taro from '@tarojs/taro';
118
118
  'app-activity',
119
119
  'app-rank',
120
120
  'app-seckill',
121
121
  'm-coupon',
122
122
  'scene-buy',
123
123
  'light-details',
124
124
  'member-paid-center',
125
125
  'member-paid-card',
126
126
  'member-paid-bind',
127
127
  'app-introduce',
128
128
  if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
129
129
  Taro.nextTick(() => {
130
130
  const htmlRoot = document?.documentElement;
131
131
  htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
132
132
  });
133
133
  }
134
134
  const mainConfig = {
135
135
  childList: true,
136
136
  subtree: true,
137
137
  attributes: true,
138
138
  attributeFilter: ['auto-accessible'],
139
139
  };
140
140
  const mainObserver = new MutationObserver(function (mutations) {
141
141
  mutations.forEach(function (mutation) {
142
142
  if (mutation.type === 'childList') {
143
143
  mutation.addedNodes.forEach(function (node) {
144
144
  if (node.nodeType === Node.ELEMENT_NODE) {
145
145
  if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
146
146
  updateAccessibilityLabel(node);
147
147
  }
148
148
  const accessibleElements = node.querySelectorAll
149
149
  ? node.querySelectorAll('[auto-accessible="true"]')
150
150
  : [];
151
151
  accessibleElements.forEach(function (el) {
152
152
  updateAccessibilityLabel(el);
153
153
  });
154
154
  }
155
155
  });
156
156
  }
157
157
  if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
158
158
  if (mutation.target.getAttribute('auto-accessible') === 'true') {
159
159
  updateAccessibilityLabel(mutation.target);
160
160
  }
161
161
  }
162
162
  });
163
163
  });
164
164
  mainObserver.observe(document.body, mainConfig);
165
165
  setupGlobalContentObserver();
166
166
  const contentConfig = {
167
167
  characterData: true,
168
168
  childList: true,
169
169
  subtree: true,
170
170
  };
171
171
  const lastUpdateTime = new WeakMap();
172
172
  const THROTTLE_DELAY = 2000;
173
173
 
174
174
  function shouldUpdate(element) {
175
175
  const now = Date.now();
176
176
  const lastTime = lastUpdateTime.get(element);
177
177
  if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
178
178
  lastUpdateTime.set(element, now);
179
179
  return true;
180
180
  }
181
181
  return false;
182
182
  }
183
183
  const globalContentObserver = new MutationObserver(function (mutations) {
184
184
  const affectedElements = new Set();
185
185
  mutations.forEach(function (mutation) {
186
186
  let targetElement = null;
187
187
  if (mutation.type === 'characterData') {
188
188
  targetElement = findClosestAccessibleElement(mutation.target);
189
189
  } else if (mutation.type === 'childList') {
190
190
  targetElement = findClosestAccessibleElement(mutation.target);
191
191
  }
192
192
  if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
193
193
  affectedElements.add(targetElement);
194
194
  }
195
195
  });
196
196
  affectedElements.forEach(function (element) {
197
197
  if (shouldUpdate(element)) {
198
198
  updateAccessibilityLabel(element);
199
199
  } else {
200
200
  }
201
201
  });
202
202
  });
203
203
  globalContentObserver.observe(document.body, contentConfig);
204
204
  let current = node;
205
205
  if (current.nodeType === Node.TEXT_NODE) {
206
206
  current = current.parentElement;
207
207
  }
208
208
  while (current && current !== document.body) {
209
209
  if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
210
210
  return current;
211
211
  }
212
212
  current = current.parentElement;
213
213
  }
214
214
  return null;
215
215
  if (!element) return;
216
216
  if (element.hasAttribute('aria-label')) {
217
217
  completeA11yAttributes(element);
218
218
  if (!element.getAttribute('data-auto-aria-label')) {
219
219
  return;
220
220
  }
221
221
  }
222
222
  const text = element.innerText;
223
223
  if (text) {
224
224
  const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
225
225
  element.setAttribute('aria-label', processedText);
226
226
  element.setAttribute('data-auto-aria-label', 'true');
227
227
  completeA11yAttributes(element);
228
228
  }
229
229
  if (!element.hasAttribute('role')) {
230
230
  element.setAttribute('role', 'text');
231
231
  }
232
232
  if (!element.hasAttribute('tabindex')) {
233
233
  element.setAttribute('tabindex', 0);
234
234
  }
235
235
  console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
236
236
  setupMainObserver();
237
237
  console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);