locize 4.0.11 → 4.0.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/cjs/api/handleEditKey.js +3 -1
  3. package/dist/cjs/api/handleRequestPopupChanges.js +8 -4
  4. package/dist/cjs/api/handleSendMatchedUninstrumented.js +3 -1
  5. package/dist/cjs/implementations/dummyImplementation.js +4 -12
  6. package/dist/cjs/implementations/i18nextImplementation.js +3 -1
  7. package/dist/cjs/locizePlugin.js +3 -3
  8. package/dist/cjs/parser.js +3 -3
  9. package/dist/cjs/process.js +3 -7
  10. package/dist/cjs/startStandalone.js +3 -1
  11. package/dist/cjs/ui/highlightNode.js +0 -1
  12. package/dist/cjs/ui/popup.js +8 -4
  13. package/dist/cjs/utils.js +9 -3
  14. package/dist/esm/api/handleEditKey.js +3 -1
  15. package/dist/esm/api/handleRequestPopupChanges.js +8 -4
  16. package/dist/esm/api/handleSendMatchedUninstrumented.js +3 -1
  17. package/dist/esm/implementations/dummyImplementation.js +4 -12
  18. package/dist/esm/implementations/i18nextImplementation.js +3 -1
  19. package/dist/esm/locizePlugin.js +3 -3
  20. package/dist/esm/parser.js +3 -3
  21. package/dist/esm/process.js +2 -6
  22. package/dist/esm/startStandalone.js +3 -1
  23. package/dist/esm/ui/highlightNode.js +0 -1
  24. package/dist/esm/ui/popup.js +8 -4
  25. package/dist/esm/utils.js +9 -4
  26. package/dist/umd/locize.js +809 -151
  27. package/dist/umd/locize.min.js +1 -1
  28. package/locize.js +809 -151
  29. package/locize.min.js +1 -1
  30. package/package.json +1 -1
  31. package/src/_startStandalone.js +1 -2
  32. package/src/api/handleEditKey.js +1 -2
  33. package/src/api/handleRequestPopupChanges.js +4 -6
  34. package/src/api/handleSendMatchedUninstrumented.js +1 -2
  35. package/src/clickHandler.js +3 -6
  36. package/src/implementations/dummyImplementation.js +5 -4
  37. package/src/implementations/i18nextImplementation.js +1 -2
  38. package/src/locizePlugin.js +120 -116
  39. package/src/parser.js +11 -11
  40. package/src/process.js +2 -9
  41. package/src/startStandalone.js +1 -2
  42. package/src/ui/highlightNode.js +26 -26
  43. package/src/ui/popup.js +4 -6
  44. package/src/utils.js +18 -12
  45. package/src/vars.js +2 -2
package/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ### 4.0.7
1
+ ### 4.0.12
2
+
3
+ - locizePlugin: start i18next-subliminal only if popup or in iframe
4
+
5
+ ### 4.0.11
2
6
 
3
7
  - fix highlighting
4
8
 
@@ -43,7 +43,9 @@ function setValueOnNode(meta, value) {
43
43
  }
44
44
  });
45
45
  children.forEach(function (replaceable) {
46
- if (item.node.contains(replaceable.child)) item.node.removeChild(replaceable.child);
46
+ if (item.node.contains(replaceable.child)) {
47
+ item.node.removeChild(replaceable.child);
48
+ }
47
49
  });
48
50
  }
49
51
  }
