@product7/product7-js 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/product7-js.js +10300 -10279
- package/dist/product7-js.js.map +1 -1
- package/dist/product7-js.min.js +1 -1
- package/dist/product7-js.min.js.map +1 -1
- package/package.json +1 -1
- package/src/core/Product7.js +22 -0
- package/types/index.d.ts +1 -0
package/package.json
CHANGED
package/src/core/Product7.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ConfigError, SDKError } from '../utils/errors.js';
|
|
2
2
|
import { deepMerge, generateId } from '../utils/helpers.js';
|
|
3
|
+
import { CSS_STYLES } from '../styles/styles.js';
|
|
3
4
|
import { WidgetFactory } from '../widgets/WidgetFactory.js';
|
|
4
5
|
import { APIService } from './APIService.js';
|
|
5
6
|
import { EventBus } from './EventBus.js';
|
|
@@ -25,11 +26,32 @@ export class Product7 {
|
|
|
25
26
|
this._bindMethods();
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
_injectStyles() {
|
|
30
|
+
if (typeof document === 'undefined') return;
|
|
31
|
+
if (document.querySelector('#product7-styles')) return;
|
|
32
|
+
|
|
33
|
+
const style = document.createElement('style');
|
|
34
|
+
style.id = 'product7-styles';
|
|
35
|
+
style.textContent = CSS_STYLES;
|
|
36
|
+
document.head.appendChild(style);
|
|
37
|
+
|
|
38
|
+
if (!document.querySelector('#product7-iconify')) {
|
|
39
|
+
const script = document.createElement('script');
|
|
40
|
+
script.id = 'product7-iconify';
|
|
41
|
+
script.src =
|
|
42
|
+
'https://cdn.jsdelivr.net/npm/iconify-icon@2/dist/iconify-icon.min.js';
|
|
43
|
+
script.async = true;
|
|
44
|
+
document.head.appendChild(script);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
28
48
|
async init() {
|
|
29
49
|
if (this.initialized) {
|
|
30
50
|
return { alreadyInitialized: true };
|
|
31
51
|
}
|
|
32
52
|
|
|
53
|
+
this._injectStyles();
|
|
54
|
+
|
|
33
55
|
try {
|
|
34
56
|
const initData = await this.apiService.init(this.config.metadata);
|
|
35
57
|
|