@lynx-js/testing-environment 0.1.10 → 0.1.11

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,11 @@
1
1
  # @lynx-js/testing-environment
2
2
 
3
+ ## 0.1.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 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))
8
+
3
9
  ## 0.1.10
4
10
 
5
11
  ### 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;
@@ -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
  */
@@ -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.11",
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",