@veltdev/react 4.5.0-beta.12 → 4.5.0-beta.13

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/cjs/index.js CHANGED
@@ -99,7 +99,7 @@ function useVeltClient() {
99
99
  return React.useContext(VeltContext);
100
100
  }
101
101
 
102
- var loadVelt = function (callback, version, staging, develop, proxyDomain) {
102
+ var loadVelt = function (callback, version, staging, develop, proxyDomain, integrity, integrityValue) {
103
103
  if (version === void 0) { version = 'latest'; }
104
104
  if (staging === void 0) { staging = false; }
105
105
  if (develop === void 0) { develop = false; }
@@ -126,6 +126,10 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain) {
126
126
  }
127
127
  script.id = 'veltScript';
128
128
  script.type = 'module';
129
+ if (integrity && integrityValue) {
130
+ script.integrity = integrityValue;
131
+ script.crossOrigin = 'anonymous';
132
+ }
129
133
  document.body.appendChild(script);
130
134
  script.onload = function () {
131
135
  if (callback) {
@@ -140,18 +144,40 @@ var loadVelt = function (callback, version, staging, develop, proxyDomain) {
140
144
  }
141
145
  };
142
146
 
143
- var VELT_SDK_VERSION = '4.5.0-beta.12';
147
+ var VELT_SDK_VERSION = '4.5.0-beta.13';
144
148
  var VELT_SDK_INIT_EVENT = 'onVeltInit';
145
149
  var VELT_TAB_ID = 'veltTabId';
150
+ // integrity map for the Velt SDK
151
+ // Note: generate integrity hashes with: https://www.srihash.org/
152
+ var INTEGRITY_MAP = {
153
+ '4.5.0-beta.13': 'sha384-Mu1jdD223jLItSpbJev0mw5PyMUf+5UlS+qPrM/1P2JMejbTZvnwa8roDWwhP/In',
154
+ };
146
155
 
147
156
  var SnippylyProvider = function (props) {
148
157
  var apiKey = props.apiKey, user = props.user, config = props.config, documentId = props.documentId, language = props.language, translations = props.translations, autoTranslation = props.autoTranslation, userDataProvider = props.userDataProvider, dataProviders = props.dataProviders, onClientLoad = props.onClientLoad, children = props.children;
149
158
  var _a = React.useState(null), client = _a[0], setClient = _a[1];
150
159
  React.useEffect(function () {
151
160
  if (apiKey) {
161
+ var staging = config === null || config === void 0 ? void 0 : config.staging;
162
+ var develop = config === null || config === void 0 ? void 0 : config.develop;
163
+ var version = (config === null || config === void 0 ? void 0 : config.version) || VELT_SDK_VERSION;
164
+ var integrity = !!(config === null || config === void 0 ? void 0 : config.integrity);
165
+ var integrityValue = '';
166
+ if (integrity) {
167
+ if (develop || staging) {
168
+ if (config === null || config === void 0 ? void 0 : config.sriv) {
169
+ integrityValue = config === null || config === void 0 ? void 0 : config.sriv;
170
+ }
171
+ }
172
+ else {
173
+ if (INTEGRITY_MAP[version]) {
174
+ integrityValue = INTEGRITY_MAP[version];
175
+ }
176
+ }
177
+ }
152
178
  loadVelt(function () {
153
179
  initVelt();
154
- }, (config === null || config === void 0 ? void 0 : config.version) || VELT_SDK_VERSION, config === null || config === void 0 ? void 0 : config.staging, config === null || config === void 0 ? void 0 : config.develop, config === null || config === void 0 ? void 0 : config.proxyDomain);
180
+ }, version, staging, develop, config === null || config === void 0 ? void 0 : config.proxyDomain, integrity, integrityValue);
155
181
  }
156
182
  }, []);
157
183
  React.useEffect(function () {
@@ -6545,6 +6571,9 @@ function usePresenceUtils() {
6545
6571
  }, [client, setPresenceElement, presenceElement]);
6546
6572
  return presenceElement;
6547
6573
  }
6574
+ /**
6575
+ * @deprecated Use `usePresenceData` hook instead.
6576
+ */
6548
6577
  function usePresenceUsers() {
6549
6578
  var presenceElement = usePresenceUtils();
6550
6579
  var _a = React__default["default"].useState(null), data = _a[0], setData = _a[1];