@eum-agent/personalization 1.1.0 → 1.2.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/dist/index.js +5 -141
- package/package.json +2 -2
- package/ui/ui.js +1033 -217
package/dist/index.js
CHANGED
|
@@ -1,151 +1,15 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
1
2
|
import { existsSync } from "node:fs";
|
|
2
3
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
//#region ui-src/fonts/manifest.json
|
|
5
|
-
var manifest_default = [
|
|
6
|
-
{
|
|
7
|
-
"id": "wenkai",
|
|
8
|
-
"file": "wenkai.ttf",
|
|
9
|
-
"revision": "v1.522",
|
|
10
|
-
"source": "https://github.com/lxgw/LxgwWenKai-Screen/releases/download/v1.522/LXGWWenKaiScreen.ttf",
|
|
11
|
-
"license": "wenkai-LICENSE.txt",
|
|
12
|
-
"weight": "400",
|
|
13
|
-
"bytes": 25673994,
|
|
14
|
-
"sha256": "cd1a6fa39c4ea42fd8f4e289945789b0e510cf7016435640f8893cdad9b220f3"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"id": "source-han-serif",
|
|
18
|
-
"file": "source-han-serif.otf",
|
|
19
|
-
"revision": "7889f11bf31170b5d092a083b357c8c8130f89e0",
|
|
20
|
-
"source": "https://raw.githubusercontent.com/adobe-fonts/source-han-serif/7889f11bf31170b5d092a083b357c8c8130f89e0/SubsetOTF/CN/SourceHanSerifCN-Regular.otf",
|
|
21
|
-
"license": "source-han-serif-LICENSE.txt",
|
|
22
|
-
"weight": "400",
|
|
23
|
-
"bytes": 11626108,
|
|
24
|
-
"sha256": "3754ea669c530e2473354f8f6d9f79680a44d7e26ec7d00eeabee4a7e0753c5d"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"id": "source-han-sans",
|
|
28
|
-
"file": "source-han-sans.otf",
|
|
29
|
-
"revision": "6c709ca72d3d7c46ab42ebecc1a26e7d69595a37",
|
|
30
|
-
"source": "https://raw.githubusercontent.com/adobe-fonts/source-han-sans/6c709ca72d3d7c46ab42ebecc1a26e7d69595a37/SubsetOTF/CN/SourceHanSansCN-Regular.otf",
|
|
31
|
-
"license": "source-han-sans-LICENSE.txt",
|
|
32
|
-
"weight": "400",
|
|
33
|
-
"bytes": 8429224,
|
|
34
|
-
"sha256": "e2bc8a2e7f37474b774fff8db758681ece40bb6947a90d571bce9dd60671a8e4"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"id": "source-serif",
|
|
38
|
-
"file": "source-serif.woff2",
|
|
39
|
-
"revision": "2823e993c53fca27c5c8749f529b56a5a7c77b6b",
|
|
40
|
-
"source": "https://raw.githubusercontent.com/adobe-fonts/source-serif/2823e993c53fca27c5c8749f529b56a5a7c77b6b/WOFF2/VAR/SourceSerif4Variable-Roman.otf.woff2",
|
|
41
|
-
"license": "source-serif-LICENSE.txt",
|
|
42
|
-
"weight": "200 900",
|
|
43
|
-
"bytes": 426716,
|
|
44
|
-
"sha256": "f146ee102dddcc5bc7a2cf4af5bcf129832195941b92bd0a512626f390688c1e"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"id": "source-sans",
|
|
48
|
-
"file": "source-sans.woff2",
|
|
49
|
-
"revision": "ed1808970eb3c7301c9a523bee26473ba0bb62fa",
|
|
50
|
-
"source": "https://raw.githubusercontent.com/adobe-fonts/source-sans/ed1808970eb3c7301c9a523bee26473ba0bb62fa/WOFF2/OTF/SourceSans3-Regular.otf.woff2",
|
|
51
|
-
"license": "source-sans-LICENSE.txt",
|
|
52
|
-
"weight": "400",
|
|
53
|
-
"bytes": 153800,
|
|
54
|
-
"sha256": "63de0da0cc05298e2e9c6e5cef506d8454ca665f6e668a99d94f51174b9256ed"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"id": "atkinson",
|
|
58
|
-
"file": "atkinson.woff2",
|
|
59
|
-
"revision": "7925f50f649b3813257faf2f4c0b381011f434f1",
|
|
60
|
-
"source": "https://raw.githubusercontent.com/googlefonts/atkinson-hyperlegible-next/7925f50f649b3813257faf2f4c0b381011f434f1/fonts/webfonts/AtkinsonHyperlegibleNext%5Bwght%5D.woff2",
|
|
61
|
-
"license": "atkinson-LICENSE.txt",
|
|
62
|
-
"weight": "200 800",
|
|
63
|
-
"bytes": 48188,
|
|
64
|
-
"sha256": "abde1ad5cf78b9ac575ef90d991f2e9101eb0b3b6668bde9a00e2e1e27d99afd"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"id": "literata",
|
|
68
|
-
"file": "literata.woff2",
|
|
69
|
-
"revision": "0c2761b727a1b3a7cffd313c37f0f5163dfc7a63",
|
|
70
|
-
"source": "https://raw.githubusercontent.com/googlefonts/literata/0c2761b727a1b3a7cffd313c37f0f5163dfc7a63/fonts/webfonts/Literata%5Bopsz%2Cwght%5D.woff2",
|
|
71
|
-
"license": "literata-LICENSE.txt",
|
|
72
|
-
"weight": "200 900",
|
|
73
|
-
"bytes": 396224,
|
|
74
|
-
"sha256": "5e50643479bee69e0204164602f830502b0db42bbc29da83edc9980df17e34df"
|
|
75
|
-
}
|
|
76
|
-
];
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/font-resource.ts
|
|
79
|
-
/** Serves bounded packaged font bytes through the current owner's authenticated resource lease. */
|
|
80
|
-
function createFontResource(reader, assets, directory) {
|
|
81
|
-
return {
|
|
82
|
-
name: "fontBytes",
|
|
83
|
-
methods: ["GET", "HEAD"],
|
|
84
|
-
params: z.object({ id: z.string().max(64) }).strict(),
|
|
85
|
-
result: z.null(),
|
|
86
|
-
metadata: z.undefined(),
|
|
87
|
-
async handle({ id }, call) {
|
|
88
|
-
const asset = assets.find((asset) => asset.id === id);
|
|
89
|
-
if (!asset) throw new Error("Unknown reading font");
|
|
90
|
-
call.signal.throwIfAborted();
|
|
91
|
-
const handle = await reader.open(fileURLToPath(new URL(asset.file, directory)), call.signal);
|
|
92
|
-
let closing;
|
|
93
|
-
const close = () => closing ??= (async () => {
|
|
94
|
-
await handle.close();
|
|
95
|
-
await handle.finished;
|
|
96
|
-
})();
|
|
97
|
-
try {
|
|
98
|
-
if (handle.size !== asset.bytes) throw new Error("Packaged font size changed");
|
|
99
|
-
const bytes = {
|
|
100
|
-
contentType: asset.file.endsWith(".woff2") ? "font/woff2" : asset.file.endsWith(".otf") ? "font/otf" : "font/ttf",
|
|
101
|
-
contentLength: asset.bytes,
|
|
102
|
-
contentDisposition: {
|
|
103
|
-
filename: asset.file,
|
|
104
|
-
disposition: "inline"
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
if (call.method === "HEAD") {
|
|
108
|
-
await close();
|
|
109
|
-
return {
|
|
110
|
-
kind: "head",
|
|
111
|
-
bytes
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
kind: "bytes",
|
|
116
|
-
bytes,
|
|
117
|
-
close,
|
|
118
|
-
body: (async function* () {
|
|
119
|
-
try {
|
|
120
|
-
for (let offset = 0; offset < asset.bytes;) {
|
|
121
|
-
call.signal.throwIfAborted();
|
|
122
|
-
const chunk = await handle.readRange(offset, Math.min(262144, asset.bytes - offset), call.signal);
|
|
123
|
-
if (!chunk.length || chunk.length > asset.bytes - offset) throw new Error("Invalid font read length");
|
|
124
|
-
offset += chunk.length;
|
|
125
|
-
yield chunk;
|
|
126
|
-
}
|
|
127
|
-
} finally {
|
|
128
|
-
await close();
|
|
129
|
-
}
|
|
130
|
-
})()
|
|
131
|
-
};
|
|
132
|
-
} catch (error) {
|
|
133
|
-
await close();
|
|
134
|
-
throw error;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
4
|
//#region src/index.ts
|
|
141
|
-
/** Owns this optional client feature and its browser activation. */
|
|
142
5
|
const plugin = {
|
|
143
6
|
name: "@eum-agent/personalization",
|
|
144
|
-
requires: ["host-file-reader"],
|
|
145
7
|
apply(ctx) {
|
|
146
|
-
ctx.client.registerResource(createFontResource(ctx.services.get("host-file-reader"), manifest_default, new URL("../ui/fonts/", import.meta.url)));
|
|
147
8
|
const module = fileURLToPath(new URL("../ui/ui.js", import.meta.url));
|
|
148
|
-
if (existsSync(module)) ctx.client.
|
|
9
|
+
if (existsSync(module)) ctx.client.registerPackageFiles({
|
|
10
|
+
root: dirname(module),
|
|
11
|
+
entry: "ui.js"
|
|
12
|
+
});
|
|
149
13
|
}
|
|
150
14
|
};
|
|
151
15
|
//#endregion
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"en-US": "Personalization",
|
|
5
5
|
"zh-CN": "个性化"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.2.0",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"description": "Theme, typography and interface preferences",
|
|
10
10
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"i18next": "^26.4.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@eum-agent/plugin": "1.
|
|
25
|
+
"@eum-agent/plugin": "1.2.0",
|
|
26
26
|
"@types/react": "^19.2.18",
|
|
27
27
|
"@types/react-dom": "^19.2.5",
|
|
28
28
|
"react": "^19.2.0",
|