@sumit_yewale/react 1.1.17 → 1.1.18-fix.1
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/@types/csvbox__react.d.ts +1 -11
- package/dist/index.js +60 -13
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +61 -14
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
|
@@ -30,25 +30,15 @@ declare module '@sumit_yewale/react' {
|
|
|
30
30
|
pendingFile: File | null;
|
|
31
31
|
targetOrigin?: string;
|
|
32
32
|
baseDomain?: string;
|
|
33
|
-
importerOrigin?: string;
|
|
34
|
-
probingOrigin?: boolean;
|
|
35
33
|
|
|
36
34
|
openModal(): void;
|
|
37
35
|
|
|
38
36
|
openModalWithFile(file: File): void;
|
|
39
37
|
|
|
40
|
-
postPendingFile(): void;
|
|
41
|
-
|
|
42
|
-
sendPendingFile(origin: string): void;
|
|
43
|
-
|
|
44
|
-
learnImporterOrigin(event: MessageEvent): void;
|
|
45
|
-
|
|
46
|
-
isImporterOrigin(origin: string): boolean;
|
|
47
|
-
|
|
48
38
|
componentDidMount(): void;
|
|
49
39
|
|
|
50
40
|
initImporter(): void;
|
|
51
41
|
|
|
52
|
-
|
|
42
|
+
enableInitiator(): void;
|
|
53
43
|
}
|
|
54
44
|
}
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ function _assertThisInitialized(self) {
|
|
|
28
28
|
return self;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
var version = "1.1.
|
|
31
|
+
var version = "1.1.18-fix.1";
|
|
32
32
|
|
|
33
33
|
var FILE_ACK_TIMEOUT_MS = 8000;
|
|
34
34
|
var OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';
|
|
@@ -95,6 +95,8 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
95
95
|
_this.openModal = _this.openModal.bind(_assertThisInitialized(_this));
|
|
96
96
|
_this.openModalWithFile = _this.openModalWithFile.bind(_assertThisInitialized(_this));
|
|
97
97
|
_this.lifecycle = adapterCore.createModalLifecycle();
|
|
98
|
+
_this.messageGate = adapterCore.createMessageGate();
|
|
99
|
+
_this.importTracker = adapterCore.createImportTracker();
|
|
98
100
|
_this.isModalShown = false;
|
|
99
101
|
_this.isReady = false;
|
|
100
102
|
_this.pendingFile = null;
|
|
@@ -184,24 +186,34 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
184
186
|
this.fileSender.reset();
|
|
185
187
|
|
|
186
188
|
var handleModalClosed = function handleModalClosed() {
|
|
187
|
-
if (_this3.
|
|
188
|
-
_this3.holder.current
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
if (_this3.importTracker.isInFlight()) {
|
|
190
|
+
if (_this3.holder.current) {
|
|
191
|
+
_this3.holder.current.style.display = 'none';
|
|
192
|
+
_this3.holder.current.style.pointerEvents = 'auto';
|
|
193
|
+
}
|
|
192
194
|
|
|
193
|
-
|
|
195
|
+
_this3.lifecycle.markHidden();
|
|
194
196
|
|
|
195
|
-
|
|
196
|
-
_this3.isReady = false;
|
|
197
|
-
_this3.iframe = null;
|
|
197
|
+
_this3.isModalShown = false;
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
_this3.clearFileAckTimer();
|
|
200
|
+
|
|
201
|
+
unregisterOpenImporter(_this3.registryEntry);
|
|
202
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
_this3.destroyImporter();
|
|
200
207
|
|
|
201
|
-
unregisterOpenImporter(_this3.registryEntry);
|
|
202
208
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
203
209
|
};
|
|
204
210
|
|
|
211
|
+
var finishImport = function finishImport(ended) {
|
|
212
|
+
if (ended && !_this3.isModalShown && _this3.iframe) {
|
|
213
|
+
_this3.destroyImporter();
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
205
217
|
if (this.messageListener) {
|
|
206
218
|
window.removeEventListener("message", this.messageListener, false);
|
|
207
219
|
}
|
|
@@ -214,6 +226,12 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
214
226
|
return;
|
|
215
227
|
}
|
|
216
228
|
|
|
229
|
+
if (!_this3.messageGate.allowLegacy()) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
var _ended = _this3.importTracker.observe(legacy);
|
|
234
|
+
|
|
217
235
|
if (legacy.type === "mainModalHidden") {
|
|
218
236
|
handleModalClosed();
|
|
219
237
|
}
|
|
@@ -226,6 +244,7 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
226
244
|
onImport(false);
|
|
227
245
|
}
|
|
228
246
|
|
|
247
|
+
finishImport(_ended);
|
|
229
248
|
return;
|
|
230
249
|
}
|
|
231
250
|
|
|
@@ -274,6 +293,10 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
274
293
|
return;
|
|
275
294
|
}
|
|
276
295
|
|
|
296
|
+
_this3.messageGate.markTyped();
|
|
297
|
+
|
|
298
|
+
var ended = _this3.importTracker.observe(message);
|
|
299
|
+
|
|
277
300
|
if (message.type === "data-on-submit") {
|
|
278
301
|
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(message.metadata);
|
|
279
302
|
} else if (message.type === "data-push-status") {
|
|
@@ -285,10 +308,14 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
285
308
|
} else if (message.type === "csvbox-upload-failed") {
|
|
286
309
|
onImport(false);
|
|
287
310
|
}
|
|
311
|
+
|
|
312
|
+
finishImport(ended);
|
|
288
313
|
};
|
|
289
314
|
|
|
290
315
|
window.addEventListener("message", this.messageListener, false);
|
|
291
316
|
this.uuid = adapterCore.generateUuid();
|
|
317
|
+
this.messageGate.reset();
|
|
318
|
+
this.importTracker.reset();
|
|
292
319
|
var iframe = document.createElement("iframe");
|
|
293
320
|
this.iframe = iframe;
|
|
294
321
|
iframe.setAttribute("src", iframeUrl);
|
|
@@ -396,9 +423,25 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
396
423
|
console.warn("[csvbox] the importer did not respond to the supplied file");
|
|
397
424
|
};
|
|
398
425
|
|
|
399
|
-
_proto.
|
|
426
|
+
_proto.destroyImporter = function destroyImporter() {
|
|
427
|
+
if (this.holder.current) {
|
|
428
|
+
this.holder.current.style.display = 'none';
|
|
429
|
+
this.holder.current.style.pointerEvents = 'auto';
|
|
430
|
+
this.holder.current.innerHTML = '';
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
this.lifecycle.markClosed();
|
|
434
|
+
this.isModalShown = false;
|
|
435
|
+
this.isReady = false;
|
|
436
|
+
this.iframe = null;
|
|
437
|
+
this.messageGate.reset();
|
|
438
|
+
this.importTracker.reset();
|
|
400
439
|
this.clearProbeTimer();
|
|
401
440
|
unregisterOpenImporter(this.registryEntry);
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
_proto.teardown = function teardown() {
|
|
444
|
+
this.destroyImporter();
|
|
402
445
|
|
|
403
446
|
if (this.unsubscribeOpenImporters) {
|
|
404
447
|
this.unsubscribeOpenImporters();
|
|
@@ -411,6 +454,10 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
411
454
|
}
|
|
412
455
|
};
|
|
413
456
|
|
|
457
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
458
|
+
this.teardown();
|
|
459
|
+
};
|
|
460
|
+
|
|
414
461
|
_proto.syncBlocked = function syncBlocked() {
|
|
415
462
|
var blocked = isBlockedByOpenImporter(this.registryEntry);
|
|
416
463
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { version } from '../package.json';\nimport {\n\tHOLDER_STYLE,\n\tIFRAME_STYLE,\n\tbuildImportUrl,\n\tgenerateUuid,\n\tbuildInitPayload,\n\tcreateModalLifecycle,\n\tcreateFileSender,\n\tclassifyStructuredMessage,\n\tclassifyLegacyMessage\n} from '@sumit_yewale/adapter-core';\n\n// How long we wait for the importer to confirm a file it was sent before giving up on it.\nconst FILE_ACK_TIMEOUT_MS = 8000;\n\n// Page-wide record of the importers that are open or opening, shared by every CSVBox adapter\n// on the page (it lives on window so separate copies of an adapter see the same list). It does\n// two things: the newest importer is stacked on top (every holder is fixed, full screen and\n// z-index 2147483647, so equal z-indexes would leave the one that comes first in the DOM on\n// top), and the other instances learn that an importer is open so they can disable their button.\nconst OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';\nconst TOP_Z_INDEX = 2147483647;\n\nfunction openImporters() {\n\tif (!window[OPEN_IMPORTERS_KEY]) window[OPEN_IMPORTERS_KEY] = { open: [], listeners: [] };\n\treturn window[OPEN_IMPORTERS_KEY];\n}\n\nfunction restackOpenImporters(reg) {\n\treg.open.forEach(function (entry, i) {\n\t\tconst holder = entry.getHolder();\n\t\tif (holder) holder.style.zIndex = String(TOP_Z_INDEX - (reg.open.length - 1 - i));\n\t});\n}\n\nfunction registerOpenImporter(entry) {\n\tconst reg = openImporters();\n\tif (reg.open.indexOf(entry) >= 0) return;\n\treg.open.push(entry);\n\trestackOpenImporters(reg);\n\treg.listeners.slice().forEach(function (fn) { fn(); });\n}\n\nfunction unregisterOpenImporter(entry) {\n\tconst reg = openImporters();\n\tconst i = reg.open.indexOf(entry);\n\tif (i < 0) return;\n\treg.open.splice(i, 1);\n\trestackOpenImporters(reg);\n\treg.listeners.slice().forEach(function (fn) { fn(); });\n}\n\nfunction isBlockedByOpenImporter(entry) {\n\tconst reg = openImporters();\n\treturn reg.open.length > 0 && reg.open.indexOf(entry) < 0;\n}\n\nfunction subscribeOpenImporters(fn) {\n\tconst reg = openImporters();\n\treg.listeners.push(fn);\n\treturn function () {\n\t\tconst i = reg.listeners.indexOf(fn);\n\t\tif (i >= 0) reg.listeners.splice(i, 1);\n\t};\n}\n\nexport class CSVBoxButton extends Component {\n\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.holder = React.createRef();\n\t\tthis.openModal = this.openModal.bind(this);\n\t\tthis.openModalWithFile = this.openModalWithFile.bind(this);\n\t\tthis.lifecycle = createModalLifecycle();\n\t\tthis.isModalShown = false;\n\t\tthis.isReady = false;\n\t\tthis.pendingFile = null;\n\t\tthis.uuid = generateUuid();\n\t\tthis.state = {\n\t\t\tisLoading: true,\n\t\t\t// True while a different importer on the page is open: the button stays disabled.\n\t\t\tblocked: false\n\t\t};\n\t\tthis.iframe = null;\n\t\tthis.registryEntry = { getHolder: () => this.holder.current };\n\t\tthis.fileSender = createFileSender({\n\t\t\tgetIframe: () => this.iframe,\n\t\t\tgetToken: () => this.uuid,\n\t\t\tgetTargetOrigin: () => this.targetOrigin,\n\t\t\tgetBaseDomain: () => this.baseDomain,\n\t\t\ttakeFile: () => {\n\t\t\t\tconst file = this.pendingFile;\n\t\t\t\tthis.pendingFile = null;\n\t\t\t\treturn file;\n\t\t\t},\n\t\t\tonSent: () => this.startFileAckTimer()\n\t\t});\n\t}\n\n\tcomponentDidMount() {\n\t\tthis.syncBlocked();\n\t\tthis.unsubscribeOpenImporters = subscribeOpenImporters(() => this.syncBlocked());\n\t\tconst { lazy } = this.props;\n\t\tif (!lazy && !this.iframe) {\n\t\t\tthis.initImporter();\n\t\t} else if (lazy) {\n\t\t\tthis.enableInitiator();\n\t\t}\n\t}\n\n\tinitImporter() {\n\t\tconst {\n\t\t\tloadStarted, user, dynamicColumns, options, onReady, onImport,\n\t\t\tonSubmit, onClose, licenseKey, dataLocation, customDomain,\n\t\t\tlanguage, environment, theme\n\t\t} = this.props;\n\n\t\tloadStarted?.();\n\n\t\tconst iframeUrl = buildImportUrl(\n\t\t\t{ licenseKey, customDomain, dataLocation, language, theme, environment },\n\t\t\t\"react\",\n\t\t\tversion\n\t\t);\n\n\t\t// Default place to send the file. A file is only ever sent to a named origin, never \"*\".\n\t\tthis.targetOrigin = new URL(iframeUrl).origin;\n\n\t\t// Data-location sheets redirect to another host, so the iframe origin can differ from\n\t\t// targetOrigin. We use this domain to check the real origin before trusting it.\n\t\tthis.baseDomain = customDomain || \"app.csvbox.io\";\n\t\tthis.fileSender.reset();\n\n\t\tconst handleModalClosed = () => {\n\t\t\tif (this.holder.current) {\n\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\tthis.holder.current.innerHTML = '';\n\t\t\t}\n\t\t\tthis.lifecycle.markClosed();\n\t\t\tthis.isModalShown = false;\n\t\t\tthis.isReady = false;\n\t\t\tthis.iframe = null;\n\t\t\t// A new iframe is built on the next open, so the origin is learned again.\n\t\t\tthis.clearProbeTimer();\n\t\t\tunregisterOpenImporter(this.registryEntry);\n\t\t\tonClose?.();\n\t\t};\n\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t}\n\n\t\tthis.messageListener = (event) => {\n\t\t\tconst legacy = classifyLegacyMessage(event.data);\n\t\t\tif (legacy) {\n\t\t\t\t// Legacy messages carry no token, so the only way to tell which importer sent one is\n\t\t\t\t// its window. Ignore those that came from another instance's iframe (or anywhere else).\n\t\t\t\tif (!this.iframe || event.source !== this.iframe.contentWindow) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"mainModalHidden\") {\n\t\t\t\t\thandleModalClosed();\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadSuccessful\") {\n\t\t\t\t\tonImport(true);\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadFailed\") {\n\t\t\t\t\tonImport(false);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set-file handshake messages. The shared core does not classify these, so they are\n\t\t\t// read here, behind the same unique_token check the core applies.\n\t\t\tconst raw = event.data;\n\t\t\tif (raw && typeof raw === \"object\" && raw.data && raw.data.unique_token == this.uuid) {\n\t\t\t\tthis.fileSender.learnOrigin(event);\n\n\t\t\t\tif (raw.type === \"csvbox-set-file-rejected\" && raw.data.reason === \"not-a-file\") {\n\t\t\t\t\t// Reply to our probe (it has no file). It only tells us the origin, so do nothing.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (raw.type === \"csvbox-modal-shown\") {\n\t\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\t\tregisterOpenImporter(this.registryEntry);\n\t\t\t\t\t// What the file path in openModal() is waiting for. display as well as\n\t\t\t\t\t// pointer-events: a second file declined while the first was still opening the\n\t\t\t\t\t// modal has put the holder away in the meantime.\n\t\t\t\t\tthis.isModalShown = true;\n\t\t\t\t\tthis.lifecycle.requestOpen();\n\t\t\t\t\tif (this.holder.current) {\n\t\t\t\t\t\tthis.holder.current.style.display = 'block';\n\t\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (raw.type === \"csvbox-set-file-rejected\") {\n\t\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\t\t// The importer has the file and will not take it. Put the holder away only if the\n\t\t\t\t\t// modal was never confirmed up: a file declined while it is open (an import past\n\t\t\t\t\t// the upload step, a fade-out under way) leaves that modal where it is, and its\n\t\t\t\t\t// own 'csvbox-modal-hidden' will put the holder away when it closes.\n\t\t\t\t\tif (!this.isModalShown && this.holder.current) {\n\t\t\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t\t\tunregisterOpenImporter(this.registryEntry);\n\t\t\t\t\t}\n\t\t\t\t\tconsole.warn(\"[csvbox] importer declined the supplied file: \" + raw.data.reason);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst message = classifyStructuredMessage(event.data, this.uuid);\n\t\t\tif (!message) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (message.type === \"data-on-submit\") {\n\t\t\t\tonSubmit?.(message.metadata);\n\t\t\t} else if (message.type === \"data-push-status\") {\n\t\t\t\tonImport(message.success, message.metadata);\n\t\t\t} else if (message.type === \"csvbox-modal-hidden\") {\n\t\t\t\thandleModalClosed();\n\t\t\t} else if (message.type === \"csvbox-upload-successful\") {\n\t\t\t\tonImport(true);\n\t\t\t} else if (message.type === \"csvbox-upload-failed\") {\n\t\t\t\tonImport(false);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(\"message\", this.messageListener, false);\n\n\t\tthis.uuid = generateUuid();\n\n\t\tconst iframe = document.createElement(\"iframe\");\n\t\tthis.iframe = iframe;\n\t\tiframe.setAttribute(\"src\", iframeUrl);\n\t\tiframe.setAttribute(\"allow\", \"clipboard-read; clipboard-write *\");\n\t\tiframe.frameBorder = 0;\n\t\tiframe.classList.add('csvbox-iframe');\n\t\tObject.assign(iframe.style, IFRAME_STYLE);\n\n\t\tiframe.onload = () => {\n\t\t\tthis.isReady = true;\n\t\t\tthis.enableInitiator();\n\t\t\tiframe.contentWindow.postMessage(buildInitPayload(user, dynamicColumns, options, this.uuid), \"*\");\n\t\t\tonReady?.();\n\t\t\tif (this.lifecycle.markReady()) {\n\t\t\t\tthis.openModal();\n\t\t\t}\n\t\t};\n\n\t\tthis.holder.current.appendChild(iframe);\n\t}\n\n\topenModal() {\n\t\t// Counts as open from the moment it is requested, so the other buttons are disabled while\n\t\t// this importer is still loading, and so it is stacked above any importer opened earlier.\n\t\tregisterOpenImporter(this.registryEntry);\n\t\tif (!this.iframe) {\n\t\t\tthis.lifecycle.requestOpen();\n\t\t\tthis.initImporter();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.pendingFile) {\n\t\t\tif (!this.isReady) {\n\t\t\t\t// Deferred: onload's markReady() calls openModal() again once the iframe is up.\n\t\t\t\tthis.lifecycle.requestOpen();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The importer opens its own modal once it has the file, so that it can inject on\n\t\t\t// 'shown.bs.modal'. Sending 'openModal' as well would race that.\n\t\t\t//\n\t\t\t// It can also decline: wrong step, an import file URL configured on the sheet, or\n\t\t\t// an importer too old to know the message at all. So the holder goes up\n\t\t\t// click-through and stays that way until 'csvbox-modal-shown' confirms the modal\n\t\t\t// is really up. It covers the viewport at z-index 2147483647 and the importer\n\t\t\t// renders transparent with its modal closed, so arming it on an unanswered message\n\t\t\t// leaves an invisible sheet over the host page eating every click.\n\t\t\t//\n\t\t\t// display:block regardless, so the iframe lays out and animates normally; only\n\t\t\t// pointer-events is held back. isModalShown likewise waits for the confirmation,\n\t\t\t// or a declined file would latch the importer shut for good.\n\t\t\tthis.holder.current.style.pointerEvents = 'none';\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t\tthis.fileSender.send();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.lifecycle.requestOpen()) {\n\t\t\tthis.isModalShown = true;\n\t\t\tthis.iframe.contentWindow.postMessage('openModal', '*');\n\t\t\t// Explicit: a previously declined file leaves the holder click-through.\n\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t}\n\t}\n\n\t/**\n\t * Open the importer on a File the host page already has, instead of the file picker.\n\t *\n\t * Reachable two ways: a ref on the component (`ref.current.openModalWithFile(file)`), or\n\t * the third argument handed to the `render` prop.\n\t *\n\t * The File crosses to the iframe by structured clone, so the importer receives the real\n\t * object and applies its own extension, worksheet and size rules to it -- this does not\n\t * bypass any of them. Pass a File; a Blob has no name for the importer to read an\n\t * extension from.\n\t */\n\topenModalWithFile(file) {\n\t\t// window.File, not a bare File: eslint-config-standard declares only window, document\n\t\t// and navigator as browser globals, so a bare File is a no-undef error here.\n\t\tif (!window.File || !(file instanceof window.File)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pendingFile = file;\n\n\t\t// Already open: hand it over now rather than holding it for the next open. The importer\n\t\t// takes it only while it is still on the upload step, and ignores it once the user has a\n\t\t// dataset and a mapping in progress.\n\t\tif (this.isModalShown && this.iframe && this.isReady) {\n\t\t\tthis.fileSender.send();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.openModal();\n\t}\n\n\tclearProbeTimer() {\n\t\tthis.clearFileAckTimer();\n\t\tthis.fileSender.reset();\n\t}\n\n\tstartFileAckTimer() {\n\t\tthis.clearFileAckTimer();\n\t\tthis.fileAckTimer = setTimeout(() => {\n\t\t\tthis.fileAckTimer = null;\n\t\t\tthis.giveUpOnFile();\n\t\t}, FILE_ACK_TIMEOUT_MS);\n\t}\n\n\tclearFileAckTimer() {\n\t\tif (this.fileAckTimer) {\n\t\t\tclearTimeout(this.fileAckTimer);\n\t\t\tthis.fileAckTimer = null;\n\t\t}\n\t}\n\n\t// The importer never confirmed the file it was sent (an origin we do not trust, or an importer too\n\t// old to know the message). Without this the holder would stay up, invisible and click-through,\n\t// and the other instances' buttons would stay disabled for good.\n\tgiveUpOnFile() {\n\t\tif (this.isModalShown) {\n\t\t\treturn;\n\t\t}\n\t\tconst holder = this.holder.current;\n\t\tif (holder) {\n\t\t\tholder.style.display = 'none';\n\t\t\tholder.style.pointerEvents = 'auto';\n\t\t}\n\t\tunregisterOpenImporter(this.registryEntry);\n\t\tconsole.warn(\"[csvbox] the importer did not respond to the supplied file\");\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.clearProbeTimer();\n\t\tunregisterOpenImporter(this.registryEntry);\n\t\tif (this.unsubscribeOpenImporters) {\n\t\t\tthis.unsubscribeOpenImporters();\n\t\t\tthis.unsubscribeOpenImporters = null;\n\t\t}\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t\tthis.messageListener = null;\n\t\t}\n\t}\n\n\tsyncBlocked() {\n\t\tconst blocked = isBlockedByOpenImporter(this.registryEntry);\n\t\tif (blocked !== this.state.blocked) {\n\t\t\tthis.setState({ blocked });\n\t\t}\n\t}\n\n\tenableInitiator() {\n\t\tthis.setState({\n\t\t\tisLoading: false\n\t\t});\n\t}\n\n\trender() {\n\t\tif (this.props.render) {\n\t\t\treturn (\n\t\t\t\t<div>\n\t\t\t\t\t{this.props.render(this.openModal, this.state.isLoading || this.state.blocked, this.openModalWithFile)}\n\t\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t<button disabled={this.state.isLoading || this.state.blocked} onClick={this.openModal} data-csvbox-initator data-csvbox-token={this.uuid}>{this.props.children}</button>\n\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t</div>\n\t\t)\n\t}\n}\n\nexport default CSVBoxButton;\n"],"names":["FILE_ACK_TIMEOUT_MS","OPEN_IMPORTERS_KEY","TOP_Z_INDEX","openImporters","window","open","listeners","restackOpenImporters","reg","forEach","entry","i","holder","getHolder","style","zIndex","String","length","registerOpenImporter","indexOf","push","slice","fn","unregisterOpenImporter","splice","isBlockedByOpenImporter","subscribeOpenImporters","CSVBoxButton","props","React","createRef","openModal","bind","openModalWithFile","lifecycle","createModalLifecycle","isModalShown","isReady","pendingFile","uuid","generateUuid","state","isLoading","blocked","iframe","registryEntry","current","fileSender","createFileSender","getIframe","getToken","getTargetOrigin","targetOrigin","getBaseDomain","baseDomain","takeFile","file","onSent","startFileAckTimer","componentDidMount","syncBlocked","unsubscribeOpenImporters","lazy","initImporter","enableInitiator","loadStarted","user","dynamicColumns","options","onReady","onImport","onSubmit","onClose","licenseKey","dataLocation","customDomain","language","environment","theme","iframeUrl","buildImportUrl","version","URL","origin","reset","handleModalClosed","display","pointerEvents","innerHTML","markClosed","clearProbeTimer","messageListener","removeEventListener","event","legacy","classifyLegacyMessage","data","source","contentWindow","type","raw","unique_token","learnOrigin","reason","clearFileAckTimer","requestOpen","console","warn","message","classifyStructuredMessage","metadata","success","addEventListener","document","createElement","setAttribute","frameBorder","classList","add","Object","assign","IFRAME_STYLE","onload","postMessage","buildInitPayload","markReady","appendChild","send","File","fileAckTimer","setTimeout","giveUpOnFile","clearTimeout","componentWillUnmount","setState","render","HOLDER_STYLE","children","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,IAAMA,mBAAmB,GAAG,IAA5B;AAOA,IAAMC,kBAAkB,GAAG,uBAA3B;AACA,IAAMC,WAAW,GAAG,UAApB;;AAEA,SAASC,aAAT,GAAyB;AACxB,MAAI,CAACC,MAAM,CAACH,kBAAD,CAAX,EAAiCG,MAAM,CAACH,kBAAD,CAAN,GAA6B;AAAEI,IAAAA,IAAI,EAAE,EAAR;AAAYC,IAAAA,SAAS,EAAE;AAAvB,GAA7B;AACjC,SAAOF,MAAM,CAACH,kBAAD,CAAb;AACA;;AAED,SAASM,oBAAT,CAA8BC,GAA9B,EAAmC;AAClCA,EAAAA,GAAG,CAACH,IAAJ,CAASI,OAAT,CAAiB,UAAUC,KAAV,EAAiBC,CAAjB,EAAoB;AACpC,QAAMC,MAAM,GAAGF,KAAK,CAACG,SAAN,EAAf;AACA,QAAID,MAAJ,EAAYA,MAAM,CAACE,KAAP,CAAaC,MAAb,GAAsBC,MAAM,CAACd,WAAW,IAAIM,GAAG,CAACH,IAAJ,CAASY,MAAT,GAAkB,CAAlB,GAAsBN,CAA1B,CAAZ,CAA5B;AACZ,GAHD;AAIA;;AAED,SAASO,oBAAT,CAA8BR,KAA9B,EAAqC;AACpC,MAAMF,GAAG,GAAGL,aAAa,EAAzB;AACA,MAAIK,GAAG,CAACH,IAAJ,CAASc,OAAT,CAAiBT,KAAjB,KAA2B,CAA/B,EAAkC;AAClCF,EAAAA,GAAG,CAACH,IAAJ,CAASe,IAAT,CAAcV,KAAd;AACAH,EAAAA,oBAAoB,CAACC,GAAD,CAApB;AACAA,EAAAA,GAAG,CAACF,SAAJ,CAAce,KAAd,GAAsBZ,OAAtB,CAA8B,UAAUa,EAAV,EAAc;AAAEA,IAAAA,EAAE;AAAK,GAArD;AACA;;AAED,SAASC,sBAAT,CAAgCb,KAAhC,EAAuC;A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Ad;AAGA,GArUF;;AAAA,SAuUC6F,MAvUD,GAuUC,kBAAS;AACR,QAAI,KAAK3G,KAAL,CAAW2G,MAAf,EAAuB;AACtB,0BACC1G,0CACE,KAAKD,KAAL,CAAW2G,MAAX,CAAkB,KAAKxG,SAAvB,EAAkC,KAAKU,KAAL,CAAWC,SAAX,IAAwB,KAAKD,KAAL,CAAWE,OAArE,EAA8E,KAAKV,iBAAnF,CADF,eAECJ;AAAK,QAAA,GAAG,EAAE,KAAKjB,MAAf;AAAuB,QAAA,KAAK,EAAE4H;AAA9B,QAFD,CADD;AAMA;;AAED,wBACC3G,uDACCA;AAAQ,MAAA,QAAQ,EAAE,KAAKY,KAAL,CAAWC,SAAX,IAAwB,KAAKD,KAAL,CAAWE,OAArD;AAA8D,MAAA,OAAO,EAAE,KAAKZ,SAA5E;AAAuF,kCAAvF;AAA4G,2BAAmB,KAAKQ;AAApI,OAA2I,KAAKX,KAAL,CAAW6G,QAAtJ,CADD,eAEC5G;AAAK,MAAA,GAAG,EAAE,KAAKjB,MAAf;AAAuB,MAAA,KAAK,EAAE4H;AAA9B,MAFD,CADD;AAMA,GAvVF;;AAAA;AAAA,EAAkCE,eAAlC;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { version } from '../package.json';\nimport {\n\tHOLDER_STYLE,\n\tIFRAME_STYLE,\n\tbuildImportUrl,\n\tgenerateUuid,\n\tbuildInitPayload,\n\tcreateModalLifecycle,\n\tcreateMessageGate,\n\tcreateImportTracker,\n\tcreateFileSender,\n\tclassifyStructuredMessage,\n\tclassifyLegacyMessage\n} from '@sumit_yewale/adapter-core';\n\n// How long we wait for the importer to confirm a file it was sent before giving up on it.\nconst FILE_ACK_TIMEOUT_MS = 8000;\n\n// Page-wide record of the importers that are open or opening, shared by every CSVBox adapter\n// on the page (it lives on window so separate copies of an adapter see the same list). It does\n// two things: the newest importer is stacked on top (every holder is fixed, full screen and\n// z-index 2147483647, so equal z-indexes would leave the one that comes first in the DOM on\n// top), and the other instances learn that an importer is open so they can disable their button.\nconst OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';\nconst TOP_Z_INDEX = 2147483647;\n\nfunction openImporters() {\n\tif (!window[OPEN_IMPORTERS_KEY]) window[OPEN_IMPORTERS_KEY] = { open: [], listeners: [] };\n\treturn window[OPEN_IMPORTERS_KEY];\n}\n\nfunction restackOpenImporters(reg) {\n\treg.open.forEach(function (entry, i) {\n\t\tconst holder = entry.getHolder();\n\t\tif (holder) holder.style.zIndex = String(TOP_Z_INDEX - (reg.open.length - 1 - i));\n\t});\n}\n\nfunction registerOpenImporter(entry) {\n\tconst reg = openImporters();\n\tif (reg.open.indexOf(entry) >= 0) return;\n\treg.open.push(entry);\n\trestackOpenImporters(reg);\n\treg.listeners.slice().forEach(function (fn) { fn(); });\n}\n\nfunction unregisterOpenImporter(entry) {\n\tconst reg = openImporters();\n\tconst i = reg.open.indexOf(entry);\n\tif (i < 0) return;\n\treg.open.splice(i, 1);\n\trestackOpenImporters(reg);\n\treg.listeners.slice().forEach(function (fn) { fn(); });\n}\n\nfunction isBlockedByOpenImporter(entry) {\n\tconst reg = openImporters();\n\treturn reg.open.length > 0 && reg.open.indexOf(entry) < 0;\n}\n\nfunction subscribeOpenImporters(fn) {\n\tconst reg = openImporters();\n\treg.listeners.push(fn);\n\treturn function () {\n\t\tconst i = reg.listeners.indexOf(fn);\n\t\tif (i >= 0) reg.listeners.splice(i, 1);\n\t};\n}\n\nexport class CSVBoxButton extends Component {\n\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.holder = React.createRef();\n\t\tthis.openModal = this.openModal.bind(this);\n\t\tthis.openModalWithFile = this.openModalWithFile.bind(this);\n\t\tthis.lifecycle = createModalLifecycle();\n\t\tthis.messageGate = createMessageGate();\n\t\tthis.importTracker = createImportTracker();\n\t\tthis.isModalShown = false;\n\t\tthis.isReady = false;\n\t\tthis.pendingFile = null;\n\t\tthis.uuid = generateUuid();\n\t\tthis.state = {\n\t\t\tisLoading: true,\n\t\t\t// True while a different importer on the page is open: the button stays disabled.\n\t\t\tblocked: false\n\t\t};\n\t\tthis.iframe = null;\n\t\tthis.registryEntry = { getHolder: () => this.holder.current };\n\t\tthis.fileSender = createFileSender({\n\t\t\tgetIframe: () => this.iframe,\n\t\t\tgetToken: () => this.uuid,\n\t\t\tgetTargetOrigin: () => this.targetOrigin,\n\t\t\tgetBaseDomain: () => this.baseDomain,\n\t\t\ttakeFile: () => {\n\t\t\t\tconst file = this.pendingFile;\n\t\t\t\tthis.pendingFile = null;\n\t\t\t\treturn file;\n\t\t\t},\n\t\t\tonSent: () => this.startFileAckTimer()\n\t\t});\n\t}\n\n\tcomponentDidMount() {\n\t\tthis.syncBlocked();\n\t\tthis.unsubscribeOpenImporters = subscribeOpenImporters(() => this.syncBlocked());\n\t\tconst { lazy } = this.props;\n\t\tif (!lazy && !this.iframe) {\n\t\t\tthis.initImporter();\n\t\t} else if (lazy) {\n\t\t\tthis.enableInitiator();\n\t\t}\n\t}\n\n\tinitImporter() {\n\t\tconst {\n\t\t\tloadStarted, user, dynamicColumns, options, onReady, onImport,\n\t\t\tonSubmit, onClose, licenseKey, dataLocation, customDomain,\n\t\t\tlanguage, environment, theme\n\t\t} = this.props;\n\n\t\tloadStarted?.();\n\n\t\tconst iframeUrl = buildImportUrl(\n\t\t\t{ licenseKey, customDomain, dataLocation, language, theme, environment },\n\t\t\t\"react\",\n\t\t\tversion\n\t\t);\n\n\t\t// Default place to send the file. A file is only ever sent to a named origin, never \"*\".\n\t\tthis.targetOrigin = new URL(iframeUrl).origin;\n\n\t\t// Data-location sheets redirect to another host, so the iframe origin can differ from\n\t\t// targetOrigin. We use this domain to check the real origin before trusting it.\n\t\tthis.baseDomain = customDomain || \"app.csvbox.io\";\n\t\tthis.fileSender.reset();\n\n\t\tconst handleModalClosed = () => {\n\t\t\tif (this.importTracker.isInFlight()) {\n\t\t\t\t// Closed after submitting and before the result arrived: keep the iframe and its\n\t\t\t\t// listener so the late result still reaches onImport. It is removed once that\n\t\t\t\t// result has been delivered (see below), so the next open is a fresh load.\n\t\t\t\tif (this.holder.current) {\n\t\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t}\n\t\t\t\tthis.lifecycle.markHidden();\n\t\t\t\tthis.isModalShown = false;\n\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\tunregisterOpenImporter(this.registryEntry);\n\t\t\t\tonClose?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.destroyImporter();\n\t\t\tonClose?.();\n\t\t};\n\n\t\t// Called after the result of an import has been delivered. If the modal was closed in the\n\t\t// meantime the iframe was only hidden, so remove it now.\n\t\tconst finishImport = (ended) => {\n\t\t\tif (ended && !this.isModalShown && this.iframe) {\n\t\t\t\tthis.destroyImporter();\n\t\t\t}\n\t\t};\n\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t}\n\n\t\tthis.messageListener = (event) => {\n\t\t\tconst legacy = classifyLegacyMessage(event.data);\n\t\t\tif (legacy) {\n\t\t\t\t// Legacy messages carry no token, so the only way to tell which importer sent one is\n\t\t\t\t// its window. Ignore those that came from another instance's iframe (or anywhere else).\n\t\t\t\tif (!this.iframe || event.source !== this.iframe.contentWindow) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// A newer importer sends the typed message as well; act on that one only.\n\t\t\t\tif (!this.messageGate.allowLegacy()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst ended = this.importTracker.observe(legacy);\n\t\t\t\tif (legacy.type === \"mainModalHidden\") {\n\t\t\t\t\thandleModalClosed();\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadSuccessful\") {\n\t\t\t\t\tonImport(true);\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadFailed\") {\n\t\t\t\t\tonImport(false);\n\t\t\t\t}\n\t\t\t\tfinishImport(ended);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set-file handshake messages. The shared core does not classify these, so they are\n\t\t\t// read here, behind the same unique_token check the core applies.\n\t\t\tconst raw = event.data;\n\t\t\tif (raw && typeof raw === \"object\" && raw.data && raw.data.unique_token == this.uuid) {\n\t\t\t\tthis.fileSender.learnOrigin(event);\n\n\t\t\t\tif (raw.type === \"csvbox-set-file-rejected\" && raw.data.reason === \"not-a-file\") {\n\t\t\t\t\t// Reply to our probe (it has no file). It only tells us the origin, so do nothing.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (raw.type === \"csvbox-modal-shown\") {\n\t\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\t\tregisterOpenImporter(this.registryEntry);\n\t\t\t\t\t// What the file path in openModal() is waiting for. display as well as\n\t\t\t\t\t// pointer-events: a second file declined while the first was still opening the\n\t\t\t\t\t// modal has put the holder away in the meantime.\n\t\t\t\t\tthis.isModalShown = true;\n\t\t\t\t\tthis.lifecycle.requestOpen();\n\t\t\t\t\tif (this.holder.current) {\n\t\t\t\t\t\tthis.holder.current.style.display = 'block';\n\t\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (raw.type === \"csvbox-set-file-rejected\") {\n\t\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\t\t// The importer has the file and will not take it. Put the holder away only if the\n\t\t\t\t\t// modal was never confirmed up: a file declined while it is open (an import past\n\t\t\t\t\t// the upload step, a fade-out under way) leaves that modal where it is, and its\n\t\t\t\t\t// own 'csvbox-modal-hidden' will put the holder away when it closes.\n\t\t\t\t\tif (!this.isModalShown && this.holder.current) {\n\t\t\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t\t\tunregisterOpenImporter(this.registryEntry);\n\t\t\t\t\t}\n\t\t\t\t\tconsole.warn(\"[csvbox] importer declined the supplied file: \" + raw.data.reason);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst message = classifyStructuredMessage(event.data, this.uuid);\n\t\t\tif (!message) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.messageGate.markTyped();\n\t\t\tconst ended = this.importTracker.observe(message);\n\n\t\t\tif (message.type === \"data-on-submit\") {\n\t\t\t\tonSubmit?.(message.metadata);\n\t\t\t} else if (message.type === \"data-push-status\") {\n\t\t\t\tonImport(message.success, message.metadata);\n\t\t\t} else if (message.type === \"csvbox-modal-hidden\") {\n\t\t\t\thandleModalClosed();\n\t\t\t} else if (message.type === \"csvbox-upload-successful\") {\n\t\t\t\tonImport(true);\n\t\t\t} else if (message.type === \"csvbox-upload-failed\") {\n\t\t\t\tonImport(false);\n\t\t\t}\n\t\t\tfinishImport(ended);\n\t\t};\n\n\t\twindow.addEventListener(\"message\", this.messageListener, false);\n\n\t\tthis.uuid = generateUuid();\n\t\tthis.messageGate.reset();\n\t\tthis.importTracker.reset();\n\n\t\tconst iframe = document.createElement(\"iframe\");\n\t\tthis.iframe = iframe;\n\t\tiframe.setAttribute(\"src\", iframeUrl);\n\t\tiframe.setAttribute(\"allow\", \"clipboard-read; clipboard-write *\");\n\t\tiframe.frameBorder = 0;\n\t\tiframe.classList.add('csvbox-iframe');\n\t\tObject.assign(iframe.style, IFRAME_STYLE);\n\n\t\tiframe.onload = () => {\n\t\t\tthis.isReady = true;\n\t\t\tthis.enableInitiator();\n\t\t\tiframe.contentWindow.postMessage(buildInitPayload(user, dynamicColumns, options, this.uuid), \"*\");\n\t\t\tonReady?.();\n\t\t\tif (this.lifecycle.markReady()) {\n\t\t\t\tthis.openModal();\n\t\t\t}\n\t\t};\n\n\t\tthis.holder.current.appendChild(iframe);\n\t}\n\n\topenModal() {\n\t\t// Counts as open from the moment it is requested, so the other buttons are disabled while\n\t\t// this importer is still loading, and so it is stacked above any importer opened earlier.\n\t\tregisterOpenImporter(this.registryEntry);\n\t\tif (!this.iframe) {\n\t\t\tthis.lifecycle.requestOpen();\n\t\t\tthis.initImporter();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.pendingFile) {\n\t\t\tif (!this.isReady) {\n\t\t\t\t// Deferred: onload's markReady() calls openModal() again once the iframe is up.\n\t\t\t\tthis.lifecycle.requestOpen();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The importer opens its own modal once it has the file, so that it can inject on\n\t\t\t// 'shown.bs.modal'. Sending 'openModal' as well would race that.\n\t\t\t//\n\t\t\t// It can also decline: wrong step, an import file URL configured on the sheet, or\n\t\t\t// an importer too old to know the message at all. So the holder goes up\n\t\t\t// click-through and stays that way until 'csvbox-modal-shown' confirms the modal\n\t\t\t// is really up. It covers the viewport at z-index 2147483647 and the importer\n\t\t\t// renders transparent with its modal closed, so arming it on an unanswered message\n\t\t\t// leaves an invisible sheet over the host page eating every click.\n\t\t\t//\n\t\t\t// display:block regardless, so the iframe lays out and animates normally; only\n\t\t\t// pointer-events is held back. isModalShown likewise waits for the confirmation,\n\t\t\t// or a declined file would latch the importer shut for good.\n\t\t\tthis.holder.current.style.pointerEvents = 'none';\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t\tthis.fileSender.send();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.lifecycle.requestOpen()) {\n\t\t\tthis.isModalShown = true;\n\t\t\tthis.iframe.contentWindow.postMessage('openModal', '*');\n\t\t\t// Explicit: a previously declined file leaves the holder click-through.\n\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t}\n\t}\n\n\t/**\n\t * Open the importer on a File the host page already has, instead of the file picker.\n\t *\n\t * Reachable two ways: a ref on the component (`ref.current.openModalWithFile(file)`), or\n\t * the third argument handed to the `render` prop.\n\t *\n\t * The File crosses to the iframe by structured clone, so the importer receives the real\n\t * object and applies its own extension, worksheet and size rules to it -- this does not\n\t * bypass any of them. Pass a File; a Blob has no name for the importer to read an\n\t * extension from.\n\t */\n\topenModalWithFile(file) {\n\t\t// window.File, not a bare File: eslint-config-standard declares only window, document\n\t\t// and navigator as browser globals, so a bare File is a no-undef error here.\n\t\tif (!window.File || !(file instanceof window.File)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pendingFile = file;\n\n\t\t// Already open: hand it over now rather than holding it for the next open. The importer\n\t\t// takes it only while it is still on the upload step, and ignores it once the user has a\n\t\t// dataset and a mapping in progress.\n\t\tif (this.isModalShown && this.iframe && this.isReady) {\n\t\t\tthis.fileSender.send();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.openModal();\n\t}\n\n\tclearProbeTimer() {\n\t\tthis.clearFileAckTimer();\n\t\tthis.fileSender.reset();\n\t}\n\n\tstartFileAckTimer() {\n\t\tthis.clearFileAckTimer();\n\t\tthis.fileAckTimer = setTimeout(() => {\n\t\t\tthis.fileAckTimer = null;\n\t\t\tthis.giveUpOnFile();\n\t\t}, FILE_ACK_TIMEOUT_MS);\n\t}\n\n\tclearFileAckTimer() {\n\t\tif (this.fileAckTimer) {\n\t\t\tclearTimeout(this.fileAckTimer);\n\t\t\tthis.fileAckTimer = null;\n\t\t}\n\t}\n\n\t// The importer never confirmed the file it was sent (an origin we do not trust, or an importer too\n\t// old to know the message). Without this the holder would stay up, invisible and click-through,\n\t// and the other instances' buttons would stay disabled for good.\n\tgiveUpOnFile() {\n\t\tif (this.isModalShown) {\n\t\t\treturn;\n\t\t}\n\t\tconst holder = this.holder.current;\n\t\tif (holder) {\n\t\t\tholder.style.display = 'none';\n\t\t\tholder.style.pointerEvents = 'auto';\n\t\t}\n\t\tunregisterOpenImporter(this.registryEntry);\n\t\tconsole.warn(\"[csvbox] the importer did not respond to the supplied file\");\n\t}\n\n\t// Puts the importer away: the next open builds a new iframe with a new token.\n\tdestroyImporter() {\n\t\tif (this.holder.current) {\n\t\t\tthis.holder.current.style.display = 'none';\n\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\tthis.holder.current.innerHTML = '';\n\t\t}\n\t\tthis.lifecycle.markClosed();\n\t\tthis.isModalShown = false;\n\t\tthis.isReady = false;\n\t\tthis.iframe = null;\n\t\tthis.messageGate.reset();\n\t\tthis.importTracker.reset();\n\t\t// A new iframe is built on the next open, so the origin is learned again.\n\t\tthis.clearProbeTimer();\n\t\tunregisterOpenImporter(this.registryEntry);\n\t}\n\n\t// Everything the component set up outside React. Leaves the instance as it was before its first\n\t// mount, so a remount (React 18 StrictMode in development) initialises it again.\n\tteardown() {\n\t\tthis.destroyImporter();\n\t\tif (this.unsubscribeOpenImporters) {\n\t\t\tthis.unsubscribeOpenImporters();\n\t\t\tthis.unsubscribeOpenImporters = null;\n\t\t}\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t\tthis.messageListener = null;\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.teardown();\n\t}\n\n\tsyncBlocked() {\n\t\tconst blocked = isBlockedByOpenImporter(this.registryEntry);\n\t\tif (blocked !== this.state.blocked) {\n\t\t\tthis.setState({ blocked });\n\t\t}\n\t}\n\n\tenableInitiator() {\n\t\tthis.setState({\n\t\t\tisLoading: false\n\t\t});\n\t}\n\n\trender() {\n\t\tif (this.props.render) {\n\t\t\treturn (\n\t\t\t\t<div>\n\t\t\t\t\t{this.props.render(this.openModal, this.state.isLoading || this.state.blocked, this.openModalWithFile)}\n\t\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t<button disabled={this.state.isLoading || this.state.blocked} onClick={this.openModal} data-csvbox-initator data-csvbox-token={this.uuid}>{this.props.children}</button>\n\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t</div>\n\t\t)\n\t}\n}\n\nexport default CSVBoxButton;\n"],"names":["FILE_ACK_TIMEOUT_MS","OPEN_IMPORTERS_KEY","TOP_Z_INDEX","openImporters","window","open","listeners","restackOpenImporters","reg","forEach","entry","i","holder","getHolder","style","zIndex","String","length","registerOpenImporter","indexOf","push","slice","fn","unregisterOpenImporter","splice","isBlockedByOpenImporter","subscribeOpenImporters","CSVBoxButton","props","React","createRef","openModal","bind","openModalWithFile","lifecycle","createModalLifecycle","messageGate","createMessageGate","importTracker","createImportTracker","isModalShown","isReady","pendingFile","uuid","generateUuid","state","isLoading","blocked","iframe","registryEntry","current","fileSender","createFileSender","getIframe","getToken","getTargetOrigin","targetOrigin","getBaseDomain","baseDomain","takeFile","file","onSent","startFileAckTimer","componentDidMount","syncBlocked","unsubscribeOpenImporters","lazy","initImporter","enableInitiator","loadStarted","user","dynamicColumns","options","onReady","onImport","onSubmit","onClose","licenseKey","dataLocation","customDomain","language","environment","theme","iframeUrl","buildImportUrl","version","URL","origin","reset","handleModalClosed","isInFlight","display","pointerEvents","markHidden","clearFileAckTimer","destroyImporter","finishImport","ended","messageListener","removeEventListener","event","legacy","classifyLegacyMessage","data","source","contentWindow","allowLegacy","observe","type","raw","unique_token","learnOrigin","reason","requestOpen","console","warn","message","classifyStructuredMessage","markTyped","metadata","success","addEventListener","document","createElement","setAttribute","frameBorder","classList","add","Object","assign","IFRAME_STYLE","onload","postMessage","buildInitPayload","markReady","appendChild","send","File","clearProbeTimer","fileAckTimer","setTimeout","giveUpOnFile","clearTimeout","innerHTML","markClosed","teardown","componentWillUnmount","setState","render","HOLDER_STYLE","children","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAMA,mBAAmB,GAAG,IAA5B;AAOA,IAAMC,kBAAkB,GAAG,uBAA3B;AACA,IAAMC,WAAW,GAAG,UAApB;;AAEA,SAASC,aAAT,GAAyB;AACxB,MAAI,CAACC,MAAM,CAACH,kBAAD,CAAX,EAAiCG,MAAM,CAACH,kBAAD,CAAN,GAA6B;AAAEI,IAAAA,IAAI,EAAE,EAAR;AAAY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WE,OAArE,EAA8E,KAAKd,iBAAnF,CADF,eAECJ;AAAK,QAAA,GAAG,EAAE,KAAKjB,MAAf;AAAuB,QAAA,KAAK,EAAEyI;AAA9B,QAFD,CADD;AAMA;;AAED,wBACCxH,uDACCA;AAAQ,MAAA,QAAQ,EAAE,KAAKgB,KAAL,CAAWC,SAAX,IAAwB,KAAKD,KAAL,CAAWE,OAArD;AAA8D,MAAA,OAAO,EAAE,KAAKhB,SAA5E;AAAuF,kCAAvF;AAA4G,2BAAmB,KAAKY;AAApI,OAA2I,KAAKf,KAAL,CAAW0H,QAAtJ,CADD,eAECzH;AAAK,MAAA,GAAG,EAAE,KAAKjB,MAAf;AAAuB,MAAA,KAAK,EAAEyI;AAA9B,MAFD,CADD;AAMA,GAvYF;;AAAA;AAAA,EAAkCE,eAAlC;;;;;"}
|
package/dist/index.modern.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { buildImportUrl, classifyLegacyMessage, classifyStructuredMessage, generateUuid, IFRAME_STYLE, buildInitPayload, HOLDER_STYLE, createModalLifecycle, createFileSender } from '@sumit_yewale/adapter-core';
|
|
2
|
+
import { buildImportUrl, classifyLegacyMessage, classifyStructuredMessage, generateUuid, IFRAME_STYLE, buildInitPayload, HOLDER_STYLE, createModalLifecycle, createMessageGate, createImportTracker, createFileSender } from '@sumit_yewale/adapter-core';
|
|
3
3
|
|
|
4
4
|
function _inheritsLoose(subClass, superClass) {
|
|
5
5
|
subClass.prototype = Object.create(superClass.prototype);
|
|
@@ -25,7 +25,7 @@ function _assertThisInitialized(self) {
|
|
|
25
25
|
return self;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
var version = "1.1.
|
|
28
|
+
var version = "1.1.18-fix.1";
|
|
29
29
|
|
|
30
30
|
var FILE_ACK_TIMEOUT_MS = 8000;
|
|
31
31
|
var OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';
|
|
@@ -92,6 +92,8 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
92
92
|
_this.openModal = _this.openModal.bind(_assertThisInitialized(_this));
|
|
93
93
|
_this.openModalWithFile = _this.openModalWithFile.bind(_assertThisInitialized(_this));
|
|
94
94
|
_this.lifecycle = createModalLifecycle();
|
|
95
|
+
_this.messageGate = createMessageGate();
|
|
96
|
+
_this.importTracker = createImportTracker();
|
|
95
97
|
_this.isModalShown = false;
|
|
96
98
|
_this.isReady = false;
|
|
97
99
|
_this.pendingFile = null;
|
|
@@ -181,24 +183,34 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
181
183
|
this.fileSender.reset();
|
|
182
184
|
|
|
183
185
|
var handleModalClosed = function handleModalClosed() {
|
|
184
|
-
if (_this3.
|
|
185
|
-
_this3.holder.current
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
if (_this3.importTracker.isInFlight()) {
|
|
187
|
+
if (_this3.holder.current) {
|
|
188
|
+
_this3.holder.current.style.display = 'none';
|
|
189
|
+
_this3.holder.current.style.pointerEvents = 'auto';
|
|
190
|
+
}
|
|
189
191
|
|
|
190
|
-
|
|
192
|
+
_this3.lifecycle.markHidden();
|
|
191
193
|
|
|
192
|
-
|
|
193
|
-
_this3.isReady = false;
|
|
194
|
-
_this3.iframe = null;
|
|
194
|
+
_this3.isModalShown = false;
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
_this3.clearFileAckTimer();
|
|
197
|
+
|
|
198
|
+
unregisterOpenImporter(_this3.registryEntry);
|
|
199
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
_this3.destroyImporter();
|
|
197
204
|
|
|
198
|
-
unregisterOpenImporter(_this3.registryEntry);
|
|
199
205
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
200
206
|
};
|
|
201
207
|
|
|
208
|
+
var finishImport = function finishImport(ended) {
|
|
209
|
+
if (ended && !_this3.isModalShown && _this3.iframe) {
|
|
210
|
+
_this3.destroyImporter();
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
202
214
|
if (this.messageListener) {
|
|
203
215
|
window.removeEventListener("message", this.messageListener, false);
|
|
204
216
|
}
|
|
@@ -211,6 +223,12 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
211
223
|
return;
|
|
212
224
|
}
|
|
213
225
|
|
|
226
|
+
if (!_this3.messageGate.allowLegacy()) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var _ended = _this3.importTracker.observe(legacy);
|
|
231
|
+
|
|
214
232
|
if (legacy.type === "mainModalHidden") {
|
|
215
233
|
handleModalClosed();
|
|
216
234
|
}
|
|
@@ -223,6 +241,7 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
223
241
|
onImport(false);
|
|
224
242
|
}
|
|
225
243
|
|
|
244
|
+
finishImport(_ended);
|
|
226
245
|
return;
|
|
227
246
|
}
|
|
228
247
|
|
|
@@ -271,6 +290,10 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
271
290
|
return;
|
|
272
291
|
}
|
|
273
292
|
|
|
293
|
+
_this3.messageGate.markTyped();
|
|
294
|
+
|
|
295
|
+
var ended = _this3.importTracker.observe(message);
|
|
296
|
+
|
|
274
297
|
if (message.type === "data-on-submit") {
|
|
275
298
|
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(message.metadata);
|
|
276
299
|
} else if (message.type === "data-push-status") {
|
|
@@ -282,10 +305,14 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
282
305
|
} else if (message.type === "csvbox-upload-failed") {
|
|
283
306
|
onImport(false);
|
|
284
307
|
}
|
|
308
|
+
|
|
309
|
+
finishImport(ended);
|
|
285
310
|
};
|
|
286
311
|
|
|
287
312
|
window.addEventListener("message", this.messageListener, false);
|
|
288
313
|
this.uuid = generateUuid();
|
|
314
|
+
this.messageGate.reset();
|
|
315
|
+
this.importTracker.reset();
|
|
289
316
|
var iframe = document.createElement("iframe");
|
|
290
317
|
this.iframe = iframe;
|
|
291
318
|
iframe.setAttribute("src", iframeUrl);
|
|
@@ -393,9 +420,25 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
393
420
|
console.warn("[csvbox] the importer did not respond to the supplied file");
|
|
394
421
|
};
|
|
395
422
|
|
|
396
|
-
_proto.
|
|
423
|
+
_proto.destroyImporter = function destroyImporter() {
|
|
424
|
+
if (this.holder.current) {
|
|
425
|
+
this.holder.current.style.display = 'none';
|
|
426
|
+
this.holder.current.style.pointerEvents = 'auto';
|
|
427
|
+
this.holder.current.innerHTML = '';
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
this.lifecycle.markClosed();
|
|
431
|
+
this.isModalShown = false;
|
|
432
|
+
this.isReady = false;
|
|
433
|
+
this.iframe = null;
|
|
434
|
+
this.messageGate.reset();
|
|
435
|
+
this.importTracker.reset();
|
|
397
436
|
this.clearProbeTimer();
|
|
398
437
|
unregisterOpenImporter(this.registryEntry);
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
_proto.teardown = function teardown() {
|
|
441
|
+
this.destroyImporter();
|
|
399
442
|
|
|
400
443
|
if (this.unsubscribeOpenImporters) {
|
|
401
444
|
this.unsubscribeOpenImporters();
|
|
@@ -408,6 +451,10 @@ var CSVBoxButton = /*#__PURE__*/function (_Component) {
|
|
|
408
451
|
}
|
|
409
452
|
};
|
|
410
453
|
|
|
454
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
455
|
+
this.teardown();
|
|
456
|
+
};
|
|
457
|
+
|
|
411
458
|
_proto.syncBlocked = function syncBlocked() {
|
|
412
459
|
var blocked = isBlockedByOpenImporter(this.registryEntry);
|
|
413
460
|
|
package/dist/index.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/index.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { version } from '../package.json';\nimport {\n\tHOLDER_STYLE,\n\tIFRAME_STYLE,\n\tbuildImportUrl,\n\tgenerateUuid,\n\tbuildInitPayload,\n\tcreateModalLifecycle,\n\tcreateFileSender,\n\tclassifyStructuredMessage,\n\tclassifyLegacyMessage\n} from '@sumit_yewale/adapter-core';\n\n// How long we wait for the importer to confirm a file it was sent before giving up on it.\nconst FILE_ACK_TIMEOUT_MS = 8000;\n\n// Page-wide record of the importers that are open or opening, shared by every CSVBox adapter\n// on the page (it lives on window so separate copies of an adapter see the same list). It does\n// two things: the newest importer is stacked on top (every holder is fixed, full screen and\n// z-index 2147483647, so equal z-indexes would leave the one that comes first in the DOM on\n// top), and the other instances learn that an importer is open so they can disable their button.\nconst OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';\nconst TOP_Z_INDEX = 2147483647;\n\nfunction openImporters() {\n\tif (!window[OPEN_IMPORTERS_KEY]) window[OPEN_IMPORTERS_KEY] = { open: [], listeners: [] };\n\treturn window[OPEN_IMPORTERS_KEY];\n}\n\nfunction restackOpenImporters(reg) {\n\treg.open.forEach(function (entry, i) {\n\t\tconst holder = entry.getHolder();\n\t\tif (holder) holder.style.zIndex = String(TOP_Z_INDEX - (reg.open.length - 1 - i));\n\t});\n}\n\nfunction registerOpenImporter(entry) {\n\tconst reg = openImporters();\n\tif (reg.open.indexOf(entry) >= 0) return;\n\treg.open.push(entry);\n\trestackOpenImporters(reg);\n\treg.listeners.slice().forEach(function (fn) { fn(); });\n}\n\nfunction unregisterOpenImporter(entry) {\n\tconst reg = openImporters();\n\tconst i = reg.open.indexOf(entry);\n\tif (i < 0) return;\n\treg.open.splice(i, 1);\n\trestackOpenImporters(reg);\n\treg.listeners.slice().forEach(function (fn) { fn(); });\n}\n\nfunction isBlockedByOpenImporter(entry) {\n\tconst reg = openImporters();\n\treturn reg.open.length > 0 && reg.open.indexOf(entry) < 0;\n}\n\nfunction subscribeOpenImporters(fn) {\n\tconst reg = openImporters();\n\treg.listeners.push(fn);\n\treturn function () {\n\t\tconst i = reg.listeners.indexOf(fn);\n\t\tif (i >= 0) reg.listeners.splice(i, 1);\n\t};\n}\n\nexport class CSVBoxButton extends Component {\n\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.holder = React.createRef();\n\t\tthis.openModal = this.openModal.bind(this);\n\t\tthis.openModalWithFile = this.openModalWithFile.bind(this);\n\t\tthis.lifecycle = createModalLifecycle();\n\t\tthis.isModalShown = false;\n\t\tthis.isReady = false;\n\t\tthis.pendingFile = null;\n\t\tthis.uuid = generateUuid();\n\t\tthis.state = {\n\t\t\tisLoading: true,\n\t\t\t// True while a different importer on the page is open: the button stays disabled.\n\t\t\tblocked: false\n\t\t};\n\t\tthis.iframe = null;\n\t\tthis.registryEntry = { getHolder: () => this.holder.current };\n\t\tthis.fileSender = createFileSender({\n\t\t\tgetIframe: () => this.iframe,\n\t\t\tgetToken: () => this.uuid,\n\t\t\tgetTargetOrigin: () => this.targetOrigin,\n\t\t\tgetBaseDomain: () => this.baseDomain,\n\t\t\ttakeFile: () => {\n\t\t\t\tconst file = this.pendingFile;\n\t\t\t\tthis.pendingFile = null;\n\t\t\t\treturn file;\n\t\t\t},\n\t\t\tonSent: () => this.startFileAckTimer()\n\t\t});\n\t}\n\n\tcomponentDidMount() {\n\t\tthis.syncBlocked();\n\t\tthis.unsubscribeOpenImporters = subscribeOpenImporters(() => this.syncBlocked());\n\t\tconst { lazy } = this.props;\n\t\tif (!lazy && !this.iframe) {\n\t\t\tthis.initImporter();\n\t\t} else if (lazy) {\n\t\t\tthis.enableInitiator();\n\t\t}\n\t}\n\n\tinitImporter() {\n\t\tconst {\n\t\t\tloadStarted, user, dynamicColumns, options, onReady, onImport,\n\t\t\tonSubmit, onClose, licenseKey, dataLocation, customDomain,\n\t\t\tlanguage, environment, theme\n\t\t} = this.props;\n\n\t\tloadStarted?.();\n\n\t\tconst iframeUrl = buildImportUrl(\n\t\t\t{ licenseKey, customDomain, dataLocation, language, theme, environment },\n\t\t\t\"react\",\n\t\t\tversion\n\t\t);\n\n\t\t// Default place to send the file. A file is only ever sent to a named origin, never \"*\".\n\t\tthis.targetOrigin = new URL(iframeUrl).origin;\n\n\t\t// Data-location sheets redirect to another host, so the iframe origin can differ from\n\t\t// targetOrigin. We use this domain to check the real origin before trusting it.\n\t\tthis.baseDomain = customDomain || \"app.csvbox.io\";\n\t\tthis.fileSender.reset();\n\n\t\tconst handleModalClosed = () => {\n\t\t\tif (this.holder.current) {\n\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\tthis.holder.current.innerHTML = '';\n\t\t\t}\n\t\t\tthis.lifecycle.markClosed();\n\t\t\tthis.isModalShown = false;\n\t\t\tthis.isReady = false;\n\t\t\tthis.iframe = null;\n\t\t\t// A new iframe is built on the next open, so the origin is learned again.\n\t\t\tthis.clearProbeTimer();\n\t\t\tunregisterOpenImporter(this.registryEntry);\n\t\t\tonClose?.();\n\t\t};\n\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t}\n\n\t\tthis.messageListener = (event) => {\n\t\t\tconst legacy = classifyLegacyMessage(event.data);\n\t\t\tif (legacy) {\n\t\t\t\t// Legacy messages carry no token, so the only way to tell which importer sent one is\n\t\t\t\t// its window. Ignore those that came from another instance's iframe (or anywhere else).\n\t\t\t\tif (!this.iframe || event.source !== this.iframe.contentWindow) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"mainModalHidden\") {\n\t\t\t\t\thandleModalClosed();\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadSuccessful\") {\n\t\t\t\t\tonImport(true);\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadFailed\") {\n\t\t\t\t\tonImport(false);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set-file handshake messages. The shared core does not classify these, so they are\n\t\t\t// read here, behind the same unique_token check the core applies.\n\t\t\tconst raw = event.data;\n\t\t\tif (raw && typeof raw === \"object\" && raw.data && raw.data.unique_token == this.uuid) {\n\t\t\t\tthis.fileSender.learnOrigin(event);\n\n\t\t\t\tif (raw.type === \"csvbox-set-file-rejected\" && raw.data.reason === \"not-a-file\") {\n\t\t\t\t\t// Reply to our probe (it has no file). It only tells us the origin, so do nothing.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (raw.type === \"csvbox-modal-shown\") {\n\t\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\t\tregisterOpenImporter(this.registryEntry);\n\t\t\t\t\t// What the file path in openModal() is waiting for. display as well as\n\t\t\t\t\t// pointer-events: a second file declined while the first was still opening the\n\t\t\t\t\t// modal has put the holder away in the meantime.\n\t\t\t\t\tthis.isModalShown = true;\n\t\t\t\t\tthis.lifecycle.requestOpen();\n\t\t\t\t\tif (this.holder.current) {\n\t\t\t\t\t\tthis.holder.current.style.display = 'block';\n\t\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (raw.type === \"csvbox-set-file-rejected\") {\n\t\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\t\t// The importer has the file and will not take it. Put the holder away only if the\n\t\t\t\t\t// modal was never confirmed up: a file declined while it is open (an import past\n\t\t\t\t\t// the upload step, a fade-out under way) leaves that modal where it is, and its\n\t\t\t\t\t// own 'csvbox-modal-hidden' will put the holder away when it closes.\n\t\t\t\t\tif (!this.isModalShown && this.holder.current) {\n\t\t\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t\t\tunregisterOpenImporter(this.registryEntry);\n\t\t\t\t\t}\n\t\t\t\t\tconsole.warn(\"[csvbox] importer declined the supplied file: \" + raw.data.reason);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst message = classifyStructuredMessage(event.data, this.uuid);\n\t\t\tif (!message) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (message.type === \"data-on-submit\") {\n\t\t\t\tonSubmit?.(message.metadata);\n\t\t\t} else if (message.type === \"data-push-status\") {\n\t\t\t\tonImport(message.success, message.metadata);\n\t\t\t} else if (message.type === \"csvbox-modal-hidden\") {\n\t\t\t\thandleModalClosed();\n\t\t\t} else if (message.type === \"csvbox-upload-successful\") {\n\t\t\t\tonImport(true);\n\t\t\t} else if (message.type === \"csvbox-upload-failed\") {\n\t\t\t\tonImport(false);\n\t\t\t}\n\t\t};\n\n\t\twindow.addEventListener(\"message\", this.messageListener, false);\n\n\t\tthis.uuid = generateUuid();\n\n\t\tconst iframe = document.createElement(\"iframe\");\n\t\tthis.iframe = iframe;\n\t\tiframe.setAttribute(\"src\", iframeUrl);\n\t\tiframe.setAttribute(\"allow\", \"clipboard-read; clipboard-write *\");\n\t\tiframe.frameBorder = 0;\n\t\tiframe.classList.add('csvbox-iframe');\n\t\tObject.assign(iframe.style, IFRAME_STYLE);\n\n\t\tiframe.onload = () => {\n\t\t\tthis.isReady = true;\n\t\t\tthis.enableInitiator();\n\t\t\tiframe.contentWindow.postMessage(buildInitPayload(user, dynamicColumns, options, this.uuid), \"*\");\n\t\t\tonReady?.();\n\t\t\tif (this.lifecycle.markReady()) {\n\t\t\t\tthis.openModal();\n\t\t\t}\n\t\t};\n\n\t\tthis.holder.current.appendChild(iframe);\n\t}\n\n\topenModal() {\n\t\t// Counts as open from the moment it is requested, so the other buttons are disabled while\n\t\t// this importer is still loading, and so it is stacked above any importer opened earlier.\n\t\tregisterOpenImporter(this.registryEntry);\n\t\tif (!this.iframe) {\n\t\t\tthis.lifecycle.requestOpen();\n\t\t\tthis.initImporter();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.pendingFile) {\n\t\t\tif (!this.isReady) {\n\t\t\t\t// Deferred: onload's markReady() calls openModal() again once the iframe is up.\n\t\t\t\tthis.lifecycle.requestOpen();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The importer opens its own modal once it has the file, so that it can inject on\n\t\t\t// 'shown.bs.modal'. Sending 'openModal' as well would race that.\n\t\t\t//\n\t\t\t// It can also decline: wrong step, an import file URL configured on the sheet, or\n\t\t\t// an importer too old to know the message at all. So the holder goes up\n\t\t\t// click-through and stays that way until 'csvbox-modal-shown' confirms the modal\n\t\t\t// is really up. It covers the viewport at z-index 2147483647 and the importer\n\t\t\t// renders transparent with its modal closed, so arming it on an unanswered message\n\t\t\t// leaves an invisible sheet over the host page eating every click.\n\t\t\t//\n\t\t\t// display:block regardless, so the iframe lays out and animates normally; only\n\t\t\t// pointer-events is held back. isModalShown likewise waits for the confirmation,\n\t\t\t// or a declined file would latch the importer shut for good.\n\t\t\tthis.holder.current.style.pointerEvents = 'none';\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t\tthis.fileSender.send();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.lifecycle.requestOpen()) {\n\t\t\tthis.isModalShown = true;\n\t\t\tthis.iframe.contentWindow.postMessage('openModal', '*');\n\t\t\t// Explicit: a previously declined file leaves the holder click-through.\n\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t}\n\t}\n\n\t/**\n\t * Open the importer on a File the host page already has, instead of the file picker.\n\t *\n\t * Reachable two ways: a ref on the component (`ref.current.openModalWithFile(file)`), or\n\t * the third argument handed to the `render` prop.\n\t *\n\t * The File crosses to the iframe by structured clone, so the importer receives the real\n\t * object and applies its own extension, worksheet and size rules to it -- this does not\n\t * bypass any of them. Pass a File; a Blob has no name for the importer to read an\n\t * extension from.\n\t */\n\topenModalWithFile(file) {\n\t\t// window.File, not a bare File: eslint-config-standard declares only window, document\n\t\t// and navigator as browser globals, so a bare File is a no-undef error here.\n\t\tif (!window.File || !(file instanceof window.File)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pendingFile = file;\n\n\t\t// Already open: hand it over now rather than holding it for the next open. The importer\n\t\t// takes it only while it is still on the upload step, and ignores it once the user has a\n\t\t// dataset and a mapping in progress.\n\t\tif (this.isModalShown && this.iframe && this.isReady) {\n\t\t\tthis.fileSender.send();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.openModal();\n\t}\n\n\tclearProbeTimer() {\n\t\tthis.clearFileAckTimer();\n\t\tthis.fileSender.reset();\n\t}\n\n\tstartFileAckTimer() {\n\t\tthis.clearFileAckTimer();\n\t\tthis.fileAckTimer = setTimeout(() => {\n\t\t\tthis.fileAckTimer = null;\n\t\t\tthis.giveUpOnFile();\n\t\t}, FILE_ACK_TIMEOUT_MS);\n\t}\n\n\tclearFileAckTimer() {\n\t\tif (this.fileAckTimer) {\n\t\t\tclearTimeout(this.fileAckTimer);\n\t\t\tthis.fileAckTimer = null;\n\t\t}\n\t}\n\n\t// The importer never confirmed the file it was sent (an origin we do not trust, or an importer too\n\t// old to know the message). Without this the holder would stay up, invisible and click-through,\n\t// and the other instances' buttons would stay disabled for good.\n\tgiveUpOnFile() {\n\t\tif (this.isModalShown) {\n\t\t\treturn;\n\t\t}\n\t\tconst holder = this.holder.current;\n\t\tif (holder) {\n\t\t\tholder.style.display = 'none';\n\t\t\tholder.style.pointerEvents = 'auto';\n\t\t}\n\t\tunregisterOpenImporter(this.registryEntry);\n\t\tconsole.warn(\"[csvbox] the importer did not respond to the supplied file\");\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.clearProbeTimer();\n\t\tunregisterOpenImporter(this.registryEntry);\n\t\tif (this.unsubscribeOpenImporters) {\n\t\t\tthis.unsubscribeOpenImporters();\n\t\t\tthis.unsubscribeOpenImporters = null;\n\t\t}\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t\tthis.messageListener = null;\n\t\t}\n\t}\n\n\tsyncBlocked() {\n\t\tconst blocked = isBlockedByOpenImporter(this.registryEntry);\n\t\tif (blocked !== this.state.blocked) {\n\t\t\tthis.setState({ blocked });\n\t\t}\n\t}\n\n\tenableInitiator() {\n\t\tthis.setState({\n\t\t\tisLoading: false\n\t\t});\n\t}\n\n\trender() {\n\t\tif (this.props.render) {\n\t\t\treturn (\n\t\t\t\t<div>\n\t\t\t\t\t{this.props.render(this.openModal, this.state.isLoading || this.state.blocked, this.openModalWithFile)}\n\t\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t<button disabled={this.state.isLoading || this.state.blocked} onClick={this.openModal} data-csvbox-initator data-csvbox-token={this.uuid}>{this.props.children}</button>\n\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t</div>\n\t\t)\n\t}\n}\n\nexport default CSVBoxButton;\n"],"names":["FILE_ACK_TIMEOUT_MS","OPEN_IMPORTERS_KEY","TOP_Z_INDEX","openImporters","window","open","listeners","restackOpenImporters","reg","forEach","entry","i","holder","getHolder","style","zIndex","String","length","registerOpenImporter","indexOf","push","slice","fn","unregisterOpenImporter","splice","isBlockedByOpenImporter","subscribeOpenImporters","CSVBoxButton","props","React","createRef","openModal","bind","openModalWithFile","lifecycle","createModalLifecycle","isModalShown","isReady","pendingFile","uuid","generateUuid","state","isLoading","blocked","iframe","registryEntry","current","fileSender","createFileSender","getIframe","getToken","getTargetOrigin","targetOrigin","getBaseDomain","baseDomain","takeFile","file","onSent","startFileAckTimer","componentDidMount","syncBlocked","unsubscribeOpenImporters","lazy","initImporter","enableInitiator","loadStarted","user","dynamicColumns","options","onReady","onImport","onSubmit","onClose","licenseKey","dataLocation","customDomain","language","environment","theme","iframeUrl","buildImportUrl","version","URL","origin","reset","handleModalClosed","display","pointerEvents","innerHTML","markClosed","clearProbeTimer","messageListener","removeEventListener","event","legacy","classifyLegacyMessage","data","source","contentWindow","type","raw","unique_token","learnOrigin","reason","clearFileAckTimer","requestOpen","console","warn","message","classifyStructuredMessage","metadata","success","addEventListener","document","createElement","setAttribute","frameBorder","classList","add","Object","assign","IFRAME_STYLE","onload","postMessage","buildInitPayload","markReady","appendChild","send","File","fileAckTimer","setTimeout","giveUpOnFile","clearTimeout","componentWillUnmount","setState","render","HOLDER_STYLE","children","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,IAAMA,mBAAmB,GAAG,IAA5B;AAOA,IAAMC,kBAAkB,GAAG,uBAA3B;AACA,IAAMC,WAAW,GAAG,UAApB;;AAEA,SAASC,aAAT,GAAyB;AACxB,MAAI,CAACC,MAAM,CAACH,kBAAD,CAAX,EAAiCG,MAAM,CAACH,kBAAD,CAAN,GAA6B;AAAEI,IAAAA,IAAI,EAAE,EAAR;AAAYC,IAAAA,SAAS,EAAE;AAAvB,GAA7B;AACjC,SAAOF,MAAM,CAACH,kBAAD,CAAb;AACA;;AAED,SAASM,oBAAT,CAA8BC,GAA9B,EAAmC;AAClCA,EAAAA,GAAG,CAACH,IAAJ,CAASI,OAAT,CAAiB,UAAUC,KAAV,EAAiBC,CAAjB,EAAoB;AACpC,QAAMC,MAAM,GAAGF,KAAK,CAACG,SAAN,EAAf;AACA,QAAID,MAAJ,EAAYA,MAAM,CAACE,KAAP,CAAaC,MAAb,GAAsBC,MAAM,CAACd,WAAW,IAAIM,GAAG,CAACH,IAAJ,CAASY,MAAT,GAAkB,CAAlB,GAAsBN,CAA1B,CAAZ,CAA5B;AACZ,GAHD;AAIA;;AAED,SAASO,oBAAT,CAA8BR,KAA9B,EAAqC;AACpC,MAAMF,GAAG,GAAGL,aAAa,EAAzB;AACA,MAAIK,GAAG,CAACH,IAAJ,CAASc,OAAT,CAAiBT,KAAjB,KAA2B,CAA/B,EAAkC;AAClCF,EAAAA,GAAG,CAACH,IAAJ,CAASe,IAAT,CAAcV,KAAd;AACAH,EAAAA,oBAAoB,CAACC,GAAD,CAApB;AACAA,EAAAA,GAAG,CAACF,SAAJ,CAAce,KAAd,GAAsBZ,OAAtB,CAA8B,UAAU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iUCqB,eAjUD,GAiUC,2BAAkB;AACjB,SAAKsE,QAAL,CAAc;AACb5F,MAAAA,SAAS,EAAE;AADE,KAAd;AAGA,GArUF;;AAAA,SAuUC6F,MAvUD,GAuUC,kBAAS;AACR,QAAI,KAAK3G,KAAL,CAAW2G,MAAf,EAAuB;AACtB,0BACC,iCACE,KAAK3G,KAAL,CAAW2G,MAAX,CAAkB,KAAKxG,SAAvB,EAAkC,KAAKU,KAAL,CAAWC,SAAX,IAAwB,KAAKD,KAAL,CAAWE,OAArE,EAA8E,KAAKV,iBAAnF,CADF,eAEC;AAAK,QAAA,GAAG,EAAE,KAAKrB,MAAf;AAAuB,QAAA,KAAK,EAAE4H;AAA9B,QAFD,CADD;AAMA;;AAED,wBACC,8CACC;AAAQ,MAAA,QAAQ,EAAE,KAAK/F,KAAL,CAAWC,SAAX,IAAwB,KAAKD,KAAL,CAAWE,OAArD;AAA8D,MAAA,OAAO,EAAE,KAAKZ,SAA5E;AAAuF,kCAAvF;AAA4G,2BAAmB,KAAKQ;AAApI,OAA2I,KAAKX,KAAL,CAAW6G,QAAtJ,CADD,eAEC;AAAK,MAAA,GAAG,EAAE,KAAK7H,MAAf;AAAuB,MAAA,KAAK,EAAE4H;AAA9B,MAFD,CADD;AAMA,GAvVF;;AAAA;AAAA,EAAkCE,SAAlC;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/index.js"],"sourcesContent":["import React, { Component } from 'react';\nimport { version } from '../package.json';\nimport {\n\tHOLDER_STYLE,\n\tIFRAME_STYLE,\n\tbuildImportUrl,\n\tgenerateUuid,\n\tbuildInitPayload,\n\tcreateModalLifecycle,\n\tcreateMessageGate,\n\tcreateImportTracker,\n\tcreateFileSender,\n\tclassifyStructuredMessage,\n\tclassifyLegacyMessage\n} from '@sumit_yewale/adapter-core';\n\n// How long we wait for the importer to confirm a file it was sent before giving up on it.\nconst FILE_ACK_TIMEOUT_MS = 8000;\n\n// Page-wide record of the importers that are open or opening, shared by every CSVBox adapter\n// on the page (it lives on window so separate copies of an adapter see the same list). It does\n// two things: the newest importer is stacked on top (every holder is fixed, full screen and\n// z-index 2147483647, so equal z-indexes would leave the one that comes first in the DOM on\n// top), and the other instances learn that an importer is open so they can disable their button.\nconst OPEN_IMPORTERS_KEY = '__csvboxOpenImporters';\nconst TOP_Z_INDEX = 2147483647;\n\nfunction openImporters() {\n\tif (!window[OPEN_IMPORTERS_KEY]) window[OPEN_IMPORTERS_KEY] = { open: [], listeners: [] };\n\treturn window[OPEN_IMPORTERS_KEY];\n}\n\nfunction restackOpenImporters(reg) {\n\treg.open.forEach(function (entry, i) {\n\t\tconst holder = entry.getHolder();\n\t\tif (holder) holder.style.zIndex = String(TOP_Z_INDEX - (reg.open.length - 1 - i));\n\t});\n}\n\nfunction registerOpenImporter(entry) {\n\tconst reg = openImporters();\n\tif (reg.open.indexOf(entry) >= 0) return;\n\treg.open.push(entry);\n\trestackOpenImporters(reg);\n\treg.listeners.slice().forEach(function (fn) { fn(); });\n}\n\nfunction unregisterOpenImporter(entry) {\n\tconst reg = openImporters();\n\tconst i = reg.open.indexOf(entry);\n\tif (i < 0) return;\n\treg.open.splice(i, 1);\n\trestackOpenImporters(reg);\n\treg.listeners.slice().forEach(function (fn) { fn(); });\n}\n\nfunction isBlockedByOpenImporter(entry) {\n\tconst reg = openImporters();\n\treturn reg.open.length > 0 && reg.open.indexOf(entry) < 0;\n}\n\nfunction subscribeOpenImporters(fn) {\n\tconst reg = openImporters();\n\treg.listeners.push(fn);\n\treturn function () {\n\t\tconst i = reg.listeners.indexOf(fn);\n\t\tif (i >= 0) reg.listeners.splice(i, 1);\n\t};\n}\n\nexport class CSVBoxButton extends Component {\n\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.holder = React.createRef();\n\t\tthis.openModal = this.openModal.bind(this);\n\t\tthis.openModalWithFile = this.openModalWithFile.bind(this);\n\t\tthis.lifecycle = createModalLifecycle();\n\t\tthis.messageGate = createMessageGate();\n\t\tthis.importTracker = createImportTracker();\n\t\tthis.isModalShown = false;\n\t\tthis.isReady = false;\n\t\tthis.pendingFile = null;\n\t\tthis.uuid = generateUuid();\n\t\tthis.state = {\n\t\t\tisLoading: true,\n\t\t\t// True while a different importer on the page is open: the button stays disabled.\n\t\t\tblocked: false\n\t\t};\n\t\tthis.iframe = null;\n\t\tthis.registryEntry = { getHolder: () => this.holder.current };\n\t\tthis.fileSender = createFileSender({\n\t\t\tgetIframe: () => this.iframe,\n\t\t\tgetToken: () => this.uuid,\n\t\t\tgetTargetOrigin: () => this.targetOrigin,\n\t\t\tgetBaseDomain: () => this.baseDomain,\n\t\t\ttakeFile: () => {\n\t\t\t\tconst file = this.pendingFile;\n\t\t\t\tthis.pendingFile = null;\n\t\t\t\treturn file;\n\t\t\t},\n\t\t\tonSent: () => this.startFileAckTimer()\n\t\t});\n\t}\n\n\tcomponentDidMount() {\n\t\tthis.syncBlocked();\n\t\tthis.unsubscribeOpenImporters = subscribeOpenImporters(() => this.syncBlocked());\n\t\tconst { lazy } = this.props;\n\t\tif (!lazy && !this.iframe) {\n\t\t\tthis.initImporter();\n\t\t} else if (lazy) {\n\t\t\tthis.enableInitiator();\n\t\t}\n\t}\n\n\tinitImporter() {\n\t\tconst {\n\t\t\tloadStarted, user, dynamicColumns, options, onReady, onImport,\n\t\t\tonSubmit, onClose, licenseKey, dataLocation, customDomain,\n\t\t\tlanguage, environment, theme\n\t\t} = this.props;\n\n\t\tloadStarted?.();\n\n\t\tconst iframeUrl = buildImportUrl(\n\t\t\t{ licenseKey, customDomain, dataLocation, language, theme, environment },\n\t\t\t\"react\",\n\t\t\tversion\n\t\t);\n\n\t\t// Default place to send the file. A file is only ever sent to a named origin, never \"*\".\n\t\tthis.targetOrigin = new URL(iframeUrl).origin;\n\n\t\t// Data-location sheets redirect to another host, so the iframe origin can differ from\n\t\t// targetOrigin. We use this domain to check the real origin before trusting it.\n\t\tthis.baseDomain = customDomain || \"app.csvbox.io\";\n\t\tthis.fileSender.reset();\n\n\t\tconst handleModalClosed = () => {\n\t\t\tif (this.importTracker.isInFlight()) {\n\t\t\t\t// Closed after submitting and before the result arrived: keep the iframe and its\n\t\t\t\t// listener so the late result still reaches onImport. It is removed once that\n\t\t\t\t// result has been delivered (see below), so the next open is a fresh load.\n\t\t\t\tif (this.holder.current) {\n\t\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t}\n\t\t\t\tthis.lifecycle.markHidden();\n\t\t\t\tthis.isModalShown = false;\n\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\tunregisterOpenImporter(this.registryEntry);\n\t\t\t\tonClose?.();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.destroyImporter();\n\t\t\tonClose?.();\n\t\t};\n\n\t\t// Called after the result of an import has been delivered. If the modal was closed in the\n\t\t// meantime the iframe was only hidden, so remove it now.\n\t\tconst finishImport = (ended) => {\n\t\t\tif (ended && !this.isModalShown && this.iframe) {\n\t\t\t\tthis.destroyImporter();\n\t\t\t}\n\t\t};\n\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t}\n\n\t\tthis.messageListener = (event) => {\n\t\t\tconst legacy = classifyLegacyMessage(event.data);\n\t\t\tif (legacy) {\n\t\t\t\t// Legacy messages carry no token, so the only way to tell which importer sent one is\n\t\t\t\t// its window. Ignore those that came from another instance's iframe (or anywhere else).\n\t\t\t\tif (!this.iframe || event.source !== this.iframe.contentWindow) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// A newer importer sends the typed message as well; act on that one only.\n\t\t\t\tif (!this.messageGate.allowLegacy()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst ended = this.importTracker.observe(legacy);\n\t\t\t\tif (legacy.type === \"mainModalHidden\") {\n\t\t\t\t\thandleModalClosed();\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadSuccessful\") {\n\t\t\t\t\tonImport(true);\n\t\t\t\t}\n\t\t\t\tif (legacy.type === \"uploadFailed\") {\n\t\t\t\t\tonImport(false);\n\t\t\t\t}\n\t\t\t\tfinishImport(ended);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Set-file handshake messages. The shared core does not classify these, so they are\n\t\t\t// read here, behind the same unique_token check the core applies.\n\t\t\tconst raw = event.data;\n\t\t\tif (raw && typeof raw === \"object\" && raw.data && raw.data.unique_token == this.uuid) {\n\t\t\t\tthis.fileSender.learnOrigin(event);\n\n\t\t\t\tif (raw.type === \"csvbox-set-file-rejected\" && raw.data.reason === \"not-a-file\") {\n\t\t\t\t\t// Reply to our probe (it has no file). It only tells us the origin, so do nothing.\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (raw.type === \"csvbox-modal-shown\") {\n\t\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\t\tregisterOpenImporter(this.registryEntry);\n\t\t\t\t\t// What the file path in openModal() is waiting for. display as well as\n\t\t\t\t\t// pointer-events: a second file declined while the first was still opening the\n\t\t\t\t\t// modal has put the holder away in the meantime.\n\t\t\t\t\tthis.isModalShown = true;\n\t\t\t\t\tthis.lifecycle.requestOpen();\n\t\t\t\t\tif (this.holder.current) {\n\t\t\t\t\t\tthis.holder.current.style.display = 'block';\n\t\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (raw.type === \"csvbox-set-file-rejected\") {\n\t\t\t\t\tthis.clearFileAckTimer();\n\t\t\t\t\t// The importer has the file and will not take it. Put the holder away only if the\n\t\t\t\t\t// modal was never confirmed up: a file declined while it is open (an import past\n\t\t\t\t\t// the upload step, a fade-out under way) leaves that modal where it is, and its\n\t\t\t\t\t// own 'csvbox-modal-hidden' will put the holder away when it closes.\n\t\t\t\t\tif (!this.isModalShown && this.holder.current) {\n\t\t\t\t\t\tthis.holder.current.style.display = 'none';\n\t\t\t\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\t\t\t\tunregisterOpenImporter(this.registryEntry);\n\t\t\t\t\t}\n\t\t\t\t\tconsole.warn(\"[csvbox] importer declined the supplied file: \" + raw.data.reason);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst message = classifyStructuredMessage(event.data, this.uuid);\n\t\t\tif (!message) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.messageGate.markTyped();\n\t\t\tconst ended = this.importTracker.observe(message);\n\n\t\t\tif (message.type === \"data-on-submit\") {\n\t\t\t\tonSubmit?.(message.metadata);\n\t\t\t} else if (message.type === \"data-push-status\") {\n\t\t\t\tonImport(message.success, message.metadata);\n\t\t\t} else if (message.type === \"csvbox-modal-hidden\") {\n\t\t\t\thandleModalClosed();\n\t\t\t} else if (message.type === \"csvbox-upload-successful\") {\n\t\t\t\tonImport(true);\n\t\t\t} else if (message.type === \"csvbox-upload-failed\") {\n\t\t\t\tonImport(false);\n\t\t\t}\n\t\t\tfinishImport(ended);\n\t\t};\n\n\t\twindow.addEventListener(\"message\", this.messageListener, false);\n\n\t\tthis.uuid = generateUuid();\n\t\tthis.messageGate.reset();\n\t\tthis.importTracker.reset();\n\n\t\tconst iframe = document.createElement(\"iframe\");\n\t\tthis.iframe = iframe;\n\t\tiframe.setAttribute(\"src\", iframeUrl);\n\t\tiframe.setAttribute(\"allow\", \"clipboard-read; clipboard-write *\");\n\t\tiframe.frameBorder = 0;\n\t\tiframe.classList.add('csvbox-iframe');\n\t\tObject.assign(iframe.style, IFRAME_STYLE);\n\n\t\tiframe.onload = () => {\n\t\t\tthis.isReady = true;\n\t\t\tthis.enableInitiator();\n\t\t\tiframe.contentWindow.postMessage(buildInitPayload(user, dynamicColumns, options, this.uuid), \"*\");\n\t\t\tonReady?.();\n\t\t\tif (this.lifecycle.markReady()) {\n\t\t\t\tthis.openModal();\n\t\t\t}\n\t\t};\n\n\t\tthis.holder.current.appendChild(iframe);\n\t}\n\n\topenModal() {\n\t\t// Counts as open from the moment it is requested, so the other buttons are disabled while\n\t\t// this importer is still loading, and so it is stacked above any importer opened earlier.\n\t\tregisterOpenImporter(this.registryEntry);\n\t\tif (!this.iframe) {\n\t\t\tthis.lifecycle.requestOpen();\n\t\t\tthis.initImporter();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.pendingFile) {\n\t\t\tif (!this.isReady) {\n\t\t\t\t// Deferred: onload's markReady() calls openModal() again once the iframe is up.\n\t\t\t\tthis.lifecycle.requestOpen();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// The importer opens its own modal once it has the file, so that it can inject on\n\t\t\t// 'shown.bs.modal'. Sending 'openModal' as well would race that.\n\t\t\t//\n\t\t\t// It can also decline: wrong step, an import file URL configured on the sheet, or\n\t\t\t// an importer too old to know the message at all. So the holder goes up\n\t\t\t// click-through and stays that way until 'csvbox-modal-shown' confirms the modal\n\t\t\t// is really up. It covers the viewport at z-index 2147483647 and the importer\n\t\t\t// renders transparent with its modal closed, so arming it on an unanswered message\n\t\t\t// leaves an invisible sheet over the host page eating every click.\n\t\t\t//\n\t\t\t// display:block regardless, so the iframe lays out and animates normally; only\n\t\t\t// pointer-events is held back. isModalShown likewise waits for the confirmation,\n\t\t\t// or a declined file would latch the importer shut for good.\n\t\t\tthis.holder.current.style.pointerEvents = 'none';\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t\tthis.fileSender.send();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.lifecycle.requestOpen()) {\n\t\t\tthis.isModalShown = true;\n\t\t\tthis.iframe.contentWindow.postMessage('openModal', '*');\n\t\t\t// Explicit: a previously declined file leaves the holder click-through.\n\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\tthis.holder.current.style.display = 'block';\n\t\t}\n\t}\n\n\t/**\n\t * Open the importer on a File the host page already has, instead of the file picker.\n\t *\n\t * Reachable two ways: a ref on the component (`ref.current.openModalWithFile(file)`), or\n\t * the third argument handed to the `render` prop.\n\t *\n\t * The File crosses to the iframe by structured clone, so the importer receives the real\n\t * object and applies its own extension, worksheet and size rules to it -- this does not\n\t * bypass any of them. Pass a File; a Blob has no name for the importer to read an\n\t * extension from.\n\t */\n\topenModalWithFile(file) {\n\t\t// window.File, not a bare File: eslint-config-standard declares only window, document\n\t\t// and navigator as browser globals, so a bare File is a no-undef error here.\n\t\tif (!window.File || !(file instanceof window.File)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pendingFile = file;\n\n\t\t// Already open: hand it over now rather than holding it for the next open. The importer\n\t\t// takes it only while it is still on the upload step, and ignores it once the user has a\n\t\t// dataset and a mapping in progress.\n\t\tif (this.isModalShown && this.iframe && this.isReady) {\n\t\t\tthis.fileSender.send();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.openModal();\n\t}\n\n\tclearProbeTimer() {\n\t\tthis.clearFileAckTimer();\n\t\tthis.fileSender.reset();\n\t}\n\n\tstartFileAckTimer() {\n\t\tthis.clearFileAckTimer();\n\t\tthis.fileAckTimer = setTimeout(() => {\n\t\t\tthis.fileAckTimer = null;\n\t\t\tthis.giveUpOnFile();\n\t\t}, FILE_ACK_TIMEOUT_MS);\n\t}\n\n\tclearFileAckTimer() {\n\t\tif (this.fileAckTimer) {\n\t\t\tclearTimeout(this.fileAckTimer);\n\t\t\tthis.fileAckTimer = null;\n\t\t}\n\t}\n\n\t// The importer never confirmed the file it was sent (an origin we do not trust, or an importer too\n\t// old to know the message). Without this the holder would stay up, invisible and click-through,\n\t// and the other instances' buttons would stay disabled for good.\n\tgiveUpOnFile() {\n\t\tif (this.isModalShown) {\n\t\t\treturn;\n\t\t}\n\t\tconst holder = this.holder.current;\n\t\tif (holder) {\n\t\t\tholder.style.display = 'none';\n\t\t\tholder.style.pointerEvents = 'auto';\n\t\t}\n\t\tunregisterOpenImporter(this.registryEntry);\n\t\tconsole.warn(\"[csvbox] the importer did not respond to the supplied file\");\n\t}\n\n\t// Puts the importer away: the next open builds a new iframe with a new token.\n\tdestroyImporter() {\n\t\tif (this.holder.current) {\n\t\t\tthis.holder.current.style.display = 'none';\n\t\t\tthis.holder.current.style.pointerEvents = 'auto';\n\t\t\tthis.holder.current.innerHTML = '';\n\t\t}\n\t\tthis.lifecycle.markClosed();\n\t\tthis.isModalShown = false;\n\t\tthis.isReady = false;\n\t\tthis.iframe = null;\n\t\tthis.messageGate.reset();\n\t\tthis.importTracker.reset();\n\t\t// A new iframe is built on the next open, so the origin is learned again.\n\t\tthis.clearProbeTimer();\n\t\tunregisterOpenImporter(this.registryEntry);\n\t}\n\n\t// Everything the component set up outside React. Leaves the instance as it was before its first\n\t// mount, so a remount (React 18 StrictMode in development) initialises it again.\n\tteardown() {\n\t\tthis.destroyImporter();\n\t\tif (this.unsubscribeOpenImporters) {\n\t\t\tthis.unsubscribeOpenImporters();\n\t\t\tthis.unsubscribeOpenImporters = null;\n\t\t}\n\t\tif (this.messageListener) {\n\t\t\twindow.removeEventListener(\"message\", this.messageListener, false);\n\t\t\tthis.messageListener = null;\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.teardown();\n\t}\n\n\tsyncBlocked() {\n\t\tconst blocked = isBlockedByOpenImporter(this.registryEntry);\n\t\tif (blocked !== this.state.blocked) {\n\t\t\tthis.setState({ blocked });\n\t\t}\n\t}\n\n\tenableInitiator() {\n\t\tthis.setState({\n\t\t\tisLoading: false\n\t\t});\n\t}\n\n\trender() {\n\t\tif (this.props.render) {\n\t\t\treturn (\n\t\t\t\t<div>\n\t\t\t\t\t{this.props.render(this.openModal, this.state.isLoading || this.state.blocked, this.openModalWithFile)}\n\t\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t\t</div>\n\t\t\t)\n\t\t}\n\n\t\treturn (\n\t\t\t<div>\n\t\t\t\t<button disabled={this.state.isLoading || this.state.blocked} onClick={this.openModal} data-csvbox-initator data-csvbox-token={this.uuid}>{this.props.children}</button>\n\t\t\t\t<div ref={this.holder} style={HOLDER_STYLE}></div>\n\t\t\t</div>\n\t\t)\n\t}\n}\n\nexport default CSVBoxButton;\n"],"names":["FILE_ACK_TIMEOUT_MS","OPEN_IMPORTERS_KEY","TOP_Z_INDEX","openImporters","window","open","listeners","restackOpenImporters","reg","forEach","entry","i","holder","getHolder","style","zIndex","String","length","registerOpenImporter","indexOf","push","slice","fn","unregisterOpenImporter","splice","isBlockedByOpenImporter","subscribeOpenImporters","CSVBoxButton","props","React","createRef","openModal","bind","openModalWithFile","lifecycle","createModalLifecycle","messageGate","createMessageGate","importTracker","createImportTracker","isModalShown","isReady","pendingFile","uuid","generateUuid","state","isLoading","blocked","iframe","registryEntry","current","fileSender","createFileSender","getIframe","getToken","getTargetOrigin","targetOrigin","getBaseDomain","baseDomain","takeFile","file","onSent","startFileAckTimer","componentDidMount","syncBlocked","unsubscribeOpenImporters","lazy","initImporter","enableInitiator","loadStarted","user","dynamicColumns","options","onReady","onImport","onSubmit","onClose","licenseKey","dataLocation","customDomain","language","environment","theme","iframeUrl","buildImportUrl","version","URL","origin","reset","handleModalClosed","isInFlight","display","pointerEvents","markHidden","clearFileAckTimer","destroyImporter","finishImport","ended","messageListener","removeEventListener","event","legacy","classifyLegacyMessage","data","source","contentWindow","allowLegacy","observe","type","raw","unique_token","learnOrigin","reason","requestOpen","console","warn","message","classifyStructuredMessage","markTyped","metadata","success","addEventListener","document","createElement","setAttribute","frameBorder","classList","add","Object","assign","IFRAME_STYLE","onload","postMessage","buildInitPayload","markReady","appendChild","send","File","clearProbeTimer","fileAckTimer","setTimeout","giveUpOnFile","clearTimeout","innerHTML","markClosed","teardown","componentWillUnmount","setState","render","HOLDER_STYLE","children","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,IAAMA,mBAAmB,GAAG,IAA5B;AAOA,IAAMC,kBAAkB,GAAG,uBAA3B;AACA,IAAMC,WAAW,GAAG,UAApB;;AAEA,SAASC,aAAT,GAAyB;AACxB,MAAI,CAACC,MAAM,CAACH,kBAAD,C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kB,KAAKrH,SAAvB,EAAkC,KAAKc,KAAL,CAAWC,SAAX,IAAwB,KAAKD,KAAL,CAAWE,OAArE,EAA8E,KAAKd,iBAAnF,CADF,eAEC;AAAK,QAAA,GAAG,EAAE,KAAKrB,MAAf;AAAuB,QAAA,KAAK,EAAEyI;AAA9B,QAFD,CADD;AAMA;;AAED,wBACC,8CACC;AAAQ,MAAA,QAAQ,EAAE,KAAKxG,KAAL,CAAWC,SAAX,IAAwB,KAAKD,KAAL,CAAWE,OAArD;AAA8D,MAAA,OAAO,EAAE,KAAKhB,SAA5E;AAAuF,kCAAvF;AAA4G,2BAAmB,KAAKY;AAApI,OAA2I,KAAKf,KAAL,CAAW0H,QAAtJ,CADD,eAEC;AAAK,MAAA,GAAG,EAAE,KAAK1I,MAAf;AAAuB,MAAA,KAAK,EAAEyI;AAA9B,MAFD,CADD;AAMA,GAvYF;;AAAA;AAAA,EAAkCE,SAAlC;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sumit_yewale/react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18-fix.1",
|
|
4
4
|
"description": "React adapter for csvbox.io",
|
|
5
5
|
"types": "@types/csvbox__react.d.ts",
|
|
6
6
|
"author": "csvbox-io",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"react-dom": "^16.13.1 || ^17.0.2 || ^18.0.0 || ^19.0.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@sumit_yewale/adapter-core": "^0.
|
|
35
|
+
"@sumit_yewale/adapter-core": "^0.2.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"babel-eslint": "^10.0.3",
|