@rpascene/shared 0.30.8 → 0.30.9

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.
Files changed (56) hide show
  1. package/README.md +2 -2
  2. package/dist/es/common.mjs +9 -9
  3. package/dist/es/constants/example-code.mjs +10 -10
  4. package/dist/es/constants/index.mjs +1 -1
  5. package/dist/es/env/constants.mjs +77 -77
  6. package/dist/es/env/global-config-manager.mjs +1 -1
  7. package/dist/es/env/init-debug.mjs +5 -5
  8. package/dist/es/env/model-config-manager.mjs +1 -1
  9. package/dist/es/env/parse.mjs +11 -11
  10. package/dist/es/env/types.mjs +191 -191
  11. package/dist/es/env/utils.mjs +2 -2
  12. package/dist/es/extractor/debug.mjs +2 -2
  13. package/dist/es/extractor/util.mjs +11 -11
  14. package/dist/es/extractor/web-extractor.mjs +7 -7
  15. package/dist/es/logger.mjs +3 -3
  16. package/dist/es/node/fs.mjs +6 -6
  17. package/dist/es/utils.mjs +2 -2
  18. package/dist/lib/common.js +16 -16
  19. package/dist/lib/constants/example-code.js +10 -10
  20. package/dist/lib/constants/index.js +1 -1
  21. package/dist/lib/env/constants.js +76 -76
  22. package/dist/lib/env/global-config-manager.js +1 -1
  23. package/dist/lib/env/init-debug.js +4 -4
  24. package/dist/lib/env/model-config-manager.js +1 -1
  25. package/dist/lib/env/parse.js +10 -10
  26. package/dist/lib/env/types.js +478 -478
  27. package/dist/lib/env/utils.js +1 -1
  28. package/dist/lib/extractor/debug.js +1 -1
  29. package/dist/lib/extractor/util.js +16 -16
  30. package/dist/lib/extractor/web-extractor.js +6 -6
  31. package/dist/lib/logger.js +2 -2
  32. package/dist/lib/node/fs.js +6 -6
  33. package/dist/lib/utils.js +2 -2
  34. package/dist/types/common.d.ts +5 -5
  35. package/dist/types/constants/example-code.d.ts +2 -2
  36. package/dist/types/env/types.d.ts +180 -180
  37. package/dist/types/extractor/util.d.ts +2 -2
  38. package/dist/types/node/fs.d.ts +1 -1
  39. package/package.json +8 -3
  40. package/src/common.ts +10 -10
  41. package/src/constants/example-code.ts +10 -10
  42. package/src/constants/index.ts +1 -1
  43. package/src/env/constants.ts +144 -144
  44. package/src/env/decide-model-config.ts +1 -1
  45. package/src/env/global-config-manager.ts +1 -1
  46. package/src/env/init-debug.ts +5 -5
  47. package/src/env/model-config-manager.ts +1 -1
  48. package/src/env/parse.ts +15 -15
  49. package/src/env/types.ts +315 -315
  50. package/src/env/utils.ts +2 -2
  51. package/src/extractor/debug.ts +2 -2
  52. package/src/extractor/util.ts +15 -15
  53. package/src/extractor/web-extractor.ts +7 -7
  54. package/src/logger.ts +3 -3
  55. package/src/node/fs.ts +5 -5
  56. package/src/utils.ts +2 -2
@@ -37,7 +37,7 @@ const globalConfigManager = new external_global_config_manager_js_namespaceObjec
37
37
  globalConfigManager.registerModelConfigManager(globalModelConfigManager);
38
38
  globalModelConfigManager.registerGlobalConfigManager(globalConfigManager);
