roamwright 0.61.15 → 0.61.17
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 +25 -24
- package/examples/effects.js +19 -13
- package/examples/island.js +21 -14
- package/examples/ruins.js +3 -2
- package/examples/stage.js +0 -6
- package/examples/world-map.html +162 -0
- package/examples/world-map.js +475 -0
- package/index.js +67 -0
- package/package.json +1 -1
- package/rendering/map-glyphs.js +494 -0
- package/rendering/map-input.js +143 -0
- package/rendering/map-labels.js +181 -0
- package/rendering/map-relief.js +330 -0
- package/rendering/map-signs.js +124 -0
- package/rendering/place-names.js +408 -0
- package/rendering/portrait-studio.js +213 -0
- package/rendering/scatter-instances.js +12 -0
- package/rendering/screen-pick.js +75 -0
- package/runtime/build-freshness.js +133 -0
- package/runtime/compass-strip.js +232 -0
- package/runtime/context-lost.js +108 -0
- package/runtime/doorways.js +98 -0
- package/runtime/hud-frame.js +74 -0
- package/runtime/map-relief.js +236 -0
- package/runtime/map-spot.js +120 -0
- package/runtime/map-view.js +229 -0
- package/runtime/panel-shell.js +90 -0
- package/runtime/relation-graph.js +163 -0
- package/runtime/stage-frame.js +263 -0
- package/runtime/url-router.js +162 -0
- package/runtime/way-back.js +71 -0
- package/runtime/whereabouts.js +210 -0
- package/runtime/world-controls.js +265 -0
- package/tools/beasts-near.cjs +17 -0
- package/tools/beasts-near.test.cjs +36 -1
- package/tools/viewport-check.cjs +56 -21
package/tools/viewport-check.cjs
CHANGED
|
@@ -20,6 +20,11 @@ const assert = require('node:assert/strict');
|
|
|
20
20
|
* @param {string} [options.fullscreenButtonSelector='#b-full'] Selector for the fullscreen toggle button.
|
|
21
21
|
* @param {string} [options.turnedClass='turned'] Body class used for rotated phone landscape layout.
|
|
22
22
|
* @param {string} [options.touchNonPhoneSelector='body.touch:not(.phone)'] Selector patched to simulate stale tablet CSS width.
|
|
23
|
+
* @param {{ output?: number, scene?: number }} [options.phoneScale={ output: 1, scene: 1 }] The share of each side the
|
|
24
|
+
* phone's Medium preset draws at: the output of its render limit, and the scene texture of the output (each within a
|
|
25
|
+
* pixel of rounding).
|
|
26
|
+
* @param {{ width: number, height: number }} [options.phoneLimit={ width: 1920, height: 1080 }] The most pixels the phone's
|
|
27
|
+
* output is drawn at, before `phoneScale`; a device with more is fitted into it.
|
|
23
28
|
* @returns {Promise<void>}
|
|
24
29
|
*/
|
|
25
30
|
async function runViewportCheck(
|
|
@@ -33,6 +38,8 @@ async function runViewportCheck(
|
|
|
33
38
|
fullscreenButtonSelector = '#b-full',
|
|
34
39
|
turnedClass = 'turned',
|
|
35
40
|
touchNonPhoneSelector = 'body.touch:not(.phone)',
|
|
41
|
+
phoneScale = {},
|
|
42
|
+
phoneLimit = { width: 1920, height: 1080 },
|
|
36
43
|
} = {},
|
|
37
44
|
) {
|
|
38
45
|
const { BASE, GPU, chromium, shell, debug, enter, applyStorage, routeUrl } = driver;
|
|
@@ -135,35 +142,63 @@ async function runViewportCheck(
|
|
|
135
142
|
await picture(1920, 1080);
|
|
136
143
|
await page.close();
|
|
137
144
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
// Checks the output is `width` x `height` (or, given a `scale` `{ output, scene }`, the device's pixels of that size fitted
|
|
146
|
+
// into the phone's limit drawn at `scale.output` of each side) and the scene texture `scale.scene` of the output.
|
|
147
|
+
async function checkTouchViewport(tab, width, height, scale = null) {
|
|
148
|
+
const fit = scale
|
|
149
|
+
? Math.min(1, (phoneLimit.width * (scale.output ?? 1)) / width, (phoneLimit.height * (scale.output ?? 1)) / height)
|
|
150
|
+
: 1;
|
|
151
|
+
const outW = Math.floor(width * fit);
|
|
152
|
+
const outH = Math.floor(height * fit);
|
|
153
|
+
const sceneW = Math.round(outW * (scale?.scene ?? 1));
|
|
154
|
+
const sceneH = Math.round(outH * (scale?.scene ?? 1));
|
|
155
|
+
await tab
|
|
156
|
+
.waitForFunction(
|
|
157
|
+
([d, w, h, sw, sh]) => {
|
|
158
|
+
const { renderer, post } = window[d];
|
|
159
|
+
const gl = renderer.getContext();
|
|
160
|
+
const bounds = renderer.domElement.getBoundingClientRect();
|
|
161
|
+
const near = (a, b) => Math.abs(a - b) <= 1;
|
|
162
|
+
return (
|
|
163
|
+
near(gl.drawingBufferWidth, w) &&
|
|
164
|
+
near(gl.drawingBufferHeight, h) &&
|
|
165
|
+
near(post.sceneRT.width, sw) &&
|
|
166
|
+
near(post.sceneRT.height, sh) &&
|
|
167
|
+
Math.abs(bounds.width - innerWidth) < 1 &&
|
|
168
|
+
Math.abs(bounds.height - innerHeight) < 1
|
|
169
|
+
);
|
|
170
|
+
},
|
|
171
|
+
[debug, outW, outH, sceneW, sceneH],
|
|
172
|
+
{ timeout: 12000 },
|
|
173
|
+
)
|
|
174
|
+
.catch(async error => {
|
|
175
|
+
console.error(
|
|
176
|
+
await tab.evaluate(d => {
|
|
177
|
+
const { renderer, post } = window[d];
|
|
178
|
+
const gl = renderer.getContext();
|
|
179
|
+
const bounds = renderer.domElement.getBoundingClientRect();
|
|
180
|
+
return {
|
|
181
|
+
buffer: [gl.drawingBufferWidth, gl.drawingBufferHeight],
|
|
182
|
+
scene: [post.sceneRT.width, post.sceneRT.height],
|
|
183
|
+
bounds: [bounds.width, bounds.height],
|
|
184
|
+
viewport: [innerWidth, innerHeight],
|
|
185
|
+
ratio: renderer.getPixelRatio(),
|
|
186
|
+
};
|
|
187
|
+
}, debug),
|
|
151
188
|
);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
);
|
|
156
|
-
console.log(width + ' x ' + height + ' scene and output filling the touch viewport');
|
|
189
|
+
throw error;
|
|
190
|
+
});
|
|
191
|
+
console.log(`${outW} x ${outH} output and ${sceneW} x ${sceneH} scene filling the touch viewport`);
|
|
157
192
|
}
|
|
158
193
|
|
|
159
194
|
const phone = await browser.newPage({ viewport: { width: 430, height: 932 }, deviceScaleFactor: 3, hasTouch: true, isMobile: true });
|
|
160
195
|
await applyStorage(phone, { quality: 'medium' });
|
|
161
196
|
await enter(phone, pageUrl, { waitUntil: 'load', direct: true });
|
|
162
|
-
await checkTouchViewport(phone,
|
|
197
|
+
await checkTouchViewport(phone, 2796, 1290, phoneScale); // 932 x 430 at 3x, turned
|
|
163
198
|
await phone.setViewportSize({ width: 742, height: 430 });
|
|
164
|
-
await checkTouchViewport(phone,
|
|
199
|
+
await checkTouchViewport(phone, 2226, 1290, phoneScale);
|
|
165
200
|
await phone.setViewportSize({ width: 600, height: 300 });
|
|
166
|
-
await checkTouchViewport(phone, 1800, 900);
|
|
201
|
+
await checkTouchViewport(phone, 1800, 900, phoneScale);
|
|
167
202
|
await phone.close();
|
|
168
203
|
|
|
169
204
|
const tablet = await browser.newPage({
|