@inboxsdk/core 1.1.1 → 1.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 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../src/common/version.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,EAAE,MAA6B,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../../src/common/version.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,EAAE,MAAoB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  // This is in its own file so that updates to the version value don't cause a
2
2
  // reload of everything.
3
- export const BUILD_VERSION = process.env.VERSION;
3
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- SDK_VERSION is injected by webpack
4
+ ///@ts-ignore
5
+ export const BUILD_VERSION = SDK_VERSION;
4
6
  if (module.hot) {
5
7
  module.hot.accept();
6
8
  }
@@ -16,9 +16,13 @@ jest.mock('../../../../lib/idMap', () => {
16
16
  const legacyMapping = {
17
17
  app_sidebar_content_panel: 'bccbBAHIcfEeHCHf'
18
18
  };
19
- return legacyMapping[key];
19
+ return legacyMapping[key] ?? key;
20
20
  }
21
- return idMap;
21
+ return {
22
+ __esModule: true,
23
+ default: idMap,
24
+ legacyIdMap: idMap
25
+ };
22
26
  });
23
27
  jest.mock('../../../../lib/dom/make-element-child-stream', () => {
24
28
  return () => require('kefir-bus')();
@@ -28,6 +28,8 @@ var _fakeWindowResize = _interopRequireDefault(require("../../../../../lib/fake-
28
28
  var _addCompanionThreadIconArea = _interopRequireDefault(require("./add-companion-thread-icon-area"));
29
29
  var _addCompanionGlobalIconArea = _interopRequireDefault(require("./add-companion-global-icon-area"));
30
30
  var _addToIconArea = _interopRequireDefault(require("./add-to-icon-area"));
31
+ var _classnames = _interopRequireDefault(require("classnames"));
32
+ var _constants = require("../../../../../driver-common/sidebar/constants");
31
33
  const ACTIVE_ADD_ON_ICON_SELECTOR = '.aT5-aOt-I-KO';
32
34
  const COMPANION_SIDEBAR_CONTENT_CLOSED_SHADOW_CLASS = 'brC-brG-btc';
33
35
 
@@ -445,9 +447,9 @@ class GmailAppSidebarPrimary {
445
447
  contentContainer.classList.add((0, _idMap.default)('companion_container_app_sidebar_in_use'));
446
448
  }
447
449
  this._companionSidebarContentContainerEl.classList.add((0, _idMap.default)('app_sidebar_in_use'));
448
- if (!document.body.querySelector('.' + (0, _idMap.default)('app_sidebar_waiting_platform'))) {
450
+ if (!document.body.querySelector(_constants.sidebarWaitingPlatformSelector)) {
449
451
  const waitingPlatform = document.createElement('div');
450
- waitingPlatform.className = (0, _idMap.default)('app_sidebar_waiting_platform');
452
+ waitingPlatform.className = (0, _classnames.default)(_constants.sidebarWaitingPlatformClassName, (0, _idMap.default)('app_sidebar_waiting_platform'));
451
453
  document.body.appendChild(waitingPlatform);
452
454
  }
453
455
 
@@ -30,6 +30,8 @@ var _ContentPanelViewDriver = _interopRequireDefault(require("../../../driver-co
30
30
  var _gmailElementGetter = _interopRequireDefault(require("../gmail-element-getter"));
31
31
  var _addIconArea = _interopRequireDefault(require("./gmail-thread-sidebar-view/add-icon-area"));
32
32
  var _addToIconArea = _interopRequireDefault(require("./gmail-app-sidebar-view/primary/add-to-icon-area"));
33
+ var _classnames = _interopRequireDefault(require("classnames"));
34
+ var _constants = require("../../../driver-common/sidebar/constants");
33
35
  /*
34
36
  This is used for PRE MATERIAL GMAIL, when sidebar only existed on threads.
35
37
  If you're reading this in the future, do you remember a time when there wasn't a global sidebar?
@@ -153,9 +155,9 @@ class GmailAppSidebarView {
153
155
  sidebarContainerEl.insertBefore(el, sidebarContainerEl.firstElementChild);
154
156
  sidebarContainerEl.classList.add((0, _idMap.default)('app_sidebar_in_use'));
155
157
  }
156
- if (!document.body.querySelector('.' + (0, _idMap.default)('app_sidebar_waiting_platform'))) {
158
+ if (!document.body.querySelector(_constants.sidebarWaitingPlatformSelector)) {
157
159
  const waitingPlatform = document.createElement('div');
158
- waitingPlatform.className = (0, _idMap.default)('app_sidebar_waiting_platform');
160
+ waitingPlatform.className = (0, _classnames.default)(_constants.sidebarWaitingPlatformClassName, (0, _idMap.default)('app_sidebar_waiting_platform'));
159
161
  document.body.appendChild(waitingPlatform);
160
162
  }
161
163
  if (addonSidebarContainerEl) {
@@ -18,9 +18,13 @@ jest.mock('../../../lib/idMap', () => {
18
18
  app_sidebar_content_panel: 'bccbBAHIcfEeHCHf',
19
19
  sidebar_button_container: 'CdCEaDfbJJbHDEaD'
20
20
  };
21
- return legacyMapping[key];
21
+ return legacyMapping[key] ?? key;
22
22
  }
23
- return idMap;
23
+ return {
24
+ __esModule: true,
25
+ default: idMap,
26
+ legacyIdMap: idMap
27
+ };
24
28
  });
25
29
  jest.mock('../../../lib/dom/make-element-child-stream', () => {
26
30
  return () => require('kefir-bus')();
@@ -11,8 +11,8 @@ var _kefir = _interopRequireDefault(require("kefir"));
11
11
  var _kefirBus = _interopRequireDefault(require("kefir-bus"));
12
12
  var _kefirStopper = _interopRequireDefault(require("kefir-stopper"));
13
13
  var _delayAsap = _interopRequireDefault(require("../../lib/delay-asap"));
14
- var _idMap = _interopRequireDefault(require("../../lib/idMap"));
15
14
  var _querySelectorOrFail = _interopRequireDefault(require("../../lib/dom/querySelectorOrFail"));
15
+ var _constants = require("./constants");
16
16
  class ContentPanelViewDriver {
17
17
  _eventStream = (0, _kefirBus.default)();
18
18
  _isActive = false;
@@ -45,7 +45,7 @@ class ContentPanelViewDriver {
45
45
  const afterAsap = (0, _delayAsap.default)().toProperty().onValue(() => {});
46
46
  let hasPlacedAlready = false;
47
47
  let appName;
48
- const waitingPlatform = (0, _querySelectorOrFail.default)(document.body, '.' + (0, _idMap.default)('app_sidebar_waiting_platform'));
48
+ const waitingPlatform = (0, _querySelectorOrFail.default)(document.body, _constants.sidebarWaitingPlatformSelector);
49
49
  descriptor.flatMap(x => afterAsap.map(() => x)).takeUntilBy(this._stopper).onValue(descriptor => {
50
50
  const {
51
51
  el,
@@ -0,0 +1,9 @@
1
+ export declare const sidebarWaitingPlatformSelector: string;
2
+ /**
3
+ * The CSS local corresponding to this SDK's classname is intentionally in
4
+ * this classname. This is because this classname
5
+ * is used as a selector for disparate bits of code,
6
+ * and the CSS local is only used for styling.
7
+ */
8
+ export declare const sidebarWaitingPlatformClassName: string;
9
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/platform-implementation-js/driver-common/sidebar/constants.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,8BAA8B,QAQ9B,CAAC;AAEd;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,QAK3C,CAAC"}
@@ -0,0 +1,26 @@
1
+ import cx from 'classnames';
2
+ import { legacyIdMap } from '../../lib/idMap';
3
+ const cssGlobal = 'inboxsdk__app_sidebar_waiting_platform';
4
+ var SidebarClassName;
5
+ (function (SidebarClassName) {
6
+ /** v1.1.0 CSS module selector, */
7
+ SidebarClassName["v1_1_0"] = "inboxsdk__a0oshmeH6N_2vLtc3DNT";
8
+ /** v1.1.1 CSS module selector, */
9
+ SidebarClassName["v1_1_1"] = "inboxsdk__BV_FA4qVT4qYxs3LbEU4";
10
+ })(SidebarClassName || (SidebarClassName = {}));
11
+ export const sidebarWaitingPlatformSelector = [
12
+ cssGlobal,
13
+ SidebarClassName.v1_1_0,
14
+ SidebarClassName.v1_1_1,
15
+ // Pre CSS module selector <1.1.0
16
+ legacyIdMap('app_sidebar_waiting_platform'),
17
+ ]
18
+ .map((x) => '.' + x)
19
+ .join(', ');
20
+ /**
21
+ * The CSS local corresponding to this SDK's classname is intentionally in
22
+ * this classname. This is because this classname
23
+ * is used as a selector for disparate bits of code,
24
+ * and the CSS local is only used for styling.
25
+ */
26
+ export const sidebarWaitingPlatformClassName = cx(cssGlobal, SidebarClassName.v1_1_0, SidebarClassName.v1_1_1, legacyIdMap('app_sidebar_waiting_platform'));
@@ -1,2 +1,9 @@
1
+ /**
2
+ * Pass a name and you'll get a unique identifier associated with that name.
3
+ * The returned identifier will only contain alphabetic characters.
4
+ *
5
+ * @deprecated a holdover from the old idMap runtime implementation. Use `idMap` instead unless you specifically need the same classname as old versions of the InboxSDK used.
6
+ */
7
+ export declare function legacyIdMap(name: string): string;
1
8
  export default function idMap(id: string): string;
2
9
  //# sourceMappingURL=idMap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"idMap.d.ts","sourceRoot":"","sources":["../../../../../src/platform-implementation-js/lib/idMap.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,EAAE,MAAM,UAGvC"}
1
+ {"version":3,"file":"idMap.d.ts","sourceRoot":"","sources":["../../../../../src/platform-implementation-js/lib/idMap.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA8BhD;AAED,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,EAAE,MAAM,UAGvC"}
@@ -1,4 +1,39 @@
1
1
  import * as s from '../style/gmail.css';
2
+ import Sha256 from 'sha.js/sha256';
3
+ const cache = new Map();
4
+ let seed = null;
5
+ /**
6
+ * Pass a name and you'll get a unique identifier associated with that name.
7
+ * The returned identifier will only contain alphabetic characters.
8
+ *
9
+ * @deprecated a holdover from the old idMap runtime implementation. Use `idMap` instead unless you specifically need the same classname as old versions of the InboxSDK used.
10
+ */
11
+ export function legacyIdMap(name) {
12
+ const id = cache.get(name);
13
+ if (id != null)
14
+ return id;
15
+ if (seed == null) {
16
+ seed = document.documentElement.getAttribute('data-map-id');
17
+ if (seed == null) {
18
+ // Make the seed change every hour: the seed is based on a hash of the
19
+ // current timestamp in hour resolution.
20
+ const hasher = new Sha256();
21
+ hasher.update('PWVe' + Math.floor(Date.now() / (1000 * 60 * 60)) + 'PYiE0');
22
+ seed =
23
+ hasher.digest('hex').slice(0, 16) +
24
+ (process.env.NODE_ENV === 'development' ? 'x' : '');
25
+ document.documentElement.setAttribute('data-map-id', seed);
26
+ }
27
+ }
28
+ const hasher = new Sha256();
29
+ hasher.update('4iYi29W' + name + ':' + seed + 'jn2mPvTG');
30
+ const newId = hasher
31
+ .digest('hex')
32
+ .slice(0, 16)
33
+ .replace(/[0-9]/g, (match) => String.fromCharCode('A'.charCodeAt(0) + Number(match)));
34
+ cache.set(name, newId);
35
+ return newId;
36
+ }
2
37
  export default function idMap(id) {
3
38
  // Uses lazy initialization of style tags from style-loader
4
39
  return s[id];