@wovoon/polaris 0.4.0 → 0.4.2
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.md +13 -0
- package/dist/client.js +14 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -26,5 +26,18 @@ room.send({ text: "你好" });
|
|
|
26
26
|
|
|
27
27
|
零构建页面可直接用平台同源下发的全局版:`<script src="/api/cloud/sdk.js"></script>` → `WovoonCloud.*`。
|
|
28
28
|
|
|
29
|
+
## 资源打包最佳实践(大游戏必读)
|
|
30
|
+
|
|
31
|
+
SDK 只负责云能力;**游戏资源的加载速度取决于打包方式**。两条硬规则:
|
|
32
|
+
|
|
33
|
+
- `.wasm`/`.pck`/`.bundle` 等二进制**直接发原始文件**——平台托管有正确 MIME
|
|
34
|
+
(`application/wasm`)、Range 分段与 CDN Brotli。**不要**用导出工具的 base64-JS 分片
|
|
35
|
+
(`xxx.000.js` 串):体积膨胀 33% 且只能串行解码,加载时间成倍增加。
|
|
36
|
+
- 加载用 `Promise.all` 并行 fetch + `WebAssembly.instantiateStreaming` 流式编译;
|
|
37
|
+
首包(引擎+开场)控制在 3MB 内,其余按场景分包按需下载。
|
|
38
|
+
|
|
39
|
+
完整配方(含 Godot/TapTap 导出还原步骤):`docs/recipes/web-asset-optimization.md`。
|
|
40
|
+
`wovoon validate` 与平台发布扫描会对以上反模式给出同文案 WARN。
|
|
41
|
+
|
|
29
42
|
- 协议正典与完整能力说明见仓库 [PROTOCOL.md](https://gitea/wujiwanjie/wovoon-polaris-sdk) 与 [llms.txt](./llms.txt)
|
|
30
43
|
- 本地开发与校验:`npx @wovoon/cli init / dev / validate`
|
package/dist/client.js
CHANGED
|
@@ -49,6 +49,20 @@ export class PolarisClient {
|
|
|
49
49
|
detectTarget() {
|
|
50
50
|
if (this.target)
|
|
51
51
|
return this.target;
|
|
52
|
+
const UUID = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
|
|
53
|
+
if (typeof location !== "undefined") {
|
|
54
|
+
// 隔离运行域:主机名首标签 static[-vN]-{deploymentId}(生产拓扑 pathname 是 /,路径正则提取不到)。
|
|
55
|
+
const firstLabel = String(location.hostname || "").split(".")[0] ?? "";
|
|
56
|
+
if (/^static-/.test(firstLabel)) {
|
|
57
|
+
const hostMatch = new RegExp(`-(${UUID})$`, "i").exec(firstLabel);
|
|
58
|
+
if (hostMatch)
|
|
59
|
+
return hostMatch[1];
|
|
60
|
+
}
|
|
61
|
+
// 平台启动片段:run-session 对所有拓扑统一注入 wovoon_app_id。
|
|
62
|
+
const hashMatch = new RegExp(`[?&#]wovoon_app_id=(${UUID})(?:&|$)`, "i").exec(String(location.hash || ""));
|
|
63
|
+
if (hashMatch)
|
|
64
|
+
return hashMatch[1];
|
|
65
|
+
}
|
|
52
66
|
const match = /\/api\/public\/static\/([0-9a-fA-F-]{36})/.exec(typeof location === "undefined" ? "" : location.pathname);
|
|
53
67
|
return match ? match[1] : "";
|
|
54
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wovoon/polaris",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "wovoon Polaris SDK——wovoon 大后台云能力客户端(身份/数据集合/云函数/房间实时),协议 1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,4 +34,4 @@
|
|
|
34
34
|
"access": "public",
|
|
35
35
|
"registry": "https://registry.npmjs.org/"
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|