@@ -8,9 +8,9 @@ function handler(payload) {
8
8
  if (containerStyle) {
9
9
  var popup$1 = document.getElementById(popup.popupId);
10
10
  if (!popup$1) return;
11
- var storedPos = localStorage.getItem('locize_popup_pos');
11
+ var storedPos = window.localStorage.getItem('locize_popup_pos');
12
12
  if (storedPos) storedPos = JSON.parse(storedPos);
13
- var storedSize = localStorage.getItem('locize_popup_size');
13
+ var storedSize = window.localStorage.getItem('locize_popup_size');
14
14
  if (storedSize) storedSize = JSON.parse(storedSize);
15
15
  if (storedSize && storedSize.height && storedSize.width) {
16
16
  containerStyle.height = storedSize.height + 'px';
@@ -26,8 +26,12 @@ function handler(payload) {
26
26
  popup$1.style.setProperty('left', "calc(".concat(popup$1.style.left, " - ").concat(_diff, ")"));
27
27
  popup$1.style.setProperty('width', containerStyle.width);
28
28
  }
29
- if (storedPos && storedPos.top && storedPos.top < window.innerHeight - containerStyle.height.replace('px', '')) popup$1.style.setProperty('top', storedPos.top + 'px');
30
- if (storedPos && storedPos.left && storedPos.left < window.innerWidth - containerStyle.width.replace('px', '')) popup$1.style.setProperty('left', storedPos.left + 'px');
29
+ if (storedPos && storedPos.top && storedPos.top < window.innerHeight - containerStyle.height.replace('px', '')) {
30
+ popup$1.style.setProperty('top', storedPos.top + 'px');
31
+ }
32
+ if (storedPos && storedPos.left && storedPos.left < window.innerWidth - containerStyle.width.replace('px', '')) {
33
+ popup$1.style.setProperty('left', storedPos.left + 'px');
34
+ }
31
35
  }
32
36
  }
33
37
  postMessage.api.addHandler('requestPopupChanges', handler);
@@ -19,7 +19,9 @@ function handler(payload) {
19
19
  key: item.key
20
20
  }), item.value), uni === null || uni === void 0 ? void 0 : uni.node);
21
21
  if (uni && uni.keys) delete uni.keys["".concat(item.textType)];
22
- if (uni && uni.keys && !Object.keys(uni.keys).length) uninstrumentedStore.uninstrumentedStore.remove(item.eleUniqueID, uni.node);
22
+ if (uni && uni.keys && !Object.keys(uni.keys).length) {
23
+ uninstrumentedStore.uninstrumentedStore.remove(item.eleUniqueID, uni.node);
24
+ }
23
25
  });
24
26
  postMessage.api.sendCurrentParsedContent();
25
27
  }
