@n-uf/placement 26.11.19 → 26.11.20
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/CHANGELOG.md +18 -0
- package/README.md +27 -6
- package/dist/{chunk-NCHRKLT3.js → chunk-GCSVZGVX.js} +14 -14
- package/dist/chunk-GCSVZGVX.js.map +1 -0
- package/dist/{model-irGEua8T.d.ts → model-DU7MovDa.d.ts} +1 -1
- package/dist/scene-cases.d.ts +35 -3
- package/dist/scene-cases.js +74 -35
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +3 -3
- package/dist/scene.js +1 -1
- package/dist/stack.d.ts +2 -2
- package/dist/{targets-50bCVu3K.d.ts → targets-CYJN0Hba.d.ts} +7 -5
- package/package.json +1 -1
- package/dist/chunk-NCHRKLT3.js.map +0 -1
package/dist/scene-cases.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
storeScene,
|
|
14
14
|
targets,
|
|
15
15
|
use
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-GCSVZGVX.js";
|
|
17
17
|
import "./chunk-RUITEOZ7.js";
|
|
18
18
|
import {
|
|
19
19
|
rect
|
|
@@ -1877,7 +1877,8 @@ var gestureWords = (g2, i) => {
|
|
|
1877
1877
|
const bits = [g2.item, g2.place ? JSON.stringify(g2.place) : void 0, g2.point ? `${px(g2.point.x)},${px(g2.point.y)}` : void 0, g2.key, g2.edge, g2.size !== void 0 ? String(g2.size) : void 0].filter((x) => x !== void 0);
|
|
1878
1878
|
return `gesture ${i + 1} (${g2.type}${bits.length ? ` ${bits.join(" ")}` : ""})`;
|
|
1879
1879
|
};
|
|
1880
|
-
|
|
1880
|
+
var words = (e) => e instanceof Error ? e.message : String(e);
|
|
1881
|
+
function* steps(row2, host) {
|
|
1881
1882
|
const failures = [];
|
|
1882
1883
|
const skipped = [];
|
|
1883
1884
|
const n = row2.gestures.length;
|
|
@@ -1898,83 +1899,119 @@ function runCase(row2, host) {
|
|
|
1898
1899
|
}
|
|
1899
1900
|
range("the stops check", row2.expectStops?.at);
|
|
1900
1901
|
if (failures.length > 0) return { ok: false, failures, skipped };
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1902
|
+
function* must(f2) {
|
|
1903
|
+
const r = yield f2;
|
|
1904
|
+
if (!r.ok) throw r.error;
|
|
1905
|
+
return r.value;
|
|
1906
|
+
}
|
|
1907
|
+
function* layoutOf(when) {
|
|
1908
|
+
const r = yield () => host.layout();
|
|
1909
|
+
if (r.ok) return r.value;
|
|
1910
|
+
fail([`the host couldn't give its layout: ${words(r.error)}`], when);
|
|
1911
|
+
return null;
|
|
1912
|
+
}
|
|
1913
|
+
function* dom(index) {
|
|
1910
1914
|
for (const c of row2.expectDom ?? []) {
|
|
1911
1915
|
if ((c.at ?? last) !== index) continue;
|
|
1912
1916
|
const check = aimed(c);
|
|
1913
|
-
const root = host.root ? host.root() : null;
|
|
1917
|
+
const root = host.root ? yield* must(() => host.root()) : null;
|
|
1914
1918
|
if (!root) {
|
|
1915
1919
|
skipped.push(labelOf(check));
|
|
1916
1920
|
continue;
|
|
1917
1921
|
}
|
|
1918
1922
|
fail(domIssues(check, root), ` after gesture ${index + 1} (${labelOf(check)})`);
|
|
1919
1923
|
}
|
|
1920
|
-
}
|
|
1921
|
-
|
|
1924
|
+
}
|
|
1925
|
+
function* stops2(index) {
|
|
1922
1926
|
const s = row2.expectStops;
|
|
1923
1927
|
if (!s || (s.at ?? last) !== index) return;
|
|
1924
1928
|
if (!host.stops) {
|
|
1925
1929
|
skipped.push(`the stops of ${s.item}`);
|
|
1926
1930
|
return;
|
|
1927
1931
|
}
|
|
1928
|
-
const have = host.stops(s.item).map(placeKey);
|
|
1932
|
+
const have = (yield* must(() => host.stops(s.item))).map(placeKey);
|
|
1929
1933
|
const want = s.places.map(placeKey);
|
|
1930
1934
|
if (have.join("\n") !== want.join("\n")) fail([`${s.item}'s stops are
|
|
1931
1935
|
${have.join("\n ")}
|
|
1932
1936
|
expected
|
|
1933
1937
|
${want.join("\n ")}`], "");
|
|
1934
|
-
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
fail([`the host couldn't load the scene: ${e instanceof Error ? e.message : String(e)}`], "");
|
|
1938
|
+
}
|
|
1939
|
+
const loaded = yield () => host.load(row2.scene, row2.settings);
|
|
1940
|
+
if (!loaded.ok) {
|
|
1941
|
+
fail([`the host couldn't load the scene: ${words(loaded.error)}`], "");
|
|
1939
1942
|
return { ok: false, failures, skipped };
|
|
1940
1943
|
}
|
|
1941
1944
|
for (let i = 0; i < n; i++) {
|
|
1942
1945
|
const g2 = row2.gestures[i];
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
fail([`${gestureWords(g2, i)} failed: ${e instanceof Error ? e.message : String(e)}`], "");
|
|
1946
|
+
const done = yield () => host.perform(g2);
|
|
1947
|
+
if (!done.ok) {
|
|
1948
|
+
fail([`${gestureWords(g2, i)} failed: ${words(done.error)}`], "");
|
|
1947
1949
|
return { ok: false, failures, skipped };
|
|
1948
1950
|
}
|
|
1949
1951
|
for (const cp of row2.checkpoints ?? []) {
|
|
1950
1952
|
if (cp.at !== i || !cp.layout) continue;
|
|
1951
|
-
const l2 = layoutOf(` after ${gestureWords(g2, i)}`);
|
|
1953
|
+
const l2 = yield* layoutOf(` after ${gestureWords(g2, i)}`);
|
|
1952
1954
|
if (l2) fail(layoutIssues(cp.layout, l2), ` after ${gestureWords(g2, i)}${cp.note ? ` (${cp.note})` : ""}`);
|
|
1953
1955
|
}
|
|
1954
|
-
dom(i);
|
|
1955
|
-
stops2(i);
|
|
1956
|
+
yield* dom(i);
|
|
1957
|
+
yield* stops2(i);
|
|
1956
1958
|
}
|
|
1957
1959
|
if (last < 0) {
|
|
1958
|
-
dom(-1);
|
|
1959
|
-
stops2(-1);
|
|
1960
|
+
yield* dom(-1);
|
|
1961
|
+
yield* stops2(-1);
|
|
1960
1962
|
}
|
|
1961
|
-
const l = layoutOf("");
|
|
1963
|
+
const l = yield* layoutOf("");
|
|
1962
1964
|
if (l) fail(layoutIssues(row2.expectLayout, l), "");
|
|
1963
1965
|
if (row2.expectStored) {
|
|
1964
1966
|
if (!host.stored) skipped.push("the stored form");
|
|
1965
1967
|
else {
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
fail([`the host couldn't give its stored form: ${e instanceof Error ? e.message : String(e)}`], "");
|
|
1970
|
-
}
|
|
1968
|
+
const r = yield () => host.stored();
|
|
1969
|
+
if (r.ok) fail(storedIssues(row2.expectStored, r.value), " (the stored form)");
|
|
1970
|
+
else fail([`the host couldn't give its stored form: ${words(r.error)}`], "");
|
|
1971
1971
|
}
|
|
1972
1972
|
}
|
|
1973
1973
|
return { ok: failures.length === 0, failures, skipped };
|
|
1974
1974
|
}
|
|
1975
|
+
function runCase(row2, host) {
|
|
1976
|
+
const run = steps(row2, host);
|
|
1977
|
+
let r = run.next();
|
|
1978
|
+
while (!r.done) {
|
|
1979
|
+
let out;
|
|
1980
|
+
try {
|
|
1981
|
+
out = { ok: true, value: r.value() };
|
|
1982
|
+
} catch (error) {
|
|
1983
|
+
out = { ok: false, error };
|
|
1984
|
+
}
|
|
1985
|
+
r = run.next(out);
|
|
1986
|
+
}
|
|
1987
|
+
return r.value;
|
|
1988
|
+
}
|
|
1989
|
+
async function runCaseAsync(row2, host) {
|
|
1990
|
+
const run = steps(row2, host);
|
|
1991
|
+
let r = run.next();
|
|
1992
|
+
while (!r.done) {
|
|
1993
|
+
let out;
|
|
1994
|
+
try {
|
|
1995
|
+
out = { ok: true, value: await r.value() };
|
|
1996
|
+
} catch (error) {
|
|
1997
|
+
out = { ok: false, error };
|
|
1998
|
+
}
|
|
1999
|
+
r = run.next(out);
|
|
2000
|
+
}
|
|
2001
|
+
return r.value;
|
|
2002
|
+
}
|
|
1975
2003
|
function runCases(rows, makeHost) {
|
|
1976
2004
|
return rows.map((row2) => ({ id: row2.id, result: runCase(row2, makeHost()) }));
|
|
1977
2005
|
}
|
|
2006
|
+
async function runCasesAsync(rows, makeHost, options = {}) {
|
|
2007
|
+
const out = [];
|
|
2008
|
+
for (const row2 of rows) {
|
|
2009
|
+
const result = await runCaseAsync(row2, await makeHost());
|
|
2010
|
+
options.onResult?.(row2.id, result);
|
|
2011
|
+
out.push({ id: row2.id, result });
|
|
2012
|
+
}
|
|
2013
|
+
return out;
|
|
2014
|
+
}
|
|
1978
2015
|
|
|
1979
2016
|
// src/scene/cases/index.ts
|
|
1980
2017
|
var CASES = [...DOCKING_ROWS, ...BAR_ROWS, ...RULE_ROWS, ...GESTURE_ROWS, ...WINDOW_ROWS];
|
|
@@ -2008,7 +2045,9 @@ export {
|
|
|
2008
2045
|
pickTarget,
|
|
2009
2046
|
resolvePlace,
|
|
2010
2047
|
runCase,
|
|
2048
|
+
runCaseAsync,
|
|
2011
2049
|
runCases,
|
|
2050
|
+
runCasesAsync,
|
|
2012
2051
|
winScene
|
|
2013
2052
|
};
|
|
2014
2053
|
//# sourceMappingURL=scene-cases.js.map
|