@taboo-avalanche/andesite-compiler 1.0.1 → 1.0.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/dist/compile.js +4 -1
- package/package.json +2 -2
- package/src/compile.ts +2 -1
- package/src/rasterize/puppeteer.ts +8 -4
package/dist/compile.js
CHANGED
|
@@ -53,6 +53,8 @@ async function rasterizeAllInBrowser(browser, pageUrl, outputDir, options) {
|
|
|
53
53
|
const kind = await page.$eval("[data-andesite-canvas]", (node) => {
|
|
54
54
|
return node.getAttribute("data-andesite-page-kind") === "hud" ? "hud" : "menu";
|
|
55
55
|
});
|
|
56
|
+
const mask = await page.$eval("[data-andesite-canvas]", (node) => node.getAttribute("data-andesite-mask"));
|
|
57
|
+
await page.$$eval("[data-andesite-screen-touch-mask]", (nodes) => nodes.forEach((node) => node.style.display = "none"));
|
|
56
58
|
const pageBox = await page.$eval("[data-andesite-content-root]", (node) => {
|
|
57
59
|
const rect = node.getBoundingClientRect();
|
|
58
60
|
return { width: Math.round(rect.width), height: Math.round(rect.height) };
|
|
@@ -167,7 +169,7 @@ async function rasterizeAllInBrowser(browser, pageUrl, outputDir, options) {
|
|
|
167
169
|
}
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
|
-
return { kind, width: pageBox.width, height: pageBox.height, mounts, viewStacks, panels: [...backgroundPanels, ...panels], buttons, labels, inputs, slots, progresses, sprites, scrollViews };
|
|
172
|
+
return { kind, mask, width: pageBox.width, height: pageBox.height, mounts, viewStacks, panels: [...backgroundPanels, ...panels], buttons, labels, inputs, slots, progresses, sprites, scrollViews };
|
|
171
173
|
} finally {
|
|
172
174
|
await page.close();
|
|
173
175
|
}
|
|
@@ -2092,6 +2094,7 @@ async function compilePage(pageUrl, pageId, outputZipPath, options) {
|
|
|
2092
2094
|
width: rasterResult.width,
|
|
2093
2095
|
height: rasterResult.height,
|
|
2094
2096
|
anchor: "center",
|
|
2097
|
+
mask: rasterResult.mask,
|
|
2095
2098
|
...pageControls,
|
|
2096
2099
|
slots: rasterResult.slots,
|
|
2097
2100
|
progresses: rasterResult.progresses,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taboo-avalanche/andesite-compiler",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Rasterize Andesite React pages to Bedrock chest UI zip",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"archiver": "^7.0.1",
|
|
20
20
|
"puppeteer": "^23.0.0",
|
|
21
|
-
"@taboo-avalanche/andesite": "1.0.
|
|
21
|
+
"@taboo-avalanche/andesite": "1.0.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^26.6.2",
|
package/src/compile.ts
CHANGED
|
@@ -89,7 +89,8 @@ export async function compilePage(
|
|
|
89
89
|
// 页面整体尺寸与锚点:anchor=center 时运行时按屏幕把整体包围盒居中,解决左上锚定导致的偏移
|
|
90
90
|
width: rasterResult.width,
|
|
91
91
|
height: rasterResult.height,
|
|
92
|
-
anchor: 'center',
|
|
92
|
+
anchor: 'center',
|
|
93
|
+
mask: rasterResult.mask,
|
|
93
94
|
...pageControls,
|
|
94
95
|
slots: rasterResult.slots,
|
|
95
96
|
progresses: rasterResult.progresses,
|
|
@@ -68,8 +68,9 @@ interface RepeaterCellBox extends DomBox {
|
|
|
68
68
|
index: number
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
export interface AndesiteRasterResult {
|
|
72
|
-
kind: 'menu' | 'hud'
|
|
71
|
+
export interface AndesiteRasterResult {
|
|
72
|
+
kind: 'menu' | 'hud'
|
|
73
|
+
mask: string | null
|
|
73
74
|
// 页面整体包围盒(内容根 px),供运行时居中摆放
|
|
74
75
|
width: number
|
|
75
76
|
height: number
|
|
@@ -143,7 +144,10 @@ export async function rasterizeAllInBrowser(
|
|
|
143
144
|
const kind: AndesiteRasterResult['kind'] = await page.$eval('[data-andesite-canvas]', node => {
|
|
144
145
|
return (node as HTMLElement).getAttribute('data-andesite-page-kind') === 'hud' ? 'hud' : 'menu'
|
|
145
146
|
})
|
|
146
|
-
|
|
147
|
+
const mask = await page.$eval('[data-andesite-canvas]', node => node.getAttribute('data-andesite-mask'))
|
|
148
|
+
// 全屏遮罩由导入器单独创建,采集内容贴图时移除其像素,避免半透明背景重复叠色。
|
|
149
|
+
await page.$$eval('[data-andesite-screen-touch-mask]', nodes => nodes.forEach(node => (node as HTMLElement).style.display = 'none'))
|
|
150
|
+
// 页面整体包围盒:菜单以内容根居中;HUD 控件另按最近 mount 作为局部坐标基准。
|
|
147
151
|
const pageBox = await page.$eval('[data-andesite-content-root]', node => {
|
|
148
152
|
const rect = (node as HTMLElement).getBoundingClientRect()
|
|
149
153
|
return { width: Math.round(rect.width), height: Math.round(rect.height) }
|
|
@@ -286,7 +290,7 @@ export async function rasterizeAllInBrowser(
|
|
|
286
290
|
}
|
|
287
291
|
}
|
|
288
292
|
}
|
|
289
|
-
return { kind, width: pageBox.width, height: pageBox.height, mounts, viewStacks, panels: [...backgroundPanels, ...panels], buttons, labels, inputs, slots, progresses, sprites, scrollViews }
|
|
293
|
+
return { kind, mask, width: pageBox.width, height: pageBox.height, mounts, viewStacks, panels: [...backgroundPanels, ...panels], buttons, labels, inputs, slots, progresses, sprites, scrollViews }
|
|
290
294
|
} finally {
|
|
291
295
|
await page.close()
|
|
292
296
|
}
|