@lynx-js/testing-environment 0.1.0

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/dist/index.js ADDED
@@ -0,0 +1,283 @@
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";
4
+ function _define_property(obj, key, value) {
5
+ if (key in obj) Object.defineProperty(obj, key, {
6
+ value: value,
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true
10
+ });
11
+ else obj[key] = value;
12
+ return obj;
13
+ }
14
+ function __injectElementApi(target) {
15
+ const elementTree = (0, __WEBPACK_EXTERNAL_MODULE__lynx_ElementPAPI_js_053942f3__.initElementTree)();
16
+ target.elementTree = elementTree;
17
+ if (void 0 === target) target = globalThis;
18
+ for (const k of Object.getOwnPropertyNames(elementTree.constructor.prototype))if (k.startsWith('__')) target[k] = elementTree[k].bind(elementTree);
19
+ target.$kTemplateAssembler = {};
20
+ target.registerDataProcessor = ()=>{
21
+ console.error('registerDataProcessor is not implemented');
22
+ };
23
+ target.__OnLifecycleEvent = (...args)=>{
24
+ const isMainThread = __MAIN_THREAD__;
25
+ globalThis.lynxTestingEnv.switchToBackgroundThread();
26
+ globalThis.lynxCoreInject.tt.OnLifecycleEvent(...args);
27
+ if (isMainThread) globalThis.lynxTestingEnv.switchToMainThread();
28
+ };
29
+ target._ReportError = ()=>{};
30
+ }
31
+ function createPolyfills() {
32
+ const app = {
33
+ callLepusMethod: (...rLynxChange)=>{
34
+ const isBackground = !__MAIN_THREAD__;
35
+ globalThis.lynxTestingEnv.switchToMainThread();
36
+ globalThis[rLynxChange[0]](rLynxChange[1]);
37
+ globalThis.lynxTestingEnv.switchToBackgroundThread();
38
+ rLynxChange[2]();
39
+ globalThis.lynxTestingEnv.switchToMainThread();
40
+ if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
41
+ },
42
+ markTiming: ()=>{},
43
+ createJSObjectDestructionObserver: ()=>({})
44
+ };
45
+ const performance = {
46
+ __functionCallHistory: [],
47
+ _generatePipelineOptions: ()=>{
48
+ performance.__functionCallHistory.push([
49
+ '_generatePipelineOptions'
50
+ ]);
51
+ return {
52
+ pipelineID: 'pipelineID',
53
+ needTimestamps: false
54
+ };
55
+ },
56
+ _onPipelineStart: (id)=>{
57
+ performance.__functionCallHistory.push([
58
+ '_onPipelineStart',
59
+ id
60
+ ]);
61
+ },
62
+ _markTiming: (id, key)=>{
63
+ performance.__functionCallHistory.push([
64
+ '_markTiming',
65
+ id,
66
+ key
67
+ ]);
68
+ },
69
+ _bindPipelineIdWithTimingFlag: (id, flag)=>{
70
+ performance.__functionCallHistory.push([
71
+ '_bindPipelineIdWithTimingFlag',
72
+ id,
73
+ flag
74
+ ]);
75
+ }
76
+ };
77
+ const ee = new __WEBPACK_EXTERNAL_MODULE_events__["default"]();
78
+ ee.dispatchEvent = ({ type, data })=>{
79
+ const isMainThread = __MAIN_THREAD__;
80
+ lynxTestingEnv.switchToBackgroundThread();
81
+ ee.emit(type, {
82
+ data: data
83
+ });
84
+ if (isMainThread) lynxTestingEnv.switchToMainThread();
85
+ };
86
+ ee.addEventListener = ee.addListener;
87
+ ee.removeEventListener = ee.removeListener;
88
+ const CoreContext = ee;
89
+ const JsContext = ee;
90
+ function __LoadLepusChunk(chunkName, options) {
91
+ const isBackground = !__MAIN_THREAD__;
92
+ globalThis.lynxTestingEnv.switchToMainThread();
93
+ if (process.env['DEBUG']) console.log('__LoadLepusChunk', chunkName, options);
94
+ let ans;
95
+ if ('worklet-runtime' === chunkName) {
96
+ var _globalThis_onInitWorkletRuntime, _globalThis;
97
+ ans = null == (_globalThis_onInitWorkletRuntime = (_globalThis = globalThis).onInitWorkletRuntime) ? void 0 : _globalThis_onInitWorkletRuntime.call(_globalThis);
98
+ } else throw new Error(`__LoadLepusChunk: Unknown chunk name: ${chunkName}`);
99
+ if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
100
+ return ans;
101
+ }
102
+ return {
103
+ app,
104
+ performance,
105
+ CoreContext,
106
+ JsContext,
107
+ __LoadLepusChunk
108
+ };
109
+ }
110
+ function injectMainThreadGlobals(target, polyfills) {
111
+ var _globalThis_onInjectMainThreadGlobals, _globalThis;
112
+ __injectElementApi(target);
113
+ const { performance, JsContext, __LoadLepusChunk } = polyfills || {};
114
+ if (void 0 === target) target = globalThis;
115
+ target.__DEV__ = true;
116
+ target.__PROFILE__ = true;
117
+ target.__JS__ = false;
118
+ target.__LEPUS__ = true;
119
+ target.__BACKGROUND__ = false;
120
+ target.__MAIN_THREAD__ = true;
121
+ target.__REF_FIRE_IMMEDIATELY__ = false;
122
+ target.__FIRST_SCREEN_SYNC_TIMING__ = 'immediately';
123
+ target.__TESTING_FORCE_RENDER_TO_OPCODE__ = false;
124
+ target.__ENABLE_SSR__ = false;
125
+ target.globDynamicComponentEntry = '__Card__';
126
+ target.lynx = {
127
+ performance,
128
+ getJSContext: ()=>JsContext,
129
+ reportError: (e)=>{
130
+ throw e;
131
+ }
132
+ };
133
+ target.requestAnimationFrame = setTimeout;
134
+ target.cancelAnimationFrame = clearTimeout;
135
+ target.console.profile = ()=>{};
136
+ target.console.profileEnd = ()=>{};
137
+ target.__LoadLepusChunk = __LoadLepusChunk;
138
+ null == (_globalThis_onInjectMainThreadGlobals = (_globalThis = globalThis).onInjectMainThreadGlobals) || _globalThis_onInjectMainThreadGlobals.call(_globalThis, target);
139
+ }
140
+ const IGNORE_LIST_GLOBALS = [
141
+ 'globalThis',
142
+ 'global'
143
+ ];
144
+ class NodesRef {
145
+ invoke() {
146
+ throw new Error('not implemented');
147
+ }
148
+ path() {
149
+ throw new Error('not implemented');
150
+ }
151
+ fields() {
152
+ throw new Error('not implemented');
153
+ }
154
+ setNativeProps() {
155
+ throw new Error('not implemented');
156
+ }
157
+ constructor(selectorQuery, nodeSelectToken){
158
+ _define_property(this, "_nodeSelectToken", void 0);
159
+ _define_property(this, "_selectorQuery", void 0);
160
+ this._nodeSelectToken = nodeSelectToken;
161
+ this._selectorQuery = selectorQuery;
162
+ }
163
+ }
164
+ function injectBackgroundThreadGlobals(target, polyfills) {
165
+ var _globalThis_onInjectBackgroundThreadGlobals, _globalThis;
166
+ const { app, performance, CoreContext, __LoadLepusChunk } = polyfills || {};
167
+ if (void 0 === target) target = globalThis;
168
+ target.__DEV__ = true;
169
+ target.__PROFILE__ = true;
170
+ target.__JS__ = true;
171
+ target.__LEPUS__ = false;
172
+ target.__BACKGROUND__ = true;
173
+ target.__MAIN_THREAD__ = false;
174
+ target.__ENABLE_SSR__ = false;
175
+ target.globDynamicComponentEntry = '__Card__';
176
+ target.lynxCoreInject = {};
177
+ target.lynxCoreInject.tt = {
178
+ _params: {
179
+ initData: {},
180
+ updateData: {}
181
+ }
182
+ };
183
+ const globalEventEmitter = new __WEBPACK_EXTERNAL_MODULE_events__["default"]();
184
+ globalEventEmitter.trigger = globalEventEmitter.emit;
185
+ globalEventEmitter.toggle = globalEventEmitter.emit;
186
+ target.lynx = {
187
+ getNativeApp: ()=>app,
188
+ performance,
189
+ createSelectorQuery: ()=>({
190
+ selectUniqueID: function(uniqueId) {
191
+ return new NodesRef({}, {
192
+ type: 2,
193
+ identifier: uniqueId.toString()
194
+ });
195
+ }
196
+ }),
197
+ getCoreContext: ()=>CoreContext,
198
+ getJSModule: (moduleName)=>{
199
+ if ('GlobalEventEmitter' === moduleName) return globalEventEmitter;
200
+ throw new Error(`getJSModule(${moduleName}) not implemented`);
201
+ },
202
+ reportError: (e)=>{
203
+ throw e;
204
+ }
205
+ };
206
+ target.requestAnimationFrame = setTimeout;
207
+ target.cancelAnimationFrame = clearTimeout;
208
+ target.console.profile = ()=>{};
209
+ target.console.profileEnd = ()=>{};
210
+ target.SystemInfo = {
211
+ platform: 'iOS',
212
+ pixelRatio: 3,
213
+ pixelWidth: 1170,
214
+ pixelHeight: 2532,
215
+ osVersion: '17.0.2',
216
+ enableKrypton: true,
217
+ runtimeType: 'quickjs',
218
+ lynxSdkVersion: '3.0'
219
+ };
220
+ target.__LoadLepusChunk = __LoadLepusChunk;
221
+ null == (_globalThis_onInjectBackgroundThreadGlobals = (_globalThis = globalThis).onInjectBackgroundThreadGlobals) || _globalThis_onInjectBackgroundThreadGlobals.call(_globalThis, target);
222
+ }
223
+ class LynxTestingEnv {
224
+ injectGlobals() {
225
+ const polyfills = createPolyfills();
226
+ injectBackgroundThreadGlobals(this.backgroundThread.globalThis, polyfills);
227
+ injectMainThreadGlobals(this.mainThread.globalThis, polyfills);
228
+ }
229
+ switchToBackgroundThread() {
230
+ var _globalThis_onSwitchedToBackgroundThread, _globalThis;
231
+ this.originals = new Map();
232
+ Object.getOwnPropertyNames(this.backgroundThread.globalThis).forEach((key)=>{
233
+ if (IGNORE_LIST_GLOBALS.includes(key)) return;
234
+ this.originals.set(key, global[key]);
235
+ global[key] = this.backgroundThread.globalThis[key];
236
+ });
237
+ null == (_globalThis = globalThis) || null == (_globalThis_onSwitchedToBackgroundThread = _globalThis.onSwitchedToBackgroundThread) || _globalThis_onSwitchedToBackgroundThread.call(_globalThis);
238
+ }
239
+ switchToMainThread() {
240
+ var _globalThis_onSwitchedToMainThread, _globalThis;
241
+ this.originals = new Map();
242
+ Object.getOwnPropertyNames(this.mainThread.globalThis).forEach((key)=>{
243
+ if (IGNORE_LIST_GLOBALS.includes(key)) return;
244
+ this.originals.set(key, global[key]);
245
+ global[key] = this.mainThread.globalThis[key];
246
+ });
247
+ null == (_globalThis = globalThis) || null == (_globalThis_onSwitchedToMainThread = _globalThis.onSwitchedToMainThread) || _globalThis_onSwitchedToMainThread.call(_globalThis);
248
+ }
249
+ clearGlobal() {
250
+ var _this_originals, _this_originals1;
251
+ null == (_this_originals = this.originals) || _this_originals.forEach((v, k)=>{
252
+ global[k] = v;
253
+ });
254
+ null == (_this_originals1 = this.originals) || _this_originals1.clear();
255
+ }
256
+ reset() {
257
+ var _globalThis_onResetLynxTestingEnv, _globalThis;
258
+ this.injectGlobals();
259
+ this.switchToMainThread();
260
+ this.switchToBackgroundThread();
261
+ null == (_globalThis_onResetLynxTestingEnv = (_globalThis = globalThis).onResetLynxTestingEnv) || _globalThis_onResetLynxTestingEnv.call(_globalThis);
262
+ }
263
+ constructor(){
264
+ _define_property(this, "originals", new Map());
265
+ _define_property(this, "backgroundThread", void 0);
266
+ _define_property(this, "mainThread", void 0);
267
+ _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
+ const globalPolyfills = {
271
+ console: this.jsdom.window['console'],
272
+ Event: this.jsdom.window.Event,
273
+ window: this.jsdom.window,
274
+ document: this.jsdom.window.document
275
+ };
276
+ Object.assign(this.mainThread.globalThis, globalPolyfills);
277
+ Object.assign(this.backgroundThread.globalThis, globalPolyfills);
278
+ this.injectGlobals();
279
+ this.switchToBackgroundThread();
280
+ }
281
+ }
282
+ var __webpack_exports__initElementTree = __WEBPACK_EXTERNAL_MODULE__lynx_ElementPAPI_js_053942f3__.initElementTree;
283
+ export { LynxTestingEnv, __webpack_exports__initElementTree as initElementTree };
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ initElementTree: ()=>initElementTree
28
+ });
29
+ function _define_property(obj, key, value) {
30
+ if (key in obj) Object.defineProperty(obj, key, {
31
+ value: value,
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true
35
+ });
36
+ else obj[key] = value;
37
+ return obj;
38
+ }
39
+ const initElementTree = ()=>{
40
+ let uiSignNext = 0;
41
+ const uniqueId2Element = new Map();
42
+ return new class {
43
+ countElement(element, parentComponentUniqueId) {
44
+ element.$$uiSign = uiSignNext++;
45
+ uniqueId2Element.set(element.$$uiSign, element);
46
+ element.parentComponentUniqueId = parentComponentUniqueId;
47
+ }
48
+ __CreatePage(_tag, parentComponentUniqueId) {
49
+ const page = this.__CreateElement('page', parentComponentUniqueId);
50
+ this.root = page;
51
+ lynxTestingEnv.jsdom.window.document.body.appendChild(page);
52
+ return page;
53
+ }
54
+ __CreateRawText(text) {
55
+ const element = lynxTestingEnv.jsdom.window.document.createTextNode(text);
56
+ this.countElement(element, 0);
57
+ return element;
58
+ }
59
+ __GetElementUniqueID(e) {
60
+ return e.$$uiSign;
61
+ }
62
+ __SetClasses(e, cls) {
63
+ e.className = cls;
64
+ }
65
+ __CreateElement(tag, parentComponentUniqueId) {
66
+ if ('raw-text' === tag) return this.__CreateRawText('');
67
+ const element = lynxTestingEnv.jsdom.window.document.createElement(tag);
68
+ this.countElement(element, parentComponentUniqueId);
69
+ return element;
70
+ }
71
+ __CreateView(parentComponentUniqueId) {
72
+ return this.__CreateElement('view', parentComponentUniqueId);
73
+ }
74
+ __CreateScrollView(parentComponentUniqueId) {
75
+ return this.__CreateElement('scroll-view', parentComponentUniqueId);
76
+ }
77
+ __FirstElement(e) {
78
+ return e.firstChild;
79
+ }
80
+ __CreateText(parentComponentUniqueId) {
81
+ return this.__CreateElement('text', parentComponentUniqueId);
82
+ }
83
+ __CreateImage(parentComponentUniqueId) {
84
+ return this.__CreateElement('image', parentComponentUniqueId);
85
+ }
86
+ __CreateWrapperElement(parentComponentUniqueId) {
87
+ return this.__CreateElement('wrapper', parentComponentUniqueId);
88
+ }
89
+ __AddInlineStyle(e, key, value) {
90
+ e.style[key] = value;
91
+ }
92
+ __AppendElement(parent, child) {
93
+ parent.appendChild(child);
94
+ }
95
+ __SetCSSId(e, id, entryName) {
96
+ const cssId = `${entryName ?? '__Card__'}:${id}`;
97
+ if (Array.isArray(e)) e.forEach((item)=>{
98
+ item.cssId = cssId;
99
+ });
100
+ else e.cssId = cssId;
101
+ }
102
+ __SetAttribute(e, key, value) {
103
+ if ('style' === key || 'class' === key || 'className' === key || 'key' === key || 'id' === key || 'ref' === key || /^data-/.exec(key) || /^(bind|catch|global-bind|capture-bind|capture-catch)[A-Za-z]/.exec(key)) throw new Error(`Cannot use __SetAttribute for "${key}"`);
104
+ if ('update-list-info' === key) {
105
+ let listInfoStr = e.getAttribute(key);
106
+ let listInfo = listInfoStr ? JSON.parse(listInfoStr) : [];
107
+ listInfo.push(value);
108
+ e.setAttribute(key, JSON.stringify(listInfo));
109
+ return;
110
+ }
111
+ if ('text' === key) {
112
+ e.textContent = value;
113
+ return;
114
+ }
115
+ if (null === value) return void e.removeAttribute(key);
116
+ if ('string' == typeof value) return void e.setAttribute(key, value);
117
+ e.setAttribute(key, JSON.stringify(value));
118
+ }
119
+ __AddEvent(e, eventType, eventName, eventHandler) {
120
+ var _e_eventMap;
121
+ if (null == (_e_eventMap = e.eventMap) ? void 0 : _e_eventMap[`${eventType}:${eventName}`]) {
122
+ e.removeEventListener(`${eventType}:${eventName}`, e.eventMap[`${eventType}:${eventName}`]);
123
+ delete e.eventMap[`${eventType}:${eventName}`];
124
+ }
125
+ if (void 0 === eventHandler) return;
126
+ if ('string' != typeof eventHandler && void 0 === eventHandler['type']) throw new Error(`event must be string, but got ${typeof eventHandler}`);
127
+ const listener = (evt)=>{
128
+ if ('object' == typeof eventHandler && 'worklet' === eventHandler['type']) {
129
+ const isBackground = !__MAIN_THREAD__;
130
+ globalThis.lynxTestingEnv.switchToMainThread();
131
+ runWorklet(eventHandler.value, [
132
+ Object.assign({}, evt)
133
+ ]);
134
+ if (isBackground) globalThis.lynxTestingEnv.switchToBackgroundThread();
135
+ } else {
136
+ if ('catchEvent' === eventType || 'capture-catch' === eventType) evt.stopPropagation();
137
+ globalThis.lynxCoreInject.tt.publishEvent(eventHandler, evt);
138
+ }
139
+ };
140
+ e.eventMap = e.eventMap ?? {};
141
+ e.eventMap[`${eventType}:${eventName}`] = listener;
142
+ e.addEventListener(`${eventType}:${eventName}`, listener, {
143
+ capture: 'capture-bind' === eventType || 'capture-catch' === eventType
144
+ });
145
+ }
146
+ __GetEvent(e, eventType, eventName) {
147
+ var _e_eventMap;
148
+ const jsFunction = null == (_e_eventMap = e.eventMap) ? void 0 : _e_eventMap[`${eventType}:${eventName}`];
149
+ if (void 0 !== jsFunction) return {
150
+ type: eventType,
151
+ name: eventName,
152
+ jsFunction
153
+ };
154
+ }
155
+ __SetID(e, id) {
156
+ e.id = id;
157
+ }
158
+ __SetInlineStyles(e, styles) {
159
+ if ('string' == typeof styles) e.style.cssText = styles;
160
+ else Object.assign(e.style, styles);
161
+ }
162
+ __AddDataset(e, key, value) {
163
+ e.dataset[key] = value;
164
+ }
165
+ __SetDataset(e, dataset) {
166
+ Object.assign(e.dataset, dataset);
167
+ }
168
+ __SetGestureDetector(e, id, type, config, relationMap) {
169
+ e.gesture = {
170
+ id,
171
+ type,
172
+ config,
173
+ relationMap
174
+ };
175
+ }
176
+ __GetDataset(e) {
177
+ return e.dataset;
178
+ }
179
+ __RemoveElement(parent, child) {
180
+ let ch = parent.firstChild;
181
+ while(ch)if (ch === child) {
182
+ parent.removeChild(ch);
183
+ break;
184
+ }
185
+ }
186
+ __InsertElementBefore(parent, child, ref) {
187
+ if (void 0 === ref) parent.appendChild(child);
188
+ else parent.insertBefore(child, ref);
189
+ }
190
+ __ReplaceElement(newElement, oldElement) {
191
+ const parent = oldElement.parentNode;
192
+ if (!parent) throw new Error('unreachable');
193
+ parent.replaceChild(newElement, oldElement);
194
+ }
195
+ __FlushElementTree() {}
196
+ __UpdateListComponents(_list, _components) {}
197
+ __UpdateListCallbacks(list, componentAtIndex, enqueueComponent) {
198
+ Object.defineProperties(list, {
199
+ componentAtIndex: {
200
+ enumerable: false,
201
+ configurable: true,
202
+ value: componentAtIndex
203
+ },
204
+ enqueueComponent: {
205
+ enumerable: false,
206
+ configurable: true,
207
+ value: enqueueComponent
208
+ }
209
+ });
210
+ }
211
+ __CreateList(parentComponentUniqueId, componentAtIndex, enqueueComponent) {
212
+ const e = this.__CreateElement('list', parentComponentUniqueId);
213
+ Object.defineProperties(e, {
214
+ componentAtIndex: {
215
+ enumerable: false,
216
+ configurable: true,
217
+ value: componentAtIndex
218
+ },
219
+ enqueueComponent: {
220
+ enumerable: false,
221
+ configurable: true,
222
+ value: enqueueComponent
223
+ }
224
+ });
225
+ return e;
226
+ }
227
+ __GetTag(ele) {
228
+ return ele.nodeName;
229
+ }
230
+ __GetAttributeByName(ele, name) {
231
+ return ele.getAttribute(name);
232
+ }
233
+ clear() {
234
+ this.root = void 0;
235
+ }
236
+ toTree() {
237
+ return this.root;
238
+ }
239
+ enterListItemAtIndex(e, index, ...args) {
240
+ const { componentAtIndex, $$uiSign } = e;
241
+ return componentAtIndex(e, $$uiSign, index, ...args);
242
+ }
243
+ leaveListItem(e, uiSign) {
244
+ const { enqueueComponent, $$uiSign } = e;
245
+ enqueueComponent(e, $$uiSign, uiSign);
246
+ }
247
+ toJSON() {
248
+ return this.toTree();
249
+ }
250
+ __GetElementByUniqueId(uniqueId) {
251
+ return uniqueId2Element.get(uniqueId);
252
+ }
253
+ constructor(){
254
+ _define_property(this, "root", void 0);
255
+ }
256
+ }();
257
+ };
258
+ exports.initElementTree = __webpack_exports__.initElementTree;
259
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
260
+ "initElementTree"
261
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
262
+ Object.defineProperty(exports, '__esModule', {
263
+ value: true
264
+ });
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Any Lynx Element, such as `view`, `text`, `image`, etc.
3
+ *
4
+ * {@link https://lynxjs.org/living-spec/index.html?ts=1743416098203#element%E2%91%A0 | Lynx Spec Reference}
5
+ *
6
+ * @public
7
+ */
8
+ export interface LynxElement extends HTMLElement {
9
+ /**
10
+ * The map of events bound to the element.
11
+ */
12
+ eventMap?: {
13
+ [key: string]: any;
14
+ };
15
+ /**
16
+ * The gestures bound to the element.
17
+ */
18
+ gesture?: {
19
+ [key: string]: any;
20
+ };
21
+ /**
22
+ * The cssId of the element
23
+ */
24
+ cssId?: string;
25
+ /**
26
+ * Returns the first child.
27
+ *
28
+ * {@link https://developer.mozilla.org/docs/Web/API/Node/firstChild | MDN Reference}
29
+ */
30
+ firstChild: LynxElement;
31
+ /**
32
+ * Returns the next sibling.
33
+ *
34
+ * {@link https://developer.mozilla.org/docs/Web/API/Node/nextSibling | MDN Reference}
35
+ */
36
+ nextSibling: LynxElement;
37
+ /**
38
+ * Returns the parent.
39
+ *
40
+ * {@link https://developer.mozilla.org/docs/Web/API/Node/parentNode | MDN Reference}
41
+ */
42
+ parentNode: LynxElement;
43
+ }
44
+ /**
45
+ * @public
46
+ */
47
+ export declare const initElementTree: () => {
48
+ root: LynxElement | undefined;
49
+ countElement(element: LynxElement, parentComponentUniqueId: number): void;
50
+ __CreatePage(_tag: string, parentComponentUniqueId: number): LynxElement;
51
+ __CreateRawText(text: string): LynxElement;
52
+ __GetElementUniqueID(e: LynxElement): number;
53
+ __SetClasses(e: LynxElement, cls: string): void;
54
+ __CreateElement(tag: string, parentComponentUniqueId: number): LynxElement;
55
+ __CreateView(parentComponentUniqueId: number): LynxElement;
56
+ __CreateScrollView(parentComponentUniqueId: number): LynxElement;
57
+ __FirstElement(e: LynxElement): LynxElement;
58
+ __CreateText(parentComponentUniqueId: number): LynxElement;
59
+ __CreateImage(parentComponentUniqueId: number): LynxElement;
60
+ __CreateWrapperElement(parentComponentUniqueId: number): LynxElement;
61
+ __AddInlineStyle(e: HTMLElement, key: number, value: string): void;
62
+ __AppendElement(parent: LynxElement, child: LynxElement): void;
63
+ __SetCSSId(e: LynxElement | LynxElement[], id: string, entryName?: string): void;
64
+ __SetAttribute(e: LynxElement, key: string, value: any): void;
65
+ __AddEvent(e: LynxElement, eventType: string, eventName: string, eventHandler: string | Record<string, any>): void;
66
+ __GetEvent(e: LynxElement, eventType: string, eventName: string): {
67
+ type: string;
68
+ name: string;
69
+ jsFunction: any;
70
+ } | undefined;
71
+ __SetID(e: LynxElement, id: string): void;
72
+ __SetInlineStyles(e: LynxElement, styles: string | Record<string, string>): void;
73
+ __AddDataset(e: LynxElement, key: string, value: string): void;
74
+ __SetDataset(e: LynxElement, dataset: any): void;
75
+ __SetGestureDetector(e: LynxElement, id: number, type: number, config: any, relationMap: Record<string, number[]>): void;
76
+ __GetDataset(e: LynxElement): DOMStringMap;
77
+ __RemoveElement(parent: LynxElement, child: LynxElement): void;
78
+ __InsertElementBefore(parent: LynxElement, child: LynxElement, ref?: LynxElement): void;
79
+ __ReplaceElement(newElement: LynxElement, oldElement: LynxElement): void;
80
+ __FlushElementTree(): void;
81
+ __UpdateListComponents(_list: LynxElement, _components: string[]): void;
82
+ __UpdateListCallbacks(list: LynxElement, componentAtIndex: (list: LynxElement, listID: number, cellIndex: number, operationID: number, enable_reuse_notification: boolean) => void, enqueueComponent: (list: LynxElement, listID: number, sign: number) => void): void;
83
+ __CreateList(parentComponentUniqueId: number, componentAtIndex: any, enqueueComponent: any): LynxElement;
84
+ __GetTag(ele: LynxElement): string;
85
+ __GetAttributeByName(ele: LynxElement, name: string): string | null;
86
+ clear(): void;
87
+ toTree(): LynxElement | undefined;
88
+ /**
89
+ * Enter a list-item element at the given index.
90
+ * It will load the list-item element using the `componentAtIndex` callback.
91
+ *
92
+ * @param e - The list element
93
+ * @param index - The index of the list-item element
94
+ * @param args - The arguments used to create the list-item element
95
+ * @returns The unique id of the list-item element
96
+ */
97
+ enterListItemAtIndex(e: LynxElement, index: number, ...args: any[]): number;
98
+ /**
99
+ * Leave a list-item element.
100
+ * It will mark the list-item element as unused using
101
+ * the `enqueueComponent` callback, and the list-item element
102
+ * will be reused in the future by other list-item elements.
103
+ *
104
+ * @param e - The list element
105
+ * @param uiSign - The unique id of the list-item element
106
+ */
107
+ leaveListItem(e: LynxElement, uiSign: number): void;
108
+ toJSON(): LynxElement | undefined;
109
+ __GetElementByUniqueId(uniqueId: number): LynxElement | undefined;
110
+ };