dromo-uploader-js 2.0.8 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DromoUploader.js +1 -1
- package/dist/DromoUploader.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/index.d.ts +120 -124
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +514 -484
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,124 +1,120 @@
|
|
|
1
|
-
import { ITableMessage, IMessagesForCell, IColumnHook, IColumnHookInput, IColumnHookOutput, IRowHook, IRowHookInput, IRowHookOutput, IDeveloperField, IDeveloperSettings, IDeveloperStyleOverrides, IUser, IValidatorField, IRowHookOutputInternal, IResultMetadata, IReviewStepData, IStepHook, IUploadStepData, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback, IBeforeFinishOutput, IPositionSpec, IConnectionMethods, ISelectField, IImporterOptions, IAllHooks, IRowToAdd } from "./interfaces";
|
|
2
|
-
declare global {
|
|
3
|
-
interface Window {
|
|
4
|
-
DROMO_WIDGET_OVERRIDE?: string;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export default class DromoUploader {
|
|
8
|
-
constructor(licenseKey: string, fields: IDeveloperField[], settings: IDeveloperSettings, user: IUser);
|
|
9
|
-
constructor(licenseKey: string, schemaId: string);
|
|
10
|
-
initChild: () => Promise<void>;
|
|
11
|
-
showIFrame: () => void;
|
|
12
|
-
/**
|
|
13
|
-
* Function called by the developer to set a callback
|
|
14
|
-
*
|
|
15
|
-
* @param fieldName the key of the column for which we want to trigger the
|
|
16
|
-
* callback
|
|
17
|
-
* @param callback developer defined callback that is callback that is added
|
|
18
|
-
* to a list of column hooks
|
|
19
|
-
*/
|
|
20
|
-
registerColumnHook: (fieldName: IColumnHook["fieldName"], callback: IColumnHook["callback"]) => void;
|
|
21
|
-
/**
|
|
22
|
-
* Function called by the developer to set a callback
|
|
23
|
-
*
|
|
24
|
-
* @param callback developer defined callback that is added to a list of row
|
|
25
|
-
* hooks
|
|
26
|
-
*/
|
|
27
|
-
registerBulkRowHook: (bulkRowHook: IBulkRowHook) => void;
|
|
28
|
-
/**
|
|
29
|
-
* Function called by the developer to set a callback
|
|
30
|
-
*
|
|
31
|
-
* @param callback developer defined callback that is added to a list of row
|
|
32
|
-
* hooks
|
|
33
|
-
*/
|
|
34
|
-
registerRowHook: (callback: IRowHook) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Function called by the developer to set a callback
|
|
37
|
-
*
|
|
38
|
-
* @param callback developer defined callback that is called per step of the
|
|
39
|
-
* import flow
|
|
40
|
-
*/
|
|
41
|
-
registerStepHook: (type: IStepHook["type"], callback: IStepHook["callback"]) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Function called by the developer to set a row delete callback
|
|
44
|
-
*
|
|
45
|
-
* @param callback developer defined callback that is called per step of the
|
|
46
|
-
* import flow
|
|
47
|
-
*/
|
|
48
|
-
registerRowDeleteHook: (callback: IRowDeleteHook) => void;
|
|
49
|
-
/**
|
|
50
|
-
* Function called by the developer to set the beforeFinish callback
|
|
51
|
-
*
|
|
52
|
-
* @param callback developer defined callback that is called when the user submits
|
|
53
|
-
*/
|
|
54
|
-
beforeFinish: (callback: IBeforeFinishCallback) => void;
|
|
55
|
-
/**
|
|
56
|
-
* Convenience function for setting all hooks at once.
|
|
57
|
-
*
|
|
58
|
-
* @param hooks object containing all hooks to register
|
|
59
|
-
*/
|
|
60
|
-
registerAllHooks: (hooks: IAllHooks) => void;
|
|
61
|
-
/**
|
|
62
|
-
* Function called by the developer to set a callback
|
|
63
|
-
*
|
|
64
|
-
* @param callback developer defined callback that is called when the import
|
|
65
|
-
* flow completes
|
|
66
|
-
*/
|
|
67
|
-
onResults: (callback: (data: Record<string, string | number | boolean | null>[], metadata: IResultMetadata) => Promise<void> | void) => void;
|
|
68
|
-
/**
|
|
69
|
-
* Function called by the developer to set a callback
|
|
70
|
-
*
|
|
71
|
-
* @param callback developer defined callback that is called when the user
|
|
72
|
-
* cancels the import
|
|
73
|
-
*/
|
|
74
|
-
onCancel: (callback: () => void) => void;
|
|
75
|
-
/**
|
|
76
|
-
* Function called by the developer to set or reset the user information
|
|
77
|
-
*/
|
|
78
|
-
setUser: (user: IUser) => Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* Function called by the developer to add a field midway through the import
|
|
81
|
-
* process
|
|
82
|
-
*/
|
|
83
|
-
addField: (field: IDeveloperField, position?:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
*
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Function called by developer
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Function called by the developer to
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Function called by
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Function called by developer to
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
*/
|
|
122
|
-
setDevelopmentMode: (developmentMode: boolean) => Promise<void>;
|
|
123
|
-
}
|
|
124
|
-
export { ITableMessage, IMessagesForCell, IColumnHook, IColumnHookInput, IColumnHookOutput, IRowHook, IRowHookInput, IRowHookOutput, IDeveloperField, IDeveloperSettings, IDeveloperStyleOverrides, IUser, IValidatorField, IRowHookOutputInternal, IResultMetadata, IReviewStepData, IStepHook, IUploadStepData, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback, IBeforeFinishOutput, IPositionSpec, IConnectionMethods, ISelectField, IImporterOptions, IAllHooks, };
|
|
1
|
+
import { ITableMessage, IMessagesForCell, IColumnHook, IColumnHookInput, IColumnHookOutput, IRowHook, IRowHookInput, IRowHookOutput, IDeveloperField, IDeveloperSettings, IDeveloperStyleOverrides, IUser, IValidatorField, IRowHookOutputInternal, IResultMetadata, IReviewStepData, IStepHook, IUploadStepData, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback, IBeforeFinishOutput, IPositionSpec, IConnectionMethods, ISelectField, IImporterOptions, IAllHooks, IRowToAdd } from "./interfaces";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
DROMO_WIDGET_OVERRIDE?: string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export default class DromoUploader {
|
|
8
|
+
constructor(licenseKey: string, fields: IDeveloperField[], settings: IDeveloperSettings, user: IUser);
|
|
9
|
+
constructor(licenseKey: string, schemaId: string);
|
|
10
|
+
initChild: () => Promise<void>;
|
|
11
|
+
showIFrame: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Function called by the developer to set a callback
|
|
14
|
+
*
|
|
15
|
+
* @param fieldName the key of the column for which we want to trigger the
|
|
16
|
+
* callback
|
|
17
|
+
* @param callback developer defined callback that is callback that is added
|
|
18
|
+
* to a list of column hooks
|
|
19
|
+
*/
|
|
20
|
+
registerColumnHook: (fieldName: IColumnHook["fieldName"], callback: IColumnHook["callback"]) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Function called by the developer to set a callback
|
|
23
|
+
*
|
|
24
|
+
* @param callback developer defined callback that is added to a list of row
|
|
25
|
+
* hooks
|
|
26
|
+
*/
|
|
27
|
+
registerBulkRowHook: (bulkRowHook: IBulkRowHook) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Function called by the developer to set a callback
|
|
30
|
+
*
|
|
31
|
+
* @param callback developer defined callback that is added to a list of row
|
|
32
|
+
* hooks
|
|
33
|
+
*/
|
|
34
|
+
registerRowHook: (callback: IRowHook) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Function called by the developer to set a callback
|
|
37
|
+
*
|
|
38
|
+
* @param callback developer defined callback that is called per step of the
|
|
39
|
+
* import flow
|
|
40
|
+
*/
|
|
41
|
+
registerStepHook: (type: IStepHook["type"], callback: IStepHook["callback"]) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Function called by the developer to set a row delete callback
|
|
44
|
+
*
|
|
45
|
+
* @param callback developer defined callback that is called per step of the
|
|
46
|
+
* import flow
|
|
47
|
+
*/
|
|
48
|
+
registerRowDeleteHook: (callback: IRowDeleteHook) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Function called by the developer to set the beforeFinish callback
|
|
51
|
+
*
|
|
52
|
+
* @param callback developer defined callback that is called when the user submits
|
|
53
|
+
*/
|
|
54
|
+
beforeFinish: (callback: IBeforeFinishCallback) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Convenience function for setting all hooks at once.
|
|
57
|
+
*
|
|
58
|
+
* @param hooks object containing all hooks to register
|
|
59
|
+
*/
|
|
60
|
+
registerAllHooks: (hooks: IAllHooks) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Function called by the developer to set a callback
|
|
63
|
+
*
|
|
64
|
+
* @param callback developer defined callback that is called when the import
|
|
65
|
+
* flow completes
|
|
66
|
+
*/
|
|
67
|
+
onResults: (callback: (data: Record<string, string | number | boolean | null>[], metadata: IResultMetadata) => Promise<void> | void) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Function called by the developer to set a callback
|
|
70
|
+
*
|
|
71
|
+
* @param callback developer defined callback that is called when the user
|
|
72
|
+
* cancels the import
|
|
73
|
+
*/
|
|
74
|
+
onCancel: (callback: () => void) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Function called by the developer to set or reset the user information
|
|
77
|
+
*/
|
|
78
|
+
setUser: (user: IUser) => Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Function called by the developer to add a field midway through the import
|
|
81
|
+
* process
|
|
82
|
+
*/
|
|
83
|
+
addField: (field: IDeveloperField, position?: IPositionSpec) => Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Function called by the developer to remove a field. The data won't appear
|
|
86
|
+
* in the user interface nor in the result data.
|
|
87
|
+
*/
|
|
88
|
+
removeField: (fieldKey: string) => Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Function called by the developer to add new table messages throughout the
|
|
91
|
+
* import process
|
|
92
|
+
*/
|
|
93
|
+
updateInfoMessages: (messages: IMessagesForCell[]) => Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Function called by the developer to change the matchingStep.headerRowOverride
|
|
96
|
+
* setting from a step hook
|
|
97
|
+
*/
|
|
98
|
+
setHeaderRowOverride: (headerRowOverride: number | null) => Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Function called by developer called to open the iframe
|
|
101
|
+
*/
|
|
102
|
+
open: () => Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Function called by the developer to add rows during the import
|
|
105
|
+
*/
|
|
106
|
+
addRows: (rows: IRowToAdd[]) => Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Function called by the developer to remove rows
|
|
109
|
+
*/
|
|
110
|
+
removeRows: (rowIds: string[]) => Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Function called by developer to close the iframe
|
|
113
|
+
*/
|
|
114
|
+
close: () => void;
|
|
115
|
+
/**
|
|
116
|
+
* Function called by the developer to set developmentMode
|
|
117
|
+
*/
|
|
118
|
+
setDevelopmentMode: (developmentMode: boolean) => Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
export { ITableMessage, IMessagesForCell, IColumnHook, IColumnHookInput, IColumnHookOutput, IRowHook, IRowHookInput, IRowHookOutput, IDeveloperField, IDeveloperSettings, IDeveloperStyleOverrides, IUser, IValidatorField, IRowHookOutputInternal, IResultMetadata, IReviewStepData, IStepHook, IUploadStepData, IRowDeleteHook, IBulkRowHook, IBeforeFinishCallback, IBeforeFinishOutput, IPositionSpec, IConnectionMethods, ISelectField, IImporterOptions, IAllHooks, };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DromoUploader=t()}(this,(function(){"use strict";
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */var e=function(){return(e=Object.assign||function(e){for(var n,o=1,t=arguments.length;o<t;o++)for(var r in n=arguments[o])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)};function n(e,n,o,t){return new(o||(o=Promise))((function(r,i){function s(e){try{a(t.next(e))}catch(e){i(e)}}function c(e){try{a(t.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?r(e.value):(n=e.value,n instanceof o?n:new o((function(e){e(n)}))).then(s,c)}a((t=t.apply(e,n||[])).next())}))}function o(e,n){var o,t,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,t&&(r=2&i[0]?t.return:i[0]?t.throw||((r=t.return)&&r.call(t),0):t.next)&&!(r=r.call(t,i[1])).done)return r;switch(t=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,t=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=n.call(e,s)}catch(e){i=[6,e],t=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var t,r,i,s,c,a,l={IFRAME_URL:"https://widget.dromo.io/"}.IFRAME_URL;!function(e){e.INIT_IFRAME="INIT_IFRAME"}(t||(t={})),function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(r||(r={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(i||(i={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(s||(s={})),function(e){e.DataCloneError="DataCloneError"}(c||(c={})),function(e){e.Message="message"}(a||(a={}));const u={"http:":"80","https:":"443"},d=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,h=["file:","data:"];const f=({name:e,message:n,stack:o})=>({name:e,message:n,stack:o});let m=0;var p=()=>++m,v=(e,n,o,t,c)=>{const{localName:l,local:u,remote:d,originForSending:h,originForReceiving:f}=n;let m=!1;c(`${l}: Connecting call sender`);const v=e=>(...n)=>{let o;c(`${l}: Sending ${e}() call`);try{d.closed&&(o=!0)}catch(e){o=!0}if(o&&t(),m){const n=new Error(`Unable to send ${e}() call due to destroyed connection`);throw n.code=s.ConnectionDestroyed,n}return new Promise(((o,t)=>{const s=p(),m=n=>{if(n.source!==d||n.data.penpal!==r.Reply||n.data.id!==s)return;if(n.origin!==f)return void c(`${l} received message from origin ${n.origin} which did not match expected origin ${f}`);const h=n.data;c(`${l}: Received ${e}() reply`),u.removeEventListener(a.Message,m);let p=h.returnValue;h.returnValueIsError&&(p=(e=>{const n=new Error;return Object.keys(e).forEach((o=>n[o]=e[o])),n})(p)),(h.resolution===i.Fulfilled?o:t)(p)};u.addEventListener(a.Message,m);const v={penpal:r.Call,id:s,methodName:e,args:n};d.postMessage(v,h)}))};return o.reduce(((e,n)=>(e[n]=v(n),e)),e),()=>{m=!0}},w=(e,n,o,t,s)=>{const{destroy:l,onDestroy:u}=t;let d,h;const m={};return t=>{if(t.origin!==n)return void s(`Parent: Handshake - Received ACK message from origin ${t.origin} which did not match expected origin ${n}`);s("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:t.source,originForSending:o,originForReceiving:n};d&&d(),d=((e,n,o)=>{const{localName:t,local:s,remote:l,originForSending:u,originForReceiving:d}=e;let h=!1;const m=e=>{if(e.source!==l||e.data.penpal!==r.Call)return;if(e.origin!==d)return void o(`${t} received message from origin ${e.origin} which did not match expected origin ${d}`);const s=e.data,{methodName:a,args:m,id:p}=s;o(`${t}: Received ${a}() call`);const v=e=>n=>{if(o(`${t}: Sending ${a}() reply`),h)return void o(`${t}: Unable to send ${a}() reply due to destroyed connection`);const s={penpal:r.Reply,id:p,resolution:e,returnValue:n};e===i.Rejected&&n instanceof Error&&(s.returnValue=f(n),s.returnValueIsError=!0);try{l.postMessage(s,u)}catch(e){if(e.name===c.DataCloneError){const n={penpal:r.Reply,id:p,resolution:i.Rejected,returnValue:f(e),returnValueIsError:!0};l.postMessage(n,u)}throw e}};new Promise((e=>e(n[a].apply(n,m)))).then(v(i.Fulfilled),v(i.Rejected))};return s.addEventListener(a.Message,m),()=>{h=!0,s.removeEventListener(a.Message,m)}})(p,e,s),u(d),h&&h.forEach((e=>{delete m[e]})),h=t.data.methodNames;const w=v(m,p,h,l,s);return u(w),m}};var g=e=>{let{iframe:n,methods:o={},childOrigin:t,timeout:i,debug:c=!1}=e;const l=(e=>(...n)=>{e&&console.log("[Penpal]",...n)})(c),f=(()=>{const e=[];let n=!1;return{destroy(o){n=!0,e.forEach((e=>{e(o)}))},onDestroy(o){n?o():e.push(o)}}})(),{onDestroy:m,destroy:p}=f;t||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=s.NoIframeSrc,e}})(n),t=(e=>{if(e&&h.find((n=>e.startsWith(n))))return"null";const n=document.location,o=d.exec(e);let t,r,i;return o?(t=o[1]?o[1]:n.protocol,r=o[2],i=o[4]):(t=n.protocol,r=n.hostname,i=n.port),`${t}//${r}${i&&i!==u[t]?`:${i}`:""}`})(n.src));const v="null"===t?"*":t,g=((e,n,o,t)=>i=>{if(i.origin!==o)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${o}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:r.SynAck,methodNames:Object.keys(n)};i.source.postMessage(s,t)})(l,o,t,v),k=w(o,t,v,f,l);return{promise:new Promise(((e,o)=>{const t=((e,n)=>{let o;return void 0!==e&&(o=window.setTimeout((()=>{const o=new Error(`Connection timed out after ${e}ms`);o.code=s.ConnectionTimeout,n(o)}),e)),()=>{clearTimeout(o)}})(i,p),c=o=>{if(o.source===n.contentWindow&&o.data)if(o.data.penpal!==r.Syn)if(o.data.penpal!==r.Ack);else{const n=k(o);n&&(t(),e(n))}else g(o)};window.addEventListener(a.Message,c),l("Parent: Awaiting handshake"),((e,n)=>{const{destroy:o,onDestroy:t}=n,r=setInterval((()=>{e.isConnected||(clearInterval(r),o())}),6e4);t((()=>{clearInterval(r)}))})(n,f),m((e=>{window.removeEventListener(a.Message,c),e||((e=new Error("Connection destroyed")).code=s.ConnectionDestroyed),o(e)}))})),destroy(){p()}}},k=function(n){var o=e({},n);return o.validators&&(o.validators=o.validators.map((function(n){return("regex_match"===n.validate||"regex_exclude"===n.validate)&&n.regex instanceof RegExp?e(e({},n),{regex:n.regex.source,regexOptions:{ignoreCase:n.regex.flags.includes("i"),dotAll:n.regex.flags.includes("s"),multiline:n.regex.flags.includes("m"),unicode:n.regex.flags.includes("u")}}):n}))),o},y=function(e){return setTimeout((function(){console.warn("[Dromo Error] Slow "+e+" detected (>10s). Long running hooks can degrade user experience and importer performance.")}),1e4)},b=function(e){clearTimeout(e)};return function(){function t(t,r,i,s){var c=this;this.columnHooks=[],this.bulkRowHooks=[],this.rowHooks=[],this.stepHooks=[],this.rowDeleteHooks=[],this.initChild=function(){return n(c,void 0,void 0,(function(){var n,t,r,i,s;return o(this,(function(o){switch(o.label){case 0:return this.connection?[4,this.connection.promise]:(console.error("shim cannot connect with Dromo service."),[2]);case 1:return n=o.sent(),t=Array.from(document.getElementsByTagName("script")).some((function(e){return"https://unpkg.com/dromo-uploader-js/dist/DromoUploader.js"===e.src||"https://cdn.jsdelivr.net/npm/dromo-uploader-js@latest/dist/DromoUploader.js"===e.src})),this.fields&&this.settings&&this.user?(r=e({},this.settings),t||(r.version=null!==(i=r.version)&&void 0!==i?i:"v2"),r.browserExcelParsing=null===(s=r.browserExcelParsing)||void 0===s||s,[4,n.init(this.licenseKey,this.fields,r,this.user,this.appHost)]):[3,3];case 2:return o.sent(),[3,6];case 3:return this.schemaId?[4,n.initFromSavedSchema(this.licenseKey,this.schemaId,this.appHost,{user:this.user,developmentMode:this.developmentMode,headerRowOverride:this.headerRowOverride})]:[3,5];case 4:return o.sent(),[3,6];case 5:console.error("Invalid Dromo configuration"),o.label=6;case 6:return[4,n.setNumRegisteredRowHooks(this.totalNumRowHooks())];case 7:return o.sent(),[4,n.setNumRegisteredColHooks(this.columnHooks.length)];case 8:return o.sent(),[4,n.setNumRegisteredRowDeleteHooks(this.rowDeleteHooks.length)];case 9:return o.sent(),[2]}}))}))},this.initIFrame=function(){var e,n;if(!document.getElementById(c.iframeId)){var o=document.createElement("iframe"),t=null!==(n=null===(e=c.settings)||void 0===e?void 0:e.importIdentifier)&&void 0!==n?n:c.schemaId;o.title=t?"Dromo Importer: "+t:"Dromo Importer",o.src=window.DROMO_WIDGET_OVERRIDE||l,o.id=c.iframeId,o.style.height="100%",o.style.width="100%",o.style.border="0",o.crossorigin="anonymous",c.iframe=o}},this.createConnection=function(){var t=c,r=c.iframe;r?c.connection=g({iframe:r,methods:{handleColumnHooks:function(r,i){return n(this,void 0,void 0,(function(){var s,c,a,l,u=this;return o(this,(function(d){switch(d.label){case 0:return s=t.columnHooks.filter((function(e){return e.fieldName===r})),c=new Map,a=i,[4,s.reduce((function(e,t){return n(u,void 0,void 0,(function(){var r=this;return o(this,(function(i){switch(i.label){case 0:return[4,e.then((function(){return n(r,void 0,void 0,(function(){var e,n,r;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),e=y("column hook"),[4,t.callback(a)];case 1:return n=o.sent(),b(e),n.forEach((function(e){if(void 0!==e.value||void 0!==e.info){var n={};void 0!==e.value&&(n.value=e.value,a[e.index]=e.value),void 0!==e.info&&(n.info=e.info),c.set(e.index,n)}})),[3,3];case 2:return r=o.sent(),console.error("[Dromo-External-Error] There was an error running your col hook.",r),[3,3];case 3:return[2]}}))}))}))];case 1:return i.sent(),[2]}}))}))}),Promise.resolve())];case 1:return d.sent(),l=[],c.forEach((function(n,o){return l.push(e(e({},n),{index:o}))})),[2,l]}}))}))},handleRowHooks:function(e,r){return n(this,void 0,void 0,(function(){var i,s,c,a,l,u,d,h,f,m,p,v,w,g=this;return o(this,(function(k){switch(k.label){case 0:i=new Map,s=new Map(e.map((function(e){return[e.index,e]}))),c=function(e,n){for(var o,t=0,r=Object.entries(null!=n?n:{});t<r.length;t++){var c=r[t],a=c[0],l=c[1];if(void 0===l.value&&void 0===l.info&&void 0===l.selectOptions)return;var u=s.get(e),d=i.get(e)||{},h=null!==(o=d[a])&&void 0!==o?o:{};void 0!==l.value&&(h.value=l.value,u.row[a].value=l.value),void 0!==l.info&&(h.info=l.info,u.row[a].info=l.info),void 0!==l.selectOptions&&(h.selectOptions=l.selectOptions,u.row[a].selectOptions=l.selectOptions),d[a]=h,i.set(e,d)}},a=0,l=t.bulkRowHooks,k.label=1;case 1:if(!(a<l.length))return[3,6];u=l[a],k.label=2;case 2:return k.trys.push([2,4,,5]),d=y("bulk row hook"),[4,u(e,r)];case 3:for(h=k.sent(),b(d),f=0,m=h;f<m.length;f++)p=m[f],c(p.index,p.row);return[3,5];case 4:return v=k.sent(),console.error("[Dromo-External-Error] There was an error running your bulk row hook.",v),[3,5];case 5:return a++,[3,1];case 6:return[4,Promise.all(e.map((function(e){return n(g,void 0,void 0,(function(){var n,i,s,a,l,u;return o(this,(function(o){switch(o.label){case 0:n=0,i=t.rowHooks,o.label=1;case 1:if(!(n<i.length))return[3,6];s=i[n],o.label=2;case 2:return o.trys.push([2,4,,5]),a=y("row hook"),[4,s.callback(e,r)];case 3:return l=o.sent(),b(a),c(e.index,l.row),[3,5];case 4:return u=o.sent(),console.error("[Dromo-External-Error] There was an error running your row hook.",u),[3,5];case 5:return n++,[3,1];case 6:return[2]}}))}))})))];case 7:return k.sent(),w=[],i.forEach((function(e,n){w.push({index:n,row:e})})),[2,w]}}))}))},handleStepHook:function(e,n){t.stepHooks.forEach((function(o){if(e===o.type)try{o.callback(t,n)}catch(e){console.error("[Dromo-External-Error] There was an error in your step callback.",e)}}))},handleRowDeleteHooks:function(e){var r=this;return Promise.all(e.map((function(e){return n(r,void 0,void 0,(function(){var r=this;return o(this,(function(i){switch(i.label){case 0:return[4,t.rowDeleteHooks.forEach((function(t){return n(r,void 0,void 0,(function(){var n,r;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),n=y("row delete hook"),[4,t(e)];case 1:return o.sent(),b(n),[3,3];case 2:return r=o.sent(),console.error("[Dromo-External-Error] There was an error running your row delete hook.",r),[3,3];case 3:return[2]}}))}))}))];case 1:return i.sent(),[2]}}))}))})))},handleBeforeFinishCallback:function(e,r){return n(this,void 0,void 0,(function(){var n;return o(this,(function(o){switch(o.label){case 0:if(!t.beforeFinishCallback)return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,t.beforeFinishCallback(e,r,t)];case 2:return[2,o.sent()];case 3:return n=o.sent(),console.error("[Dromo-External-Error] There was an error in your beforeFinish callback.",n),[3,4];case 4:return[2]}}))}))},handleResults:function(e,r){return n(this,void 0,void 0,(function(){var n;return o(this,(function(o){switch(o.label){case 0:if(!t.resultsCallback)return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,t.resultsCallback(e,r)];case 2:return o.sent(),[3,4];case 3:return n=o.sent(),console.error("[Dromo-External-Error] There was an error in your onResult callback.",n),[3,4];case 4:return t.close(),[2]}}))}))},handleCloseModal:function(){t.close()},handleCancel:function(){if(t.cancelCallback)try{t.cancelCallback()}catch(e){console.error("[Dromo-External-Error] There was an error in your cancel callback.",e)}t.close()}}}):console.error("shim cannot connect to Dromo.")},this.mountIFrame=function(){if(!document.getElementById(c.iframeId)){var e=document.createElement("div");e.id=c.wrapperId,e.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),e.style.visibility="hidden",e.style.width="0px",e.style.height="0px",e.style.position="fixed",e.style.top="0px",e.style.left="0px",e.style.right="0px",e.style.bottom="0px",e.appendChild(c.iframe),document.body.appendChild(e),c.wrapper=e}},this.showIFrame=function(){c.wrapper&&(c.wrapper.style.visibility="visible",c.wrapper.style.width="100%",c.wrapper.style.height="100%",document.body.style.overflow="hidden")},this.registerColumnHook=function(e,n){c.columnHooks.push({fieldName:e,callback:n}),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredColHooks(c.columnHooks.length)}))},this.totalNumRowHooks=function(){return c.rowHooks.length+c.bulkRowHooks.length},this.registerBulkRowHook=function(e){c.bulkRowHooks.push(e),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowHooks(c.totalNumRowHooks())}))},this.registerRowHook=function(e){c.rowHooks.push({callback:e}),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowHooks(c.totalNumRowHooks())}))},this.registerStepHook=function(e,n){c.stepHooks.push({type:e,callback:n})},this.registerRowDeleteHook=function(e){c.rowDeleteHooks.push(e),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowDeleteHooks(c.rowDeleteHooks.length)}))},this.beforeFinish=function(e){c.beforeFinishCallback=e},this.registerAllHooks=function(e){if(e.columnHooks)for(var n=0,o=e.columnHooks;n<o.length;n++){var t=o[n],r=t.fieldName,i=t.callback;c.registerColumnHook(r,i)}if(e.rowHooks)for(var s=0,a=e.rowHooks;s<a.length;s++){var l=a[s];c.registerRowHook(l)}if(e.bulkRowHooks)for(var u=0,d=e.bulkRowHooks;u<d.length;u++){var h=d[u];c.registerBulkRowHook(h)}if(e.rowDeleteHooks)for(var f=0,m=e.rowDeleteHooks;f<m.length;f++){var p=m[f];c.registerRowDeleteHook(p)}if(e.stepHooks)for(var v=0,w=e.stepHooks;v<w.length;v++){var g=w[v],k=g.type;i=g.callback;c.registerStepHook(k,i)}e.beforeFinishCallback&&c.beforeFinish(e.beforeFinishCallback)},this.onResults=function(e){c.resultsCallback=e},this.onCancel=function(e){c.cancelCallback=e},this.setUser=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.user=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().setUser(this.user)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},this.addField=function(e,t){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().addField(k(e),t)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.removeField=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().removeField(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.updateInfoMessages=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().updateInfoMessages(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.setHeaderRowOverride=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.headerRowOverride=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().setHeaderRowOverride(e)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},this.open=function(){return n(c,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.wrapper||(this.initIFrame(),this.createConnection(),this.mountIFrame()),[4,this.initChild()];case 1:return e.sent(),this.showIFrame(),[2]}}))}))},this.addRows=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().addRows(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.removeRows=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().removeRows(e)];case 2:return n.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),n.label=4;case 4:return[2]}}))}))},this.close=function(){c.wrapper&&(c.wrapper.style.visibility="hidden",c.wrapper.style.width="0px",c.wrapper.style.height="0px",document.body.style.overflow="inherit")},this.setDevelopmentMode=function(e){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.developmentMode=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,n.sent().setDevelopmentMode(this.developmentMode)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},this.rehydrate=function(e,t){return n(c,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return this.wrapper||(this.initIFrame(),this.createConnection(),this.mountIFrame()),[4,this.initChild()];case 1:return n.sent(),[4,this.connection.promise];case 2:return[4,n.sent().rehydrate(e,t)];case 3:return n.sent(),this.showIFrame(),[2]}}))}))},this.iframeId=Math.random().toString(36).substring(7)+"-dromo-iframe-element",this.wrapperId=Math.random().toString(36).substring(7)+"-dromo-container",this.appHost=document.location.hostname,void 0!==i&&void 0!==s?(this.licenseKey=t,this.fields=r.map(k),this.settings=i,this.user=s):(this.licenseKey=t,this.schemaId=r)}return t.rehydrateHeadless=function(e){var r=e.licenseKey,i=e.headlessImportId,s=e.fields,c=e.settings,a=e.hooks,l=e.rehydrateState;return n(void 0,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return(e=new t(r,s,c,{id:"headless-review"})).registerAllHooks(a),[4,e.rehydrate(l,i)];case 1:return n.sent(),e.open(),[2,e]}}))}))},t}()}));
|
|
15
|
+
***************************************************************************** */var e=function(){return(e=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function t(e,t,n,o){return new(n||(n=Promise))((function(r,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function c(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,c)}a((o=o.apply(e,t||[])).next())}))}function n(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){s.label=i[1];break}if(6===i[0]&&s.label<r[1]){s.label=r[1],r=i;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(i);break}r[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}var o,r,i,s,c,a,l={IFRAME_URL:"https://widget.dromo.io/"}.IFRAME_URL;!function(e){e.INIT_IFRAME="INIT_IFRAME"}(o||(o={})),function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(r||(r={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(i||(i={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(s||(s={})),function(e){e.DataCloneError="DataCloneError"}(c||(c={})),function(e){e.Message="message"}(a||(a={}));const u={"http:":"80","https:":"443"},d=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,h=["file:","data:"];const f=({name:e,message:t,stack:n})=>({name:e,message:t,stack:n});let m=0;var p=()=>++m,v=(e,t,n,o,c)=>{const{localName:l,local:u,remote:d,originForSending:h,originForReceiving:f}=t;let m=!1;c(`${l}: Connecting call sender`);const v=e=>(...t)=>{let n;c(`${l}: Sending ${e}() call`);try{d.closed&&(n=!0)}catch(e){n=!0}if(n&&o(),m){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=s.ConnectionDestroyed,t}return new Promise(((n,o)=>{const s=p(),m=t=>{if(t.source!==d||t.data.penpal!==r.Reply||t.data.id!==s)return;if(t.origin!==f)return void c(`${l} received message from origin ${t.origin} which did not match expected origin ${f}`);const h=t.data;c(`${l}: Received ${e}() reply`),u.removeEventListener(a.Message,m);let p=h.returnValue;h.returnValueIsError&&(p=(e=>{const t=new Error;return Object.keys(e).forEach((n=>t[n]=e[n])),t})(p)),(h.resolution===i.Fulfilled?n:o)(p)};u.addEventListener(a.Message,m);const v={penpal:r.Call,id:s,methodName:e,args:t};d.postMessage(v,h)}))};return n.reduce(((e,t)=>(e[t]=v(t),e)),e),()=>{m=!0}},w=(e,t,n,o,s)=>{const{destroy:l,onDestroy:u}=o;let d,h;const m={};return o=>{if(o.origin!==t)return void s(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${t}`);s("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:o.source,originForSending:n,originForReceiving:t};d&&d(),d=((e,t,n)=>{const{localName:o,local:s,remote:l,originForSending:u,originForReceiving:d}=e;let h=!1;const m=e=>{if(e.source!==l||e.data.penpal!==r.Call)return;if(e.origin!==d)return void n(`${o} received message from origin ${e.origin} which did not match expected origin ${d}`);const s=e.data,{methodName:a,args:m,id:p}=s;n(`${o}: Received ${a}() call`);const v=e=>t=>{if(n(`${o}: Sending ${a}() reply`),h)return void n(`${o}: Unable to send ${a}() reply due to destroyed connection`);const s={penpal:r.Reply,id:p,resolution:e,returnValue:t};e===i.Rejected&&t instanceof Error&&(s.returnValue=f(t),s.returnValueIsError=!0);try{l.postMessage(s,u)}catch(e){if(e.name===c.DataCloneError){const t={penpal:r.Reply,id:p,resolution:i.Rejected,returnValue:f(e),returnValueIsError:!0};l.postMessage(t,u)}throw e}};new Promise((e=>e(t[a].apply(t,m)))).then(v(i.Fulfilled),v(i.Rejected))};return s.addEventListener(a.Message,m),()=>{h=!0,s.removeEventListener(a.Message,m)}})(p,e,s),u(d),h&&h.forEach((e=>{delete m[e]})),h=o.data.methodNames;const w=v(m,p,h,l,s);return u(w),m}};var g=e=>{let{iframe:t,methods:n={},childOrigin:o,timeout:i,debug:c=!1}=e;const l=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(c),f=(()=>{const e=[];let t=!1;return{destroy(n){t=!0,e.forEach((e=>{e(n)}))},onDestroy(n){t?n():e.push(n)}}})(),{onDestroy:m,destroy:p}=f;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=s.NoIframeSrc,e}})(t),o=(e=>{if(e&&h.find((t=>e.startsWith(t))))return"null";const t=document.location,n=d.exec(e);let o,r,i;return n?(o=n[1]?n[1]:t.protocol,r=n[2],i=n[4]):(o=t.protocol,r=t.hostname,i=t.port),`${o}//${r}${i&&i!==u[o]?`:${i}`:""}`})(t.src));const v="null"===o?"*":o,g=((e,t,n,o)=>i=>{if(i.origin!==n)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${n}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:r.SynAck,methodNames:Object.keys(t)};i.source.postMessage(s,o)})(l,n,o,v),k=w(n,o,v,f,l);return{promise:new Promise(((e,n)=>{const o=((e,t)=>{let n;return void 0!==e&&(n=window.setTimeout((()=>{const n=new Error(`Connection timed out after ${e}ms`);n.code=s.ConnectionTimeout,t(n)}),e)),()=>{clearTimeout(n)}})(i,p),c=n=>{if(n.source===t.contentWindow&&n.data)if(n.data.penpal!==r.Syn)if(n.data.penpal!==r.Ack);else{const t=k(n);t&&(o(),e(t))}else g(n)};window.addEventListener(a.Message,c),l("Parent: Awaiting handshake"),((e,t)=>{const{destroy:n,onDestroy:o}=t,r=setInterval((()=>{e.isConnected||(clearInterval(r),n())}),6e4);o((()=>{clearInterval(r)}))})(t,f),m((e=>{window.removeEventListener(a.Message,c),e||((e=new Error("Connection destroyed")).code=s.ConnectionDestroyed),n(e)}))})),destroy(){p()}}},k=function(t){var n=e({},t);return n.validators&&(n.validators=n.validators.map((function(t){return("regex_match"===t.validate||"regex_exclude"===t.validate)&&t.regex instanceof RegExp?e(e({},t),{regex:t.regex.source,regexOptions:{ignoreCase:t.regex.flags.includes("i"),dotAll:t.regex.flags.includes("s"),multiline:t.regex.flags.includes("m"),unicode:t.regex.flags.includes("u")}}):t}))),n},y=function(e){return setTimeout((function(){console.warn("[Dromo Error] Slow ".concat(e," detected (>10s). Long running hooks can degrade user experience and importer performance."))}),1e4)},b=function(e){clearTimeout(e)};return function(){function o(o,r,i,s){var c=this;this.columnHooks=[],this.bulkRowHooks=[],this.rowHooks=[],this.stepHooks=[],this.rowDeleteHooks=[],this.initChild=function(){return t(c,void 0,void 0,(function(){var t,o,r,i,s;return n(this,(function(n){switch(n.label){case 0:return this.connection?[4,this.connection.promise]:(console.error("shim cannot connect with Dromo service."),alert("There was en error opening the importer. Please contact support if this issue persists."),[2]);case 1:return t=n.sent(),o=Array.from(document.getElementsByTagName("script")).some((function(e){return"https://unpkg.com/dromo-uploader-js/dist/DromoUploader.js"===e.src||"https://cdn.jsdelivr.net/npm/dromo-uploader-js@latest/dist/DromoUploader.js"===e.src})),this.fields&&this.settings&&this.user?(r=e({},this.settings),o||(r.version=null!==(i=r.version)&&void 0!==i?i:"v2"),r.browserExcelParsing=null===(s=r.browserExcelParsing)||void 0===s||s,[4,t.init(this.licenseKey,this.fields,r,this.user,this.appHost)]):[3,3];case 2:return n.sent(),[3,6];case 3:return this.schemaId?[4,t.initFromSavedSchema(this.licenseKey,this.schemaId,this.appHost,{user:this.user,developmentMode:this.developmentMode,headerRowOverride:this.headerRowOverride})]:[3,5];case 4:return n.sent(),[3,6];case 5:console.error("Invalid Dromo configuration"),n.label=6;case 6:return[4,t.setNumRegisteredRowHooks(this.totalNumRowHooks())];case 7:return n.sent(),[4,t.setNumRegisteredColHooks(this.columnHooks.length)];case 8:return n.sent(),[4,t.setNumRegisteredRowDeleteHooks(this.rowDeleteHooks.length)];case 9:return n.sent(),[2]}}))}))},this.initIFrame=function(){var e,t;if(!document.getElementById(c.iframeId)){var n=document.createElement("iframe"),o=null!==(t=null===(e=c.settings)||void 0===e?void 0:e.importIdentifier)&&void 0!==t?t:c.schemaId;n.title=o?"Dromo Importer: ".concat(o):"Dromo Importer",n.src=window.DROMO_WIDGET_OVERRIDE||l,n.id=c.iframeId,n.style.height="100%",n.style.width="100%",n.style.border="0",n.crossorigin="anonymous",c.iframe=n}},this.createConnection=function(){var o=c,r=c.iframe;r?c.connection=g({iframe:r,methods:{handleColumnHooks:function(r,i){return t(this,void 0,void 0,(function(){var s,c,a,l,u=this;return n(this,(function(d){switch(d.label){case 0:return s=o.columnHooks.filter((function(e){return e.fieldName===r})),c=new Map,a=i,[4,s.reduce((function(e,o){return t(u,void 0,void 0,(function(){var r=this;return n(this,(function(i){switch(i.label){case 0:return[4,e.then((function(){return t(r,void 0,void 0,(function(){var e,t,r;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),e=y("column hook"),[4,o.callback(a)];case 1:return t=n.sent(),b(e),t.forEach((function(e){if(void 0!==e.value||void 0!==e.info){var t={};void 0!==e.value&&(t.value=e.value,a[e.index]=e.value),void 0!==e.info&&(t.info=e.info),c.set(e.index,t)}})),[3,3];case 2:return r=n.sent(),console.error("[Dromo-External-Error] There was an error running your col hook.",r),[3,3];case 3:return[2]}}))}))}))];case 1:return i.sent(),[2]}}))}))}),Promise.resolve())];case 1:return d.sent(),l=[],c.forEach((function(t,n){return l.push(e(e({},t),{index:n}))})),[2,l]}}))}))},handleRowHooks:function(e,r){return t(this,void 0,void 0,(function(){var i,s,c,a,l,u,d,h,f,m,p,v,w,g=this;return n(this,(function(k){switch(k.label){case 0:i=new Map,s=new Map(e.map((function(e){return[e.index,e]}))),c=function(e,t){for(var n,o=0,r=Object.entries(null!=t?t:{});o<r.length;o++){var c=r[o],a=c[0],l=c[1];if(void 0===l.value&&void 0===l.info&&void 0===l.selectOptions)return;var u=s.get(e),d=i.get(e)||{},h=null!==(n=d[a])&&void 0!==n?n:{};void 0!==l.value&&(h.value=l.value,u.row[a].value=l.value),void 0!==l.info&&(h.info=l.info,u.row[a].info=l.info),void 0!==l.selectOptions&&(h.selectOptions=l.selectOptions,u.row[a].selectOptions=l.selectOptions),d[a]=h,i.set(e,d)}},a=0,l=o.bulkRowHooks,k.label=1;case 1:if(!(a<l.length))return[3,6];u=l[a],k.label=2;case 2:return k.trys.push([2,4,,5]),d=y("bulk row hook"),[4,u(e,r)];case 3:for(h=k.sent(),b(d),f=0,m=h;f<m.length;f++)p=m[f],c(p.index,p.row);return[3,5];case 4:return v=k.sent(),console.error("[Dromo-External-Error] There was an error running your bulk row hook.",v),[3,5];case 5:return a++,[3,1];case 6:return[4,Promise.all(e.map((function(e){return t(g,void 0,void 0,(function(){var t,i,s,a,l,u;return n(this,(function(n){switch(n.label){case 0:t=0,i=o.rowHooks,n.label=1;case 1:if(!(t<i.length))return[3,6];s=i[t],n.label=2;case 2:return n.trys.push([2,4,,5]),a=y("row hook"),[4,s.callback(e,r)];case 3:return l=n.sent(),b(a),c(e.index,l.row),[3,5];case 4:return u=n.sent(),console.error("[Dromo-External-Error] There was an error running your row hook.",u),[3,5];case 5:return t++,[3,1];case 6:return[2]}}))}))})))];case 7:return k.sent(),w=[],i.forEach((function(e,t){w.push({index:t,row:e})})),[2,w]}}))}))},handleStepHook:function(e,t){o.stepHooks.forEach((function(n){if(e===n.type)try{n.callback(o,t)}catch(e){console.error("[Dromo-External-Error] There was an error in your step callback.",e)}}))},handleRowDeleteHooks:function(e){var r=this;return Promise.all(e.map((function(e){return t(r,void 0,void 0,(function(){var r=this;return n(this,(function(i){switch(i.label){case 0:return[4,o.rowDeleteHooks.forEach((function(o){return t(r,void 0,void 0,(function(){var t,r;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t=y("row delete hook"),[4,o(e)];case 1:return n.sent(),b(t),[3,3];case 2:return r=n.sent(),console.error("[Dromo-External-Error] There was an error running your row delete hook.",r),[3,3];case 3:return[2]}}))}))}))];case 1:return i.sent(),[2]}}))}))})))},handleBeforeFinishCallback:function(e,r){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:if(!o.beforeFinishCallback)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,o.beforeFinishCallback(e,r,o)];case 2:return[2,n.sent()];case 3:return t=n.sent(),console.error("[Dromo-External-Error] There was an error in your beforeFinish callback.",t),[3,4];case 4:return[2]}}))}))},handleResults:function(e,r){return t(this,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:if(!o.resultsCallback)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,o.resultsCallback(e,r)];case 2:return n.sent(),[3,4];case 3:return t=n.sent(),console.error("[Dromo-External-Error] There was an error in your onResult callback.",t),[3,4];case 4:return o.close(),[2]}}))}))},handleCloseModal:function(){o.close()},handleCancel:function(){if(o.cancelCallback)try{o.cancelCallback()}catch(e){console.error("[Dromo-External-Error] There was an error in your cancel callback.",e)}o.close()}}}):console.error("shim cannot connect to Dromo.")},this.mountIFrame=function(){if(!document.getElementById(c.iframeId)){var e=document.createElement("div");e.id=c.wrapperId,e.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),e.style.visibility="hidden",e.style.width="0px",e.style.height="0px",e.style.position="fixed",e.style.top="0px",e.style.left="0px",e.style.right="0px",e.style.bottom="0px",e.appendChild(c.iframe),document.body.appendChild(e),c.wrapper=e}},this.showIFrame=function(){c.wrapper&&(c.wrapper.style.visibility="visible",c.wrapper.style.width="100%",c.wrapper.style.height="100%",document.body.style.overflow="hidden")},this.registerColumnHook=function(e,t){c.columnHooks.push({fieldName:e,callback:t}),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredColHooks(c.columnHooks.length)}))},this.totalNumRowHooks=function(){return c.rowHooks.length+c.bulkRowHooks.length},this.registerBulkRowHook=function(e){c.bulkRowHooks.push(e),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowHooks(c.totalNumRowHooks())}))},this.registerRowHook=function(e){c.rowHooks.push({callback:e}),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowHooks(c.totalNumRowHooks())}))},this.registerStepHook=function(e,t){c.stepHooks.push({type:e,callback:t})},this.registerRowDeleteHook=function(e){c.rowDeleteHooks.push(e),c.connection&&c.connection.promise.then((function(e){e.setNumRegisteredRowDeleteHooks(c.rowDeleteHooks.length)}))},this.beforeFinish=function(e){c.beforeFinishCallback=e},this.registerAllHooks=function(e){if(e.columnHooks)for(var t=0,n=e.columnHooks;t<n.length;t++){var o=n[t],r=o.fieldName,i=o.callback;c.registerColumnHook(r,i)}if(e.rowHooks)for(var s=0,a=e.rowHooks;s<a.length;s++){var l=a[s];c.registerRowHook(l)}if(e.bulkRowHooks)for(var u=0,d=e.bulkRowHooks;u<d.length;u++){var h=d[u];c.registerBulkRowHook(h)}if(e.rowDeleteHooks)for(var f=0,m=e.rowDeleteHooks;f<m.length;f++){var p=m[f];c.registerRowDeleteHook(p)}if(e.stepHooks)for(var v=0,w=e.stepHooks;v<w.length;v++){var g=w[v],k=g.type;i=g.callback;c.registerStepHook(k,i)}e.beforeFinishCallback&&c.beforeFinish(e.beforeFinishCallback)},this.onResults=function(e){c.resultsCallback=e},this.onCancel=function(e){c.cancelCallback=e},this.setUser=function(e){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return this.user=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,t.sent().setUser(this.user)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},this.addField=function(e,o){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,t.sent().addField(k(e),o)];case 2:return t.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),t.label=4;case 4:return[2]}}))}))},this.removeField=function(e){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,t.sent().removeField(e)];case 2:return t.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),t.label=4;case 4:return[2]}}))}))},this.updateInfoMessages=function(e){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,t.sent().updateInfoMessages(e)];case 2:return t.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),t.label=4;case 4:return[2]}}))}))},this.setHeaderRowOverride=function(e){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return this.headerRowOverride=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,t.sent().setHeaderRowOverride(e)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},this.open=function(){return t(c,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return this.wrapper||(this.initIFrame(),this.createConnection(),this.mountIFrame()),[4,this.initChild()];case 1:return e.sent(),this.showIFrame(),[2]}}))}))},this.addRows=function(e){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,t.sent().addRows(e)];case 2:return t.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),t.label=4;case 4:return[2]}}))}))},this.removeRows=function(e){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,t.sent().removeRows(e)];case 2:return t.sent(),[3,4];case 3:console.error("[Dromo-Error] Invalid connection to Dromo Uploader."),t.label=4;case 4:return[2]}}))}))},this.close=function(){c.wrapper&&(c.wrapper.style.visibility="hidden",c.wrapper.style.width="0px",c.wrapper.style.height="0px",document.body.style.overflow="inherit")},this.setDevelopmentMode=function(e){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return this.developmentMode=e,this.connection?[4,this.connection.promise]:[3,3];case 1:return[4,t.sent().setDevelopmentMode(this.developmentMode)];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))},this.rehydrate=function(e,o){return t(c,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return this.wrapper||(this.initIFrame(),this.createConnection(),this.mountIFrame()),[4,this.initChild()];case 1:return t.sent(),[4,this.connection.promise];case 2:return[4,t.sent().rehydrate(e,o)];case 3:return t.sent(),this.showIFrame(),[2]}}))}))},this.iframeId=Math.random().toString(36).substring(7)+"-dromo-iframe-element",this.wrapperId=Math.random().toString(36).substring(7)+"-dromo-container",this.appHost=document.location.hostname,void 0!==i&&void 0!==s?(this.licenseKey=o,this.fields=r.map(k),this.settings=i,this.user=s,this.checkCloneable({licenseKey:this.licenseKey,fields:this.fields,settings:this.settings,user:this.user})):(this.licenseKey=o,this.schemaId=r,this.checkCloneable({licenseKey:this.licenseKey,schemaId:this.schemaId}))}var r;return o.prototype.checkCloneable=function(e){if("function"==typeof structuredClone){var t=Object.entries(e).filter((function(e){e[0];var t=e[1];try{return structuredClone(t),!1}catch(e){return!0}})).map((function(e){return e[0]}));if(t.length>0){var n=t.join(", ");throw new Error("[Dromo-External-Error] The Dromo importer received non-cloneable parameters: ".concat(n,". See https://dromo.dev/err/clone"))}}},r=o,o.rehydrateHeadless=function(e){var i=e.licenseKey,s=e.headlessImportId,c=e.fields,a=e.settings,l=e.hooks,u=e.rehydrateState;return t(void 0,void 0,void 0,(function(){var e;return n(r,(function(t){switch(t.label){case 0:return(e=new o(i,c,a,{id:"headless-review"})).registerAllHooks(l),[4,e.rehydrate(u,s)];case 1:return t.sent(),e.open(),[2,e]}}))}))},o}()}));
|
|
16
16
|
//# sourceMappingURL=index.js.map
|