reifyui 0.18.5 → 0.19.1
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 +43 -0
- package/dist/index.cjs +128 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +122 -8
- package/dist/index.js.map +1 -1
- package/dist/tree.cjs +1159 -0
- package/dist/tree.cjs.map +1 -0
- package/dist/tree.d.ts +178 -0
- package/dist/tree.js +1129 -0
- package/dist/tree.js.map +1 -0
- package/package.json +9 -1
- package/src/auth/AuthForm.jsx +2 -0
- package/src/auth/client.js +34 -4
- package/src/auth/personCheck.js +98 -0
- package/src/index.d.ts +7 -1
- package/src/index.js +2 -1
- package/src/tree/FileTree.jsx +668 -0
- package/src/tree/index.d.ts +178 -0
- package/src/tree/index.js +14 -0
- package/src/tree/model.js +220 -0
- package/styles/tree.css +199 -0
package/dist/tree.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tree/FileTree.jsx","../src/tree/model.js"],"sourcesContent":["// FileTree — a folder tree of files the way an editor's Explorer shows one: folders first, a\n// chevron to open each, the open file marked, and the tree's own actions (new file, new folder,\n// upload, collapse all) in its header beside its title. Names are typed in place (New file, New\n// folder, Rename), a delete asks in the row, a row drags into another folder, and a right click,\n// Shift+F10 or the menu key opens the row's menu. The keyboard follows the WAI-ARIA tree pattern.\n//\n// The tree owns no files: it draws `entries` and reports what the person did (onCreate, onRename,\n// onDelete, onMove, onUpload); the host changes its list and passes it back. A handler may return\n// a message (or a Promise of one) to refuse, and that message is shown where the person acted.\n//\n// Look and behaviour follow the HarnessRouter console's skill-editor tree (30px rows, 14px icons,\n// 14px per level, the open file on the surface colour with a hairline, row actions at the right on\n// hover). Styles: reifyui/styles/tree.css.\nimport React, { useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport {\n DEFAULT_TREE_LABELS, baseName, buildFileTree, canMove, folderPaths, isWithin, joinPath, movedPath,\n nameProblem, parentOf, splitExt, treeKeyAction, visibleRows,\n} from './model.js';\n\nconst useIsoLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\nconst DRAG_TYPE = 'application/x-reifyui-tree-path';\nconst OPEN_ON_HOVER_MS = 600; // a closed folder held under a drag opens after this\nconst FOCUS_WAIT_MS = 4000; // how long a focus waits for its row to arrive from the host\nconst HEADER_ACTIONS = ['newFile', 'newFolder', 'upload', 'collapseAll'];\n// the resolved colours a menu carries with it into document.body, where the host's theme class\n// (set on some ancestor of the tree) no longer reaches\nconst MENU_VARS = ['--_surface', '--_ink', '--_mute', '--_faint', '--_line', '--_brand', '--_hover', '--_fail', '--_shadow',\n '--_r-menu', '--_r-row', '--_z', '--_fs-md'];\n\nconst say = (v, ...a) => (typeof v === 'function' ? v(...a) : v);\n\nfunction Svg({ s = 14, children }) {\n return (\n <svg width={s} height={s} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\"\n strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">{children}</svg>\n );\n}\nconst I = {\n file: <Svg><path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z\" /><path d=\"M14 3v5h5\" /></Svg>,\n folder: <Svg><path d=\"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\" /></Svg>,\n chevron: <Svg s={12}><path d=\"M9 6l6 6-6 6\" /></Svg>,\n newFile: <Svg><path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z\" /><path d=\"M14 3v5h5\" /><path d=\"M12 11v6M9 14h6\" /></Svg>,\n newFolder: <Svg><path d=\"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\" /><path d=\"M12 10.5v5M9.5 13h5\" /></Svg>,\n upload: <Svg><path d=\"M12 16V4M7 9l5-5 5 5\" /><path d=\"M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3\" /></Svg>,\n collapseAll: <Svg><path d=\"M7 10l5-5 5 5M7 19l5-5 5 5\" /></Svg>,\n pencil: <Svg><path d=\"M12 20h9\" /><path d=\"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z\" /></Svg>,\n trash: <Svg><path d=\"M4 7h16M9 7V4.5h6V7M18 7l-1 13H7L6 7M10 11v5M14 11v5\" /></Svg>,\n};\n\n/** A handler's answer as a message: '' when it went through, the host's words when it refused,\n * the generic failure when it threw. */\nasync function answer(fn, failed) {\n try { const r = await fn(); return typeof r === 'string' ? r : ''; }\n catch { return failed; }\n}\n\n/** A name cut at the end, its extension kept whole. */\nfunction Name({ name }) {\n const [base, ext] = splitExt(name);\n return <span className=\"rui-tree-name\"><span className=\"rui-tree-base\">{base}</span>{ext ? <span className=\"rui-tree-ext\">{ext}</span> : null}</span>;\n}\n\n/** The row's menu: fixed at the pointer (or under the row from the keyboard), kept inside the\n * window, closed by Escape, a press outside, a scroll, or a choice. */\nfunction TreeMenu({ menu, items, label, tokensFrom, onClose, menuRef }) {\n const [pos, setPos] = useState(null);\n const btns = useRef([]);\n const style = useMemo(() => {\n const s = {};\n const src = tokensFrom.current;\n if (src && typeof getComputedStyle === 'function') {\n const cs = getComputedStyle(src);\n for (const v of MENU_VARS) { const val = cs.getPropertyValue(v); if (val) s[v] = val.trim(); }\n s.fontFamily = cs.fontFamily;\n }\n return s;\n }, [tokensFrom, menu]);\n\n useIsoLayoutEffect(() => {\n const el = menuRef.current;\n if (!el) return;\n const r = el.getBoundingClientRect();\n const vw = window.innerWidth, vh = window.innerHeight, m = 8;\n const left = Math.max(m, Math.min(menu.x, vw - r.width - m));\n const top = menu.y + r.height > vh - m ? Math.max(m, menu.y - r.height) : menu.y;\n setPos({ left, top });\n }, [menu]);\n useEffect(() => { if (pos) btns.current.find((b) => b && !b.disabled)?.focus(); }, [pos]);\n\n useEffect(() => {\n const down = (e) => { if (!menuRef.current?.contains(e.target)) onClose(false); };\n const scroll = (e) => { if (!menuRef.current?.contains(e.target)) onClose(false); };\n const resize = () => onClose(false);\n document.addEventListener('pointerdown', down, true);\n window.addEventListener('scroll', scroll, true);\n window.addEventListener('resize', resize);\n return () => {\n document.removeEventListener('pointerdown', down, true);\n window.removeEventListener('scroll', scroll, true);\n window.removeEventListener('resize', resize);\n };\n }, [onClose, menuRef]);\n\n const onKeyDown = (e) => {\n const list = btns.current.filter((b) => b && !b.disabled);\n const at = list.indexOf(document.activeElement);\n const go = (i) => { e.preventDefault(); list[(i + list.length) % list.length]?.focus(); };\n if (e.key === 'ArrowDown') go(at + 1);\n else if (e.key === 'ArrowUp') go(at < 0 ? list.length - 1 : at - 1);\n else if (e.key === 'Home') go(0);\n else if (e.key === 'End') go(list.length - 1);\n else if (e.key === 'Tab' || e.key === 'Escape') { e.preventDefault(); onClose(true); }\n };\n\n btns.current = [];\n let k = 0;\n return createPortal(\n <div ref={menuRef} className=\"rui-tree-menu\" role=\"menu\" aria-label={label} onKeyDown={onKeyDown}\n onContextMenu={(e) => e.preventDefault()}\n style={{ ...style, left: pos ? pos.left : menu.x, top: pos ? pos.top : menu.y, visibility: pos ? 'visible' : 'hidden' }}>\n {items.map((it, i) => (it.sep ? <div key={`s${i}`} className=\"rui-tree-menu-sep\" role=\"separator\" /> : (\n <button key={it.id} type=\"button\" role=\"menuitem\" tabIndex={-1} ref={(el) => { btns.current[k++] = el; }}\n className={`rui-tree-menu-item${it.danger ? ' is-danger' : ''}`} disabled={it.disabled}\n aria-keyshortcuts={it.keys || undefined}\n onClick={() => { onClose(false); it.run(); }}>\n <span className=\"rui-tree-menu-label\">{it.label}</span>\n {it.hint ? <kbd className=\"rui-tree-menu-hint\" aria-hidden=\"true\">{it.hint}</kbd> : null}\n </button>\n )))}\n </div>,\n document.body,\n );\n}\n\nexport function FileTree(props) {\n const {\n entries, selected = null, onSelect,\n open: openProp, defaultOpen = true, onOpenChange,\n title, label, actions, labels: labelsProp,\n onCreate, onRename, onDelete, onMove, onUpload, validateName, menuItems,\n readOnly = false, busy = false, pending, rowErrors, error,\n className, style,\n } = props;\n const L = useMemo(() => ({ ...DEFAULT_TREE_LABELS, ...(labelsProp || {}) }), [labelsProp]);\n const uid = useId().replace(/:/g, '');\n const rootRef = useRef(null);\n const menuRef = useRef(null);\n const inputRef = useRef(null);\n const askRef = useRef(null);\n\n const tree = useMemo(() => buildFileTree(entries), [entries]);\n const editable = !readOnly;\n\n // ── open folders: controlled (open + onOpenChange) or kept here ────────────────────────────────\n // Kept here as \"everything open except\" (defaultOpen true: folders that arrive later start open)\n // or \"only these open\" (a list, or after Collapse all).\n const controlled = Array.isArray(openProp);\n const [kept, setKept] = useState(() => (defaultOpen === true\n ? { all: true, set: new Set() } : { all: false, set: new Set(Array.isArray(defaultOpen) ? defaultOpen : []) }));\n // the latest open state, read by changes made one after another in the same event (a move both\n // carries a folder's open state to its new path and opens the folder it landed in)\n const keptRef = useRef(kept);\n const ctlRef = useRef(openProp);\n if (controlled) ctlRef.current = openProp;\n const openSet = useMemo(() => (controlled ? new Set(openProp) : null), [controlled, openProp]);\n const isOpen = useCallback((p) => (controlled ? openSet.has(p) : kept.all ? !kept.set.has(p) : kept.set.has(p)),\n [controlled, openSet, kept]);\n const readOpen = () => (controlled ? { all: false, set: new Set(ctlRef.current || []) } : keptRef.current);\n const writeOpen = (next) => {\n if (controlled) { const list = Array.from(next.set); ctlRef.current = list; onOpenChange?.(list); return; }\n keptRef.current = next;\n setKept(next);\n onOpenChange?.(next.all ? folderPaths(tree).filter((p) => !next.set.has(p)) : Array.from(next.set));\n };\n const setOpen = (paths, value) => {\n const cur = readOpen();\n const set = new Set(cur.set);\n let changed = false;\n for (const p of paths) {\n if (!p) continue;\n const inSet = cur.all ? !value : value;\n if (set.has(p) !== inSet) { if (inSet) set.add(p); else set.delete(p); changed = true; }\n }\n if (changed) writeOpen({ all: cur.all, set });\n };\n const remapOpen = (from, to) => {\n const cur = readOpen();\n if (!Array.from(cur.set).some((p) => isWithin(p, from))) return;\n writeOpen({ all: cur.all, set: new Set(Array.from(cur.set).map((p) => movedPath(p, from, to))) });\n };\n const collapseAll = () => {\n writeOpen({ all: false, set: new Set() });\n if (active) setActive(active.split('/')[0]);\n };\n\n const rows = useMemo(() => visibleRows(tree.nodes, isOpen), [tree, isOpen]);\n\n // ── focus: one row holds the tab stop; `active` is the last row the person was on ──────────────\n // null: not yet on any row; '': the top (an empty part of the tree was clicked).\n const [active, setActive] = useState(null);\n const pendingFocus = useRef(null);\n const focusSoon = (path) => { pendingFocus.current = { path, at: Date.now() }; setActive(path); };\n const tabPath = useMemo(() => {\n const has = (p) => rows.some((r) => r.path === p);\n for (let p = active; p; p = parentOf(p)) if (has(p)) return p;\n if (selected && has(selected)) return selected;\n return rows[0]?.path ?? null;\n }, [rows, active, selected]);\n const tabPathRef = useRef(tabPath);\n tabPathRef.current = tabPath;\n useEffect(() => {\n const want = pendingFocus.current;\n if (!want) return;\n if (Date.now() - want.at > FOCUS_WAIT_MS) { pendingFocus.current = null; return; }\n const root = rootRef.current;\n if (!root) return;\n const here = document.activeElement;\n if (here && here !== document.body && !root.contains(here)) { pendingFocus.current = null; return; }\n const el = Array.from(root.querySelectorAll('[role=\"treeitem\"][data-path]')).find((x) => x.dataset.path === want.path);\n if (el) { pendingFocus.current = null; el.focus(); }\n });\n // the selected file is never hidden in a closed folder: its folders open when it changes\n useEffect(() => {\n if (!selected) return;\n const up = [];\n for (let p = parentOf(selected); p; p = parentOf(p)) if (tree.byPath.get(p)?.kind === 'dir' && !isOpen(p)) up.push(p);\n if (up.length) setOpen(up, true);\n // when the selection changes, not when a folder is closed around it\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selected]);\n\n // ── transient states: a name being typed, a delete being asked, a menu ─────────────────────────\n const [edit, setEditState] = useState(null); // { mode: 'create', kind, dir, value, err, busy } | { mode: 'rename', path, kind, ... }\n const editRef = useRef(null);\n const setEdit = (x) => { editRef.current = x; setEditState(x); };\n const returnTo = useRef(null);\n const [ask, setAsk] = useState(null); // { path, kind, files, busy }\n const [menu, setMenu] = useState(null); // { path, kind, x, y }\n const [notes, setNotes] = useState({}); // a refused delete or move, under its row\n const note = (path, msg) => setNotes((n) => { const x = { ...n }; if (msg) x[path] = msg; else delete x[path]; return x; });\n\n const nodeKind = (p) => tree.byPath.get(p)?.kind;\n // the nearest folder that still exists (the host may have removed the one last used)\n const existingDir = (d) => { let x = d || ''; while (x && nodeKind(x) !== 'dir') x = parentOf(x); return x; };\n const targetDir = () => {\n const from = active !== null ? active : selected;\n if (!from) return '';\n return existingDir(nodeKind(from) === 'dir' ? from : parentOf(from));\n };\n const childNames = (dir) => (tree.byPath.get(dir)?.children || []).map((c) => c.name);\n const hold = busy;\n\n // a name the host is still answering for stays until it answers\n function dropEdit() { if (!editRef.current?.busy) setEdit(null); }\n function closeAll() { dropEdit(); setAsk(null); setMenu(null); }\n\n function startCreate(kind, dir) {\n if (!editable || !onCreate || hold || editRef.current?.busy) return;\n setAsk(null); setMenu(null);\n returnTo.current = typeof document !== 'undefined' ? document.activeElement : null;\n dir = existingDir(dir);\n if (dir) setOpen([...ancestorsOf(dir), dir], true);\n setEdit({ mode: 'create', kind, dir, value: '', err: '', busy: false });\n }\n function startRename(path) {\n if (!editable || !onRename || hold || editRef.current?.busy || !tree.byPath.has(path)) return;\n setAsk(null); setMenu(null);\n setEdit({ mode: 'rename', path, kind: nodeKind(path), value: baseName(path), err: '', busy: false });\n setActive(path);\n }\n function askDelete(path) {\n if (!editable || !onDelete || hold) return;\n const n = tree.byPath.get(path);\n if (!n) return;\n dropEdit(); setMenu(null);\n setAsk({ path, kind: n.kind, files: n.files, busy: false });\n setActive(path);\n }\n\n async function commitEdit(fromBlur) {\n const ed = editRef.current;\n if (!ed || ed.busy) return;\n const value = ed.value.trim();\n const same = ed.mode === 'rename' && value === baseName(ed.path);\n if (same || (fromBlur && !value)) {\n setEdit(null);\n if (!fromBlur) { if (ed.mode === 'rename') focusSoon(ed.path); else restoreFocus(); }\n return;\n }\n const dir = ed.mode === 'create' ? ed.dir : parentOf(ed.path);\n const siblings = childNames(dir).filter((n) => ed.mode !== 'rename' || n !== baseName(ed.path));\n const err = nameProblem(value, { kind: ed.kind, dir, siblings, labels: L, validate: validateName });\n if (err) { setEdit({ ...ed, err }); return; }\n const to = joinPath(dir, value);\n const going = { ...ed, err: '', busy: true };\n setEdit(going);\n const refused = await answer(() => (ed.mode === 'create'\n ? onCreate({ path: to, kind: ed.kind }) : onRename({ from: ed.path, to, kind: ed.kind })), L.failed);\n if (editRef.current !== going) return; // put away while the host was answering\n if (refused) { setEdit({ ...going, busy: false, err: refused }); return; }\n setEdit(null);\n if (ed.mode === 'rename' && ed.kind === 'dir') remapOpen(ed.path, to);\n if (ed.mode === 'create' && ed.kind === 'dir') setOpen([to], true);\n if (fromBlur) setActive(to); else focusSoon(to);\n }\n\n async function confirmDelete() {\n const a = ask;\n if (!a || a.busy) return;\n const i = rows.findIndex((r) => r.path === a.path);\n const after = rows.slice(i + 1).find((r) => !isWithin(r.path, a.path));\n const next = after && parentOf(after.path) === parentOf(a.path) ? after.path : (rows[i - 1]?.path ?? after?.path ?? null);\n const going = { ...a, busy: true };\n setAsk(going);\n const refused = await answer(() => onDelete({ path: a.path, kind: a.kind }), L.failed);\n setAsk((cur) => (cur && cur.path === a.path ? null : cur));\n if (refused) { note(a.path, refused); focusSoon(a.path); return; }\n note(a.path, '');\n if (next !== null) focusSoon(next); else setActive(null);\n }\n\n async function doMove(from, kind, toDir) {\n const to = joinPath(toDir, baseName(from));\n note(from, '');\n const refused = await answer(() => onMove({ from, toDir, kind }), L.failed);\n if (refused) { note(from, refused); return; }\n if (kind === 'dir') remapOpen(from, to);\n if (toDir) setOpen([...ancestorsOf(toDir), toDir], true);\n setActive(to);\n }\n\n function restoreFocus() {\n const el = returnTo.current;\n returnTo.current = null;\n if (el && el.isConnected && rootRef.current?.contains(el)) el.focus();\n else if (tabPath) focusSoon(tabPath);\n }\n\n // Escape puts away the innermost thing, and only that: a dialog the tree sits in stays open\n // (taken on the way down, before a host's own Escape listener hears it).\n useEffect(() => {\n if (!edit && !ask && !menu) return undefined;\n const onKey = (e) => {\n if (e.key !== 'Escape') return;\n const t = e.target;\n if (!(rootRef.current?.contains(t) || menuRef.current?.contains(t))) return;\n e.stopPropagation(); e.preventDefault();\n if (menu) { setMenu(null); focusSoon(menu.path || tabPath); return; }\n if (editRef.current) {\n const ed = editRef.current;\n if (ed.busy) return;\n setEdit(null);\n if (ed.mode === 'rename') focusSoon(ed.path); else restoreFocus();\n return;\n }\n if (ask) { setAsk(null); focusSoon(ask.path); }\n };\n window.addEventListener('keydown', onKey, true);\n return () => window.removeEventListener('keydown', onKey, true);\n });\n\n // a name being typed takes focus as it opens, the name selected without its extension\n useEffect(() => {\n const el = inputRef.current;\n if (!el || !edit) return;\n el.focus();\n const v = el.value;\n const dot = edit.mode === 'rename' && edit.kind === 'file' ? splitExt(v)[0].length : v.length;\n el.setSelectionRange(edit.mode === 'rename' ? 0 : v.length, dot);\n // when one opens, not on every keystroke\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [edit?.mode, edit?.path, edit?.dir, edit?.kind]);\n // a delete being asked: its Delete button takes focus, as the console's in-row confirms do\n useEffect(() => { if (ask && !ask.busy) askRef.current?.focus(); }, [ask?.path]); // eslint-disable-line react-hooks/exhaustive-deps\n\n // ── the menu ───────────────────────────────────────────────────────────────────────────────────\n const itemsFor = (path, kind) => {\n const at = kind === 'dir' ? path : parentOf(path);\n const groups = [[], [], []];\n if (onCreate) {\n groups[0].push({ id: 'new-file', label: L.newFile, run: () => startCreate('file', at) });\n groups[0].push({ id: 'new-folder', label: L.newFolder, run: () => startCreate('dir', at) });\n }\n if (path) {\n if (onRename) groups[1].push({ id: 'rename', label: L.rename, hint: L.renameKey, keys: 'F2', run: () => startRename(path) });\n for (const m of menuItems || []) {\n if (m.when && !m.when(path, kind)) continue;\n groups[1].push({ id: `x-${m.id}`, label: m.label, disabled: !!m.disabled, run: () => { focusSoon(path); m.onSelect(path, kind); } });\n }\n if (onDelete) groups[2].push({ id: 'delete', label: L.delete, hint: L.deleteKey, keys: 'Delete', danger: true, run: () => askDelete(path) });\n }\n const out = [];\n for (const g of groups) { if (!g.length) continue; if (out.length) out.push({ sep: true }); out.push(...g); }\n return out;\n };\n function openMenu(path, kind, x, y) {\n if (!editable || hold) return false;\n if (!itemsFor(path, kind).length) return false;\n dropEdit(); setAsk(null);\n setMenu({ path, kind, x, y });\n if (path) setActive(path);\n return true;\n }\n const menuNow = useRef(null);\n menuNow.current = menu;\n const closeMenu = useCallback((refocus) => {\n const m = menuNow.current;\n if (!m) return;\n if (refocus) pendingFocus.current = { path: m.path || tabPathRef.current, at: Date.now() };\n setMenu(null);\n }, []);\n function menuFromKeyboard(path) {\n const el = rowEl(path);\n const r = el ? el.getBoundingClientRect() : { left: 0, bottom: 0 };\n openMenu(path, nodeKind(path), Math.round(r.left + 24), Math.round(r.bottom));\n }\n const rowEl = (path) => Array.from(rootRef.current?.querySelectorAll('[data-row]') || []).find((x) => x.dataset.row === path);\n\n // ── keyboard on the tree ──────────────────────────────────────────────────────────────────────\n function onTreeKeyDown(e) {\n const t = e.target;\n if (t.closest('input, button, .rui-tree-ask')) return;\n const item = t.closest('[role=\"treeitem\"]');\n if (!item || item.dataset.path === undefined) return;\n const act = treeKeyAction(rows, item.dataset.path, e, { editable });\n if (!act) return;\n e.preventDefault();\n switch (act.type) {\n case 'focus': focusSoon(act.path); break;\n case 'open': setOpen([act.path], true); break;\n case 'close': setOpen([act.path], false); break;\n case 'activate':\n closeAll();\n onSelect?.(act.path, act.kind);\n if (act.kind === 'dir') setOpen([act.path], !isOpen(act.path));\n break;\n case 'rename': startRename(act.path); break;\n case 'delete': askDelete(act.path); break;\n case 'menu': menuFromKeyboard(act.path); break;\n default: break;\n }\n }\n function onRowClick(r) {\n if (editRef.current?.mode === 'rename' && editRef.current.path === r.path) return;\n dropEdit(); setAsk(null);\n setActive(r.path);\n onSelect?.(r.path, r.kind);\n if (r.kind === 'dir') setOpen([r.path], !isOpen(r.path));\n }\n\n // ── drag a row into a folder ──────────────────────────────────────────────────────────────────\n const dragRef = useRef(null);\n const [dragging, setDragging] = useState(null);\n const [dropDir, setDropDirState] = useState(null);\n const dropRef = useRef(null);\n const hoverTimer = useRef(null);\n const setDropDir = (d) => {\n if (dropRef.current === d) return;\n dropRef.current = d;\n setDropDirState(d);\n clearTimeout(hoverTimer.current);\n if (d && !isOpen(d)) hoverTimer.current = setTimeout(() => { if (dropRef.current === d) setOpen([d], true); }, OPEN_ON_HOVER_MS);\n };\n useEffect(() => () => clearTimeout(hoverTimer.current), []);\n const canDrag = editable && !!onMove && !hold;\n const overDir = (e, dir) => {\n const d = dragRef.current;\n if (!d) return;\n e.stopPropagation();\n if (canMove(tree, d.path, dir)) { e.preventDefault(); e.dataTransfer.dropEffect = 'move'; setDropDir(dir); }\n else { e.dataTransfer.dropEffect = 'none'; setDropDir(null); }\n };\n const dropOn = (e, dir) => {\n const d = dragRef.current;\n if (!d) return;\n e.preventDefault(); e.stopPropagation();\n dragRef.current = null; setDragging(null); setDropDir(null);\n if (canMove(tree, d.path, dir)) void doMove(d.path, d.kind, dir);\n };\n const endDrag = () => { dragRef.current = null; setDragging(null); setDropDir(null); };\n\n // ── what the header offers ────────────────────────────────────────────────────────────────────\n const wanted = Array.isArray(actions) ? actions : HEADER_ACTIONS;\n const offered = wanted.filter((a) => (a === 'collapseAll' ? true\n : !editable ? false : a === 'upload' ? !!onUpload : (a === 'newFile' || a === 'newFolder') ? !!onCreate : false));\n const headerAction = {\n newFile: { label: L.newFile, icon: I.newFile, run: () => startCreate('file', targetDir()), mutates: true },\n newFolder: { label: L.newFolder, icon: I.newFolder, run: () => startCreate('dir', targetDir()), mutates: true },\n upload: { label: L.upload, icon: I.upload, run: () => onUpload(targetDir()), mutates: true },\n collapseAll: { label: L.collapseAll, icon: I.collapseAll, run: collapseAll, mutates: false },\n };\n\n // ── rendering ─────────────────────────────────────────────────────────────────────────────────\n const pendingSet = useMemo(() => new Set(pending || []), [pending]);\n const errs = rowErrors || {};\n const depthStyle = (depth) => ({ '--rui-tree-d': depth });\n let msgN = 0;\n\n const entryRow = (dir, depth) => {\n const ed = edit;\n const errId = `${uid}-new-err`;\n return (\n <li key=\"__rui-tree-new\" role=\"treeitem\" aria-level={depth} aria-selected={false} className=\"rui-tree-item is-new\"\n aria-label={ed.kind === 'dir' ? L.newFolderInput : L.newFileInput}>\n <div className=\"rui-tree-row is-editing\" style={depthStyle(depth - 1)}>\n <span className=\"rui-tree-twisty\" aria-hidden=\"true\" />\n <span className=\"rui-tree-icon\" aria-hidden=\"true\">{ed.kind === 'dir' ? I.folder : I.file}</span>\n {nameInput(ed, ed.kind === 'dir' ? L.newFolderInput : L.newFileInput, errId)}\n </div>\n {ed.err ? <p className=\"rui-tree-msg is-error\" id={errId} role=\"alert\" style={depthStyle(depth - 1)}>{ed.err}</p> : null}\n </li>\n );\n };\n function nameInput(ed, aria, errId) {\n return (\n <input ref={inputRef} className=\"rui-tree-input\" value={ed.value} aria-label={aria} autoComplete=\"off\" spellCheck={false}\n readOnly={ed.busy} aria-busy={ed.busy || undefined} aria-invalid={!!ed.err} aria-describedby={ed.err ? errId : undefined}\n onClick={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}\n onChange={(e) => setEdit({ ...ed, value: e.target.value, err: '' })}\n onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); void commitEdit(false); } }}\n onBlur={() => { if (editRef.current) void commitEdit(true); }} />\n );\n }\n\n function renderNode(n) {\n const r = { path: n.path, kind: n.kind, depth: n.depth };\n const isDir = n.kind === 'dir';\n const open = isDir && isOpen(n.path);\n const renaming = edit && edit.mode === 'rename' && edit.path === n.path;\n const asking = ask && ask.path === n.path;\n const sel = selected === n.path;\n const busyRow = pendingSet.has(n.path);\n const msg = errs[n.path] || notes[n.path] || '';\n const msgId = msg ? `${uid}-m${msgN++}` : undefined;\n const errId = `${uid}-ren-err`;\n const creatingHere = edit && edit.mode === 'create' && isDir && edit.dir === n.path;\n const kids = open ? n.children : [];\n const cls = ['rui-tree-row', sel ? 'is-selected' : '', isDir && active === n.path ? 'is-target' : '',\n menu && menu.path === n.path ? 'is-menu' : '', busyRow ? 'is-pending' : '', renaming ? 'is-editing' : '',\n dragging === n.path ? 'is-dragging' : ''].filter(Boolean).join(' ');\n const showActs = editable && !renaming && !busyRow && (onRename || onDelete);\n return (\n <li key={n.path} role=\"treeitem\" data-path={n.path} aria-level={n.depth} aria-expanded={isDir ? open : undefined}\n aria-selected={sel} aria-busy={busyRow || undefined} aria-describedby={msgId}\n tabIndex={tabPath === n.path ? 0 : -1}\n className={`rui-tree-item${dropDir === n.path ? ' is-drop' : ''}`}>\n <div className={cls} data-row={n.path} style={depthStyle(n.depth - 1)} title={n.path}\n draggable={canDrag && !renaming ? true : undefined}\n onClick={() => onRowClick(r)}\n onContextMenu={(e) => { if (openMenu(n.path, n.kind, e.clientX, e.clientY)) e.preventDefault(); e.stopPropagation(); }}\n onDragStart={canDrag ? (e) => {\n closeAll();\n dragRef.current = { path: n.path, kind: n.kind };\n setDragging(n.path);\n e.dataTransfer.effectAllowed = 'move';\n try { e.dataTransfer.setData(DRAG_TYPE, n.path); e.dataTransfer.setData('text/plain', n.path); } catch { /* old engines */ }\n } : undefined}\n onDragEnd={canDrag ? endDrag : undefined}\n onDragEnter={(e) => overDir(e, isDir ? n.path : parentOf(n.path))}\n onDragOver={(e) => overDir(e, isDir ? n.path : parentOf(n.path))}\n onDrop={(e) => dropOn(e, isDir ? n.path : parentOf(n.path))}>\n <span className={`rui-tree-twisty${open ? ' is-open' : ''}`} aria-hidden=\"true\">{isDir ? I.chevron : null}</span>\n <span className=\"rui-tree-icon\" aria-hidden=\"true\">{isDir ? I.folder : I.file}</span>\n {renaming ? nameInput(edit, say(L.renameInput, n.name), errId) : <Name name={n.name} />}\n {!renaming && n.note ? <span className=\"rui-tree-note\">{n.note}</span> : null}\n {!renaming && isDir && !n.children.length ? <span className=\"rui-tree-tag\">{L.emptyFolder}</span> : null}\n {busyRow ? <span className=\"rui-tree-spin\" role=\"status\"><span className=\"rui-tree-sr\">{L.saving}</span></span> : null}\n {showActs ? (\n <span className=\"rui-tree-acts\" aria-hidden=\"true\">\n {onRename ? (\n <button type=\"button\" className=\"rui-tree-ib\" tabIndex={-1} title={L.rename} disabled={hold}\n onMouseDown={(e) => e.preventDefault()}\n onClick={(e) => { e.stopPropagation(); startRename(n.path); }}>{I.pencil}</button>\n ) : null}\n {onDelete ? (\n <button type=\"button\" className=\"rui-tree-ib\" tabIndex={-1} title={L.delete} disabled={hold}\n onMouseDown={(e) => e.preventDefault()}\n onClick={(e) => { e.stopPropagation(); askDelete(n.path); }}>{I.trash}</button>\n ) : null}\n </span>\n ) : null}\n </div>\n {renaming && edit.err ? <p className=\"rui-tree-msg is-error\" id={errId} role=\"alert\" style={depthStyle(n.depth - 1)}>{edit.err}</p> : null}\n {msg ? <p className=\"rui-tree-msg is-error\" id={msgId} style={depthStyle(n.depth - 1)}>{msg}</p> : null}\n {asking ? (\n <div className=\"rui-tree-ask\" role=\"group\" aria-label={isDir ? say(L.confirmFolder, n.name, n.files) : say(L.confirmFile, n.name)}\n style={depthStyle(n.depth - 1)}>\n <span className=\"rui-tree-ask-q\">{isDir ? say(L.confirmFolder, n.name, n.files) : say(L.confirmFile, n.name)}</span>\n <span className=\"rui-tree-ask-b\">\n <button type=\"button\" className=\"rui-tree-link\" disabled={ask.busy} onClick={() => { setAsk(null); focusSoon(n.path); }}>{L.keep}</button>\n <button type=\"button\" className=\"rui-tree-link is-danger\" ref={askRef} disabled={ask.busy} onClick={() => void confirmDelete()}>{L.delete}</button>\n </span>\n </div>\n ) : null}\n {(open && kids.length) || creatingHere ? (\n <ul role=\"group\" className=\"rui-tree-group\">\n {kids.map(renderNode)}\n {creatingHere ? entryRow(n.path, n.depth + 1) : null}\n </ul>\n ) : null}\n </li>\n );\n }\n\n const empty = !tree.nodes.length;\n const creatingAtTop = edit && edit.mode === 'create' && edit.dir === '';\n const treeLabel = label || title || L.tree;\n const rootClass = ['rui-tree', readOnly ? 'is-readonly' : '', className || ''].filter(Boolean).join(' ');\n\n return (\n <div ref={rootRef} className={rootClass} style={style}>\n {title || offered.length ? (\n <div className=\"rui-tree-head\">\n {title ? <span className=\"rui-tree-title\">{title}</span> : <span className=\"rui-tree-title\" />}\n {offered.length ? (\n <span className=\"rui-tree-tools\">\n {offered.map((a) => (\n <button key={a} type=\"button\" className=\"rui-tree-tool\" aria-label={headerAction[a].label} title={headerAction[a].label}\n disabled={headerAction[a].mutates && hold} onClick={headerAction[a].run}>{headerAction[a].icon}</button>\n ))}\n </span>\n ) : null}\n </div>\n ) : null}\n {error ? <p className=\"rui-tree-msg is-error is-tree\" role=\"alert\">{error}</p> : null}\n <div className={`rui-tree-body${dropDir === '' ? ' is-drop' : ''}`}\n onClick={(e) => { if (e.target === e.currentTarget || e.target.classList?.contains('rui-tree-list')) { dropEdit(); setAsk(null); setActive(''); } }}\n onContextMenu={(e) => { if (e.target.closest('[data-row]')) return; if (openMenu('', 'dir', e.clientX, e.clientY)) e.preventDefault(); }}\n onDragEnter={(e) => overDir(e, '')} onDragOver={(e) => overDir(e, '')} onDrop={(e) => dropOn(e, '')}\n onDragLeave={(e) => {\n // Chrome often gives a drag's leave no relatedTarget, even between two rows: where the\n // pointer is says whether it left the tree\n const b = e.currentTarget.getBoundingClientRect();\n const out = e.relatedTarget ? !e.currentTarget.contains(e.relatedTarget)\n : e.clientX < b.left || e.clientX >= b.right || e.clientY < b.top || e.clientY >= b.bottom;\n if (out) setDropDir(null);\n }}>\n {busy && empty ? (\n <div className=\"rui-tree-skel\" role=\"status\">\n <span className=\"rui-tree-sr\">{L.loading}</span>\n {[64, 48, 56].map((w, i) => <span key={i} className=\"rui-tree-skel-line\" style={{ width: `${w}%` }} aria-hidden=\"true\" />)}\n </div>\n ) : null}\n {!busy && empty && !creatingAtTop ? <p className=\"rui-tree-empty\">{L.empty}</p> : null}\n {!empty || creatingAtTop ? (\n <ul role=\"tree\" className=\"rui-tree-list\" aria-label={treeLabel} aria-busy={busy || undefined}\n onKeyDown={onTreeKeyDown}\n onFocus={(e) => { const p = e.target.getAttribute?.('data-path'); if (e.target.getAttribute?.('role') === 'treeitem' && p !== null && p !== active) setActive(p); }}>\n {tree.nodes.map(renderNode)}\n {creatingAtTop ? entryRow('', 1) : null}\n </ul>\n ) : null}\n </div>\n {menu && typeof document !== 'undefined' ? (\n <TreeMenu menu={menu} items={itemsFor(menu.path, menu.kind)} label={say(L.menu, menu.path ? baseName(menu.path) : treeLabel)}\n tokensFrom={rootRef} menuRef={menuRef} onClose={closeMenu} />\n ) : null}\n </div>\n );\n}\n\n/** Every folder above `dir`, nearest last. */\nfunction ancestorsOf(dir) {\n const out = [];\n for (let p = parentOf(dir); p; p = parentOf(p)) out.unshift(p);\n return out;\n}\n","// reifyui/tree — the model behind FileTree, with no React and no DOM, so every rule the tree\n// follows (how paths become folders, which rows are visible, what a key does, which names and\n// moves are refused) is a plain function a test can call and a host can reuse.\n\n/** The folder a path sits in ('' is the top). */\nexport const parentOf = (p) => { const i = p.lastIndexOf('/'); return i < 0 ? '' : p.slice(0, i); };\n/** A path's last part. */\nexport const baseName = (p) => p.slice(p.lastIndexOf('/') + 1);\n/** A name inside a folder ('' is the top). */\nexport const joinPath = (dir, name) => (dir ? `${dir}/${name}` : name);\n/** True when `p` is `dir` or anything inside it. */\nexport const isWithin = (p, dir) => p === dir || p.startsWith(dir + '/');\n\n/** A path as the tree keys it: forward slashes, nothing doubled, none at either end. */\nexport function normalizePath(raw) {\n return String(raw ?? '').replace(/\\\\/g, '/').replace(/\\/{2,}/g, '/').replace(/^\\/+|\\/+$/g, '');\n}\n\n/** A name cut for display: the extension kept whole when the rest is cut (\"very-long-na….md\").\n * A leading dot (\".env\") is part of the name, not an extension. */\nexport function splitExt(name) {\n const i = name.lastIndexOf('.');\n return i <= 0 ? [name, ''] : [name.slice(0, i), name.slice(i)];\n}\n\nconst byName = (a, b) => (a.kind !== b.kind ? (a.kind === 'dir' ? -1 : 1)\n : a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));\n\n/**\n * The tree drawn from a flat list of entries.\n * entries [{ path: 'tasks/refund', kind: 'file' | 'dir', note? }]\n * A file's folders are implied by its path; a 'dir' entry adds a folder that may be empty. Each\n * level is sorted folders first, then by name (numbers in names compare as numbers). A folder's\n * `files` counts every file inside it, all the way down. When one path is given both as a file and\n * as a folder (or a file sits \"inside\" a file), the folder wins and the file entry is left out.\n */\nexport function buildFileTree(entries) {\n const root = { path: '', name: '', kind: 'dir', depth: 0, children: [], files: 0 };\n const byPath = new Map([['', root]]);\n const ensureDir = (path) => {\n const hit = byPath.get(path);\n if (hit) {\n if (hit.kind === 'dir') return hit;\n // a file at a path something else sits inside: the folder takes its place\n hit.kind = 'dir'; hit.children = []; hit.files = 0; delete hit.note;\n return hit;\n }\n const parent = ensureDir(parentOf(path));\n const node = { path, name: baseName(path), kind: 'dir', depth: parent.depth + 1, children: [], files: 0 };\n parent.children.push(node);\n byPath.set(path, node);\n return node;\n };\n for (const e of entries || []) {\n const path = normalizePath(e && e.path);\n if (!path) continue;\n if (e.kind === 'dir') { const d = ensureDir(path); if (e.note) d.note = String(e.note); continue; }\n if (byPath.has(path)) continue; // a folder (or the same file) already holds this path\n const parent = ensureDir(parentOf(path));\n const node = { path, name: baseName(path), kind: 'file', depth: parent.depth + 1, children: [], files: 0 };\n if (e.note) node.note = String(e.note);\n parent.children.push(node);\n byPath.set(path, node);\n }\n const finish = (n) => {\n n.children.sort(byName);\n n.files = 0;\n for (const c of n.children) { if (c.kind === 'dir') { finish(c); n.files += c.files; } else n.files += 1; }\n };\n finish(root);\n return { root, nodes: root.children, byPath };\n}\n\n/** Every folder path in the tree. */\nexport function folderPaths(tree) {\n const out = [];\n for (const [p, n] of tree.byPath) if (p && n.kind === 'dir') out.push(p);\n return out;\n}\n\n/**\n * The rows a person can see, top to bottom: every node whose folders are all open.\n * Each row: { path, name, kind, depth (1 at the top), parent, open, hasChildren, files, note }.\n */\nexport function visibleRows(nodes, isOpen) {\n const open = typeof isOpen === 'function' ? isOpen : (p) => !!(isOpen && isOpen.has && isOpen.has(p));\n const rows = [];\n const walk = (list) => {\n for (const n of list) {\n const o = n.kind === 'dir' && open(n.path);\n rows.push({ path: n.path, name: n.name, kind: n.kind, depth: n.depth, parent: parentOf(n.path), open: o,\n hasChildren: n.children.length > 0, files: n.files, note: n.note });\n if (o) walk(n.children);\n }\n };\n walk(nodes || []);\n return rows;\n}\n\n/**\n * What a key does on the focused row, per the WAI-ARIA tree pattern. Pure: it reads the visible\n * rows and returns an action for the component to apply, or null when the key is not the tree's.\n * { type: 'focus', path } move focus to a row\n * { type: 'open', path } open a closed folder (focus stays)\n * { type: 'close', path } close an open folder (focus stays)\n * { type: 'activate', path, kind } Enter / Space: select it, and open or close a folder\n * { type: 'rename', path } / { type: 'delete', path } / { type: 'menu', path }\n * `opts.editable` false drops rename, delete and the menu.\n */\nexport function treeKeyAction(rows, active, ev, opts = {}) {\n const key = typeof ev === 'string' ? ev : ev.key;\n const shift = typeof ev === 'object' && !!ev.shiftKey;\n const mod = typeof ev === 'object' && !!(ev.ctrlKey || ev.metaKey || ev.altKey);\n if (!rows.length) return null;\n let i = rows.findIndex((r) => r.path === active);\n if (i < 0) i = 0;\n const row = rows[i];\n const editable = opts.editable !== false;\n if (mod && key !== 'F10') return null;\n switch (key) {\n case 'ArrowDown': return i < rows.length - 1 ? { type: 'focus', path: rows[i + 1].path } : { type: 'focus', path: row.path };\n case 'ArrowUp': return i > 0 ? { type: 'focus', path: rows[i - 1].path } : { type: 'focus', path: row.path };\n case 'Home': return { type: 'focus', path: rows[0].path };\n case 'End': return { type: 'focus', path: rows[rows.length - 1].path };\n case 'ArrowRight':\n if (row.kind !== 'dir') return { type: 'none' };\n if (!row.open) return { type: 'open', path: row.path };\n return row.hasChildren && rows[i + 1] ? { type: 'focus', path: rows[i + 1].path } : { type: 'none' };\n case 'ArrowLeft':\n if (row.kind === 'dir' && row.open) return { type: 'close', path: row.path };\n return row.parent ? { type: 'focus', path: row.parent } : { type: 'none' };\n case 'Enter': case ' ': case 'Spacebar':\n return { type: 'activate', path: row.path, kind: row.kind };\n case 'F2': return editable ? { type: 'rename', path: row.path } : null;\n case 'Delete': case 'Backspace': return editable ? { type: 'delete', path: row.path } : null;\n case 'ContextMenu': return editable ? { type: 'menu', path: row.path } : null;\n case 'F10': return shift && editable ? { type: 'menu', path: row.path } : null;\n default: return null;\n }\n}\n\nconst invisible = (s) => Array.from(s).some((c) => { const n = c.charCodeAt(0); return n < 32 || n === 127; });\nconst say = (v, ...a) => (typeof v === 'function' ? v(...a) : v);\n\n/**\n * Why `name` can't be used for a new or renamed entry in `dir`, or '' when it can.\n * kind 'file' | 'dir'\n * siblings the names already in `dir` (the entry being renamed left out)\n * labels the words (DEFAULT_TREE_LABELS' name* keys)\n * validate the host's own rule, (name, dir, kind) => message | '' — asked only once the\n * defaults pass, so it never sees '', '.', '..' or a name with a slash\n */\nexport function nameProblem(name, { kind = 'file', dir = '', siblings = [], labels = {}, validate } = {}) {\n const L = { ...NAME_LABELS, ...labels };\n const n = String(name ?? '').trim();\n if (!n) return say(L.nameEmpty, kind);\n if (n === '.' || n === '..') return say(L.nameDots, kind);\n if (/[\\\\/]/.test(n)) return say(L.nameSlash, kind);\n if (invisible(n)) return say(L.nameInvisible, kind);\n const lower = n.toLowerCase();\n const sib = Array.from(siblings || []);\n if (sib.some((s) => s === n)) return say(L.nameTaken, n, kind);\n // two names that differ only in case read as one on most computers a file is later saved to\n if (sib.some((s) => s.toLowerCase() === lower)) return say(L.nameTaken, sib.find((s) => s.toLowerCase() === lower), kind);\n if (typeof validate === 'function') return validate(n, dir, kind) || '';\n return '';\n}\n\n/**\n * Whether `from` (a file or folder) may move into `toDir` ('' is the top): never into itself or a\n * folder inside it, never where it already is, never onto a name already taken there, and only\n * into a folder that exists. `tree` is buildFileTree's result.\n */\nexport function canMove(tree, from, toDir) {\n const node = tree.byPath.get(from);\n if (!node || !from) return false;\n const dest = tree.byPath.get(toDir);\n if (!dest || dest.kind !== 'dir') return false;\n if (parentOf(from) === toDir) return false;\n if (node.kind === 'dir' && isWithin(toDir, from)) return false;\n return !dest.children.some((c) => c.name.toLowerCase() === node.name.toLowerCase());\n}\n\n/** Rewrite a path when `from` moved to `to` (a folder's insides move with it). */\nexport const movedPath = (p, from, to) => (isWithin(p, from) ? to + p.slice(from.length) : p);\n\nconst NAME_LABELS = {\n nameEmpty: (kind) => (kind === 'dir' ? 'Type a folder name.' : 'Type a file name.'),\n nameDots: 'Choose a name other than . or ..',\n nameSlash: 'Use a name without a slash.',\n nameInvisible: 'Use visible characters only.',\n nameTaken: (name) => `${name} is already here.`,\n};\n\n/** Every word FileTree shows, each overridable through `labels`. A function takes the values\n * named in its parameters. */\nexport const DEFAULT_TREE_LABELS = Object.freeze({\n tree: 'Files',\n newFile: 'New file',\n newFolder: 'New folder',\n upload: 'Upload files',\n collapseAll: 'Collapse all',\n rename: 'Rename',\n delete: 'Delete',\n keep: 'Keep',\n renameKey: 'F2',\n deleteKey: '⌫',\n empty: 'No files yet.',\n emptyFolder: 'empty',\n loading: 'Loading',\n saving: 'Saving',\n failed: 'That didn’t work. Try again.',\n newFileInput: 'Name of the new file',\n newFolderInput: 'Name of the new folder',\n renameInput: (name) => `New name for ${name}`,\n confirmFile: (name) => `Delete ${name}?`,\n confirmFolder: (name, files) => (files ? `Delete ${name} and the ${files === 1 ? 'file' : `${files} files`} in it?` : `Delete ${name}?`),\n menu: (name) => name,\n ...NAME_LABELS,\n});\n"],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
+
"version": "0.19.1",
|
|
4
4
|
"description": "The open-source rendering & interaction layer for agentic applications. Stream and render any agent's output as polished, application-native UI — model-agnostic, framework-agnostic, design-system-native. The foundation for building generative-UI and agent products.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -76,6 +76,11 @@
|
|
|
76
76
|
"import": "./dist/agent-chat.js",
|
|
77
77
|
"require": "./dist/agent-chat.cjs"
|
|
78
78
|
},
|
|
79
|
+
"./tree": {
|
|
80
|
+
"types": "./dist/tree.d.ts",
|
|
81
|
+
"import": "./dist/tree.js",
|
|
82
|
+
"require": "./dist/tree.cjs"
|
|
83
|
+
},
|
|
79
84
|
"./styles/*": "./styles/*",
|
|
80
85
|
"./package.json": "./package.json"
|
|
81
86
|
},
|
|
@@ -104,6 +109,9 @@
|
|
|
104
109
|
],
|
|
105
110
|
"agent-chat": [
|
|
106
111
|
"dist/agent-chat.d.ts"
|
|
112
|
+
],
|
|
113
|
+
"tree": [
|
|
114
|
+
"dist/tree.d.ts"
|
|
107
115
|
]
|
|
108
116
|
}
|
|
109
117
|
},
|
package/src/auth/AuthForm.jsx
CHANGED
|
@@ -140,6 +140,7 @@ export function AuthForm({ onDone, subtitle, brand = null, productName = '' }) {
|
|
|
140
140
|
<label>Email</label>
|
|
141
141
|
<input className="input" type="email" value={email} onChange={(e) => setEmail(e.target.value)} autoFocus required autoComplete="email" />
|
|
142
142
|
</div>
|
|
143
|
+
<div data-person-check="" className="person-check" />
|
|
143
144
|
{err && <div className="auth-err">{err}</div>}
|
|
144
145
|
<button type="submit" className="btn primary lg" style={{ width: '100%', marginTop: 8 }} disabled={busy}>
|
|
145
146
|
{busy ? 'Please wait...' : 'Send reset link'}
|
|
@@ -180,6 +181,7 @@ export function AuthForm({ onDone, subtitle, brand = null, productName = '' }) {
|
|
|
180
181
|
placeholder={mode === 'register' ? 'At least 8 characters' : ''}
|
|
181
182
|
/>
|
|
182
183
|
</div>
|
|
184
|
+
{mode === 'register' && <div data-person-check="" className="person-check" />}
|
|
183
185
|
{err && <div className="auth-err">{err}</div>}
|
|
184
186
|
<button type="submit" className="btn primary lg" style={{ width: '100%', marginTop: 8 }} disabled={busy}>
|
|
185
187
|
{busy ? 'Please wait...' : mode === 'register' ? 'Create account' : 'Sign in'}
|
package/src/auth/client.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
// call order (configure first) is the only contract.
|
|
12
12
|
/* eslint-env browser */
|
|
13
13
|
|
|
14
|
+
import { personToken } from './personCheck.js';
|
|
15
|
+
|
|
14
16
|
const _cfg = {
|
|
15
17
|
// Same-origin. A product that forgets to configure gets the working default rather than the
|
|
16
18
|
// engine's Azure FQDN, which no browser may call — its ingress admits only the VM that fronts
|
|
@@ -97,7 +99,8 @@ export async function login(email, password) {
|
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
export async function register(email, password, name = '') {
|
|
100
|
-
const
|
|
102
|
+
const turnstile_token = await personToken('register', _cfg.engine);
|
|
103
|
+
const s = toSession(await authPost('/v1/auth/register', { email, password, name, product: _cfg.product, turnstile_token }));
|
|
101
104
|
setSession(s);
|
|
102
105
|
return s;
|
|
103
106
|
}
|
|
@@ -117,12 +120,39 @@ export async function microsoftSignIn(credential) {
|
|
|
117
120
|
return s;
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
// A reset or resend refusal in the person's words: the engine's own sentence for a check it refused
|
|
124
|
+
// (the person check, an address whose domain takes no mail), else the general one. Neither says
|
|
125
|
+
// whether the address has an account: the engine answers 200 for one it doesn't know.
|
|
126
|
+
async function readMailDoorError(res) {
|
|
127
|
+
if (res.status === 400 || res.status === 403 || res.status === 503) {
|
|
128
|
+
try {
|
|
129
|
+
const d = (await res.json())?.detail;
|
|
130
|
+
if (typeof d === 'string' && d.length > 0 && d.length < 200) return d;
|
|
131
|
+
} catch { /* not JSON */ }
|
|
132
|
+
}
|
|
133
|
+
return 'We could not send the request. Please try again later.';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function mailDoor(path, door, email) {
|
|
137
|
+
const turnstile_token = await personToken(door, _cfg.engine);
|
|
138
|
+
const res = await fetch(`${_cfg.engine}${path}`, {
|
|
122
139
|
method: 'POST',
|
|
123
140
|
headers: { 'content-type': 'application/json' },
|
|
124
|
-
body: JSON.stringify({ email, product: _cfg.product }),
|
|
141
|
+
body: JSON.stringify({ email, product: _cfg.product, turnstile_token }),
|
|
125
142
|
});
|
|
143
|
+
// a refusal is said, never shown as "check your email" with no mail coming
|
|
144
|
+
if (!res.ok) throw new Error(await readMailDoorError(res));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Ask for a password reset link. Resolves when the engine took the request (it answers the same
|
|
148
|
+
* whether or not the address has an account); throws with words for the person when it refused. */
|
|
149
|
+
export async function requestPasswordReset(email) {
|
|
150
|
+
await mailDoor('/v1/auth/request-password-reset', 'reset', email);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Send the confirmation email again, as requestPasswordReset does. */
|
|
154
|
+
export async function resendVerification(email) {
|
|
155
|
+
await mailDoor('/v1/auth/resend-verification', 'resend', email);
|
|
126
156
|
}
|
|
127
157
|
|
|
128
158
|
/** Re-mint an org-scoped token for the chosen org. */
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// The person check on the engine's three doors that send mail: sign-up (register), password reset
|
|
2
|
+
// (request-password-reset) and resending the confirmation email (resend-verification). The engine
|
|
3
|
+
// checks the token this gets on the server; for a door it enforces, a request without a good token
|
|
4
|
+
// is refused (403) and no mail goes out.
|
|
5
|
+
//
|
|
6
|
+
// The site key is public and the engine hands it out (GET <engine>/v1/auth/person-check), so a
|
|
7
|
+
// product sets nothing at build time; with none set, no widget runs and no token is sent. The widget
|
|
8
|
+
// runs in Cloudflare's managed mode and is shown only when Cloudflare asks the person to do
|
|
9
|
+
// something; it renders into the visible [data-person-check] slot of the form being sent (AuthForm
|
|
10
|
+
// carries one), else into a box at the end of the page, so the form looks as it always has.
|
|
11
|
+
// A token is good for one request and only for the door it was made for (its action).
|
|
12
|
+
/* eslint-env browser */
|
|
13
|
+
|
|
14
|
+
const SCRIPT = 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';
|
|
15
|
+
const WAIT_MS = 60_000;
|
|
16
|
+
|
|
17
|
+
/** What a person reads when the check can't finish here (the engine's own words for its refusal). */
|
|
18
|
+
export const PERSON_CHECK_FAILED = "We couldn't confirm you're a person. Please try again.";
|
|
19
|
+
|
|
20
|
+
/** @type {Map<string, Promise<string>>} engine -> its site key; only an answer is kept */
|
|
21
|
+
const keys = new Map();
|
|
22
|
+
/** @type {Promise<any> | null} */
|
|
23
|
+
let script = null;
|
|
24
|
+
|
|
25
|
+
function siteKey(engine) {
|
|
26
|
+
let p = keys.get(engine);
|
|
27
|
+
if (!p) {
|
|
28
|
+
p = fetch(`${engine}/v1/auth/person-check`, { cache: 'no-store' })
|
|
29
|
+
.then(async (r) => {
|
|
30
|
+
if (!r.ok) throw new Error('no answer');
|
|
31
|
+
const b = await r.json();
|
|
32
|
+
return typeof b?.site_key === 'string' ? b.site_key : '';
|
|
33
|
+
})
|
|
34
|
+
// a failed read is asked again next time, never remembered as "no key"
|
|
35
|
+
.catch(() => { keys.delete(engine); return ''; });
|
|
36
|
+
keys.set(engine, p);
|
|
37
|
+
}
|
|
38
|
+
return p;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function loadScript() {
|
|
42
|
+
script ??= new Promise((resolve, reject) => {
|
|
43
|
+
if (window.turnstile) { resolve(window.turnstile); return; }
|
|
44
|
+
const s = document.createElement('script');
|
|
45
|
+
s.src = SCRIPT; s.async = true; s.defer = true;
|
|
46
|
+
s.onload = () => (window.turnstile ? resolve(window.turnstile) : reject(new Error(PERSON_CHECK_FAILED)));
|
|
47
|
+
s.onerror = () => { script = null; s.remove(); reject(new Error(PERSON_CHECK_FAILED)); };
|
|
48
|
+
document.head.appendChild(s);
|
|
49
|
+
});
|
|
50
|
+
return script;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function slot() {
|
|
54
|
+
const shown = Array.from(document.querySelectorAll('[data-person-check]')).find((el) => el.offsetParent !== null);
|
|
55
|
+
if (shown) return shown;
|
|
56
|
+
let el = document.getElementById('person-check-fallback');
|
|
57
|
+
if (!el) {
|
|
58
|
+
el = document.createElement('div');
|
|
59
|
+
el.id = 'person-check-fallback';
|
|
60
|
+
el.className = 'person-check-fallback';
|
|
61
|
+
document.body.appendChild(el);
|
|
62
|
+
}
|
|
63
|
+
return el;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A fresh token for one door ('register' | 'reset' | 'resend'), or '' when the engine has no site key
|
|
68
|
+
* set (nothing to check). Call it right before the request it goes with. Throws, with words for the
|
|
69
|
+
* person, when the check can't finish.
|
|
70
|
+
* @param {'register'|'reset'|'resend'} door
|
|
71
|
+
* @param {string} engine the engine's base, as configureAuth was given it
|
|
72
|
+
* @returns {Promise<string>}
|
|
73
|
+
*/
|
|
74
|
+
export async function personToken(door, engine) {
|
|
75
|
+
const key = await siteKey(engine);
|
|
76
|
+
if (!key) return '';
|
|
77
|
+
const ts = await loadScript();
|
|
78
|
+
const host = document.createElement('div');
|
|
79
|
+
slot().appendChild(host);
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
let id = '';
|
|
82
|
+
const done = (fn) => {
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
try { if (id) ts.remove(id); } catch { /* already gone */ }
|
|
85
|
+
host.remove();
|
|
86
|
+
fn();
|
|
87
|
+
};
|
|
88
|
+
const fail = () => done(() => reject(new Error(PERSON_CHECK_FAILED)));
|
|
89
|
+
const timer = setTimeout(fail, WAIT_MS);
|
|
90
|
+
try {
|
|
91
|
+
id = ts.render(host, {
|
|
92
|
+
sitekey: key, action: door, appearance: 'interaction-only', theme: 'auto', 'refresh-expired': 'never',
|
|
93
|
+
callback: (token) => done(() => resolve(token)),
|
|
94
|
+
'error-callback': fail, 'expired-callback': fail, 'timeout-callback': fail,
|
|
95
|
+
});
|
|
96
|
+
} catch { fail(); }
|
|
97
|
+
});
|
|
98
|
+
}
|
package/src/index.d.ts
CHANGED
|
@@ -513,7 +513,13 @@ export function isAuthed(): boolean;
|
|
|
513
513
|
export function login(email: string, password: string): Promise<unknown>;
|
|
514
514
|
export function register(payload: Record<string, unknown>): Promise<unknown>;
|
|
515
515
|
export function googleSignIn(credential: string, extra?: Record<string, unknown>): Promise<unknown>;
|
|
516
|
-
|
|
516
|
+
/** Throws with words for the person when the engine refused (the person check, a domain that takes no mail). */
|
|
517
|
+
export function requestPasswordReset(email: string): Promise<void>;
|
|
518
|
+
/** Send the confirmation email again; throws as requestPasswordReset does. */
|
|
519
|
+
export function resendVerification(email: string): Promise<void>;
|
|
520
|
+
/** A fresh person-check token for one of the engine's mail doors, or '' when the engine sets no site key. */
|
|
521
|
+
export function personToken(door: 'register' | 'reset' | 'resend', engine: string): Promise<string>;
|
|
522
|
+
export const PERSON_CHECK_FAILED: string;
|
|
517
523
|
export function switchOrg(orgId: string): Promise<unknown>;
|
|
518
524
|
export function refreshToken(): Promise<unknown>;
|
|
519
525
|
export function handleAuthExpired(): void;
|
package/src/index.js
CHANGED
|
@@ -38,9 +38,10 @@ export { DialogHost, useDialog } from './components/Dialog.jsx';
|
|
|
38
38
|
export {
|
|
39
39
|
configureAuth, authConfig, SESSION_EVENT,
|
|
40
40
|
getSession, clearSession, getToken, isAuthed,
|
|
41
|
-
login, register, googleSignIn, microsoftSignIn, requestPasswordReset, switchOrg,
|
|
41
|
+
login, register, googleSignIn, microsoftSignIn, requestPasswordReset, resendVerification, switchOrg,
|
|
42
42
|
refreshToken, handleAuthExpired, logout, authFetch, fetchBalance,
|
|
43
43
|
} from './auth/client.js';
|
|
44
|
+
export { personToken, PERSON_CHECK_FAILED } from './auth/personCheck.js';
|
|
44
45
|
export { AuthForm } from './auth/AuthForm.jsx';
|
|
45
46
|
export { GoogleButton, GOOGLE_ENABLED } from './auth/GoogleButton.jsx';
|
|
46
47
|
export { MicrosoftButton, MICROSOFT_ENABLED, microsoftIdToken } from './auth/MicrosoftButton.jsx';
|