@chronista-club/creo-ui-layout 0.1.0 → 0.3.0
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/drivers.d.ts +44 -0
- package/dist/engine.d.ts +46 -0
- package/dist/gestures.d.ts +9 -2
- package/dist/index.d.ts +7 -3
- package/dist/index.js +355 -211
- package/dist/index.js.map +1 -1
- package/dist/policy.d.ts +20 -0
- package/dist/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SettleAuthor, TransitionHandle } from './engine';
|
|
2
|
+
/**
|
|
3
|
+
* 経過時間 → 進行度の純関数。position は 0 始まりで settleTime 秒後に ≈1 に静定。
|
|
4
|
+
* 1 超え(spring の overshoot)は許すが、scrub 側で [0,1] に clamp される —
|
|
5
|
+
* 面積和 = 1 の invariant を外挿で壊さないため(overshoot の表現は frame / WAAPI の領分)
|
|
6
|
+
*/
|
|
7
|
+
export interface TimeCurve {
|
|
8
|
+
position(elapsedSeconds: number): number;
|
|
9
|
+
settleTime: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 既定 curve = 臨界減衰 spring の閉形式(overshoot なし、約 0.35s で静定)。
|
|
13
|
+
* ω = 26.4 は |x - 1| < 0.001 が 0.35s になる値。frame の springCurve を使えば
|
|
14
|
+
* preset(gentle / wobbly / …)で差し替えられる
|
|
15
|
+
*/
|
|
16
|
+
export declare const defaultCurve: TimeCurve;
|
|
17
|
+
export interface DriverRun {
|
|
18
|
+
cancel(): void;
|
|
19
|
+
/** true = 端点まで走り切った / false = cancel された */
|
|
20
|
+
finished: Promise<boolean>;
|
|
21
|
+
}
|
|
22
|
+
export interface TransitionDriver {
|
|
23
|
+
/** apply に t を流し込む。range で部分区間(release の「現在地 → 端点」等)を駆動 */
|
|
24
|
+
start(apply: (t: number) => void, range?: {
|
|
25
|
+
from?: number;
|
|
26
|
+
to?: number;
|
|
27
|
+
}): DriverRun;
|
|
28
|
+
}
|
|
29
|
+
export interface TimeDriverOptions {
|
|
30
|
+
curve?: TimeCurve;
|
|
31
|
+
/** ms 時計(テスト注入用。既定 = performance.now / Date.now) */
|
|
32
|
+
now?: () => number;
|
|
33
|
+
/** 次 frame の予約(テスト注入用。既定 = rAF、非 browser は setTimeout 16ms)。戻り値 = 予約取消 */
|
|
34
|
+
schedule?: (cb: () => void) => () => void;
|
|
35
|
+
}
|
|
36
|
+
/** time driver: curve を実時間で sample して t を進める。settleTime 到達で必ず to に着地 */
|
|
37
|
+
export declare function createTimeDriver(options?: TimeDriverOptions): TransitionDriver;
|
|
38
|
+
/** jump driver: 即 to(reduced-motion / テンポの速い操作用)。同期に apply する */
|
|
39
|
+
export declare const jumpDriver: TransitionDriver;
|
|
40
|
+
/**
|
|
41
|
+
* スクラブ手放しの着地(§5): 近い端点へ driver で運び、1 なら commit / 0 なら cancel。
|
|
42
|
+
* 「一時状態は必ず settle 状態に着地する」の実行形
|
|
43
|
+
*/
|
|
44
|
+
export declare function settleRelease(handle: TransitionHandle, driver: TransitionDriver, author?: SettleAuthor): DriverRun;
|
package/dist/engine.d.ts
CHANGED
|
@@ -10,6 +10,39 @@ export interface FloatPosition {
|
|
|
10
10
|
readonly y: number;
|
|
11
11
|
}
|
|
12
12
|
export type ResolvedListener = (scope: string, resolved: ResolvedMap) => void;
|
|
13
|
+
/**
|
|
14
|
+
* 進行中の遷移への操作面(LE-7)。t を進めるのは driver(time / hand / jump)で、
|
|
15
|
+
* handle は「どこまで来たか」と「どちらに着地するか」だけを扱う。
|
|
16
|
+
*
|
|
17
|
+
* base は begin 時点の**投影 snapshot**(ResolvedMap)— scrub の中間形は構造の離散性を
|
|
18
|
+
* rect 空間で回避したものなので Layout に逆変換できない。着地は常に端点:
|
|
19
|
+
* commit = target が current になる / cancel = 元の layout のまま。
|
|
20
|
+
*
|
|
21
|
+
* seize(update / moveFloat / applyScene / restoreLastSettle)や後続の beginTransition で
|
|
22
|
+
* 遷移が破棄されたら done = true になり、以降の全メソッドは no-op(stale handle は無害)。
|
|
23
|
+
*/
|
|
24
|
+
export interface TransitionHandle {
|
|
25
|
+
readonly scope: string;
|
|
26
|
+
/** 現在の t ∈ [0, 1] */
|
|
27
|
+
readonly t: number;
|
|
28
|
+
/** commit / cancel / seize 済みなら true(以降の操作は no-op) */
|
|
29
|
+
readonly done: boolean;
|
|
30
|
+
/** 遷移先の Layout(engine 所有の複製。書き換えは updateTarget で) */
|
|
31
|
+
readonly target: Layout;
|
|
32
|
+
/** t を動かして中間形を表示する(非有限は 1 = jump に倒す) */
|
|
33
|
+
scrub(t: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* morph を続けたまま目標だけ書き換える(Touch の per-pane 調停の土台 —
|
|
36
|
+
* AI 遷移中に human の knob が target の share を上書きし、morph は続行する)
|
|
37
|
+
*/
|
|
38
|
+
updateTarget(fn: (layout: Layout) => Layout): void;
|
|
39
|
+
/** target を current にして settle log に刻む(author = 引き金を引いた者) */
|
|
40
|
+
commit(author: SettleAuthor): void;
|
|
41
|
+
/** 遷移を破棄して元の layout の表示に戻す(log には何も残らない) */
|
|
42
|
+
cancel(): void;
|
|
43
|
+
/** スクラブ手放しの着地先(§5: t < 0.5 → 0 = cancel 側、以上 → 1 = commit 側) */
|
|
44
|
+
nearestEndpoint(): 0 | 1;
|
|
45
|
+
}
|
|
13
46
|
export interface LayoutEngineOptions {
|
|
14
47
|
/** テスト用の時計注入(既定 = Date.now) */
|
|
15
48
|
clock?: () => number;
|
|
@@ -29,7 +62,20 @@ export interface LayoutEngine {
|
|
|
29
62
|
restoreLastSettle(scope: string): boolean;
|
|
30
63
|
/** float の一時的な移動(ephemeral — log / Scene に入らない)。pos は左上 0..1 */
|
|
31
64
|
moveFloat(scope: string, id: string, pos: FloatPosition): void;
|
|
65
|
+
/**
|
|
66
|
+
* target への遷移を開く(LE-7)。base = 「今の表示」の snapshot なので、遷移中に
|
|
67
|
+
* 次の begin が来ても表示は飛ばない(連鎖)。進行中の遷移は置き換えられ done になる。
|
|
68
|
+
* t = 0 で開くため表示は変わらない — 動かすのは driver / scrub。
|
|
69
|
+
*/
|
|
70
|
+
beginTransition(scope: string, target: Layout): TransitionHandle;
|
|
71
|
+
/** 進行中の遷移の handle(無ければ null)。Touch 配線 = consumer がこれを掴んで調停する */
|
|
72
|
+
transition(scope: string): TransitionHandle | null;
|
|
32
73
|
resolved(scope: string): ResolvedMap;
|
|
33
74
|
subscribe(listener: ResolvedListener): () => void;
|
|
34
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Layout の構造的複製(純 data なので手書きで足りる — structuredClone = DOM API に依存しない)。
|
|
78
|
+
* consumer も Scene capture 等で使う public API(複製の同型実装を増やさないため export)。
|
|
79
|
+
*/
|
|
80
|
+
export declare const cloneLayout: (layout: Layout) => Layout;
|
|
35
81
|
export declare function createLayoutEngine(options?: LayoutEngineOptions): LayoutEngine;
|
package/dist/gestures.d.ts
CHANGED
|
@@ -34,7 +34,14 @@ export interface AdmitOptions {
|
|
|
34
34
|
* 既定 = 末尾に新規列、attention = 可視 pane の raw 平均(居なければ 1)。
|
|
35
35
|
*/
|
|
36
36
|
export declare function admit(layout: Layout, id: string, opts?: AdmitOptions): Layout;
|
|
37
|
-
/** tiled → floating(構造から抜くだけ。場は不変 =
|
|
37
|
+
/** tiled → floating(構造から抜くだけ。場は不変 = サイズが保存される。lock は休眠) */
|
|
38
38
|
export declare function popOut(layout: Layout, id: string): Layout;
|
|
39
|
-
/** floating → tiled
|
|
39
|
+
/** floating → tiled(構造へ戻すだけ。場は不変、休眠 lock は復活)。既定 = 末尾に新規列 */
|
|
40
40
|
export declare function popIn(layout: Layout, id: string, column?: number): Layout;
|
|
41
|
+
/**
|
|
42
|
+
* 列幅 lock(LE-21、fader lock の幅版)。share = その pane を含む列の幅 share。
|
|
43
|
+
* サイズ情報なので場の側(Layout.locks)に住む — 構造・記法には入らない(LE-4)。
|
|
44
|
+
*/
|
|
45
|
+
export declare function lock(layout: Layout, id: string, share: number): Layout;
|
|
46
|
+
/** lock 解除。無ければ no-op(同一参照) */
|
|
47
|
+
export declare function unlock(layout: Layout, id: string): Layout;
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export type { ResolveOptions } from './resolve';
|
|
|
11
11
|
export { resolve } from './resolve';
|
|
12
12
|
export { interpolate } from './interpolate';
|
|
13
13
|
export type { AdmitOptions, DominanceDirection } from './gestures';
|
|
14
|
-
export { admit, equalize, moveDominance, mute, popIn, popOut, setShare, solo, visibleIds, } from './gestures';
|
|
15
|
-
export type { FloatPosition, LayoutEngine, LayoutEngineOptions, ResolvedListener, SettleAuthor, SettleEntry, } from './engine';
|
|
16
|
-
export { createLayoutEngine } from './engine';
|
|
14
|
+
export { admit, equalize, lock, moveDominance, mute, popIn, popOut, setShare, solo, unlock, visibleIds, } from './gestures';
|
|
15
|
+
export type { FloatPosition, LayoutEngine, LayoutEngineOptions, ResolvedListener, SettleAuthor, SettleEntry, TransitionHandle, } from './engine';
|
|
16
|
+
export { cloneLayout, createLayoutEngine } from './engine';
|
|
17
|
+
export type { DriverRun, TimeCurve, TimeDriverOptions, TransitionDriver } from './drivers';
|
|
18
|
+
export { createTimeDriver, defaultCurve, jumpDriver, settleRelease } from './drivers';
|
|
19
|
+
export type { ApplyPolicy, ProposeOptions, ProposeResult } from './policy';
|
|
20
|
+
export { proposeLayout } from './policy';
|
package/dist/index.js
CHANGED
|
@@ -1,298 +1,442 @@
|
|
|
1
|
-
const
|
|
1
|
+
const _ = Object.freeze({
|
|
2
2
|
structure: Object.freeze({ columns: Object.freeze([]) }),
|
|
3
3
|
attention: Object.freeze({})
|
|
4
4
|
});
|
|
5
|
-
function
|
|
5
|
+
function D(t) {
|
|
6
6
|
return t.columns.flatMap((n) => [...n.panes]);
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
return t.columns.some((
|
|
8
|
+
function z(t, n) {
|
|
9
|
+
return t.columns.some((r) => r.panes.includes(n));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function X(t, n) {
|
|
12
|
+
return z(t, n) ? { columns: t.columns.map((o) => ({ panes: o.panes.filter((s) => s !== n) })).filter((o) => o.panes.length > 0) } : t;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function R(t, n) {
|
|
15
15
|
return { columns: [...t.columns, { panes: [n] }] };
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
19
|
-
(
|
|
17
|
+
function H(t, n, r) {
|
|
18
|
+
return r < 0 || r >= t.columns.length ? R(t, n) : { columns: t.columns.map(
|
|
19
|
+
(s, c) => c === r ? { panes: [...s.panes, n] } : s
|
|
20
20
|
) };
|
|
21
21
|
}
|
|
22
|
-
const
|
|
23
|
-
function
|
|
24
|
-
if (!
|
|
22
|
+
const Y = /^[^\s|/~]+$/;
|
|
23
|
+
function A(t) {
|
|
24
|
+
if (!Y.test(t))
|
|
25
25
|
throw new Error(`layout notation: 不正な pane id "${t}"(空白と | / ~ は使えない)`);
|
|
26
26
|
return t;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function nt(t) {
|
|
29
29
|
const n = t.split("~");
|
|
30
30
|
if (n.length > 2)
|
|
31
31
|
throw new Error("layout notation: float 区切り ~ は 1 つまで");
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
32
|
+
const r = (n[0] ?? "").trim(), o = (n[1] ?? "").trim(), s = r === "" ? [] : r.split("|").map((p) => {
|
|
33
|
+
const h = p.trim();
|
|
34
|
+
if (h === "")
|
|
35
35
|
throw new Error("layout notation: 空の列(| の間に pane が無い)");
|
|
36
|
-
return { panes:
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
36
|
+
return { panes: h.split("/").map((e) => {
|
|
37
|
+
const a = e.trim();
|
|
38
|
+
if (a === "")
|
|
39
39
|
throw new Error("layout notation: 空の pane(/ の間に id が無い)");
|
|
40
|
-
return
|
|
40
|
+
return A(a);
|
|
41
41
|
}) };
|
|
42
|
-
}),
|
|
43
|
-
for (const
|
|
44
|
-
if (
|
|
45
|
-
throw new Error(`layout notation: pane id 重複 "${
|
|
46
|
-
|
|
42
|
+
}), c = o === "" ? [] : o.split(/\s+/).map(A), m = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const p of [...s.flatMap((h) => h.panes), ...c]) {
|
|
44
|
+
if (m.has(p))
|
|
45
|
+
throw new Error(`layout notation: pane id 重複 "${p}"`);
|
|
46
|
+
m.add(p);
|
|
47
47
|
}
|
|
48
|
-
return { structure: { columns:
|
|
48
|
+
return { structure: { columns: s }, floats: c };
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
for (const
|
|
53
|
-
if (
|
|
54
|
-
throw new Error(`layout notation: pane id 重複 "${
|
|
55
|
-
|
|
50
|
+
function et(t, n = []) {
|
|
51
|
+
const r = /* @__PURE__ */ new Set();
|
|
52
|
+
for (const c of [...t.columns.flatMap((m) => [...m.panes]), ...n]) {
|
|
53
|
+
if (A(c), r.has(c))
|
|
54
|
+
throw new Error(`layout notation: pane id 重複 "${c}"`);
|
|
55
|
+
r.add(c);
|
|
56
56
|
}
|
|
57
|
-
for (const
|
|
58
|
-
if (
|
|
57
|
+
for (const c of t.columns)
|
|
58
|
+
if (c.panes.length === 0)
|
|
59
59
|
throw new Error("layout notation: 空の列は直列化できない");
|
|
60
|
-
const
|
|
61
|
-
if (n.length === 0) return
|
|
62
|
-
const
|
|
63
|
-
return
|
|
60
|
+
const o = t.columns.map((c) => c.panes.join("/")).join(" | ");
|
|
61
|
+
if (n.length === 0) return o;
|
|
62
|
+
const s = `~ ${n.join(" ")}`;
|
|
63
|
+
return o === "" ? s : `${o} ${s}`;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
function
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
if (!Number.isFinite(
|
|
70
|
-
const
|
|
71
|
-
return Number.isFinite(
|
|
72
|
-
},
|
|
73
|
-
let
|
|
74
|
-
for (const f of Object.keys(
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
(f) => f.panes.reduce((
|
|
78
|
-
),
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
65
|
+
const B = (t) => t;
|
|
66
|
+
function N(t, n = {}) {
|
|
67
|
+
const r = n.taper ?? B, o = t.attention, s = (f) => {
|
|
68
|
+
const g = o[f] ?? 0;
|
|
69
|
+
if (!Number.isFinite(g) || g <= 0) return 0;
|
|
70
|
+
const w = r(g);
|
|
71
|
+
return Number.isFinite(w) && w > 0 ? w : 0;
|
|
72
|
+
}, c = new Set(D(t.structure));
|
|
73
|
+
let m = 0;
|
|
74
|
+
for (const f of Object.keys(o))
|
|
75
|
+
m += s(f);
|
|
76
|
+
const p = t.structure.columns.map(
|
|
77
|
+
(f) => f.panes.reduce((g, w) => Math.max(g, s(w)), 0)
|
|
78
|
+
), h = t.locks ?? {}, l = t.structure.columns.map((f, g) => (p[g] ?? 0) <= 0 ? 0 : f.panes.reduce((w, k) => {
|
|
79
|
+
const M = h[k] ?? 0;
|
|
80
|
+
return Number.isFinite(M) && M > 0 ? Math.max(w, Math.min(M, 1)) : w;
|
|
81
|
+
}, 0)), e = l.reduce((f, g) => f + g, 0), a = p.reduce((f, g, w) => (l[w] ?? 0) > 0 ? f : f + g, 0), i = e <= 0 ? 0 : a > 0 ? Math.min(1, 1 / e) : 1 / e, u = Math.max(0, 1 - e * i), d = {};
|
|
82
|
+
let b = 0;
|
|
83
|
+
t.structure.columns.forEach((f, g) => {
|
|
84
|
+
const w = p[g] ?? 0, k = w > 0, M = (l[g] ?? 0) * i, P = k ? M > 0 ? M : a > 0 ? u * (w / a) : 0 : 0, $ = b, C = f.panes.reduce((j, E) => j + s(E), 0);
|
|
85
|
+
let T = 0;
|
|
86
|
+
for (const j of f.panes) {
|
|
87
|
+
const E = s(j);
|
|
88
|
+
if (E > 0 && C > 0) {
|
|
89
|
+
const I = E / C;
|
|
90
|
+
d[j] = {
|
|
91
|
+
rect: { x: $, y: T, w: P, h: I },
|
|
92
|
+
attention: m > 0 ? E / m : 0,
|
|
90
93
|
floating: !1
|
|
91
|
-
},
|
|
94
|
+
}, T += I;
|
|
92
95
|
} else
|
|
93
|
-
|
|
94
|
-
rect: { x:
|
|
96
|
+
d[j] = {
|
|
97
|
+
rect: { x: $, y: T, w: k ? P : 0, h: 0 },
|
|
95
98
|
attention: 0,
|
|
96
99
|
floating: !1
|
|
97
100
|
};
|
|
98
101
|
}
|
|
99
|
-
|
|
102
|
+
b += P;
|
|
100
103
|
});
|
|
101
|
-
for (const f of Object.keys(
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
rect: { x: (1 -
|
|
108
|
-
attention:
|
|
104
|
+
for (const f of Object.keys(o)) {
|
|
105
|
+
if (c.has(f)) continue;
|
|
106
|
+
const g = s(f);
|
|
107
|
+
if (g <= 0) continue;
|
|
108
|
+
const w = m > 0 ? g / m : 0, k = Math.min(1, w);
|
|
109
|
+
d[f] = {
|
|
110
|
+
rect: { x: (1 - k) / 2, y: (1 - k) / 2, w: k, h: k },
|
|
111
|
+
attention: w,
|
|
109
112
|
floating: !0
|
|
110
113
|
};
|
|
111
114
|
}
|
|
112
|
-
return
|
|
115
|
+
return d;
|
|
113
116
|
}
|
|
114
|
-
const
|
|
115
|
-
function
|
|
117
|
+
const O = (t, n, r) => t + (n - t) * r;
|
|
118
|
+
function U(t) {
|
|
116
119
|
return { x: t.x + t.w / 2, y: t.y + t.h / 2, w: 0, h: 0 };
|
|
117
120
|
}
|
|
118
|
-
function
|
|
119
|
-
return { rect:
|
|
121
|
+
function L(t) {
|
|
122
|
+
return { rect: U(t.rect), attention: 0, floating: t.floating };
|
|
120
123
|
}
|
|
121
|
-
function
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
126
|
-
for (const
|
|
127
|
-
const
|
|
128
|
-
|
|
124
|
+
function W(t, n, r) {
|
|
125
|
+
const o = Number.isFinite(r) ? Math.min(1, Math.max(0, r)) : 1;
|
|
126
|
+
if (o === 0) return t;
|
|
127
|
+
if (o === 1) return n;
|
|
128
|
+
const s = {}, c = /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(n)]);
|
|
129
|
+
for (const m of c) {
|
|
130
|
+
const p = n[m], h = t[m], l = h ?? L(p), e = p ?? L(h);
|
|
131
|
+
s[m] = {
|
|
129
132
|
rect: {
|
|
130
|
-
x:
|
|
131
|
-
y:
|
|
132
|
-
w:
|
|
133
|
-
h:
|
|
133
|
+
x: O(l.rect.x, e.rect.x, o),
|
|
134
|
+
y: O(l.rect.y, e.rect.y, o),
|
|
135
|
+
w: O(l.rect.w, e.rect.w, o),
|
|
136
|
+
h: O(l.rect.h, e.rect.h, o)
|
|
134
137
|
},
|
|
135
|
-
attention:
|
|
136
|
-
floating:
|
|
138
|
+
attention: O(l.attention, e.attention, o),
|
|
139
|
+
floating: o < 0.5 ? l.floating : e.floating
|
|
137
140
|
};
|
|
138
141
|
}
|
|
139
|
-
return
|
|
142
|
+
return s;
|
|
140
143
|
}
|
|
141
|
-
function
|
|
144
|
+
function F(t) {
|
|
142
145
|
return Object.keys(t.attention).filter((n) => (t.attention[n] ?? 0) > 0);
|
|
143
146
|
}
|
|
144
|
-
function
|
|
145
|
-
return { structure: t.structure, attention: n };
|
|
147
|
+
function x(t, n) {
|
|
148
|
+
return { structure: t.structure, attention: n, locks: t.locks };
|
|
146
149
|
}
|
|
147
|
-
const
|
|
148
|
-
function
|
|
149
|
-
if (
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
return (t.attention[n] ?? 0) > 0 ? t :
|
|
153
|
-
const
|
|
154
|
-
return
|
|
150
|
+
const q = 0.99;
|
|
151
|
+
function G(t, n, r) {
|
|
152
|
+
if (r <= 0) return J(t, n);
|
|
153
|
+
const o = Math.min(r, q), s = F(t).filter((m) => m !== n).reduce((m, p) => m + (t.attention[p] ?? 0), 0);
|
|
154
|
+
if (s <= 0)
|
|
155
|
+
return (t.attention[n] ?? 0) > 0 ? t : x(t, { ...t.attention, [n]: 1 });
|
|
156
|
+
const c = o / (1 - o) * s;
|
|
157
|
+
return x(t, { ...t.attention, [n]: c });
|
|
155
158
|
}
|
|
156
|
-
function
|
|
157
|
-
return (t.attention[n] ?? 0) <= 0 ||
|
|
159
|
+
function J(t, n) {
|
|
160
|
+
return (t.attention[n] ?? 0) <= 0 || F(t).length <= 1 ? t : x(t, { ...t.attention, [n]: 0 });
|
|
158
161
|
}
|
|
159
|
-
function
|
|
160
|
-
const
|
|
161
|
-
for (const
|
|
162
|
-
return
|
|
162
|
+
function rt(t, n) {
|
|
163
|
+
const r = t.attention[n] ?? 0, o = r > 0 ? r : 1, s = {};
|
|
164
|
+
for (const c of Object.keys(t.attention)) s[c] = 0;
|
|
165
|
+
return s[n] = o, x(t, s);
|
|
163
166
|
}
|
|
164
|
-
function
|
|
165
|
-
const
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
168
|
-
for (const
|
|
169
|
-
return
|
|
167
|
+
function ot(t, n) {
|
|
168
|
+
const r = n ?? F(t);
|
|
169
|
+
if (r.length === 0) return t;
|
|
170
|
+
const o = { ...t.attention };
|
|
171
|
+
for (const s of r) o[s] = 1;
|
|
172
|
+
return x(t, o);
|
|
170
173
|
}
|
|
171
|
-
function
|
|
172
|
-
const
|
|
173
|
-
if (
|
|
174
|
-
let
|
|
175
|
-
for (const u of
|
|
176
|
-
(
|
|
177
|
-
if (!
|
|
178
|
-
const
|
|
179
|
-
if (
|
|
180
|
-
const
|
|
181
|
-
let
|
|
174
|
+
function st(t, n) {
|
|
175
|
+
const r = t.attention, o = D(t.structure), s = new Set(o), c = o.filter((u) => (r[u] ?? 0) > 0), m = Object.keys(r).filter((u) => !s.has(u) && (r[u] ?? 0) > 0), p = [...c, ...m];
|
|
176
|
+
if (p.length === 0) return t;
|
|
177
|
+
let h = p[0];
|
|
178
|
+
for (const u of p)
|
|
179
|
+
(r[u] ?? 0) > (r[h] ?? 0) && (h = u);
|
|
180
|
+
if (!s.has(h)) return t;
|
|
181
|
+
const l = t.structure.columns.map((u) => u.panes.filter((d) => (r[d] ?? 0) > 0)).filter((u) => u.length > 0), e = l.findIndex((u) => u.includes(h));
|
|
182
|
+
if (e < 0) return t;
|
|
183
|
+
const a = l[e];
|
|
184
|
+
let i;
|
|
182
185
|
if (n === "left" || n === "right") {
|
|
183
|
-
const
|
|
184
|
-
let
|
|
185
|
-
for (const
|
|
186
|
-
(
|
|
187
|
-
|
|
186
|
+
const d = l[(e + (n === "right" ? 1 : -1) + l.length) % l.length];
|
|
187
|
+
let b = d[0];
|
|
188
|
+
for (const f of d)
|
|
189
|
+
(r[f] ?? 0) > (r[b] ?? 0) && (b = f);
|
|
190
|
+
i = b;
|
|
188
191
|
} else {
|
|
189
|
-
const u =
|
|
190
|
-
|
|
192
|
+
const u = a.indexOf(h);
|
|
193
|
+
i = a[(u + (n === "down" ? 1 : -1) + a.length) % a.length];
|
|
191
194
|
}
|
|
192
|
-
return
|
|
193
|
-
...
|
|
194
|
-
[
|
|
195
|
-
[
|
|
195
|
+
return i === h ? t : x(t, {
|
|
196
|
+
...r,
|
|
197
|
+
[h]: r[i] ?? 0,
|
|
198
|
+
[i]: r[h] ?? 0
|
|
196
199
|
});
|
|
197
200
|
}
|
|
198
|
-
function
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
|
|
201
|
+
function ct(t, n, r = {}) {
|
|
202
|
+
if (z(t.structure, n)) return t;
|
|
203
|
+
const o = r.column != null ? H(t.structure, n, r.column) : R(t.structure, n), s = F(t).filter((l) => l !== n), c = s.length > 0 ? s.reduce((l, e) => l + (t.attention[e] ?? 0), 0) / s.length : 1, m = t.attention[n] ?? 0, p = m > 0 ? m : c, h = {
|
|
204
|
+
structure: o,
|
|
205
|
+
attention: { ...t.attention, [n]: p },
|
|
206
|
+
locks: t.locks
|
|
207
|
+
};
|
|
208
|
+
return r.share != null ? G(h, n, r.share) : h;
|
|
209
|
+
}
|
|
210
|
+
function it(t, n) {
|
|
211
|
+
const r = X(t.structure, n);
|
|
212
|
+
return r === t.structure ? t : { structure: r, attention: t.attention, locks: t.locks };
|
|
202
213
|
}
|
|
203
|
-
function
|
|
204
|
-
|
|
205
|
-
|
|
214
|
+
function at(t, n, r) {
|
|
215
|
+
return z(t.structure, n) ? t : { structure: r != null ? H(t.structure, n, r) : R(t.structure, n), attention: t.attention, locks: t.locks };
|
|
216
|
+
}
|
|
217
|
+
function ut(t, n, r) {
|
|
218
|
+
if (!Number.isFinite(r) || r <= 0) return K(t, n);
|
|
219
|
+
const o = Math.min(r, q);
|
|
220
|
+
return {
|
|
221
|
+
structure: t.structure,
|
|
222
|
+
attention: t.attention,
|
|
223
|
+
locks: { ...t.locks ?? {}, [n]: o }
|
|
224
|
+
};
|
|
206
225
|
}
|
|
207
|
-
function K(t, n
|
|
208
|
-
|
|
226
|
+
function K(t, n) {
|
|
227
|
+
if (!t.locks || !(n in t.locks)) return t;
|
|
228
|
+
const r = { ...t.locks };
|
|
229
|
+
return delete r[n], {
|
|
230
|
+
structure: t.structure,
|
|
231
|
+
attention: t.attention,
|
|
232
|
+
locks: Object.keys(r).length > 0 ? r : void 0
|
|
233
|
+
};
|
|
209
234
|
}
|
|
210
|
-
const
|
|
235
|
+
const S = (t) => Math.min(1, Math.max(0, t)), v = (t) => ({
|
|
211
236
|
structure: { columns: t.structure.columns.map((n) => ({ panes: [...n.panes] })) },
|
|
212
|
-
attention: { ...t.attention }
|
|
237
|
+
attention: { ...t.attention },
|
|
238
|
+
locks: t.locks ? { ...t.locks } : void 0
|
|
213
239
|
});
|
|
214
|
-
function
|
|
215
|
-
const n = t.clock ?? (() => Date.now()),
|
|
216
|
-
let
|
|
217
|
-
return
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
240
|
+
function lt(t = {}) {
|
|
241
|
+
const n = t.clock ?? (() => Date.now()), r = t.taper, o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), c = (e) => {
|
|
242
|
+
let a = o.get(e);
|
|
243
|
+
return a || (a = {
|
|
244
|
+
layout: _,
|
|
245
|
+
log: [],
|
|
246
|
+
floatPos: /* @__PURE__ */ new Map(),
|
|
247
|
+
transition: null,
|
|
248
|
+
transitionHandle: null
|
|
249
|
+
}, o.set(e, a)), a;
|
|
250
|
+
}, m = (e, a, i) => {
|
|
251
|
+
if (i)
|
|
252
|
+
for (const d of [...e.floatPos.keys()])
|
|
253
|
+
a[d]?.floating || e.floatPos.delete(d);
|
|
254
|
+
if (e.floatPos.size === 0) return a;
|
|
255
|
+
const u = { ...a };
|
|
256
|
+
for (const [d, b] of e.floatPos) {
|
|
257
|
+
const f = u[d];
|
|
258
|
+
f?.floating && (u[d] = {
|
|
259
|
+
...f,
|
|
228
260
|
rect: {
|
|
229
|
-
...
|
|
230
|
-
x:
|
|
231
|
-
y:
|
|
261
|
+
...f.rect,
|
|
262
|
+
x: S(Math.min(b.x, 1 - f.rect.w)),
|
|
263
|
+
y: S(Math.min(b.y, 1 - f.rect.h))
|
|
232
264
|
}
|
|
233
265
|
});
|
|
234
266
|
}
|
|
235
|
-
return
|
|
236
|
-
}, m = (e) => {
|
|
237
|
-
|
|
238
|
-
|
|
267
|
+
return u;
|
|
268
|
+
}, p = (e) => e.transition ? W(e.transition.base, e.transition.targetResolved, e.transition.t) : m(e, N(e.layout, { taper: r }), !0), h = (e) => {
|
|
269
|
+
e.transition = null;
|
|
270
|
+
}, l = (e) => {
|
|
271
|
+
const a = p(c(e));
|
|
272
|
+
for (const i of s) i(e, a);
|
|
239
273
|
};
|
|
240
274
|
return {
|
|
241
275
|
current(e) {
|
|
242
|
-
return
|
|
276
|
+
return c(e).layout;
|
|
243
277
|
},
|
|
244
|
-
update(e,
|
|
245
|
-
const i =
|
|
246
|
-
i.layout =
|
|
278
|
+
update(e, a) {
|
|
279
|
+
const i = c(e);
|
|
280
|
+
h(i), i.layout = a(i.layout), l(e);
|
|
247
281
|
},
|
|
248
|
-
applyScene(e,
|
|
249
|
-
const i =
|
|
250
|
-
i.layout =
|
|
282
|
+
applyScene(e, a) {
|
|
283
|
+
const i = c(e);
|
|
284
|
+
h(i), i.layout = v(a.layout), i.log.push({ layout: v(i.layout), at: n(), author: "scene" }), l(e);
|
|
251
285
|
},
|
|
252
|
-
settle(e,
|
|
253
|
-
const i =
|
|
254
|
-
i.log.push({ layout:
|
|
286
|
+
settle(e, a) {
|
|
287
|
+
const i = c(e);
|
|
288
|
+
i.log.push({ layout: v(i.layout), at: n(), author: a });
|
|
255
289
|
},
|
|
256
290
|
history(e) {
|
|
257
|
-
return [...
|
|
291
|
+
return [...c(e).log];
|
|
258
292
|
},
|
|
259
293
|
restoreLastSettle(e) {
|
|
260
|
-
const
|
|
261
|
-
return i ? (
|
|
294
|
+
const a = c(e), i = a.log[a.log.length - 1];
|
|
295
|
+
return i ? (h(a), a.layout = v(i.layout), l(e), !0) : !1;
|
|
296
|
+
},
|
|
297
|
+
moveFloat(e, a, i) {
|
|
298
|
+
const u = c(e);
|
|
299
|
+
h(u), u.floatPos.set(a, { x: S(i.x), y: S(i.y) }), l(e);
|
|
262
300
|
},
|
|
263
|
-
|
|
264
|
-
|
|
301
|
+
beginTransition(e, a) {
|
|
302
|
+
const i = c(e), u = {
|
|
303
|
+
base: p(i),
|
|
304
|
+
// 遷移中なら中間形 = 連鎖しても表示が飛ばない
|
|
305
|
+
target: v(a),
|
|
306
|
+
targetResolved: {},
|
|
307
|
+
t: 0
|
|
308
|
+
};
|
|
309
|
+
u.targetResolved = m(i, N(u.target, { taper: r }), !1), i.transition = u;
|
|
310
|
+
const d = () => i.transition === u, b = {
|
|
311
|
+
scope: e,
|
|
312
|
+
get t() {
|
|
313
|
+
return u.t;
|
|
314
|
+
},
|
|
315
|
+
get done() {
|
|
316
|
+
return !d();
|
|
317
|
+
},
|
|
318
|
+
get target() {
|
|
319
|
+
return u.target;
|
|
320
|
+
},
|
|
321
|
+
scrub(f) {
|
|
322
|
+
d() && (u.t = Number.isFinite(f) ? S(f) : 1, l(e));
|
|
323
|
+
},
|
|
324
|
+
updateTarget(f) {
|
|
325
|
+
d() && (u.target = f(u.target), u.targetResolved = m(i, N(u.target, { taper: r }), !1), l(e));
|
|
326
|
+
},
|
|
327
|
+
commit(f) {
|
|
328
|
+
d() && (i.transition = null, i.layout = v(u.target), i.log.push({ layout: v(i.layout), at: n(), author: f }), l(e));
|
|
329
|
+
},
|
|
330
|
+
cancel() {
|
|
331
|
+
d() && (i.transition = null, l(e));
|
|
332
|
+
},
|
|
333
|
+
nearestEndpoint() {
|
|
334
|
+
return u.t >= 0.5 ? 1 : 0;
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
return i.transitionHandle = b, l(e), b;
|
|
338
|
+
},
|
|
339
|
+
transition(e) {
|
|
340
|
+
const a = c(e);
|
|
341
|
+
return a.transition ? a.transitionHandle : null;
|
|
265
342
|
},
|
|
266
343
|
resolved(e) {
|
|
267
|
-
return
|
|
344
|
+
return p(c(e));
|
|
268
345
|
},
|
|
269
346
|
subscribe(e) {
|
|
270
|
-
return
|
|
271
|
-
|
|
347
|
+
return s.add(e), () => {
|
|
348
|
+
s.delete(e);
|
|
272
349
|
};
|
|
273
350
|
}
|
|
274
351
|
};
|
|
275
352
|
}
|
|
353
|
+
const Q = {
|
|
354
|
+
position: (t) => 1 - Math.exp(-26.4 * t) * (1 + 26.4 * t),
|
|
355
|
+
settleTime: 0.35
|
|
356
|
+
}, V = () => typeof performance < "u" ? performance.now() : Date.now(), Z = (t) => {
|
|
357
|
+
if (typeof requestAnimationFrame == "function") {
|
|
358
|
+
const r = requestAnimationFrame(() => t());
|
|
359
|
+
return () => cancelAnimationFrame(r);
|
|
360
|
+
}
|
|
361
|
+
const n = setTimeout(t, 16);
|
|
362
|
+
return () => clearTimeout(n);
|
|
363
|
+
}, y = (t) => Math.min(1, Math.max(0, t));
|
|
364
|
+
function tt(t = {}) {
|
|
365
|
+
const n = t.curve ?? Q, r = t.now ?? V, o = t.schedule ?? Z;
|
|
366
|
+
return {
|
|
367
|
+
start(s, c = {}) {
|
|
368
|
+
const m = c.from ?? 0, p = c.to ?? 1;
|
|
369
|
+
let h = !1, l = null, e;
|
|
370
|
+
const a = new Promise((d) => {
|
|
371
|
+
e = d;
|
|
372
|
+
}), i = r(), u = () => {
|
|
373
|
+
if (h) return;
|
|
374
|
+
const d = (r() - i) / 1e3;
|
|
375
|
+
if (d >= n.settleTime) {
|
|
376
|
+
s(p), e(!0);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
const b = y(n.position(d));
|
|
380
|
+
s(m + (p - m) * (Number.isFinite(b) ? b : 0)), l = o(u);
|
|
381
|
+
};
|
|
382
|
+
return l = o(u), {
|
|
383
|
+
cancel() {
|
|
384
|
+
h || (h = !0, l?.(), e(!1));
|
|
385
|
+
},
|
|
386
|
+
finished: a
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const ft = {
|
|
392
|
+
start(t, n = {}) {
|
|
393
|
+
return t(n.to ?? 1), { cancel() {
|
|
394
|
+
}, finished: Promise.resolve(!0) };
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
function mt(t, n, r = "human") {
|
|
398
|
+
const o = t.nearestEndpoint(), s = n.start((c) => t.scrub(c), { from: t.t, to: o });
|
|
399
|
+
return s.finished.then((c) => {
|
|
400
|
+
!c || t.done || (o === 1 ? t.commit(r) : t.cancel());
|
|
401
|
+
}), s;
|
|
402
|
+
}
|
|
403
|
+
function pt(t, n, r, o) {
|
|
404
|
+
if (o.policy === "off") return { accepted: !1 };
|
|
405
|
+
const s = t.beginTransition(n, r);
|
|
406
|
+
if (o.policy === "write") return { accepted: !0, handle: s };
|
|
407
|
+
const m = (o.driver ?? tt()).start((p) => s.scrub(p));
|
|
408
|
+
return m.finished.then((p) => {
|
|
409
|
+
p && !s.done && s.commit(o.author ?? "ai");
|
|
410
|
+
}), { accepted: !0, handle: s, drive: m };
|
|
411
|
+
}
|
|
276
412
|
export {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
413
|
+
_ as EMPTY_LAYOUT,
|
|
414
|
+
ct as admit,
|
|
415
|
+
R as appendColumn,
|
|
416
|
+
v as cloneLayout,
|
|
417
|
+
lt as createLayoutEngine,
|
|
418
|
+
tt as createTimeDriver,
|
|
419
|
+
Q as defaultCurve,
|
|
420
|
+
ot as equalize,
|
|
421
|
+
et as formatNotation,
|
|
422
|
+
H as insertIntoColumn,
|
|
423
|
+
W as interpolate,
|
|
424
|
+
z as isMember,
|
|
425
|
+
ft as jumpDriver,
|
|
426
|
+
ut as lock,
|
|
427
|
+
D as memberIds,
|
|
428
|
+
st as moveDominance,
|
|
429
|
+
J as mute,
|
|
430
|
+
nt as parseNotation,
|
|
431
|
+
at as popIn,
|
|
432
|
+
it as popOut,
|
|
433
|
+
pt as proposeLayout,
|
|
434
|
+
X as removePane,
|
|
435
|
+
N as resolve,
|
|
436
|
+
G as setShare,
|
|
437
|
+
mt as settleRelease,
|
|
438
|
+
rt as solo,
|
|
439
|
+
K as unlock,
|
|
440
|
+
F as visibleIds
|
|
297
441
|
};
|
|
298
442
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/types.ts","../src/structure.ts","../src/notation.ts","../src/resolve.ts","../src/interpolate.ts","../src/gestures.ts","../src/engine.ts"],"sourcesContent":["/**\n * Layout Engine — protocol types(LE-P0)。\n *\n * 設計 SSOT: docs/design/layout-engine.md(LE-1〜LE-20)。\n * 場(attention)が唯一のサイズ真実源(LE-3)、構造は軸交代 + 所属のみ(LE-4/5)。\n * keyboard focus は protocol の関心外(LE-20 — DOM / consumer の領分)。\n */\n\n/** pane identity — 「何が存在するか」は consumer 供給(LE-11/12)。primitive は kind を意味づけしない */\nexport interface PaneRef {\n readonly id: string\n readonly kind?: string\n readonly label?: string\n}\n\n/** 列 = 副軸(縦)の並び。構造はサイズを持たない(LE-4) */\nexport interface Column {\n readonly panes: readonly string[]\n}\n\n/** 主軸 = 水平の列並び。軸交代はここで打ち止め(LE-5、arity は無制限) */\nexport interface Structure {\n readonly columns: readonly Column[]\n}\n\n/**\n * 場: pane id → raw attention(≥ 0)。0 = 非表示(LE-3)。\n * 格納は raw、操作/表示は share(正規化後の取り分)— 二重読みは gestures / resolve が担う。\n */\nexport type Attention = Readonly<Record<string, number>>\n\nexport interface Layout {\n readonly structure: Structure\n readonly attention: Attention\n}\n\n/** Scene = Layout の名前付き immutable snapshot = 注視の表現 = scrub の端点(LE-14) */\nexport interface Scene {\n readonly id: string\n readonly name: string\n readonly layout: Layout\n readonly description?: string\n}\n\n/** 0..1 連続の矩形。量子化は投影の縁でやる(LE-9 — ここでは丸めない) */\nexport interface Rect {\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n}\n\n/** resolve の出力 1 pane 分 */\nexport interface ResolvedPane {\n readonly rect: Rect\n /** 全可視 pane に対する share。遠近・明暗への射影は platform 判断(frame F-3) */\n readonly attention: number\n readonly floating: boolean\n}\n\nexport type ResolvedMap = Readonly<Record<string, ResolvedPane>>\n\n/** 空 Layout。全 scope の初期値として共有されるため freeze(in-place mutation 事故の構造的防止) */\nexport const EMPTY_LAYOUT: Layout = Object.freeze({\n structure: Object.freeze({ columns: Object.freeze([]) }),\n attention: Object.freeze({}),\n})\n","/**\n * 構造の純操作(LE-4/5)。\n *\n * 構造が持つのは「軸の交代」と「所属」だけ — サイズ情報は一切持たない。\n * 全関数は新しい Structure を返す(無変更なら同一参照を返し、呼び手が no-op を検知できる)。\n */\n\nimport type { Structure } from './types'\n\n/** 所属 pane id を構造順(列順 → 列内順)で返す */\nexport function memberIds(structure: Structure): string[] {\n return structure.columns.flatMap((col) => [...col.panes])\n}\n\nexport function isMember(structure: Structure, id: string): boolean {\n return structure.columns.some((col) => col.panes.includes(id))\n}\n\n/** pane を構造から抜く(空になった列は落とす)。非所属なら同一参照 */\nexport function removePane(structure: Structure, id: string): Structure {\n if (!isMember(structure, id)) return structure\n const columns = structure.columns\n .map((col) => ({ panes: col.panes.filter((p) => p !== id) }))\n .filter((col) => col.panes.length > 0)\n return { columns }\n}\n\n/** 末尾に新規列として pane を足す */\nexport function appendColumn(structure: Structure, id: string): Structure {\n return { columns: [...structure.columns, { panes: [id] }] }\n}\n\n/** 指定列の末尾に pane を足す。列 index が範囲外なら新規列(appendColumn)に落ちる */\nexport function insertIntoColumn(structure: Structure, id: string, columnIndex: number): Structure {\n if (columnIndex < 0 || columnIndex >= structure.columns.length) {\n return appendColumn(structure, id)\n }\n const columns = structure.columns.map((col, i) =>\n i === columnIndex ? { panes: [...col.panes, id] } : col,\n )\n return { columns }\n}\n","/**\n * 記法 — トポロジーの直列化(LE-4)。\n *\n * \"ec | cv/pp ~ board\"\n * | = 列の区切り(軸の交代)\n * / = 列内の縦の並び\n * ~ = floating(構造非所属で場に居る pane の明示)\n *\n * サイズ(数字)は書かない — サイズは場の領分。二重 SSOT を構造的に排除する。\n * parse / format は往復テストで固定(対の写像の規律)。\n */\n\nimport type { Structure } from './types'\n\n/** id に使える文字: 区切り記号(| / ~)と空白以外 */\nconst ID_RE = /^[^\\s|/~]+$/\n\nexport interface ParsedNotation {\n readonly structure: Structure\n /** 構造非所属で場に居る pane(floating)。場の値そのものは記法の外(attention record が持つ) */\n readonly floats: readonly string[]\n}\n\nfunction validateId(id: string): string {\n if (!ID_RE.test(id)) {\n throw new Error(`layout notation: 不正な pane id \"${id}\"(空白と | / ~ は使えない)`)\n }\n return id\n}\n\n/** 記法文字列 → 構造 + float 集合。不正入力は throw */\nexport function parseNotation(text: string): ParsedNotation {\n const parts = text.split('~')\n if (parts.length > 2) {\n throw new Error('layout notation: float 区切り ~ は 1 つまで')\n }\n const left = (parts[0] ?? '').trim()\n const right = (parts[1] ?? '').trim()\n\n const columns =\n left === ''\n ? []\n : left.split('|').map((segment) => {\n const trimmed = segment.trim()\n if (trimmed === '') {\n throw new Error('layout notation: 空の列(| の間に pane が無い)')\n }\n const panes = trimmed.split('/').map((s) => {\n const id = s.trim()\n if (id === '') {\n throw new Error('layout notation: 空の pane(/ の間に id が無い)')\n }\n return validateId(id)\n })\n return { panes }\n })\n\n const floats = right === '' ? [] : right.split(/\\s+/).map(validateId)\n\n const seen = new Set<string>()\n for (const id of [...columns.flatMap((c) => c.panes), ...floats]) {\n if (seen.has(id)) {\n throw new Error(`layout notation: pane id 重複 \"${id}\"`)\n }\n seen.add(id)\n }\n\n return { structure: { columns }, floats }\n}\n\n/** 構造 + float 集合 → 正準形の記法文字列。parse(format(x)) が deep-equal になる */\nexport function formatNotation(structure: Structure, floats: readonly string[] = []): string {\n const seen = new Set<string>()\n for (const id of [...structure.columns.flatMap((c) => [...c.panes]), ...floats]) {\n validateId(id)\n if (seen.has(id)) {\n throw new Error(`layout notation: pane id 重複 \"${id}\"`)\n }\n seen.add(id)\n }\n for (const col of structure.columns) {\n if (col.panes.length === 0) {\n throw new Error('layout notation: 空の列は直列化できない')\n }\n }\n const cols = structure.columns.map((col) => col.panes.join('/')).join(' | ')\n if (floats.length === 0) return cols\n const floatPart = `~ ${floats.join(' ')}`\n return cols === '' ? floatPart : `${cols} ${floatPart}`\n}\n","/**\n * resolve — normalize の再帰適用(LE-6)。純 calculation、DOM を知らない。\n *\n * 「兄弟集合内で場を正規化する」1 つの演算の再帰適用:\n * レベル 1(row) : 列の実効 attention(max 集約)を正規化 → 幅\n * レベル 2(column): pane の attention を正規化 → 高さ\n *\n * - attention = 0 は正規化から除外(0 = 非表示、LE-3 の 2 規則の 1 つ目)\n * - 非表示の所属 pane は所属位置で面積 0 の rect(morph の収束先)\n * - floating(構造非所属 × attention > 0)は tiled の正規化に参加せず中央に浮く(LE-18)\n * - taper: attention → 面積の知覚写像(既定 = 恒等。曲線は token / dogfood で決める)\n * - viewport 引数なしの純形(content negotiation 延期に伴う、LE-8)\n */\n\nimport { memberIds } from './structure'\nimport type { Layout, ResolvedMap, ResolvedPane } from './types'\n\nexport interface ResolveOptions {\n /** 知覚テーパー。taper(x) > 0 for x > 0 を要求(0 の扱いは resolve が持つ) */\n taper?: (raw: number) => number\n}\n\nconst identity = (n: number): number => n\n\nexport function resolve(layout: Layout, options: ResolveOptions = {}): ResolvedMap {\n const taper = options.taper ?? identity\n const att = layout.attention\n\n /**\n * 実効 attention: 0 は 0 のまま(taper は正値にのみ適用)。\n * 非有限(NaN / Infinity)は 0 = 非表示に倒す — 壊れた値は「何も描かない」に落とし、\n * xCursor 経由で兄弟の座標を汚染させない(MCP propose 等、gesture を経ない入力経路がある)\n */\n const eff = (id: string): number => {\n const raw = att[id] ?? 0\n if (!Number.isFinite(raw) || raw <= 0) return 0\n const tapered = taper(raw)\n return Number.isFinite(tapered) && tapered > 0 ? tapered : 0\n }\n\n const members = new Set(memberIds(layout.structure))\n\n // share の分母 = 全可視 pane(tiled + floating)の実効値合計。非可視は eff = 0 で自然に落ちる\n let globalSum = 0\n for (const id of Object.keys(att)) {\n globalSum += eff(id)\n }\n\n // 列の実効 attention(max 集約 — 列の幅はその列で一番見たいものが決める、OQ-1)\n const colEffs = layout.structure.columns.map((col) =>\n col.panes.reduce((m, p) => Math.max(m, eff(p)), 0),\n )\n const totalW = colEffs.reduce((s, v) => s + v, 0)\n\n const out: Record<string, ResolvedPane> = {}\n\n // tiled 層\n let xCursor = 0\n layout.structure.columns.forEach((col, ci) => {\n const colEff = colEffs[ci] ?? 0\n const visible = colEff > 0 && totalW > 0\n const colW = visible ? colEff / totalW : 0\n const colX = xCursor\n const sumH = col.panes.reduce((s, p) => s + eff(p), 0)\n let yCursor = 0\n for (const p of col.panes) {\n const e = eff(p)\n if (e > 0 && sumH > 0) {\n const h = e / sumH\n out[p] = {\n rect: { x: colX, y: yCursor, w: colW, h },\n attention: globalSum > 0 ? e / globalSum : 0,\n floating: false,\n }\n yCursor += h\n } else {\n // 非表示: 所属位置で面積 0 に収束(LE-3 / interpolate の収束先)\n out[p] = {\n rect: { x: colX, y: yCursor, w: visible ? colW : 0, h: 0 },\n attention: 0,\n floating: false,\n }\n }\n }\n xCursor += colW\n })\n\n // floating 層(構造非所属 × attention > 0。非所属 × 0 = 外なので emit しない)\n for (const id of Object.keys(att)) {\n if (members.has(id)) continue\n const e = eff(id)\n if (e <= 0) continue\n const share = globalSum > 0 ? e / globalSum : 0\n const size = Math.min(1, share)\n out[id] = {\n rect: { x: (1 - size) / 2, y: (1 - size) / 2, w: size, h: size },\n attention: share,\n floating: true,\n }\n }\n\n return out\n}\n","/**\n * interpolate — 唯一の遷移 primitive(LE-7)。\n *\n * 時間は protocol の外: t を与えるのは driver(time / hand / jump)。\n * reduced-motion は「jump driver の選択」に落ち、ここには分岐が無い。\n *\n * 端点に居ない pane は「相手側 rect の中心で面積 0」へ収束 — 消える動きも\n * 現れる動きも同じ規則(非表示 = 所属位置で 0 収束、と同じ幾何)。\n */\n\nimport type { Rect, ResolvedMap, ResolvedPane } from './types'\n\nconst lerp = (a: number, b: number, t: number): number => a + (b - a) * t\n\n/** rect の中心に面積 0 で潰した rect(欠員側の合成端点) */\nfunction collapse(rect: Rect): Rect {\n return { x: rect.x + rect.w / 2, y: rect.y + rect.h / 2, w: 0, h: 0 }\n}\n\nfunction ghostOf(present: ResolvedPane): ResolvedPane {\n return { rect: collapse(present.rect), attention: 0, floating: present.floating }\n}\n\nexport function interpolate(a: ResolvedMap, b: ResolvedMap, t: number): ResolvedMap {\n // NaN(duration 0 の time driver の 0/0 等)は jump(t = 1)に倒す —\n // Math.min/max は NaN を素通しするため明示ガードが要る\n const clamped = Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 1\n // 端点は正確に一致させる(property: interpolate(A, B, 0) = A / (…, 1) = B)\n if (clamped === 0) return a\n if (clamped === 1) return b\n\n const out: Record<string, ResolvedPane> = {}\n const ids = new Set([...Object.keys(a), ...Object.keys(b)])\n for (const id of ids) {\n const fromB = b[id]\n const fromA = a[id]\n const pa = fromA ?? ghostOf(fromB as ResolvedPane)\n const pb = fromB ?? ghostOf(fromA as ResolvedPane)\n out[id] = {\n rect: {\n x: lerp(pa.rect.x, pb.rect.x, clamped),\n y: lerp(pa.rect.y, pb.rect.y, clamped),\n w: lerp(pa.rect.w, pb.rect.w, clamped),\n h: lerp(pa.rect.h, pb.rect.h, clamped),\n },\n attention: lerp(pa.attention, pb.attention, clamped),\n floating: clamped < 0.5 ? pa.floating : pb.floating,\n }\n }\n return out\n}\n","/**\n * gestures — 場と構造への純操作(LE-3/16/18/20)。\n *\n * 全関数は Layout → Layout の純関数。無変更(no-op / guard による拒否)なら\n * 同一参照を返す — 呼び手が「効かなかった」を検知できる。\n *\n * - 量子化(equalize 等の snap)はここ = UI 作法の層。場そのものは連続のまま\n * - share 指定: touched の取り分を固定し untouched は余りを比例配分(VCA と同型)\n * - 全零 guard: 場を全零にする変更は拒否(最後の 1 枚、LE-3 の 2 規則の 2 つ目)\n * - dominance = argmax(主役 = 最大面積)。keyboard focus ではない(LE-20)\n */\n\nimport { appendColumn, insertIntoColumn, isMember, memberIds, removePane } from './structure'\nimport type { Attention, Layout } from './types'\n\n/** 場に正の値を持つ pane id(tiled + floating) */\nexport function visibleIds(layout: Layout): string[] {\n return Object.keys(layout.attention).filter((id) => (layout.attention[id] ?? 0) > 0)\n}\n\nfunction withAttention(layout: Layout, attention: Attention): Layout {\n return { structure: layout.structure, attention }\n}\n\n/** share の上限(1 に漸近すると raw が発散するため) */\nconst MAX_SHARE = 0.99\n\n/**\n * share 直接指定(knob / float リサイズの実体)。\n * raw_id = share / (1 - share) × Σ(他の可視 raw) — untouched の raw は不変のまま、\n * 正規化で全員の share が動く(モータライズノブが「連動して動く」の根拠)。\n */\nexport function setShare(layout: Layout, id: string, share: number): Layout {\n if (share <= 0) return mute(layout, id)\n const s = Math.min(share, MAX_SHARE)\n const others = visibleIds(layout)\n .filter((v) => v !== id)\n .reduce((sum, v) => sum + (layout.attention[v] ?? 0), 0)\n if (others <= 0) {\n // 他に可視が居ない = share は常に 1。可視であることだけ保証する\n const prev = layout.attention[id] ?? 0\n if (prev > 0) return layout\n return withAttention(layout, { ...layout.attention, [id]: 1 })\n }\n const raw = (s / (1 - s)) * others\n return withAttention(layout, { ...layout.attention, [id]: raw })\n}\n\n/** 非表示(= 0)。最後の可視 1 枚は拒否(全零 guard) */\nexport function mute(layout: Layout, id: string): Layout {\n if ((layout.attention[id] ?? 0) <= 0) return layout\n const visible = visibleIds(layout)\n if (visible.length <= 1) return layout\n return withAttention(layout, { ...layout.attention, [id]: 0 })\n}\n\n/**\n * 独占(9 の残滓 = mixer の solo)。指定 pane 以外を 0 に。\n * un-solo は engine の「last settle へ復帰」で行う(一時状態の統一)。\n */\nexport function solo(layout: Layout, id: string): Layout {\n const prev = layout.attention[id] ?? 0\n const raw = prev > 0 ? prev : 1\n const attention: Record<string, number> = {}\n for (const key of Object.keys(layout.attention)) attention[key] = 0\n attention[id] = raw\n return withAttention(layout, attention)\n}\n\n/** 等分 snap(UI 作法の量子化 — 場は raw 同値で表現する) */\nexport function equalize(layout: Layout, ids?: readonly string[]): Layout {\n const targets = ids ?? visibleIds(layout)\n if (targets.length === 0) return layout\n const attention = { ...layout.attention } as Record<string, number>\n for (const id of targets) attention[id] = 1\n return withAttention(layout, attention)\n}\n\nexport type DominanceDirection = 'left' | 'right' | 'up' | 'down'\n\n/**\n * dominance(argmax)の空間移動 — 2D cyclic(横 = 列間 / 縦 = 列内)。\n * 実装は raw 値の swap: 場の multiset を保存し、位置だけが入れ替わる。\n * dominant が floating の間は no-op(浮きは列に居ない)。\n */\nexport function moveDominance(layout: Layout, dir: DominanceDirection): Layout {\n const att = layout.attention\n const members = memberIds(layout.structure)\n const memberSet = new Set(members)\n const visibleMembers = members.filter((id) => (att[id] ?? 0) > 0)\n const visibleFloats = Object.keys(att).filter((id) => !memberSet.has(id) && (att[id] ?? 0) > 0)\n const candidates = [...visibleMembers, ...visibleFloats]\n if (candidates.length === 0) return layout\n\n let dominant = candidates[0] as string\n for (const id of candidates) {\n if ((att[id] ?? 0) > (att[dominant] ?? 0)) dominant = id\n }\n if (!memberSet.has(dominant)) return layout\n\n // 可視 pane を持つ列だけの格子で移動する\n const visibleColumns = layout.structure.columns\n .map((col) => col.panes.filter((p) => (att[p] ?? 0) > 0))\n .filter((panes) => panes.length > 0)\n const colIndex = visibleColumns.findIndex((panes) => panes.includes(dominant))\n if (colIndex < 0) return layout\n const column = visibleColumns[colIndex] as string[]\n\n let target: string\n if (dir === 'left' || dir === 'right') {\n const delta = dir === 'right' ? 1 : -1\n const nextCol = visibleColumns[\n (colIndex + delta + visibleColumns.length) % visibleColumns.length\n ] as string[]\n let best = nextCol[0] as string\n for (const p of nextCol) {\n if ((att[p] ?? 0) > (att[best] ?? 0)) best = p\n }\n target = best\n } else {\n const paneIndex = column.indexOf(dominant)\n const delta = dir === 'down' ? 1 : -1\n target = column[(paneIndex + delta + column.length) % column.length] as string\n }\n if (target === dominant) return layout\n\n return withAttention(layout, {\n ...att,\n [dominant]: att[target] ?? 0,\n [target]: att[dominant] ?? 0,\n })\n}\n\nexport interface AdmitOptions {\n /** 入れる列 index(省略 = 末尾に新規列) */\n column?: number\n /** 初期 share(省略 = 可視 pane の raw 平均で入る) */\n share?: number\n}\n\n/**\n * 入場 — 新 pane は tiled 直入り(float 入場は不採用、mako 2026-07-22)。\n * 既定 = 末尾に新規列、attention = 可視 pane の raw 平均(居なければ 1)。\n */\nexport function admit(layout: Layout, id: string, opts: AdmitOptions = {}): Layout {\n if (isMember(layout.structure, id)) return layout\n const structure =\n opts.column != null\n ? insertIntoColumn(layout.structure, id, opts.column)\n : appendColumn(layout.structure, id)\n const visible = visibleIds(layout).filter((v) => v !== id)\n const mean =\n visible.length > 0\n ? visible.reduce((s, v) => s + (layout.attention[v] ?? 0), 0) / visible.length\n : 1\n const prev = layout.attention[id] ?? 0\n const raw = prev > 0 ? prev : mean\n const admitted: Layout = { structure, attention: { ...layout.attention, [id]: raw } }\n return opts.share != null ? setShare(admitted, id, opts.share) : admitted\n}\n\n/** tiled → floating(構造から抜くだけ。場は不変 = サイズが保存される) */\nexport function popOut(layout: Layout, id: string): Layout {\n const structure = removePane(layout.structure, id)\n if (structure === layout.structure) return layout\n return { structure, attention: layout.attention }\n}\n\n/** floating → tiled(構造へ戻すだけ。場は不変)。既定 = 末尾に新規列 */\nexport function popIn(layout: Layout, id: string, column?: number): Layout {\n if (isMember(layout.structure, id)) return layout\n const structure =\n column != null\n ? insertIntoColumn(layout.structure, id, column)\n : appendColumn(layout.structure, id)\n return { structure, attention: layout.attention }\n}\n","/**\n * engine — scope key ごとの Layout + settle log を束ねる(LE-11/17/18)。\n *\n * - scope: layout state の単位を型で明示(VP = lane、site = route 等。doc 47 §0 の教訓)\n * - settle log: 履歴 = 無名 Scene の列。永続 = log の末尾(consumer が保存し、復元は\n * 最後の entry を apply するだけ)。連続の knob stream は記録しない\n * - 一時状態(solo / Touch / scrub 逸脱)の戻り先 = last settle(restoreLastSettle)\n * - float の位置は ephemeral(Scene / log / token に直列化しない、LE-18)\n * - DOM 反映(action)は subscribe の外側 — renderer / MIDI motor が resolved を写す\n */\n\nimport { resolve } from './resolve'\nimport type { Layout, ResolvedMap, ResolvedPane, Scene } from './types'\nimport { EMPTY_LAYOUT } from './types'\n\nexport type SettleAuthor = 'human' | 'ai' | 'scene'\n\nexport interface SettleEntry {\n readonly layout: Layout\n readonly at: number\n readonly author: SettleAuthor\n}\n\nexport interface FloatPosition {\n readonly x: number\n readonly y: number\n}\n\nexport type ResolvedListener = (scope: string, resolved: ResolvedMap) => void\n\nexport interface LayoutEngineOptions {\n /** テスト用の時計注入(既定 = Date.now) */\n clock?: () => number\n /** 知覚テーパー(resolve に渡る) */\n taper?: (raw: number) => number\n}\n\nexport interface LayoutEngine {\n current(scope: string): Layout\n /** 場・構造の変更(gesture 純関数を渡す)。settle は別途(連続操作の途中は log しない) */\n update(scope: string, fn: (layout: Layout) => Layout): void\n /** Scene の total recall(LE-14)。preset は複製され mutate されない。author = \"scene\" で settle */\n applyScene(scope: string, scene: Scene): void\n /** 形が定まった瞬間を log に刻む(gesture release / AI apply 等、呼び手が判断) */\n settle(scope: string, author: SettleAuthor): void\n history(scope: string): readonly SettleEntry[]\n /** 一時状態(solo / Touch / scrub 逸脱)からの復帰先 = last settle */\n restoreLastSettle(scope: string): boolean\n /** float の一時的な移動(ephemeral — log / Scene に入らない)。pos は左上 0..1 */\n moveFloat(scope: string, id: string, pos: FloatPosition): void\n resolved(scope: string): ResolvedMap\n subscribe(listener: ResolvedListener): () => void\n}\n\ninterface ScopeState {\n layout: Layout\n log: SettleEntry[]\n floatPos: Map<string, FloatPosition>\n}\n\nconst clamp01 = (n: number): number => Math.min(1, Math.max(0, n))\n\n/** Layout の構造的複製(純 data なので手書きで足りる — structuredClone = DOM API に依存しない) */\nconst cloneLayout = (layout: Layout): Layout => ({\n structure: { columns: layout.structure.columns.map((col) => ({ panes: [...col.panes] })) },\n attention: { ...layout.attention },\n})\n\nexport function createLayoutEngine(options: LayoutEngineOptions = {}): LayoutEngine {\n const clock = options.clock ?? (() => Date.now())\n const taper = options.taper\n const scopes = new Map<string, ScopeState>()\n const listeners = new Set<ResolvedListener>()\n\n const state = (scope: string): ScopeState => {\n let s = scopes.get(scope)\n if (!s) {\n s = { layout: EMPTY_LAYOUT, log: [], floatPos: new Map() }\n scopes.set(scope, s)\n }\n return s\n }\n\n /** resolve + ephemeral float 位置の合成(枠外に出ない範囲へ clamp) */\n const project = (s: ScopeState): ResolvedMap => {\n const base = resolve(s.layout, { taper })\n // 浮いていない pane の位置は捨てる(ephemeral の自然な寿命)\n for (const id of [...s.floatPos.keys()]) {\n if (!base[id]?.floating) s.floatPos.delete(id)\n }\n if (s.floatPos.size === 0) return base\n const out: Record<string, ResolvedPane> = { ...base }\n for (const [id, pos] of s.floatPos) {\n const pane = out[id]\n if (!pane) continue\n out[id] = {\n ...pane,\n rect: {\n ...pane.rect,\n x: clamp01(Math.min(pos.x, 1 - pane.rect.w)),\n y: clamp01(Math.min(pos.y, 1 - pane.rect.h)),\n },\n }\n }\n return out\n }\n\n const notify = (scope: string): void => {\n const projected = project(state(scope))\n for (const listener of listeners) listener(scope, projected)\n }\n\n return {\n current(scope) {\n return state(scope).layout\n },\n update(scope, fn) {\n const s = state(scope)\n s.layout = fn(s.layout)\n notify(scope)\n },\n applyScene(scope, scene) {\n const s = state(scope)\n s.layout = cloneLayout(scene.layout)\n s.log.push({ layout: cloneLayout(s.layout), at: clock(), author: 'scene' })\n notify(scope)\n },\n settle(scope, author) {\n const s = state(scope)\n s.log.push({ layout: cloneLayout(s.layout), at: clock(), author })\n },\n history(scope) {\n return [...state(scope).log]\n },\n restoreLastSettle(scope) {\n const s = state(scope)\n const last = s.log[s.log.length - 1]\n if (!last) return false\n s.layout = cloneLayout(last.layout)\n notify(scope)\n return true\n },\n moveFloat(scope, id, pos) {\n state(scope).floatPos.set(id, { x: clamp01(pos.x), y: clamp01(pos.y) })\n notify(scope)\n },\n resolved(scope) {\n return project(state(scope))\n },\n subscribe(listener) {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n }\n}\n"],"names":["EMPTY_LAYOUT","memberIds","structure","col","isMember","id","removePane","p","appendColumn","insertIntoColumn","columnIndex","i","ID_RE","validateId","parseNotation","text","parts","left","right","columns","segment","trimmed","s","floats","seen","c","formatNotation","cols","floatPart","identity","n","resolve","layout","options","taper","att","eff","raw","tapered","members","globalSum","colEffs","m","totalW","v","out","xCursor","ci","colEff","visible","colW","colX","sumH","yCursor","e","h","share","size","lerp","a","b","t","collapse","rect","ghostOf","present","interpolate","clamped","ids","fromB","fromA","pa","pb","visibleIds","withAttention","attention","MAX_SHARE","setShare","mute","others","sum","solo","prev","key","equalize","targets","moveDominance","dir","memberSet","visibleMembers","visibleFloats","candidates","dominant","visibleColumns","panes","colIndex","column","target","nextCol","best","paneIndex","admit","opts","mean","admitted","popOut","popIn","clamp01","cloneLayout","createLayoutEngine","clock","scopes","listeners","state","scope","project","base","pos","pane","notify","projected","listener","fn","scene","author","last"],"mappings":"AA+DO,MAAMA,IAAuB,OAAO,OAAO;AAAA,EAChD,WAAW,OAAO,OAAO,EAAE,SAAS,OAAO,OAAO,CAAA,CAAE,GAAG;AAAA,EACvD,WAAW,OAAO,OAAO,CAAA,CAAE;AAC7B,CAAC;ACxDM,SAASC,EAAUC,GAAgC;AACxD,SAAOA,EAAU,QAAQ,QAAQ,CAACC,MAAQ,CAAC,GAAGA,EAAI,KAAK,CAAC;AAC1D;AAEO,SAASC,EAASF,GAAsBG,GAAqB;AAClE,SAAOH,EAAU,QAAQ,KAAK,CAACC,MAAQA,EAAI,MAAM,SAASE,CAAE,CAAC;AAC/D;AAGO,SAASC,EAAWJ,GAAsBG,GAAuB;AACtE,SAAKD,EAASF,GAAWG,CAAE,IAIpB,EAAE,SAHOH,EAAU,QACvB,IAAI,CAACC,OAAS,EAAE,OAAOA,EAAI,MAAM,OAAO,CAACI,MAAMA,MAAMF,CAAE,IAAI,EAC3D,OAAO,CAACF,MAAQA,EAAI,MAAM,SAAS,CAAC,EAC9B,IAJ4BD;AAKvC;AAGO,SAASM,EAAaN,GAAsBG,GAAuB;AACxE,SAAO,EAAE,SAAS,CAAC,GAAGH,EAAU,SAAS,EAAE,OAAO,CAACG,CAAE,EAAA,CAAG,EAAA;AAC1D;AAGO,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AIA,EAAE,IAAI,SAAS,CAAC;AACnC,aAAKuG,KACLvG,EAAE,SAASsF,EAAYiB,EAAK,MAAM,GAClCN,EAAOL,CAAK,GACL,MAHW;AAAA,IAIpB;AAAA,IACA,UAAUA,GAAO7G,GAAIgH,GAAK;AACxB,MAAAJ,EAAMC,CAAK,EAAE,SAAS,IAAI7G,GAAI,EAAE,GAAGsG,EAAQU,EAAI,CAAC,GAAG,GAAGV,EAAQU,EAAI,CAAC,GAAG,GACtEE,EAAOL,CAAK;AAAA,IACd;AAAA,IACA,SAASA,GAAO;AACd,aAAOC,EAAQF,EAAMC,CAAK,CAAC;AAAA,IAC7B;AAAA,IACA,UAAUO,GAAU;AAClB,aAAAT,EAAU,IAAIS,CAAQ,GACf,MAAM;AACX,QAAAT,EAAU,OAAOS,CAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/types.ts","../src/structure.ts","../src/notation.ts","../src/resolve.ts","../src/interpolate.ts","../src/gestures.ts","../src/engine.ts","../src/drivers.ts","../src/policy.ts"],"sourcesContent":["/**\n * Layout Engine — protocol types(LE-P0)。\n *\n * 設計 SSOT: docs/design/layout-engine.md(LE-1〜LE-20)。\n * 場(attention)が唯一のサイズ真実源(LE-3)、構造は軸交代 + 所属のみ(LE-4/5)。\n * keyboard focus は protocol の関心外(LE-20 — DOM / consumer の領分)。\n */\n\n/** pane identity — 「何が存在するか」は consumer 供給(LE-11/12)。primitive は kind を意味づけしない */\nexport interface PaneRef {\n readonly id: string\n readonly kind?: string\n readonly label?: string\n}\n\n/** 列 = 副軸(縦)の並び。構造はサイズを持たない(LE-4) */\nexport interface Column {\n readonly panes: readonly string[]\n}\n\n/** 主軸 = 水平の列並び。軸交代はここで打ち止め(LE-5、arity は無制限) */\nexport interface Structure {\n readonly columns: readonly Column[]\n}\n\n/**\n * 場: pane id → raw attention(≥ 0)。0 = 非表示(LE-3)。\n * 格納は raw、操作/表示は share(正規化後の取り分)— 二重読みは gestures / resolve が担う。\n */\nexport type Attention = Readonly<Record<string, number>>\n\nexport interface Layout {\n readonly structure: Structure\n readonly attention: Attention\n /**\n * 列幅 lock(LE-21、fader lock の幅版): pane id → 幅 share ∈ (0, 1)。\n * その pane を**含む列**の幅を固定し、残りの列が余りを正規化する。\n * サイズ情報なので構造/記法には入らず場の側に住む(LE-4)。px 固定は consumer が\n * resize 時に fraction を再計算して更新する(viewport は protocol の外、LE-9)。\n * 非所属 pane の lock は休眠(popIn で復活)。\n */\n readonly locks?: Readonly<Record<string, number>>\n}\n\n/** Scene = Layout の名前付き immutable snapshot = 注視の表現 = scrub の端点(LE-14) */\nexport interface Scene {\n readonly id: string\n readonly name: string\n readonly layout: Layout\n readonly description?: string\n}\n\n/** 0..1 連続の矩形。量子化は投影の縁でやる(LE-9 — ここでは丸めない) */\nexport interface Rect {\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n}\n\n/** resolve の出力 1 pane 分 */\nexport interface ResolvedPane {\n readonly rect: Rect\n /** 全可視 pane に対する share。遠近・明暗への射影は platform 判断(frame F-3) */\n readonly attention: number\n readonly floating: boolean\n}\n\nexport type ResolvedMap = Readonly<Record<string, ResolvedPane>>\n\n/** 空 Layout。全 scope の初期値として共有されるため freeze(in-place mutation 事故の構造的防止) */\nexport const EMPTY_LAYOUT: Layout = Object.freeze({\n structure: Object.freeze({ columns: Object.freeze([]) }),\n attention: Object.freeze({}),\n})\n","/**\n * 構造の純操作(LE-4/5)。\n *\n * 構造が持つのは「軸の交代」と「所属」だけ — サイズ情報は一切持たない。\n * 全関数は新しい Structure を返す(無変更なら同一参照を返し、呼び手が no-op を検知できる)。\n */\n\nimport type { Structure } from './types'\n\n/** 所属 pane id を構造順(列順 → 列内順)で返す */\nexport function memberIds(structure: Structure): string[] {\n return structure.columns.flatMap((col) => [...col.panes])\n}\n\nexport function isMember(structure: Structure, id: string): boolean {\n return structure.columns.some((col) => col.panes.includes(id))\n}\n\n/** pane を構造から抜く(空になった列は落とす)。非所属なら同一参照 */\nexport function removePane(structure: Structure, id: string): Structure {\n if (!isMember(structure, id)) return structure\n const columns = structure.columns\n .map((col) => ({ panes: col.panes.filter((p) => p !== id) }))\n .filter((col) => col.panes.length > 0)\n return { columns }\n}\n\n/** 末尾に新規列として pane を足す */\nexport function appendColumn(structure: Structure, id: string): Structure {\n return { columns: [...structure.columns, { panes: [id] }] }\n}\n\n/** 指定列の末尾に pane を足す。列 index が範囲外なら新規列(appendColumn)に落ちる */\nexport function insertIntoColumn(structure: Structure, id: string, columnIndex: number): Structure {\n if (columnIndex < 0 || columnIndex >= structure.columns.length) {\n return appendColumn(structure, id)\n }\n const columns = structure.columns.map((col, i) =>\n i === columnIndex ? { panes: [...col.panes, id] } : col,\n )\n return { columns }\n}\n","/**\n * 記法 — トポロジーの直列化(LE-4)。\n *\n * \"ec | cv/pp ~ board\"\n * | = 列の区切り(軸の交代)\n * / = 列内の縦の並び\n * ~ = floating(構造非所属で場に居る pane の明示)\n *\n * サイズ(数字)は書かない — サイズは場の領分。二重 SSOT を構造的に排除する。\n * parse / format は往復テストで固定(対の写像の規律)。\n */\n\nimport type { Structure } from './types'\n\n/** id に使える文字: 区切り記号(| / ~)と空白以外 */\nconst ID_RE = /^[^\\s|/~]+$/\n\nexport interface ParsedNotation {\n readonly structure: Structure\n /** 構造非所属で場に居る pane(floating)。場の値そのものは記法の外(attention record が持つ) */\n readonly floats: readonly string[]\n}\n\nfunction validateId(id: string): string {\n if (!ID_RE.test(id)) {\n throw new Error(`layout notation: 不正な pane id \"${id}\"(空白と | / ~ は使えない)`)\n }\n return id\n}\n\n/** 記法文字列 → 構造 + float 集合。不正入力は throw */\nexport function parseNotation(text: string): ParsedNotation {\n const parts = text.split('~')\n if (parts.length > 2) {\n throw new Error('layout notation: float 区切り ~ は 1 つまで')\n }\n const left = (parts[0] ?? '').trim()\n const right = (parts[1] ?? '').trim()\n\n const columns =\n left === ''\n ? []\n : left.split('|').map((segment) => {\n const trimmed = segment.trim()\n if (trimmed === '') {\n throw new Error('layout notation: 空の列(| の間に pane が無い)')\n }\n const panes = trimmed.split('/').map((s) => {\n const id = s.trim()\n if (id === '') {\n throw new Error('layout notation: 空の pane(/ の間に id が無い)')\n }\n return validateId(id)\n })\n return { panes }\n })\n\n const floats = right === '' ? [] : right.split(/\\s+/).map(validateId)\n\n const seen = new Set<string>()\n for (const id of [...columns.flatMap((c) => c.panes), ...floats]) {\n if (seen.has(id)) {\n throw new Error(`layout notation: pane id 重複 \"${id}\"`)\n }\n seen.add(id)\n }\n\n return { structure: { columns }, floats }\n}\n\n/** 構造 + float 集合 → 正準形の記法文字列。parse(format(x)) が deep-equal になる */\nexport function formatNotation(structure: Structure, floats: readonly string[] = []): string {\n const seen = new Set<string>()\n for (const id of [...structure.columns.flatMap((c) => [...c.panes]), ...floats]) {\n validateId(id)\n if (seen.has(id)) {\n throw new Error(`layout notation: pane id 重複 \"${id}\"`)\n }\n seen.add(id)\n }\n for (const col of structure.columns) {\n if (col.panes.length === 0) {\n throw new Error('layout notation: 空の列は直列化できない')\n }\n }\n const cols = structure.columns.map((col) => col.panes.join('/')).join(' | ')\n if (floats.length === 0) return cols\n const floatPart = `~ ${floats.join(' ')}`\n return cols === '' ? floatPart : `${cols} ${floatPart}`\n}\n","/**\n * resolve — normalize の再帰適用(LE-6)。純 calculation、DOM を知らない。\n *\n * 「兄弟集合内で場を正規化する」1 つの演算の再帰適用:\n * レベル 1(row) : 列の実効 attention(max 集約)を正規化 → 幅\n * レベル 2(column): pane の attention を正規化 → 高さ\n *\n * - attention = 0 は正規化から除外(0 = 非表示、LE-3 の 2 規則の 1 つ目)\n * - 非表示の所属 pane は所属位置で面積 0 の rect(morph の収束先)\n * - floating(構造非所属 × attention > 0)は tiled の正規化に参加せず中央に浮く(LE-18)\n * - taper: attention → 面積の知覚写像(既定 = 恒等。曲線は token / dogfood で決める)\n * - viewport 引数なしの純形(content negotiation 延期に伴う、LE-8)\n */\n\nimport { memberIds } from './structure'\nimport type { Layout, ResolvedMap, ResolvedPane } from './types'\n\nexport interface ResolveOptions {\n /** 知覚テーパー。taper(x) > 0 for x > 0 を要求(0 の扱いは resolve が持つ) */\n taper?: (raw: number) => number\n}\n\nconst identity = (n: number): number => n\n\nexport function resolve(layout: Layout, options: ResolveOptions = {}): ResolvedMap {\n const taper = options.taper ?? identity\n const att = layout.attention\n\n /**\n * 実効 attention: 0 は 0 のまま(taper は正値にのみ適用)。\n * 非有限(NaN / Infinity)は 0 = 非表示に倒す — 壊れた値は「何も描かない」に落とし、\n * xCursor 経由で兄弟の座標を汚染させない(MCP propose 等、gesture を経ない入力経路がある)\n */\n const eff = (id: string): number => {\n const raw = att[id] ?? 0\n if (!Number.isFinite(raw) || raw <= 0) return 0\n const tapered = taper(raw)\n return Number.isFinite(tapered) && tapered > 0 ? tapered : 0\n }\n\n const members = new Set(memberIds(layout.structure))\n\n // share の分母 = 全可視 pane(tiled + floating)の実効値合計。非可視は eff = 0 で自然に落ちる\n let globalSum = 0\n for (const id of Object.keys(att)) {\n globalSum += eff(id)\n }\n\n // 列の実効 attention(max 集約 — 列の幅はその列で一番見たいものが決める、OQ-1)\n const colEffs = layout.structure.columns.map((col) =>\n col.panes.reduce((m, p) => Math.max(m, eff(p)), 0),\n )\n\n // 列幅 lock(LE-21): 列内 pane の lock の最大値。可視列にのみ効く(不可視・非所属は休眠)\n const locks = layout.locks ?? {}\n const colLocks = layout.structure.columns.map((col, ci) => {\n if ((colEffs[ci] ?? 0) <= 0) return 0\n return col.panes.reduce((m, p) => {\n const v = locks[p] ?? 0\n return Number.isFinite(v) && v > 0 ? Math.max(m, Math.min(v, 1)) : m\n }, 0)\n })\n const lockSumRaw = colLocks.reduce((s, v) => s + v, 0)\n const unlockedEffSum = colEffs.reduce((s, v, ci) => ((colLocks[ci] ?? 0) > 0 ? s : s + v), 0)\n // 幅和 = 1 を常に保つ: 過剰 lock は比例縮小(unlocked は 0 幅まで潰れうる)、\n // locked しか可視で無ければ正規化して埋める\n const lockScale =\n lockSumRaw <= 0 ? 0 : unlockedEffSum > 0 ? Math.min(1, 1 / lockSumRaw) : 1 / lockSumRaw\n const remaining = Math.max(0, 1 - lockSumRaw * lockScale)\n\n const out: Record<string, ResolvedPane> = {}\n\n // tiled 層\n let xCursor = 0\n layout.structure.columns.forEach((col, ci) => {\n const colEff = colEffs[ci] ?? 0\n const visible = colEff > 0\n const colLock = (colLocks[ci] ?? 0) * lockScale\n const colW = !visible\n ? 0\n : colLock > 0\n ? colLock\n : unlockedEffSum > 0\n ? remaining * (colEff / unlockedEffSum)\n : 0\n const colX = xCursor\n const sumH = col.panes.reduce((s, p) => s + eff(p), 0)\n let yCursor = 0\n for (const p of col.panes) {\n const e = eff(p)\n if (e > 0 && sumH > 0) {\n const h = e / sumH\n out[p] = {\n rect: { x: colX, y: yCursor, w: colW, h },\n attention: globalSum > 0 ? e / globalSum : 0,\n floating: false,\n }\n yCursor += h\n } else {\n // 非表示: 所属位置で面積 0 に収束(LE-3 / interpolate の収束先)\n out[p] = {\n rect: { x: colX, y: yCursor, w: visible ? colW : 0, h: 0 },\n attention: 0,\n floating: false,\n }\n }\n }\n xCursor += colW\n })\n\n // floating 層(構造非所属 × attention > 0。非所属 × 0 = 外なので emit しない)\n for (const id of Object.keys(att)) {\n if (members.has(id)) continue\n const e = eff(id)\n if (e <= 0) continue\n const share = globalSum > 0 ? e / globalSum : 0\n const size = Math.min(1, share)\n out[id] = {\n rect: { x: (1 - size) / 2, y: (1 - size) / 2, w: size, h: size },\n attention: share,\n floating: true,\n }\n }\n\n return out\n}\n","/**\n * interpolate — 唯一の遷移 primitive(LE-7)。\n *\n * 時間は protocol の外: t を与えるのは driver(time / hand / jump)。\n * reduced-motion は「jump driver の選択」に落ち、ここには分岐が無い。\n *\n * 端点に居ない pane は「相手側 rect の中心で面積 0」へ収束 — 消える動きも\n * 現れる動きも同じ規則(非表示 = 所属位置で 0 収束、と同じ幾何)。\n */\n\nimport type { Rect, ResolvedMap, ResolvedPane } from './types'\n\nconst lerp = (a: number, b: number, t: number): number => a + (b - a) * t\n\n/** rect の中心に面積 0 で潰した rect(欠員側の合成端点) */\nfunction collapse(rect: Rect): Rect {\n return { x: rect.x + rect.w / 2, y: rect.y + rect.h / 2, w: 0, h: 0 }\n}\n\nfunction ghostOf(present: ResolvedPane): ResolvedPane {\n return { rect: collapse(present.rect), attention: 0, floating: present.floating }\n}\n\nexport function interpolate(a: ResolvedMap, b: ResolvedMap, t: number): ResolvedMap {\n // NaN(duration 0 の time driver の 0/0 等)は jump(t = 1)に倒す —\n // Math.min/max は NaN を素通しするため明示ガードが要る\n const clamped = Number.isFinite(t) ? Math.min(1, Math.max(0, t)) : 1\n // 端点は正確に一致させる(property: interpolate(A, B, 0) = A / (…, 1) = B)\n if (clamped === 0) return a\n if (clamped === 1) return b\n\n const out: Record<string, ResolvedPane> = {}\n const ids = new Set([...Object.keys(a), ...Object.keys(b)])\n for (const id of ids) {\n const fromB = b[id]\n const fromA = a[id]\n const pa = fromA ?? ghostOf(fromB as ResolvedPane)\n const pb = fromB ?? ghostOf(fromA as ResolvedPane)\n out[id] = {\n rect: {\n x: lerp(pa.rect.x, pb.rect.x, clamped),\n y: lerp(pa.rect.y, pb.rect.y, clamped),\n w: lerp(pa.rect.w, pb.rect.w, clamped),\n h: lerp(pa.rect.h, pb.rect.h, clamped),\n },\n attention: lerp(pa.attention, pb.attention, clamped),\n floating: clamped < 0.5 ? pa.floating : pb.floating,\n }\n }\n return out\n}\n","/**\n * gestures — 場と構造への純操作(LE-3/16/18/20)。\n *\n * 全関数は Layout → Layout の純関数。無変更(no-op / guard による拒否)なら\n * 同一参照を返す — 呼び手が「効かなかった」を検知できる。\n *\n * - 量子化(equalize 等の snap)はここ = UI 作法の層。場そのものは連続のまま\n * - share 指定: touched の取り分を固定し untouched は余りを比例配分(VCA と同型)\n * - 全零 guard: 場を全零にする変更は拒否(最後の 1 枚、LE-3 の 2 規則の 2 つ目)\n * - dominance = argmax(主役 = 最大面積)。keyboard focus ではない(LE-20)\n */\n\nimport { appendColumn, insertIntoColumn, isMember, memberIds, removePane } from './structure'\nimport type { Attention, Layout } from './types'\n\n/** 場に正の値を持つ pane id(tiled + floating) */\nexport function visibleIds(layout: Layout): string[] {\n return Object.keys(layout.attention).filter((id) => (layout.attention[id] ?? 0) > 0)\n}\n\nfunction withAttention(layout: Layout, attention: Attention): Layout {\n return { structure: layout.structure, attention, locks: layout.locks }\n}\n\n/** share の上限(1 に漸近すると raw が発散するため) */\nconst MAX_SHARE = 0.99\n\n/**\n * share 直接指定(knob / float リサイズの実体)。\n * raw_id = share / (1 - share) × Σ(他の可視 raw) — untouched の raw は不変のまま、\n * 正規化で全員の share が動く(モータライズノブが「連動して動く」の根拠)。\n */\nexport function setShare(layout: Layout, id: string, share: number): Layout {\n if (share <= 0) return mute(layout, id)\n const s = Math.min(share, MAX_SHARE)\n const others = visibleIds(layout)\n .filter((v) => v !== id)\n .reduce((sum, v) => sum + (layout.attention[v] ?? 0), 0)\n if (others <= 0) {\n // 他に可視が居ない = share は常に 1。可視であることだけ保証する\n const prev = layout.attention[id] ?? 0\n if (prev > 0) return layout\n return withAttention(layout, { ...layout.attention, [id]: 1 })\n }\n const raw = (s / (1 - s)) * others\n return withAttention(layout, { ...layout.attention, [id]: raw })\n}\n\n/** 非表示(= 0)。最後の可視 1 枚は拒否(全零 guard) */\nexport function mute(layout: Layout, id: string): Layout {\n if ((layout.attention[id] ?? 0) <= 0) return layout\n const visible = visibleIds(layout)\n if (visible.length <= 1) return layout\n return withAttention(layout, { ...layout.attention, [id]: 0 })\n}\n\n/**\n * 独占(9 の残滓 = mixer の solo)。指定 pane 以外を 0 に。\n * un-solo は engine の「last settle へ復帰」で行う(一時状態の統一)。\n */\nexport function solo(layout: Layout, id: string): Layout {\n const prev = layout.attention[id] ?? 0\n const raw = prev > 0 ? prev : 1\n const attention: Record<string, number> = {}\n for (const key of Object.keys(layout.attention)) attention[key] = 0\n attention[id] = raw\n return withAttention(layout, attention)\n}\n\n/** 等分 snap(UI 作法の量子化 — 場は raw 同値で表現する) */\nexport function equalize(layout: Layout, ids?: readonly string[]): Layout {\n const targets = ids ?? visibleIds(layout)\n if (targets.length === 0) return layout\n const attention = { ...layout.attention } as Record<string, number>\n for (const id of targets) attention[id] = 1\n return withAttention(layout, attention)\n}\n\nexport type DominanceDirection = 'left' | 'right' | 'up' | 'down'\n\n/**\n * dominance(argmax)の空間移動 — 2D cyclic(横 = 列間 / 縦 = 列内)。\n * 実装は raw 値の swap: 場の multiset を保存し、位置だけが入れ替わる。\n * dominant が floating の間は no-op(浮きは列に居ない)。\n */\nexport function moveDominance(layout: Layout, dir: DominanceDirection): Layout {\n const att = layout.attention\n const members = memberIds(layout.structure)\n const memberSet = new Set(members)\n const visibleMembers = members.filter((id) => (att[id] ?? 0) > 0)\n const visibleFloats = Object.keys(att).filter((id) => !memberSet.has(id) && (att[id] ?? 0) > 0)\n const candidates = [...visibleMembers, ...visibleFloats]\n if (candidates.length === 0) return layout\n\n let dominant = candidates[0] as string\n for (const id of candidates) {\n if ((att[id] ?? 0) > (att[dominant] ?? 0)) dominant = id\n }\n if (!memberSet.has(dominant)) return layout\n\n // 可視 pane を持つ列だけの格子で移動する\n const visibleColumns = layout.structure.columns\n .map((col) => col.panes.filter((p) => (att[p] ?? 0) > 0))\n .filter((panes) => panes.length > 0)\n const colIndex = visibleColumns.findIndex((panes) => panes.includes(dominant))\n if (colIndex < 0) return layout\n const column = visibleColumns[colIndex] as string[]\n\n let target: string\n if (dir === 'left' || dir === 'right') {\n const delta = dir === 'right' ? 1 : -1\n const nextCol = visibleColumns[\n (colIndex + delta + visibleColumns.length) % visibleColumns.length\n ] as string[]\n let best = nextCol[0] as string\n for (const p of nextCol) {\n if ((att[p] ?? 0) > (att[best] ?? 0)) best = p\n }\n target = best\n } else {\n const paneIndex = column.indexOf(dominant)\n const delta = dir === 'down' ? 1 : -1\n target = column[(paneIndex + delta + column.length) % column.length] as string\n }\n if (target === dominant) return layout\n\n return withAttention(layout, {\n ...att,\n [dominant]: att[target] ?? 0,\n [target]: att[dominant] ?? 0,\n })\n}\n\nexport interface AdmitOptions {\n /** 入れる列 index(省略 = 末尾に新規列) */\n column?: number\n /** 初期 share(省略 = 可視 pane の raw 平均で入る) */\n share?: number\n}\n\n/**\n * 入場 — 新 pane は tiled 直入り(float 入場は不採用、mako 2026-07-22)。\n * 既定 = 末尾に新規列、attention = 可視 pane の raw 平均(居なければ 1)。\n */\nexport function admit(layout: Layout, id: string, opts: AdmitOptions = {}): Layout {\n if (isMember(layout.structure, id)) return layout\n const structure =\n opts.column != null\n ? insertIntoColumn(layout.structure, id, opts.column)\n : appendColumn(layout.structure, id)\n const visible = visibleIds(layout).filter((v) => v !== id)\n const mean =\n visible.length > 0\n ? visible.reduce((s, v) => s + (layout.attention[v] ?? 0), 0) / visible.length\n : 1\n const prev = layout.attention[id] ?? 0\n const raw = prev > 0 ? prev : mean\n const admitted: Layout = {\n structure,\n attention: { ...layout.attention, [id]: raw },\n locks: layout.locks,\n }\n return opts.share != null ? setShare(admitted, id, opts.share) : admitted\n}\n\n/** tiled → floating(構造から抜くだけ。場は不変 = サイズが保存される。lock は休眠) */\nexport function popOut(layout: Layout, id: string): Layout {\n const structure = removePane(layout.structure, id)\n if (structure === layout.structure) return layout\n return { structure, attention: layout.attention, locks: layout.locks }\n}\n\n/** floating → tiled(構造へ戻すだけ。場は不変、休眠 lock は復活)。既定 = 末尾に新規列 */\nexport function popIn(layout: Layout, id: string, column?: number): Layout {\n if (isMember(layout.structure, id)) return layout\n const structure =\n column != null\n ? insertIntoColumn(layout.structure, id, column)\n : appendColumn(layout.structure, id)\n return { structure, attention: layout.attention, locks: layout.locks }\n}\n\n/**\n * 列幅 lock(LE-21、fader lock の幅版)。share = その pane を含む列の幅 share。\n * サイズ情報なので場の側(Layout.locks)に住む — 構造・記法には入らない(LE-4)。\n */\nexport function lock(layout: Layout, id: string, share: number): Layout {\n if (!Number.isFinite(share) || share <= 0) return unlock(layout, id)\n const clamped = Math.min(share, MAX_SHARE)\n return {\n structure: layout.structure,\n attention: layout.attention,\n locks: { ...(layout.locks ?? {}), [id]: clamped },\n }\n}\n\n/** lock 解除。無ければ no-op(同一参照) */\nexport function unlock(layout: Layout, id: string): Layout {\n if (!layout.locks || !(id in layout.locks)) return layout\n const locks: Record<string, number> = { ...layout.locks }\n delete locks[id]\n return {\n structure: layout.structure,\n attention: layout.attention,\n locks: Object.keys(locks).length > 0 ? locks : undefined,\n }\n}\n","/**\n * engine — scope key ごとの Layout + settle log を束ねる(LE-11/17/18)。\n *\n * - scope: layout state の単位を型で明示(VP = lane、site = route 等。doc 47 §0 の教訓)\n * - settle log: 履歴 = 無名 Scene の列。永続 = log の末尾(consumer が保存し、復元は\n * 最後の entry を apply するだけ)。連続の knob stream は記録しない\n * - 一時状態(solo / Touch / scrub 逸脱)の戻り先 = last settle(restoreLastSettle)\n * - float の位置は ephemeral(Scene / log / token に直列化しない、LE-18)\n * - DOM 反映(action)は subscribe の外側 — renderer / MIDI motor が resolved を写す\n * - transition(LE-7/P3): beginTransition が「今の表示」を base snapshot に凍結し、\n * target への scrub を開く。t を進めるのは driver(drivers.ts / consumer)\n */\n\nimport { interpolate } from './interpolate'\nimport { resolve } from './resolve'\nimport type { Layout, ResolvedMap, ResolvedPane, Scene } from './types'\nimport { EMPTY_LAYOUT } from './types'\n\nexport type SettleAuthor = 'human' | 'ai' | 'scene'\n\nexport interface SettleEntry {\n readonly layout: Layout\n readonly at: number\n readonly author: SettleAuthor\n}\n\nexport interface FloatPosition {\n readonly x: number\n readonly y: number\n}\n\nexport type ResolvedListener = (scope: string, resolved: ResolvedMap) => void\n\n/**\n * 進行中の遷移への操作面(LE-7)。t を進めるのは driver(time / hand / jump)で、\n * handle は「どこまで来たか」と「どちらに着地するか」だけを扱う。\n *\n * base は begin 時点の**投影 snapshot**(ResolvedMap)— scrub の中間形は構造の離散性を\n * rect 空間で回避したものなので Layout に逆変換できない。着地は常に端点:\n * commit = target が current になる / cancel = 元の layout のまま。\n *\n * seize(update / moveFloat / applyScene / restoreLastSettle)や後続の beginTransition で\n * 遷移が破棄されたら done = true になり、以降の全メソッドは no-op(stale handle は無害)。\n */\nexport interface TransitionHandle {\n readonly scope: string\n /** 現在の t ∈ [0, 1] */\n readonly t: number\n /** commit / cancel / seize 済みなら true(以降の操作は no-op) */\n readonly done: boolean\n /** 遷移先の Layout(engine 所有の複製。書き換えは updateTarget で) */\n readonly target: Layout\n /** t を動かして中間形を表示する(非有限は 1 = jump に倒す) */\n scrub(t: number): void\n /**\n * morph を続けたまま目標だけ書き換える(Touch の per-pane 調停の土台 —\n * AI 遷移中に human の knob が target の share を上書きし、morph は続行する)\n */\n updateTarget(fn: (layout: Layout) => Layout): void\n /** target を current にして settle log に刻む(author = 引き金を引いた者) */\n commit(author: SettleAuthor): void\n /** 遷移を破棄して元の layout の表示に戻す(log には何も残らない) */\n cancel(): void\n /** スクラブ手放しの着地先(§5: t < 0.5 → 0 = cancel 側、以上 → 1 = commit 側) */\n nearestEndpoint(): 0 | 1\n}\n\nexport interface LayoutEngineOptions {\n /** テスト用の時計注入(既定 = Date.now) */\n clock?: () => number\n /** 知覚テーパー(resolve に渡る) */\n taper?: (raw: number) => number\n}\n\nexport interface LayoutEngine {\n current(scope: string): Layout\n /** 場・構造の変更(gesture 純関数を渡す)。settle は別途(連続操作の途中は log しない) */\n update(scope: string, fn: (layout: Layout) => Layout): void\n /** Scene の total recall(LE-14)。preset は複製され mutate されない。author = \"scene\" で settle */\n applyScene(scope: string, scene: Scene): void\n /** 形が定まった瞬間を log に刻む(gesture release / AI apply 等、呼び手が判断) */\n settle(scope: string, author: SettleAuthor): void\n history(scope: string): readonly SettleEntry[]\n /** 一時状態(solo / Touch / scrub 逸脱)からの復帰先 = last settle */\n restoreLastSettle(scope: string): boolean\n /** float の一時的な移動(ephemeral — log / Scene に入らない)。pos は左上 0..1 */\n moveFloat(scope: string, id: string, pos: FloatPosition): void\n /**\n * target への遷移を開く(LE-7)。base = 「今の表示」の snapshot なので、遷移中に\n * 次の begin が来ても表示は飛ばない(連鎖)。進行中の遷移は置き換えられ done になる。\n * t = 0 で開くため表示は変わらない — 動かすのは driver / scrub。\n */\n beginTransition(scope: string, target: Layout): TransitionHandle\n /** 進行中の遷移の handle(無ければ null)。Touch 配線 = consumer がこれを掴んで調停する */\n transition(scope: string): TransitionHandle | null\n resolved(scope: string): ResolvedMap\n subscribe(listener: ResolvedListener): () => void\n}\n\ninterface ActiveTransition {\n /** begin 時点の表示 snapshot(連鎖時は中間形そのもの) */\n base: ResolvedMap\n target: Layout\n targetResolved: ResolvedMap\n t: number\n}\n\ninterface ScopeState {\n layout: Layout\n log: SettleEntry[]\n floatPos: Map<string, FloatPosition>\n transition: ActiveTransition | null\n transitionHandle: TransitionHandle | null\n}\n\nconst clamp01 = (n: number): number => Math.min(1, Math.max(0, n))\n\n/**\n * Layout の構造的複製(純 data なので手書きで足りる — structuredClone = DOM API に依存しない)。\n * consumer も Scene capture 等で使う public API(複製の同型実装を増やさないため export)。\n */\nexport const cloneLayout = (layout: Layout): Layout => ({\n structure: { columns: layout.structure.columns.map((col) => ({ panes: [...col.panes] })) },\n attention: { ...layout.attention },\n locks: layout.locks ? { ...layout.locks } : undefined,\n})\n\nexport function createLayoutEngine(options: LayoutEngineOptions = {}): LayoutEngine {\n const clock = options.clock ?? (() => Date.now())\n const taper = options.taper\n const scopes = new Map<string, ScopeState>()\n const listeners = new Set<ResolvedListener>()\n\n const state = (scope: string): ScopeState => {\n let s = scopes.get(scope)\n if (!s) {\n s = {\n layout: EMPTY_LAYOUT,\n log: [],\n floatPos: new Map(),\n transition: null,\n transitionHandle: null,\n }\n scopes.set(scope, s)\n }\n return s\n }\n\n /**\n * ephemeral float 位置の合成(枠外に出ない範囲へ clamp)。\n * prune = 浮いていない pane の位置を捨てる(ephemeral の自然な寿命)— 遷移の\n * target 投影では中間形の都合で位置を落とさないよう prune しない\n */\n const overlayFloats = (s: ScopeState, base: ResolvedMap, prune: boolean): ResolvedMap => {\n if (prune) {\n for (const id of [...s.floatPos.keys()]) {\n if (!base[id]?.floating) s.floatPos.delete(id)\n }\n }\n if (s.floatPos.size === 0) return base\n const out: Record<string, ResolvedPane> = { ...base }\n for (const [id, pos] of s.floatPos) {\n const pane = out[id]\n if (!pane?.floating) continue\n out[id] = {\n ...pane,\n rect: {\n ...pane.rect,\n x: clamp01(Math.min(pos.x, 1 - pane.rect.w)),\n y: clamp01(Math.min(pos.y, 1 - pane.rect.h)),\n },\n }\n }\n return out\n }\n\n const project = (s: ScopeState): ResolvedMap => {\n if (s.transition) {\n return interpolate(s.transition.base, s.transition.targetResolved, s.transition.t)\n }\n return overlayFloats(s, resolve(s.layout, { taper }), true)\n }\n\n /**\n * 直接操作は遷移を奪取して破棄する(Touch の whole-scope 規則 — 注視の主権は user、\n * LE-16)。morph を続けたまま介入したい場合は handle.updateTarget を使う\n */\n const seize = (s: ScopeState): void => {\n s.transition = null\n }\n\n const notify = (scope: string): void => {\n const projected = project(state(scope))\n for (const listener of listeners) listener(scope, projected)\n }\n\n return {\n current(scope) {\n return state(scope).layout\n },\n update(scope, fn) {\n const s = state(scope)\n seize(s)\n s.layout = fn(s.layout)\n notify(scope)\n },\n applyScene(scope, scene) {\n const s = state(scope)\n seize(s)\n s.layout = cloneLayout(scene.layout)\n s.log.push({ layout: cloneLayout(s.layout), at: clock(), author: 'scene' })\n notify(scope)\n },\n settle(scope, author) {\n const s = state(scope)\n s.log.push({ layout: cloneLayout(s.layout), at: clock(), author })\n },\n history(scope) {\n return [...state(scope).log]\n },\n restoreLastSettle(scope) {\n const s = state(scope)\n const last = s.log[s.log.length - 1]\n if (!last) return false\n seize(s)\n s.layout = cloneLayout(last.layout)\n notify(scope)\n return true\n },\n moveFloat(scope, id, pos) {\n const s = state(scope)\n seize(s)\n s.floatPos.set(id, { x: clamp01(pos.x), y: clamp01(pos.y) })\n notify(scope)\n },\n beginTransition(scope, target) {\n const s = state(scope)\n const tr: ActiveTransition = {\n base: project(s), // 遷移中なら中間形 = 連鎖しても表示が飛ばない\n target: cloneLayout(target),\n targetResolved: {},\n t: 0,\n }\n tr.targetResolved = overlayFloats(s, resolve(tr.target, { taper }), false)\n s.transition = tr\n\n const live = (): boolean => s.transition === tr\n const handle: TransitionHandle = {\n scope,\n get t() {\n return tr.t\n },\n get done() {\n return !live()\n },\n get target() {\n return tr.target\n },\n scrub(t) {\n if (!live()) return\n tr.t = Number.isFinite(t) ? clamp01(t) : 1\n notify(scope)\n },\n updateTarget(fn) {\n if (!live()) return\n tr.target = fn(tr.target)\n tr.targetResolved = overlayFloats(s, resolve(tr.target, { taper }), false)\n notify(scope)\n },\n commit(author) {\n if (!live()) return\n s.transition = null\n s.layout = cloneLayout(tr.target)\n s.log.push({ layout: cloneLayout(s.layout), at: clock(), author })\n notify(scope)\n },\n cancel() {\n if (!live()) return\n s.transition = null\n notify(scope)\n },\n nearestEndpoint() {\n return tr.t >= 0.5 ? 1 : 0\n },\n }\n s.transitionHandle = handle\n notify(scope) // t = 0 なので表示は base のまま(購読側の状態同期のため通知はする)\n return handle\n },\n transition(scope) {\n const s = state(scope)\n return s.transition ? s.transitionHandle : null\n },\n resolved(scope) {\n return project(state(scope))\n },\n subscribe(listener) {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n }\n}\n","/**\n * drivers — t を進める者たち(LE-7)。\n *\n * interpolate / scrub は t を受けるだけで、時間は常に外から来る:\n * - time driver : curve(spring 等)が実時間で t を進める(従来のアニメーション相当)\n * - jump driver : t を即 to に(prefers-reduced-motion は「jump driver の選択」に落ちる)\n * - hand driver : fader / gesture がそのまま handle.scrub を呼ぶ(driver 実装は不要)\n *\n * curve は構造型 `TimeCurve` — creo-ui-frame の `springCurve` がそのまま刺さるが、\n * core は frame を import しない(LE-7)。frame 不在の consumer(VP webview 等)は\n * `defaultCurve` で動く。\n *\n * DOM 依存ゼロの規律: requestAnimationFrame は typeof ガード付きで使い、非 browser では\n * setTimeout に落ちる(テストは schedule 注入で決定的に回す)。\n */\n\nimport type { SettleAuthor, TransitionHandle } from './engine'\n\n/**\n * 経過時間 → 進行度の純関数。position は 0 始まりで settleTime 秒後に ≈1 に静定。\n * 1 超え(spring の overshoot)は許すが、scrub 側で [0,1] に clamp される —\n * 面積和 = 1 の invariant を外挿で壊さないため(overshoot の表現は frame / WAAPI の領分)\n */\nexport interface TimeCurve {\n position(elapsedSeconds: number): number\n settleTime: number\n}\n\n/**\n * 既定 curve = 臨界減衰 spring の閉形式(overshoot なし、約 0.35s で静定)。\n * ω = 26.4 は |x - 1| < 0.001 が 0.35s になる値。frame の springCurve を使えば\n * preset(gentle / wobbly / …)で差し替えられる\n */\nexport const defaultCurve: TimeCurve = {\n position: (t) => 1 - Math.exp(-26.4 * t) * (1 + 26.4 * t),\n settleTime: 0.35,\n}\n\nexport interface DriverRun {\n cancel(): void\n /** true = 端点まで走り切った / false = cancel された */\n finished: Promise<boolean>\n}\n\nexport interface TransitionDriver {\n /** apply に t を流し込む。range で部分区間(release の「現在地 → 端点」等)を駆動 */\n start(apply: (t: number) => void, range?: { from?: number; to?: number }): DriverRun\n}\n\nexport interface TimeDriverOptions {\n curve?: TimeCurve\n /** ms 時計(テスト注入用。既定 = performance.now / Date.now) */\n now?: () => number\n /** 次 frame の予約(テスト注入用。既定 = rAF、非 browser は setTimeout 16ms)。戻り値 = 予約取消 */\n schedule?: (cb: () => void) => () => void\n}\n\nconst defaultNow = (): number =>\n typeof performance !== 'undefined' ? performance.now() : Date.now()\n\nconst defaultSchedule = (cb: () => void): (() => void) => {\n if (typeof requestAnimationFrame === 'function') {\n const id = requestAnimationFrame(() => cb())\n return () => cancelAnimationFrame(id)\n }\n const id = setTimeout(cb, 16)\n return () => clearTimeout(id)\n}\n\nconst clamp01 = (n: number): number => Math.min(1, Math.max(0, n))\n\n/** time driver: curve を実時間で sample して t を進める。settleTime 到達で必ず to に着地 */\nexport function createTimeDriver(options: TimeDriverOptions = {}): TransitionDriver {\n const curve = options.curve ?? defaultCurve\n const now = options.now ?? defaultNow\n const schedule = options.schedule ?? defaultSchedule\n\n return {\n start(apply, range = {}) {\n const from = range.from ?? 0\n const to = range.to ?? 1\n let cancelled = false\n let cancelTick: (() => void) | null = null\n let resolveFinished!: (v: boolean) => void\n const finished = new Promise<boolean>((r) => {\n resolveFinished = r\n })\n const startAt = now()\n\n const step = (): void => {\n if (cancelled) return\n const elapsed = (now() - startAt) / 1000\n if (elapsed >= curve.settleTime) {\n apply(to)\n resolveFinished(true)\n return\n }\n // 壊れた curve 値はその frame を from 側に倒すだけ — settleTime で必ず終端に着く\n const p = clamp01(curve.position(elapsed))\n apply(from + (to - from) * (Number.isFinite(p) ? p : 0))\n cancelTick = schedule(step)\n }\n // 初回も schedule 経由(start の同期中に apply しない — 呼び手の再入を避ける)\n cancelTick = schedule(step)\n\n return {\n cancel() {\n if (cancelled) return\n cancelled = true\n cancelTick?.()\n resolveFinished(false)\n },\n finished,\n }\n },\n }\n}\n\n/** jump driver: 即 to(reduced-motion / テンポの速い操作用)。同期に apply する */\nexport const jumpDriver: TransitionDriver = {\n start(apply, range = {}) {\n apply(range.to ?? 1)\n return { cancel() {}, finished: Promise.resolve(true) }\n },\n}\n\n/**\n * スクラブ手放しの着地(§5): 近い端点へ driver で運び、1 なら commit / 0 なら cancel。\n * 「一時状態は必ず settle 状態に着地する」の実行形\n */\nexport function settleRelease(\n handle: TransitionHandle,\n driver: TransitionDriver,\n author: SettleAuthor = 'human',\n): DriverRun {\n const to = handle.nearestEndpoint()\n const run = driver.start((t) => handle.scrub(t), { from: handle.t, to })\n run.finished.then((ok) => {\n if (!ok || handle.done) return\n if (to === 1) handle.commit(author)\n else handle.cancel()\n })\n return run\n}\n","/**\n * policy — AI 提案の適用規則 = DAW automation modes(LE-16)。\n *\n * 誰が引き金を引くかは consumer 側の per-scope 設定。ここはその語彙と、\n * 提案 1 件を mode に従って遷移に落とす入口だけを持つ:\n *\n * | mode | 挙動 |\n * |-------|------|\n * | off | 受けない(accepted = false) |\n * | write | 遷移を開くだけ(hitl、既定)— 適用は人の手(t fader / commit) |\n * | read | driver が t を 1 へ運び、到達で commit(author = 'ai' が監査証跡) |\n * | touch | read と同じ駆動 + human 入力での奪取は consumer 配線 |\n *\n * touch の奪取は 2 段構え(engine 側に実装済):\n * - whole-scope: engine.update 等の直接操作が遷移を seize(1 規則)\n * - per-pane 継続: handle.updateTarget で morph を続けたまま目標を上書き\n * consumer は human 入力イベントで drive.cancel() → hand driver / settleRelease に\n * 引き継ぐ。復帰(release 後に AI へ滑らかに戻る)も同じ部品の合成で書ける。\n */\n\nimport type { DriverRun, TransitionDriver } from './drivers'\nimport { createTimeDriver } from './drivers'\nimport type { LayoutEngine, SettleAuthor, TransitionHandle } from './engine'\nimport type { Layout } from './types'\n\nexport type ApplyPolicy = 'off' | 'write' | 'read' | 'touch'\n\nexport interface ProposeOptions {\n policy: ApplyPolicy\n /** read / touch の適用駆動(既定 = createTimeDriver())。reduced-motion なら jumpDriver を渡す */\n driver?: TransitionDriver\n /** 到達時の settle author(既定 'ai' — 監査証跡) */\n author?: SettleAuthor\n}\n\nexport interface ProposeResult {\n accepted: boolean\n /** off 以外で返る。write = これを人が scrub / commit する */\n handle?: TransitionHandle\n /** read / touch で返る。touch の奪取 = consumer が human 入力でこれを cancel する */\n drive?: DriverRun\n}\n\n/** AI 提案 1 件を policy に従って遷移へ落とす(LE-15 の適用側の入口) */\nexport function proposeLayout(\n engine: LayoutEngine,\n scope: string,\n target: Layout,\n options: ProposeOptions,\n): ProposeResult {\n if (options.policy === 'off') return { accepted: false }\n\n const handle = engine.beginTransition(scope, target)\n if (options.policy === 'write') return { accepted: true, handle }\n\n const driver = options.driver ?? createTimeDriver()\n const drive = driver.start((t) => handle.scrub(t))\n drive.finished.then((ok) => {\n if (ok && !handle.done) handle.commit(options.author ?? 'ai')\n })\n return { accepted: true, handle, drive }\n}\n"],"names":["EMPTY_LAYOUT","memberIds","structure","col","isMember","id","removePane","p","appendColumn","insertIntoColumn","columnIndex","i","ID_RE","validateId","parseNotation","text","parts","left","right","columns","segment","trimmed","s","floats","seen","c","formatNotation","cols","floatPart","identity","n","resolve","layout","options","taper","att","eff","raw","tapered","members","globalSum","colEffs","m","locks","colLocks","ci","v","lockSumRaw","unlockedEffSum","lockScale","remaining","out","xCursor","colEff","visible","colLock","colW","colX","sumH","yCursor","e","h","share","size","lerp","a","b","t","collapse","rect","ghostOf","present","interpolate","clamped","ids","fromB","fromA","pa","pb","visibleIds","withAttention","attention","MAX_SHARE","setShare","mute","others","sum","solo","prev","key","equalize","targets","moveDominance","dir","memberSet","visibleMembers","visibleFloats","candidates","dominant","visibleColumns","panes","colIndex","column","target","nextCol","best","paneIndex","admit","opts","mean","admitted","popOut","popIn","lock","unlock","clamp01","cloneLayout","createLayoutEngine","clock","scopes","listeners","state","scope","overlayFloats","base","prune","pos","pane","project","seize","notify","projected","listener","fn","scene","author","last","tr","live","handle","defaultCurve","defaultNow","defaultSchedule","cb","createTimeDriver","curve","now","schedule","apply","range","from","to","cancelled","cancelTick","resolveFinished","finished","r","startAt","step","elapsed","jumpDriver","settleRelease","driver","run","ok","proposeLayout","engine","drive"],"mappings":"AAuEO,MAAMA,IAAuB,OAAO,OAAO;AAAA,EAChD,WAAW,OAAO,OAAO,EAAE,SAAS,OAAO,OAAO,CAAA,CAAE,GAAG;AAAA,EACvD,WAAW,OAAO,OAAO,CAAA,CAAE;AAC7B,CAAC;AChEM,SAASC,EAAUC,GAAgC;AACxD,SAAOA,EAAU,QAAQ,QAAQ,CAACC,MAAQ,CAAC,GAAGA,EAAI,KAAK,CAAC;AAC1D;AAEO,SAASC,EAASF,GAAsBG,GAAqB;AAClE,SAAOH,EAAU,QAAQ,KAAK,CAACC,MAAQA,EAAI,MAAM,SAASE,CAAE,CAAC;AAC/D;AAGO,SAASC,EAAWJ,GAAsBG,GAAuB;AACtE,SAAKD,EAASF,GAAWG,CAAE,IAIpB,EAAE,SAHOH,EAAU,QAC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AAI,CAACA,KAAMzB,EAAO,SACdY,MAAO,IAAGZ,EAAO,OAAOJ,CAAM,MACtB,OAAA;AAAA,EACd,CAAC,GACM4B;AACT;ACnGO,SAASE,GACdC,GACA5C,GACAnB,GACAtE,GACe;AACf,MAAIA,EAAQ,WAAW,MAAO,QAAO,EAAE,UAAU,GAAA;AAEjD,QAAM0G,IAAS2B,EAAO,gBAAgB5C,GAAOnB,CAAM;AACnD,MAAItE,EAAQ,WAAW,gBAAgB,EAAE,UAAU,IAAM,QAAA0G,EAAA;AAGzD,QAAM4B,KADStI,EAAQ,UAAU+G,GAAA,GACZ,MAAM,CAAC7E,MAAMwE,EAAO,MAAMxE,CAAC,CAAC;AACjD,SAAAoG,EAAM,SAAS,KAAK,CAACH,MAAO;AAC1B,IAAIA,KAAM,CAACzB,EAAO,UAAa,OAAO1G,EAAQ,UAAU,IAAI;AAAA,EAC9D,CAAC,GACM,EAAE,UAAU,IAAM,QAAA0G,GAAQ,OAAA4B,EAAA;AACnC;"}
|
package/dist/policy.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DriverRun, TransitionDriver } from './drivers';
|
|
2
|
+
import { LayoutEngine, SettleAuthor, TransitionHandle } from './engine';
|
|
3
|
+
import { Layout } from './types';
|
|
4
|
+
export type ApplyPolicy = 'off' | 'write' | 'read' | 'touch';
|
|
5
|
+
export interface ProposeOptions {
|
|
6
|
+
policy: ApplyPolicy;
|
|
7
|
+
/** read / touch の適用駆動(既定 = createTimeDriver())。reduced-motion なら jumpDriver を渡す */
|
|
8
|
+
driver?: TransitionDriver;
|
|
9
|
+
/** 到達時の settle author(既定 'ai' — 監査証跡) */
|
|
10
|
+
author?: SettleAuthor;
|
|
11
|
+
}
|
|
12
|
+
export interface ProposeResult {
|
|
13
|
+
accepted: boolean;
|
|
14
|
+
/** off 以外で返る。write = これを人が scrub / commit する */
|
|
15
|
+
handle?: TransitionHandle;
|
|
16
|
+
/** read / touch で返る。touch の奪取 = consumer が human 入力でこれを cancel する */
|
|
17
|
+
drive?: DriverRun;
|
|
18
|
+
}
|
|
19
|
+
/** AI 提案 1 件を policy に従って遷移へ落とす(LE-15 の適用側の入口) */
|
|
20
|
+
export declare function proposeLayout(engine: LayoutEngine, scope: string, target: Layout, options: ProposeOptions): ProposeResult;
|
package/dist/types.d.ts
CHANGED
|
@@ -27,6 +27,14 @@ export type Attention = Readonly<Record<string, number>>;
|
|
|
27
27
|
export interface Layout {
|
|
28
28
|
readonly structure: Structure;
|
|
29
29
|
readonly attention: Attention;
|
|
30
|
+
/**
|
|
31
|
+
* 列幅 lock(LE-21、fader lock の幅版): pane id → 幅 share ∈ (0, 1)。
|
|
32
|
+
* その pane を**含む列**の幅を固定し、残りの列が余りを正規化する。
|
|
33
|
+
* サイズ情報なので構造/記法には入らず場の側に住む(LE-4)。px 固定は consumer が
|
|
34
|
+
* resize 時に fraction を再計算して更新する(viewport は protocol の外、LE-9)。
|
|
35
|
+
* 非所属 pane の lock は休眠(popIn で復活)。
|
|
36
|
+
*/
|
|
37
|
+
readonly locks?: Readonly<Record<string, number>>;
|
|
30
38
|
}
|
|
31
39
|
/** Scene = Layout の名前付き immutable snapshot = 注視の表現 = scrub の端点(LE-14) */
|
|
32
40
|
export interface Scene {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chronista-club/creo-ui-layout",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "creo-ui — Layout Engine(attention 連続場 + 構造 + scrub)。core は純 calculation(DOM 依存ゼロ)、/solid が SolidJS reference 実装。設計 SSOT: docs/design/layout-engine.md(LE-1〜LE-20)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|