@vibecook/ice 0.16.0-portals.3 → 0.16.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.
Files changed (37) hide show
  1. package/dist/{chunk-NB4ALBIY.js → chunk-BH5AFWJX.js} +57 -215
  2. package/dist/chunk-BH5AFWJX.js.map +1 -0
  3. package/dist/{chunk-SUNUMQLC.js → chunk-REJTEK3V.js} +214 -14
  4. package/dist/chunk-REJTEK3V.js.map +1 -0
  5. package/dist/{chunk-SHU3HVMF.js → chunk-Y7K6CHSF.js} +21 -1
  6. package/dist/chunk-Y7K6CHSF.js.map +1 -0
  7. package/dist/{chunk-6VY7I6VA.js → chunk-ZTY2VRIS.js} +2 -2
  8. package/dist/desk-kit.js +2 -6
  9. package/dist/desk-objects.js +17 -10
  10. package/dist/desk-objects.js.map +1 -1
  11. package/dist/desk.js +7 -5
  12. package/dist/devtools.js +1 -1
  13. package/dist/dom.js +2 -2
  14. package/dist/index.js +3 -1
  15. package/dist/react.js +9 -5
  16. package/dist/react.js.map +1 -1
  17. package/dist/types/packages/core/src/facade/create-canvas-engine.d.ts +2 -1
  18. package/dist/types/packages/core/src/index.d.ts +1 -1
  19. package/dist/types/packages/core/src/systems/held.d.ts +5 -1
  20. package/dist/types/packages/core/src/widget/held-tools.d.ts +35 -0
  21. package/dist/types/packages/desk/src/compose/marks.d.ts +17 -4
  22. package/dist/types/packages/desk/src/compose/reflector.d.ts +5 -2
  23. package/dist/types/packages/desk/src/host/index.d.ts +1 -0
  24. package/dist/types/packages/desk/src/host/live-texture.d.ts +70 -0
  25. package/dist/types/packages/desk/src/index.d.ts +1 -1
  26. package/dist/types/packages/desk/src/kinds/world.d.ts +16 -6
  27. package/dist/types/packages/desk/src/kit/live.d.ts +11 -71
  28. package/dist/types/packages/desk/src/theme.d.ts +12 -0
  29. package/dist/types/packages/objects/src/board/board-pen.d.ts +1 -1
  30. package/dist/types/packages/objects/src/calendar/hand.d.ts +5 -1
  31. package/dist/types/packages/objects/src/notebook/leaf.d.ts +1 -1
  32. package/dist/types/packages/react/src/selection-menu.d.ts +4 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-NB4ALBIY.js.map +0 -1
  35. package/dist/chunk-SHU3HVMF.js.map +0 -1
  36. package/dist/chunk-SUNUMQLC.js.map +0 -1
  37. /package/dist/{chunk-6VY7I6VA.js.map → chunk-ZTY2VRIS.js.map} +0 -0
@@ -12,7 +12,7 @@ import {
12
12
  defineQuery,
13
13
  field,
14
14
  init
15
- } from "./chunk-SHU3HVMF.js";
15
+ } from "./chunk-Y7K6CHSF.js";
16
16
 
17
17
  // ../desk/src/lattice/lod.ts
18
18
  var BASE_SPACING = 20;
@@ -156,6 +156,9 @@ var MAT = {
156
156
  // 14 26 10
157
157
  };
158
158
  var MAT_COLORS = { ground: rgb(MAT.ground.css, STRICT), line: rgb(MAT.line.css, STRICT), cast: rgb(MAT.cast.css, STRICT) };
