@lynx-js/testing-environment 0.1.10 → 0.1.12

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,17 @@
1
1
  # @lynx-js/testing-environment
2
2
 
3
+ ## 0.1.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Implement `__ElementAnimate` PAPI for web platform animation lifecycle ([#2329](https://github.com/lynx-family/lynx-stack/pull/2329))
8
+
9
+ ## 0.1.11
10
+
11
+ ### Patch Changes
12
+
13
+ - Remove element api calls alog by default, and only enable it when `__ALOG_ELEMENT_API__` is defined to `true` or environment variable `REACT_ALOG_ELEMENT_API` is set to `true`. ([#2192](https://github.com/lynx-family/lynx-stack/pull/2192))
14
+
3
15
  ## 0.1.10
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -163,6 +163,7 @@ function injectMainThreadGlobals(target, polyfills) {
163
163
  target.__DEV__ = true;
164
164
  target.__PROFILE__ = true;
165
165
  target.__ALOG__ = true;
166
+ target.__ALOG_ELEMENT_API__ = true;
166
167
  target.__JS__ = false;
167
168
  target.__LEPUS__ = true;
168
169
  target.__BACKGROUND__ = false;
@@ -172,8 +173,28 @@ function injectMainThreadGlobals(target, polyfills) {
172
173
  target.__TESTING_FORCE_RENDER_TO_OPCODE__ = false;
173
174
  target.__ENABLE_SSR__ = false;
174
175
  target.globDynamicComponentEntry = '__Card__';
176
+ const native = {
177
+ _listeners: {},
178
+ onTriggerEvent: void 0,
179
+ postMessage: (_message)=>{},
180
+ addEventListener: (type, listener)=>{
181
+ if (!native._listeners[type]) native._listeners[type] = [];
182
+ native._listeners[type].push(listener);
183
+ },
184
+ removeEventListener: (type, listener)=>{
185
+ if (native._listeners[type]) native._listeners[type] = native._listeners[type].filter((l)=>l !== listener);
186
+ },
187
+ dispatchEvent: (event)=>{
188
+ const listeners = native._listeners[event.type];
189
+ if (listeners) listeners.forEach((listener)=>listener(event));
190
+ return {
191
+ canceled: false
192
+ };
193
+ }
194
+ };
175
195
  target.lynx = {
176
196
  performance,
197
+ getNative: ()=>native,
177
198
  getCoreContext: ()=>CoreContext,
178
199
  getJSContext: ()=>JsContext,
179
200
  reportError: (e)=>{
@@ -222,6 +243,7 @@ function injectBackgroundThreadGlobals(target, polyfills) {
222
243
  target.__DEV__ = true;
223
244
  target.__PROFILE__ = true;
224
245
  target.__ALOG__ = true;
246
+ target.__ALOG_ELEMENT_API__ = true;
225
247
  target.__JS__ = true;
226
248
  target.__LEPUS__ = false;
227
249
  target.__BACKGROUND__ = true;
package/dist/index.js CHANGED
@@ -124,6 +124,7 @@ function injectMainThreadGlobals(target, polyfills) {
124
124
  target.__DEV__ = true;
125
125
  target.__PROFILE__ = true;
126
126
  target.__ALOG__ = true;
127
+ target.__ALOG_ELEMENT_API__ = true;
127
128
  target.__JS__ = false;
128
129
  target.__LEPUS__ = true;
129
130
  target.__BACKGROUND__ = false;
@@ -133,8 +134,28 @@ function injectMainThreadGlobals(target, polyfills) {
133
134
  target.__TESTING_FORCE_RENDER_TO_OPCODE__ = false;
134
135
  target.__ENABLE_SSR__ = false;
135
136
  target.globDynamicComponentEntry = '__Card__';
137
+ const native = {
138
+ _listeners: {},
139
+ onTriggerEvent: void 0,
140
+ postMessage: (_message)=>{},
141
+ addEventListener: (type, listener)=>{
142
+ if (!native._listeners[type]) native._listeners[type] = [];
143
+ native._listeners[type].push(listener);
144
+ },
145
+ removeEventListener: (type, listener)=>{
146
+ if (native._listeners[type]) native._listeners[type] = native._listeners[type].filter((l)=>l !== listener);
147
+ },
148
+ dispatchEvent: (event)=>{
149
+ const listeners = native._listeners[event.type];
150
+ if (listeners) listeners.forEach((listener)=>listener(event));
151
+ return {
152
+ canceled: false
153
+ };
154
+ }
155
+ };
136
156
  target.lynx = {
137
157
  performance,
158
+ getNative: ()=>native,
138
159
  getCoreContext: ()=>CoreContext,
139
160
  getJSContext: ()=>JsContext,
140
161
  reportError: (e)=>{
@@ -183,6 +204,7 @@ function injectBackgroundThreadGlobals(target, polyfills) {
183
204
  target.__DEV__ = true;
184
205
  target.__PROFILE__ = true;
185
206
  target.__ALOG__ = true;
207
+ target.__ALOG_ELEMENT_API__ = true;
186
208
  target.__JS__ = true;
187
209
  target.__LEPUS__ = false;
188
210
  target.__BACKGROUND__ = true;
@@ -231,6 +231,44 @@ const initElementTree = ()=>{
231
231
  __GetAttributeByName(ele, name) {
232
232
  return ele.getAttribute(name);
233
233
  }
234
+ __ElementAnimate(element, args) {
235
+ const [operation, name] = args;
236
+ switch(operation){
237
+ case 0:
238
+ {
239
+ const keyframes = args[2];
240
+ const options = args[3];
241
+ this.animationMap.set(name, {
242
+ element,
243
+ state: 'running',
244
+ keyframes,
245
+ options
246
+ });
247
+ break;
248
+ }
249
+ case 1:
250
+ {
251
+ const anim = this.animationMap.get(name);
252
+ if (anim) anim.state = 'running';
253
+ break;
254
+ }
255
+ case 2:
256
+ {
257
+ const anim = this.animationMap.get(name);
258
+ if (anim) anim.state = 'paused';
259
+ break;
260
+ }
261
+ case 3:
262
+ this.animationMap.delete(name);
263
+ break;
264
+ case 4:
265
+ {
266
+ const anim = this.animationMap.get(name);
267
+ if (anim) anim.state = 'finished';
268
+ break;
269
+ }
270
+ }
271
+ }
234
272
  clear() {
235
273
  this.root = void 0;
236
274
  }
@@ -254,6 +292,7 @@ const initElementTree = ()=>{
254
292
  constructor(){
255
293
  _define_property(this, "uniqueId2Element", new Map());
256
294
  _define_property(this, "root", void 0);
295
+ _define_property(this, "animationMap", new Map());
257
296
  }
258
297
  }();
259
298
  };
@@ -6,18 +6,6 @@
6
6
  * @public
7
7
  */
8
8
  export interface LynxElement extends HTMLElement {
9
- /**
10
- * The unique id of the element.
11
- *
12
- * @internal
13
- */
14
- $$uiSign: number;
15
- /**
16
- * The unique id of the parent of the element.
17
- *
18
- * @internal
19
- */
20
- parentComponentUniqueId: number;
21
9
  /**
22
10
  * The map of events bound to the element.
23
11
  */
@@ -96,6 +84,14 @@ export declare const initElementTree: () => {
96
84
  __CreateList(parentComponentUniqueId: number, componentAtIndex: any, enqueueComponent: any): LynxElement;
97
85
  __GetTag(ele: LynxElement): string;
98
86
  __GetAttributeByName(ele: LynxElement, name: string): string | null;
87
+ /** @internal */
88
+ animationMap: Map<string, {
89
+ element: LynxElement;
90
+ state: string;
91
+ keyframes?: any[];
92
+ options?: any;
93
+ }>;
94
+ __ElementAnimate(element: LynxElement, args: [number, string, ...any[]]): void;
99
95
  clear(): void;
100
96
  toTree(): LynxElement | undefined;
101
97
  /**
@@ -203,6 +203,44 @@ const initElementTree = ()=>{
203
203
  __GetAttributeByName(ele, name) {
204
204
  return ele.getAttribute(name);
205
205
  }
206
+ __ElementAnimate(element, args) {
207
+ const [operation, name] = args;
208
+ switch(operation){
209
+ case 0:
210
+ {
211
+ const keyframes = args[2];
212
+ const options = args[3];
213
+ this.animationMap.set(name, {
214
+ element,
215
+ state: 'running',
216
+ keyframes,
217
+ options
218
+ });
219
+ break;
220
+ }
221
+ case 1:
222
+ {
223
+ const anim = this.animationMap.get(name);
224
+ if (anim) anim.state = 'running';
225
+ break;
226
+ }
227
+ case 2:
228
+ {
229
+ const anim = this.animationMap.get(name);
230
+ if (anim) anim.state = 'paused';
231
+ break;
232
+ }
233
+ case 3:
234
+ this.animationMap.delete(name);
235
+ break;
236
+ case 4:
237
+ {
238
+ const anim = this.animationMap.get(name);
239
+ if (anim) anim.state = 'finished';
240
+ break;
241
+ }
242
+ }
243
+ }
206
244
  clear() {
207
245
  this.root = void 0;
208
246
  }
@@ -226,6 +264,7 @@ const initElementTree = ()=>{
226
264
  constructor(){
227
265
  _define_property(this, "uniqueId2Element", new Map());
228
266
  _define_property(this, "root", void 0);
267
+ _define_property(this, "animationMap", new Map());
229
268
  }
230
269
  }();
231
270
  };
@@ -5,14 +5,6 @@ export declare const createGlobalThis: () => LynxGlobalThis;
5
5
  * @public
6
6
  */
7
7
  export interface LynxGlobalThis {
8
- /**
9
- * @internal
10
- */
11
- _globalObject: any;
12
- /**
13
- * @internal
14
- */
15
- _globalProxy: any;
16
8
  /**
17
9
  * The globalThis object.
18
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/testing-environment",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "A subset of a Lynx environment to be useful for testing",
5
5
  "keywords": [
6
6
  "Lynx",
@@ -49,7 +49,7 @@
49
49
  "devDependencies": {
50
50
  "@testing-library/jest-dom": "^6.9.1",
51
51
  "@types/jsdom": "^21.1.7",
52
- "rsbuild-plugin-publint": "0.3.3"
52
+ "rsbuild-plugin-publint": "0.3.4"
53
53
  },
54
54
  "scripts": {
55
55
  "api-extractor": "api-extractor run --verbose",