@hotwax/dxp-components 1.0.2 → 1.1.1
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/lib/components/ShopifyImg.d.ts +17 -0
- package/lib/components/ShopifyImg.js +56 -0
- package/lib/index.d.ts +5 -2
- package/lib/index.js +21 -3
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +11 -0
- package/package.json +5 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<Readonly<{
|
|
2
|
+
size?: any;
|
|
3
|
+
src?: any;
|
|
4
|
+
}>, unknown, {
|
|
5
|
+
imageUrl: string;
|
|
6
|
+
}, {}, {
|
|
7
|
+
prepareImgUrl(src: string, size?: string): string;
|
|
8
|
+
checkIfImageExists(src: string): Promise<unknown>;
|
|
9
|
+
setImageUrl(): void;
|
|
10
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<Readonly<{
|
|
11
|
+
size?: any;
|
|
12
|
+
src?: any;
|
|
13
|
+
}>>>, {
|
|
14
|
+
readonly size?: any;
|
|
15
|
+
readonly src?: any;
|
|
16
|
+
}, {}>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
var _index = require("../index");
|
|
9
|
+
var _default = (0, _vue.defineComponent)({
|
|
10
|
+
template: `
|
|
11
|
+
<img :src="imageUrl"/>
|
|
12
|
+
`,
|
|
13
|
+
data() {
|
|
14
|
+
return {
|
|
15
|
+
imageUrl: _index.defaultImgUrl
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
props: ['src', 'size'],
|
|
19
|
+
mounted() {
|
|
20
|
+
this.setImageUrl();
|
|
21
|
+
},
|
|
22
|
+
updated() {
|
|
23
|
+
this.setImageUrl();
|
|
24
|
+
},
|
|
25
|
+
methods: {
|
|
26
|
+
prepareImgUrl(src, size) {
|
|
27
|
+
// return original size if no size is given
|
|
28
|
+
if (!size) return src;
|
|
29
|
+
// remove any current image size then add the new image size
|
|
30
|
+
return src.replace(/_(pico|icon|thumb|small|compact|medium|large|grande|original|1024x1024|2048x2048|master)+\./g, '.').replace(/\.jpg|\.png|\.gif|\.jpeg/g, function (match) {
|
|
31
|
+
return '_' + size + match;
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
checkIfImageExists(src) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const img = new Image();
|
|
37
|
+
img.onload = function () {
|
|
38
|
+
resolve(true);
|
|
39
|
+
};
|
|
40
|
+
img.onerror = function () {
|
|
41
|
+
reject(false);
|
|
42
|
+
};
|
|
43
|
+
img.src = src;
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
setImageUrl() {
|
|
47
|
+
if (this.src) {
|
|
48
|
+
const src = this.prepareImgUrl(this.src, this.size);
|
|
49
|
+
this.checkIfImageExists(src).then(() => {
|
|
50
|
+
this.imageUrl = src;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
exports.default = _default;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { useProductIdentificationStore } from "./store/productIdentification";
|
|
2
|
+
import ShopifyImg from "./components/ShopifyImg";
|
|
3
|
+
import { goToOms } from "./utils";
|
|
4
|
+
declare let defaultImgUrl: string;
|
|
2
5
|
export declare let dxpComponents: {
|
|
3
|
-
install(app: any): void;
|
|
6
|
+
install(app: any, options: any): void;
|
|
4
7
|
};
|
|
5
|
-
export { useProductIdentificationStore };
|
|
8
|
+
export { useProductIdentificationStore, defaultImgUrl, ShopifyImg, goToOms };
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
Object.defineProperty(exports, "ShopifyImg", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ShopifyImg.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.dxpComponents = exports.defaultImgUrl = void 0;
|
|
13
|
+
Object.defineProperty(exports, "goToOms", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _utils.goToOms;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
7
19
|
Object.defineProperty(exports, "useProductIdentificationStore", {
|
|
8
20
|
enumerable: true,
|
|
9
21
|
get: function () {
|
|
@@ -12,15 +24,21 @@ Object.defineProperty(exports, "useProductIdentificationStore", {
|
|
|
12
24
|
});
|
|
13
25
|
var _pinia = require("pinia");
|
|
14
26
|
var _productIdentification = require("./store/productIdentification");
|
|
27
|
+
var _ShopifyImg = _interopRequireDefault(require("./components/ShopifyImg"));
|
|
28
|
+
var _utils = require("./utils");
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
30
|
// TODO: handle cases when the store from app or pinia store are not available
|
|
16
31
|
// creating a pinia store for the plugin
|
|
17
32
|
const pinia = (0, _pinia.createPinia)();
|
|
18
|
-
|
|
33
|
+
let defaultImgUrl;
|
|
19
34
|
// executed on app initialization
|
|
35
|
+
exports.defaultImgUrl = defaultImgUrl;
|
|
20
36
|
let dxpComponents = {
|
|
21
|
-
install(app) {
|
|
37
|
+
install(app, options) {
|
|
22
38
|
// registering pinia in the app
|
|
23
39
|
app.use(pinia);
|
|
40
|
+
app.component('ShopifyImg', _ShopifyImg.default);
|
|
41
|
+
exports.defaultImgUrl = defaultImgUrl = options.defaultImgUrl;
|
|
24
42
|
}
|
|
25
43
|
};
|
|
26
44
|
exports.dxpComponents = dxpComponents;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.goToOms = void 0;
|
|
7
|
+
const goToOms = (token, oms) => {
|
|
8
|
+
const link = (oms.startsWith('http') ? oms.replace('api/', "") : `https://${oms}.hotwax.io/`) + `?token=${token}`;
|
|
9
|
+
window.open(link, '_blank', 'noopener, noreferrer');
|
|
10
|
+
};
|
|
11
|
+
exports.goToOms = goToOms;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hotwax/dxp-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -22,9 +22,13 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@babel/cli": "^7.21.5",
|
|
24
24
|
"@babel/core": "^7.22.1",
|
|
25
|
+
"@babel/plugin-syntax-jsx": "^7.22.5",
|
|
25
26
|
"@babel/preset-env": "^7.22.4",
|
|
26
27
|
"@babel/preset-typescript": "^7.21.5",
|
|
28
|
+
"@vue/babel-plugin-jsx": "^1.1.1",
|
|
29
|
+
"@vue/babel-plugin-transform-vue-jsx": "^1.4.0",
|
|
27
30
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
31
|
+
"babel-preset-vue": "^2.0.2",
|
|
28
32
|
"eslint": "^8.16.0",
|
|
29
33
|
"typescript": "^5.0.4"
|
|
30
34
|
},
|