@underverse-ui/underverse 1.0.167 → 1.0.169

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@underverse-ui/underverse",
3
- "version": "1.0.167",
3
+ "version": "1.0.169",
4
4
  "private": false,
5
5
  "description": "Underverse UI – reusable React/Next.js UI components",
6
6
  "type": "module",
@@ -33,10 +33,12 @@
33
33
  "api-reference.json",
34
34
  "llms.txt",
35
35
  "agent-recipes.json",
36
- "emojis"
36
+ "emojis",
37
+ "scripts/copy-emojis.mjs"
37
38
  ],
38
39
  "sideEffects": false,
39
40
  "scripts": {
41
+ "postinstall": "node ./scripts/copy-emojis.mjs",
40
42
  "dev": "tsup --config tsup.config.ts --watch",
41
43
  "typecheck": "tsc -p tsconfig.tsup.json --noEmit --incremental false",
42
44
  "generate:api": "node ./scripts/generate-api-reference.mjs",
@@ -0,0 +1,54 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ // Thư mục chứa emoji nguồn trong package
9
+ const srcEmojisDir = path.resolve(__dirname, '../emojis');
10
+
11
+ // Các đường dẫn có khả năng là thư mục public của dự án tiêu thụ
12
+ const pathsToTry = [
13
+ path.resolve(__dirname, '../../../../public'), // Cài đặt tiêu chuẩn: node_modules/@underverse-ui/underverse/scripts -> dự án
14
+ path.resolve(__dirname, '../../../../../public'), // Monorepo / Cài đặt lồng nhau
15
+ path.resolve(__dirname, '../../../public'),
16
+ path.resolve(__dirname, '../../public'), // Môi trường dev local
17
+ ];
18
+
19
+ let targetPublicDir = null;
20
+ for (const p of pathsToTry) {
21
+ try {
22
+ if (fs.existsSync(p) && fs.statSync(p).isDirectory()) {
23
+ targetPublicDir = p;
24
+ break;
25
+ }
26
+ } catch (e) {
27
+ // Bỏ qua lỗi truy cập nếu có
28
+ }
29
+ }
30
+
31
+ if (targetPublicDir && fs.existsSync(srcEmojisDir)) {
32
+ const destEmojisDir = path.join(targetPublicDir, 'emojis');
33
+ console.log(`[underverse] Automatically copying emoji assets to: ${destEmojisDir}`);
34
+
35
+ try {
36
+ fs.mkdirSync(destEmojisDir, { recursive: true });
37
+ const files = fs.readdirSync(srcEmojisDir);
38
+ let copiedCount = 0;
39
+
40
+ for (const file of files) {
41
+ const srcFile = path.join(srcEmojisDir, file);
42
+ const destFile = path.join(destEmojisDir, file);
43
+ if (fs.statSync(srcFile).isFile()) {
44
+ fs.copyFileSync(srcFile, destFile);
45
+ copiedCount++;
46
+ }
47
+ }
48
+ console.log(`[underverse] Copied ${copiedCount} emoji assets successfully.`);
49
+ } catch (err) {
50
+ console.warn(`[underverse] Failed to automatically copy emoji assets: ${err.message}`);
51
+ }
52
+ } else {
53
+ console.log(`[underverse] Could not automatically locate target public/ directory. Please manually copy the 'emojis/' folder from '@underverse-ui/underverse/emojis' to your project's 'public/emojis' directory.`);
54
+ }