@chronista-club/creo-ui-layout 0.1.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/README.md +18 -0
- package/dist/engine.d.ts +35 -0
- package/dist/gestures.d.ts +40 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +298 -0
- package/dist/index.js.map +1 -0
- package/dist/interpolate.d.ts +2 -0
- package/dist/notation.d.ts +10 -0
- package/dist/resolve.d.ts +6 -0
- package/dist/solid/index.d.ts +7 -0
- package/dist/solid/index.js +78 -0
- package/dist/solid/index.js.map +1 -0
- package/dist/solid/signal.d.ts +5 -0
- package/dist/solid/stage.d.ts +18 -0
- package/dist/structure.d.ts +10 -0
- package/dist/types.d.ts +54 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @chronista-club/creo-ui-layout
|
|
2
|
+
|
|
3
|
+
Layout Engine — attention 連続場 + 構造 + scrub の protocol core。
|
|
4
|
+
|
|
5
|
+
- **設計 SSOT**: [docs/design/layout-engine.md](../../docs/design/layout-engine.md)(LE-1〜LE-20)
|
|
6
|
+
- **LE-P0**: protocol types + 純 calculation(resolve / interpolate / gestures / 記法)+ property test。
|
|
7
|
+
core は DOM 依存ゼロ。
|
|
8
|
+
- **LE-P1**: `/solid` = SolidJS reference 実装(`PaneStage` + `useEngineResolved`、action 層)。
|
|
9
|
+
host div は reparent しない(LE-10)、motion なし(時間は driver = LE-P3)。
|
|
10
|
+
dogfood: site の `/lab/layout`(secondary)。
|
|
11
|
+
- 場(attention ∈ [0,1])が唯一のサイズ真実源。0 = 非表示。構造は軸交代 + 所属のみ
|
|
12
|
+
(記法 `ec | cv/pp ~ board`、サイズを持たない)。
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
bun test packages/layout/src # property + golden(記法文字列で書かれた読める仕様)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
primary consumer / dogfood は Vantage Point(VP `docs/design/49-gui-layout-engine.md`)。
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Layout, ResolvedMap, Scene } from './types';
|
|
2
|
+
export type SettleAuthor = 'human' | 'ai' | 'scene';
|
|
3
|
+
export interface SettleEntry {
|
|
4
|
+
readonly layout: Layout;
|
|
5
|
+
readonly at: number;
|
|
6
|
+
readonly author: SettleAuthor;
|
|
7
|
+
}
|
|
8
|
+
export interface FloatPosition {
|
|
9
|
+
readonly x: number;
|
|
10
|
+
readonly y: number;
|
|
11
|
+
}
|
|
12
|
+
export type ResolvedListener = (scope: string, resolved: ResolvedMap) => void;
|
|
13
|
+
export interface LayoutEngineOptions {
|
|
14
|
+
/** テスト用の時計注入(既定 = Date.now) */
|
|
15
|
+
clock?: () => number;
|
|
16
|
+
/** 知覚テーパー(resolve に渡る) */
|
|
17
|
+
taper?: (raw: number) => number;
|
|
18
|
+
}
|
|
19
|
+
export interface LayoutEngine {
|
|
20
|
+
current(scope: string): Layout;
|
|
21
|
+
/** 場・構造の変更(gesture 純関数を渡す)。settle は別途(連続操作の途中は log しない) */
|
|
22
|
+
update(scope: string, fn: (layout: Layout) => Layout): void;
|
|
23
|
+
/** Scene の total recall(LE-14)。preset は複製され mutate されない。author = "scene" で settle */
|
|
24
|
+
applyScene(scope: string, scene: Scene): void;
|
|
25
|
+
/** 形が定まった瞬間を log に刻む(gesture release / AI apply 等、呼び手が判断) */
|
|
26
|
+
settle(scope: string, author: SettleAuthor): void;
|
|
27
|
+
history(scope: string): readonly SettleEntry[];
|
|
28
|
+
/** 一時状態(solo / Touch / scrub 逸脱)からの復帰先 = last settle */
|
|
29
|
+
restoreLastSettle(scope: string): boolean;
|
|
30
|
+
/** float の一時的な移動(ephemeral — log / Scene に入らない)。pos は左上 0..1 */
|
|
31
|
+
moveFloat(scope: string, id: string, pos: FloatPosition): void;
|
|
32
|
+
resolved(scope: string): ResolvedMap;
|
|
33
|
+
subscribe(listener: ResolvedListener): () => void;
|
|
34
|
+
}
|
|
35
|
+
export declare function createLayoutEngine(options?: LayoutEngineOptions): LayoutEngine;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Layout } from './types';
|
|
2
|
+
/** 場に正の値を持つ pane id(tiled + floating) */
|
|
3
|
+
export declare function visibleIds(layout: Layout): string[];
|
|
4
|
+
/**
|
|
5
|
+
* share 直接指定(knob / float リサイズの実体)。
|
|
6
|
+
* raw_id = share / (1 - share) × Σ(他の可視 raw) — untouched の raw は不変のまま、
|
|
7
|
+
* 正規化で全員の share が動く(モータライズノブが「連動して動く」の根拠)。
|
|
8
|
+
*/
|
|
9
|
+
export declare function setShare(layout: Layout, id: string, share: number): Layout;
|
|
10
|
+
/** 非表示(= 0)。最後の可視 1 枚は拒否(全零 guard) */
|
|
11
|
+
export declare function mute(layout: Layout, id: string): Layout;
|
|
12
|
+
/**
|
|
13
|
+
* 独占(9 の残滓 = mixer の solo)。指定 pane 以外を 0 に。
|
|
14
|
+
* un-solo は engine の「last settle へ復帰」で行う(一時状態の統一)。
|
|
15
|
+
*/
|
|
16
|
+
export declare function solo(layout: Layout, id: string): Layout;
|
|
17
|
+
/** 等分 snap(UI 作法の量子化 — 場は raw 同値で表現する) */
|
|
18
|
+
export declare function equalize(layout: Layout, ids?: readonly string[]): Layout;
|
|
19
|
+
export type DominanceDirection = 'left' | 'right' | 'up' | 'down';
|
|
20
|
+
/**
|
|
21
|
+
* dominance(argmax)の空間移動 — 2D cyclic(横 = 列間 / 縦 = 列内)。
|
|
22
|
+
* 実装は raw 値の swap: 場の multiset を保存し、位置だけが入れ替わる。
|
|
23
|
+
* dominant が floating の間は no-op(浮きは列に居ない)。
|
|
24
|
+
*/
|
|
25
|
+
export declare function moveDominance(layout: Layout, dir: DominanceDirection): Layout;
|
|
26
|
+
export interface AdmitOptions {
|
|
27
|
+
/** 入れる列 index(省略 = 末尾に新規列) */
|
|
28
|
+
column?: number;
|
|
29
|
+
/** 初期 share(省略 = 可視 pane の raw 平均で入る) */
|
|
30
|
+
share?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 入場 — 新 pane は tiled 直入り(float 入場は不採用、mako 2026-07-22)。
|
|
34
|
+
* 既定 = 末尾に新規列、attention = 可視 pane の raw 平均(居なければ 1)。
|
|
35
|
+
*/
|
|
36
|
+
export declare function admit(layout: Layout, id: string, opts?: AdmitOptions): Layout;
|
|
37
|
+
/** tiled → floating(構造から抜くだけ。場は不変 = サイズが保存される) */
|
|
38
|
+
export declare function popOut(layout: Layout, id: string): Layout;
|
|
39
|
+
/** floating → tiled(構造へ戻すだけ。場は不変)。既定 = 末尾に新規列 */
|
|
40
|
+
export declare function popIn(layout: Layout, id: string, column?: number): Layout;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* creo-ui-layout — Layout Engine protocol core(LE-P0)。
|
|
3
|
+
* 設計 SSOT: docs/design/layout-engine.md
|
|
4
|
+
*/
|
|
5
|
+
export type { Attention, Column, Layout, PaneRef, Rect, ResolvedMap, ResolvedPane, Scene, Structure, } from './types';
|
|
6
|
+
export { EMPTY_LAYOUT } from './types';
|
|
7
|
+
export { appendColumn, insertIntoColumn, isMember, memberIds, removePane } from './structure';
|
|
8
|
+
export type { ParsedNotation } from './notation';
|
|
9
|
+
export { formatNotation, parseNotation } from './notation';
|
|
10
|
+
export type { ResolveOptions } from './resolve';
|
|
11
|
+
export { resolve } from './resolve';
|
|
12
|
+
export { interpolate } from './interpolate';
|
|
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';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
const F = Object.freeze({
|
|
2
|
+
structure: Object.freeze({ columns: Object.freeze([]) }),
|
|
3
|
+
attention: Object.freeze({})
|
|
4
|
+
});
|
|
5
|
+
function C(t) {
|
|
6
|
+
return t.columns.flatMap((n) => [...n.panes]);
|
|
7
|
+
}
|
|
8
|
+
function k(t, n) {
|
|
9
|
+
return t.columns.some((o) => o.panes.includes(n));
|
|
10
|
+
}
|
|
11
|
+
function N(t, n) {
|
|
12
|
+
return k(t, n) ? { columns: t.columns.map((s) => ({ panes: s.panes.filter((c) => c !== n) })).filter((s) => s.panes.length > 0) } : t;
|
|
13
|
+
}
|
|
14
|
+
function P(t, n) {
|
|
15
|
+
return { columns: [...t.columns, { panes: [n] }] };
|
|
16
|
+
}
|
|
17
|
+
function A(t, n, o) {
|
|
18
|
+
return o < 0 || o >= t.columns.length ? P(t, n) : { columns: t.columns.map(
|
|
19
|
+
(c, a) => a === o ? { panes: [...c.panes, n] } : c
|
|
20
|
+
) };
|
|
21
|
+
}
|
|
22
|
+
const y = /^[^\s|/~]+$/;
|
|
23
|
+
function S(t) {
|
|
24
|
+
if (!y.test(t))
|
|
25
|
+
throw new Error(`layout notation: 不正な pane id "${t}"(空白と | / ~ は使えない)`);
|
|
26
|
+
return t;
|
|
27
|
+
}
|
|
28
|
+
function W(t) {
|
|
29
|
+
const n = t.split("~");
|
|
30
|
+
if (n.length > 2)
|
|
31
|
+
throw new Error("layout notation: float 区切り ~ は 1 つまで");
|
|
32
|
+
const o = (n[0] ?? "").trim(), s = (n[1] ?? "").trim(), c = o === "" ? [] : o.split("|").map((m) => {
|
|
33
|
+
const e = m.trim();
|
|
34
|
+
if (e === "")
|
|
35
|
+
throw new Error("layout notation: 空の列(| の間に pane が無い)");
|
|
36
|
+
return { panes: e.split("/").map((i) => {
|
|
37
|
+
const f = i.trim();
|
|
38
|
+
if (f === "")
|
|
39
|
+
throw new Error("layout notation: 空の pane(/ の間に id が無い)");
|
|
40
|
+
return S(f);
|
|
41
|
+
}) };
|
|
42
|
+
}), a = s === "" ? [] : s.split(/\s+/).map(S), l = /* @__PURE__ */ new Set();
|
|
43
|
+
for (const m of [...c.flatMap((e) => e.panes), ...a]) {
|
|
44
|
+
if (l.has(m))
|
|
45
|
+
throw new Error(`layout notation: pane id 重複 "${m}"`);
|
|
46
|
+
l.add(m);
|
|
47
|
+
}
|
|
48
|
+
return { structure: { columns: c }, floats: a };
|
|
49
|
+
}
|
|
50
|
+
function X(t, n = []) {
|
|
51
|
+
const o = /* @__PURE__ */ new Set();
|
|
52
|
+
for (const a of [...t.columns.flatMap((l) => [...l.panes]), ...n]) {
|
|
53
|
+
if (S(a), o.has(a))
|
|
54
|
+
throw new Error(`layout notation: pane id 重複 "${a}"`);
|
|
55
|
+
o.add(a);
|
|
56
|
+
}
|
|
57
|
+
for (const a of t.columns)
|
|
58
|
+
if (a.panes.length === 0)
|
|
59
|
+
throw new Error("layout notation: 空の列は直列化できない");
|
|
60
|
+
const s = t.columns.map((a) => a.panes.join("/")).join(" | ");
|
|
61
|
+
if (n.length === 0) return s;
|
|
62
|
+
const c = `~ ${n.join(" ")}`;
|
|
63
|
+
return s === "" ? c : `${s} ${c}`;
|
|
64
|
+
}
|
|
65
|
+
const L = (t) => t;
|
|
66
|
+
function D(t, n = {}) {
|
|
67
|
+
const o = n.taper ?? L, s = t.attention, c = (f) => {
|
|
68
|
+
const p = s[f] ?? 0;
|
|
69
|
+
if (!Number.isFinite(p) || p <= 0) return 0;
|
|
70
|
+
const u = o(p);
|
|
71
|
+
return Number.isFinite(u) && u > 0 ? u : 0;
|
|
72
|
+
}, a = new Set(C(t.structure));
|
|
73
|
+
let l = 0;
|
|
74
|
+
for (const f of Object.keys(s))
|
|
75
|
+
l += c(f);
|
|
76
|
+
const m = t.structure.columns.map(
|
|
77
|
+
(f) => f.panes.reduce((p, u) => Math.max(p, c(u)), 0)
|
|
78
|
+
), e = m.reduce((f, p) => f + p, 0), r = {};
|
|
79
|
+
let i = 0;
|
|
80
|
+
t.structure.columns.forEach((f, p) => {
|
|
81
|
+
const u = m[p] ?? 0, h = u > 0 && e > 0, g = h ? u / e : 0, d = i, z = f.panes.reduce((b, x) => b + c(x), 0);
|
|
82
|
+
let E = 0;
|
|
83
|
+
for (const b of f.panes) {
|
|
84
|
+
const x = c(b);
|
|
85
|
+
if (x > 0 && z > 0) {
|
|
86
|
+
const I = x / z;
|
|
87
|
+
r[b] = {
|
|
88
|
+
rect: { x: d, y: E, w: g, h: I },
|
|
89
|
+
attention: l > 0 ? x / l : 0,
|
|
90
|
+
floating: !1
|
|
91
|
+
}, E += I;
|
|
92
|
+
} else
|
|
93
|
+
r[b] = {
|
|
94
|
+
rect: { x: d, y: E, w: h ? g : 0, h: 0 },
|
|
95
|
+
attention: 0,
|
|
96
|
+
floating: !1
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
i += g;
|
|
100
|
+
});
|
|
101
|
+
for (const f of Object.keys(s)) {
|
|
102
|
+
if (a.has(f)) continue;
|
|
103
|
+
const p = c(f);
|
|
104
|
+
if (p <= 0) continue;
|
|
105
|
+
const u = l > 0 ? p / l : 0, h = Math.min(1, u);
|
|
106
|
+
r[f] = {
|
|
107
|
+
rect: { x: (1 - h) / 2, y: (1 - h) / 2, w: h, h },
|
|
108
|
+
attention: u,
|
|
109
|
+
floating: !0
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return r;
|
|
113
|
+
}
|
|
114
|
+
const v = (t, n, o) => t + (n - t) * o;
|
|
115
|
+
function _(t) {
|
|
116
|
+
return { x: t.x + t.w / 2, y: t.y + t.h / 2, w: 0, h: 0 };
|
|
117
|
+
}
|
|
118
|
+
function $(t) {
|
|
119
|
+
return { rect: _(t.rect), attention: 0, floating: t.floating };
|
|
120
|
+
}
|
|
121
|
+
function Y(t, n, o) {
|
|
122
|
+
const s = Number.isFinite(o) ? Math.min(1, Math.max(0, o)) : 1;
|
|
123
|
+
if (s === 0) return t;
|
|
124
|
+
if (s === 1) return n;
|
|
125
|
+
const c = {}, a = /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(n)]);
|
|
126
|
+
for (const l of a) {
|
|
127
|
+
const m = n[l], e = t[l], r = e ?? $(m), i = m ?? $(e);
|
|
128
|
+
c[l] = {
|
|
129
|
+
rect: {
|
|
130
|
+
x: v(r.rect.x, i.rect.x, s),
|
|
131
|
+
y: v(r.rect.y, i.rect.y, s),
|
|
132
|
+
w: v(r.rect.w, i.rect.w, s),
|
|
133
|
+
h: v(r.rect.h, i.rect.h, s)
|
|
134
|
+
},
|
|
135
|
+
attention: v(r.attention, i.attention, s),
|
|
136
|
+
floating: s < 0.5 ? r.floating : i.floating
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return c;
|
|
140
|
+
}
|
|
141
|
+
function O(t) {
|
|
142
|
+
return Object.keys(t.attention).filter((n) => (t.attention[n] ?? 0) > 0);
|
|
143
|
+
}
|
|
144
|
+
function w(t, n) {
|
|
145
|
+
return { structure: t.structure, attention: n };
|
|
146
|
+
}
|
|
147
|
+
const H = 0.99;
|
|
148
|
+
function R(t, n, o) {
|
|
149
|
+
if (o <= 0) return T(t, n);
|
|
150
|
+
const s = Math.min(o, H), c = O(t).filter((l) => l !== n).reduce((l, m) => l + (t.attention[m] ?? 0), 0);
|
|
151
|
+
if (c <= 0)
|
|
152
|
+
return (t.attention[n] ?? 0) > 0 ? t : w(t, { ...t.attention, [n]: 1 });
|
|
153
|
+
const a = s / (1 - s) * c;
|
|
154
|
+
return w(t, { ...t.attention, [n]: a });
|
|
155
|
+
}
|
|
156
|
+
function T(t, n) {
|
|
157
|
+
return (t.attention[n] ?? 0) <= 0 || O(t).length <= 1 ? t : w(t, { ...t.attention, [n]: 0 });
|
|
158
|
+
}
|
|
159
|
+
function q(t, n) {
|
|
160
|
+
const o = t.attention[n] ?? 0, s = o > 0 ? o : 1, c = {};
|
|
161
|
+
for (const a of Object.keys(t.attention)) c[a] = 0;
|
|
162
|
+
return c[n] = s, w(t, c);
|
|
163
|
+
}
|
|
164
|
+
function B(t, n) {
|
|
165
|
+
const o = n ?? O(t);
|
|
166
|
+
if (o.length === 0) return t;
|
|
167
|
+
const s = { ...t.attention };
|
|
168
|
+
for (const c of o) s[c] = 1;
|
|
169
|
+
return w(t, s);
|
|
170
|
+
}
|
|
171
|
+
function U(t, n) {
|
|
172
|
+
const o = t.attention, s = C(t.structure), c = new Set(s), a = s.filter((u) => (o[u] ?? 0) > 0), l = Object.keys(o).filter((u) => !c.has(u) && (o[u] ?? 0) > 0), m = [...a, ...l];
|
|
173
|
+
if (m.length === 0) return t;
|
|
174
|
+
let e = m[0];
|
|
175
|
+
for (const u of m)
|
|
176
|
+
(o[u] ?? 0) > (o[e] ?? 0) && (e = u);
|
|
177
|
+
if (!c.has(e)) return t;
|
|
178
|
+
const r = t.structure.columns.map((u) => u.panes.filter((h) => (o[h] ?? 0) > 0)).filter((u) => u.length > 0), i = r.findIndex((u) => u.includes(e));
|
|
179
|
+
if (i < 0) return t;
|
|
180
|
+
const f = r[i];
|
|
181
|
+
let p;
|
|
182
|
+
if (n === "left" || n === "right") {
|
|
183
|
+
const h = r[(i + (n === "right" ? 1 : -1) + r.length) % r.length];
|
|
184
|
+
let g = h[0];
|
|
185
|
+
for (const d of h)
|
|
186
|
+
(o[d] ?? 0) > (o[g] ?? 0) && (g = d);
|
|
187
|
+
p = g;
|
|
188
|
+
} else {
|
|
189
|
+
const u = f.indexOf(e);
|
|
190
|
+
p = f[(u + (n === "down" ? 1 : -1) + f.length) % f.length];
|
|
191
|
+
}
|
|
192
|
+
return p === e ? t : w(t, {
|
|
193
|
+
...o,
|
|
194
|
+
[e]: o[p] ?? 0,
|
|
195
|
+
[p]: o[e] ?? 0
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function G(t, n, o = {}) {
|
|
199
|
+
if (k(t.structure, n)) return t;
|
|
200
|
+
const s = o.column != null ? A(t.structure, n, o.column) : P(t.structure, n), c = O(t).filter((r) => r !== n), a = c.length > 0 ? c.reduce((r, i) => r + (t.attention[i] ?? 0), 0) / c.length : 1, l = t.attention[n] ?? 0, m = l > 0 ? l : a, e = { structure: s, attention: { ...t.attention, [n]: m } };
|
|
201
|
+
return o.share != null ? R(e, n, o.share) : e;
|
|
202
|
+
}
|
|
203
|
+
function J(t, n) {
|
|
204
|
+
const o = N(t.structure, n);
|
|
205
|
+
return o === t.structure ? t : { structure: o, attention: t.attention };
|
|
206
|
+
}
|
|
207
|
+
function K(t, n, o) {
|
|
208
|
+
return k(t.structure, n) ? t : { structure: o != null ? A(t.structure, n, o) : P(t.structure, n), attention: t.attention };
|
|
209
|
+
}
|
|
210
|
+
const M = (t) => Math.min(1, Math.max(0, t)), j = (t) => ({
|
|
211
|
+
structure: { columns: t.structure.columns.map((n) => ({ panes: [...n.panes] })) },
|
|
212
|
+
attention: { ...t.attention }
|
|
213
|
+
});
|
|
214
|
+
function Q(t = {}) {
|
|
215
|
+
const n = t.clock ?? (() => Date.now()), o = t.taper, s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), a = (e) => {
|
|
216
|
+
let r = s.get(e);
|
|
217
|
+
return r || (r = { layout: F, log: [], floatPos: /* @__PURE__ */ new Map() }, s.set(e, r)), r;
|
|
218
|
+
}, l = (e) => {
|
|
219
|
+
const r = D(e.layout, { taper: o });
|
|
220
|
+
for (const f of [...e.floatPos.keys()])
|
|
221
|
+
r[f]?.floating || e.floatPos.delete(f);
|
|
222
|
+
if (e.floatPos.size === 0) return r;
|
|
223
|
+
const i = { ...r };
|
|
224
|
+
for (const [f, p] of e.floatPos) {
|
|
225
|
+
const u = i[f];
|
|
226
|
+
u && (i[f] = {
|
|
227
|
+
...u,
|
|
228
|
+
rect: {
|
|
229
|
+
...u.rect,
|
|
230
|
+
x: M(Math.min(p.x, 1 - u.rect.w)),
|
|
231
|
+
y: M(Math.min(p.y, 1 - u.rect.h))
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return i;
|
|
236
|
+
}, m = (e) => {
|
|
237
|
+
const r = l(a(e));
|
|
238
|
+
for (const i of c) i(e, r);
|
|
239
|
+
};
|
|
240
|
+
return {
|
|
241
|
+
current(e) {
|
|
242
|
+
return a(e).layout;
|
|
243
|
+
},
|
|
244
|
+
update(e, r) {
|
|
245
|
+
const i = a(e);
|
|
246
|
+
i.layout = r(i.layout), m(e);
|
|
247
|
+
},
|
|
248
|
+
applyScene(e, r) {
|
|
249
|
+
const i = a(e);
|
|
250
|
+
i.layout = j(r.layout), i.log.push({ layout: j(i.layout), at: n(), author: "scene" }), m(e);
|
|
251
|
+
},
|
|
252
|
+
settle(e, r) {
|
|
253
|
+
const i = a(e);
|
|
254
|
+
i.log.push({ layout: j(i.layout), at: n(), author: r });
|
|
255
|
+
},
|
|
256
|
+
history(e) {
|
|
257
|
+
return [...a(e).log];
|
|
258
|
+
},
|
|
259
|
+
restoreLastSettle(e) {
|
|
260
|
+
const r = a(e), i = r.log[r.log.length - 1];
|
|
261
|
+
return i ? (r.layout = j(i.layout), m(e), !0) : !1;
|
|
262
|
+
},
|
|
263
|
+
moveFloat(e, r, i) {
|
|
264
|
+
a(e).floatPos.set(r, { x: M(i.x), y: M(i.y) }), m(e);
|
|
265
|
+
},
|
|
266
|
+
resolved(e) {
|
|
267
|
+
return l(a(e));
|
|
268
|
+
},
|
|
269
|
+
subscribe(e) {
|
|
270
|
+
return c.add(e), () => {
|
|
271
|
+
c.delete(e);
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
export {
|
|
277
|
+
F as EMPTY_LAYOUT,
|
|
278
|
+
G as admit,
|
|
279
|
+
P as appendColumn,
|
|
280
|
+
Q as createLayoutEngine,
|
|
281
|
+
B as equalize,
|
|
282
|
+
X as formatNotation,
|
|
283
|
+
A as insertIntoColumn,
|
|
284
|
+
Y as interpolate,
|
|
285
|
+
k as isMember,
|
|
286
|
+
C as memberIds,
|
|
287
|
+
U as moveDominance,
|
|
288
|
+
T as mute,
|
|
289
|
+
W as parseNotation,
|
|
290
|
+
K as popIn,
|
|
291
|
+
J as popOut,
|
|
292
|
+
N as removePane,
|
|
293
|
+
D as resolve,
|
|
294
|
+
R as setShare,
|
|
295
|
+
q as solo,
|
|
296
|
+
O as visibleIds
|
|
297
|
+
};
|
|
298
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,O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EAAYtF,EAAE,MAAM,GAAG,IAAIwF,EAAA,GAAS,QAAAc,EAAA,CAAQ;AAAA,IACnE;AAAA,IACA,QAAQV,GAAO;AACb,aAAO,CAAC,GAAGD,EAAMC,CAAK,EAAE,GAAG;AAAA,IAC7B;AAAA,IACA,kBAAkBA,GAAO;AACvB,YAAM5F,IAAI2F,EAAMC,CAAK,GACfW,IAAOvG,EAAE,IAAIA,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;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Structure } from './types';
|
|
2
|
+
export interface ParsedNotation {
|
|
3
|
+
readonly structure: Structure;
|
|
4
|
+
/** 構造非所属で場に居る pane(floating)。場の値そのものは記法の外(attention record が持つ) */
|
|
5
|
+
readonly floats: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/** 記法文字列 → 構造 + float 集合。不正入力は throw */
|
|
8
|
+
export declare function parseNotation(text: string): ParsedNotation;
|
|
9
|
+
/** 構造 + float 集合 → 正準形の記法文字列。parse(format(x)) が deep-equal になる */
|
|
10
|
+
export declare function formatNotation(structure: Structure, floats?: readonly string[]): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Layout, ResolvedMap } from './types';
|
|
2
|
+
export interface ResolveOptions {
|
|
3
|
+
/** 知覚テーパー。taper(x) > 0 for x > 0 を要求(0 の扱いは resolve が持つ) */
|
|
4
|
+
taper?: (raw: number) => number;
|
|
5
|
+
}
|
|
6
|
+
export declare function resolve(layout: Layout, options?: ResolveOptions): ResolvedMap;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* creo-ui-layout /solid — SolidJS reference 実装(LE-P1、action 層)。
|
|
3
|
+
* core(純 calculation)は "@chronista-club/creo-ui-layout" 本体から。
|
|
4
|
+
*/
|
|
5
|
+
export type { FloatMovePosition, PaneStageProps } from './stage';
|
|
6
|
+
export { PaneStage } from './stage';
|
|
7
|
+
export { useEngineResolved } from './signal';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { delegateEvents as E, insert as h, createComponent as $, effect as w, setAttribute as m, style as p, className as x, template as b, use as D } from "solid-js/web";
|
|
2
|
+
import { onCleanup as y, For as S, createSignal as C } from "solid-js";
|
|
3
|
+
var F = /* @__PURE__ */ b("<div style=position:relative;width:100%;height:100%>"), L = /* @__PURE__ */ b("<div>");
|
|
4
|
+
const R = {
|
|
5
|
+
rect: {
|
|
6
|
+
x: 0,
|
|
7
|
+
y: 0,
|
|
8
|
+
w: 0,
|
|
9
|
+
h: 0
|
|
10
|
+
},
|
|
11
|
+
attention: 0,
|
|
12
|
+
floating: !1
|
|
13
|
+
};
|
|
14
|
+
function Y(i) {
|
|
15
|
+
let a, l = null;
|
|
16
|
+
y(() => l?.());
|
|
17
|
+
const v = (n, e) => {
|
|
18
|
+
const o = i.onFloatMove, r = i.resolved[n.id];
|
|
19
|
+
if (!o || !r?.floating || !a) return;
|
|
20
|
+
e.preventDefault();
|
|
21
|
+
const t = a.getBoundingClientRect();
|
|
22
|
+
if (t.width <= 0 || t.height <= 0) return;
|
|
23
|
+
const s = (e.clientX - t.left) / t.width - r.rect.x, d = (e.clientY - t.top) / t.height - r.rect.y, c = (g) => {
|
|
24
|
+
o(n.id, {
|
|
25
|
+
x: (g.clientX - t.left) / t.width - s,
|
|
26
|
+
y: (g.clientY - t.top) / t.height - d
|
|
27
|
+
});
|
|
28
|
+
}, f = () => {
|
|
29
|
+
window.removeEventListener("pointermove", c), window.removeEventListener("pointerup", f), l = null;
|
|
30
|
+
};
|
|
31
|
+
l?.(), l = f, window.addEventListener("pointermove", c), window.addEventListener("pointerup", f);
|
|
32
|
+
}, u = (n) => {
|
|
33
|
+
const e = i.resolved[n] ?? R, o = e.rect.w > 0 && e.rect.h > 0;
|
|
34
|
+
return {
|
|
35
|
+
position: "absolute",
|
|
36
|
+
left: `${e.rect.x * 100}%`,
|
|
37
|
+
top: `${e.rect.y * 100}%`,
|
|
38
|
+
width: `${e.rect.w * 100}%`,
|
|
39
|
+
height: `${e.rect.h * 100}%`,
|
|
40
|
+
opacity: o ? 1 : 0,
|
|
41
|
+
overflow: "hidden",
|
|
42
|
+
// float は attention 順で手前(LE-18)。tiled は重ならないので auto でよい
|
|
43
|
+
"z-index": e.floating ? String(100 + Math.round(e.attention * 100)) : "auto",
|
|
44
|
+
"pointer-events": o ? "auto" : "none"
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
return (() => {
|
|
48
|
+
var n = F(), e = a;
|
|
49
|
+
return typeof e == "function" ? D(e, n) : a = n, h(n, $(S, {
|
|
50
|
+
get each() {
|
|
51
|
+
return i.panes;
|
|
52
|
+
},
|
|
53
|
+
children: (o) => (() => {
|
|
54
|
+
var r = L();
|
|
55
|
+
return r.$$pointerdown = (t) => v(o, t), h(r, () => i.renderPane(o)), w((t) => {
|
|
56
|
+
var s = o.id, d = i.resolved[o.id]?.floating ? "true" : void 0, c = u(o.id);
|
|
57
|
+
return s !== t.e && m(r, "data-pane-id", t.e = s), d !== t.t && m(r, "data-floating", t.t = d), t.a = p(r, c, t.a), t;
|
|
58
|
+
}, {
|
|
59
|
+
e: void 0,
|
|
60
|
+
t: void 0,
|
|
61
|
+
a: void 0
|
|
62
|
+
}), r;
|
|
63
|
+
})()
|
|
64
|
+
})), w(() => x(n, i.class)), n;
|
|
65
|
+
})();
|
|
66
|
+
}
|
|
67
|
+
E(["pointerdown"]);
|
|
68
|
+
function A(i, a) {
|
|
69
|
+
const [l, v] = C(i.resolved(a)), u = i.subscribe((n, e) => {
|
|
70
|
+
n === a && v(e);
|
|
71
|
+
});
|
|
72
|
+
return y(u), l;
|
|
73
|
+
}
|
|
74
|
+
export {
|
|
75
|
+
Y as PaneStage,
|
|
76
|
+
A as useEngineResolved
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/solid/stage.tsx","../../src/solid/signal.ts"],"sourcesContent":["/**\n * PaneStage — resolved を DOM に写す reference 実装(LE-P1、action 層)。\n *\n * - **DOM 安定(LE-10)**: pane ごとの host div は一度だけ作られ、以後 reparent しない。\n * 配置は left/top/width/height(0..1 → %)の座標変更のみ。resolved に居ない pane も\n * host は unmount せず面積 0 で保持する(xterm 等の再生成不可 content を守る契約)\n * - **契約**: `panes` の各要素は referentially stable に保つこと(`<For>` が参照で key するため、\n * 毎 render で PaneRef を作り直すと host が再生成され LE-10 が破れる)\n * - **motion なし**: 配置変更は即時反映(jump)。時間を持つのは driver(LE-P3)で、\n * ここに transition を書かない — scrub は呼び手が interpolate 済みの resolved を渡す\n * - float は z-index = attention 順で tiled の上に重なり、`onFloatMove` があれば drag で\n * ephemeral 移動できる(engine.moveFloat への配線は consumer)\n */\n\nimport type { JSX } from 'solid-js'\nimport { For, onCleanup } from 'solid-js'\nimport type { PaneRef, ResolvedMap, ResolvedPane } from '../types'\n\nexport interface FloatMovePosition {\n readonly x: number\n readonly y: number\n}\n\nexport interface PaneStageProps {\n /** 表示する配置(engine の購読値、または interpolate 済みの中間 frame) */\n resolved: ResolvedMap\n /** 何が存在するか(consumer 供給、LE-11/12)。要素は referentially stable に */\n panes: readonly PaneRef[]\n /** pane の中身。pane ごとに一度だけ呼ばれる(host の中で生き続ける) */\n renderPane: (pane: PaneRef) => JSX.Element\n /** floating pane の drag 移動(省略 = drag 無効)。pos は左上 0..1 */\n onFloatMove?: (id: string, pos: FloatMovePosition) => void\n class?: string\n}\n\n/** resolved に居ない pane の描画(面積 0・不可視。host は保持する) */\nconst ABSENT: ResolvedPane = {\n rect: { x: 0, y: 0, w: 0, h: 0 },\n attention: 0,\n floating: false,\n}\n\nexport function PaneStage(props: PaneStageProps): JSX.Element {\n let stageEl: HTMLDivElement | undefined\n\n // drag 中の listener を追跡し、途中 unmount でも必ず剥がす(listener leak 対策)\n let activeDragCleanup: (() => void) | null = null\n onCleanup(() => activeDragCleanup?.())\n\n const startFloatDrag = (pane: PaneRef, ev: PointerEvent) => {\n const onFloatMove = props.onFloatMove\n const current = props.resolved[pane.id]\n if (!onFloatMove || !current?.floating || !stageEl) return\n ev.preventDefault()\n const stageRect = stageEl.getBoundingClientRect()\n if (stageRect.width <= 0 || stageRect.height <= 0) return\n // 掴んだ点と pane 左上のずれを保存(掴んだ場所がそのまま持ち手になる)\n const grabDX = (ev.clientX - stageRect.left) / stageRect.width - current.rect.x\n const grabDY = (ev.clientY - stageRect.top) / stageRect.height - current.rect.y\n\n const move = (e: PointerEvent) => {\n onFloatMove(pane.id, {\n x: (e.clientX - stageRect.left) / stageRect.width - grabDX,\n y: (e.clientY - stageRect.top) / stageRect.height - grabDY,\n })\n }\n const stop = () => {\n window.removeEventListener('pointermove', move)\n window.removeEventListener('pointerup', stop)\n activeDragCleanup = null\n }\n activeDragCleanup?.()\n activeDragCleanup = stop\n window.addEventListener('pointermove', move)\n window.addEventListener('pointerup', stop)\n }\n\n const paneStyle = (id: string): JSX.CSSProperties => {\n const p = props.resolved[id] ?? ABSENT\n const visible = p.rect.w > 0 && p.rect.h > 0\n return {\n position: 'absolute',\n left: `${p.rect.x * 100}%`,\n top: `${p.rect.y * 100}%`,\n width: `${p.rect.w * 100}%`,\n height: `${p.rect.h * 100}%`,\n opacity: visible ? 1 : 0,\n overflow: 'hidden',\n // float は attention 順で手前(LE-18)。tiled は重ならないので auto でよい\n 'z-index': p.floating ? String(100 + Math.round(p.attention * 100)) : 'auto',\n 'pointer-events': visible ? 'auto' : 'none',\n }\n }\n\n return (\n <div\n ref={stageEl}\n class={props.class}\n style={{ position: 'relative', width: '100%', height: '100%' }}\n >\n <For each={props.panes}>\n {(pane) => (\n <div\n data-pane-id={pane.id}\n data-floating={props.resolved[pane.id]?.floating ? 'true' : undefined}\n style={paneStyle(pane.id)}\n onPointerDown={(ev) => startFloatDrag(pane, ev)}\n >\n {props.renderPane(pane)}\n </div>\n )}\n </For>\n </div>\n )\n}\n","/**\n * engine → Solid signal の橋(LE-P1)。\n *\n * subscribe の外側で DOM 反映を担う action 層の入口。core(純 calculation)は\n * ここから import されるだけで、Solid を知らない向きを保つ。\n */\n\nimport type { Accessor } from 'solid-js'\nimport { createSignal, onCleanup } from 'solid-js'\nimport type { LayoutEngine } from '../engine'\nimport type { ResolvedMap } from '../types'\n\n/** 指定 scope の resolved を signal として購読する。unmount で自動 unsubscribe */\nexport function useEngineResolved(engine: LayoutEngine, scope: string): Accessor<ResolvedMap> {\n const [resolved, setResolved] = createSignal<ResolvedMap>(engine.resolved(scope))\n const unsubscribe = engine.subscribe((s, r) => {\n if (s === scope) setResolved(r)\n })\n onCleanup(unsubscribe)\n return resolved\n}\n"],"names":["ABSENT","rect","x","y","w","h","attention","floating","PaneStage","props","stageEl","activeDragCleanup","onCleanup","startFloatDrag","pane","ev","onFloatMove","current","resolved","id","preventDefault","stageRect","getBoundingClientRect","width","height","grabDX","clientX","left","grabDY","clientY","top","move","e","stop","window","removeEventListener","addEventListener","paneStyle","p","visible","position","opacity","overflow","String","Math","round","_el$","_tmpl$","_ref$","_$use","_$insert","_$createComponent","For","each","panes","children","_el$2","_tmpl$2","$$pointerdown","renderPane","_$effect","_p$","_v$","_v$2","undefined","_v$3","_$setAttribute","t","a","_$style","_$className","class","_$delegateEvents","useEngineResolved","engine","scope","setResolved","createSignal","unsubscribe","s","r"],"mappings":";;;AAoCA,MAAMA,IAAuB;AAAA,EAC3BC,MAAM;AAAA,IAAEC,GAAG;AAAA,IAAGC,GAAG;AAAA,IAAGC,GAAG;AAAA,IAAGC,GAAG;AAAA,EAAA;AAAA,EAC7BC,WAAW;AAAA,EACXC,UAAU;AACZ;AAEO,SAASC,EAAUC,GAAoC;AAC5D,MAAIC,GAGAC,IAAyC;AAC7CC,EAAAA,EAAU,MAAMD,KAAqB;AAErC,QAAME,IAAiBA,CAACC,GAAeC,MAAqB;AAC1D,UAAMC,IAAcP,EAAMO,aACpBC,IAAUR,EAAMS,SAASJ,EAAKK,EAAE;AACtC,QAAI,CAACH,KAAe,CAACC,GAASV,YAAY,CAACG,EAAS;AACpDK,IAAAA,EAAGK,eAAAA;AACH,UAAMC,IAAYX,EAAQY,sBAAAA;AAC1B,QAAID,EAAUE,SAAS,KAAKF,EAAUG,UAAU,EAAG;AAEnD,UAAMC,KAAUV,EAAGW,UAAUL,EAAUM,QAAQN,EAAUE,QAAQN,EAAQhB,KAAKC,GACxE0B,KAAUb,EAAGc,UAAUR,EAAUS,OAAOT,EAAUG,SAASP,EAAQhB,KAAKE,GAExE4B,IAAOA,CAACC,MAAoB;AAChChB,MAAAA,EAAYF,EAAKK,IAAI;AAAA,QACnBjB,IAAI8B,EAAEN,UAAUL,EAAUM,QAAQN,EAAUE,QAAQE;AAAAA,QACpDtB,IAAI6B,EAAEH,UAAUR,EAAUS,OAAOT,EAAUG,SAASI;AAAAA,MAAAA,CACrD;AAAA,IACH,GACMK,IAAOA,MAAM;AACjBC,aAAOC,oBAAoB,eAAeJ,CAAI,GAC9CG,OAAOC,oBAAoB,aAAaF,CAAI,GAC5CtB,IAAoB;AAAA,IACtB;AACAA,IAAAA,IAAAA,GACAA,IAAoBsB,GACpBC,OAAOE,iBAAiB,eAAeL,CAAI,GAC3C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BAAAA,MAAAD,EAAA7B,KAAAkC,EAAAV,GAAA,gBAAAK,EAAA7B,IAAA8B,CAAA,GAAAC,MAAAF,EAAAM,KAAAD,EAAAV,GAAA,iBAAAK,EAAAM,IAAAJ,CAAA,GAAAF,EAAAO,IAAAC,EAAAb,GAAAS,GAAAJ,EAAAO,CAAA,GAAAP;AAAAA,QAAA,GAAA;AAAA,UAAA7B,GAAAgC;AAAAA,UAAAG,GAAAH;AAAAA,UAAAI,GAAAJ;AAAAA,QAAAA,CAAA,GAAAR;AAAAA,MAAA,GAAA;AAAA,IAAA,CAK5B,CAAA,GAAAI,QAAAU,EAAAxB,GAbIrC,EAAM8D,KAAK,CAAA,GAAAzB;AAAAA,EAAA,GAAA;AAiBxB;AAAC0B,EAAA,CAAA,aAAA,CAAA;ACrGM,SAASC,EAAkBC,GAAsBC,GAAsC;AAC5F,QAAM,CAACzD,GAAU0D,CAAW,IAAIC,EAA0BH,EAAO,SAASC,CAAK,CAAC,GAC1EG,IAAcJ,EAAO,UAAU,CAACK,GAAGC,MAAM;AAC7C,IAAID,MAAMJ,KAAOC,EAAYI,CAAC;AAAA,EAChC,CAAC;AACD,SAAApE,EAAUkE,CAAW,GACd5D;AACT;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
import { LayoutEngine } from '../engine';
|
|
3
|
+
import { ResolvedMap } from '../types';
|
|
4
|
+
/** 指定 scope の resolved を signal として購読する。unmount で自動 unsubscribe */
|
|
5
|
+
export declare function useEngineResolved(engine: LayoutEngine, scope: string): Accessor<ResolvedMap>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { JSX } from 'solid-js';
|
|
2
|
+
import { PaneRef, ResolvedMap } from '../types';
|
|
3
|
+
export interface FloatMovePosition {
|
|
4
|
+
readonly x: number;
|
|
5
|
+
readonly y: number;
|
|
6
|
+
}
|
|
7
|
+
export interface PaneStageProps {
|
|
8
|
+
/** 表示する配置(engine の購読値、または interpolate 済みの中間 frame) */
|
|
9
|
+
resolved: ResolvedMap;
|
|
10
|
+
/** 何が存在するか(consumer 供給、LE-11/12)。要素は referentially stable に */
|
|
11
|
+
panes: readonly PaneRef[];
|
|
12
|
+
/** pane の中身。pane ごとに一度だけ呼ばれる(host の中で生き続ける) */
|
|
13
|
+
renderPane: (pane: PaneRef) => JSX.Element;
|
|
14
|
+
/** floating pane の drag 移動(省略 = drag 無効)。pos は左上 0..1 */
|
|
15
|
+
onFloatMove?: (id: string, pos: FloatMovePosition) => void;
|
|
16
|
+
class?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function PaneStage(props: PaneStageProps): JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Structure } from './types';
|
|
2
|
+
/** 所属 pane id を構造順(列順 → 列内順)で返す */
|
|
3
|
+
export declare function memberIds(structure: Structure): string[];
|
|
4
|
+
export declare function isMember(structure: Structure, id: string): boolean;
|
|
5
|
+
/** pane を構造から抜く(空になった列は落とす)。非所属なら同一参照 */
|
|
6
|
+
export declare function removePane(structure: Structure, id: string): Structure;
|
|
7
|
+
/** 末尾に新規列として pane を足す */
|
|
8
|
+
export declare function appendColumn(structure: Structure, id: string): Structure;
|
|
9
|
+
/** 指定列の末尾に pane を足す。列 index が範囲外なら新規列(appendColumn)に落ちる */
|
|
10
|
+
export declare function insertIntoColumn(structure: Structure, id: string, columnIndex: number): Structure;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout Engine — protocol types(LE-P0)。
|
|
3
|
+
*
|
|
4
|
+
* 設計 SSOT: docs/design/layout-engine.md(LE-1〜LE-20)。
|
|
5
|
+
* 場(attention)が唯一のサイズ真実源(LE-3)、構造は軸交代 + 所属のみ(LE-4/5)。
|
|
6
|
+
* keyboard focus は protocol の関心外(LE-20 — DOM / consumer の領分)。
|
|
7
|
+
*/
|
|
8
|
+
/** pane identity — 「何が存在するか」は consumer 供給(LE-11/12)。primitive は kind を意味づけしない */
|
|
9
|
+
export interface PaneRef {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly kind?: string;
|
|
12
|
+
readonly label?: string;
|
|
13
|
+
}
|
|
14
|
+
/** 列 = 副軸(縦)の並び。構造はサイズを持たない(LE-4) */
|
|
15
|
+
export interface Column {
|
|
16
|
+
readonly panes: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
/** 主軸 = 水平の列並び。軸交代はここで打ち止め(LE-5、arity は無制限) */
|
|
19
|
+
export interface Structure {
|
|
20
|
+
readonly columns: readonly Column[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 場: pane id → raw attention(≥ 0)。0 = 非表示(LE-3)。
|
|
24
|
+
* 格納は raw、操作/表示は share(正規化後の取り分)— 二重読みは gestures / resolve が担う。
|
|
25
|
+
*/
|
|
26
|
+
export type Attention = Readonly<Record<string, number>>;
|
|
27
|
+
export interface Layout {
|
|
28
|
+
readonly structure: Structure;
|
|
29
|
+
readonly attention: Attention;
|
|
30
|
+
}
|
|
31
|
+
/** Scene = Layout の名前付き immutable snapshot = 注視の表現 = scrub の端点(LE-14) */
|
|
32
|
+
export interface Scene {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly layout: Layout;
|
|
36
|
+
readonly description?: string;
|
|
37
|
+
}
|
|
38
|
+
/** 0..1 連続の矩形。量子化は投影の縁でやる(LE-9 — ここでは丸めない) */
|
|
39
|
+
export interface Rect {
|
|
40
|
+
readonly x: number;
|
|
41
|
+
readonly y: number;
|
|
42
|
+
readonly w: number;
|
|
43
|
+
readonly h: number;
|
|
44
|
+
}
|
|
45
|
+
/** resolve の出力 1 pane 分 */
|
|
46
|
+
export interface ResolvedPane {
|
|
47
|
+
readonly rect: Rect;
|
|
48
|
+
/** 全可視 pane に対する share。遠近・明暗への射影は platform 判断(frame F-3) */
|
|
49
|
+
readonly attention: number;
|
|
50
|
+
readonly floating: boolean;
|
|
51
|
+
}
|
|
52
|
+
export type ResolvedMap = Readonly<Record<string, ResolvedPane>>;
|
|
53
|
+
/** 空 Layout。全 scope の初期値として共有されるため freeze(in-place mutation 事故の構造的防止) */
|
|
54
|
+
export declare const EMPTY_LAYOUT: Layout;
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chronista-club/creo-ui-layout",
|
|
3
|
+
"version": "0.1.0",
|
|
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
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"creo-ui",
|
|
8
|
+
"layout-engine",
|
|
9
|
+
"attention-field",
|
|
10
|
+
"tiling",
|
|
11
|
+
"scrub",
|
|
12
|
+
"design-system",
|
|
13
|
+
"solid-js"
|
|
14
|
+
],
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./solid": {
|
|
27
|
+
"types": "./dist/solid/index.d.ts",
|
|
28
|
+
"import": "./dist/solid/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": ["dist", "README.md"],
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/chronista-club/creo-ui.git",
|
|
36
|
+
"directory": "packages/layout"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "vite build",
|
|
40
|
+
"test": "bun test src",
|
|
41
|
+
"typecheck:build": "tsc -p tsconfig.build.json --noEmit",
|
|
42
|
+
"prepublishOnly": "bun run build"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"solid-js": "^1.9.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"solid-js": "^1.9.0",
|
|
49
|
+
"typescript": "^5.5.0",
|
|
50
|
+
"vite": "^5.4.0",
|
|
51
|
+
"vite-plugin-dts": "^4.2.0",
|
|
52
|
+
"vite-plugin-solid": "^2.10.0"
|
|
53
|
+
},
|
|
54
|
+
"license": "Apache-2.0"
|
|
55
|
+
}
|