159
+ function kindPalette(palette) {
160
+ return { ...palette, cast: MAT.cast };
161
+ }
159
162
  var MAT_GRID = {
160
163
  line: { thin: 0.5, thick: 0.75, alphaThin: 0.14, alphaThick: 0.28 },
161
164
  /** ±8/255 on the green channel (0.4× red, 0.35× blue): static hash + drifting value noise + blue noise. */
@@ -1139,26 +1142,26 @@ var HOLD = {
1139
1142
  bar: { travelMs: 340, backMs: 200 }
1140
1143
  };
1141
1144
  var isNarrow = (vp) => vp.width < HOLD.narrow;
1142
- function readingTarget(extent2, vp, spread = false, face = 0, reserves = HOLD) {
1145
+ function readingTarget(extent, vp, spread = false, face = 0, reserves = HOLD) {
1143
1146
  const narrow = isNarrow(vp);
1144
1147
  const m = narrow ? HOLD.marginPhone : HOLD.margin;
1145
1148
  const top = narrow ? HOLD.topPhone : reserves.top;
1146
1149
  const boxW = Math.max(40, vp.width - 2 * m);
1147
1150
  const boxH = Math.max(40, vp.height - top - reserves.band);
1148
- let s = Math.min(boxW / extent2.w, boxH / extent2.h, HOLD.max);
1151
+ let s = Math.min(boxW / extent.w, boxH / extent.h, HOLD.max);
1149
1152
  let single = false;
1150
1153
  if (spread && narrow && vp.width < vp.height * 0.85) {
1151
1154
  const own = Math.max(40, vp.height - top - HOLD.band);
1152
- const s0 = Math.min(boxW / extent2.w, own / extent2.h, HOLD.max);
1153
- if (Math.min(boxW / (extent2.w / 2), own / extent2.h, HOLD.max) > s0 * 1.3) {
1154
- s = Math.min(boxW / (extent2.w / 2), boxH / extent2.h, HOLD.max);
1155
+ const s0 = Math.min(boxW / extent.w, own / extent.h, HOLD.max);
1156
+ if (Math.min(boxW / (extent.w / 2), own / extent.h, HOLD.max) > s0 * 1.3) {
1157
+ s = Math.min(boxW / (extent.w / 2), boxH / extent.h, HOLD.max);
1155
1158
  single = true;
1156
1159
  }
1157
1160
  }
1158
- return { cx: vp.width / 2 - (single ? extent2.w / 4 * s * (1 - 2 * face) : 0), cy: top + boxH / 2, s, single };
1161
+ return { cx: vp.width / 2 - (single ? extent.w / 4 * s * (1 - 2 * face) : 0), cy: top + boxH / 2, s, single };
1159
1162
  }
1160
- function homePose(extent2, angle, cam) {
1161
- return { cx: (extent2.cx - cam.x) * cam.zoom, cy: (extent2.cy - cam.y) * cam.zoom, s: cam.zoom, angle };
1163
+ function homePose(extent, angle, cam) {
1164
+ return { cx: (extent.cx - cam.x) * cam.zoom, cy: (extent.cy - cam.y) * cam.zoom, s: cam.zoom, angle };
1162
1165
  }
1163
1166
  var HELD_USER_REST = { zoom: 1, panX: 0, panY: 0 };
1164
1167
  function heldPose(home, target, user, e) {
@@ -1188,11 +1191,11 @@ function heldFocus(e, vp, theme) {
1188
1191
  light: night ? mixLight(theme.matLight, DAY_LIGHT, e) : theme.matLight
1189
1192
  };
1190
1193
  }
1191
- function heldCamera(pose, rect, extent2, deskZoom, eye, vp) {
1194
+ function heldCamera(pose, rect, extent, deskZoom, eye, vp) {
1192
1195
  const zoom = eye ? Math.min(deskZoom, pose.s) : pose.s;
1193
1196
  const grow = pose.s / zoom;
1194
- const ox = rect.cx - extent2.cx;
1195
- const oy = rect.cy - extent2.cy;
1197
+ const ox = rect.cx - extent.cx;
1198
+ const oy = rect.cy - extent.cy;
1196
1199
  const c = Math.cos(pose.angle);
1197
1200
  const sn = Math.sin(pose.angle);
1198
1201
  const sx = pose.cx + (c * ox - sn * oy) * pose.s;
@@ -1202,11 +1205,11 @@ function heldCamera(pose, rect, extent2, deskZoom, eye, vp) {
1202
1205
  const ey = rect.cy - (sy - vp.height / 2) / (grow * zoom);
1203
1206
  return { cam: { x: ex - vp.width / (2 * zoom), y: ey - vp.height / (2 * zoom), zoom }, grow };
1204
1207
  }
1205
- function heldFrame(pose, extent2, single, face = 0) {
1206
- if (!single) return { cx: pose.cx, cy: pose.cy, hx: extent2.w / 2 * pose.s, hy: extent2.h / 2 * pose.s, s: pose.s };
1207
- const half = extent2.w / 4 * pose.s;
1208
+ function heldFrame(pose, extent, single, face = 0) {
1209
+ if (!single) return { cx: pose.cx, cy: pose.cy, hx: extent.w / 2 * pose.s, hy: extent.h / 2 * pose.s, s: pose.s };
1210
+ const half = extent.w / 4 * pose.s;
1208
1211
  const q = half * (1 - 2 * face);
1209
- return { cx: pose.cx + q * Math.cos(pose.angle), cy: pose.cy + q * Math.sin(pose.angle), hx: half, hy: extent2.h / 2 * pose.s, s: pose.s };
1212
+ return { cx: pose.cx + q * Math.cos(pose.angle), cy: pose.cy + q * Math.sin(pose.angle), hx: half, hy: extent.h / 2 * pose.s, s: pose.s };
1210
1213
  }
1211
1214
  var focusOf = (e, vp) => ({ blur: (isNarrow(vp) ? HOLD.blurPhone : HOLD.blur) * e, dim: HOLD.dim * e });
1212
1215
 
@@ -1649,32 +1652,6 @@ var LayerArray = class {
1649
1652
  }
1650
1653
  };
1651
1654
 
1652
- // ../desk/src/kit/eye.ts
1653
- function eyeOf(cam, vp, law) {
1654
- const zoom = Math.max(cam.zoom, 1e-9);
1655
- const diag = Math.hypot(vp.width, vp.height) / zoom;
1656
- return { ex: cam.x + vp.width / (2 * zoom), ey: cam.y + vp.height / (2 * zoom), h: Math.max(law.min, law.k * diag), zoom, vw: vp.width, vh: vp.height };
1657
- }
1658
- function project(e, x, y, z) {
1659
- const k = e.h / Math.max(e.h - z, 1e-6);
1660
- return [e.vw / 2 + (x - e.ex) * k * e.zoom, e.vh / 2 + (y - e.ey) * k * e.zoom];
1661
- }
1662
- function deskAt(e, sx, sy) {
1663
- return [e.ex + (sx - e.vw / 2) / e.zoom, e.ey + (sy - e.vh / 2) / e.zoom];
1664
- }
1665
- function unproject(e, dx, dy, z) {
1666
- const f = (e.h - z) / e.h;
1667
- return [e.ex + (dx - e.ex) * f, e.ey + (dy - e.ey) * f];
1668
- }
1669
- function rayThrough(e, dx, dy) {
1670
- return { o: [e.ex, e.ey, e.h], d: [dx - e.ex, dy - e.ey, -e.h] };
1671
- }
1672
- function eyeValues(e, reach = 900) {
1673
- const near = Math.max(e.h - reach, 1);
1674
- const far = e.h + 40;
1675
- return { eye: [e.ex, e.ey, e.h, e.zoom], view: [e.vw, e.vh, near, far] };
1676
- }
1677
-
1678
1655
  // ../desk/src/kit/mips.ts
1679
1656
  var WGSL2 = (
1680
1657
  /* wgsl */
@@ -1758,145 +1735,45 @@ function mipsInto(device, encoder, texture, from, to) {
1758
1735
  }
1759
1736
  }
1760
1737
 
1761
- // ../desk/src/kit/live.ts
1762
- function extent(what, v) {
1763
- if (typeof v !== "number" || !Number.isFinite(v) || v < 1) throw new Error(`createLiveTexture: ${what} must be a finite number \u2265 1 (got ${String(v)})`);
1764
- return Math.floor(v);
1765
- }
1766
- function logicalOf(l) {
1767
- if (l === void 0) return null;
1768
- const ok = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
1769
- if (!Array.isArray(l) || !ok(l[0]) || !ok(l[1])) throw new Error(`LiveWriter: a logical size is [width, height], each finite and > 0 (got ${JSON.stringify(l)})`);
1770
- return [l[0], l[1]];
1771
- }
1772
- var isVideoFrame = (s) => typeof s.close === "function" && typeof s.codedWidth === "number";
1773
- function wholeOf(s) {
1774
- if (isVideoFrame(s)) return { x: 0, y: 0, width: s.displayWidth, height: s.displayHeight };
1775
- const c = s;
1776
- return { x: 0, y: 0, width: c.width, height: c.height };
1777
- }
1778
- function createLiveTexture(device, o) {
1779
- const format = o.format ?? "rgba8unorm-srgb";
1780
- if (format !== "rgba8unorm-srgb" && format !== "rgba8unorm") throw new Error(`createLiveTexture: format must be "rgba8unorm-srgb" or "rgba8unorm" (got ${String(format)})`);
1781
- if (typeof o.label !== "string") throw new Error("createLiveTexture: `label` is required \u2014 the caller's, `<kind>/live <key>` by convention");
1782
- const chain = o.mips !== false;
1783
- let width = extent("width", o.width);
1784
- let height = extent("height", o.height);
1785
- const make = (w, h) => device.createTexture({
1786
- label: o.label,
1787
- size: [w, h],
1788
- format,
1789
- mipLevelCount: chain ? mipCount(w, h) : 1,
1790
- usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT
1791
- });
1792
- let texture = make(width, height);
1793
- let view = null;
1794
- let revision = 0;
1795
- let epoch = 0;
1796
- let mipped = { epoch: -1, revision: -1, depth: 0 };
1797
- let logical = null;
1798
- let gone = false;
1799
- const sized = (w, h) => {
1800
- if (w === width && h === height) return;
1801
- logical = null;
1802
- texture.destroy();
1803
- width = w;
1804
- height = h;
1805
- texture = make(w, h);
1806
- view = null;
1807
- epoch += 1;
1808
- };
1809
- const face = {
1810
- get width() {
1811
- return width;
1812
- },
1813
- get height() {
1814
- return height;
1815
- },
1816
- format,
1817
- get revision() {
1818
- return revision;
1819
- },
1820
- get epoch() {
1821
- return epoch;
1822
- },
1823
- view() {
1824
- if (view === null) view = texture.createView();
1825
- return view;
1826
- },
1827
- prepare(encoder, upTo) {
1828
- if (gone || revision === 0) return;
1829
- if (mipped.epoch !== epoch || mipped.revision !== revision) mipped = { epoch, revision, depth: 0 };
1830
- const to = Math.min(Math.floor(upTo), texture.mipLevelCount - 1);
1831
- if (!(to > mipped.depth)) return;
1832
- mipsInto(device, encoder, texture, mipped.depth + 1, to);
1833
- mipped.depth = to;
1834
- },
1835
- get bytes() {
1836
- return chainBytes(width, height, texture.mipLevelCount);
1837
- },
1838
- get logical() {
1839
- return logical ?? [width, height];
1840
- }
1841
- };
1842
- return {
1843
- face,
1844
- present(source, rect, size) {
1845
- try {
1846
- if (gone) return;
1847
- const r = rect ?? wholeOf(source);
1848
- const w = extent("the source's width", r.width);
1849
- const h = extent("the source's height", r.height);
1850
- const l = logicalOf(size);
1851
- sized(w, h);
1852
- device.queue.copyExternalImageToTexture({ source, origin: [r.x, r.y] }, { texture, premultipliedAlpha: false }, [w, h]);
1853
- logical = l;
1854
- revision += 1;
1855
- } finally {
1856
- if (isVideoFrame(source)) source.close();
1857
- }
1858
- },
1859
- presentBytes(bytes, w0, h0, size) {
1860
- if (gone) return;
1861
- const w = extent("width", w0);
1862
- const h = extent("height", h0);
1863
- if (bytes.byteLength < w * h * 4) throw new Error(`LiveWriter.presentBytes: ${bytes.byteLength} bytes for ${w} \xD7 ${h} RGBA8 rows (${w * h * 4} wanted)`);
1864
- const l = logicalOf(size);
1865
- sized(w, h);
1866
- device.queue.writeTexture({ texture }, bytes, { bytesPerRow: w * 4, rowsPerImage: h }, [w, h]);
1867
- logical = l;
1868
- revision += 1;
1869
- },
1870
- presentTexture(src, rect, size) {
1871
- if (gone) return;
1872
- const r = rect ?? { x: 0, y: 0, width: src.width, height: src.height };
1873
- const w = extent("the source's width", r.width);
1874
- const h = extent("the source's height", r.height);
1875
- const l = logicalOf(size);
1876
- sized(w, h);
1877
- const encoder = device.createCommandEncoder({ label: `${o.label} present` });
1878
- encoder.copyTextureToTexture({ texture: src, origin: [r.x, r.y] }, { texture }, [w, h]);
1879
- device.queue.submit([encoder.finish()]);
1880
- logical = l;
1881
- revision += 1;
1882
- },
1883
- resize(w, h) {
1884
- if (gone) return;
1885
- sized(extent("width", w), extent("height", h));
1886
- },
1887
- destroy() {
1888
- if (gone) return;
1889
- gone = true;
1890
- texture.destroy();
1891
- }
1892
- };
1738
+ // ../desk/src/kit/eye.ts
1739
+ function eyeOf(cam, vp, law) {
1740
+ const zoom = Math.max(cam.zoom, 1e-9);
1741
+ const diag = Math.hypot(vp.width, vp.height) / zoom;
1742
+ return { ex: cam.x + vp.width / (2 * zoom), ey: cam.y + vp.height / (2 * zoom), h: Math.max(law.min, law.k * diag), zoom, vw: vp.width, vh: vp.height };
1743
+ }
1744
+ function project(e, x, y, z) {
1745
+ const k = e.h / Math.max(e.h - z, 1e-6);
1746
+ return [e.vw / 2 + (x - e.ex) * k * e.zoom, e.vh / 2 + (y - e.ey) * k * e.zoom];
1747
+ }
1748
+ function deskAt(e, sx, sy) {
1749
+ return [e.ex + (sx - e.vw / 2) / e.zoom, e.ey + (sy - e.vh / 2) / e.zoom];
1750
+ }
1751
+ function unproject(e, dx, dy, z) {
1752
+ const f = (e.h - z) / e.h;
1753
+ return [e.ex + (dx - e.ex) * f, e.ey + (dy - e.ey) * f];
1754
+ }
1755
+ function rayThrough(e, dx, dy) {
1756
+ return { o: [e.ex, e.ey, e.h], d: [dx - e.ex, dy - e.ey, -e.h] };
1893
1757
  }
1758
+ function eyeValues(e, reach = 900) {
1759
+ const near = Math.max(e.h - reach, 1);
1760
+ const far = e.h + 40;
1761
+ return { eye: [e.ex, e.ey, e.h, e.zoom], view: [e.vw, e.vh, near, far] };
1762
+ }
1763
+
1764
+ // ../desk/src/kit/live.ts
1894
1765
  function liveDepth(face, px) {
1895
1766
  const ratio = Math.max(face.width / Math.max(px[0], 1e-6), face.height / Math.max(px[1], 1e-6));
1896
1767
  return ratio <= 1 ? 0 : Math.ceil(Math.log2(ratio) - 1e-9);
1897
1768
  }
1898
1769
  var LIVE = serviceKey("live");
1899
1770
  var UNSEEN = { seen: false, px: [0, 0], held: false };
1771
+ function meetsBox(view, face) {
1772
+ const b = boxOf(view);
1773
+ const x0 = (face.cx - face.w / 2 - view.camX) * view.zoom;
1774
+ const y0 = (face.cy - face.h / 2 - view.camY) * view.zoom;
1775
+ return x0 + face.w * view.zoom > b.x && x0 < b.x + b.w && y0 + face.h * view.zoom > b.y && y0 < b.y + b.h;
1776
+ }
1900
1777
  var sameSeen = (a, b) => a.seen === b.seen && a.held === b.held && a.px[0] === b.px[0] && a.px[1] === b.px[1];
1901
1778
  function createSight(frames) {
1902
1779
  const facts = /* @__PURE__ */ new Map();
@@ -1913,6 +1790,7 @@ function createSight(frames) {
1913
1790
  foldAt = n;
1914
1791
  }
1915
1792
  }
1793
+ if (!meetsBox(slot.view, face)) return;
1916
1794
  const k = slot.view.zoom * slot.view.dpr;
1917
1795
  const glimpse = { w: Math.round(face.w * k), h: Math.round(face.h * k), held: slot.target === "hand" };
1918
1796
  const had = fold.get(e);
@@ -1962,41 +1840,6 @@ function createSight(frames) {
1962
1840
  }
1963
1841
  };
1964
1842
  }
1965
- function stillLive(device, frames) {
1966
- const open = /* @__PURE__ */ new Set();
1967
- return {
1968
- open(key, spec) {
1969
- if (open.has(key)) throw new Error(`stillLive: the face "${key}" is open twice \u2014 one face per key per desk (design-019 \xA73.2)`);
1970
- open.add(key);
1971
- const still = typeof frames === "function" ? frames(key, spec) : frames[key];
1972
- let writer;
1973
- let taken = false;
1974
- let closed = false;
1975
- return {
1976
- key,
1977
- texture: () => writer?.face,
1978
- take() {
1979
- if (taken || closed || still === void 0) return false;
1980
- taken = true;
1981
- writer = createLiveTexture(device, { label: `live/still ${key}`, width: still.width, height: still.height });
1982
- writer.presentBytes(still.bytes, still.width, still.height, still.logical);
1983
- return true;
1984
- },
1985
- state: () => closed ? { is: "closed" } : still === void 0 ? { is: "starting" } : { is: "live" },
1986
- info: () => still?.info ?? {},
1987
- demand: () => {
1988
- },
1989
- close() {
1990
- if (closed) return;
1991
- closed = true;
1992
- writer?.destroy();
1993
- writer = void 0;
1994
- open.delete(key);
1995
- }
1996
- };
1997
- }
1998
- };
1999
- }
2000
1843
 
2001
1844
  // ../desk/src/kit/mesh.ts
2002
1845
  var VERTEX_FLOATS = 16;
@@ -2518,6 +2361,7 @@ export {
2518
2361
  GRID,
2519
2362
  MAT,
2520
2363
  MAT_COLORS,
2364
+ kindPalette,
2521
2365
  MAT_GRID,
2522
2366
  NIGHT,
2523
2367
  EIGENGRAU,
@@ -2627,20 +2471,18 @@ export {
2627
2471
  Layers,
2628
2472
  plainFormat,
2629
2473
  LayerArray,
2474
+ mipCount,
2475
+ generateMips,
2476
+ mipsInto,
2630
2477
  eyeOf,
2631
2478
  project,
2632
2479
  deskAt,
2633
2480
  unproject,
2634
2481
  rayThrough,
2635
2482
  eyeValues,
2636
- mipCount,
2637
- generateMips,
2638
- mipsInto,
2639
- createLiveTexture,
2640
2483
  liveDepth,
2641
2484
  LIVE,
2642
2485
  createSight,
2643
- stillLive,
2644
2486
  VERTEX_FLOATS,
2645
2487
  VERTEX_BYTES,
2646
2488
  FLAG_TWO_SIDED,
@@ -2682,4 +2524,4 @@ export {
2682
2524
  writeChanged,
2683
2525
  lineWeight
2684
2526
  };
2685
- //# sourceMappingURL=chunk-NB4ALBIY.js.map
2527
+ //# sourceMappingURL=chunk-BH5AFWJX.js.map