amazon-quicksight-embedding-sdk
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -1,28 +0,20 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
var _eventify = _interopRequireDefault(require("./lib/eventify")); | ||
var _eventify = require('./lib/eventify'); | ||
var _constructEvent = _interopRequireDefault(require("./lib/constructEvent")); | ||
var _eventify2 = _interopRequireDefault(_eventify); | ||
var _constants = require("./lib/constants"); | ||
var _constructEvent = require('./lib/constructEvent'); | ||
var _punycode = _interopRequireDefault(require("punycode")); | ||
var _constructEvent2 = _interopRequireDefault(_constructEvent); | ||
var _constants = require('./lib/constants'); | ||
var _punycode = require('punycode'); | ||
var _punycode2 = _interopRequireDefault(_punycode); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
@@ -51,149 +43,148 @@ /** | ||
*/ | ||
var EmbeddableDashboard = function () { | ||
class EmbeddableDashboard { | ||
/* eslint-disable complexity */ | ||
constructor(options) { | ||
if (!options) { | ||
throw new Error('options is required'); | ||
} | ||
/* eslint-disable complexity */ | ||
function EmbeddableDashboard(options) { | ||
_classCallCheck(this, EmbeddableDashboard); | ||
if (!options.url) { | ||
throw new Error('url is required'); | ||
} | ||
if (!options) { | ||
throw new Error('options is required'); | ||
} | ||
var { | ||
url, | ||
container, | ||
parameters, | ||
errorCallback, | ||
loadCallback | ||
} = options; | ||
this.url = url; | ||
if (!options.url) { | ||
throw new Error('url is required'); | ||
} | ||
if (container instanceof HTMLElement) { | ||
this.container = container; | ||
} else if (typeof container === 'string') { | ||
this.container = document.querySelector(container); | ||
} | ||
var url = options.url, | ||
container = options.container, | ||
parameters = options.parameters, | ||
errorCallback = options.errorCallback, | ||
loadCallback = options.loadCallback; | ||
if (!this.container) { | ||
throw new Error('can\'t find valid container'); | ||
} | ||
this.parameters = parameters; | ||
this.iframe = createIframe(options); | ||
(0, _eventify.default)(this); | ||
this.url = url; | ||
if (typeof errorCallback === 'function') { | ||
this.on(_constants.CLIENT_FACING_EVENT_NAMES.error, errorCallback); | ||
} | ||
if (container instanceof HTMLElement) { | ||
this.container = container; | ||
} else if (typeof container === 'string') { | ||
this.container = document.querySelector(container); | ||
} | ||
if (typeof loadCallback === 'function') { | ||
this.on(_constants.CLIENT_FACING_EVENT_NAMES.load, loadCallback); | ||
} | ||
if (!this.container) { | ||
throw new Error('can\'t find valid container'); | ||
} | ||
window.addEventListener('message', function (event) { | ||
if (!event) { | ||
return; | ||
} | ||
this.parameters = parameters; | ||
if (event.source === (this.iframe && this.iframe.contentWindow)) { | ||
var { | ||
eventName, | ||
payload | ||
} = event.data; | ||
this.trigger(_constants.CLIENT_FACING_EVENT_NAMES[eventName], payload); | ||
this.iframe = createIframe(options); | ||
if (eventName === _constants.IN_COMING_POST_MESSAGE_EVENT_NAMES.RESIZE_EVENT) { | ||
var { | ||
height | ||
} = options; | ||
(0, _eventify2.default)(this); | ||
if (typeof errorCallback === 'function') { | ||
this.on(_constants.CLIENT_FACING_EVENT_NAMES.error, errorCallback); | ||
if (height === _constants.DASHBOARD_SIZE_OPTIONS.AUTO_FIT) { | ||
this.iframe.height = payload.height; | ||
} | ||
} | ||
} | ||
}.bind(this), false); | ||
this.getContainer = this.getContainer.bind(this); | ||
this.getParameters = this.getParameters.bind(this); | ||
this.getUrl = this.getUrl.bind(this); | ||
this.setParameters = this.setParameters.bind(this); | ||
} | ||
if (typeof loadCallback === 'function') { | ||
this.on(_constants.CLIENT_FACING_EVENT_NAMES.load, loadCallback); | ||
} | ||
getUrl() { | ||
return this.url; | ||
} | ||
window.addEventListener('message', function (event) { | ||
if (!event) { | ||
return; | ||
} | ||
if (event.source === (this.iframe && this.iframe.contentWindow)) { | ||
var _event$data = event.data, | ||
eventName = _event$data.eventName, | ||
payload = _event$data.payload; | ||
getContainer() { | ||
return this.container; | ||
} | ||
this.trigger(_constants.CLIENT_FACING_EVENT_NAMES[eventName], payload); | ||
if (eventName === _constants.IN_COMING_POST_MESSAGE_EVENT_NAMES.RESIZE_EVENT) { | ||
var height = options.height; | ||
getParameters() { | ||
return this.parameters; | ||
} | ||
if (height === _constants.DASHBOARD_SIZE_OPTIONS.AUTO_FIT) { | ||
this.iframe.height = payload.height; | ||
} | ||
} | ||
} | ||
}.bind(this), false); | ||
setParameters(parameters) { | ||
var eventName = _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES.UPDATE_PARAMETER_VALUES; | ||
var payload = { | ||
parameters | ||
}; | ||
var event = (0, _constructEvent.default)(eventName, payload); | ||
this.iframe.contentWindow.postMessage(event, this.url); | ||
} | ||
this.getContainer = this.getContainer.bind(this); | ||
this.getParameters = this.getParameters.bind(this); | ||
this.getUrl = this.getUrl.bind(this); | ||
this.setParameters = this.setParameters.bind(this); | ||
} | ||
} | ||
_createClass(EmbeddableDashboard, [{ | ||
key: 'getUrl', | ||
value: function getUrl() { | ||
return this.url; | ||
} | ||
}, { | ||
key: 'getContainer', | ||
value: function getContainer() { | ||
return this.container; | ||
} | ||
}, { | ||
key: 'getParameters', | ||
value: function getParameters() { | ||
return this.parameters; | ||
} | ||
}, { | ||
key: 'setParameters', | ||
value: function setParameters(parameters) { | ||
var eventName = _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES.UPDATE_PARAMETER_VALUES; | ||
var payload = { parameters: parameters }; | ||
var event = (0, _constructEvent2.default)(eventName, payload); | ||
this.iframe.contentWindow.postMessage(event, this.url); | ||
} | ||
}]); | ||
function createIframe(options) { | ||
var { | ||
width, | ||
height | ||
} = options; | ||
var { | ||
loadingHeight, | ||
url, | ||
scrolling, | ||
className | ||
} = options; | ||
return EmbeddableDashboard; | ||
}(); | ||
if (height === _constants.DASHBOARD_SIZE_OPTIONS.AUTO_FIT) { | ||
height = loadingHeight; | ||
} | ||
function createIframe(options) { | ||
var width = options.width, | ||
height = options.height; | ||
var loadingHeight = options.loadingHeight, | ||
url = options.url, | ||
scrolling = options.scrolling, | ||
className = options.className; | ||
if (height === _constants.DASHBOARD_SIZE_OPTIONS.AUTO_FIT) { | ||
height = loadingHeight; | ||
} | ||
var iframe = document.createElement('iframe'); | ||
iframe.className = ['quicksight-embedding-iframe', className].join(' ').trim(); | ||
iframe.width = width || '100%'; | ||
iframe.height = height || '100%'; | ||
iframe.scrolling = scrolling || 'no'; | ||
iframe.onload = sendInitialPostMessage.bind(null, iframe, url); | ||
iframe.src = getIframeSrc(options); | ||
iframe.style.border = '0px'; | ||
iframe.style.padding = '0px'; | ||
return iframe; | ||
var iframe = document.createElement('iframe'); | ||
iframe.className = ['quicksight-embedding-iframe', className].join(' ').trim(); | ||
iframe.width = width || '100%'; | ||
iframe.height = height || '100%'; | ||
iframe.scrolling = scrolling || 'no'; | ||
iframe.onload = sendInitialPostMessage.bind(null, iframe, url); | ||
iframe.src = getIframeSrc(options); | ||
iframe.style.border = '0px'; | ||
iframe.style.padding = '0px'; | ||
return iframe; | ||
} | ||
function getIframeSrc(options) { | ||
var url = options.url, | ||
parameters = options.parameters, | ||
locale = options.locale, | ||
footerPaddingEnabled = options.footerPaddingEnabled; | ||
var { | ||
url, | ||
parameters, | ||
locale, | ||
footerPaddingEnabled | ||
} = options; | ||
var src = url + '&punyCodeEmbedOrigin=' + _punycode2.default.encode(window.location.origin + '/'); | ||
var src = url + '&punyCodeEmbedOrigin=' + _punycode.default.encode(window.location.origin + '/'); | ||
if (locale) { | ||
src = src + '&locale=' + locale; | ||
} | ||
if (locale) { | ||
src = src + '&locale=' + locale; | ||
} | ||
if (footerPaddingEnabled) { | ||
src = src + '&footerPaddingEnabled=' + String(footerPaddingEnabled); | ||
} | ||
if (footerPaddingEnabled) { | ||
src = src + '&footerPaddingEnabled=' + String(footerPaddingEnabled); | ||
} | ||
if (parameters) { | ||
return useParameterValuesInUrl(src, parameters); | ||
} | ||
if (parameters) { | ||
return useParameterValuesInUrl(src, parameters); | ||
} | ||
return src; | ||
return src; | ||
} | ||
/** | ||
@@ -206,29 +197,27 @@ * Use parameter values in url. | ||
*/ | ||
function useParameterValuesInUrl(url, parameters) { | ||
var parameterNames = Object.keys(parameters); | ||
var parameterStrings = parameterNames.map(function (name) { | ||
var value = parameters[name]; | ||
var values = [].concat(value); | ||
var encodedName = encodeURIComponent(name); | ||
return values.map(function (paramValue) { | ||
return encodeURIComponent(paramValue); | ||
}).map(function (encodedValue) { | ||
return 'p.' + encodedName + '=' + encodedValue; | ||
}).join('&'); | ||
}); | ||
return url + '#' + parameterStrings.join('&'); | ||
var parameterNames = Object.keys(parameters); | ||
var parameterStrings = parameterNames.map(name => { | ||
var value = parameters[name]; | ||
var values = [].concat(value); | ||
var encodedName = encodeURIComponent(name); | ||
return values.map(paramValue => encodeURIComponent(paramValue)).map(encodedValue => "p.".concat(encodedName, "=").concat(encodedValue)).join('&'); | ||
}); | ||
return "".concat(url, "#").concat(parameterStrings.join('&')); | ||
} | ||
function sendInitialPostMessage(iframe, domain) { | ||
if (iframe.contentWindow === null) { | ||
setTimeout(sendInitialPostMessage.bind(null, iframe, domain), 100); | ||
} | ||
if (iframe.contentWindow === null) { | ||
setTimeout(sendInitialPostMessage.bind(null, iframe, domain), 100); | ||
} | ||
var eventName = _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES.ESTABLISH_MESSAGE_CHANNEL; | ||
var event = (0, _constructEvent2.default)(eventName); | ||
// wait until iframe.contentWindow exists and send message to iframe window | ||
iframe.contentWindow.postMessage(event, domain); | ||
var eventName = _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES.ESTABLISH_MESSAGE_CHANNEL; | ||
var event = (0, _constructEvent.default)(eventName); // wait until iframe.contentWindow exists and send message to iframe window | ||
iframe.contentWindow.postMessage(event, domain); | ||
} | ||
exports.default = EmbeddableDashboard; | ||
var _default = EmbeddableDashboard; | ||
exports.default = _default; |
@@ -1,13 +0,15 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _EmbeddableDashboard = require('./EmbeddableDashboard'); | ||
var _EmbeddableDashboard = _interopRequireDefault(require("./EmbeddableDashboard")); | ||
var _EmbeddableDashboard2 = _interopRequireDefault(_EmbeddableDashboard); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/** | ||
@@ -20,8 +22,7 @@ * Embed a dashboard. | ||
function embedDashboard(options) { | ||
var dashboard = new _EmbeddableDashboard2.default(options); | ||
var container = dashboard.getContainer(); | ||
setTimeout(attachToDom.bind(null, dashboard.iframe, container), 0); | ||
return dashboard; | ||
var dashboard = new _EmbeddableDashboard.default(options); | ||
var container = dashboard.getContainer(); | ||
setTimeout(attachToDom.bind(null, dashboard.iframe, container), 0); | ||
return dashboard; | ||
} | ||
/** | ||
@@ -36,17 +37,16 @@ * Create a iframe and attach it to parent element. | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
function attachToDom(iframe, container) { | ||
if (!iframe) { | ||
throw new Error('iFrame is required'); | ||
} | ||
if (!iframe) { | ||
throw new Error('iFrame is required'); | ||
} | ||
if (!container) { | ||
throw new Error('container of iFrame is required'); | ||
} | ||
if (!container) { | ||
throw new Error('container of iFrame is required'); | ||
} | ||
container.appendChild(iframe); | ||
container.appendChild(iframe); | ||
} | ||
exports.default = embedDashboard; | ||
var _default = embedDashboard; | ||
exports.default = _default; |
@@ -1,16 +0,15 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.embedDashboard = undefined; | ||
Object.defineProperty(exports, "embedDashboard", { | ||
enumerable: true, | ||
get: function get() { | ||
return _embedDashboard.default; | ||
} | ||
}); | ||
var _embedDashboard = require('./embedDashboard'); | ||
var _embedDashboard = _interopRequireDefault(require("./embedDashboard")); | ||
var _embedDashboard2 = _interopRequireDefault(_embedDashboard); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.embedDashboard = _embedDashboard2.default; | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -1,32 +0,32 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.DASHBOARD_SIZE_OPTIONS = exports.CLIENT_FACING_EVENT_NAMES = exports.IN_COMING_POST_MESSAGE_EVENT_NAMES = exports.OUT_GOING_POST_MESSAGE_EVENT_NAMES = void 0; | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
var OUT_GOING_POST_MESSAGE_EVENT_NAMES = exports.OUT_GOING_POST_MESSAGE_EVENT_NAMES = { | ||
ESTABLISH_MESSAGE_CHANNEL: 'establishMessageChannel', | ||
UPDATE_PARAMETER_VALUES: 'updateParameterValues' | ||
var OUT_GOING_POST_MESSAGE_EVENT_NAMES = { | ||
ESTABLISH_MESSAGE_CHANNEL: 'establishMessageChannel', | ||
UPDATE_PARAMETER_VALUES: 'updateParameterValues' | ||
}; | ||
exports.OUT_GOING_POST_MESSAGE_EVENT_NAMES = OUT_GOING_POST_MESSAGE_EVENT_NAMES; | ||
var IN_COMING_POST_MESSAGE_EVENT_NAMES = { | ||
LOAD: 'load', | ||
ERROR: 'error', | ||
RESIZE_EVENT: 'RESIZE_EVENT', | ||
SHOW_MODAL_EVENT: 'SHOW_MODAL_EVENT' | ||
}; // this is a mapping of event names we use internally to the event names we expose to clients | ||
var IN_COMING_POST_MESSAGE_EVENT_NAMES = exports.IN_COMING_POST_MESSAGE_EVENT_NAMES = { | ||
LOAD: 'load', | ||
ERROR: 'error', | ||
RESIZE_EVENT: 'RESIZE_EVENT', | ||
SHOW_MODAL_EVENT: 'SHOW_MODAL_EVENT' | ||
exports.IN_COMING_POST_MESSAGE_EVENT_NAMES = IN_COMING_POST_MESSAGE_EVENT_NAMES; | ||
var CLIENT_FACING_EVENT_NAMES = { | ||
load: 'load', | ||
error: 'error', | ||
RESIZE_EVENT: 'resize', | ||
SHOW_MODAL_EVENT: 'SHOW_MODAL_EVENT' | ||
}; | ||
// this is a mapping of event names we use internally to the event names we expose to clients | ||
var CLIENT_FACING_EVENT_NAMES = exports.CLIENT_FACING_EVENT_NAMES = { | ||
load: 'load', | ||
error: 'error', | ||
RESIZE_EVENT: 'resize', | ||
SHOW_MODAL_EVENT: 'SHOW_MODAL_EVENT' | ||
exports.CLIENT_FACING_EVENT_NAMES = CLIENT_FACING_EVENT_NAMES; | ||
var DASHBOARD_SIZE_OPTIONS = { | ||
AUTO_FIT: 'AutoFit' | ||
}; | ||
var DASHBOARD_SIZE_OPTIONS = exports.DASHBOARD_SIZE_OPTIONS = { | ||
AUTO_FIT: 'AutoFit' | ||
}; | ||
exports.DASHBOARD_SIZE_OPTIONS = DASHBOARD_SIZE_OPTIONS; |
@@ -1,26 +0,24 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = constructEvent; | ||
var _constants = require('./constants'); | ||
var _constants = require("./constants"); | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
function constructEvent(eventName, payload) { | ||
var isValidEventName = Object.keys(_constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES).some(function (k) { | ||
return _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES[k] === eventName; | ||
}); | ||
var isValidEventName = Object.keys(_constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES).some(k => _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES[k] === eventName); | ||
if (!isValidEventName) { | ||
throw new Error('Unexpected eventName'); | ||
} | ||
if (!isValidEventName) { | ||
throw new Error('Unexpected eventName'); | ||
} | ||
return { | ||
eventName: eventName, | ||
clientType: 'EMBEDDING', | ||
payload: payload | ||
}; | ||
} | ||
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
return { | ||
eventName, | ||
clientType: 'EMBEDDING', | ||
payload | ||
}; | ||
} |
@@ -1,5 +0,5 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -17,64 +17,63 @@ exports.default = eventify; | ||
function eventify(object) { | ||
if (!object) { | ||
object = {}; | ||
} | ||
if (!object) { | ||
object = {}; | ||
} | ||
assertObjectHasNoReservedKeywords(object); | ||
assertObjectHasNoReservedKeywords(object); | ||
var listeners = new Map(); // eventName -> Set() of listeners | ||
var listeners = new Map(); // eventName -> Set() of listeners | ||
object.on = on; | ||
object.off = off; | ||
object.trigger = trigger; | ||
return object; | ||
object.on = on; | ||
object.off = off; | ||
object.trigger = trigger; | ||
function on(eventName, callback) { | ||
var eventListeners = listeners.get(eventName); | ||
return object; | ||
if (!eventListeners) { | ||
eventListeners = new Set(); | ||
listeners.set(eventName, eventListeners); | ||
} | ||
function on(eventName, callback) { | ||
var eventListeners = listeners.get(eventName); | ||
if (!eventListeners) { | ||
eventListeners = new Set(); | ||
listeners.set(eventName, eventListeners); | ||
} | ||
eventListeners.add(callback); | ||
} | ||
eventListeners.add(callback); | ||
function trigger(eventName) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
function trigger(eventName) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
var eventListeners = listeners.get(eventName); | ||
var eventListeners = listeners.get(eventName); | ||
if (eventListeners) { | ||
eventListeners.forEach(function (listener) { | ||
return listener.apply(null, args); | ||
}); | ||
} | ||
if (eventListeners) { | ||
eventListeners.forEach(listener => listener.apply(null, args)); | ||
} | ||
} | ||
function off(eventName, callback) { | ||
if (!callback) { | ||
// we want to unsubscribe from all events | ||
listeners.delete(eventName); | ||
return object; | ||
} | ||
function off(eventName, callback) { | ||
if (!callback) { | ||
// we want to unsubscribe from all events | ||
listeners.delete(eventName); | ||
return object; | ||
} | ||
var eventListeners = listeners.get(eventName); | ||
if (!eventListeners) { | ||
// no listeners, nothing to unsubscribe from | ||
return object; | ||
} | ||
// remove this specific callback from this event | ||
eventListeners.delete(callback); | ||
var eventListeners = listeners.get(eventName); | ||
return object; | ||
} | ||
if (!eventListeners) { | ||
// no listeners, nothing to unsubscribe from | ||
return object; | ||
} // remove this specific callback from this event | ||
eventListeners.delete(callback); | ||
return object; | ||
} | ||
} | ||
function assertObjectHasNoReservedKeywords(object) { | ||
['on', 'trigger', 'off'].forEach(function (keyword) { | ||
if (keyword in object) { | ||
throw new Error('Cannot eventify object that has `' + keyword + '()` method on it'); | ||
} | ||
}); | ||
['on', 'trigger', 'off'].forEach(keyword => { | ||
if (keyword in object) { | ||
throw new Error('Cannot eventify object that has `' + keyword + '()` method on it'); | ||
} | ||
}); | ||
} |
@@ -97,3 +97,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nvar _eventify = __webpack_require__(/*! ./lib/eventify */ \"./dist/lib/eventify.js\");\n\nvar _eventify2 = _interopRequireDefault(_eventify);\n\nvar _constructEvent = __webpack_require__(/*! ./lib/constructEvent */ \"./dist/lib/constructEvent.js\");\n\nvar _constructEvent2 = _interopRequireDefault(_constructEvent);\n\nvar _constants = __webpack_require__(/*! ./lib/constants */ \"./dist/lib/constants.js\");\n\nvar _punycode = __webpack_require__(/*! punycode */ \"./node_modules/node-libs-browser/node_modules/punycode/punycode.js\");\n\nvar _punycode2 = _interopRequireDefault(_punycode);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * Embedding options.\n * @typedef {Object} EmbeddingOptions\n * @property {string} url - url of the dashboard to embed\n * @property {HTMLElement | string} container - parent html element or query selector string\n * @property {Function} errorCallback - callback when error occurs\n * @property {Function} loadCallback - callback when visualization data load complete\n * @property {Object} parameters\n * @property {string} width - width of the iframe\n * @property {string} height - height of the iframe\n * @property {string} loadingHeight - when height is set to be \"AutoFit\",\n * loadingHeight is used before actual height is received\n * @property {string} scrolling\n * @property {string} locale\n */\n\n/**\n * Embeddable dashboard class.\n * @class\n * @name EmbeddableDashboard\n * @param {EmbeddingOptions} options - options set by customers to embed the dashboard.\n */\nvar EmbeddableDashboard = function () {\n\n /* eslint-disable complexity */\n function EmbeddableDashboard(options) {\n _classCallCheck(this, EmbeddableDashboard);\n\n if (!options) {\n throw new Error('options is required');\n }\n\n if (!options.url) {\n throw new Error('url is required');\n }\n\n var url = options.url,\n container = options.container,\n parameters = options.parameters,\n errorCallback = options.errorCallback,\n loadCallback = options.loadCallback;\n\n\n this.url = url;\n\n if (container instanceof HTMLElement) {\n this.container = container;\n } else if (typeof container === 'string') {\n this.container = document.querySelector(container);\n }\n\n if (!this.container) {\n throw new Error('can\\'t find valid container');\n }\n\n this.parameters = parameters;\n\n this.iframe = createIframe(options);\n\n (0, _eventify2.default)(this);\n\n if (typeof errorCallback === 'function') {\n this.on(_constants.CLIENT_FACING_EVENT_NAMES.error, errorCallback);\n }\n\n if (typeof loadCallback === 'function') {\n this.on(_constants.CLIENT_FACING_EVENT_NAMES.load, loadCallback);\n }\n\n window.addEventListener('message', function (event) {\n if (!event) {\n return;\n }\n if (event.source === (this.iframe && this.iframe.contentWindow)) {\n var _event$data = event.data,\n eventName = _event$data.eventName,\n payload = _event$data.payload;\n\n this.trigger(_constants.CLIENT_FACING_EVENT_NAMES[eventName], payload);\n if (eventName === _constants.IN_COMING_POST_MESSAGE_EVENT_NAMES.RESIZE_EVENT) {\n var height = options.height;\n\n if (height === _constants.DASHBOARD_SIZE_OPTIONS.AUTO_FIT) {\n this.iframe.height = payload.height;\n }\n }\n }\n }.bind(this), false);\n\n this.getContainer = this.getContainer.bind(this);\n this.getParameters = this.getParameters.bind(this);\n this.getUrl = this.getUrl.bind(this);\n this.setParameters = this.setParameters.bind(this);\n }\n\n _createClass(EmbeddableDashboard, [{\n key: 'getUrl',\n value: function getUrl() {\n return this.url;\n }\n }, {\n key: 'getContainer',\n value: function getContainer() {\n return this.container;\n }\n }, {\n key: 'getParameters',\n value: function getParameters() {\n return this.parameters;\n }\n }, {\n key: 'setParameters',\n value: function setParameters(parameters) {\n var eventName = _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES.UPDATE_PARAMETER_VALUES;\n var payload = { parameters: parameters };\n var event = (0, _constructEvent2.default)(eventName, payload);\n this.iframe.contentWindow.postMessage(event, this.url);\n }\n }]);\n\n return EmbeddableDashboard;\n}();\n\nfunction createIframe(options) {\n var width = options.width,\n height = options.height;\n var loadingHeight = options.loadingHeight,\n url = options.url,\n scrolling = options.scrolling,\n className = options.className;\n\n if (height === _constants.DASHBOARD_SIZE_OPTIONS.AUTO_FIT) {\n height = loadingHeight;\n }\n var iframe = document.createElement('iframe');\n iframe.className = ['quicksight-embedding-iframe', className].join(' ').trim();\n iframe.width = width || '100%';\n iframe.height = height || '100%';\n iframe.scrolling = scrolling || 'no';\n iframe.onload = sendInitialPostMessage.bind(null, iframe, url);\n iframe.src = getIframeSrc(options);\n iframe.style.border = '0px';\n iframe.style.padding = '0px';\n return iframe;\n}\n\nfunction getIframeSrc(options) {\n var url = options.url,\n parameters = options.parameters,\n locale = options.locale,\n footerPaddingEnabled = options.footerPaddingEnabled;\n\n var src = url + '&punyCodeEmbedOrigin=' + _punycode2.default.encode(window.location.origin + '/');\n\n if (locale) {\n src = src + '&locale=' + locale;\n }\n\n if (footerPaddingEnabled) {\n src = src + '&footerPaddingEnabled=' + String(footerPaddingEnabled);\n }\n\n if (parameters) {\n return useParameterValuesInUrl(src, parameters);\n }\n\n return src;\n}\n\n/**\n * Use parameter values in url.\n * @function\n * @name useParameterValuesInUrl\n * @param {string} url - url of the dashboard to embed.\n * @param {Object} parameters\n */\nfunction useParameterValuesInUrl(url, parameters) {\n var parameterNames = Object.keys(parameters);\n var parameterStrings = parameterNames.map(function (name) {\n var value = parameters[name];\n var values = [].concat(value);\n var encodedName = encodeURIComponent(name);\n return values.map(function (paramValue) {\n return encodeURIComponent(paramValue);\n }).map(function (encodedValue) {\n return 'p.' + encodedName + '=' + encodedValue;\n }).join('&');\n });\n\n return url + '#' + parameterStrings.join('&');\n}\n\nfunction sendInitialPostMessage(iframe, domain) {\n if (iframe.contentWindow === null) {\n setTimeout(sendInitialPostMessage.bind(null, iframe, domain), 100);\n }\n\n var eventName = _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES.ESTABLISH_MESSAGE_CHANNEL;\n var event = (0, _constructEvent2.default)(eventName);\n // wait until iframe.contentWindow exists and send message to iframe window\n iframe.contentWindow.postMessage(event, domain);\n}\n\nexports.default = EmbeddableDashboard;\n\n//# sourceURL=webpack:///./dist/EmbeddableDashboard.js?"); | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _eventify = _interopRequireDefault(__webpack_require__(/*! ./lib/eventify */ \"./dist/lib/eventify.js\"));\n\nvar _constructEvent = _interopRequireDefault(__webpack_require__(/*! ./lib/constructEvent */ \"./dist/lib/constructEvent.js\"));\n\nvar _constants = __webpack_require__(/*! ./lib/constants */ \"./dist/lib/constants.js\");\n\nvar _punycode = _interopRequireDefault(__webpack_require__(/*! punycode */ \"./node_modules/node-libs-browser/node_modules/punycode/punycode.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Embedding options.\n * @typedef {Object} EmbeddingOptions\n * @property {string} url - url of the dashboard to embed\n * @property {HTMLElement | string} container - parent html element or query selector string\n * @property {Function} errorCallback - callback when error occurs\n * @property {Function} loadCallback - callback when visualization data load complete\n * @property {Object} parameters\n * @property {string} width - width of the iframe\n * @property {string} height - height of the iframe\n * @property {string} loadingHeight - when height is set to be \"AutoFit\",\n * loadingHeight is used before actual height is received\n * @property {string} scrolling\n * @property {string} locale\n */\n\n/**\n * Embeddable dashboard class.\n * @class\n * @name EmbeddableDashboard\n * @param {EmbeddingOptions} options - options set by customers to embed the dashboard.\n */\nclass EmbeddableDashboard {\n /* eslint-disable complexity */\n constructor(options) {\n if (!options) {\n throw new Error('options is required');\n }\n\n if (!options.url) {\n throw new Error('url is required');\n }\n\n var {\n url,\n container,\n parameters,\n errorCallback,\n loadCallback\n } = options;\n this.url = url;\n\n if (container instanceof HTMLElement) {\n this.container = container;\n } else if (typeof container === 'string') {\n this.container = document.querySelector(container);\n }\n\n if (!this.container) {\n throw new Error('can\\'t find valid container');\n }\n\n this.parameters = parameters;\n this.iframe = createIframe(options);\n (0, _eventify.default)(this);\n\n if (typeof errorCallback === 'function') {\n this.on(_constants.CLIENT_FACING_EVENT_NAMES.error, errorCallback);\n }\n\n if (typeof loadCallback === 'function') {\n this.on(_constants.CLIENT_FACING_EVENT_NAMES.load, loadCallback);\n }\n\n window.addEventListener('message', function (event) {\n if (!event) {\n return;\n }\n\n if (event.source === (this.iframe && this.iframe.contentWindow)) {\n var {\n eventName,\n payload\n } = event.data;\n this.trigger(_constants.CLIENT_FACING_EVENT_NAMES[eventName], payload);\n\n if (eventName === _constants.IN_COMING_POST_MESSAGE_EVENT_NAMES.RESIZE_EVENT) {\n var {\n height\n } = options;\n\n if (height === _constants.DASHBOARD_SIZE_OPTIONS.AUTO_FIT) {\n this.iframe.height = payload.height;\n }\n }\n }\n }.bind(this), false);\n this.getContainer = this.getContainer.bind(this);\n this.getParameters = this.getParameters.bind(this);\n this.getUrl = this.getUrl.bind(this);\n this.setParameters = this.setParameters.bind(this);\n }\n\n getUrl() {\n return this.url;\n }\n\n getContainer() {\n return this.container;\n }\n\n getParameters() {\n return this.parameters;\n }\n\n setParameters(parameters) {\n var eventName = _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES.UPDATE_PARAMETER_VALUES;\n var payload = {\n parameters\n };\n var event = (0, _constructEvent.default)(eventName, payload);\n this.iframe.contentWindow.postMessage(event, this.url);\n }\n\n}\n\nfunction createIframe(options) {\n var {\n width,\n height\n } = options;\n var {\n loadingHeight,\n url,\n scrolling,\n className\n } = options;\n\n if (height === _constants.DASHBOARD_SIZE_OPTIONS.AUTO_FIT) {\n height = loadingHeight;\n }\n\n var iframe = document.createElement('iframe');\n iframe.className = ['quicksight-embedding-iframe', className].join(' ').trim();\n iframe.width = width || '100%';\n iframe.height = height || '100%';\n iframe.scrolling = scrolling || 'no';\n iframe.onload = sendInitialPostMessage.bind(null, iframe, url);\n iframe.src = getIframeSrc(options);\n iframe.style.border = '0px';\n iframe.style.padding = '0px';\n return iframe;\n}\n\nfunction getIframeSrc(options) {\n var {\n url,\n parameters,\n locale,\n footerPaddingEnabled\n } = options;\n\n var src = url + '&punyCodeEmbedOrigin=' + _punycode.default.encode(window.location.origin + '/');\n\n if (locale) {\n src = src + '&locale=' + locale;\n }\n\n if (footerPaddingEnabled) {\n src = src + '&footerPaddingEnabled=' + String(footerPaddingEnabled);\n }\n\n if (parameters) {\n return useParameterValuesInUrl(src, parameters);\n }\n\n return src;\n}\n/**\n * Use parameter values in url.\n * @function\n * @name useParameterValuesInUrl\n * @param {string} url - url of the dashboard to embed.\n * @param {Object} parameters\n */\n\n\nfunction useParameterValuesInUrl(url, parameters) {\n var parameterNames = Object.keys(parameters);\n var parameterStrings = parameterNames.map(name => {\n var value = parameters[name];\n var values = [].concat(value);\n var encodedName = encodeURIComponent(name);\n return values.map(paramValue => encodeURIComponent(paramValue)).map(encodedValue => \"p.\".concat(encodedName, \"=\").concat(encodedValue)).join('&');\n });\n return \"\".concat(url, \"#\").concat(parameterStrings.join('&'));\n}\n\nfunction sendInitialPostMessage(iframe, domain) {\n if (iframe.contentWindow === null) {\n setTimeout(sendInitialPostMessage.bind(null, iframe, domain), 100);\n }\n\n var eventName = _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES.ESTABLISH_MESSAGE_CHANNEL;\n var event = (0, _constructEvent.default)(eventName); // wait until iframe.contentWindow exists and send message to iframe window\n\n iframe.contentWindow.postMessage(event, domain);\n}\n\nvar _default = EmbeddableDashboard;\nexports.default = _default;\n\n//# sourceURL=webpack:///./dist/EmbeddableDashboard.js?"); | ||
@@ -110,3 +110,3 @@ /***/ }), | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _EmbeddableDashboard = __webpack_require__(/*! ./EmbeddableDashboard */ \"./dist/EmbeddableDashboard.js\");\n\nvar _EmbeddableDashboard2 = _interopRequireDefault(_EmbeddableDashboard);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Embed a dashboard.\n * @function\n * @name embedDashboard\n * @param {EmbeddingOptions} options - options set by customers to embed the dashboard.\n */\nfunction embedDashboard(options) {\n var dashboard = new _EmbeddableDashboard2.default(options);\n var container = dashboard.getContainer();\n setTimeout(attachToDom.bind(null, dashboard.iframe, container), 0);\n return dashboard;\n}\n\n/**\n * Create a iframe and attach it to parent element.\n * @function\n * @name attachToDom\n * @param {HTMLIFrameElement} iframe\n * @param {string} url - url of the dashboard to embed with parameter values appended.\n * @param {HTMLElement} container - parent html element.\n */\n\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nfunction attachToDom(iframe, container) {\n if (!iframe) {\n throw new Error('iFrame is required');\n }\n\n if (!container) {\n throw new Error('container of iFrame is required');\n }\n\n container.appendChild(iframe);\n}\n\nexports.default = embedDashboard;\n\n//# sourceURL=webpack:///./dist/embedDashboard.js?"); | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\n\nvar _EmbeddableDashboard = _interopRequireDefault(__webpack_require__(/*! ./EmbeddableDashboard */ \"./dist/EmbeddableDashboard.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Embed a dashboard.\n * @function\n * @name embedDashboard\n * @param {EmbeddingOptions} options - options set by customers to embed the dashboard.\n */\nfunction embedDashboard(options) {\n var dashboard = new _EmbeddableDashboard.default(options);\n var container = dashboard.getContainer();\n setTimeout(attachToDom.bind(null, dashboard.iframe, container), 0);\n return dashboard;\n}\n/**\n * Create a iframe and attach it to parent element.\n * @function\n * @name attachToDom\n * @param {HTMLIFrameElement} iframe\n * @param {string} url - url of the dashboard to embed with parameter values appended.\n * @param {HTMLElement} container - parent html element.\n */\n\n\nfunction attachToDom(iframe, container) {\n if (!iframe) {\n throw new Error('iFrame is required');\n }\n\n if (!container) {\n throw new Error('container of iFrame is required');\n }\n\n container.appendChild(iframe);\n}\n\nvar _default = embedDashboard;\nexports.default = _default;\n\n//# sourceURL=webpack:///./dist/embedDashboard.js?"); | ||
@@ -123,3 +123,3 @@ /***/ }), | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.embedDashboard = undefined;\n\nvar _embedDashboard = __webpack_require__(/*! ./embedDashboard */ \"./dist/embedDashboard.js\");\n\nvar _embedDashboard2 = _interopRequireDefault(_embedDashboard);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nexports.embedDashboard = _embedDashboard2.default;\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n//# sourceURL=webpack:///./dist/index.js?"); | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nObject.defineProperty(exports, \"embedDashboard\", {\n enumerable: true,\n get: function get() {\n return _embedDashboard.default;\n }\n});\n\nvar _embedDashboard = _interopRequireDefault(__webpack_require__(/*! ./embedDashboard */ \"./dist/embedDashboard.js\"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n//# sourceURL=webpack:///./dist/index.js?"); | ||
@@ -147,3 +147,3 @@ /***/ }), | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nvar OUT_GOING_POST_MESSAGE_EVENT_NAMES = exports.OUT_GOING_POST_MESSAGE_EVENT_NAMES = {\n ESTABLISH_MESSAGE_CHANNEL: 'establishMessageChannel',\n UPDATE_PARAMETER_VALUES: 'updateParameterValues'\n};\n\nvar IN_COMING_POST_MESSAGE_EVENT_NAMES = exports.IN_COMING_POST_MESSAGE_EVENT_NAMES = {\n LOAD: 'load',\n ERROR: 'error',\n RESIZE_EVENT: 'RESIZE_EVENT',\n SHOW_MODAL_EVENT: 'SHOW_MODAL_EVENT'\n};\n\n// this is a mapping of event names we use internally to the event names we expose to clients\nvar CLIENT_FACING_EVENT_NAMES = exports.CLIENT_FACING_EVENT_NAMES = {\n load: 'load',\n error: 'error',\n RESIZE_EVENT: 'resize',\n SHOW_MODAL_EVENT: 'SHOW_MODAL_EVENT'\n};\n\nvar DASHBOARD_SIZE_OPTIONS = exports.DASHBOARD_SIZE_OPTIONS = {\n AUTO_FIT: 'AutoFit'\n};\n\n//# sourceURL=webpack:///./dist/lib/constants.js?"); | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.DASHBOARD_SIZE_OPTIONS = exports.CLIENT_FACING_EVENT_NAMES = exports.IN_COMING_POST_MESSAGE_EVENT_NAMES = exports.OUT_GOING_POST_MESSAGE_EVENT_NAMES = void 0;\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nvar OUT_GOING_POST_MESSAGE_EVENT_NAMES = {\n ESTABLISH_MESSAGE_CHANNEL: 'establishMessageChannel',\n UPDATE_PARAMETER_VALUES: 'updateParameterValues'\n};\nexports.OUT_GOING_POST_MESSAGE_EVENT_NAMES = OUT_GOING_POST_MESSAGE_EVENT_NAMES;\nvar IN_COMING_POST_MESSAGE_EVENT_NAMES = {\n LOAD: 'load',\n ERROR: 'error',\n RESIZE_EVENT: 'RESIZE_EVENT',\n SHOW_MODAL_EVENT: 'SHOW_MODAL_EVENT'\n}; // this is a mapping of event names we use internally to the event names we expose to clients\n\nexports.IN_COMING_POST_MESSAGE_EVENT_NAMES = IN_COMING_POST_MESSAGE_EVENT_NAMES;\nvar CLIENT_FACING_EVENT_NAMES = {\n load: 'load',\n error: 'error',\n RESIZE_EVENT: 'resize',\n SHOW_MODAL_EVENT: 'SHOW_MODAL_EVENT'\n};\nexports.CLIENT_FACING_EVENT_NAMES = CLIENT_FACING_EVENT_NAMES;\nvar DASHBOARD_SIZE_OPTIONS = {\n AUTO_FIT: 'AutoFit'\n};\nexports.DASHBOARD_SIZE_OPTIONS = DASHBOARD_SIZE_OPTIONS;\n\n//# sourceURL=webpack:///./dist/lib/constants.js?"); | ||
@@ -160,3 +160,3 @@ /***/ }), | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = constructEvent;\n\nvar _constants = __webpack_require__(/*! ./constants */ \"./dist/lib/constants.js\");\n\nfunction constructEvent(eventName, payload) {\n var isValidEventName = Object.keys(_constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES).some(function (k) {\n return _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES[k] === eventName;\n });\n\n if (!isValidEventName) {\n throw new Error('Unexpected eventName');\n }\n\n return {\n eventName: eventName,\n clientType: 'EMBEDDING',\n payload: payload\n };\n}\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n//# sourceURL=webpack:///./dist/lib/constructEvent.js?"); | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = constructEvent;\n\nvar _constants = __webpack_require__(/*! ./constants */ \"./dist/lib/constants.js\");\n\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nfunction constructEvent(eventName, payload) {\n var isValidEventName = Object.keys(_constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES).some(k => _constants.OUT_GOING_POST_MESSAGE_EVENT_NAMES[k] === eventName);\n\n if (!isValidEventName) {\n throw new Error('Unexpected eventName');\n }\n\n return {\n eventName,\n clientType: 'EMBEDDING',\n payload\n };\n}\n\n//# sourceURL=webpack:///./dist/lib/constructEvent.js?"); | ||
@@ -173,3 +173,3 @@ /***/ }), | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = eventify;\n\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Adds `on()`, `off()`, and `trigger()` methods to an object.\n * Consumers can use `on()` function to subscribe to events, use `off()` to unsubscribe\n * and use `trigger()` to trigger event.\n */\nfunction eventify(object) {\n if (!object) {\n object = {};\n }\n\n assertObjectHasNoReservedKeywords(object);\n\n var listeners = new Map(); // eventName -> Set() of listeners\n\n object.on = on;\n object.off = off;\n object.trigger = trigger;\n\n return object;\n\n function on(eventName, callback) {\n var eventListeners = listeners.get(eventName);\n if (!eventListeners) {\n eventListeners = new Set();\n listeners.set(eventName, eventListeners);\n }\n\n eventListeners.add(callback);\n }\n\n function trigger(eventName) {\n for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n var eventListeners = listeners.get(eventName);\n if (eventListeners) {\n eventListeners.forEach(function (listener) {\n return listener.apply(null, args);\n });\n }\n }\n\n function off(eventName, callback) {\n if (!callback) {\n // we want to unsubscribe from all events\n listeners.delete(eventName);\n return object;\n }\n\n var eventListeners = listeners.get(eventName);\n if (!eventListeners) {\n // no listeners, nothing to unsubscribe from\n return object;\n }\n // remove this specific callback from this event\n eventListeners.delete(callback);\n\n return object;\n }\n}\n\nfunction assertObjectHasNoReservedKeywords(object) {\n ['on', 'trigger', 'off'].forEach(function (keyword) {\n if (keyword in object) {\n throw new Error('Cannot eventify object that has `' + keyword + '()` method on it');\n }\n });\n}\n\n//# sourceURL=webpack:///./dist/lib/eventify.js?"); | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = eventify;\n\n// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Adds `on()`, `off()`, and `trigger()` methods to an object.\n * Consumers can use `on()` function to subscribe to events, use `off()` to unsubscribe\n * and use `trigger()` to trigger event.\n */\nfunction eventify(object) {\n if (!object) {\n object = {};\n }\n\n assertObjectHasNoReservedKeywords(object);\n var listeners = new Map(); // eventName -> Set() of listeners\n\n object.on = on;\n object.off = off;\n object.trigger = trigger;\n return object;\n\n function on(eventName, callback) {\n var eventListeners = listeners.get(eventName);\n\n if (!eventListeners) {\n eventListeners = new Set();\n listeners.set(eventName, eventListeners);\n }\n\n eventListeners.add(callback);\n }\n\n function trigger(eventName) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n var eventListeners = listeners.get(eventName);\n\n if (eventListeners) {\n eventListeners.forEach(listener => listener.apply(null, args));\n }\n }\n\n function off(eventName, callback) {\n if (!callback) {\n // we want to unsubscribe from all events\n listeners.delete(eventName);\n return object;\n }\n\n var eventListeners = listeners.get(eventName);\n\n if (!eventListeners) {\n // no listeners, nothing to unsubscribe from\n return object;\n } // remove this specific callback from this event\n\n\n eventListeners.delete(callback);\n return object;\n }\n}\n\nfunction assertObjectHasNoReservedKeywords(object) {\n ['on', 'trigger', 'off'].forEach(keyword => {\n if (keyword in object) {\n throw new Error('Cannot eventify object that has `' + keyword + '()` method on it');\n }\n });\n}\n\n//# sourceURL=webpack:///./dist/lib/eventify.js?"); | ||
@@ -176,0 +176,0 @@ /***/ }), |
@@ -1,1 +0,1 @@ | ||
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.OUT_GOING_POST_MESSAGE_EVENT_NAMES={ESTABLISH_MESSAGE_CHANNEL:"establishMessageChannel",UPDATE_PARAMETER_VALUES:"updateParameterValues"},t.IN_COMING_POST_MESSAGE_EVENT_NAMES={LOAD:"load",ERROR:"error",RESIZE_EVENT:"RESIZE_EVENT",SHOW_MODAL_EVENT:"SHOW_MODAL_EVENT"},t.CLIENT_FACING_EVENT_NAMES={load:"load",error:"error",RESIZE_EVENT:"resize",SHOW_MODAL_EVENT:"SHOW_MODAL_EVENT"},t.DASHBOARD_SIZE_OPTIONS={AUTO_FIT:"AutoFit"}},function(e,t,n){(function(t){e.exports=t.QuickSightEmbedding=n(3)}).call(this,n(0))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.embedDashboard=void 0;var r,o=n(4),i=(r=o)&&r.__esModule?r:{default:r};t.embedDashboard=i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=n(5),i=(r=o)&&r.__esModule?r:{default:r};function u(e,t){if(!e)throw new Error("iFrame is required");if(!t)throw new Error("container of iFrame is required");t.appendChild(e)}t.default=function(e){var t=new i.default(e),n=t.getContainer();return setTimeout(u.bind(null,t.iframe,n),0),t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=c(n(6)),i=c(n(7)),u=n(1),a=c(n(8));function c(e){return e&&e.__esModule?e:{default:e}}var f=function(){function e(t){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw new Error("options is required");if(!t.url)throw new Error("url is required");var n=t.url,r=t.container,i=t.parameters,c=t.errorCallback,f=t.loadCallback;if(this.url=n,r instanceof HTMLElement?this.container=r:"string"==typeof r&&(this.container=document.querySelector(r)),!this.container)throw new Error("can't find valid container");this.parameters=i,this.iframe=function(e){var t=e.width,n=e.height,r=e.loadingHeight,o=e.url,i=e.scrolling,c=e.className;n===u.DASHBOARD_SIZE_OPTIONS.AUTO_FIT&&(n=r);var f=document.createElement("iframe");return f.className=["quicksight-embedding-iframe",c].join(" ").trim(),f.width=t||"100%",f.height=n||"100%",f.scrolling=i||"no",f.onload=l.bind(null,f,o),f.src=function(e){var t=e.url,n=e.parameters,r=e.locale,o=e.footerPaddingEnabled,i=t+"&punyCodeEmbedOrigin="+a.default.encode(window.location.origin+"/");r&&(i=i+"&locale="+r);o&&(i=i+"&footerPaddingEnabled="+String(o));if(n)return function(e,t){var n=Object.keys(t).map((function(e){var n=t[e],r=[].concat(n),o=encodeURIComponent(e);return r.map((function(e){return encodeURIComponent(e)})).map((function(e){return"p."+o+"="+e})).join("&")}));return e+"#"+n.join("&")}(i,n);return i}(e),f.style.border="0px",f.style.padding="0px",f}(t),(0,o.default)(this),"function"==typeof c&&this.on(u.CLIENT_FACING_EVENT_NAMES.error,c),"function"==typeof f&&this.on(u.CLIENT_FACING_EVENT_NAMES.load,f),window.addEventListener("message",function(e){if(e&&e.source===(this.iframe&&this.iframe.contentWindow)){var n=e.data,r=n.eventName,o=n.payload;if(this.trigger(u.CLIENT_FACING_EVENT_NAMES[r],o),r===u.IN_COMING_POST_MESSAGE_EVENT_NAMES.RESIZE_EVENT)t.height===u.DASHBOARD_SIZE_OPTIONS.AUTO_FIT&&(this.iframe.height=o.height)}}.bind(this),!1),this.getContainer=this.getContainer.bind(this),this.getParameters=this.getParameters.bind(this),this.getUrl=this.getUrl.bind(this),this.setParameters=this.setParameters.bind(this)}return r(e,[{key:"getUrl",value:function(){return this.url}},{key:"getContainer",value:function(){return this.container}},{key:"getParameters",value:function(){return this.parameters}},{key:"setParameters",value:function(e){var t=u.OUT_GOING_POST_MESSAGE_EVENT_NAMES.UPDATE_PARAMETER_VALUES,n={parameters:e},r=(0,i.default)(t,n);this.iframe.contentWindow.postMessage(r,this.url)}}]),e}();function l(e,t){null===e.contentWindow&&setTimeout(l.bind(null,e,t),100);var n=u.OUT_GOING_POST_MESSAGE_EVENT_NAMES.ESTABLISH_MESSAGE_CHANNEL,r=(0,i.default)(n);e.contentWindow.postMessage(r,t)}t.default=f},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){e||(e={});!function(e){["on","trigger","off"].forEach((function(t){if(t in e)throw new Error("Cannot eventify object that has `"+t+"()` method on it")}))}(e);var t=new Map;return e.on=function(e,n){var r=t.get(e);r||(r=new Set,t.set(e,r));r.add(n)},e.off=function(n,r){if(!r)return t.delete(n),e;var o=t.get(n);if(!o)return e;return o.delete(r),e},e.trigger=function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];var i=t.get(e);i&&i.forEach((function(e){return e.apply(null,r)}))},e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if(!Object.keys(r.OUT_GOING_POST_MESSAGE_EVENT_NAMES).some((function(t){return r.OUT_GOING_POST_MESSAGE_EVENT_NAMES[t]===e})))throw new Error("Unexpected eventName");return{eventName:e,clientType:"EMBEDDING",payload:t}};var r=n(1)},function(e,t,n){(function(e,r){var o;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(i){t&&t.nodeType,e&&e.nodeType;var u="object"==typeof r&&r;u.global!==u&&u.window!==u&&u.self;var a,c=2147483647,f=/^xn--/,l=/[^\x20-\x7E]/,s=/[\x2E\u3002\uFF0E\uFF61]/g,d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=Math.floor,_=String.fromCharCode;function h(e){throw new RangeError(d[e])}function p(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function v(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+p((e=e.replace(s,".")).split("."),t).join(".")}function S(e){for(var t,n,r=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(n=e.charCodeAt(o++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),o--):r.push(t);return r}function g(e){return p(e,(function(e){var t="";return e>65535&&(t+=_((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=_(e)})).join("")}function O(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function b(e,t,n){var r=0;for(e=n?E(e/700):e>>1,e+=E(e/t);e>455;r+=36)e=E(e/35);return E(r+36*e/(e+38))}function N(e){var t,n,r,o,i,u,a,f,l,s,d,_=[],p=e.length,v=0,S=128,O=72;for((n=e.lastIndexOf("-"))<0&&(n=0),r=0;r<n;++r)e.charCodeAt(r)>=128&&h("not-basic"),_.push(e.charCodeAt(r));for(o=n>0?n+1:0;o<p;){for(i=v,u=1,a=36;o>=p&&h("invalid-input"),((f=(d=e.charCodeAt(o++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:36)>=36||f>E((c-v)/u))&&h("overflow"),v+=f*u,!(f<(l=a<=O?1:a>=O+26?26:a-O));a+=36)u>E(c/(s=36-l))&&h("overflow"),u*=s;O=b(v-i,t=_.length+1,0==i),E(v/t)>c-S&&h("overflow"),S+=E(v/t),v%=t,_.splice(v++,0,S)}return g(_)}function T(e){var t,n,r,o,i,u,a,f,l,s,d,p,v,g,N,T=[];for(p=(e=S(e)).length,t=128,n=0,i=72,u=0;u<p;++u)(d=e[u])<128&&T.push(_(d));for(r=o=T.length,o&&T.push("-");r<p;){for(a=c,u=0;u<p;++u)(d=e[u])>=t&&d<a&&(a=d);for(a-t>E((c-n)/(v=r+1))&&h("overflow"),n+=(a-t)*v,t=a,u=0;u<p;++u)if((d=e[u])<t&&++n>c&&h("overflow"),d==t){for(f=n,l=36;!(f<(s=l<=i?1:l>=i+26?26:l-i));l+=36)N=f-s,g=36-s,T.push(_(O(s+N%g,0))),f=E(N/g);T.push(_(O(f,0))),i=b(n,v,r==o),n=0,++r}++n,++t}return T.join("")}a={version:"1.4.1",ucs2:{decode:S,encode:g},decode:N,encode:T,toASCII:function(e){return v(e,(function(e){return l.test(e)?"xn--"+T(e):e}))},toUnicode:function(e){return v(e,(function(e){return f.test(e)?N(e.slice(4).toLowerCase()):e}))}},void 0===(o=function(){return a}.call(t,n,t,e))||(e.exports=o)}()}).call(this,n(9)(e),n(0))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}}]); | ||
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DASHBOARD_SIZE_OPTIONS=t.CLIENT_FACING_EVENT_NAMES=t.IN_COMING_POST_MESSAGE_EVENT_NAMES=t.OUT_GOING_POST_MESSAGE_EVENT_NAMES=void 0;t.OUT_GOING_POST_MESSAGE_EVENT_NAMES={ESTABLISH_MESSAGE_CHANNEL:"establishMessageChannel",UPDATE_PARAMETER_VALUES:"updateParameterValues"};t.IN_COMING_POST_MESSAGE_EVENT_NAMES={LOAD:"load",ERROR:"error",RESIZE_EVENT:"RESIZE_EVENT",SHOW_MODAL_EVENT:"SHOW_MODAL_EVENT"};t.CLIENT_FACING_EVENT_NAMES={load:"load",error:"error",RESIZE_EVENT:"resize",SHOW_MODAL_EVENT:"SHOW_MODAL_EVENT"};t.DASHBOARD_SIZE_OPTIONS={AUTO_FIT:"AutoFit"}},function(e,t,r){(function(t){e.exports=t.QuickSightEmbedding=r(3)}).call(this,r(0))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"embedDashboard",{enumerable:!0,get:function(){return o.default}});var n,o=(n=r(4))&&n.__esModule?n:{default:n}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=(n=r(5))&&n.__esModule?n:{default:n};function i(e,t){if(!e)throw new Error("iFrame is required");if(!t)throw new Error("container of iFrame is required");t.appendChild(e)}var a=function(e){var t=new o.default(e),r=t.getContainer();return setTimeout(i.bind(null,t.iframe,r),0),t};t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=u(r(6)),o=u(r(7)),i=r(1),a=u(r(8));function u(e){return e&&e.__esModule?e:{default:e}}function c(e,t){null===e.contentWindow&&setTimeout(c.bind(null,e,t),100);var r=i.OUT_GOING_POST_MESSAGE_EVENT_NAMES.ESTABLISH_MESSAGE_CHANNEL,n=(0,o.default)(r);e.contentWindow.postMessage(n,t)}var l=class{constructor(e){if(!e)throw new Error("options is required");if(!e.url)throw new Error("url is required");var{url:t,container:r,parameters:o,errorCallback:u,loadCallback:l}=e;if(this.url=t,r instanceof HTMLElement?this.container=r:"string"==typeof r&&(this.container=document.querySelector(r)),!this.container)throw new Error("can't find valid container");this.parameters=o,this.iframe=function(e){var{width:t,height:r}=e,{loadingHeight:n,url:o,scrolling:u,className:l}=e;r===i.DASHBOARD_SIZE_OPTIONS.AUTO_FIT&&(r=n);var f=document.createElement("iframe");return f.className=["quicksight-embedding-iframe",l].join(" ").trim(),f.width=t||"100%",f.height=r||"100%",f.scrolling=u||"no",f.onload=c.bind(null,f,o),f.src=function(e){var{url:t,parameters:r,locale:n,footerPaddingEnabled:o}=e,i=t+"&punyCodeEmbedOrigin="+a.default.encode(window.location.origin+"/");n&&(i=i+"&locale="+n);o&&(i=i+"&footerPaddingEnabled="+String(o));if(r)return function(e,t){var r=Object.keys(t).map(e=>{var r=t[e],n=[].concat(r),o=encodeURIComponent(e);return n.map(e=>encodeURIComponent(e)).map(e=>"p.".concat(o,"=").concat(e)).join("&")});return"".concat(e,"#").concat(r.join("&"))}(i,r);return i}(e),f.style.border="0px",f.style.padding="0px",f}(e),(0,n.default)(this),"function"==typeof u&&this.on(i.CLIENT_FACING_EVENT_NAMES.error,u),"function"==typeof l&&this.on(i.CLIENT_FACING_EVENT_NAMES.load,l),window.addEventListener("message",function(t){if(t&&t.source===(this.iframe&&this.iframe.contentWindow)){var{eventName:r,payload:n}=t.data;if(this.trigger(i.CLIENT_FACING_EVENT_NAMES[r],n),r===i.IN_COMING_POST_MESSAGE_EVENT_NAMES.RESIZE_EVENT){var{height:o}=e;o===i.DASHBOARD_SIZE_OPTIONS.AUTO_FIT&&(this.iframe.height=n.height)}}}.bind(this),!1),this.getContainer=this.getContainer.bind(this),this.getParameters=this.getParameters.bind(this),this.getUrl=this.getUrl.bind(this),this.setParameters=this.setParameters.bind(this)}getUrl(){return this.url}getContainer(){return this.container}getParameters(){return this.parameters}setParameters(e){var t=i.OUT_GOING_POST_MESSAGE_EVENT_NAMES.UPDATE_PARAMETER_VALUES,r={parameters:e},n=(0,o.default)(t,r);this.iframe.contentWindow.postMessage(n,this.url)}};t.default=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){e||(e={});!function(e){["on","trigger","off"].forEach(t=>{if(t in e)throw new Error("Cannot eventify object that has `"+t+"()` method on it")})}(e);var t=new Map;return e.on=function(e,r){var n=t.get(e);n||(n=new Set,t.set(e,n));n.add(r)},e.off=function(r,n){if(!n)return t.delete(r),e;var o=t.get(r);if(!o)return e;return o.delete(n),e},e.trigger=function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];var i=t.get(e);i&&i.forEach(e=>e.apply(null,n))},e}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){if(!Object.keys(n.OUT_GOING_POST_MESSAGE_EVENT_NAMES).some(t=>n.OUT_GOING_POST_MESSAGE_EVENT_NAMES[t]===e))throw new Error("Unexpected eventName");return{eventName:e,clientType:"EMBEDDING",payload:t}};var n=r(1)},function(e,t,r){(function(e,n){var o;/*! https://mths.be/punycode v1.4.1 by @mathias */!function(i){t&&t.nodeType,e&&e.nodeType;var a="object"==typeof n&&n;a.global!==a&&a.window!==a&&a.self;var u,c=2147483647,l=/^xn--/,f=/[^\x20-\x7E]/,s=/[\x2E\u3002\uFF0E\uFF61]/g,d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=Math.floor,_=String.fromCharCode;function h(e){throw new RangeError(d[e])}function p(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function S(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+p((e=e.replace(s,".")).split("."),t).join(".")}function N(e){for(var t,r,n=[],o=0,i=e.length;o<i;)(t=e.charCodeAt(o++))>=55296&&t<=56319&&o<i?56320==(64512&(r=e.charCodeAt(o++)))?n.push(((1023&t)<<10)+(1023&r)+65536):(n.push(t),o--):n.push(t);return n}function O(e){return p(e,(function(e){var t="";return e>65535&&(t+=_((e-=65536)>>>10&1023|55296),e=56320|1023&e),t+=_(e)})).join("")}function v(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function g(e,t,r){var n=0;for(e=r?E(e/700):e>>1,e+=E(e/t);e>455;n+=36)e=E(e/35);return E(n+36*e/(e+38))}function A(e){var t,r,n,o,i,a,u,l,f,s,d,_=[],p=e.length,S=0,N=128,v=72;for((r=e.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)e.charCodeAt(n)>=128&&h("not-basic"),_.push(e.charCodeAt(n));for(o=r>0?r+1:0;o<p;){for(i=S,a=1,u=36;o>=p&&h("invalid-input"),((l=(d=e.charCodeAt(o++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:36)>=36||l>E((c-S)/a))&&h("overflow"),S+=l*a,!(l<(f=u<=v?1:u>=v+26?26:u-v));u+=36)a>E(c/(s=36-f))&&h("overflow"),a*=s;v=g(S-i,t=_.length+1,0==i),E(S/t)>c-N&&h("overflow"),N+=E(S/t),S%=t,_.splice(S++,0,N)}return O(_)}function T(e){var t,r,n,o,i,a,u,l,f,s,d,p,S,O,A,T=[];for(p=(e=N(e)).length,t=128,r=0,i=72,a=0;a<p;++a)(d=e[a])<128&&T.push(_(d));for(n=o=T.length,o&&T.push("-");n<p;){for(u=c,a=0;a<p;++a)(d=e[a])>=t&&d<u&&(u=d);for(u-t>E((c-r)/(S=n+1))&&h("overflow"),r+=(u-t)*S,t=u,a=0;a<p;++a)if((d=e[a])<t&&++r>c&&h("overflow"),d==t){for(l=r,f=36;!(l<(s=f<=i?1:f>=i+26?26:f-i));f+=36)A=l-s,O=36-s,T.push(_(v(s+A%O,0))),l=E(A/O);T.push(_(v(l,0))),i=g(r,S,n==o),r=0,++n}++r,++t}return T.join("")}u={version:"1.4.1",ucs2:{decode:N,encode:O},decode:A,encode:T,toASCII:function(e){return S(e,(function(e){return f.test(e)?"xn--"+T(e):e}))},toUnicode:function(e){return S(e,(function(e){return l.test(e)?A(e.slice(4).toLowerCase()):e}))}},void 0===(o=function(){return u}.call(t,r,t,e))||(e.exports=o)}()}).call(this,r(9)(e),r(0))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}}]); |
{ | ||
"name": "amazon-quicksight-embedding-sdk", | ||
"description": "JS SDK for embedding Amazon QuickSight", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"main": "dist/index.js", | ||
@@ -26,9 +26,10 @@ "homepage": "https://github.com/awslabs/amazon-quicksight-embedding-sdk", | ||
"devDependencies": { | ||
"babel-cli": "^6.6.5", | ||
"babel-core": "^6.26.0", | ||
"babel-eslint": "^8.2.1", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-preset-flow": "^6.23.0", | ||
"@babel/cli": "^7.8.4", | ||
"@babel/core": "^7.9.6", | ||
"@babel/preset-env": "^7.9.6", | ||
"@babel/preset-flow": "^7.9.0", | ||
"@babel/register": "^7.9.0", | ||
"babel-eslint": "^10.1.0", | ||
"chai": "^3.5.0", | ||
"eslint": "^5.6.0", | ||
"eslint": "^5.16.0", | ||
"eslint-plugin-flowtype": "2.39.1", | ||
@@ -39,3 +40,3 @@ "expose-loader": "^0.7.3", | ||
"jsdom-global": "^3.0.2", | ||
"mocha": "^5.1", | ||
"mocha": "^7.1.2", | ||
"webpack": "^4.25.1", | ||
@@ -48,3 +49,3 @@ "webpack-cli": "^3.3.6" | ||
"lint": "eslint --ignore-path .gitignore .", | ||
"test": "mocha --recursive --compilers js:babel-core/register", | ||
"test": "mocha --recursive --require @babel/register", | ||
"flow": "flow", | ||
@@ -51,0 +52,0 @@ "dev": "webpack --mode development ./dist/index.js --output ./dist/quicksight-embedding-js-sdk.js", |
225
README.md
# Amazon QuickSight Embedding SDK | ||
Thank you for using the Amazon QuickSight JavaScript SDK. You can use this SDK to embed Amazon QuickSight dashboards on HTML pages within your web applications. | ||
Thank you for using the Amazon QuickSight JavaScript SDK. You can use this SDK to embed Amazon QuickSight in your HTML. | ||
## Usage | ||
Before you can embed an Amazon QuickSight dashboard, you need to publish it and ensure that users are granted necessary permissions. For more information, see [Embedding Amazon QuickSight Dashboards](https://docs.aws.amazon.com/en_us/quicksight/latest/user/embedding-dashboards.html) in the Amazon QuickSight User Guide.. | ||
Amazon QuickSight offers two different embedded experiences with options for branding, user isolation with namespaces, and custom UI permissions: | ||
After a dashboard is ready to be embedded, follow the steps below to embed an Amazon QuickSight dashboard in this [example](#example): | ||
* Embedded authoring portals provide the QuickSight authoring experience | ||
To get started with an embedded authoring portal, you need to make sure that the users are granted the necessary permissions. For more information, see [Embedding the Amazon QuickSight Console](https://docs.aws.amazon.com/en_us/quicksight/latest/user/embedding-quicksight-console.html) | ||
* Embedded dashboards provide an interactive read-only experience | ||
To get started with an embedded dashboard, you need to publish it and also make sure that the users have the necessary permissions. For more information, see [Embedding Amazon QuickSight Dashboards](https://docs.aws.amazon.com/en_us/quicksight/latest/user/embedding-dashboards.html) in the Amazon QuickSight User Guide. After a dashboard is ready, follow the procedure to embed your Amazon QuickSight dashboard in this [example](#example): | ||
### Setup differences between embedded QuickSight experiences: dashboards and portals | ||
The process to set up QuickSight embedding is similar in both cases. The differences between setting up the two embedded experiences are as follows: | ||
1. You use a different SDK object for each embedded QuickSight experience. You use `embedDashboard` to embed a dashboard, and you use `embedSession` to embed an authoring portal. | ||
2. You use a different API for each embedded experience. For more information, see [QuickSight Embedding APIs](https://docs.aws.amazon.com/en_us/quicksight/latest/APIReference/embedding-quicksight.html) | ||
3. Different options are supported for each embedded experience. | ||
* Embedded dashboards are always read-only. The level of interactivity is set when the dashboard is published. | ||
* Embedded authoring ports allow the user to create QuickSight assets, just like they can in the AWS console for QuickSight. Exactly what the user can do in the console is controlled by a custom permission profile. The profile can remove abilities such as creating or updating data sources and datasets. You can set also the default visual type. Embedded consoles currently don't support screen scaling in formatting options. | ||
Details for each option are provided below in [step 2](#Step-2:-Configure-embedding) | ||
### Step 1: Download and include QuickSight Embedding SDK | ||
Do one of the following: | ||
Do ONE of the following: | ||
@@ -16,3 +33,3 @@ - Option 1: Use the Amazon QuickSight Embedding SDK in the browser: | ||
``` | ||
*OR* | ||
- Option 2: Install and use the QuickSight Embedding SDK in Node.js: | ||
@@ -26,5 +43,7 @@ ```shell | ||
You can also use ES6 import syntax in place of require: | ||
#### For the embedded dashboard experience | ||
```javascript | ||
import { embedDashboard } from 'amazon-quicksight-embedding-sdk'; | ||
const dashboard = embedDashboard(options); | ||
@@ -34,15 +53,28 @@ ``` | ||
```javascript | ||
import * as QuicksightEmbedding from 'amazon-quicksight-embedding-sdk'; | ||
import * as QuickSightEmbedding from 'amazon-quicksight-embedding-sdk'; | ||
const dashboard = QuickSightEmbedding.embedDashboard(options); | ||
``` | ||
#### For the embedded console experience (authoring portals) | ||
You can also use ES6 import syntax in place of require: | ||
```javascript | ||
import { embedSession } from 'amazon-quicksight-embedding-sdk'; | ||
### Step 2: Configure the dashboard to embed | ||
Set up the dashboard so you can embed it. | ||
const session = embedSession(options); | ||
``` | ||
Alternatively, if you need to load the entire module: | ||
```javascript | ||
import * as QuickSightEmbedding from 'amazon-quicksight-embedding-sdk'; | ||
const session = QuickSightEmbedding.embedSession(options); | ||
``` | ||
### Step 2: Configure embedding | ||
Set up the embedded QuickSight console options. | ||
```javascript | ||
var options = { | ||
url: "https://us-east-1.quicksight.aws.amazon.com/sn/dashboards/dashboardId?isauthcode=true&identityprovider=quicksight&code=authcode", | ||
container: document.getElementById("dashboardContainer"), | ||
container: document.getElementById("embeddingContainer"), | ||
parameters: { | ||
country: "United States" | ||
country: "United States", | ||
states: [ | ||
@@ -57,18 +89,21 @@ "California", | ||
locale: "en-US", | ||
footerPaddingEnabled: true | ||
footerPaddingEnabled: true, | ||
defaultEmbeddingVisualType: TABLE // this option only applies to experience embedding and will not be used for dashboard embedding | ||
}; | ||
``` | ||
#### Url element (required) | ||
If you haven't done it yet, follow [Embedding Amazon QuickSight Dashboards](https://docs.aws.amazon.com/en_us/quicksight/latest/user/embedding-dashboards.html) in the Amazon QuickSight User Guide to generate the url. | ||
#### URL element (required) | ||
If you haven't done it yet, to generate the embedding URL for dashboard embedding, follow [Embedding Amazon QuickSight Dashboards](https://docs.aws.amazon.com/en_us/quicksight/latest/user/embedding-dashboards.html) in the Amazon QuickSight User Guide to generate the url. | ||
To generate the embedding URL for console embedding, follow [Embedding the Amazon QuickSight Console](https://docs.aws.amazon.com/en_us/quicksight/latest/user/embedding-the-quicksight-console.html) in the Amazon QuickSight User Guide to generate the URL. | ||
#### Container element (required) | ||
The `container` element is the parent HTMLElement where we're going to embed the dashboard. You can make it one of the following: | ||
The `container` element is the parent HTMLElement where we're going to embed QuickSight. You can make it one of the following: | ||
- Option 1: It can be an HTMLElement: | ||
```javascript | ||
container: document.getElementById("dashboardContainer"), | ||
container: document.getElementById("embeddingContainer") | ||
``` | ||
- Option 2: Or, it can be a query selector string: | ||
```javascript | ||
container: "#dashboardContainer", | ||
container: "#embeddingContainer" | ||
``` | ||
@@ -78,11 +113,11 @@ | ||
The `parameters` element is an object that contains key:value pairs for parameters names:values. | ||
It allows you to set initial parameter values for your dashboard. Pass an array as value for multi-value parameters. | ||
It allows you to set initial parameter values for your embedded QuickSight session. Pass an array as value for multi-value parameters. | ||
For more information about parameters in Amazon QuickSight, see https://docs.aws.amazon.com/quicksight/latest/user/parameters-in-quicksight.html | ||
#### Scrolling element (optional) | ||
The `scrolling` element lets you set up a specific scrolling experience for the iFrame that holds your dashboard. Available values are `auto`, `yes`, | ||
The `scrolling` element lets you set up a specific scrolling experience for the iFrame that holds your embedded QuickSight session. Available values are `auto`, `yes`, | ||
and `no`. The default value is `no`. | ||
#### Width element and height element (optional) | ||
You can set `width` and `height` for the iFrame that holds your dashboard. Both of these default to 100%. You can set them to be fixed values: | ||
You can set `width` and `height` for the iFrame that holds your embedded QuickSight session. Both of these default to 100%. You can set them to be fixed values: | ||
```javascript | ||
@@ -99,13 +134,13 @@ height: "700px", | ||
To make your embedded dashboard responsive, don't set `width` or `height` (leave them at the default: `100%`). Then make the container HTMLElement responsive to screen size change. | ||
To make your embedded QuickSight session responsive, don't set `width` or `height` (leave them at the default: `100%`). Then you can make the container HTMLElement responsive to screen size change. | ||
You can also choose to set height to be `AutoFit` to make the iFrame fit your dashboard height. Use `loadingHeight` to specify the height you'd like to use before actual dashboard height is known: | ||
You can also choose to set height to be `AutoFit` to make the iFrame fit your dashboard height. Use `loadingHeight` to specify the height you'd like to use before actual dashboard height is known. **This is currently only supported for dashboard embedding**: | ||
```javascript | ||
height: "AutoFit", | ||
loadingHeight: "700px", | ||
loadingHeight: "700px" | ||
``` | ||
Note: With AutoFit height enabled, the dashboard's modal (such as modal shown when selected "Export to CSV" for a Table visual) could be hidden | ||
if the dashboard content is larger than the screen. To solve the issue, you can add the following code to auto-scroll the focus to the modal. | ||
Note: With AutoFit height enabled, modals generated by the dashboard can be hidden | ||
if the content is larger than the screen. An example of this type of modal is the one that displays when you select "Export to CSV" on a Table visual. To solve this issue, you can add the following code to autoscroll the focus to the modal. | ||
```javascript | ||
@@ -138,7 +173,6 @@ dashboard.on("SHOW_MODAL_EVENT", () => { | ||
We've overridden border and padding of the iFrame to be 0px, as setting border and padding on the iFrame might cause unexpected issues. | ||
If you have to set border and padding on the embedded dashboard, set it on the container div that contains the iFrame. | ||
We've overridden the border and padding of the iFrame to be 0px, because setting border and padding on the iFrame might cause unexpected issues. If you have to set border and padding on the embedded QuickSight session, set it on the container div that contains the iFrame. | ||
#### Locale element (optional) | ||
You can set locale for the embedded dashboard: | ||
You can set locale for the embedded QuickSight session: | ||
```javascript | ||
@@ -149,10 +183,10 @@ locale: "en-US", | ||
``` | ||
en-US (English), | ||
de-DE (Deutsch), | ||
ja-JP (日本語), | ||
es-ES (Español), | ||
fr-FR (Français), | ||
it-IT (Italiano), | ||
pt-BR (Português), | ||
ko-KR (한국어), | ||
en-US (English), | ||
de-DE (Deutsch), | ||
ja-JP (日本語), | ||
es-ES (Español), | ||
fr-FR (Français), | ||
it-IT (Italiano), | ||
pt-BR (Português), | ||
ko-KR (한국어), | ||
zh-CN (中文 (简体)), | ||
@@ -162,8 +196,20 @@ zh-TW (中文 (繁體)) | ||
#### DefaultEmbeddingVisualType for QuickSight console embedding (optional) | ||
You can set the embedding visual type for embedded sessions. The default visual type provided in the options will be used during visual creating. By default, when you add a new visual in an embedded session, `AutoGraph` is selected by default. This setting can be overridden to `Table` by setting the following option: | ||
``` | ||
defaultEmbeddingVisualType: "TABLE" | ||
``` | ||
Available options for default visual types in embedding are: | ||
``` | ||
AUTO_GRAPH, | ||
TABLE | ||
``` | ||
#### FooterPaddingEnabled element (optional) | ||
The `footerPaddingEnabled` element adds 22 pixels of space at the bottom of the layout. For example, you can set this to `true` if the "Powered by QuickSight" footer blocks part of your visual. The default value is `false`. | ||
### Step 3: Embed the dashboard | ||
### Step 3: Create the QuickSight session object | ||
Embed the dashboard by calling: | ||
#### Dashboard embedding | ||
```javascript | ||
@@ -174,4 +220,10 @@ var dashboard = QuickSightEmbedding.embedDashboard(options); | ||
#### Console embedding | ||
```javascript | ||
var session = QuickSightEmbedding.embedSession(options); | ||
``` | ||
This returns an console session object for further action. | ||
### Step 4: Setup load callback (optional) | ||
**This is currently only supported for dashboard embedding.** | ||
@@ -193,3 +245,3 @@ If you want your application to get notified and respond when the Amazon QuickSight dashboard is fully loaded, use a load callback. Choose one of the following: | ||
If you want your application get notified and respond when QuickSight dashboard fails to load, use a error callback. Choose one of the following: | ||
If you want your application get notified and respond when the embedded QuickSight session fails to load, use a error callback. Choose one of the following: | ||
@@ -206,5 +258,10 @@ - Use options: | ||
- To register the "error" event on the returned console session object: | ||
```javascript | ||
session.on("error", yourErrorCallback); | ||
``` | ||
We pass a payload object to your callback function with a specific `payload.errorCode`. Currently, the error codes are: | ||
- `Forbidden` -- the URL's authentication code expired | ||
- `Forbidden` -- the URL's authentication code expired | ||
@@ -217,4 +274,7 @@ - `Unauthorized` -- the session obtained from the authentication code expired | ||
### Step 6: Update parameter values (optional) | ||
Use `dashboard.setParameters()` to update parameter values. Pass an array as value for multi-value parameters. | ||
You can build your own UI to trigger this, so that viewers of the embedded dashboard can control the dashboard from your app page. | ||
Use `setParameters()` to update parameter values. Pass an array as value for multi-value parameters. | ||
You can build your own UI to trigger this, so that viewers of the embedded QuickSight session can control it from your app page. | ||
#### Dashboard embedding | ||
Parameters in an embedded dashboard session can be set by using the following call: | ||
```javascript | ||
@@ -229,5 +289,18 @@ dashboard.setParameters({country: "United States", states: ["California", "Washington"]}); | ||
#### Console embedding | ||
Parameters in an embedded console session can be set by using the following call: | ||
```javascript | ||
session.setParameters({country: "United States", states: ["California", "Washington"]}); | ||
``` | ||
To reset a parameter so that it includes all values, you can pass the string `"[ALL]"`. | ||
```javascript | ||
session.setParameters({country: "United States", states: "[ALL]" }); | ||
``` | ||
## Troubleshooting | ||
1. Make sure the url you provide in options is not encoded. Don't encode the url as it changes the authcode in the url and breaks the url. Also check that the url responded from server side is not encoded. | ||
1. Make sure the URL you provide in options is not encoded. You should avoid using an encoded URL because it breaks the authcode in the URL by changing it. Also, check that the URL sent in the response from the server side is not encoded. | ||
2. The URL only works if it used with the authcode it came with. The URL and authcode need to be used together. They expire after five minutes, so it's worth checking that you're not troubleshooting an expired combination of URL and authcode. | ||
2. Some browsers (e.g. mobile safari) have default setting to "Always Block Cookies". Change the setting to either "Allow form Websites I Visit" or "Always Allow". | ||
@@ -237,2 +310,3 @@ | ||
## Example | ||
### Dashboard embedding | ||
```html | ||
@@ -244,3 +318,3 @@ <!DOCTYPE html> | ||
<title>Basic Embed</title> | ||
<script src="https://unpkg.com/amazon-quicksight-embedding-sdk@1.0.7/dist/quicksight-embedding-js-sdk.min.js"></script> | ||
<script src="https://unpkg.com/amazon-quicksight-embedding-sdk@1.0.8/dist/quicksight-embedding-js-sdk.min.js"></script> | ||
<script type="text/javascript"> | ||
@@ -257,3 +331,3 @@ var dashboard | ||
function embedDashboard() { | ||
var containerDiv = document.getElementById("dashboardContainer"); | ||
var containerDiv = document.getElementById("embeddingContainer"); | ||
var options = { | ||
@@ -291,3 +365,3 @@ url: "https://us-east-1.quicksight.aws.amazon.com/sn/dashboards/dashboardId?isauthcode=true&identityprovider=quicksight&code=authcode", | ||
</span> | ||
<div id="dashboardContainer"></div> | ||
<div id="embeddingContainer"></div> | ||
</body> | ||
@@ -298,3 +372,62 @@ | ||
### QuickSight console embedding | ||
```html | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>QuickSight Console Embedding</title> | ||
<script src="https://unpkg.com/amazon-quicksight-embedding-sdk@1.0.8/dist/quicksight-embedding-js-sdk.min.js"></script> | ||
<script type="text/javascript"> | ||
var session | ||
function onError(payload) { | ||
console.log("Do something when the session fails loading"); | ||
} | ||
function embedSession() { | ||
var containerDiv = document.getElementById("embeddingContainer"); | ||
var options = { | ||
url: "https://us-east-1.quicksight.aws.amazon.com/sn/dashboards/dashboardId?isauthcode=true&identityprovider=quicksight&code=authcode", // replace this dummy url with the one generated via embedding API | ||
container: containerDiv, | ||
parameters: { | ||
country: "United States" | ||
}, | ||
scrolling: "no", | ||
height: "700px", | ||
width: "1000px", | ||
locale: "en-US", | ||
footerPaddingEnabled: true, | ||
defaultEmbeddingVisualType: TABLE, // this option only applies to QuickSight console embedding and is not used for dashboard embedding | ||
}; | ||
session = QuickSightEmbedding.embedSession(options); | ||
session.on("error", onError); | ||
} | ||
function onCountryChange(obj) { | ||
session.setParameters({country: obj.value}); | ||
} | ||
</script> | ||
</head> | ||
<body onload="embedSession()"> | ||
<span> | ||
<label for="country">Country</label> | ||
<select id="country" name="country" onchange="onCountryChange(this)"> | ||
<option value="United States">United States</option> | ||
<option value="Mexico">Mexico</option> | ||
<option value="Canada">Canada</option> | ||
</select> | ||
</span> | ||
<div id="embeddingContainer"></div> | ||
</body> | ||
</html> | ||
``` | ||
## Change Log | ||
**1.0.8** | ||
* Added support for session embedding | ||
* Added option for default visual type for session embedding | ||
* Updated Babel to the latest version | ||
**1.0.7** | ||
@@ -301,0 +434,0 @@ * Added option to enable footer padding. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117524
439
16
930
1