@@ -7,21 +7,13 @@ function getImplementation() {
7
7
  getResource: function getResource(lng, ns, key) {
8
8
  return {};
9
9
  },
10
- setResource: function setResource(lng, ns, key, value) {
11
- return;
12
- },
10
+ setResource: function setResource(lng, ns, key, value) {},
13
11
  getResourceBundle: function getResourceBundle(lng, ns, cb) {
14
12
  cb({});
15
13
  },
16
- getDefaultNS: function getDefaultNS() {
17
- return;
18
- },
19
- getLng: function getLng() {
20
- return;
21
- },
22
- getSourceLng: function getSourceLng() {
23
- return;
24
- },
14
+ getDefaultNS: function getDefaultNS() {},
15
+ getLng: function getLng() {},
16
+ getSourceLng: function getSourceLng() {},
25
17
  getLocizeDetails: function getLocizeDetails() {
26
18
  return {};
27
19
  },
@@ -39,7 +39,9 @@ function getImplementation(i18n) {
39
39
  if (Array.isArray(fallback)) return fallback[fallback.length - 1];
40
40
  if (fallback && fallback["default"]) {
41
41
  if (typeof fallback["default"] === 'string') return fallback;
42
- if (Array.isArray(fallback["default"])) return fallback["default"][fallback["default"].length - 1];
42
+ if (Array.isArray(fallback["default"])) {
43
+ return fallback["default"][fallback["default"].length - 1];
44
+ }
43
45
  }
44
46
  if (typeof fallback === 'function') {
45
47
  var res = fallback(i18n.resolvedLanguage);
@@ -2,10 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('@babel/runtime/helpers/defineProperty');
6
- require('@babel/runtime/helpers/toConsumableArray');
7
5
  var i18nextSubliminal = require('i18next-subliminal');
8
6
  var process = require('./process.js');
7
+ var utils = require('./utils.js');
9
8
  var i18nextImplementation = require('./implementations/i18nextImplementation.js');
10
9
 
11
10
  function configurePostProcessor(i18next, options) {
@@ -29,7 +28,8 @@ var locizeEditorPlugin = function locizeEditorPlugin() {
29
28
  var options = i18n.options;
30
29
  i18next = i18n;
31
30
  var impl = i18nextImplementation.getImplementation(i18n);
32
- configurePostProcessor(i18next, options);
31
+ var showInContext = opt.show || utils.getQsParameterByName(opt.qsProp) === 'true';
32
+ if (utils.isInIframe || showInContext) configurePostProcessor(i18next, options);
33
33
  process.start(impl, opt);
34
34
  }
35
35
  };
@@ -155,13 +155,13 @@ function handleNode(node) {
155
155
  ignoreMergedEleUniqueIds.push(child.uniqueID);
156
156
  }
157
157
  var txt = child.textContent;
158
- if (nodeI18nMeta && nodeI18nMeta['html'] && i < node.childNodes.length - 1) {
158
+ if (nodeI18nMeta && nodeI18nMeta.html && i < node.childNodes.length - 1) {
159
159
  merge.push({
160
160
  childIndex: i,
161
161
  child: child,
162
162
  text: txt
163
163
  });
164
- } else if (nodeI18nMeta && nodeI18nMeta['html'] && i === node.childNodes.length - 1) {
164
+ } else if (nodeI18nMeta && nodeI18nMeta.html && i === node.childNodes.length - 1) {
165
165
  merge.push({
166
166
  childIndex: i,
167
167
  child: child,
@@ -170,7 +170,7 @@ function handleNode(node) {
170
170
  storeIfQualifiedKey(node.uniqueID, null, 'html', nodeI18nMeta, node, merge, node.innerHTML);
171
171
  merge = [];
172
172
  } else if (txt) {
173
- if (nodeI18nMeta && nodeI18nMeta['text']) {
173
+ if (nodeI18nMeta && nodeI18nMeta.text) {
174
174
  storeIfQualifiedKey(node.uniqueID, null, 'text', nodeI18nMeta, node, undefined, txt);
175
175
  } else if (child.nodeName === '#text' && !containsOnlySpaces(txt)) {
176
176
  uninstrumentedStore.uninstrumentedStore.save(node.uniqueID, 'text', node, txt);
@@ -30,10 +30,6 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
30
30
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
31
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
32
  var dummyImplementation = dummyImplementation$1.getImplementation();
33
- var isInIframe = typeof window !== 'undefined';
34
- try {
35
- isInIframe = self !== top;
36
- } catch (e) {}
37
33
  function start() {
38
34
  var implementation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dummyImplementation;
39
35
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
@@ -59,7 +55,7 @@ function start() {
59
55
  postMessage.api.sendCurrentTargetLanguage(implementation.getLng());
60
56
  });
61
57
  function continueToStart() {
62
- if (!isInIframe && !showInContext) return;
58
+ if (!utils.isInIframe && !showInContext) return;
63
59
  var observer$1 = observer.createObserver(document.body, function (eles) {
64
60
  eles.forEach(function (ele) {
65
61
  parser.parseTree(ele);
@@ -68,7 +64,7 @@ function start() {
68
64
  });
69
65
  observer$1.start();
70
66
  mouseDistance.startMouseTracking(observer$1);
71
- if (!isInIframe && !document.getElementById(popup.popupId)) {
67
+ if (!utils.isInIframe && !document.getElementById(popup.popupId)) {
72
68
  document.body.append(popup.Popup(vars.getIframeUrl(), function () {
73
69
  postMessage.api.requestInitialize(config);
74
70
  }));
@@ -95,7 +91,7 @@ function start() {
95
91
  }
96
92
  }
97
93
  if (document.body) return continueToStart();
98
- window.addEventListener('load', function () {
94
+ if (typeof window !== 'undefined') window.addEventListener('load', function () {
99
95
  return continueToStart();
100
96
  });
101
97
  }
@@ -16,6 +16,8 @@ function startStandalone() {
16
16
  rest = _objectWithoutProperties__default["default"](options, _excluded);
17
17
  process.start(implementation, Object.keys(rest).length > 0 ? rest : undefined);
18
18
  }
19
- if (typeof window !== 'undefined') window.locizeStartStandalone = startStandalone;
19
+ if (typeof window !== 'undefined') {
20
+ window.locizeStartStandalone = startStandalone;
21
+ }
20
22
 
21
23
  exports.startStandalone = startStandalone;
@@ -15,7 +15,6 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
15
15
 
16
16
  var selected = {};
17
17
  function highlight(item, node, keys) {
18
- item.id;
19
18
  var rectEle = utils.getOptimizedBoundingRectEle(node);
20
19
  if (!item.highlightBox) {
21
20
  var box = highlightBox.HighlightBox(rectEle, vars.colors.highlight);
@@ -25,7 +25,9 @@ function initDragElement() {
25
25
  }
26
26
  }
27
27
  function dragMouseDown(e) {
28
- if (!overlay) overlay = document.getElementById('i18next-editor-popup-overlay');
28
+ if (!overlay) {
29
+ overlay = document.getElementById('i18next-editor-popup-overlay');
30
+ }
29
31
  if (overlay) overlay.style.display = 'block';
30
32
  mouseDistance.stopMouseTracking();
31
33
  elmnt = this.parentPopup;
@@ -52,7 +54,7 @@ function initDragElement() {
52
54
  mouseDistance.startMouseTracking();
53
55
  if (overlay) overlay.style.display = 'none';
54
56
  var ele = document.getElementById('i18next-editor-popup');
55
- localStorage.setItem('locize_popup_pos', JSON.stringify({
57
+ window.localStorage.setItem('locize_popup_pos', JSON.stringify({
56
58
  top: parseInt(document.defaultView.getComputedStyle(ele).top, 10),
57
59
  left: parseInt(document.defaultView.getComputedStyle(ele).left, 10)
58
60
  }));
@@ -92,7 +94,9 @@ function initResizeElement() {
92
94
  }
93
95
  function initDrag(e) {
94
96
  mouseDistance.stopMouseTracking();
95
- if (!overlay) overlay = document.getElementById('i18next-editor-popup-overlay');
97
+ if (!overlay) {
98
+ overlay = document.getElementById('i18next-editor-popup-overlay');
99
+ }
96
100
  if (overlay) overlay.style.display = 'block';
97
101
  element = this.parentPopup;
98
102
  startX = e.clientX;
@@ -110,7 +114,7 @@ function initResizeElement() {
110
114
  mouseDistance.startMouseTracking();
111
115
  if (overlay) overlay.style.display = 'none';
112
116
  var ele = document.getElementById('i18next-editor-popup');
113
- localStorage.setItem('locize_popup_size', JSON.stringify({
117
+ window.localStorage.setItem('locize_popup_size', JSON.stringify({
114
118
  width: parseInt(document.defaultView.getComputedStyle(ele).width, 10),
115
119
  height: parseInt(document.defaultView.getComputedStyle(ele).height, 10)
116
120
  }));
package/dist/cjs/utils.js CHANGED
@@ -37,12 +37,12 @@ function getElementI18nKey(el) {
37
37
  }
38
38
  function parseAttrFromKey(key) {
39
39
  var attr = 'text';
40
- if (key.indexOf('[') == 0) {
40
+ if (key.indexOf('[') === 0) {
41
41
  var parts = key.split(']');
42
42
  key = parts[1];
43
43
  attr = parts[0].substr(1, parts[0].length - 1);
44
44
  }
45
- var newKey = key.indexOf(';') == key.length - 1 ? key.substr(0, key.length - 2) : key;
45
+ var newKey = key.indexOf(';') === key.length - 1 ? key.substr(0, key.length - 2) : key;
46
46
  return [newKey, attr];
47
47
  }
48
48
  function getI18nMetaFromNode(el) {
@@ -52,7 +52,7 @@ function getI18nMetaFromNode(el) {
52
52
  var allKeys = {};
53
53
  if (key && key.indexOf(';') >= 0) {
54
54
  var keys = key.split(';');
55
- for (var ix = 0, l_ix = keys.length; ix < l_ix; ix++) {
55
+ for (var ix = 0, lix = keys.length; ix < lix; ix++) {
56
56
  if (keys[ix] != '') {
57
57
  var _parseAttrFromKey = parseAttrFromKey(keys[ix]),
58
58
  _parseAttrFromKey2 = _slicedToArray__default["default"](_parseAttrFromKey, 2),
@@ -119,9 +119,15 @@ function getQsParameterByName(name, url) {
119
119
  if (!results[2]) return '';
120
120
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
121
121
  }
122
+ var _isInIframe = typeof window !== 'undefined';
123
+ try {
124
+ _isInIframe = self !== top;
125
+ } catch (e) {}
126
+ var isInIframe = _isInIframe;
122
127
 
123
128
  exports.debounce = debounce;
124
129
  exports.getElementI18nKey = getElementI18nKey;
125
130
  exports.getElementNamespace = getElementNamespace;
126
131
  exports.getI18nMetaFromNode = getI18nMetaFromNode;
127
132
  exports.getQsParameterByName = getQsParameterByName;
133
+ exports.isInIframe = isInIframe;
@@ -39,7 +39,9 @@ function setValueOnNode(meta, value) {
39
39
  }
40
40
  });
41
41
  children.forEach(function (replaceable) {
42
- if (item.node.contains(replaceable.child)) item.node.removeChild(replaceable.child);
42
+ if (item.node.contains(replaceable.child)) {
43
+ item.node.removeChild(replaceable.child);
44
+ }
43
45
  });
44
46
  }
45
47
  }
@@ -6,9 +6,9 @@ function handler(payload) {
6
6
  if (containerStyle) {
7
7
  var popup = document.getElementById(popupId);
8
8
  if (!popup) return;
9
- var storedPos = localStorage.getItem('locize_popup_pos');
9
+ var storedPos = window.localStorage.getItem('locize_popup_pos');
10
10
  if (storedPos) storedPos = JSON.parse(storedPos);
11
- var storedSize = localStorage.getItem('locize_popup_size');
11
+ var storedSize = window.localStorage.getItem('locize_popup_size');
12
12
  if (storedSize) storedSize = JSON.parse(storedSize);
13
13
  if (storedSize && storedSize.height && storedSize.width) {
14
14
  containerStyle.height = storedSize.height + 'px';
@@ -24,8 +24,12 @@ function handler(payload) {
24
24
  popup.style.setProperty('left', "calc(".concat(popup.style.left, " - ").concat(_diff, ")"));
25
25
  popup.style.setProperty('width', containerStyle.width);
26
26
  }
27
- if (storedPos && storedPos.top && storedPos.top < window.innerHeight - containerStyle.height.replace('px', '')) popup.style.setProperty('top', storedPos.top + 'px');
28
- if (storedPos && storedPos.left && storedPos.left < window.innerWidth - containerStyle.width.replace('px', '')) popup.style.setProperty('left', storedPos.left + 'px');
27
+ if (storedPos && storedPos.top && storedPos.top < window.innerHeight - containerStyle.height.replace('px', '')) {
28
+ popup.style.setProperty('top', storedPos.top + 'px');
29
+ }
30
+ if (storedPos && storedPos.left && storedPos.left < window.innerWidth - containerStyle.width.replace('px', '')) {
31
+ popup.style.setProperty('left', storedPos.left + 'px');
32
+ }
29
33
  }
30
34
  }
31
35
  api.addHandler('requestPopupChanges', handler);
@@ -13,7 +13,9 @@ function handler(payload) {
13
13
  key: item.key
14
14
  }), item.value), uni === null || uni === void 0 ? void 0 : uni.node);
15
15
  if (uni && uni.keys) delete uni.keys["".concat(item.textType)];
16
- if (uni && uni.keys && !Object.keys(uni.keys).length) uninstrumentedStore.remove(item.eleUniqueID, uni.node);
16
+ if (uni && uni.keys && !Object.keys(uni.keys).length) {
17
+ uninstrumentedStore.remove(item.eleUniqueID, uni.node);
18
+ }
17
19
  });
18
20
  api.sendCurrentParsedContent();
19
21
  }
@@ -3,21 +3,13 @@ function getImplementation() {
3
3
  getResource: function getResource(lng, ns, key) {
4
4
  return {};
5
5
  },
6
- setResource: function setResource(lng, ns, key, value) {
7
- return;
8
- },
6
+ setResource: function setResource(lng, ns, key, value) {},
9
7
  getResourceBundle: function getResourceBundle(lng, ns, cb) {
10
8
  cb({});
11
9
  },
12
- getDefaultNS: function getDefaultNS() {
13
- return;
14
- },
15
- getLng: function getLng() {
16
- return;
17
- },
18
- getSourceLng: function getSourceLng() {
19
- return;
20
- },
10
+ getDefaultNS: function getDefaultNS() {},
11
+ getLng: function getLng() {},
12
+ getSourceLng: function getSourceLng() {},
21
13
  getLocizeDetails: function getLocizeDetails() {
22
14
  return {};
23
15
  },
@@ -30,7 +30,9 @@ function getImplementation(i18n) {
30
30
  if (Array.isArray(fallback)) return fallback[fallback.length - 1];
31
31
  if (fallback && fallback["default"]) {
32
32
  if (typeof fallback["default"] === 'string') return fallback;
33
- if (Array.isArray(fallback["default"])) return fallback["default"][fallback["default"].length - 1];
33
+ if (Array.isArray(fallback["default"])) {
34
+ return fallback["default"][fallback["default"].length - 1];
35
+ }
34
36
  }
35
37
  if (typeof fallback === 'function') {
36
38
  var res = fallback(i18n.resolvedLanguage);
@@ -1,8 +1,7 @@
1
- import '@babel/runtime/helpers/esm/defineProperty';
2
- import '@babel/runtime/helpers/esm/toConsumableArray';
3
1
  import { PostProcessor } from 'i18next-subliminal';
4
2
  export { unwrap } from 'i18next-subliminal';
5
3
  import { start } from './process.js';
4
+ import { getQsParameterByName, isInIframe } from './utils.js';
6
5
  import { getImplementation } from './implementations/i18nextImplementation.js';
7
6
 
8
7
  function configurePostProcessor(i18next, options) {
@@ -26,7 +25,8 @@ var locizeEditorPlugin = function locizeEditorPlugin() {
26
25
  var options = i18n.options;
27
26
  i18next = i18n;
28
27
  var impl = getImplementation(i18n);
29
- configurePostProcessor(i18next, options);
28
+ var showInContext = opt.show || getQsParameterByName(opt.qsProp) === 'true';
29
+ if (isInIframe || showInContext) configurePostProcessor(i18next, options);
30
30
  start(impl, opt);
31
31
  }
32
32
  };
@@ -147,13 +147,13 @@ function handleNode(node) {
147
147
  ignoreMergedEleUniqueIds.push(child.uniqueID);
148
148
  }
149
149
  var txt = child.textContent;
150
- if (nodeI18nMeta && nodeI18nMeta['html'] && i < node.childNodes.length - 1) {
150
+ if (nodeI18nMeta && nodeI18nMeta.html && i < node.childNodes.length - 1) {
151
151
  merge.push({
152
152
  childIndex: i,
153
153
  child: child,
154
154
  text: txt
155
155
  });
156
- } else if (nodeI18nMeta && nodeI18nMeta['html'] && i === node.childNodes.length - 1) {
156
+ } else if (nodeI18nMeta && nodeI18nMeta.html && i === node.childNodes.length - 1) {
157
157
  merge.push({
158
158
  childIndex: i,
159
159
  child: child,
@@ -162,7 +162,7 @@ function handleNode(node) {
162
162
  storeIfQualifiedKey(node.uniqueID, null, 'html', nodeI18nMeta, node, merge, node.innerHTML);
163
163
  merge = [];
164
164
  } else if (txt) {
165
- if (nodeI18nMeta && nodeI18nMeta['text']) {
165
+ if (nodeI18nMeta && nodeI18nMeta.text) {
166
166
  storeIfQualifiedKey(node.uniqueID, null, 'text', nodeI18nMeta, node, undefined, txt);
167
167
  } else if (child.nodeName === '#text' && !containsOnlySpaces(txt)) {
168
168
  uninstrumentedStore.save(node.uniqueID, 'text', node, txt);
@@ -15,17 +15,13 @@ import './api/handleSelectedKeys.js';
15
15
  import './api/handleIsLocizeEnabled.js';
16
16
  import './api/handleSendMatchedUninstrumented.js';
17
17
  import { api } from './api/postMessage.js';
18
- import { getQsParameterByName } from './utils.js';
18
+ import { getQsParameterByName, isInIframe } from './utils.js';
19
19
  import '@babel/runtime/helpers/esm/toConsumableArray';
20
20
  import { getImplementation } from './implementations/dummyImplementation.js';
21
21
 
22
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
23
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
24
  var dummyImplementation = getImplementation();
25
- var isInIframe = typeof window !== 'undefined';
26
- try {
27
- isInIframe = self !== top;
28
- } catch (e) {}
29
25
  function start() {
30
26
  var implementation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : dummyImplementation;
31
27
  var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
@@ -87,7 +83,7 @@ function start() {
87
83
  }
88
84
  }
89
85
  if (document.body) return continueToStart();
90
- window.addEventListener('load', function () {
86
+ if (typeof window !== 'undefined') window.addEventListener('load', function () {
91
87
  return continueToStart();
92
88
  });
93
89
  }
@@ -8,6 +8,8 @@ function startStandalone() {
8
8
  rest = _objectWithoutProperties(options, _excluded);
9
9
  start(implementation, Object.keys(rest).length > 0 ? rest : undefined);
10
10
  }
11
- if (typeof window !== 'undefined') window.locizeStartStandalone = startStandalone;
11
+ if (typeof window !== 'undefined') {
12
+ window.locizeStartStandalone = startStandalone;
13
+ }
12
14
 
13
15
  export { startStandalone };
@@ -7,7 +7,6 @@ import { getOptimizedBoundingRectEle } from './utils.js';
7
7
 
8
8
  var selected = {};
9
9
  function highlight(item, node, keys) {
10
- item.id;
11
10
  var rectEle = getOptimizedBoundingRectEle(node);
12
11
  if (!item.highlightBox) {
13
12
  var box = HighlightBox(rectEle, colors.highlight);
@@ -21,7 +21,9 @@ function initDragElement() {
21
21
  }
22
22
  }
23
23
  function dragMouseDown(e) {
24
- if (!overlay) overlay = document.getElementById('i18next-editor-popup-overlay');
24
+ if (!overlay) {
25
+ overlay = document.getElementById('i18next-editor-popup-overlay');
26
+ }
25
27
  if (overlay) overlay.style.display = 'block';
26
28
  stopMouseTracking();
27
29
  elmnt = this.parentPopup;
@@ -48,7 +50,7 @@ function initDragElement() {
48
50
  startMouseTracking();
49
51
  if (overlay) overlay.style.display = 'none';
50
52
  var ele = document.getElementById('i18next-editor-popup');
51
- localStorage.setItem('locize_popup_pos', JSON.stringify({
53
+ window.localStorage.setItem('locize_popup_pos', JSON.stringify({
52
54
  top: parseInt(document.defaultView.getComputedStyle(ele).top, 10),
53
55
  left: parseInt(document.defaultView.getComputedStyle(ele).left, 10)
54
56
  }));
@@ -88,7 +90,9 @@ function initResizeElement() {
88
90
  }
89
91
  function initDrag(e) {
90
92
  stopMouseTracking();
91
- if (!overlay) overlay = document.getElementById('i18next-editor-popup-overlay');
93
+ if (!overlay) {
94
+ overlay = document.getElementById('i18next-editor-popup-overlay');
95
+ }
92
96
  if (overlay) overlay.style.display = 'block';
93
97
  element = this.parentPopup;
94
98
  startX = e.clientX;
@@ -106,7 +110,7 @@ function initResizeElement() {
106
110
  startMouseTracking();
107
111
  if (overlay) overlay.style.display = 'none';
108
112
  var ele = document.getElementById('i18next-editor-popup');
109
- localStorage.setItem('locize_popup_size', JSON.stringify({
113
+ window.localStorage.setItem('locize_popup_size', JSON.stringify({
110
114
  width: parseInt(document.defaultView.getComputedStyle(ele).width, 10),
111
115
  height: parseInt(document.defaultView.getComputedStyle(ele).height, 10)
112
116
  }));
package/dist/esm/utils.js CHANGED
@@ -29,12 +29,12 @@ function getElementI18nKey(el) {
29
29
  }
30
30
  function parseAttrFromKey(key) {
31
31
  var attr = 'text';
32
- if (key.indexOf('[') == 0) {
32
+ if (key.indexOf('[') === 0) {
33
33
  var parts = key.split(']');
34
34
  key = parts[1];
35
35
  attr = parts[0].substr(1, parts[0].length - 1);
36
36
  }
37
- var newKey = key.indexOf(';') == key.length - 1 ? key.substr(0, key.length - 2) : key;
37
+ var newKey = key.indexOf(';') === key.length - 1 ? key.substr(0, key.length - 2) : key;
38
38
  return [newKey, attr];
39
39
  }
40
40
  function getI18nMetaFromNode(el) {
@@ -44,7 +44,7 @@ function getI18nMetaFromNode(el) {
44
44
  var allKeys = {};
45
45
  if (key && key.indexOf(';') >= 0) {
46
46
  var keys = key.split(';');
47
- for (var ix = 0, l_ix = keys.length; ix < l_ix; ix++) {
47
+ for (var ix = 0, lix = keys.length; ix < lix; ix++) {
48
48
  if (keys[ix] != '') {
49
49
  var _parseAttrFromKey = parseAttrFromKey(keys[ix]),
50
50
  _parseAttrFromKey2 = _slicedToArray(_parseAttrFromKey, 2),
@@ -111,5 +111,10 @@ function getQsParameterByName(name, url) {
111
111
  if (!results[2]) return '';
112
112
  return decodeURIComponent(results[2].replace(/\+/g, ' '));
113
113
  }
114
+ var _isInIframe = typeof window !== 'undefined';
115
+ try {
116
+ _isInIframe = self !== top;
117
+ } catch (e) {}
118
+ var isInIframe = _isInIframe;
114
119
 
115
- export { debounce, getElementI18nKey, getElementNamespace, getI18nMetaFromNode, getQsParameterByName };
120
+ export { debounce, getElementI18nKey, getElementNamespace, getI18nMetaFromNode, getQsParameterByName, isInIframe };