@lynx-js/web-mainthread-apis 0.13.0 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @lynx-js/web-mainthread-apis
2
2
 
3
+ ## 0.13.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: some inline style properties cause crash ([#647](https://github.com/lynx-family/lynx-stack/pull/647))
8
+
9
+ add support for the following css properties
10
+
11
+ - mask
12
+ - mask-repeat
13
+ - mask-position
14
+ - mask-clip
15
+ - mask-origin
16
+ - mask-size
17
+ - gap
18
+ - column-gap
19
+ - row-gap
20
+ - image-rendering
21
+ - hyphens
22
+ - offset-path
23
+ - offset-distance
24
+
25
+ - feat: support touch events for MTS ([#641](https://github.com/lynx-family/lynx-stack/pull/641))
26
+
27
+ now we support
28
+
29
+ - main-thread:bindtouchstart
30
+ - main-thread:bindtouchend
31
+ - main-thread:bindtouchmove
32
+ - main-thread:bindtouchcancel
33
+
34
+ - Updated dependencies [[`c9ccad6`](https://github.com/lynx-family/lynx-stack/commit/c9ccad6b574c98121149d3e9d4a9a7e97af63d91)]:
35
+ - @lynx-js/web-constants@0.13.1
36
+
3
37
  ## 0.13.0
4
38
 
5
39
  ### Minor Changes
@@ -75,7 +75,7 @@ export class MainThreadRuntime {
75
75
  this.__OnLifecycleEvent = this.config.callbacks.__OnLifecycleEvent;
76
76
  this.SystemInfo = {
77
77
  ...systemInfo,
78
- pixelRatio: config.browserConfig.pixelRatio,
78
+ ...config.browserConfig,
79
79
  };
80
80
  /**
81
81
  * Start the exposure service
@@ -2,12 +2,12 @@ export declare function camelize(str: string): string;
2
2
  declare const cssPropertyMap: Record<number, {
3
3
  name: string;
4
4
  dashName: string;
5
- defaultValue: string;
5
+ isX: boolean;
6
6
  }>;
7
7
  export declare function queryCSSProperty(index: number): {
8
8
  name: string;
9
- defaultValue: string;
10
9
  dashName: string;
10
+ isX: boolean;
11
11
  };
12
12
  export declare function queryCSSPropertyNumber(name: string): number;
13
13
  export { cssPropertyMap };
@@ -15,209 +15,227 @@ export function camelize(str) {
15
15
  let index = 1;
16
16
  const cssPropertyMap = {};
17
17
  const cssPropertyReverseMap = {};
18
- const V = (name, defaultValue) => {
18
+ const V = (name) => {
19
19
  const k = index++;
20
- cssPropertyMap[k] = { name: camelize(name), dashName: name, defaultValue };
20
+ const isX = name.startsWith('-x-');
21
+ cssPropertyMap[k] = { name: camelize(name), dashName: name, isX };
21
22
  cssPropertyReverseMap[name] = k;
22
23
  };
23
- V('top', 'auto');
24
- V('left', 'auto');
25
- V('right', 'auto');
26
- V('bottom', 'auto');
27
- V('position', 'relative');
28
- V('box-sizing', 'auto');
29
- V('background-color', 'transparent');
30
- V('border-left-color', 'black');
31
- V('border-right-color', 'black');
32
- V('border-top-color', 'black');
33
- V('border-bottom-color', 'black');
34
- V('border-radius', '0px');
35
- V('border-top-left-radius', '0px');
36
- V('border-bottom-left-radius', '0px');
37
- V('border-top-right-radius', '0px');
38
- V('border-bottom-right-radius', '0px');
39
- V('border-width', '0px');
40
- V('border-left-width', '0px');
41
- V('border-right-width', '0px');
42
- V('border-top-width', '0px');
43
- V('border-bottom-width', '0px');
44
- V('color', 'black');
45
- V('opacity', '1');
46
- V('display', 'auto');
47
- V('overflow', 'hidden');
48
- V('height', 'auto');
49
- V('width', 'auto');
50
- V('max-width', 'auto');
51
- V('min-width', 'auto');
52
- V('max-height', 'auto');
53
- V('min-height', 'auto');
54
- V('padding', '0px');
55
- V('padding-left', '0px');
56
- V('padding-right', '0px');
57
- V('padding-top', '0px');
58
- V('padding-bottom', '0px');
59
- V('margin', '0px');
60
- V('margin-left', '0px');
61
- V('margin-right', '0px');
62
- V('margin-top', '0px');
63
- V('margin-bottom', '0px');
64
- V('white-space', 'normal');
65
- V('letter-spacing', '0px');
66
- V('text-align', 'start');
67
- V('line-height', '');
68
- V('text-overflow', 'clip');
69
- V('font-size', 'medium');
70
- V('font-weight', 'normal');
71
- V('flex', '0');
72
- V('flex-grow', '0');
73
- V('flex-shrink', '1');
74
- V('flex-basis', 'auto');
75
- V('flex-direction', 'row');
76
- V('flex-wrap', 'nowrap');
77
- V('align-items', 'stretch');
78
- V('align-self', 'stretch');
79
- V('align-content', 'stretch');
80
- V('justify-content', 'stretch');
81
- V('background', 'transparent, transparent');
82
- V('border-color', 'black');
83
- V('font-family', '');
84
- V('font-style', 'normal');
85
- V('transform', '');
86
- V('animation', '');
87
- V('animation-name', '');
88
- V('animation-duration', '');
89
- V('animation-timing-function', 'linear');
90
- V('animation-delay', '0s');
91
- V('animation-iteration-count', '1');
92
- V('animation-direction', 'normal');
93
- V('animation-fill-mode', 'none');
94
- V('animation-play-state', 'running');
95
- V('line-spacing', '0px');
96
- V('border-style', 'solid');
97
- V('order', '0');
98
- V('box-shadow', '');
99
- V('transform-origin', '');
100
- V('linear-orientation', 'vertical');
101
- V('linear-weight-sum', '0');
102
- V('linear-weight', '0');
103
- V('linear-gravity', 'none');
104
- V('linear-layout-gravity', 'none');
105
- V('layout-animation-create-duration', '0s');
106
- V('layout-animation-create-timing-function', 'linear');
107
- V('layout-animation-create-delay', '0s');
108
- V('layout-animation-create-property', 'opacity');
109
- V('layout-animation-delete-duration', '0s');
110
- V('layout-animation-delete-timing-function', 'linear');
111
- V('layout-animation-delete-delay', '0s');
112
- V('layout-animation-delete-property', 'opacity');
113
- V('layout-animation-update-duration', '0s');
114
- V('layout-animation-update-timing-function', 'linear');
115
- V('layout-animation-update-delay', '0s');
116
- V('adapt-font-size', '0');
117
- V('aspect-ratio', '');
118
- V('text-decoration', '');
119
- V('text-shadow', '');
120
- V('background-image', '');
121
- V('background-position', '');
122
- V('background-origin', 'border-box');
123
- V('background-repeat', 'no-repeat');
124
- V('background-size', '');
125
- V('border', '');
126
- V('visibility', 'visible');
127
- V('border-right', '');
128
- V('border-left', '');
129
- V('border-top', '');
130
- V('border-bottom', '');
131
- V('transition', '');
132
- V('transition-property', '');
133
- V('transition-duration', '');
134
- V('transition-delay', '');
135
- V('transition-timing-function', '');
136
- V('content', '');
137
- V('border-left-style', '');
138
- V('border-right-style', '');
139
- V('border-top-style', '');
140
- V('border-bottom-style', '');
141
- V('implicit-animation', 'true');
142
- V('overflow-x', 'hidden');
143
- V('overflow-y', 'hidden');
144
- V('word-break', 'normal');
145
- V('background-clip', 'border-box');
146
- V('outline', 'medium none black');
147
- V('outline-color', 'black');
148
- V('outline-style', 'black');
149
- V('outline-width', 'medium');
150
- V('vertical-align', 'default');
151
- V('caret-color', 'auto');
152
- V('direction', 'normal');
153
- V('relative-id', '-1');
154
- V('relative-align-top', '-1');
155
- V('relative-align-right', '-1');
156
- V('relative-align-bottom', '-1');
157
- V('relative-align-left', '-1');
158
- V('relative-top-of', '-1');
159
- V('relative-right-of', '-1');
160
- V('relative-bottom-of', '-1');
161
- V('relative-left-of', '-1');
162
- V('relative-layout-once', 'true');
163
- V('relative-center', 'none');
164
- V('enter-transition-name', '');
165
- V('exit-transition-name', '');
166
- V('pause-transition-name', '');
167
- V('resume-transition-name', '');
168
- V('flex-flow', 'row nowrap');
169
- V('z-index', '0');
170
- V('text-decoration-color', 'black');
171
- V('linear-cross-gravity', 'none');
172
- V('margin-inline-start', '0px');
173
- V('margin-inline-end', '0px');
174
- V('padding-inline-start', '0px');
175
- V('padding-inline-end', '0px');
176
- V('border-inline-start-color', 'black');
177
- V('border-inline-end-color', 'black');
178
- V('border-inline-start-width', '0px');
179
- V('border-inline-end-width', '0px');
180
- V('border-inline-start-style', '');
181
- V('border-inline-end-style', '');
182
- V('border-start-start-radius', '0px');
183
- V('border-end-start-radius', '0px');
184
- V('border-start-end-radius', '0px');
185
- V('border-end-end-radius', '0px');
186
- V('relative-align-inline-start', '-1');
187
- V('relative-align-inline-end', '-1');
188
- V('relative-inline-start-of', '-1');
189
- V('relative-inline-end-of', '-1');
190
- V('inset-inline-start', '0px');
191
- V('inset-inline-end', '0px');
192
- V('mask-image', '');
193
- V('grid-template-columns', '');
194
- V('grid-template-rows', '');
195
- V('grid-auto-columns', '');
196
- V('grid-auto-rows', '');
197
- V('grid-column-span', '');
198
- V('grid-row-span', '');
199
- V('grid-column-start', '');
200
- V('grid-column-end', '');
201
- V('grid-row-start', '');
202
- V('grid-row-end', '');
203
- V('grid-column-gap', '');
204
- V('grid-row-gap', '');
205
- V('justify-items', 'stretch');
206
- V('justify-self', 'auto');
207
- V('grid-auto-flow', 'row');
208
- V('filter', '');
209
- V('list-main-axis-gap', '0px');
210
- V('list-cross-axis-gap', '0px');
211
- V('linear-direction', 'column');
212
- V('perspective', 'none');
213
- V('cursor', 'default');
214
- V('text-indent', '0px');
215
- V('clip-path', '');
216
- V('text-stroke', '0px transparent');
217
- V('text-stroke-width', '0px');
218
- V('text-stroke-color', 'transparent');
219
- V('-x-auto-font-size', 'false');
220
- V('-x-auto-font-size-preset-sizes', '');
24
+ V('top');
25
+ V('left');
26
+ V('right');
27
+ V('bottom');
28
+ V('position');
29
+ V('box-sizing');
30
+ V('background-color');
31
+ V('border-left-color');
32
+ V('border-right-color');
33
+ V('border-top-color');
34
+ V('border-bottom-color');
35
+ V('border-radius');
36
+ V('border-top-left-radius');
37
+ V('border-bottom-left-radius');
38
+ V('border-top-right-radius');
39
+ V('border-bottom-right-radius');
40
+ V('border-width');
41
+ V('border-left-width');
42
+ V('border-right-width');
43
+ V('border-top-width');
44
+ V('border-bottom-width');
45
+ V('color');
46
+ V('opacity');
47
+ V('display');
48
+ V('overflow');
49
+ V('height');
50
+ V('width');
51
+ V('max-width');
52
+ V('min-width');
53
+ V('max-height');
54
+ V('min-height');
55
+ V('padding');
56
+ V('padding-left');
57
+ V('padding-right');
58
+ V('padding-top');
59
+ V('padding-bottom');
60
+ V('margin');
61
+ V('margin-left');
62
+ V('margin-right');
63
+ V('margin-top');
64
+ V('margin-bottom');
65
+ V('white-space');
66
+ V('letter-spacing');
67
+ V('text-align');
68
+ V('line-height');
69
+ V('text-overflow');
70
+ V('font-size');
71
+ V('font-weight');
72
+ V('flex');
73
+ V('flex-grow');
74
+ V('flex-shrink');
75
+ V('flex-basis');
76
+ V('flex-direction');
77
+ V('flex-wrap');
78
+ V('align-items');
79
+ V('align-self');
80
+ V('align-content');
81
+ V('justify-content');
82
+ V('background');
83
+ V('border-color');
84
+ V('font-family');
85
+ V('font-style');
86
+ V('transform');
87
+ V('animation');
88
+ V('animation-name');
89
+ V('animation-duration');
90
+ V('animation-timing-function');
91
+ V('animation-delay');
92
+ V('animation-iteration-count');
93
+ V('animation-direction');
94
+ V('animation-fill-mode');
95
+ V('animation-play-state');
96
+ V('line-spacing');
97
+ V('border-style');
98
+ V('order');
99
+ V('box-shadow');
100
+ V('transform-origin');
101
+ V('linear-orientation');
102
+ V('linear-weight-sum');
103
+ V('linear-weight');
104
+ V('linear-gravity');
105
+ V('linear-layout-gravity');
106
+ V('layout-animation-create-duration');
107
+ V('layout-animation-create-timing-function');
108
+ V('layout-animation-create-delay');
109
+ V('layout-animation-create-property');
110
+ V('layout-animation-delete-duration');
111
+ V('layout-animation-delete-timing-function');
112
+ V('layout-animation-delete-delay');
113
+ V('layout-animation-delete-property');
114
+ V('layout-animation-update-duration');
115
+ V('layout-animation-update-timing-function');
116
+ V('layout-animation-update-delay');
117
+ V('adapt-font-size');
118
+ V('aspect-ratio');
119
+ V('text-decoration');
120
+ V('text-shadow');
121
+ V('background-image');
122
+ V('background-position');
123
+ V('background-origin');
124
+ V('background-repeat');
125
+ V('background-size');
126
+ V('border');
127
+ V('visibility');
128
+ V('border-right');
129
+ V('border-left');
130
+ V('border-top');
131
+ V('border-bottom');
132
+ V('transition');
133
+ V('transition-property');
134
+ V('transition-duration');
135
+ V('transition-delay');
136
+ V('transition-timing-function');
137
+ V('content');
138
+ V('border-left-style');
139
+ V('border-right-style');
140
+ V('border-top-style');
141
+ V('border-bottom-style');
142
+ V('implicit-animation');
143
+ V('overflow-x');
144
+ V('overflow-y');
145
+ V('word-break');
146
+ V('background-clip');
147
+ V('outline');
148
+ V('outline-color');
149
+ V('outline-style');
150
+ V('outline-width');
151
+ V('vertical-align');
152
+ V('caret-color');
153
+ V('direction');
154
+ V('relative-id');
155
+ V('relative-align-top');
156
+ V('relative-align-right');
157
+ V('relative-align-bottom');
158
+ V('relative-align-left');
159
+ V('relative-top-of');
160
+ V('relative-right-of');
161
+ V('relative-bottom-of');
162
+ V('relative-left-of');
163
+ V('relative-layout-once');
164
+ V('relative-center');
165
+ V('enter-transition-name');
166
+ V('exit-transition-name');
167
+ V('pause-transition-name');
168
+ V('resume-transition-name');
169
+ V('flex-flow');
170
+ V('z-index');
171
+ V('text-decoration-color');
172
+ V('linear-cross-gravity');
173
+ V('margin-inline-start');
174
+ V('margin-inline-end');
175
+ V('padding-inline-start');
176
+ V('padding-inline-end');
177
+ V('border-inline-start-color');
178
+ V('border-inline-end-color');
179
+ V('border-inline-start-width');
180
+ V('border-inline-end-width');
181
+ V('border-inline-start-style');
182
+ V('border-inline-end-style');
183
+ V('border-start-start-radius');
184
+ V('border-end-start-radius');
185
+ V('border-start-end-radius');
186
+ V('border-end-end-radius');
187
+ V('relative-align-inline-start');
188
+ V('relative-align-inline-end');
189
+ V('relative-inline-start-of');
190
+ V('relative-inline-end-of');
191
+ V('inset-inline-start');
192
+ V('inset-inline-end');
193
+ V('mask-image');
194
+ V('grid-template-columns');
195
+ V('grid-template-rows');
196
+ V('grid-auto-columns');
197
+ V('grid-auto-rows');
198
+ V('grid-column-span');
199
+ V('grid-row-span');
200
+ V('grid-column-start');
201
+ V('grid-column-end');
202
+ V('grid-row-start');
203
+ V('grid-row-end');
204
+ V('grid-column-gap');
205
+ V('grid-row-gap');
206
+ V('justify-items');
207
+ V('justify-self');
208
+ V('grid-auto-flow');
209
+ V('filter');
210
+ V('list-main-axis-gap');
211
+ V('list-cross-axis-gap');
212
+ V('linear-direction');
213
+ V('perspective');
214
+ V('cursor');
215
+ V('text-indent');
216
+ V('clip-path');
217
+ V('text-stroke');
218
+ V('text-stroke-width');
219
+ V('text-stroke-color');
220
+ V('-x-auto-font-size');
221
+ V('-x-auto-font-size-preset-sizes');
222
+ V('mask');
223
+ V('mask-repeat');
224
+ V('mask-position');
225
+ V('mask-clip');
226
+ V('mask-origin');
227
+ V('mask-size');
228
+ V('gap');
229
+ V('column-gap');
230
+ V('row-gap');
231
+ V('image-rendering');
232
+ V('hyphens');
233
+ V('-x-app-region');
234
+ V('-x-animation-color-interpolation');
235
+ V('-x-handle-color');
236
+ V('-x-handle-size');
237
+ V('offset-path');
238
+ V('offset-distance');
221
239
  export function queryCSSProperty(index) {
222
240
  return cssPropertyMap[index];
223
241
  }
@@ -32,7 +32,11 @@ export function createStyleFunctions(runtime, cssInJsInfo) {
32
32
  function __AddInlineStyle(element, key, value) {
33
33
  let dashName;
34
34
  if (typeof key === 'number') {
35
- dashName = queryCSSProperty(key).dashName;
35
+ const queryResult = queryCSSProperty(key);
36
+ dashName = queryResult.dashName;
37
+ if (queryResult.isX) {
38
+ console.error(`[lynx-web] css property: ${dashName} is not supported.`);
39
+ }
36
40
  }
37
41
  else {
38
42
  dashName = key;
@@ -1,10 +1,23 @@
1
1
  import { elementToRuntimeInfoMap, } from '../MainThreadRuntime.js';
2
+ function toCloneableObject(obj) {
3
+ const cloneableObj = {};
4
+ for (const key in obj) {
5
+ const value = obj[key];
6
+ if (typeof value === 'boolean' || typeof value === 'number'
7
+ || typeof value === 'string' || value === null) {
8
+ cloneableObj[key] = value;
9
+ }
10
+ }
11
+ return cloneableObj;
12
+ }
2
13
  export function createCrossThreadEvent(runtime, domEvent, eventName) {
3
14
  const targetElement = domEvent.target;
4
15
  const currentTargetElement = domEvent
5
16
  .currentTarget;
6
17
  const type = domEvent.type;
7
18
  const params = {};
19
+ const isTrusted = domEvent.isTrusted;
20
+ const otherProperties = {};
8
21
  if (type.match(/^transition/)) {
9
22
  Object.assign(params, {
10
23
  'animation_type': 'keyframe-animation',
@@ -19,6 +32,21 @@ export function createCrossThreadEvent(runtime, domEvent, eventName) {
19
32
  new_animator: true, // we support the new_animator only
20
33
  });
21
34
  }
35
+ else if (type.startsWith('touch')) {
36
+ const touchEvent = domEvent;
37
+ const touch = [...touchEvent.touches];
38
+ const targetTouches = [...touchEvent.targetTouches];
39
+ const changedTouches = [...touchEvent.changedTouches];
40
+ Object.assign(otherProperties, {
41
+ touches: isTrusted ? touch.map(toCloneableObject) : touch,
42
+ targetTouches: isTrusted
43
+ ? targetTouches.map(toCloneableObject)
44
+ : targetTouches,
45
+ changedTouches: isTrusted
46
+ ? changedTouches.map(toCloneableObject)
47
+ : changedTouches,
48
+ });
49
+ }
22
50
  const targetElementRuntimeInfo = runtime[elementToRuntimeInfoMap].get(targetElement);
23
51
  const currentTargetElementRuntimeInfo = runtime[elementToRuntimeInfoMap].get(currentTargetElement);
24
52
  return {
@@ -39,6 +67,7 @@ export function createCrossThreadEvent(runtime, domEvent, eventName) {
39
67
  // @ts-expect-error
40
68
  detail: domEvent.detail ?? {},
41
69
  params,
70
+ ...otherProperties,
42
71
  };
43
72
  }
44
73
  //# sourceMappingURL=createCrossThreadEvent.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-mainthread-apis",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "css-tree": "^3.1.0",
27
27
  "hyphenate-style-name": "^1.1.0",
28
- "@lynx-js/web-constants": "0.13.0",
28
+ "@lynx-js/web-constants": "0.13.1",
29
29
  "@lynx-js/web-style-transformer": "0.3.0"
30
30
  }
31
31
  }