@antscorp/antsomi-ui 1.3.5-beta.753 → 1.3.5-beta.754
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.
|
@@ -29,6 +29,7 @@ export declare const parseTagString: (input: string, acceptableTagPattern: Array
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function convertInputString(input: string): string;
|
|
31
31
|
export declare const getLinkLineURLImage: (productId?: string, code?: string) => string;
|
|
32
|
+
export declare const getImageSourceViberEmoji: (fileName?: string) => any;
|
|
32
33
|
/**
|
|
33
34
|
* Processes the input text to replace emojis based on the specified collection type.
|
|
34
35
|
*
|
|
@@ -4,7 +4,6 @@ import stringReplaceToArray from 'string-replace-to-array';
|
|
|
4
4
|
import { CUSTOM_FN, EMOJI, EMOJI_COLLECTIONS, PREFIX_PATTERN_LINE_MESSAGE, PROMOTION_CODE, SHORT_LINK, } from './constants';
|
|
5
5
|
import { iconsViber } from './iconsViber';
|
|
6
6
|
// Utils
|
|
7
|
-
import { getImagePath } from './generateImagePath';
|
|
8
7
|
import { acceptablePatternChecking, getCachedRegex, patternHandlers } from './patternHandlers';
|
|
9
8
|
/**
|
|
10
9
|
* Parses the input string and replaces matching patterns with processed tags.
|
|
@@ -102,24 +101,20 @@ export function convertInputString(input) {
|
|
|
102
101
|
return result.trim(); // Remove any trailing whitespace
|
|
103
102
|
}
|
|
104
103
|
export const getLinkLineURLImage = (productId = '', code = '') => `https://stickershop.line-scdn.net/sticonshop/v1/sticon/${productId}/android/${code}.png?detect-emoji=line-message&v=1`;
|
|
104
|
+
export const getImageSourceViberEmoji = (fileName = '') => {
|
|
105
|
+
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
106
|
+
const src = require(`../../../assets/images/viber/96x96/${fileName}`);
|
|
107
|
+
return src.default || src;
|
|
108
|
+
};
|
|
105
109
|
/**
|
|
106
110
|
* Creates a renderer function for Viber emojis that maps specific filenames to emojis.
|
|
107
111
|
*
|
|
108
112
|
* @returns {Function} A function that takes a filename extension and returns a corresponding image source URL
|
|
109
113
|
* or undefined if the image path is not found.
|
|
110
114
|
*
|
|
111
|
-
* The renderer replaces certain filenames with their corresponding special characters (e.g., 'exclamation' with '!').
|
|
112
115
|
*/
|
|
113
116
|
const makeViberEmojiRenderer = () => function renderViberEmoji(fileNameExtension) {
|
|
114
|
-
const
|
|
115
|
-
let fileNameWithoutExtension = fileNameExtension.slice(0, findIndexOfDot);
|
|
116
|
-
if (fileNameWithoutExtension === 'exclamation') {
|
|
117
|
-
fileNameWithoutExtension = '!';
|
|
118
|
-
}
|
|
119
|
-
if (fileNameWithoutExtension === 'dollars') {
|
|
120
|
-
fileNameWithoutExtension = '$';
|
|
121
|
-
}
|
|
122
|
-
const src = getImagePath(fileNameWithoutExtension);
|
|
117
|
+
const src = getImageSourceViberEmoji(fileNameExtension);
|
|
123
118
|
return src;
|
|
124
119
|
};
|
|
125
120
|
/**
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getImagePath(fileName: string): string | undefined;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
// Utility function to determine if running in Vite environment
|
|
3
|
-
function isVite() {
|
|
4
|
-
console.log('import meta', import.meta);
|
|
5
|
-
return typeof import.meta !== 'undefined';
|
|
6
|
-
}
|
|
7
|
-
// Utility function to determine if running in Webpack environment
|
|
8
|
-
function isWebpack() {
|
|
9
|
-
console.log('typeof require', typeof require);
|
|
10
|
-
return typeof require !== 'undefined' && typeof require.context === 'function';
|
|
11
|
-
}
|
|
12
|
-
// Create an image map based on the detected environment
|
|
13
|
-
const imageMap = {};
|
|
14
|
-
if (isVite()) {
|
|
15
|
-
// Vite environment: Use import.meta.glob to preload images
|
|
16
|
-
const images = import.meta.glob('../../../assets/images/viber/96x96/*.png', {
|
|
17
|
-
eager: true,
|
|
18
|
-
import: 'default',
|
|
19
|
-
});
|
|
20
|
-
for (const path in images) {
|
|
21
|
-
const fileName = (_a = path.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift();
|
|
22
|
-
if (fileName) {
|
|
23
|
-
imageMap[fileName] = images[path];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else if (isWebpack()) {
|
|
28
|
-
// Webpack environment: Use require.context to preload images
|
|
29
|
-
const images = require.context('../../../assets/images/viber/96x96', false, /\.png$/);
|
|
30
|
-
images.keys().forEach(key => {
|
|
31
|
-
var _a;
|
|
32
|
-
const fileName = (_a = key.split('/').pop()) === null || _a === void 0 ? void 0 : _a.split('.').shift();
|
|
33
|
-
if (fileName) {
|
|
34
|
-
imageMap[fileName] = images(key).default || images(key);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
console.error('Unsupported environment: This code must run in either Vite or Webpack.');
|
|
40
|
-
}
|
|
41
|
-
export function getImagePath(fileName) {
|
|
42
|
-
return imageMap[fileName]; // Return the correct image path
|
|
43
|
-
}
|