@lynx-js/testing-environment 0.1.0 → 0.1.2

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,13 +1,13 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE_vitest_environments_fd1a84b1__ from "vitest/environments";
2
- import * as __WEBPACK_EXTERNAL_MODULE__lynx_js_testing_environment_6a42c65e__ from "@lynx-js/testing-environment";
1
+ import { builtinEnvironments } from "vitest/environments";
2
+ import { LynxTestingEnv } from "@lynx-js/testing-environment";
3
3
  const env = {
4
4
  name: 'lynxTestingEnv',
5
5
  transformMode: 'web',
6
6
  async setup (global) {
7
7
  const fakeGlobal = {};
8
- await __WEBPACK_EXTERNAL_MODULE_vitest_environments_fd1a84b1__.builtinEnvironments.jsdom.setup(fakeGlobal, {});
8
+ await builtinEnvironments.jsdom.setup(fakeGlobal, {});
9
9
  global.jsdom = fakeGlobal.jsdom;
10
- const lynxTestingEnv = new __WEBPACK_EXTERNAL_MODULE__lynx_js_testing_environment_6a42c65e__.LynxTestingEnv();
10
+ const lynxTestingEnv = new LynxTestingEnv();
11
11
  global.lynxTestingEnv = lynxTestingEnv;
12
12
  return {
13
13
  teardown (global) {
package/dist/index.cjs CHANGED
@@ -149,7 +149,7 @@ function createPolyfills() {
149
149
  function injectMainThreadGlobals(target, polyfills) {
150
150
  var _globalThis_onInjectMainThreadGlobals, _globalThis;
151
151
  __injectElementApi(target);
152
- const { performance, JsContext, __LoadLepusChunk } = polyfills || {};
152
+ const { performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
153
153
  if (void 0 === target) target = globalThis;
154
154
  target.__DEV__ = true;
155
155
  target.__PROFILE__ = true;
@@ -164,6 +164,7 @@ function injectMainThreadGlobals(target, polyfills) {
164
164
  target.globDynamicComponentEntry = '__Card__';
165
165
  target.lynx = {
166
166
  performance,
167
+ getCoreContext: ()=>CoreContext,
167
168
  getJSContext: ()=>JsContext,
168
169
  reportError: (e)=>{
169
170
  throw e;
@@ -202,7 +203,7 @@ class NodesRef {
202
203
  }
203
204
  function injectBackgroundThreadGlobals(target, polyfills) {
204
205
  var _globalThis_onInjectBackgroundThreadGlobals, _globalThis;
205
- const { app, performance, CoreContext, __LoadLepusChunk } = polyfills || {};
206
+ const { app, performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
206
207
  if (void 0 === target) target = globalThis;
207
208
  target.__DEV__ = true;
208
209
  target.__PROFILE__ = true;
@@ -234,6 +235,7 @@ function injectBackgroundThreadGlobals(target, polyfills) {
234
235
  }
235
236
  }),
236
237
  getCoreContext: ()=>CoreContext,
238
+ getJSContext: ()=>JsContext,
237
239
  getJSModule: (moduleName)=>{
238
240
  if ('GlobalEventEmitter' === moduleName) return globalEventEmitter;
239
241
  throw new Error(`getJSModule(${moduleName}) not implemented`);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE_events__ from "events";
2
- import * as __WEBPACK_EXTERNAL_MODULE__lynx_GlobalThis_js_9774bdf8__ from "./lynx/GlobalThis.js";
3
- import * as __WEBPACK_EXTERNAL_MODULE__lynx_ElementPAPI_js_053942f3__ from "./lynx/ElementPAPI.js";
1
+ import events from "events";
2
+ import { createGlobalThis } from "./lynx/GlobalThis.js";
3
+ import { initElementTree } from "./lynx/ElementPAPI.js";
4
4
  function _define_property(obj, key, value) {
5
5
  if (key in obj) Object.defineProperty(obj, key, {
6
6
  value: value,
@@ -12,7 +12,7 @@ function _define_property(obj, key, value) {
12
12
  return obj;
13
13
  }
14
14
  function __injectElementApi(target) {
15
- const elementTree = (0, __WEBPACK_EXTERNAL_MODULE__lynx_ElementPAPI_js_053942f3__.initElementTree)();
15
+ const elementTree = initElementTree();
16
16
  target.elementTree = elementTree;
17
17
  if (void 0 === target) target = globalThis;
18
18
  for (const k of Object.getOwnPropertyNames(elementTree.constructor.prototype))if (k.startsWith('__')) target[k] = elementTree[k].bind(elementTree);
@@ -74,7 +74,7 @@ function createPolyfills() {
74
74
  ]);
75
75
  }
76
76
  };
77
- const ee = new __WEBPACK_EXTERNAL_MODULE_events__["default"]();
77
+ const ee = new events();
78
78
  ee.dispatchEvent = ({ type, data })=>{
79
79
  const isMainThread = __MAIN_THREAD__;
80
80
  lynxTestingEnv.switchToBackgroundThread();
@@ -110,7 +110,7 @@ function createPolyfills() {
110
110
  function injectMainThreadGlobals(target, polyfills) {
111
111
  var _globalThis_onInjectMainThreadGlobals, _globalThis;
112
112
  __injectElementApi(target);
113
- const { performance, JsContext, __LoadLepusChunk } = polyfills || {};
113
+ const { performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
114
114
  if (void 0 === target) target = globalThis;
115
115
  target.__DEV__ = true;
116
116
  target.__PROFILE__ = true;
@@ -125,6 +125,7 @@ function injectMainThreadGlobals(target, polyfills) {
125
125
  target.globDynamicComponentEntry = '__Card__';
126
126
  target.lynx = {
127
127
  performance,
128
+ getCoreContext: ()=>CoreContext,
128
129
  getJSContext: ()=>JsContext,
129
130
  reportError: (e)=>{
130
131
  throw e;
@@ -163,7 +164,7 @@ class NodesRef {
163
164
  }
164
165
  function injectBackgroundThreadGlobals(target, polyfills) {
165
166
  var _globalThis_onInjectBackgroundThreadGlobals, _globalThis;
166
- const { app, performance, CoreContext, __LoadLepusChunk } = polyfills || {};
167
+ const { app, performance, CoreContext, JsContext, __LoadLepusChunk } = polyfills || {};
167
168
  if (void 0 === target) target = globalThis;
168
169
  target.__DEV__ = true;
169
170
  target.__PROFILE__ = true;
@@ -180,7 +181,7 @@ function injectBackgroundThreadGlobals(target, polyfills) {
180
181
  updateData: {}
181
182
  }
182
183
  };
183
- const globalEventEmitter = new __WEBPACK_EXTERNAL_MODULE_events__["default"]();
184
+ const globalEventEmitter = new events();
184
185
  globalEventEmitter.trigger = globalEventEmitter.emit;
185
186
  globalEventEmitter.toggle = globalEventEmitter.emit;
186
187
  target.lynx = {
@@ -195,6 +196,7 @@ function injectBackgroundThreadGlobals(target, polyfills) {
195
196
  }
196
197
  }),
197
198
  getCoreContext: ()=>CoreContext,
199
+ getJSContext: ()=>JsContext,
198
200
  getJSModule: (moduleName)=>{
199
201
  if ('GlobalEventEmitter' === moduleName) return globalEventEmitter;
200
202
  throw new Error(`getJSModule(${moduleName}) not implemented`);
@@ -265,8 +267,8 @@ class LynxTestingEnv {
265
267
  _define_property(this, "backgroundThread", void 0);
266
268
  _define_property(this, "mainThread", void 0);
267
269
  _define_property(this, "jsdom", global.jsdom);
268
- this.backgroundThread = (0, __WEBPACK_EXTERNAL_MODULE__lynx_GlobalThis_js_9774bdf8__.createGlobalThis)();
269
- this.mainThread = (0, __WEBPACK_EXTERNAL_MODULE__lynx_GlobalThis_js_9774bdf8__.createGlobalThis)();
270
+ this.backgroundThread = createGlobalThis();
271
+ this.mainThread = createGlobalThis();
270
272
  const globalPolyfills = {
271
273
  console: this.jsdom.window['console'],
272
274
  Event: this.jsdom.window.Event,
@@ -279,5 +281,4 @@ class LynxTestingEnv {
279
281
  this.switchToBackgroundThread();
280
282
  }
281
283
  }
282
- var __webpack_exports__initElementTree = __WEBPACK_EXTERNAL_MODULE__lynx_ElementPAPI_js_053942f3__.initElementTree;
283
- export { LynxTestingEnv, __webpack_exports__initElementTree as initElementTree };
284
+ export { LynxTestingEnv, initElementTree };
@@ -156,7 +156,7 @@ const initElementTree = ()=>{
156
156
  e.id = id;
157
157
  }
158
158
  __SetInlineStyles(e, styles) {
159
- if ('string' == typeof styles) e.style.cssText = styles;
159
+ if ('string' == typeof styles) e.setAttributeNS(null, 'style', styles);
160
160
  else Object.assign(e.style, styles);
161
161
  }
162
162
  __AddDataset(e, key, value) {
@@ -178,9 +178,12 @@ const initElementTree = ()=>{
178
178
  }
179
179
  __RemoveElement(parent, child) {
180
180
  let ch = parent.firstChild;
181
- while(ch)if (ch === child) {
182
- parent.removeChild(ch);
183
- break;
181
+ while(ch){
182
+ if (ch === child) {
183
+ parent.removeChild(ch);
184
+ break;
185
+ }
186
+ ch = ch.nextSibling;
184
187
  }
185
188
  }
186
189
  __InsertElementBefore(parent, child, ref) {
@@ -128,7 +128,7 @@ const initElementTree = ()=>{
128
128
  e.id = id;
129
129
  }
130
130
  __SetInlineStyles(e, styles) {
131
- if ('string' == typeof styles) e.style.cssText = styles;
131
+ if ('string' == typeof styles) e.setAttributeNS(null, 'style', styles);
132
132
  else Object.assign(e.style, styles);
133
133
  }
134
134
  __AddDataset(e, key, value) {
@@ -150,9 +150,12 @@ const initElementTree = ()=>{
150
150
  }
151
151
  __RemoveElement(parent, child) {
152
152
  let ch = parent.firstChild;
153
- while(ch)if (ch === child) {
154
- parent.removeChild(ch);
155
- break;
153
+ while(ch){
154
+ if (ch === child) {
155
+ parent.removeChild(ch);
156
+ break;
157
+ }
158
+ ch = ch.nextSibling;
156
159
  }
157
160
  }
158
161
  __InsertElementBefore(parent, child, ref) {
@@ -1,6 +1,6 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE__util_js_1dab4bad__ from "../util.js";
1
+ import { define as external_util_js_define } from "../util.js";
2
2
  function installOwnProperties(globalThis) {
3
- (0, __WEBPACK_EXTERNAL_MODULE__util_js_1dab4bad__.define)(globalThis, {
3
+ external_util_js_define(globalThis, {
4
4
  get globalThis () {
5
5
  return globalThis._globalProxy;
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/testing-environment",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A subset of a Lynx environment to be useful for testing",
5
5
  "keywords": [
6
6
  "Lynx",
@@ -48,7 +48,7 @@
48
48
  "devDependencies": {
49
49
  "@testing-library/jest-dom": "^6.6.3",
50
50
  "@types/jsdom": "^21.1.7",
51
- "rsbuild-plugin-publint": "0.3.1"
51
+ "rsbuild-plugin-publint": "0.3.2"
52
52
  },
53
53
  "scripts": {
54
54
  "api-extractor": "api-extractor run --verbose",