crosstalk-comments-livechat-sdk 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/EmbedComponent1.d.ts +0 -12
- package/dist/EmbedComponent1.js +0 -49
- package/dist/EmbedComponent2.d.ts +0 -12
- package/dist/EmbedComponent2.js +0 -50
- package/dist/component.d.ts +0 -12
- package/dist/component.js +0 -107
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crosstalk-comments-livechat-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Add Comments, Live Chat, and Video Player Embeds to your website with CrossTalk Comments and Live Chat!",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EmbedOptions } from './types';
|
|
2
|
-
export declare class EmbedComponent1 {
|
|
3
|
-
private container;
|
|
4
|
-
private config;
|
|
5
|
-
private iframe;
|
|
6
|
-
constructor(container: HTMLElement, config: EmbedOptions);
|
|
7
|
-
render(): void;
|
|
8
|
-
update(config: Partial<EmbedOptions>): void;
|
|
9
|
-
destroy(): void;
|
|
10
|
-
getIframe(): HTMLIFrameElement | null;
|
|
11
|
-
}
|
|
12
|
-
export declare function createEmbedComponent1(container: HTMLElement, config: EmbedOptions): EmbedComponent1;
|
package/dist/EmbedComponent1.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
function buildIframeUrl(config) {
|
|
2
|
-
const baseUrl = 'https://example.com/embed';
|
|
3
|
-
const params = new URLSearchParams();
|
|
4
|
-
params.append('webPropertyID', config.webPropertyID);
|
|
5
|
-
if (config.url) {
|
|
6
|
-
params.append('url', config.url);
|
|
7
|
-
}
|
|
8
|
-
else if (config.pageID) {
|
|
9
|
-
params.append('pageID', config.pageID);
|
|
10
|
-
}
|
|
11
|
-
return `${baseUrl}?${params.toString()}`;
|
|
12
|
-
}
|
|
13
|
-
export class EmbedComponent1 {
|
|
14
|
-
constructor(container, config) {
|
|
15
|
-
this.container = container;
|
|
16
|
-
this.config = config;
|
|
17
|
-
this.iframe = null;
|
|
18
|
-
this.render();
|
|
19
|
-
}
|
|
20
|
-
render() {
|
|
21
|
-
this.container.innerHTML = '';
|
|
22
|
-
this.iframe = document.createElement('iframe');
|
|
23
|
-
this.iframe.src = buildIframeUrl(this.config);
|
|
24
|
-
this.iframe.title = 'Embed Widget 1';
|
|
25
|
-
this.iframe.allowFullscreen = true;
|
|
26
|
-
// Apply styles
|
|
27
|
-
Object.assign(this.iframe.style, Object.assign({ border: 'none', width: '100%', height: '400px', borderRadius: '8px' }, this.config.style));
|
|
28
|
-
if (this.config.className) {
|
|
29
|
-
this.iframe.className = this.config.className;
|
|
30
|
-
}
|
|
31
|
-
this.container.appendChild(this.iframe);
|
|
32
|
-
}
|
|
33
|
-
update(config) {
|
|
34
|
-
this.config = Object.assign(Object.assign({}, this.config), config);
|
|
35
|
-
this.render();
|
|
36
|
-
}
|
|
37
|
-
destroy() {
|
|
38
|
-
if (this.iframe && this.iframe.parentNode) {
|
|
39
|
-
this.iframe.parentNode.removeChild(this.iframe);
|
|
40
|
-
this.iframe = null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
getIframe() {
|
|
44
|
-
return this.iframe;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export function createEmbedComponent1(container, config) {
|
|
48
|
-
return new EmbedComponent1(container, config);
|
|
49
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EmbedOptions } from './types';
|
|
2
|
-
export declare class EmbedComponent2 {
|
|
3
|
-
private container;
|
|
4
|
-
private config;
|
|
5
|
-
private iframe;
|
|
6
|
-
constructor(container: HTMLElement, config: EmbedOptions);
|
|
7
|
-
render(): void;
|
|
8
|
-
update(config: Partial<EmbedOptions>): void;
|
|
9
|
-
destroy(): void;
|
|
10
|
-
getIframe(): HTMLIFrameElement | null;
|
|
11
|
-
}
|
|
12
|
-
export declare function createEmbedComponent2(container: HTMLElement, config: EmbedOptions): EmbedComponent2;
|
package/dist/EmbedComponent2.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
function buildIframeUrl(config) {
|
|
2
|
-
const baseUrl = 'https://example.com/embed/v2';
|
|
3
|
-
const params = new URLSearchParams();
|
|
4
|
-
params.append('webPropertyID', config.webPropertyID);
|
|
5
|
-
params.append('component', 'v2');
|
|
6
|
-
if (config.url) {
|
|
7
|
-
params.append('url', config.url);
|
|
8
|
-
}
|
|
9
|
-
else if (config.pageID) {
|
|
10
|
-
params.append('pageID', config.pageID);
|
|
11
|
-
}
|
|
12
|
-
return `${baseUrl}?${params.toString()}`;
|
|
13
|
-
}
|
|
14
|
-
export class EmbedComponent2 {
|
|
15
|
-
constructor(container, config) {
|
|
16
|
-
this.container = container;
|
|
17
|
-
this.config = config;
|
|
18
|
-
this.iframe = null;
|
|
19
|
-
this.render();
|
|
20
|
-
}
|
|
21
|
-
render() {
|
|
22
|
-
this.container.innerHTML = '';
|
|
23
|
-
this.iframe = document.createElement('iframe');
|
|
24
|
-
this.iframe.src = buildIframeUrl(this.config);
|
|
25
|
-
this.iframe.title = 'Embed Widget 2';
|
|
26
|
-
this.iframe.allowFullscreen = true;
|
|
27
|
-
// Apply styles
|
|
28
|
-
Object.assign(this.iframe.style, Object.assign({ border: '1px solid #e0e0e0', width: '100%', height: '500px', borderRadius: '4px', boxShadow: '0 2px 8px rgba(0,0,0,0.1)' }, this.config.style));
|
|
29
|
-
if (this.config.className) {
|
|
30
|
-
this.iframe.className = this.config.className;
|
|
31
|
-
}
|
|
32
|
-
this.container.appendChild(this.iframe);
|
|
33
|
-
}
|
|
34
|
-
update(config) {
|
|
35
|
-
this.config = Object.assign(Object.assign({}, this.config), config);
|
|
36
|
-
this.render();
|
|
37
|
-
}
|
|
38
|
-
destroy() {
|
|
39
|
-
if (this.iframe && this.iframe.parentNode) {
|
|
40
|
-
this.iframe.parentNode.removeChild(this.iframe);
|
|
41
|
-
this.iframe = null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
getIframe() {
|
|
45
|
-
return this.iframe;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export function createEmbedComponent2(container, config) {
|
|
49
|
-
return new EmbedComponent2(container, config);
|
|
50
|
-
}
|
package/dist/component.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { EmbedComponentProps } from './types';
|
|
2
|
-
export declare class EmbedComponent extends HTMLElement {
|
|
3
|
-
private iframe;
|
|
4
|
-
private props;
|
|
5
|
-
constructor(props: EmbedComponentProps);
|
|
6
|
-
static get observedAttributes(): string[];
|
|
7
|
-
connectedCallback(): void;
|
|
8
|
-
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
9
|
-
private render;
|
|
10
|
-
updateProps(newProps: Partial<EmbedComponentProps>): void;
|
|
11
|
-
getIframe(): HTMLIFrameElement | null;
|
|
12
|
-
}
|
package/dist/component.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.EmbedComponent = void 0;
|
|
30
|
-
var EmbedComponent = /** @class */ (function (_super) {
|
|
31
|
-
__extends(EmbedComponent, _super);
|
|
32
|
-
function EmbedComponent(props) {
|
|
33
|
-
var _this = _super.call(this) || this;
|
|
34
|
-
_this.iframe = null;
|
|
35
|
-
_this.props = props;
|
|
36
|
-
_this.attachShadow({ mode: 'open' });
|
|
37
|
-
_this.render();
|
|
38
|
-
return _this;
|
|
39
|
-
}
|
|
40
|
-
Object.defineProperty(EmbedComponent, "observedAttributes", {
|
|
41
|
-
get: function () {
|
|
42
|
-
return ['src', 'width', 'height', 'title'];
|
|
43
|
-
},
|
|
44
|
-
enumerable: false,
|
|
45
|
-
configurable: true
|
|
46
|
-
});
|
|
47
|
-
EmbedComponent.prototype.connectedCallback = function () {
|
|
48
|
-
this.render();
|
|
49
|
-
};
|
|
50
|
-
EmbedComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
|
|
51
|
-
if (oldValue !== newValue && this.iframe) {
|
|
52
|
-
switch (name) {
|
|
53
|
-
case 'src':
|
|
54
|
-
this.iframe.src = newValue;
|
|
55
|
-
break;
|
|
56
|
-
case 'width':
|
|
57
|
-
this.iframe.width = newValue;
|
|
58
|
-
break;
|
|
59
|
-
case 'height':
|
|
60
|
-
this.iframe.height = newValue;
|
|
61
|
-
break;
|
|
62
|
-
case 'title':
|
|
63
|
-
this.iframe.title = newValue;
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
EmbedComponent.prototype.render = function () {
|
|
69
|
-
if (!this.shadowRoot)
|
|
70
|
-
return;
|
|
71
|
-
var _a = this.props, src = _a.src, _b = _a.width, width = _b === void 0 ? '100%' : _b, _c = _a.height, height = _c === void 0 ? '400px' : _c, _d = _a.className, className = _d === void 0 ? '' : _d, _e = _a.allowFullscreen, allowFullscreen = _e === void 0 ? true : _e, _f = _a.sandbox, sandbox = _f === void 0 ? ['allow-scripts', 'allow-same-origin'] : _f, _g = _a.allow, allow = _g === void 0 ? 'fullscreen' : _g, _h = _a.title, title = _h === void 0 ? 'Embedded Content' : _h, onLoad = _a.onLoad, onError = _a.onError, _j = _a.style, style = _j === void 0 ? {} : _j;
|
|
72
|
-
this.iframe = document.createElement('iframe');
|
|
73
|
-
this.iframe.src = src;
|
|
74
|
-
this.iframe.width = width;
|
|
75
|
-
this.iframe.height = height;
|
|
76
|
-
this.iframe.className = "embed-iframe ".concat(className);
|
|
77
|
-
this.iframe.title = title;
|
|
78
|
-
this.iframe.allow = allow;
|
|
79
|
-
if (allowFullscreen) {
|
|
80
|
-
this.iframe.allow += ' fullscreen';
|
|
81
|
-
}
|
|
82
|
-
this.iframe.sandbox.value = sandbox.join(' ');
|
|
83
|
-
// Apply custom styles
|
|
84
|
-
Object.assign(this.iframe.style, style);
|
|
85
|
-
// Add event listeners
|
|
86
|
-
if (onLoad) {
|
|
87
|
-
this.iframe.addEventListener('load', onLoad);
|
|
88
|
-
}
|
|
89
|
-
if (onError) {
|
|
90
|
-
this.iframe.addEventListener('error', onError);
|
|
91
|
-
}
|
|
92
|
-
// Clear and append
|
|
93
|
-
this.shadowRoot.innerHTML = '';
|
|
94
|
-
this.shadowRoot.appendChild(this.iframe);
|
|
95
|
-
};
|
|
96
|
-
// Public method to update props
|
|
97
|
-
EmbedComponent.prototype.updateProps = function (newProps) {
|
|
98
|
-
this.props = __assign(__assign({}, this.props), newProps);
|
|
99
|
-
this.render();
|
|
100
|
-
};
|
|
101
|
-
// Public method to get the iframe element
|
|
102
|
-
EmbedComponent.prototype.getIframe = function () {
|
|
103
|
-
return this.iframe;
|
|
104
|
-
};
|
|
105
|
-
return EmbedComponent;
|
|
106
|
-
}(HTMLElement));
|
|
107
|
-
exports.EmbedComponent = EmbedComponent;
|