@usecsv/vuejs 1.0.0

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.
@@ -0,0 +1,826 @@
1
+ import Vue from 'vue';
2
+
3
+ /*!
4
+ * @usecsv/js v0.1.0
5
+ * (c) layercode
6
+ * Released under the MIT License.
7
+ */
8
+
9
+ var containers = []; // will store container HTMLElement references
10
+ var styleElements = []; // will store {prepend: HTMLElement, append: HTMLElement}
11
+
12
+ var usage = 'insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).';
13
+
14
+ function insertCss(css, options) {
15
+ options = options || {};
16
+
17
+ if (css === undefined) {
18
+ throw new Error(usage);
19
+ }
20
+
21
+ var position = options.prepend === true ? 'prepend' : 'append';
22
+ var container = options.container !== undefined ? options.container : document.querySelector('head');
23
+ var containerId = containers.indexOf(container);
24
+
25
+ // first time we see this container, create the necessary entries
26
+ if (containerId === -1) {
27
+ containerId = containers.push(container) - 1;
28
+ styleElements[containerId] = {};
29
+ }
30
+
31
+ // try to get the correponding container + position styleElement, create it otherwise
32
+ var styleElement;
33
+
34
+ if (styleElements[containerId] !== undefined && styleElements[containerId][position] !== undefined) {
35
+ styleElement = styleElements[containerId][position];
36
+ } else {
37
+ styleElement = styleElements[containerId][position] = createStyleElement();
38
+
39
+ if (position === 'prepend') {
40
+ container.insertBefore(styleElement, container.childNodes[0]);
41
+ } else {
42
+ container.appendChild(styleElement);
43
+ }
44
+ }
45
+
46
+ // strip potential UTF-8 BOM if css was read from a file
47
+ if (css.charCodeAt(0) === 0xFEFF) { css = css.substr(1, css.length); }
48
+
49
+ // actually add the stylesheet
50
+ if (styleElement.styleSheet) {
51
+ styleElement.styleSheet.cssText += css;
52
+ } else {
53
+ styleElement.textContent += css;
54
+ }
55
+
56
+ return styleElement;
57
+ }
58
+ function createStyleElement() {
59
+ var styleElement = document.createElement('style');
60
+ styleElement.setAttribute('type', 'text/css');
61
+ return styleElement;
62
+ }
63
+
64
+ var insertCss_1 = insertCss;
65
+ var insertCss_2 = insertCss;
66
+ insertCss_1.insertCss = insertCss_2;
67
+
68
+ var MessageType;
69
+ (function (MessageType) {
70
+ MessageType["Call"] = "call";
71
+ MessageType["Reply"] = "reply";
72
+ MessageType["Syn"] = "syn";
73
+ MessageType["SynAck"] = "synAck";
74
+ MessageType["Ack"] = "ack";
75
+ })(MessageType || (MessageType = {}));
76
+ var Resolution;
77
+ (function (Resolution) {
78
+ Resolution["Fulfilled"] = "fulfilled";
79
+ Resolution["Rejected"] = "rejected";
80
+ })(Resolution || (Resolution = {}));
81
+ var ErrorCode;
82
+ (function (ErrorCode) {
83
+ ErrorCode["ConnectionDestroyed"] = "ConnectionDestroyed";
84
+ ErrorCode["ConnectionTimeout"] = "ConnectionTimeout";
85
+ ErrorCode["NoIframeSrc"] = "NoIframeSrc";
86
+ })(ErrorCode || (ErrorCode = {}));
87
+ var NativeErrorName;
88
+ (function (NativeErrorName) {
89
+ NativeErrorName["DataCloneError"] = "DataCloneError";
90
+ })(NativeErrorName || (NativeErrorName = {}));
91
+ var NativeEventType;
92
+ (function (NativeEventType) {
93
+ NativeEventType["Message"] = "message";
94
+ })(NativeEventType || (NativeEventType = {}));
95
+
96
+ var createDestructor = (localName, log) => {
97
+ const callbacks = [];
98
+ let destroyed = false;
99
+ return {
100
+ destroy(error) {
101
+ if (!destroyed) {
102
+ destroyed = true;
103
+ log(`${localName}: Destroying connection`);
104
+ callbacks.forEach((callback) => {
105
+ callback(error);
106
+ });
107
+ }
108
+ },
109
+ onDestroy(callback) {
110
+ destroyed ? callback() : callbacks.push(callback);
111
+ },
112
+ };
113
+ };
114
+
115
+ var createLogger = (debug) => {
116
+ /**
117
+ * Logs a message if debug is enabled.
118
+ */
119
+ return (...args) => {
120
+ if (debug) {
121
+ console.log('[Penpal]', ...args); // eslint-disable-line no-console
122
+ }
123
+ };
124
+ };
125
+
126
+ const DEFAULT_PORT_BY_PROTOCOL = {
127
+ 'http:': '80',
128
+ 'https:': '443',
129
+ };
130
+ const URL_REGEX = /^(https?:)?\/\/([^/:]+)?(:(\d+))?/;
131
+ const opaqueOriginSchemes = ['file:', 'data:'];
132
+ /**
133
+ * Converts a src value into an origin.
134
+ */
135
+ var getOriginFromSrc = (src) => {
136
+ if (src && opaqueOriginSchemes.find((scheme) => src.startsWith(scheme))) {
137
+ // The origin of the child document is an opaque origin and its
138
+ // serialization is "null"
139
+ // https://html.spec.whatwg.org/multipage/origin.html#origin
140
+ return 'null';
141
+ }
142
+ // Note that if src is undefined, then srcdoc is being used instead of src
143
+ // and we can follow this same logic below to get the origin of the parent,
144
+ // which is the origin that we will need to use.
145
+ const location = document.location;
146
+ const regexResult = URL_REGEX.exec(src);
147
+ let protocol;
148
+ let hostname;
149
+ let port;
150
+ if (regexResult) {
151
+ // It's an absolute URL. Use the parsed info.
152
+ // regexResult[1] will be undefined if the URL starts with //
153
+ protocol = regexResult[1] ? regexResult[1] : location.protocol;
154
+ hostname = regexResult[2];
155
+ port = regexResult[4];
156
+ }
157
+ else {
158
+ // It's a relative path. Use the current location's info.
159
+ protocol = location.protocol;
160
+ hostname = location.hostname;
161
+ port = location.port;
162
+ }
163
+ // If the port is the default for the protocol, we don't want to add it to the origin string
164
+ // or it won't match the message's event.origin.
165
+ const portSuffix = port && port !== DEFAULT_PORT_BY_PROTOCOL[protocol] ? `:${port}` : '';
166
+ return `${protocol}//${hostname}${portSuffix}`;
167
+ };
168
+
169
+ /**
170
+ * Converts an error object into a plain object.
171
+ */
172
+ const serializeError = ({ name, message, stack, }) => ({
173
+ name,
174
+ message,
175
+ stack,
176
+ });
177
+ /**
178
+ * Converts a plain object into an error object.
179
+ */
180
+ const deserializeError = (obj) => {
181
+ const deserializedError = new Error();
182
+ // @ts-ignore
183
+ Object.keys(obj).forEach((key) => (deserializedError[key] = obj[key]));
184
+ return deserializedError;
185
+ };
186
+
187
+ /**
188
+ * Listens for "call" messages coming from the remote, executes the corresponding method, and
189
+ * responds with the return value.
190
+ */
191
+ var connectCallReceiver = (info, methods, log) => {
192
+ const { localName, local, remote, originForSending, originForReceiving, } = info;
193
+ let destroyed = false;
194
+ const handleMessageEvent = (event) => {
195
+ if (event.source !== remote || event.data.penpal !== MessageType.Call) {
196
+ return;
197
+ }
198
+ if (event.origin !== originForReceiving) {
199
+ log(`${localName} received message from origin ${event.origin} which did not match expected origin ${originForReceiving}`);
200
+ return;
201
+ }
202
+ const callMessage = event.data;
203
+ const { methodName, args, id } = callMessage;
204
+ log(`${localName}: Received ${methodName}() call`);
205
+ const createPromiseHandler = (resolution) => {
206
+ return (returnValue) => {
207
+ log(`${localName}: Sending ${methodName}() reply`);
208
+ if (destroyed) {
209
+ // It's possible to throw an error here, but it would need to be thrown asynchronously
210
+ // and would only be catchable using window.onerror. This is because the consumer
211
+ // is merely returning a value from their method and not calling any function
212
+ // that they could wrap in a try-catch. Even if the consumer were to catch the error,
213
+ // the value of doing so is questionable. Instead, we'll just log a message.
214
+ log(`${localName}: Unable to send ${methodName}() reply due to destroyed connection`);
215
+ return;
216
+ }
217
+ const message = {
218
+ penpal: MessageType.Reply,
219
+ id,
220
+ resolution,
221
+ returnValue,
222
+ };
223
+ if (resolution === Resolution.Rejected &&
224
+ returnValue instanceof Error) {
225
+ message.returnValue = serializeError(returnValue);
226
+ message.returnValueIsError = true;
227
+ }
228
+ try {
229
+ remote.postMessage(message, originForSending);
230
+ }
231
+ catch (err) {
232
+ // If a consumer attempts to send an object that's not cloneable (e.g., window),
233
+ // we want to ensure the receiver's promise gets rejected.
234
+ if (err.name === NativeErrorName.DataCloneError) {
235
+ const errorReplyMessage = {
236
+ penpal: MessageType.Reply,
237
+ id,
238
+ resolution: Resolution.Rejected,
239
+ returnValue: serializeError(err),
240
+ returnValueIsError: true,
241
+ };
242
+ remote.postMessage(errorReplyMessage, originForSending);
243
+ }
244
+ throw err;
245
+ }
246
+ };
247
+ };
248
+ new Promise((resolve) => resolve(methods[methodName].apply(methods, args))).then(createPromiseHandler(Resolution.Fulfilled), createPromiseHandler(Resolution.Rejected));
249
+ };
250
+ local.addEventListener(NativeEventType.Message, handleMessageEvent);
251
+ return () => {
252
+ destroyed = true;
253
+ local.removeEventListener(NativeEventType.Message, handleMessageEvent);
254
+ };
255
+ };
256
+
257
+ let id = 0;
258
+ /**
259
+ * @return {number} A unique ID (not universally unique)
260
+ */
261
+ var generateId = () => ++id;
262
+
263
+ /**
264
+ * Augments an object with methods that match those defined by the remote. When these methods are
265
+ * called, a "call" message will be sent to the remote, the remote's corresponding method will be
266
+ * executed, and the method's return value will be returned via a message.
267
+ * @param {Object} callSender Sender object that should be augmented with methods.
268
+ * @param {Object} info Information about the local and remote windows.
269
+ * @param {Array} methodNames Names of methods available to be called on the remote.
270
+ * @param {Promise} destructionPromise A promise resolved when destroy() is called on the penpal
271
+ * connection.
272
+ * @returns {Object} The call sender object with methods that may be called.
273
+ */
274
+ var connectCallSender = (callSender, info, methodNames, destroyConnection, log) => {
275
+ const { localName, local, remote, originForSending, originForReceiving, } = info;
276
+ let destroyed = false;
277
+ log(`${localName}: Connecting call sender`);
278
+ const createMethodProxy = (methodName) => {
279
+ return (...args) => {
280
+ log(`${localName}: Sending ${methodName}() call`);
281
+ // This handles the case where the iframe has been removed from the DOM
282
+ // (and therefore its window closed), the consumer has not yet
283
+ // called destroy(), and the user calls a method exposed by
284
+ // the remote. We detect the iframe has been removed and force
285
+ // a destroy() immediately so that the consumer sees the error saying
286
+ // the connection has been destroyed. We wrap this check in a try catch
287
+ // because Edge throws an "Object expected" error when accessing
288
+ // contentWindow.closed on a contentWindow from an iframe that's been
289
+ // removed from the DOM.
290
+ let iframeRemoved;
291
+ try {
292
+ if (remote.closed) {
293
+ iframeRemoved = true;
294
+ }
295
+ }
296
+ catch (e) {
297
+ iframeRemoved = true;
298
+ }
299
+ if (iframeRemoved) {
300
+ destroyConnection();
301
+ }
302
+ if (destroyed) {
303
+ const error = new Error(`Unable to send ${methodName}() call due ` + `to destroyed connection`);
304
+ error.code = ErrorCode.ConnectionDestroyed;
305
+ throw error;
306
+ }
307
+ return new Promise((resolve, reject) => {
308
+ const id = generateId();
309
+ const handleMessageEvent = (event) => {
310
+ if (event.source !== remote ||
311
+ event.data.penpal !== MessageType.Reply ||
312
+ event.data.id !== id) {
313
+ return;
314
+ }
315
+ if (event.origin !== originForReceiving) {
316
+ log(`${localName} received message from origin ${event.origin} which did not match expected origin ${originForReceiving}`);
317
+ return;
318
+ }
319
+ const replyMessage = event.data;
320
+ log(`${localName}: Received ${methodName}() reply`);
321
+ local.removeEventListener(NativeEventType.Message, handleMessageEvent);
322
+ let returnValue = replyMessage.returnValue;
323
+ if (replyMessage.returnValueIsError) {
324
+ returnValue = deserializeError(returnValue);
325
+ }
326
+ (replyMessage.resolution === Resolution.Fulfilled ? resolve : reject)(returnValue);
327
+ };
328
+ local.addEventListener(NativeEventType.Message, handleMessageEvent);
329
+ const callMessage = {
330
+ penpal: MessageType.Call,
331
+ id,
332
+ methodName,
333
+ args,
334
+ };
335
+ remote.postMessage(callMessage, originForSending);
336
+ });
337
+ };
338
+ };
339
+ methodNames.reduce((api, methodName) => {
340
+ api[methodName] = createMethodProxy(methodName);
341
+ return api;
342
+ }, callSender);
343
+ return () => {
344
+ destroyed = true;
345
+ };
346
+ };
347
+
348
+ /**
349
+ * Handles an ACK handshake message.
350
+ */
351
+ var handleAckMessageFactory = (methods, childOrigin, originForSending, destructor, log) => {
352
+ const { destroy, onDestroy } = destructor;
353
+ let destroyCallReceiver;
354
+ let receiverMethodNames;
355
+ // We resolve the promise with the call sender. If the child reconnects
356
+ // (for example, after refreshing or navigating to another page that
357
+ // uses Penpal, we'll update the call sender with methods that match the
358
+ // latest provided by the child.
359
+ const callSender = {};
360
+ return (event) => {
361
+ if (event.origin !== childOrigin) {
362
+ log(`Parent: Handshake - Received ACK message from origin ${event.origin} which did not match expected origin ${childOrigin}`);
363
+ return;
364
+ }
365
+ log('Parent: Handshake - Received ACK');
366
+ const info = {
367
+ localName: 'Parent',
368
+ local: window,
369
+ remote: event.source,
370
+ originForSending: originForSending,
371
+ originForReceiving: childOrigin,
372
+ };
373
+ // If the child reconnected, we need to destroy the prior call receiver
374
+ // before setting up a new one.
375
+ if (destroyCallReceiver) {
376
+ destroyCallReceiver();
377
+ }
378
+ destroyCallReceiver = connectCallReceiver(info, methods, log);
379
+ onDestroy(destroyCallReceiver);
380
+ // If the child reconnected, we need to remove the methods from the
381
+ // previous call receiver off the sender.
382
+ if (receiverMethodNames) {
383
+ receiverMethodNames.forEach((receiverMethodName) => {
384
+ delete callSender[receiverMethodName];
385
+ });
386
+ }
387
+ receiverMethodNames = event.data.methodNames;
388
+ const destroyCallSender = connectCallSender(callSender, info, receiverMethodNames, destroy, log);
389
+ onDestroy(destroyCallSender);
390
+ return callSender;
391
+ };
392
+ };
393
+
394
+ /**
395
+ * Handles a SYN handshake message.
396
+ */
397
+ var handleSynMessageFactory = (log, methods, childOrigin, originForSending) => {
398
+ return (event) => {
399
+ if (event.origin !== childOrigin) {
400
+ log(`Parent: Handshake - Received SYN message from origin ${event.origin} which did not match expected origin ${childOrigin}`);
401
+ return;
402
+ }
403
+ log('Parent: Handshake - Received SYN, responding with SYN-ACK');
404
+ const synAckMessage = {
405
+ penpal: MessageType.SynAck,
406
+ methodNames: Object.keys(methods),
407
+ };
408
+ event.source.postMessage(synAckMessage, originForSending);
409
+ };
410
+ };
411
+
412
+ const CHECK_IFRAME_IN_DOC_INTERVAL = 60000;
413
+ /**
414
+ * Monitors for iframe removal and destroys connection if iframe
415
+ * is found to have been removed from DOM. This is to prevent memory
416
+ * leaks when the iframe is removed from the document and the consumer
417
+ * hasn't called destroy(). Without this, event listeners attached to
418
+ * the window would stick around and since the event handlers have a
419
+ * reference to the iframe in their closures, the iframe would stick
420
+ * around too.
421
+ */
422
+ var monitorIframeRemoval = (iframe, destructor) => {
423
+ const { destroy, onDestroy } = destructor;
424
+ const checkIframeInDocIntervalId = setInterval(() => {
425
+ if (!iframe.isConnected) {
426
+ clearInterval(checkIframeInDocIntervalId);
427
+ destroy();
428
+ }
429
+ }, CHECK_IFRAME_IN_DOC_INTERVAL);
430
+ onDestroy(() => {
431
+ clearInterval(checkIframeInDocIntervalId);
432
+ });
433
+ };
434
+
435
+ /**
436
+ * Starts a timeout and calls the callback with an error
437
+ * if the timeout completes before the stop function is called.
438
+ */
439
+ var startConnectionTimeout = (timeout, callback) => {
440
+ let timeoutId;
441
+ if (timeout !== undefined) {
442
+ timeoutId = window.setTimeout(() => {
443
+ const error = new Error(`Connection timed out after ${timeout}ms`);
444
+ error.code = ErrorCode.ConnectionTimeout;
445
+ callback(error);
446
+ }, timeout);
447
+ }
448
+ return () => {
449
+ clearTimeout(timeoutId);
450
+ };
451
+ };
452
+
453
+ var validateIframeHasSrcOrSrcDoc = (iframe) => {
454
+ if (!iframe.src && !iframe.srcdoc) {
455
+ const error = new Error('Iframe must have src or srcdoc property defined.');
456
+ error.code = ErrorCode.NoIframeSrc;
457
+ throw error;
458
+ }
459
+ };
460
+
461
+ /**
462
+ * Attempts to establish communication with an iframe.
463
+ */
464
+ var connectToChild = (options) => {
465
+ let { iframe, methods = {}, childOrigin, timeout, debug = false } = options;
466
+ const log = createLogger(debug);
467
+ const destructor = createDestructor('Parent', log);
468
+ const { onDestroy, destroy } = destructor;
469
+ if (!childOrigin) {
470
+ validateIframeHasSrcOrSrcDoc(iframe);
471
+ childOrigin = getOriginFromSrc(iframe.src);
472
+ }
473
+ // If event.origin is "null", the remote protocol is file: or data: and we
474
+ // must post messages with "*" as targetOrigin when sending messages.
475
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#Using_window.postMessage_in_extensions
476
+ const originForSending = childOrigin === 'null' ? '*' : childOrigin;
477
+ const handleSynMessage = handleSynMessageFactory(log, methods, childOrigin, originForSending);
478
+ const handleAckMessage = handleAckMessageFactory(methods, childOrigin, originForSending, destructor, log);
479
+ const promise = new Promise((resolve, reject) => {
480
+ const stopConnectionTimeout = startConnectionTimeout(timeout, destroy);
481
+ const handleMessage = (event) => {
482
+ if (event.source !== iframe.contentWindow || !event.data) {
483
+ return;
484
+ }
485
+ if (event.data.penpal === MessageType.Syn) {
486
+ handleSynMessage(event);
487
+ return;
488
+ }
489
+ if (event.data.penpal === MessageType.Ack) {
490
+ const callSender = handleAckMessage(event);
491
+ if (callSender) {
492
+ stopConnectionTimeout();
493
+ resolve(callSender);
494
+ }
495
+ return;
496
+ }
497
+ };
498
+ window.addEventListener(NativeEventType.Message, handleMessage);
499
+ log('Parent: Awaiting handshake');
500
+ monitorIframeRemoval(iframe, destructor);
501
+ onDestroy((error) => {
502
+ window.removeEventListener(NativeEventType.Message, handleMessage);
503
+ if (error) {
504
+ reject(error);
505
+ }
506
+ });
507
+ });
508
+ return {
509
+ promise,
510
+ destroy() {
511
+ // Don't allow consumer to pass an error into destroy.
512
+ destroy();
513
+ },
514
+ };
515
+ };
516
+
517
+ /* eslint no-void: "off" */
518
+
519
+ // Loaded ready states
520
+ var loadedStates = ['interactive', 'complete'];
521
+
522
+ // Return Promise
523
+ var whenDomReady = function whenDomReady(cb, doc) {
524
+ return new Promise(function (resolve) {
525
+ // Allow doc to be passed in as the lone first param
526
+ if (cb && typeof cb !== 'function') {
527
+ doc = cb;
528
+ cb = null;
529
+ }
530
+
531
+ // Use global document if we don't have one
532
+ doc = doc || window.document;
533
+
534
+ // Handle DOM load
535
+ var done = function done() {
536
+ return resolve(void (cb && setTimeout(cb)));
537
+ };
538
+
539
+ // Resolve now if DOM has already loaded
540
+ // Otherwise wait for DOMContentLoaded
541
+ if (loadedStates.indexOf(doc.readyState) !== -1) {
542
+ done();
543
+ } else {
544
+ doc.addEventListener('DOMContentLoaded', done);
545
+ }
546
+ });
547
+ };
548
+
549
+ // Promise chain helper
550
+ whenDomReady.resume = function (doc) {
551
+ return function (val) {
552
+ return whenDomReady(doc).then(function () {
553
+ return val;
554
+ });
555
+ };
556
+ };
557
+
558
+ // eslint-disable-next-line dot-notation
559
+ var MOUNT_URL = {"MOUNT_URL":"https://app.usecsv.com/importer"}["MOUNT_URL"] ;
560
+ var insertIframe = function (id) {
561
+ var _a;
562
+ insertCss_2("\n .usecsv_container {\n position: fixed;\n top: 0;\n bottom: 0;\n right: 0;\n left: 0;\n z-index: 100000;\n }\n .usecsv_container iframe {\n width: 100%;\n height: 100%;\n position: absolute;\n border-width: 0;\n }\n .usecsv_container {\n overflow: hidden;\n overscroll-behavior-x: none;\n }\n");
563
+ document.body.insertAdjacentHTML("beforeend", "<div id=".concat(id, " class=\"usecsv_container loading\">\n</div>"));
564
+ var iframe = document.createElement("iframe");
565
+ iframe.setAttribute("src", MOUNT_URL);
566
+ (_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.appendChild(iframe);
567
+ return iframe;
568
+ };
569
+ var useCsvPlugin = function (_a) {
570
+ var importerKey = _a.importerKey, user = _a.user, metadata = _a.metadata;
571
+ var id = "usecsv-".concat(Math.round(Math.random() * 100000000));
572
+ return whenDomReady().then(function () {
573
+ var iframe = insertIframe(id);
574
+ var iframeConnection = connectToChild({
575
+ iframe: iframe,
576
+ methods: {
577
+ closeIframe: function () {
578
+ var _a;
579
+ (_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.remove();
580
+ },
581
+ },
582
+ });
583
+ iframeConnection.promise.then(function (child) {
584
+ var _a;
585
+ (_a = document.getElementById(id)) === null || _a === void 0 ? void 0 : _a.classList.remove("loading");
586
+ // eslint-disable-next-line dot-notation
587
+ child["setParams"] && child["setParams"]({ importerKey: importerKey, user: user, metadata: metadata });
588
+ });
589
+ return iframeConnection;
590
+ });
591
+ };
592
+
593
+ var script = /*#__PURE__*/Vue.extend({
594
+ name: "use-csv",
595
+
596
+ data() {
597
+ return {
598
+ hasSlot: !!this.$slots.default
599
+ };
600
+ },
601
+
602
+ methods: {
603
+ onclick() {
604
+ useCsvPlugin({
605
+ importerKey: this.importerKey,
606
+ user: this.importerKey,
607
+ metadata: this.metadata
608
+ });
609
+ },
610
+
611
+ hasScopedSlot() {
612
+ console.log(this.$scopedSlots.default && this.$scopedSlots.default.name);
613
+ return (this.$scopedSlots.default && this.$scopedSlots.default.name) === "normalized";
614
+ }
615
+
616
+ }
617
+ });
618
+
619
+ function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
620
+ if (typeof shadowMode !== 'boolean') {
621
+ createInjectorSSR = createInjector;
622
+ createInjector = shadowMode;
623
+ shadowMode = false;
624
+ }
625
+ // Vue.extend constructor export interop.
626
+ const options = typeof script === 'function' ? script.options : script;
627
+ // render functions
628
+ if (template && template.render) {
629
+ options.render = template.render;
630
+ options.staticRenderFns = template.staticRenderFns;
631
+ options._compiled = true;
632
+ // functional template
633
+ if (isFunctionalTemplate) {
634
+ options.functional = true;
635
+ }
636
+ }
637
+ // scopedId
638
+ if (scopeId) {
639
+ options._scopeId = scopeId;
640
+ }
641
+ let hook;
642
+ if (moduleIdentifier) {
643
+ // server build
644
+ hook = function (context) {
645
+ // 2.3 injection
646
+ context =
647
+ context || // cached call
648
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
649
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
650
+ // 2.2 with runInNewContext: true
651
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
652
+ context = __VUE_SSR_CONTEXT__;
653
+ }
654
+ // inject component styles
655
+ if (style) {
656
+ style.call(this, createInjectorSSR(context));
657
+ }
658
+ // register component module identifier for async chunk inference
659
+ if (context && context._registeredComponents) {
660
+ context._registeredComponents.add(moduleIdentifier);
661
+ }
662
+ };
663
+ // used by ssr in case component is cached and beforeCreate
664
+ // never gets called
665
+ options._ssrRegister = hook;
666
+ }
667
+ else if (style) {
668
+ hook = shadowMode
669
+ ? function (context) {
670
+ style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
671
+ }
672
+ : function (context) {
673
+ style.call(this, createInjector(context));
674
+ };
675
+ }
676
+ if (hook) {
677
+ if (options.functional) {
678
+ // register for functional component in vue file
679
+ const originalRender = options.render;
680
+ options.render = function renderWithStyleInjection(h, context) {
681
+ hook.call(context);
682
+ return originalRender(h, context);
683
+ };
684
+ }
685
+ else {
686
+ // inject component registration as beforeCreate hook
687
+ const existing = options.beforeCreate;
688
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
689
+ }
690
+ }
691
+ return script;
692
+ }
693
+
694
+ const isOldIE = typeof navigator !== 'undefined' &&
695
+ /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
696
+ function createInjector(context) {
697
+ return (id, style) => addStyle(id, style);
698
+ }
699
+ let HEAD;
700
+ const styles = {};
701
+ function addStyle(id, css) {
702
+ const group = isOldIE ? css.media || 'default' : id;
703
+ const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
704
+ if (!style.ids.has(id)) {
705
+ style.ids.add(id);
706
+ let code = css.source;
707
+ if (css.map) {
708
+ // https://developer.chrome.com/devtools/docs/javascript-debugging
709
+ // this makes source maps inside style tags work properly in Chrome
710
+ code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
711
+ // http://stackoverflow.com/a/26603875
712
+ code +=
713
+ '\n/*# sourceMappingURL=data:application/json;base64,' +
714
+ btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
715
+ ' */';
716
+ }
717
+ if (!style.element) {
718
+ style.element = document.createElement('style');
719
+ style.element.type = 'text/css';
720
+ if (css.media)
721
+ style.element.setAttribute('media', css.media);
722
+ if (HEAD === undefined) {
723
+ HEAD = document.head || document.getElementsByTagName('head')[0];
724
+ }
725
+ HEAD.appendChild(style.element);
726
+ }
727
+ if ('styleSheet' in style.element) {
728
+ style.styles.push(code);
729
+ style.element.styleSheet.cssText = style.styles
730
+ .filter(Boolean)
731
+ .join('\n');
732
+ }
733
+ else {
734
+ const index = style.ids.size - 1;
735
+ const textNode = document.createTextNode(code);
736
+ const nodes = style.element.childNodes;
737
+ if (nodes[index])
738
+ style.element.removeChild(nodes[index]);
739
+ if (nodes.length)
740
+ style.element.insertBefore(textNode, nodes[index]);
741
+ else
742
+ style.element.appendChild(textNode);
743
+ }
744
+ }
745
+ }
746
+
747
+ /* script */
748
+ const __vue_script__ = script;
749
+ /* template */
750
+
751
+ var __vue_render__ = function () {
752
+ var _vm = this;
753
+
754
+ var _h = _vm.$createElement;
755
+
756
+ var _c = _vm._self._c || _h;
757
+
758
+ return _c('div', {
759
+ staticClass: "usecsv"
760
+ }, [_vm.hasScopedSlot() ? _c('div', [_vm._t("default", function () {
761
+ return [_vm._v(" open usecsv ")];
762
+ }, {
763
+ "onclick": _vm.onclick
764
+ })], 2) : _c('div', [_c('button', {
765
+ attrs: {
766
+ "type": "button",
767
+ "id": "usecsv-button"
768
+ },
769
+ on: {
770
+ "click": _vm.onclick
771
+ }
772
+ }, [_vm._t("default", function () {
773
+ return [_vm._v(" open usecsv ")];
774
+ })], 2)])]);
775
+ };
776
+
777
+ var __vue_staticRenderFns__ = [];
778
+ /* style */
779
+
780
+ const __vue_inject_styles__ = function (inject) {
781
+ if (!inject) return;
782
+ inject("data-v-d2ea7b16_0", {
783
+ source: "#usecsv-button[data-v-d2ea7b16]{background-color:#fff;color:#000;border:2px solid #000;border-radius:6px;padding:10px 15px;text-align:center;font-size:16px;cursor:pointer}",
784
+ map: undefined,
785
+ media: undefined
786
+ });
787
+ };
788
+ /* scoped */
789
+
790
+
791
+ const __vue_scope_id__ = "data-v-d2ea7b16";
792
+ /* module identifier */
793
+
794
+ const __vue_module_identifier__ = undefined;
795
+ /* functional template */
796
+
797
+ const __vue_is_functional_template__ = false;
798
+ /* style inject SSR */
799
+
800
+ /* style inject shadow dom */
801
+
802
+ const __vue_component__ = /*#__PURE__*/normalizeComponent({
803
+ render: __vue_render__,
804
+ staticRenderFns: __vue_staticRenderFns__
805
+ }, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, createInjector, undefined, undefined);
806
+
807
+ var component = __vue_component__;
808
+
809
+ // Import vue component
810
+ // IIFE injects install function into component, allowing component
811
+ // to be registered via Vue.use() as well as Vue.component(),
812
+
813
+ var entry_esm = /*#__PURE__*/(() => {
814
+ // Assign InstallableComponent type
815
+ const installable = component; // Attach install function executed by Vue.use()
816
+
817
+ installable.install = Vue => {
818
+ Vue.component('use-csv', installable);
819
+ };
820
+
821
+ return installable;
822
+ })(); // It's possible to expose named exports when writing components that can
823
+ // also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo';
824
+ // export const RollupDemoDirective = directive;
825
+
826
+ export { entry_esm as default };