@n-uf/placement 26.11.19 → 26.11.21
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 +56 -0
- package/README.md +69 -15
- package/dist/{chunk-RUITEOZ7.js → chunk-RL3QB5SM.js} +61 -7
- package/dist/chunk-RL3QB5SM.js.map +1 -0
- package/dist/{chunk-NCHRKLT3.js → chunk-TFM4S3L3.js} +127 -18
- package/dist/chunk-TFM4S3L3.js.map +1 -0
- package/dist/{model-irGEua8T.d.ts → model-DPTu2EtG.d.ts} +24 -10
- package/dist/scene-cases.d.ts +35 -3
- package/dist/scene-cases.js +75 -36
- package/dist/scene-cases.js.map +1 -1
- package/dist/scene.d.ts +3 -3
- package/dist/scene.js +4 -2
- package/dist/stack.d.ts +9 -8
- package/dist/stack.js +1 -1
- package/dist/{targets-50bCVu3K.d.ts → targets-DRFuud5d.d.ts} +40 -5
- package/package.json +1 -1
- package/dist/chunk-NCHRKLT3.js.map +0 -1
- package/dist/chunk-RUITEOZ7.js.map +0 -1
|
@@ -269,21 +269,35 @@ interface StackFit {
|
|
|
269
269
|
* only when the stack overflows. `fitStack`'s `previous` reads it to tell room coming back from a change of ages.
|
|
270
270
|
*/
|
|
271
271
|
readonly need?: number;
|
|
272
|
+
/**
|
|
273
|
+
* The give-way history: every step down from the items' starting forms to the forms chosen, in the order taken (items
|
|
274
|
+
* that went into the » menu together share a `batch`). `fitStack`'s `previous` carries it on, and room coming back
|
|
275
|
+
* undoes it from the last step: growing back is exactly the reverse of giving way.
|
|
276
|
+
*/
|
|
277
|
+
readonly steps?: readonly StackStep[];
|
|
278
|
+
}
|
|
279
|
+
/** One give-way step: item `id` went from form `from` to form `to`; steps sharing a `batch` were taken together. */
|
|
280
|
+
interface StackStep {
|
|
281
|
+
readonly id: string;
|
|
282
|
+
readonly from: number;
|
|
283
|
+
readonly to: number;
|
|
284
|
+
readonly batch?: number;
|
|
272
285
|
}
|
|
273
286
|
/** What `fitStack` and `stackTargets` take besides the input. */
|
|
274
287
|
interface FitOptions {
|
|
275
288
|
/**
|
|
276
289
|
* The fit the stack had before. While the forms it chose still fit, they are kept: a change of `used` ages alone (a press
|
|
277
290
|
* on a header) reshapes nothing. Ages decide only who gives way anew (the length shrank, an item was added or opened),
|
|
278
|
-
* and room that came back is used, but growing never re-ranks: the fresh fit is taken
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
291
|
+
* and room that came back is used, but growing never re-ranks: the fresh fit is taken when the stack got wider across;
|
|
292
|
+
* otherwise room comes back by undoing the give-way history (`StackFit.steps`, carried on from fit to fit) from its
|
|
293
|
+
* last step: a batch that went into the » menu together comes out together, an item goes back to the nearest earlier
|
|
294
|
+
* form the stack fits with (the last item out of the menu takes the » entry with it), and the first step that can't
|
|
295
|
+
* be undone stops all growth. Growing back is exactly the reverse of giving way, the menu included: at every length
|
|
296
|
+
* the way back holds what the way down held, whatever presses changed the ages since; an item made `kept` after its
|
|
297
|
+
* step comes back in step order, it doesn't jump ahead. A `previous` without a history
|
|
298
|
+
* (built by hand, or by an older version) grows the old way: a fresh fit that is a pure gain, else the item that gave
|
|
299
|
+
* way most recently (highest rank, then `kept`, the newest used, the earlier in the stack) first, menu items out only
|
|
300
|
+
* while that keeps the order.
|
|
287
301
|
* One px of room moves nothing. Results under `previous` depend on history: a shrink then a grow may end at another
|
|
288
302
|
* arrangement than a fresh solve of the same input, and more room never undoes a growth along successive solves.
|
|
289
303
|
* Growing back is meant for stacks of up to about 50 items (60 small menu items take about 9 ms; the cost grows with
|
|
@@ -298,4 +312,4 @@ interface FitOptions {
|
|
|
298
312
|
readonly previous?: StackFit;
|
|
299
313
|
}
|
|
300
314
|
|
|
301
|
-
export { type CrossLimits as C, DEFAULT_MENU as D, type FitOptions as F, type GroupFormKind as G, type MainSize as M, type PanelFormKind as P, type StackFormKind as S, type WrapSpec as W, type StackForm as a, type
|
|
315
|
+
export { type CrossLimits as C, DEFAULT_MENU as D, type FitOptions as F, type GroupFormKind as G, type MainSize as M, type PanelFormKind as P, type StackFormKind as S, type WrapSpec as W, type StackForm as a, type StackFit as b, type StackNote as c, type StackInput as d, type StackItem as e, DEFAULT_RAIL as f, type PlacedStackItem as g, type StackAxis as h, type StackMenu as i, type StackNoteCode as j, type StackStep as k, formCrossMin as l, formFitsCross as m, formMain as n, formSetsCross as o, wrapCross as p, wrapLines as q, wrapRows as r, withItem as w };
|
package/dist/scene-cases.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as Point, R as Rect } from './geometry-mL-GTRti.js';
|
|
2
|
-
import { S as StackFormKind } from './model-
|
|
3
|
-
import { S as Scene, a as ScenePlace,
|
|
2
|
+
import { S as StackFormKind } from './model-DPTu2EtG.js';
|
|
3
|
+
import { S as Scene, a as ScenePlace, b as SceneLayout, c as StoredScene, Z as Zone, d as Side, e as SceneNoteCode, f as SceneTarget } from './targets-DRFuud5d.js';
|
|
4
4
|
import './target-D3PiLg44.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -224,6 +224,20 @@ interface CaseHost {
|
|
|
224
224
|
/** The places "Move to ›" offers for an item, in order (the library's `stops` places); absent: the stops check is skipped. */
|
|
225
225
|
stops?(item: string): readonly ScenePlace[];
|
|
226
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* A `CaseHost` whose calls may be async (a page a browser runner drives with real pointer events and timers): each of
|
|
229
|
+
* `load`, `perform`, `layout`, `root`, `stored` and `stops` may return a promise. `itemSelector` stays a plain value.
|
|
230
|
+
* `runCaseAsync` awaits every call.
|
|
231
|
+
*/
|
|
232
|
+
interface AsyncCaseHost {
|
|
233
|
+
load(scene: Scene, settings?: CaseSettings): void | Promise<void>;
|
|
234
|
+
perform(gesture: Gesture): void | Promise<void>;
|
|
235
|
+
layout(): SceneLayout | Promise<SceneLayout>;
|
|
236
|
+
root?(): DomRoot | null | Promise<DomRoot | null>;
|
|
237
|
+
itemSelector?(id: string): string;
|
|
238
|
+
stored?(): StoredScene | Promise<StoredScene>;
|
|
239
|
+
stops?(item: string): readonly ScenePlace[] | Promise<readonly ScenePlace[]>;
|
|
240
|
+
}
|
|
227
241
|
interface CaseResult {
|
|
228
242
|
readonly ok: boolean;
|
|
229
243
|
readonly failures: string[];
|
|
@@ -303,11 +317,29 @@ declare function layoutIssues(want: LayoutExpect, layout: SceneLayout): string[]
|
|
|
303
317
|
* `host.stored` the stored checks and with no `host.stops` the stops check; each is listed in `skipped`.
|
|
304
318
|
*/
|
|
305
319
|
declare function runCase(row: CaseRow, host: CaseHost): CaseResult;
|
|
320
|
+
/**
|
|
321
|
+
* `runCase` for a host whose calls may be async (a page driven from a browser runner, with real pointer events and
|
|
322
|
+
* timers): every host call is awaited, in the same order as `runCase` makes them, with the same checks. A rejected call
|
|
323
|
+
* counts as a thrown one: a failed `load`, `perform`, `layout` or `stored` is a failed result, as in `runCase`, while a
|
|
324
|
+
* rejection or throw from `root` or `stops` rejects `runCaseAsync` (as it throws from `runCase`). A sync `CaseHost`
|
|
325
|
+
* works too.
|
|
326
|
+
*/
|
|
327
|
+
declare function runCaseAsync(row: CaseRow, host: AsyncCaseHost | CaseHost): Promise<CaseResult>;
|
|
306
328
|
/** Runs every row on a fresh host each (`makeHost`), and returns each row's result by id. */
|
|
307
329
|
declare function runCases(rows: readonly CaseRow[], makeHost: () => CaseHost): {
|
|
308
330
|
id: string;
|
|
309
331
|
result: CaseResult;
|
|
310
332
|
}[];
|
|
333
|
+
/**
|
|
334
|
+
* `runCases` with `runCaseAsync`: one row after another (a page has one pointer), each on a fresh host (`makeHost` may be
|
|
335
|
+
* async). `options.onResult` hears each row's result as it is known.
|
|
336
|
+
*/
|
|
337
|
+
declare function runCasesAsync(rows: readonly CaseRow[], makeHost: () => AsyncCaseHost | CaseHost | Promise<AsyncCaseHost | CaseHost>, options?: {
|
|
338
|
+
readonly onResult?: (id: string, result: CaseResult) => void;
|
|
339
|
+
}): Promise<{
|
|
340
|
+
id: string;
|
|
341
|
+
result: CaseResult;
|
|
342
|
+
}[]>;
|
|
311
343
|
|
|
312
344
|
/**
|
|
313
345
|
* Short constructors for gestures, so a row reads as what a user does: `g.press("pages")`, `g.to(place)`,
|
|
@@ -406,4 +438,4 @@ declare const CASE_GROUPS: readonly {
|
|
|
406
438
|
/** The row with this id, or undefined. */
|
|
407
439
|
declare const caseById: (id: string) => CaseRow | undefined;
|
|
408
440
|
|
|
409
|
-
export { type AimArea, CASES, CASE_GROUPS, type CaseGroup, type CaseHost, type CaseResult, type CaseRow, type CaseSettings, type Checkpoint, type DomCheck, type DomRoot, END_REACH, type EdgeExpect, type Gesture, type GestureType, type ItemExpect, LIFT_THRESHOLD, type LayoutExpect, type SceneHost, type SceneHostOptions, type StoredExpect, WINDOW_A, WINDOW_B, WINDOW_BARE, type WinOptions, type WinSpec, caseById, createSceneHost, defaultItemSelector, g, layoutIssues, pickTarget, resolvePlace, runCase, runCases, winScene };
|
|
441
|
+
export { type AimArea, type AsyncCaseHost, CASES, CASE_GROUPS, type CaseGroup, type CaseHost, type CaseResult, type CaseRow, type CaseSettings, type Checkpoint, type DomCheck, type DomRoot, END_REACH, type EdgeExpect, type Gesture, type GestureType, type ItemExpect, LIFT_THRESHOLD, type LayoutExpect, type SceneHost, type SceneHostOptions, type StoredExpect, WINDOW_A, WINDOW_B, WINDOW_BARE, type WinOptions, type WinSpec, caseById, createSceneHost, defaultItemSelector, g, layoutIssues, pickTarget, resolvePlace, runCase, runCaseAsync, runCases, runCasesAsync, winScene };
|
package/dist/scene-cases.js
CHANGED
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
storeScene,
|
|
14
14
|
targets,
|
|
15
15
|
use
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-TFM4S3L3.js";
|
|
17
|
+
import "./chunk-RL3QB5SM.js";
|
|
18
18
|
import {
|
|
19
19
|
rect
|
|
20
20
|
} from "./chunk-QMTNB2C3.js";
|
|
@@ -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
|