nfx-ui 0.30.0 → 0.32.0
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/README.en.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Shared React library for NebulaForgeX (theme, i18n, hooks). **Not** a standalone site. Hosts: Identity, Vault, News, Storages, Documentation.
|
|
6
6
|
|
|
7
|
-
Exports and host wiring: [NFX-Documentation chapter 7](https://github.com/NebulaForgeX/NFX-Documentation/blob/main/books/en/chapter-07-nfx-ui.md). Current **0.
|
|
7
|
+
Exports and host wiring: [NFX-Documentation chapter 7](https://github.com/NebulaForgeX/NFX-Documentation/blob/main/books/en/chapter-07-nfx-ui.md). Current **0.32.0**; hosts pin exactly `"nfx-ui": "0.32.0"`. No `file:` dual path.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
NebulaForgeX 共享 React 库(主题、i18n、hooks)。**不是**独立站点。宿主:Identity、Vault、News、Storages、Documentation。
|
|
6
6
|
|
|
7
|
-
接入与真实导出:[NFX-Documentation 第七章](https://github.com/NebulaForgeX/NFX-Documentation/blob/main/books/zh/chapter-07-nfx-ui.md)。当前 **0.
|
|
7
|
+
接入与真实导出:[NFX-Documentation 第七章](https://github.com/NebulaForgeX/NFX-Documentation/blob/main/books/zh/chapter-07-nfx-ui.md)。当前 **0.32.0**,宿主精确钉 `"nfx-ui": "0.32.0"`。不要 `file:` 双路径。
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../../src/utils/domain/images.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AAExD,eAAO,MAAM,aAAa,GAAI,SAAS,OAAO,CAAC,MAAM,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../../src/utils/domain/images.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AAExD,eAAO,MAAM,aAAa,GAAI,SAAS,OAAO,CAAC,MAAM,CAAC,KAAG,MAMxD,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAE1E;AAED,eAAO,MAAM,gBAAgB,GAAI,SAAS,OAAO,CAAC,MAAM,CAAC,KAAG,MAAsD,CAAC;AA2CnH,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAK7D"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { API_ENDPOINTS as e, URL_PATHS as t } from "../../apis/ip.js";
|
|
2
2
|
//#region src/utils/domain/images.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
return e ?
|
|
3
|
+
var n = "/default-avatar.png", r = (n) => n ? n.startsWith("http://") || n.startsWith("https://") ? n : `${e.IDENTITY}${t.ASSET.Images.fileById(n)}` : "";
|
|
4
|
+
function i(e) {
|
|
5
|
+
return e ? r(e) : n;
|
|
6
6
|
}
|
|
7
|
-
var
|
|
8
|
-
async function
|
|
7
|
+
var a = (e) => r(e) || "/default-avatar.png";
|
|
8
|
+
async function o(e, t = 800) {
|
|
9
9
|
return new Promise((n, r) => {
|
|
10
10
|
let i = document.createElement("canvas"), a = i.getContext("2d"), o = new Image();
|
|
11
11
|
o.onload = () => {
|
|
@@ -18,11 +18,11 @@ async function a(e, t = 800) {
|
|
|
18
18
|
}, o.src = URL.createObjectURL(e);
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
async function
|
|
22
|
-
let t = await
|
|
21
|
+
async function s(e) {
|
|
22
|
+
let t = await o(e, 800);
|
|
23
23
|
return new File([t], `avatar_${Date.now()}.png`, { type: "image/png" });
|
|
24
24
|
}
|
|
25
25
|
//#endregion
|
|
26
|
-
export {
|
|
26
|
+
export { n as DEFAULT_AVATAR_SRC, i as buildAvatarImageSrc, r as buildImageUrl, s as compressImage, a as resolveAvatarSrc };
|
|
27
27
|
|
|
28
28
|
//# sourceMappingURL=images.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"images.js","names":[],"sources":["../../../src/utils/domain/images.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"images.js","names":[],"sources":["../../../src/utils/domain/images.ts"],"sourcesContent":["import { API_ENDPOINTS, URL_PATHS } from \"../../apis/ip\";\n\nexport const DEFAULT_AVATAR_SRC = \"/default-avatar.png\";\n\nexport const buildImageUrl = (imageId: Nilable<string>): string => {\n if (!imageId) return \"\";\n if (imageId.startsWith(\"http://\") || imageId.startsWith(\"https://\")) {\n return imageId;\n }\n return `${API_ENDPOINTS.IDENTITY}${URL_PATHS.ASSET.Images.fileById(imageId)}`;\n};\n\nexport function buildAvatarImageSrc(avatarImageId: Nilable<string>): string {\n return avatarImageId ? buildImageUrl(avatarImageId) : DEFAULT_AVATAR_SRC;\n}\n\nexport const resolveAvatarSrc = (imageId: Nilable<string>): string => buildImageUrl(imageId) || DEFAULT_AVATAR_SRC;\n\nasync function compressImageBlob(file: File, maxSize: number = 800): Promise<Blob> {\n return new Promise((resolve, reject) => {\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n const img = new Image();\n\n img.onload = () => {\n let { width, height } = img;\n\n if (width > height) {\n if (width > maxSize) {\n height = (height * maxSize) / width;\n width = maxSize;\n }\n } else if (height > maxSize) {\n width = (width * maxSize) / height;\n height = maxSize;\n }\n\n canvas.width = width;\n canvas.height = height;\n ctx?.drawImage(img, 0, 0, width, height);\n\n canvas.toBlob(\n (blob) => {\n if (blob) resolve(blob);\n else reject(new Error(\"Failed to compress image\"));\n },\n \"image/png\",\n 0.9,\n );\n };\n\n img.onerror = () => {\n reject(new Error(\"Failed to load image\"));\n };\n\n img.src = URL.createObjectURL(file);\n });\n}\n\nexport async function compressImage(file: File): Promise<File> {\n const compressedBlob = await compressImageBlob(file, 800);\n return new File([compressedBlob], `avatar_${Date.now()}.png`, {\n type: \"image/png\",\n });\n}\n"],"mappings":";;AAEA,IAAa,IAAqB,uBAErB,KAAiB,MACvB,IACD,EAAQ,WAAW,SAAS,KAAK,EAAQ,WAAW,UAAU,IACzD,IAEF,GAAG,EAAc,WAAW,EAAU,MAAM,OAAO,SAAS,CAAO,MAJrD;AAOvB,SAAgB,EAAoB,GAAwC;CAC1E,OAAO,IAAgB,EAAc,CAAa,IAAI;AACxD;AAEA,IAAa,KAAoB,MAAqC,EAAc,CAAO,KAAA;AAE3F,eAAe,EAAkB,GAAY,IAAkB,KAAoB;CACjF,OAAO,IAAI,SAAS,GAAS,MAAW;EACtC,IAAM,IAAS,SAAS,cAAc,QAAQ,GACxC,IAAM,EAAO,WAAW,IAAI,GAC5B,IAAM,IAAI,MAAM;EAiCtB,AA/BA,EAAI,eAAe;GACjB,IAAI,EAAE,UAAO,cAAW;GAgBxB,AAdI,IAAQ,IACN,IAAQ,MACV,IAAU,IAAS,IAAW,GAC9B,IAAQ,KAED,IAAS,MAClB,IAAS,IAAQ,IAAW,GAC5B,IAAS,IAGX,EAAO,QAAQ,GACf,EAAO,SAAS,GAChB,GAAK,UAAU,GAAK,GAAG,GAAG,GAAO,CAAM,GAEvC,EAAO,QACJ,MAAS;IACR,AAAI,IAAM,EAAQ,CAAI,IACjB,EAAO,gBAAI,MAAM,0BAA0B,CAAC;GACnD,GACA,aACA,EACF;EACF,GAEA,EAAI,gBAAgB;GAClB,EAAO,gBAAI,MAAM,sBAAsB,CAAC;EAC1C,GAEA,EAAI,MAAM,IAAI,gBAAgB,CAAI;CACpC,CAAC;AACH;AAEA,eAAsB,EAAc,GAA2B;CAC7D,IAAM,IAAiB,MAAM,EAAkB,GAAM,GAAG;CACxD,OAAO,IAAI,KAAK,CAAC,CAAc,GAAG,UAAU,KAAK,IAAI,EAAE,OAAO,EAC5D,MAAM,YACR,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { API_ENDPOINTS, URL_PATHS } from "../../apis/ip";
|
|
2
2
|
|
|
3
3
|
export const DEFAULT_AVATAR_SRC = "/default-avatar.png";
|
|
4
4
|
|
|
@@ -7,8 +7,7 @@ export const buildImageUrl = (imageId: Nilable<string>): string => {
|
|
|
7
7
|
if (imageId.startsWith("http://") || imageId.startsWith("https://")) {
|
|
8
8
|
return imageId;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
return `${apiBase}/asset/images/${imageId}/file`;
|
|
10
|
+
return `${API_ENDPOINTS.IDENTITY}${URL_PATHS.ASSET.Images.fileById(imageId)}`;
|
|
12
11
|
};
|
|
13
12
|
|
|
14
13
|
export function buildAvatarImageSrc(avatarImageId: Nilable<string>): string {
|