39
39
  const getPreferredLanguage = ()=>{
40
- const prefer = globalConfigManager.getEnvConfigValue(external_types_js_namespaceObject.RPASCENE_PREFERRED_LANGUAGE);
40
+ const prefer = globalConfigManager.getEnvConfigValue(external_types_js_namespaceObject.MIDSCENE_PREFERRED_LANGUAGE);
41
41
  if (prefer) return prefer;
42
42
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
43
43
  const isChina = 'Asia/Shanghai' === timeZone;
@@ -5,7 +5,7 @@ const external_util_js_namespaceObject = require("./util.js");
5
5
  console.log((0, external_index_js_namespaceObject.webExtractTextWithPosition)(document.body, true));
6
6
  console.log(JSON.stringify((0, external_index_js_namespaceObject.webExtractTextWithPosition)(document.body, true)));
7
7
  (0, external_util_js_namespaceObject.setExtractTextWithPositionOnWindow)();
8
- (0, external_util_js_namespaceObject.setRpasceneVisibleRectOnWindow)();
8
+ (0, external_util_js_namespaceObject.setMidsceneVisibleRectOnWindow)();
9
9
  for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
10
10
  Object.defineProperty(exports, '__esModule', {
11
11
  value: true
@@ -24,13 +24,14 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
+ midsceneGenerateHash: ()=>midsceneGenerateHash,
27
28
  validTextNodeContent: ()=>validTextNodeContent,
28
29
  setNodeHashCacheListOnWindow: ()=>setNodeHashCacheListOnWindow,
29
30
  overlappedRect: ()=>overlappedRect,
30
31
  isElementPartiallyInViewport: ()=>isElementPartiallyInViewport,
31
32
  elementRect: ()=>elementRect,
32
33
  getTopDocument: ()=>getTopDocument,
33
- rpasceneGenerateHash: ()=>rpasceneGenerateHash,
34
+ setMidsceneVisibleRectOnWindow: ()=>setMidsceneVisibleRectOnWindow,
34
35
  getNodeFromCacheList: ()=>getNodeFromCacheList,
35
36
  getNodeAttributes: ()=>getNodeAttributes,
36
37
  generateId: ()=>generateId,
@@ -42,7 +43,6 @@ __webpack_require__.d(__webpack_exports__, {
42
43
  getRect: ()=>getRect,
43
44
  setDebugMode: ()=>setDebugMode,
44
45
  setExtractTextWithPositionOnWindow: ()=>setExtractTextWithPositionOnWindow,
45
- setRpasceneVisibleRectOnWindow: ()=>setRpasceneVisibleRectOnWindow,
46
46
  setGenerateHashOnWindow: ()=>setGenerateHashOnWindow
47
47
  });
48
48
  const external_utils_js_namespaceObject = require("../utils.js");
@@ -244,22 +244,22 @@ function getNodeAttributes(node, currentWindow) {
244
244
  });
245
245
  return Object.fromEntries(attributesList);
246
246
  }
247
- function rpasceneGenerateHash(node, content, rect) {
247
+ function midsceneGenerateHash(node, content, rect) {
248
248
  const slicedHash = (0, external_utils_js_namespaceObject.generateHashId)(rect, content);
249
249
  if (node) {
250
- if (!window.rpasceneNodeHashCacheList) setNodeHashCacheListOnWindow();
250
+ if (!window.midsceneNodeHashCacheList) setNodeHashCacheListOnWindow();
251
251
  setNodeToCacheList(node, slicedHash);
252
252
  }
253
253
  return slicedHash;
254
254
  }
255
255
  function setNodeHashCacheListOnWindow() {
256
- if ('undefined' != typeof window) window.rpasceneNodeHashCacheList = [];
256
+ if ('undefined' != typeof window) window.midsceneNodeHashCacheList = [];
257
257
  }
258
258
  function setNodeToCacheList(node, id) {
259
259
  if ('undefined' != typeof window) {
260
- var _window_rpasceneNodeHashCacheList;
260
+ var _window_midsceneNodeHashCacheList;
261
261
  if (getNodeFromCacheList(id)) return;
262
- null == (_window_rpasceneNodeHashCacheList = window.rpasceneNodeHashCacheList) || _window_rpasceneNodeHashCacheList.push({
262
+ null == (_window_midsceneNodeHashCacheList = window.midsceneNodeHashCacheList) || _window_midsceneNodeHashCacheList.push({
263
263
  node,
264
264
  id
265
265
  });
@@ -267,8 +267,8 @@ function setNodeToCacheList(node, id) {
267
267
  }
268
268
  function getNodeFromCacheList(id) {
269
269
  if ('undefined' != typeof window) {
270
- var _window_rpasceneNodeHashCacheList_find, _window_rpasceneNodeHashCacheList;
271
- return null == (_window_rpasceneNodeHashCacheList = window.rpasceneNodeHashCacheList) ? void 0 : null == (_window_rpasceneNodeHashCacheList_find = _window_rpasceneNodeHashCacheList.find((item)=>item.id === id)) ? void 0 : _window_rpasceneNodeHashCacheList_find.node;
270
+ var _window_midsceneNodeHashCacheList_find, _window_midsceneNodeHashCacheList;
271
+ return null == (_window_midsceneNodeHashCacheList = window.midsceneNodeHashCacheList) ? void 0 : null == (_window_midsceneNodeHashCacheList_find = _window_midsceneNodeHashCacheList.find((item)=>item.id === id)) ? void 0 : _window_midsceneNodeHashCacheList_find.node;
272
272
  }
273
273
  return null;
274
274
  }
@@ -276,10 +276,10 @@ function generateId(numberId) {
276
276
  return `${numberId}`;
277
277
  }
278
278
  function setGenerateHashOnWindow() {
279
- if ('undefined' != typeof window) window.rpasceneGenerateHash = rpasceneGenerateHash;
279
+ if ('undefined' != typeof window) window.midsceneGenerateHash = midsceneGenerateHash;
280
280
  }
281
- function setRpasceneVisibleRectOnWindow() {
282
- if ('undefined' != typeof window) window.rpasceneVisibleRect = elementRect;
281
+ function setMidsceneVisibleRectOnWindow() {
282
+ if ('undefined' != typeof window) window.midsceneVisibleRect = elementRect;
283
283
  }
284
284
  function setExtractTextWithPositionOnWindow() {
285
285
  if ('undefined' != typeof window) window.extractTextWithPosition = external_web_extractor_js_namespaceObject.extractTextWithPosition;
@@ -299,14 +299,14 @@ exports.getTopDocument = __webpack_exports__.getTopDocument;
299
299
  exports.hasOverflowY = __webpack_exports__.hasOverflowY;
300
300
  exports.isElementPartiallyInViewport = __webpack_exports__.isElementPartiallyInViewport;
301
301
  exports.logger = __webpack_exports__.logger;
302
+ exports.midsceneGenerateHash = __webpack_exports__.midsceneGenerateHash;
302
303
  exports.overlappedRect = __webpack_exports__.overlappedRect;
303
- exports.rpasceneGenerateHash = __webpack_exports__.rpasceneGenerateHash;
304
304
  exports.setDebugMode = __webpack_exports__.setDebugMode;
305
305
  exports.setExtractTextWithPositionOnWindow = __webpack_exports__.setExtractTextWithPositionOnWindow;
306
306
  exports.setGenerateHashOnWindow = __webpack_exports__.setGenerateHashOnWindow;
307
+ exports.setMidsceneVisibleRectOnWindow = __webpack_exports__.setMidsceneVisibleRectOnWindow;
307
308
  exports.setNodeHashCacheListOnWindow = __webpack_exports__.setNodeHashCacheListOnWindow;
308
309
  exports.setNodeToCacheList = __webpack_exports__.setNodeToCacheList;
309
- exports.setRpasceneVisibleRectOnWindow = __webpack_exports__.setRpasceneVisibleRectOnWindow;
310
310
  exports.validTextNodeContent = __webpack_exports__.validTextNodeContent;
311
311
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
312
312
  "elementRect",
@@ -320,14 +320,14 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
320
320
  "hasOverflowY",
321
321
  "isElementPartiallyInViewport",
322
322
  "logger",
323
+ "midsceneGenerateHash",
323
324
  "overlappedRect",
324
- "rpasceneGenerateHash",
325
325
  "setDebugMode",
326
326
  "setExtractTextWithPositionOnWindow",
327
327
  "setGenerateHashOnWindow",
328
+ "setMidsceneVisibleRectOnWindow",
328
329
  "setNodeHashCacheListOnWindow",
329
330
  "setNodeToCacheList",
330
- "setRpasceneVisibleRectOnWindow",
331
331
  "validTextNodeContent"
332
332
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
333
333
  Object.defineProperty(exports, '__esModule', {
@@ -66,7 +66,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
66
66
  if ((0, external_dom_util_js_namespaceObject.isFormElement)(node, currentWindow)) {
67
67
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
68
68
  let valueContent = attributes.value || attributes.placeholder || node.textContent || '';
69
- const nodeHashId = (0, external_util_js_namespaceObject.rpasceneGenerateHash)(node, valueContent, rect);
69
+ const nodeHashId = (0, external_util_js_namespaceObject.midsceneGenerateHash)(node, valueContent, rect);
70
70
  const tagName = node.tagName.toLowerCase();
71
71
  if ('select' === node.tagName.toLowerCase()) {
72
72
  const selectedOption = node.options[node.selectedIndex];
@@ -100,7 +100,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
100
100
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
101
101
  const pseudo = (0, external_util_js_namespaceObject.getPseudoElementContent)(node, currentWindow);
102
102
  const content = node.innerText || pseudo.before || pseudo.after || '';
103
- const nodeHashId = (0, external_util_js_namespaceObject.rpasceneGenerateHash)(node, content, rect);
103
+ const nodeHashId = (0, external_util_js_namespaceObject.midsceneGenerateHash)(node, content, rect);
104
104
  const elementInfo = {
105
105
  id: nodeHashId,
106
106
  indexId: indexId++,
@@ -125,7 +125,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
125
125
  if ((0, external_dom_util_js_namespaceObject.isImgElement)(node, currentWindow)) {
126
126
  var _node_nodeName;
127
127
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
128
- const nodeHashId = (0, external_util_js_namespaceObject.rpasceneGenerateHash)(node, '', rect);
128
+ const nodeHashId = (0, external_util_js_namespaceObject.midsceneGenerateHash)(node, '', rect);
129
129
  const elementInfo = {
130
130
  id: nodeHashId,
131
131
  indexId: indexId++,
@@ -157,7 +157,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
157
157
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
158
158
  const attributeKeys = Object.keys(attributes);
159
159
  if (!text.trim() && 0 === attributeKeys.length) return null;
160
- const nodeHashId = (0, external_util_js_namespaceObject.rpasceneGenerateHash)(node, text, rect);
160
+ const nodeHashId = (0, external_util_js_namespaceObject.midsceneGenerateHash)(node, text, rect);
161
161
  const elementInfo = {
162
162
  id: nodeHashId,
163
163
  indexId: indexId++,
@@ -183,7 +183,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
183
183
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
184
184
  const pseudo = (0, external_util_js_namespaceObject.getPseudoElementContent)(node, currentWindow);
185
185
  const content = node.innerText || pseudo.before || pseudo.after || '';
186
- const nodeHashId = (0, external_util_js_namespaceObject.rpasceneGenerateHash)(node, content, rect);
186
+ const nodeHashId = (0, external_util_js_namespaceObject.midsceneGenerateHash)(node, content, rect);
187
187
  const elementInfo = {
188
188
  id: nodeHashId,
189
189
  indexId: indexId++,
@@ -207,7 +207,7 @@ function collectElementInfo(node, currentWindow, currentDocument, baseZoom = 1,
207
207
  }
208
208
  if ((0, external_dom_util_js_namespaceObject.isContainerElement)(node, currentWindow) || isContainer) {
209
209
  const attributes = (0, external_util_js_namespaceObject.getNodeAttributes)(node, currentWindow);
210
- const nodeHashId = (0, external_util_js_namespaceObject.rpasceneGenerateHash)(node, '', rect);
210
+ const nodeHashId = (0, external_util_js_namespaceObject.midsceneGenerateHash)(node, '', rect);
211
211
  const elementInfo = {
212
212
  id: nodeHashId,
213
213
  nodeHashId,
@@ -47,13 +47,13 @@ const external_debug_namespaceObject = require("debug");
47
47
  var external_debug_default = /*#__PURE__*/ __webpack_require__.n(external_debug_namespaceObject);
48
48
  const external_common_js_namespaceObject = require("./common.js");
49
49
  const external_utils_js_namespaceObject = require("./utils.js");
50
- const topicPrefix = 'rpascene';
50
+ const topicPrefix = 'midscene';
51
51
  const logStreams = new Map();
52
52
  const debugInstances = new Map();
53
53
  function getLogStream(topic) {
54
54
  const topicFileName = topic.replace(/:/g, '-');
55
55
  if (!logStreams.has(topicFileName)) {
56
- const logFile = external_node_path_default().join((0, external_common_js_namespaceObject.getRpasceneRunSubDir)('log'), `${topicFileName}.log`);
56
+ const logFile = external_node_path_default().join((0, external_common_js_namespaceObject.getMidsceneRunSubDir)('log'), `${topicFileName}.log`);
57
57
  const stream = external_node_fs_default().createWriteStream(logFile, {
58
58
  flags: 'a'
59
59
  });