@3sln/trove 0.0.12 → 0.0.13

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 (89) hide show
  1. package/README.md +13 -1
  2. package/package.json +2 -1
  3. package/packages/core/src/collections/index.js +71 -10
  4. package/packages/core/src/encryption/keys.js +4 -3
  5. package/packages/core/src/encryption/policy.js +14 -7
  6. package/packages/core/src/encryption/rotation.js +46 -12
  7. package/packages/core/src/errors.js +8 -0
  8. package/packages/core/src/index.js +8 -2
  9. package/packages/core/src/indexers/contribution.js +18 -17
  10. package/packages/core/src/indexing.js +8 -4
  11. package/packages/core/src/issues.js +8 -0
  12. package/packages/core/src/links.js +21 -9
  13. package/packages/core/src/metadata/interface.js +22 -0
  14. package/packages/core/src/metadata/memory.js +15 -0
  15. package/packages/core/src/metadata/sqlite.js +23 -1
  16. package/packages/core/src/plugins/contributions.js +13 -0
  17. package/packages/core/src/rateLimit.js +253 -0
  18. package/packages/core/src/scan.js +44 -16
  19. package/packages/core/src/sidecar/document.js +18 -14
  20. package/packages/core/src/sidecar/index.js +9 -10
  21. package/packages/core/src/sidecar/manager.js +10 -15
  22. package/packages/core/src/uploads.js +40 -15
  23. package/packages/core/src/vfs.js +59 -34
  24. package/packages/plugin-sdk/src/browser.js +155 -0
  25. package/packages/plugin-sdk/src/protocol.js +13 -1
  26. package/packages/server/src/adapters/bun.js +1 -2
  27. package/packages/server/src/adapters/node.js +1 -2
  28. package/packages/server/src/engine/index.js +1 -1
  29. package/packages/server/src/engine/providers/access.js +17 -34
  30. package/packages/server/src/engine/providers/core.js +112 -14
  31. package/packages/server/src/index.js +145 -103
  32. package/packages/server/src/mcp/index.js +7 -12
  33. package/packages/server/src/mcp/tools.js +24 -29
  34. package/packages/server/src/router.js +31 -8
  35. package/packages/server/src/routes.js +74 -113
  36. package/packages/server/src/scope.js +78 -0
  37. package/packages/web/dist/assets/main-828yzsr7.js +511 -0
  38. package/packages/web/dist/assets/main-828yzsr7.js.map +120 -0
  39. package/packages/web/dist/index.html +1 -1
  40. package/packages/web/dist/sw.js +1 -1
  41. package/packages/web/src/bl/actions.js +226 -104
  42. package/packages/web/src/bl/activity.js +32 -82
  43. package/packages/web/src/bl/index.js +23 -11
  44. package/packages/web/src/bl/launcher.js +2 -9
  45. package/packages/web/src/bl/links.js +31 -18
  46. package/packages/web/src/bl/offline.js +24 -10
  47. package/packages/web/src/bl/pluginInstall.js +29 -26
  48. package/packages/web/src/bl/queries.js +76 -68
  49. package/packages/web/src/bl/services.js +22 -14
  50. package/packages/web/src/bl/social.js +39 -25
  51. package/packages/web/src/bl/state.js +22 -4
  52. package/packages/web/src/bl/viewState.js +9 -0
  53. package/packages/web/src/bl/watchQuery.js +1 -8
  54. package/packages/web/src/dispatch.js +26 -0
  55. package/packages/web/src/platform/api.js +32 -0
  56. package/packages/web/src/platform/commands.js +14 -15
  57. package/packages/web/src/platform/context.js +3 -58
  58. package/packages/web/src/platform/contributions.js +1 -35
  59. package/packages/web/src/platform/fileChunks.js +281 -0
  60. package/packages/web/src/platform/index.js +8 -9
  61. package/packages/web/src/platform/mediaUrls.js +10 -0
  62. package/packages/web/src/platform/navigation.js +35 -21
  63. package/packages/web/src/platform/pickers.js +39 -19
  64. package/packages/web/src/platform/pluginHost.js +4 -1
  65. package/packages/web/src/platform/pluginRpc.js +47 -2
  66. package/packages/web/src/platform/spatialNav.js +1 -1
  67. package/packages/web/src/platform/viewport.js +14 -6
  68. package/packages/web/src/platform/voiceSearch.js +17 -9
  69. package/packages/web/src/platform/whenclause.js +9 -19
  70. package/packages/web/src/runtime.js +2 -37
  71. package/packages/web/src/ui/activate.js +18 -2
  72. package/packages/web/src/ui/components/activityPanel.js +1 -1
  73. package/packages/web/src/ui/components/adminView.js +4 -7
  74. package/packages/web/src/ui/components/editorArea.js +10 -1
  75. package/packages/web/src/ui/components/launcher.js +29 -13
  76. package/packages/web/src/ui/components/openers/index.js +17 -22
  77. package/packages/web/src/ui/components/openers/markdown.js +2 -2
  78. package/packages/web/src/ui/components/overlays.js +31 -5
  79. package/packages/web/src/ui/components/pluginReview.js +7 -4
  80. package/packages/web/src/ui/components/pluginsView.js +1 -1
  81. package/packages/web/src/ui/components/settingsView.js +30 -27
  82. package/packages/web/src/ui/components/statusBar.js +8 -6
  83. package/packages/web/src/ui/components/views/grid.js +2 -2
  84. package/packages/web/src/ui/components/views/parts.js +1 -1
  85. package/packages/web/src/ui/compositions/workbench.js +20 -6
  86. package/packages/web/src/ui/sanitize.js +0 -5
  87. package/packages/web/src/workbench.js +37 -19
  88. package/packages/web/dist/assets/main-c9dnnnc6.js +0 -356
  89. package/packages/web/dist/assets/main-c9dnnnc6.js.map +0 -118
@@ -0,0 +1,120 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../node_modules/@3sln/dodo/src/vdom.js", "../../../node_modules/@3sln/dodo/src/html.js", "../../../node_modules/@3sln/dodo/src/scheduler.js", "../../../node_modules/@3sln/dodo/index.js", "../../../node_modules/@3sln/dodo/src/settings.js", "../../../node_modules/@3sln/dodo/src/reactive.js", "../../../node_modules/@3sln/dodo/reactive.js", "../src/runtime.js", "../../core/src/errors.js", "../../core/src/util.js", "../../core/src/plugins/identity.js", "../../core/src/plugins/contributions.js", "../src/platform/contributions.js", "../src/platform/whenclause.js", "../src/platform/context.js", "../src/dispatch.js", "../src/platform/commands.js", "../src/platform/keybindings.js", "../src/platform/settings.js", "../src/platform/notifications.js", "../../core/src/retry.js", "../src/platform/api.js", "../../../node_modules/fflate/esm/browser.js", "../src/platform/pluginStore.js", "../src/platform/pluginClientDb.js", "../src/platform/pluginSigning.js", "../src/platform/pluginNet.js", "../src/platform/pluginPackage.js", "../src/platform/pluginMedia.js", "../src/platform/pluginDock.js", "../../../node_modules/@3sln/ngin/src/internal.js", "../../../node_modules/@3sln/ngin/src/providers.js", "../../../node_modules/@3sln/ngin/src/actions.js", "../../../node_modules/@3sln/ngin/src/queries.js", "../../../node_modules/@3sln/ngin/src/engine.js", "../src/bl/viewState.js", "../src/bl/trust.js", "../src/bl/pluginInstall.js", "../../core/src/search/tagMatch.js", "../src/bl/tagQuery.js", "../src/bl/fileType.js", "../src/bl/openers.js", "../../core/src/links.js", "../src/bl/services.js", "../src/platform/pickers.js", "../src/bl/state.js", "../src/bl/actions.js", "../../plugin-sdk/src/rpc.js", "../../plugin-sdk/src/protocol.js", "../../../node_modules/es-module-lexer/dist/lexer.js", "../src/platform/pluginModules.js", "../src/platform/pluginFrames.js", "../../core/src/plugins/sql.js", "../src/platform/pluginRpc.js", "../../core/src/plugins/package.js", "../src/platform/pluginHost.js", "../src/platform/viewport.js", "../src/platform/spatialNav.js", "../src/platform/voice.js", "../src/platform/voiceSearch.js", "../src/platform/mediaUrls.js", "../src/platform/fileChunks.js", "../src/platform/index.js", "../src/bl/context.js", "../src/platform/navigation.js", "../src/bl/social.js", "../../core/src/search/embeddings.js", "../../core/src/indexers/registry.js", "../../core/src/search/keywordStore.js", "../src/bl/offline.js", "../src/bl/activity.js", "../src/bl/commands.js", "../src/bl/index.js", "../src/bl/watchQuery.js", "../src/ui/region.js", "../src/bl/intern.js", "../src/bl/match.js", "../src/bl/status.js", "../src/bl/launcher.js", "../src/bl/views.js", "../src/bl/queries.js", "../src/ui/icon.js", "../src/ui/format.js", "../src/bl/mentions.js", "../src/ui/components/social.js", "../src/ui/components/activityBar.js", "../src/ui/sanitize.js", "../src/ui/components/statusBar.js", "../src/ui/activate.js", "../src/ui/components/views/parts.js", "../src/ui/components/views/list.js", "../src/ui/media.js", "../src/ui/components/views/grid.js", "../src/ui/components/views/index.js", "../src/ui/components/launcher.js", "../src/ui/components/settingsView.js", "../src/ui/components/collectionGate.js", "../src/ui/components/pluginsView.js", "../src/ui/components/adminView.js", "../src/bl/links.js", "../src/ui/components/openers/markdown.js", "../src/ui/components/openers/index.js", "../src/ui/components/editorArea.js", "../src/ui/components/commandPalette.js", "../src/ui/components/pluginReview.js", "../src/ui/components/overlays.js", "../src/ui/components/activityPanel.js", "../src/ui/components/phoneChrome.js", "../src/ui/compositions/workbench.js", "../src/workbench.js", "../src/main.js"],
4
+ "sourcesContent": [
5
+ "const ELEMENT_NODE = Symbol('ELEMENT_NODE');\nconst ALIAS_NODE = Symbol('ALIAS_NODE');\nconst SPECIAL_NODE = Symbol('SPECIAL_NODE');\nconst OPAQUE_NODE = Symbol('OPAQUE_NODE');\nconst NODE_STATE = Symbol('NODE_STATE');\nconst HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n\n// Property names that must never be written through to a DOM node: assigning\n// `__proto__` swaps the node's prototype, which corrupts the element for every\n// later operation. Relevant whenever props are built from untrusted data.\nconst UNSAFE_PROP_NAMES = new Set(['__proto__', 'constructor', 'prototype']);\n\nconst hasOwn = (o, k) => Object.prototype.hasOwnProperty.call(o, k);\n\n// HTML tag names come back from the DOM upper cased while SVG/MathML keep their\n// authored case. A plain case-insensitive compare covers both, and unlike\n// `localeCompare` it neither builds a collator nor depends on the host locale.\nfunction sameTagName(nodeName, tag) {\n return typeof tag === 'string' && nodeName.toLowerCase() === tag.toLowerCase();\n}\n\nclass VNode {\n constructor(type, tag, args) {\n this.type = type;\n this.tag = tag;\n this.args = args;\n }\n\n key(k) {\n this.k = k;\n return this;\n }\n\n on(hooks) {\n this.hooks = hooks;\n return this;\n }\n\n opaque() {\n if (this.type !== ELEMENT_NODE) {\n throw new Error('.opaque() can only be used on element nodes (h).');\n }\n this.type = OPAQUE_NODE;\n return this;\n }\n}\n\nfunction defaultShouldUpdate(a, b) {\n if (a === b) return false;\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n if (a.constructor !== b.constructor) return true;\n\n if (Array.isArray(a)) {\n if (a.length !== b.length) return true;\n for (let j = 0; j < a.length; j++) {\n if (a[j] !== b[j]) return true;\n }\n return false;\n }\n\n if (a.constructor === Object) {\n const keysA = Object.keys(a);\n if (keysA.length !== Object.keys(b).length) return true;\n for (const key of keysA) {\n if (!hasOwn(b, key) || a[key] !== b[key]) return true;\n }\n return false;\n }\n }\n return true;\n}\n\nfunction isIterable(x) {\n return (\n Array.isArray(x) ||\n (x != null && typeof x[Symbol.iterator] === 'function' && typeof x !== 'string')\n );\n}\n\nfunction alias(f) {\n return (...args) => new VNode(ALIAS_NODE, f, args);\n}\n\nfunction special(o) {\n return (...args) => new VNode(SPECIAL_NODE, o, args);\n}\n\nfunction newElementNamespace(parentNode, newNodeTag) {\n if (parentNode.namespaceURI === HTML_NAMESPACE) {\n switch (newNodeTag) {\n case 'svg':\n return 'http://www.w3.org/2000/svg';\n case 'math':\n return 'http://www.w3.org/1998/Math/MathML';\n }\n }\n return parentNode.namespaceURI ?? parentNode.host?.namespaceURI ?? HTML_NAMESPACE;\n}\n\n// `originalProps` is null-prototyped so that prop names like `__proto__` or\n// `toString` are recorded as ordinary own keys rather than hitting Object.prototype.\nfunction newNodeState(vdom) {\n return {originalProps: Object.create(null), newVdom: vdom};\n}\n\nfunction createElementNode(parentNode, tag, vdom) {\n const el = parentNode.ownerDocument.createElementNS(newElementNamespace(parentNode, tag), tag);\n el[NODE_STATE] = newNodeState(vdom);\n return el;\n}\n\nconst documentToFocusWithinSet = new WeakMap();\n\nfunction getPathFromElement(element) {\n const path = [];\n let current = element;\n while (current) {\n path.push(current);\n if (current.parentElement) {\n current = current.parentElement;\n } else {\n current = current.getRootNode()?.host;\n }\n }\n return path;\n}\n\nfunction addPathToFocusWithinSet(set, path) {\n for (const node of path) {\n set.add(node);\n }\n}\n\n// The realm's own `Node.prototype` is what we want, so that a node from an\n// iframe or a detached document is moved by its own implementation. Falls back\n// through the configured window and then the ambient one, either of which may\n// be all that is available for a document with no `defaultView`.\nfunction nodePrototypeFor(doc, settingsWindow) {\n const view = settingsWindow ?? doc?.defaultView ?? globalThis;\n return view.Node?.prototype ?? view.Element?.prototype;\n}\n\nfunction installFocusTrackingForDocument(doc) {\n const focusWithinSet = new Set();\n // The set is rebuilt on every focusin rather than accumulated. `focusin`\n // fires after `focusout`, and its composed path is the path of the element\n // that just gained focus, so this is always exactly the current focus path.\n // Accumulating instead would leave every previously focused element marked as\n // holding focus for the rest of the document's life.\n doc.addEventListener('focusin', event => {\n focusWithinSet.clear();\n addPathToFocusWithinSet(focusWithinSet, event.composedPath());\n });\n doc.addEventListener('focusout', event => {\n // A focusout with no relatedTarget means focus left the document entirely;\n // otherwise the focusin that follows will rebuild the set.\n if (!event.relatedTarget) focusWithinSet.clear();\n });\n addPathToFocusWithinSet(focusWithinSet, getPathFromElement(doc.activeElement));\n documentToFocusWithinSet.set(doc, focusWithinSet);\n return focusWithinSet;\n}\n\nexport default userSettings => {\n const shouldUpdate = userSettings?.shouldUpdate ?? defaultShouldUpdate;\n const isMap = userSettings?.isMap ?? (x => x?.constructor === Object);\n const mapIter = userSettings?.mapIter ?? (m => Object.entries(m));\n const mapGet = userSettings?.mapGet ?? ((m, k) => m[k]);\n const mapMerge = userSettings?.mapMerge ?? ((...maps) => Object.assign({}, ...maps));\n const newMap = userSettings?.newMap ?? (obj => ({...obj}));\n const mapPut =\n userSettings?.mapPut ??\n ((m, k, v) => {\n m[k] = v;\n return m;\n });\n const isSeq = userSettings?.isSeq ?? isIterable;\n const seqIter = userSettings?.seqIter ?? (s => s);\n const convertName = userSettings?.convertName ?? (x => x);\n const convertTagName = userSettings?.convertTagName ?? convertName;\n const convertPropName = userSettings?.convertPropName ?? convertName;\n const convertStyleName = userSettings?.convertStyleName ?? convertName;\n const convertDataName = userSettings?.convertDataName ?? convertName;\n const convertClassName = userSettings?.convertClassName ?? convertName;\n const convertHookName = userSettings?.convertHookName ?? convertName;\n const listenerKey = userSettings?.listenerKey ?? 'listener';\n const captureKey = userSettings?.captureKey ?? 'capture';\n const passiveKey = userSettings?.passiveKey ?? 'passive';\n\n const EMPTY_MAP = newMap({});\n\n function toIterator(iterableOrIterator) {\n if (iterableOrIterator == null) return [][Symbol.iterator]();\n if (typeof iterableOrIterator[Symbol.iterator] === 'function') {\n return iterableOrIterator[Symbol.iterator]();\n }\n if (typeof iterableOrIterator.next === 'function') {\n return iterableOrIterator;\n }\n return [iterableOrIterator][Symbol.iterator]();\n }\n\n // Reconciling one element walks its props, styling, attrs, dataset and hooks,\n // so building an array of [name, value] pairs for each of those maps is the\n // single biggest source of garbage in an update. `mapEach` is the iteration\n // primitive the reconciler actually uses: it visits entries without\n // materialising them.\n //\n // Supply `mapEach` for a custom collection and it is as cheap as a plain\n // object — ClojureScript has `reduce-kv`, Immutable.js has `forEach`. Supply\n // only `mapIter` and it still works, by way of the pairs it yields; that is\n // the existing contract and it is unchanged.\n //\n // The extra `a`/`b`/`c` slots let call sites pass context to a hoisted\n // visitor, so iterating does not allocate a closure either.\n // `for...in` with an own-key guard, not `Object.keys`: it allocates no key\n // array and measures ~3.5x faster, while enumerating exactly the same keys.\n // The guard has to be the hoisted `hasOwnProperty.call` — `Object.hasOwn`\n // reads better but benchmarks about the same as building the key array,\n // which defeats the point.\n function defaultMapEach(map, visit, a, b, c) {\n if (map == null) return;\n for (const key in map) {\n if (hasOwn(map, key)) visit(key, map[key], a, b, c);\n }\n }\n\n function mapEachViaIter(map, visit, a, b, c) {\n if (map == null) return;\n const iterator = toIterator(mapIter(map));\n let result;\n while (!(result = iterator.next()).done) {\n const entry = result.value;\n visit(entry[0], entry[1], a, b, c);\n }\n }\n\n // Only fall back to the plain-object walk when the user has told us nothing\n // about their maps. Overriding `mapIter` alone still routes through it.\n const mapEach =\n userSettings?.mapEach ?? (userSettings?.mapIter ? mapEachViaIter : defaultMapEach);\n\n // `null`, `undefined` and `false` are the \"render nothing\" values. Note the\n // checks are strict: `0` and `''` are legitimate text children.\n function isBlank(item) {\n return item === null || item === undefined || item === false;\n }\n\n function flattenSeqIntoArray(array, items, excludeFalsey) {\n const iterator = toIterator(seqIter(items));\n let result;\n while (!(result = iterator.next()).done) {\n const item = result.value;\n if (excludeFalsey && isBlank(item)) {\n continue;\n }\n\n if (!isSeq(item)) {\n array.push(item);\n } else {\n flattenSeqIntoArray(array, item, excludeFalsey);\n }\n }\n }\n\n function defaultFlattenSeq(items, excludeFalsey) {\n const array = [];\n flattenSeqIntoArray(array, items, excludeFalsey);\n return array;\n }\n\n const flattenSeq = userSettings?.flattenSeq ?? defaultFlattenSeq;\n\n function flattenVNodeChildren(children, startIndex) {\n const array = [];\n for (let i = startIndex; i < children.length; i++) {\n const item = children[i];\n if (isBlank(item)) continue;\n if (!isSeq(item)) {\n array.push(item);\n } else {\n flattenSeqIntoArray(array, item, true);\n }\n }\n return array;\n }\n\n // Blank children are filtered out before they reach here, but a custom\n // `flattenSeq` may not do that filtering, so never assume `.toString()` exists.\n function toText(value) {\n return isBlank(value) ? '' : String(value);\n }\n\n function h(tag, props, ...children) {\n if (!isMap(props)) {\n // An explicit nullish props slot means \"no props\", not \"render nothing\".\n if (props !== null && props !== undefined) children.unshift(props);\n props = EMPTY_MAP;\n }\n return new VNode(ELEMENT_NODE, convertTagName(tag), [props, ...children]);\n }\n\n // Visitors are hoisted to the factory closure rather than written inline, so\n // that iterating a map allocates neither entries nor a callback.\n function setStyleProperty(name, value, style) {\n style.setProperty(convertStyleName(name), value);\n }\n\n function removeStaleStyleProperty(name, _value, style, newStyling) {\n if (mapGet(newStyling, name) !== undefined) return;\n style.removeProperty(convertStyleName(name));\n }\n\n function reconcileElementStyling(target, oldStyling, newStyling) {\n const style = target.style;\n mapEach(newStyling, setStyleProperty, style);\n mapEach(oldStyling, removeStaleStyleProperty, style, newStyling);\n }\n\n function setAttribute(name, value, target) {\n target.setAttribute(convertPropName(name), value);\n }\n\n function removeStaleAttribute(name, _value, target, newAttrs) {\n if (mapGet(newAttrs, name) !== undefined) return;\n target.removeAttribute(convertPropName(name));\n }\n\n function reconcileElementAttributes(target, oldAttrs, newAttrs) {\n mapEach(newAttrs, setAttribute, target);\n mapEach(oldAttrs, removeStaleAttribute, target, newAttrs);\n }\n\n function setDataProperty(name, value, target) {\n target.dataset[convertDataName(name)] = value;\n }\n\n function removeStaleDataProperty(name, _value, target, newDataset) {\n if (mapGet(newDataset, name) !== undefined) return;\n delete target.dataset[convertDataName(name)];\n }\n\n function reconcileElementDataset(target, oldDataset, newDataset) {\n mapEach(newDataset, setDataProperty, target);\n mapEach(oldDataset, removeStaleDataProperty, target, newDataset);\n }\n\n function reconcileElementClasses(target, oldClasses, newClasses) {\n // Both sides are compared post-conversion, otherwise a non-identity\n // `convertClassName` would never match an old class against a new one.\n const classesToRemove = new Set();\n for (const c of flattenSeq(oldClasses, true)) {\n const className = convertClassName(c);\n if (className) classesToRemove.add(className);\n }\n for (const c of flattenSeq(newClasses, true)) {\n const className = convertClassName(c);\n // `classList.add('')` throws, and empty class names carry no meaning.\n if (!className) continue;\n classesToRemove.delete(className);\n target.classList.add(className);\n }\n for (const className of classesToRemove) {\n target.classList.remove(className);\n }\n }\n\n function setElementProp(target, nodeState, propName, newValue) {\n if (UNSAFE_PROP_NAMES.has(propName)) {\n console.error(`Refusing to assign unsafe prop name '${propName}' to a DOM node.`);\n return;\n }\n const originalProps = nodeState.originalProps;\n if (!(propName in originalProps)) {\n originalProps[propName] = target[propName];\n }\n target[propName] = newValue === undefined ? originalProps[propName] : newValue;\n }\n\n function restoreElementProp(target, nodeState, propName) {\n const originalProps = nodeState.originalProps;\n if (propName in originalProps) {\n target[propName] = originalProps[propName];\n delete originalProps[propName];\n }\n }\n\n function applyProp(name, newValue, target, oldProps, isHtml) {\n const propName = convertPropName(name);\n const oldValue = mapGet(oldProps, name);\n\n if (Object.is(newValue, oldValue)) return;\n\n switch (propName) {\n case '$styling': {\n if (!isMap(newValue)) throw new Error('invalid value for styling prop');\n reconcileElementStyling(target, oldValue ?? EMPTY_MAP, newValue ?? EMPTY_MAP);\n break;\n }\n case '$classes': {\n if (!isSeq(newValue)) throw new Error('invalid value for classes prop');\n reconcileElementClasses(target, oldValue ?? [], newValue ?? []);\n break;\n }\n case '$attrs': {\n if (!isMap(newValue)) throw new Error('invalid value for attrs prop');\n reconcileElementAttributes(target, oldValue ?? EMPTY_MAP, newValue ?? EMPTY_MAP);\n break;\n }\n case '$dataset': {\n if (!isMap(newValue)) throw new Error('invalid value for dataset prop');\n reconcileElementDataset(target, oldValue ?? EMPTY_MAP, newValue ?? EMPTY_MAP);\n break;\n }\n default: {\n if (isHtml) {\n setElementProp(target, target[NODE_STATE], propName, newValue);\n } else {\n if (newValue === undefined) {\n target.removeAttribute(propName);\n } else {\n target.setAttribute(propName, newValue);\n }\n }\n break;\n }\n }\n }\n\n function restoreRemovedProp(name, oldValue, target, props, isHtml) {\n if (mapGet(props, name) !== undefined) return; // it wasn't removed\n\n const propName = convertPropName(name);\n switch (propName) {\n case '$styling':\n reconcileElementStyling(target, oldValue ?? EMPTY_MAP, EMPTY_MAP);\n break;\n case '$classes':\n reconcileElementClasses(target, oldValue ?? [], []);\n break;\n case '$attrs':\n reconcileElementAttributes(target, oldValue ?? EMPTY_MAP, EMPTY_MAP);\n break;\n case '$dataset':\n reconcileElementDataset(target, oldValue ?? EMPTY_MAP, EMPTY_MAP);\n break;\n default: {\n if (isHtml) {\n restoreElementProp(target, target[NODE_STATE], propName);\n } else {\n target.removeAttribute(propName);\n }\n break;\n }\n }\n }\n\n function reconcileElementProps(target, props) {\n const nodeState = target[NODE_STATE];\n const isHtml = target.namespaceURI === HTML_NAMESPACE;\n const oldProps = nodeState.vdom?.args[0] ?? EMPTY_MAP;\n\n mapEach(props, applyProp, target, oldProps, isHtml);\n mapEach(oldProps, restoreRemovedProp, target, props, isHtml);\n }\n\n function addListener(target, hookName, listener) {\n if (typeof listener === 'function') {\n target.addEventListener(hookName, listener);\n } else if (listener != null) {\n target.addEventListener(hookName, mapGet(listener, listenerKey), {\n capture: !!mapGet(listener, captureKey),\n passive: !!mapGet(listener, passiveKey),\n });\n }\n }\n\n function removeListener(target, hookName, listener) {\n if (typeof listener === 'function') {\n target.removeEventListener(hookName, listener);\n } else if (listener != null) {\n target.removeEventListener(\n hookName,\n mapGet(listener, listenerKey),\n !!mapGet(listener, captureKey),\n );\n }\n }\n\n function addInitialListener(name, listener, target) {\n const hookName = convertHookName(name);\n if (hookName[0] === '$') return;\n addListener(target, hookName, listener);\n }\n\n function swapListener(name, listener, target, oldHooks) {\n const hookName = convertHookName(name);\n if (hookName[0] === '$') return;\n const oldListener = mapGet(oldHooks, name);\n if (listener === oldListener) return;\n removeListener(target, hookName, oldListener);\n addListener(target, hookName, listener);\n }\n\n function removeStaleListener(name, oldListener, target, newHooks) {\n const hookName = convertHookName(name);\n if (hookName[0] === '$' || mapGet(newHooks, name) !== undefined) return;\n removeListener(target, hookName, oldListener);\n }\n\n function reconcileListeners(target, hooks) {\n const state = target[NODE_STATE];\n const newHooks = hooks ?? EMPTY_MAP;\n\n if (!state.vdom) {\n mapEach(newHooks, addInitialListener, target);\n return;\n }\n\n const oldHooks = state.vdom.hooks ?? EMPTY_MAP;\n mapEach(newHooks, swapListener, target, oldHooks);\n mapEach(oldHooks, removeStaleListener, target, newHooks);\n }\n\n function reconcileNode(target) {\n const state = target[NODE_STATE];\n const newVdom = state.newVdom;\n const oldVdom = state.vdom;\n const args = newVdom.args;\n\n switch (newVdom.type) {\n case ELEMENT_NODE: {\n reconcileElementProps(target, args[0]);\n reconcileElementChildren(target, flattenVNodeChildren(args, 1));\n break;\n }\n case OPAQUE_NODE: {\n reconcileElementProps(target, args[0]);\n break;\n }\n case ALIAS_NODE: {\n const innerVdom = newVdom.tag.apply(target, newVdom.args);\n if (isBlank(innerVdom)) {\n reconcileElementChildren(target, []);\n } else if (isSeq(innerVdom)) {\n reconcileElementChildren(target, flattenSeq(innerVdom, true));\n } else {\n reconcileElementChildren(target, [innerVdom]);\n }\n break;\n }\n case SPECIAL_NODE: {\n try {\n newVdom.tag.update?.(target, newVdom.args, oldVdom?.args);\n } catch (err) {\n console.error(err);\n }\n break;\n }\n }\n\n if (newVdom.hooks || oldVdom?.hooks) {\n reconcileListeners(target, newVdom.hooks ?? EMPTY_MAP);\n }\n try {\n newVdom.hooks?.$update?.(target, newVdom, oldVdom);\n } catch (err) {\n console.error(err);\n }\n state.vdom = newVdom;\n delete state.newVdom;\n }\n\n function createNode(parentNode, vdom) {\n if (typeof vdom !== 'object' || vdom === null) {\n return parentNode.ownerDocument.createTextNode(toText(vdom));\n }\n\n let domNode;\n switch (vdom.type) {\n case ELEMENT_NODE:\n case OPAQUE_NODE:\n domNode = createElementNode(parentNode, vdom.tag, vdom);\n break;\n case ALIAS_NODE:\n domNode = createElementNode(parentNode, 'udom-alias', vdom);\n domNode.style.display = 'contents';\n break;\n case SPECIAL_NODE:\n domNode = createElementNode(parentNode, 'udom-special', vdom);\n domNode.style.display = 'contents';\n break;\n default:\n throw new Error('Invalid VDOM node');\n }\n return domNode;\n }\n\n function cleanupTargetChildren(target) {\n if (target.children) {\n for (const child of target.children) {\n cleanupTarget(child);\n }\n }\n }\n\n function cleanupTarget(target) {\n const state = target[NODE_STATE];\n if (!state) {\n return;\n }\n\n const {vdom} = state;\n if (!vdom) {\n // The node was created but never reconciled (a builder threw part way\n // through); there is nothing attached to tear down.\n delete target[NODE_STATE];\n return;\n }\n\n if (vdom.hooks) {\n reconcileListeners(target, EMPTY_MAP);\n }\n\n if (vdom.type === ELEMENT_NODE || vdom.type === OPAQUE_NODE) {\n reconcileElementProps(target, EMPTY_MAP);\n }\n\n if (vdom.type === ELEMENT_NODE || vdom.type === ALIAS_NODE) {\n cleanupTargetChildren(target);\n }\n\n delete target[NODE_STATE];\n\n try {\n if (vdom.type === SPECIAL_NODE) {\n vdom.tag.detach?.(target);\n }\n vdom.hooks?.$detach?.(target);\n } catch (err) {\n console.error(err);\n }\n }\n\n // A reused node only needs a second pass when its arguments or its hooks\n // changed; comparing hooks too means a node whose props are stable but whose\n // listeners are freshly bound each render still gets those listeners swapped.\n function claimExistingNode(domNode, newVdom) {\n const state = domNode[NODE_STATE];\n if (\n shouldUpdate(state.vdom.args, newVdom.args) ||\n shouldUpdate(state.vdom.hooks, newVdom.hooks)\n ) {\n state.newVdom = newVdom;\n }\n return domNode;\n }\n\n function collectOldChildren(target) {\n // Keyed by vdom tag; each bucket keeps a native Map of key -> nodes so that\n // user supplied keys such as 'constructor' or '__proto__' cannot collide\n // with Object.prototype. `cursor` replaces Array#shift, which would make\n // reconciling a long unkeyed list quadratic.\n const byTag = new Map();\n const textNodes = {nodes: [], cursor: 0};\n\n for (const oldChild of target.childNodes) {\n if (oldChild.nodeType === 3 /* TEXT_NODE */) {\n textNodes.nodes.push(oldChild);\n continue;\n }\n\n const oldChildState = oldChild[NODE_STATE];\n const vdom = oldChildState?.vdom;\n if (vdom === undefined) {\n if (oldChildState?.newVdom) {\n throw new Error(\n 'Attempt to reconcile against a target while already working on a reconciliation against that same target, this is not allowed',\n );\n }\n continue;\n }\n\n let poolForTag = byTag.get(vdom.tag);\n if (!poolForTag) {\n poolForTag = {nodesForKey: null, nodesWithoutKey: {nodes: [], cursor: 0}};\n byTag.set(vdom.tag, poolForTag);\n }\n\n if (vdom.k !== undefined) {\n if (!poolForTag.nodesForKey) poolForTag.nodesForKey = new Map();\n const nodesForKey = poolForTag.nodesForKey.get(vdom.k);\n if (nodesForKey) {\n nodesForKey.nodes.push(oldChild);\n } else {\n poolForTag.nodesForKey.set(vdom.k, {nodes: [oldChild], cursor: 0});\n }\n } else {\n poolForTag.nodesWithoutKey.nodes.push(oldChild);\n }\n }\n\n return {byTag, textNodes};\n }\n\n function takeFromPool(pool) {\n if (!pool || pool.cursor >= pool.nodes.length) return undefined;\n return pool.nodes[pool.cursor++];\n }\n\n // Places children in order, walking the existing siblings alongside the\n // desired list so that only nodes that are genuinely out of position move.\n function placeChildren(target, newDomChildren, insertBefore, moveBefore) {\n let ref = target.firstChild;\n for (let i = 0; i < newDomChildren.length; i++) {\n const newChild = newDomChildren[i];\n if (newChild === ref) {\n ref = ref.nextSibling;\n continue;\n }\n const op = moveBefore && newChild.isConnected ? moveBefore : insertBefore;\n op.call(target, newChild, ref);\n }\n }\n\n // Same result, but reached without ever passing the focused child to\n // insertBefore. Detaching a focused node blurs it, so instead it is treated\n // as a fixed anchor and every other child is arranged around it: the children\n // that belong before it are placed immediately before it, and the rest are\n // walked into place after it. The anchor still ends up at its correct index,\n // because exactly the right number of children end up on either side.\n //\n // Only needed where `moveBefore` is unavailable — it relocates a node without\n // detaching it, so focus survives an ordinary move.\n function placeChildrenAroundAnchor(target, newDomChildren, insertBefore, anchorIndex) {\n const anchor = newDomChildren[anchorIndex];\n\n // Right to left, so each child lands directly before the one that follows it.\n let before = anchor;\n for (let i = anchorIndex - 1; i >= 0; i--) {\n const child = newDomChildren[i];\n if (child !== before.previousSibling) {\n insertBefore.call(target, child, before);\n }\n before = child;\n }\n\n // Left to right over whatever still follows the anchor. Children that were\n // stranded on the other side of it get pulled across here.\n let ref = anchor.nextSibling;\n for (let i = anchorIndex + 1; i < newDomChildren.length; i++) {\n const child = newDomChildren[i];\n if (child === ref) {\n ref = ref.nextSibling;\n } else {\n insertBefore.call(target, child, ref);\n }\n }\n }\n\n // At most one child of a given parent can be on the focus path, so there is\n // never more than one anchor to preserve.\n function findFocusedChildIndex(newDomChildren, focusWithin) {\n for (let i = 0; i < newDomChildren.length; i++) {\n if (focusWithin.has(newDomChildren[i])) return i;\n }\n return -1;\n }\n\n function attachAndReconcile(newChild) {\n const state = newChild[NODE_STATE];\n if (!state?.newVdom) return;\n if (!state.vdom) {\n try {\n state.newVdom.hooks?.$attach?.(newChild);\n if (state.newVdom.type === SPECIAL_NODE) {\n state.newVdom.tag.attach?.(newChild);\n }\n } catch (err) {\n console.error(err);\n }\n }\n reconcileNode(newChild);\n }\n\n function reconcileElementChildren(target, newChildren) {\n const oldNodesToRemove = target.firstChild ? new Set(target.childNodes) : null;\n const {byTag, textNodes} = collectOldChildren(target);\n\n const newDomChildren = [];\n for (const newVdom of newChildren) {\n let newDomNode;\n if (newVdom instanceof VNode) {\n const poolForTag = byTag.get(newVdom.tag);\n const reusable = poolForTag\n ? takeFromPool(\n newVdom.k !== undefined\n ? poolForTag.nodesForKey?.get(newVdom.k)\n : poolForTag.nodesWithoutKey,\n )\n : undefined;\n newDomNode = reusable ? claimExistingNode(reusable, newVdom) : createNode(target, newVdom);\n } else {\n const reusableText = takeFromPool(textNodes);\n const text = toText(newVdom);\n if (reusableText) {\n newDomNode = reusableText;\n if (newDomNode.nodeValue !== text) newDomNode.nodeValue = text;\n } else {\n newDomNode = target.ownerDocument.createTextNode(text);\n }\n }\n oldNodesToRemove?.delete(newDomNode);\n newDomChildren.push(newDomNode);\n }\n\n if (oldNodesToRemove) {\n for (const nodeToRemove of oldNodesToRemove) {\n cleanupTarget(nodeToRemove);\n target.removeChild(nodeToRemove);\n }\n }\n\n if (newDomChildren.length === 0) return;\n\n const doc = target.ownerDocument;\n const nodeProto = nodePrototypeFor(doc, userSettings?.window);\n const insertBefore = nodeProto.insertBefore;\n const moveBefore = typeof nodeProto.moveBefore === 'function' ? nodeProto.moveBefore : null;\n const connected = target.isConnected;\n\n let anchorIndex = -1;\n if (connected && !moveBefore) {\n const focusWithin = documentToFocusWithinSet.get(doc) ?? installFocusTrackingForDocument(doc);\n anchorIndex = findFocusedChildIndex(newDomChildren, focusWithin);\n // A focused child is always one we pooled from the existing children, so\n // it is already under this target. The guard is only here so that a\n // surprising focus set can never turn into a thrown insertBefore.\n if (anchorIndex !== -1 && newDomChildren[anchorIndex].parentNode !== target) {\n anchorIndex = -1;\n }\n }\n\n if (anchorIndex === -1) {\n placeChildren(target, newDomChildren, insertBefore, connected ? moveBefore : null);\n } else {\n placeChildrenAroundAnchor(target, newDomChildren, insertBefore, anchorIndex);\n }\n\n // Placement happens first so that lifecycle hooks and alias builders run\n // against a fully arranged sibling list rather than a half built one.\n for (let i = 0; i < newDomChildren.length; i++) {\n attachAndReconcile(newDomChildren[i]);\n }\n }\n\n function reconcile(target, vdom) {\n const state = target[NODE_STATE];\n if (vdom === null || vdom === undefined) {\n if (state) {\n cleanupTarget(target);\n } else {\n cleanupTargetChildren(target);\n }\n target.replaceChildren();\n return;\n }\n\n if (isSeq(vdom)) {\n reconcileElementChildren(target, flattenSeq(vdom, true));\n return;\n }\n\n if (vdom instanceof VNode) {\n if (state) {\n // The tag has to match as well as the type: swapping the alias function\n // or the special descriptor is a different component, and reusing the\n // state would skip the old one's detach and the new one's attach.\n if (state.vdom.type === vdom.type && state.vdom.tag === vdom.tag) {\n if (\n shouldUpdate(state.vdom.args, vdom.args) ||\n shouldUpdate(state.vdom.hooks, vdom.hooks)\n ) {\n state.newVdom = vdom;\n reconcileNode(target);\n }\n return;\n }\n cleanupTarget(target);\n }\n\n switch (vdom.type) {\n case ELEMENT_NODE:\n case OPAQUE_NODE:\n if (!sameTagName(target.nodeName, convertTagName(vdom.tag))) {\n throw new Error('incompatible target for vdom');\n }\n break;\n }\n\n target[NODE_STATE] = newNodeState(vdom);\n try {\n vdom.hooks?.$attach?.(target);\n if (vdom.type === SPECIAL_NODE) {\n vdom.tag.attach?.(target);\n }\n } catch (err) {\n console.error(err);\n }\n reconcileNode(target);\n return;\n }\n\n throw new Error('invalid vdom');\n }\n\n return {\n h,\n alias,\n special,\n reconcile,\n settings: {\n shouldUpdate,\n isMap,\n mapIter,\n mapEach,\n mapGet,\n mapMerge,\n newMap,\n mapPut,\n isSeq,\n flattenSeq,\n seqIter,\n convertTagName,\n convertPropName,\n convertStyleName,\n convertDataName,\n convertClassName,\n convertHookName,\n convertName,\n listenerKey,\n captureKey,\n passiveKey,\n },\n };\n};\n",
6
+ "export default function htmlFactory({h}) {\n return {\n // Document metadata\n title: (...args) => h('title', ...args),\n meta: props => h('meta', props),\n link: props => h('link', props),\n style: (...args) => h('style', ...args),\n script: (...args) => h('script', ...args),\n noscript: (...args) => h('noscript', ...args),\n\n // Content sectioning\n address: (...args) => h('address', ...args),\n article: (...args) => h('article', ...args),\n aside: (...args) => h('aside', ...args),\n footer: (...args) => h('footer', ...args),\n header: (...args) => h('header', ...args),\n h1: (...args) => h('h1', ...args),\n h2: (...args) => h('h2', ...args),\n h3: (...args) => h('h3', ...args),\n h4: (...args) => h('h4', ...args),\n h5: (...args) => h('h5', ...args),\n h6: (...args) => h('h6', ...args),\n main: (...args) => h('main', ...args),\n nav: (...args) => h('nav', ...args),\n section: (...args) => h('section', ...args),\n\n // Text content\n blockquote: (...args) => h('blockquote', ...args),\n dd: (...args) => h('dd', ...args),\n div: (...args) => h('div', ...args),\n dl: (...args) => h('dl', ...args),\n dt: (...args) => h('dt', ...args),\n figcaption: (...args) => h('figcaption', ...args),\n figure: (...args) => h('figure', ...args),\n hr: () => h('hr'),\n li: (...args) => h('li', ...args),\n ol: (...args) => h('ol', ...args),\n p: (...args) => h('p', ...args),\n pre: (...args) => h('pre', ...args),\n ul: (...args) => h('ul', ...args),\n\n // Inline text semantics\n a: (...args) => h('a', ...args),\n abbr: (...args) => h('abbr', ...args),\n b: (...args) => h('b', ...args),\n br: () => h('br'),\n cite: (...args) => h('cite', ...args),\n code: (...args) => h('code', ...args),\n data: (...args) => h('data', ...args),\n del: (...args) => h('del', ...args),\n dfn: (...args) => h('dfn', ...args),\n em: (...args) => h('em', ...args),\n i: (...args) => h('i', ...args),\n ins: (...args) => h('ins', ...args),\n kbd: (...args) => h('kbd', ...args),\n mark: (...args) => h('mark', ...args),\n q: (...args) => h('q', ...args),\n s: (...args) => h('s', ...args),\n samp: (...args) => h('samp', ...args),\n small: (...args) => h('small', ...args),\n span: (...args) => h('span', ...args),\n strong: (...args) => h('strong', ...args),\n sub: (...args) => h('sub', ...args),\n sup: (...args) => h('sup', ...args),\n time: (...args) => h('time', ...args),\n u: (...args) => h('u', ...args),\n wbr: () => h('wbr'),\n\n // Image and multimedia\n area: props => h('area', props),\n audio: (...args) => h('audio', ...args),\n img: props => h('img', props),\n map: (...args) => h('map', ...args),\n track: props => h('track', props),\n video: (...args) => h('video', ...args),\n\n // Embedded content\n embed: props => h('embed', props),\n iframe: (...args) => h('iframe', ...args),\n object: (...args) => h('object', ...args),\n param: props => h('param', props),\n picture: (...args) => h('picture', ...args),\n portal: (...args) => h('portal', ...args),\n source: props => h('source', props),\n\n // SVG and MathML\n svg: (...args) => h('svg', ...args),\n math: (...args) => h('math', ...args),\n\n // Scripting\n canvas: (...args) => h('canvas', ...args),\n\n // Table content\n caption: (...args) => h('caption', ...args),\n col: props => h('col', props),\n colgroup: (...args) => h('colgroup', ...args),\n table: (...args) => h('table', ...args),\n tbody: (...args) => h('tbody', ...args),\n td: (...args) => h('td', ...args),\n tfoot: (...args) => h('tfoot', ...args),\n th: (...args) => h('th', ...args),\n thead: (...args) => h('thead', ...args),\n tr: (...args) => h('tr', ...args),\n\n // Forms\n button: (...args) => h('button', ...args),\n datalist: (...args) => h('datalist', ...args),\n fieldset: (...args) => h('fieldset', ...args),\n form: (...args) => h('form', ...args),\n input: props => h('input', props),\n label: (...args) => h('label', ...args),\n legend: (...args) => h('legend', ...args),\n meter: (...args) => h('meter', ...args),\n optgroup: (...args) => h('optgroup', ...args),\n option: (...args) => h('option', ...args),\n output: (...args) => h('output', ...args),\n progress: (...args) => h('progress', ...args),\n select: (...args) => h('select', ...args),\n textarea: (...args) => h('textarea', ...args),\n\n // Interactive elements\n details: (...args) => h('details', ...args),\n dialog: (...args) => h('dialog', ...args),\n summary: (...args) => h('summary', ...args),\n\n // Web Components\n slot: (...args) => h('slot', ...args),\n template: (...args) => h('template', ...args),\n };\n}\n",
7
+ "const FRAME_BUDGET = 10; // ms\nconst CHUNK_SIZE = 100;\n\nexport default function factory({window} = {}) {\n let scheduled = false;\n let frameId = 0;\n let queue = [];\n\n // Resolved lazily: the default dodo instance is built at import time, which\n // in Node or a jsdom/happy-dom test may run before any animation frame or\n // performance API exists on the global object.\n function host() {\n return window ?? globalThis;\n }\n\n function requestFrame(f) {\n const raf = host().requestAnimationFrame;\n // ~1 frame at 60Hz. setTimeout also keeps the queue draining in\n // environments with no rAF at all, such as SSR and background workers.\n return typeof raf === 'function' ? raf.call(host(), f) : setTimeout(f, 16);\n }\n\n function cancelFrame(id) {\n const caf = host().cancelAnimationFrame;\n if (typeof caf === 'function') {\n caf.call(host(), id);\n } else {\n clearTimeout(id);\n }\n }\n\n function now() {\n return host().performance?.now() ?? Date.now();\n }\n\n function _runTasks(tasks) {\n for (const f of tasks) {\n try {\n f();\n } catch (err) {\n console.error('Error in scheduled function:', err);\n }\n }\n }\n\n function runQueue() {\n const startTime = now();\n frameId = 0;\n\n while (queue.length > 0) {\n const chunk = queue.splice(0, CHUNK_SIZE);\n _runTasks(chunk);\n\n if (now() - startTime > FRAME_BUDGET && queue.length > 0) {\n frameId = requestFrame(runQueue);\n return;\n }\n }\n\n scheduled = false;\n }\n\n // Schedules a function to be executed on the next animation frame.\n function schedule(f, {signal} = {}) {\n if (signal?.aborted) {\n return;\n }\n\n let task = f;\n // If a signal is provided, wrap the task to check for abortion before execution.\n if (signal) {\n task = () => {\n if (!signal.aborted) {\n f();\n }\n };\n }\n\n queue.push(task);\n\n if (!scheduled) {\n scheduled = true;\n frameId = requestFrame(runQueue);\n }\n }\n\n // Immediately runs all queued tasks synchronously.\n function flush() {\n if (frameId) {\n cancelFrame(frameId);\n frameId = 0;\n }\n // Tasks commonly schedule more work (a reconcile that queues a follow-up\n // render). Draining in a loop means flush() leaves an empty queue rather\n // than an orphaned one that no frame is pending for.\n scheduled = true;\n while (queue.length > 0) {\n const toRun = queue;\n queue = [];\n _runTasks(toRun);\n }\n scheduled = false;\n }\n\n // Clears all pending tasks.\n function clear() {\n if (frameId) {\n cancelFrame(frameId);\n }\n queue = [];\n scheduled = false;\n frameId = 0;\n }\n\n return {schedule, flush, clear};\n}\n",
8
+ "import vdomFactory from './src/vdom.js';\nimport htmlFactory from './src/html.js';\nimport schedulerFactory from './src/scheduler.js';\n\nfunction dodoFactory(userSettings) {\n const vdomInstance = vdomFactory(userSettings);\n const htmlInstance = htmlFactory(vdomInstance);\n // `scheduler` replaces the built in animation frame scheduler wholesale. It\n // must provide {schedule, flush, clear}. Useful for rendering synchronously,\n // for driving frames from a test, or for scheduling on idle instead.\n const schedulerInstance = userSettings?.scheduler ?? schedulerFactory(userSettings);\n return {\n ...vdomInstance,\n ...htmlInstance,\n ...schedulerInstance,\n };\n}\n\nconst defaultDodo = dodoFactory();\n\nexport {vdomFactory as vdom, htmlFactory as html, dodoFactory as dodo};\n\nexport const {\n h,\n alias,\n special,\n reconcile,\n settings,\n title,\n meta,\n link,\n style,\n script,\n noscript,\n address,\n article,\n aside,\n footer,\n header,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n main,\n nav,\n section,\n blockquote,\n dd,\n div,\n dl,\n dt,\n figcaption,\n figure,\n hr,\n li,\n ol,\n p,\n pre,\n ul,\n a,\n abbr,\n b,\n br,\n cite,\n code,\n data,\n del,\n dfn,\n em,\n i,\n ins,\n kbd,\n mark,\n q,\n s,\n samp,\n small,\n span,\n strong,\n sub,\n sup,\n time,\n u,\n wbr,\n area,\n audio,\n img,\n map,\n track,\n video,\n embed,\n iframe,\n object,\n param,\n picture,\n portal,\n source,\n svg,\n math,\n canvas,\n caption,\n col,\n colgroup,\n table,\n tbody,\n td,\n tfoot,\n th,\n thead,\n tr,\n button,\n datalist,\n fieldset,\n form,\n input,\n label,\n legend,\n meter,\n optgroup,\n option,\n output,\n progress,\n select,\n textarea,\n details,\n dialog,\n summary,\n slot,\n template,\n schedule,\n flush,\n clear,\n} = defaultDodo;\n",
9
+ "/**\n * Shared settings resolution for dodo's optional modules.\n *\n * The modules follow the same factory shape as the rest of the project: you\n * hand a factory a `userSettings` object carrying a `dodo` instance, and it\n * returns a configured API.\n *\n * const {watch} = reactive({dodo});\n * const {withContext, useContext} = context({dodo, reactive: {watch}});\n *\n * Dependencies between modules are injected, not discovered. `context` renders\n * through a `watch`, so it takes one — build it once and pass it in. That\n * matters more than it looks: a `special` component's identity *is* its\n * descriptor object, and the reconciler uses that identity to decide whether a\n * DOM node can be reused, so two independently built `watch` components would\n * never reuse each other's nodes.\n *\n * As a convenience a bare dodo instance is accepted in place of the settings\n * object:\n *\n * const {watch} = reactive(dodo);\n */\n\nfunction microtaskSchedule(fn, {signal} = {}) {\n queueMicrotask(() => {\n if (!signal?.aborted) fn();\n });\n}\n\nfunction defaultRenderError(h) {\n return error =>\n h(\n 'pre',\n {\n $styling: {\n 'background-color': '#fdd',\n color: '#330',\n padding: '1em',\n 'white-space': 'pre-wrap',\n },\n },\n h('strong', null, `Error: ${error?.message ?? String(error)}`),\n '\\n\\n',\n error?.stack ?? '',\n );\n}\n\nfunction looksLikeDodo(value) {\n return (\n value != null && typeof value.special === 'function' && typeof value.reconcile === 'function'\n );\n}\n\n/**\n * Merges user settings with defaults.\n *\n * | setting | default |\n * | ------------- | ------------------------------------------- |\n * | `dodo` | required |\n * | `schedule` | the instance's `schedule`, else a microtask |\n * | `renderError` | a `<pre>` with the message and stack |\n */\nexport function settings(userSettings) {\n const source = looksLikeDodo(userSettings) ? {dodo: userSettings} : userSettings;\n const dodo = source?.dodo;\n if (!looksLikeDodo(dodo)) {\n throw new Error('a dodo instance must be provided in settings, e.g. reactive({dodo})');\n }\n\n return {\n // Rendering is scheduled rather than run inline so that a burst of changes\n // collapses into one pass. Replace it to render synchronously, to render on\n // idle, or to drive frames from a test.\n schedule: typeof dodo.schedule === 'function' ? dodo.schedule : microtaskSchedule,\n renderError: defaultRenderError(dodo.h),\n ...source,\n dodo,\n // Map handling and change detection always come from the dodo instance. A\n // module that disagreed with its renderer about what a map is would be\n // worse than useless, so these are not overridable here.\n ...dodo.settings,\n };\n}\n",
10
+ "/**\n * Optional reactivity for dodo.\n *\n * Nothing in dodo's core imports this module, and this module only ever reads\n * the public dodo API it is handed. It is safe to ignore entirely.\n *\n * Everything here is built on one small protocol, the **Cell**:\n *\n * { onDirty(fn) -> unsubscribe, getValue() -> any }\n *\n * `onDirty` registers a callback that fires when the value *may* have changed,\n * and `getValue` pulls the current value. That is the whole contract. It is\n * deliberately push-to-invalidate / pull-to-read: dodo can coalesce any number\n * of invalidations into a single render and then read once.\n *\n * Because the contract is this small, most reactive libraries adapt to it in a\n * few lines. `fromObservable`, `fromSubscribe` and `fromSignal` cover the\n * common shapes (RxJS-style observables, callback subscriptions such as Svelte\n * stores, and preact signals respectively).\n *\n * Two values are special:\n * - `PENDING` means \"no value yet\"; `watch` renders its placeholder instead\n * of calling the builder.\n * - An error is reported by *throwing* from `getValue()`; `watch` catches it\n * and renders its error view.\n */\n\nimport {settings as resolveSettings} from './settings.js';\n\nexport const PENDING = Symbol('dodo.reactive.PENDING');\n\nconst NOTHING = Symbol('dodo.reactive.NOTHING');\n\n/** Duck-types a Cell. Anything with both methods qualifies. */\nexport function isCell(value) {\n return (\n value != null && typeof value.onDirty === 'function' && typeof value.getValue === 'function'\n );\n}\n\n/** Reads a Cell, passing plain values straight through. */\nexport function readCell(value) {\n return isCell(value) ? value.getValue() : value;\n}\n\nfunction toUnsubscribe(subscription) {\n if (typeof subscription === 'function') return subscription;\n if (subscription && typeof subscription.unsubscribe === 'function') {\n return () => subscription.unsubscribe();\n }\n return () => {};\n}\n\n/**\n * A listener set plus a safe fan-out, for writing your own cells:\n *\n * const {listeners, notify} = notifier();\n */\nexport function notifier() {\n const listeners = new Set();\n return {\n listeners,\n notify() {\n // Copied because a listener may unsubscribe itself while being notified.\n for (const listener of Array.from(listeners)) {\n try {\n listener();\n } catch (err) {\n console.error('Error in dodo cell listener:', err);\n }\n }\n },\n };\n}\n\n/**\n * Shared plumbing for adapted cells: connect to the upstream source on the\n * first listener and disconnect on the last. Staying disconnected while nobody\n * is listening is what keeps adapted sources from leaking subscriptions once\n * their `watch` has been detached — cleanup is structural rather than something\n * every adapter has to remember.\n *\n * `connect` receives a `notify` callback and returns either an unsubscribe\n * function or `{unsubscribe}`. `read` supplies `getValue`, and should cope with\n * being called while disconnected.\n *\n * const online = connectable(\n * notify => {\n * addEventListener('online', notify);\n * addEventListener('offline', notify);\n * return () => {\n * removeEventListener('online', notify);\n * removeEventListener('offline', notify);\n * };\n * },\n * () => navigator.onLine,\n * );\n */\nexport function connectable(connect, read) {\n const {listeners, notify} = notifier();\n let disconnect = null;\n\n return {\n onDirty(fn) {\n listeners.add(fn);\n if (listeners.size === 1) {\n try {\n disconnect = toUnsubscribe(connect(notify));\n } catch (err) {\n // Leaving the listener in place would make the cell look connected\n // for good, so a later subscriber would never retry.\n listeners.delete(fn);\n throw err;\n }\n }\n let removed = false;\n return () => {\n if (removed) return;\n removed = true;\n listeners.delete(fn);\n if (listeners.size === 0 && disconnect) {\n const stop = disconnect;\n disconnect = null;\n stop();\n }\n };\n },\n getValue() {\n return read();\n },\n };\n}\n\n/**\n * A writable cell. The simplest possible source, and enough on its own for\n * applications that do not want another dependency.\n *\n * const count = cell(0);\n * count.setValue(1);\n * count.update(n => n + 1);\n */\nexport function cell(initialValue) {\n let value = initialValue;\n const {listeners, notify} = notifier();\n\n return {\n onDirty(fn) {\n listeners.add(fn);\n return () => listeners.delete(fn);\n },\n getValue() {\n return value;\n },\n setValue(newValue) {\n if (Object.is(newValue, value)) return;\n value = newValue;\n notify();\n },\n update(fn) {\n this.setValue(fn(value));\n },\n };\n}\n\n/** A cell that never changes. Useful for filling a slot in `derive`. */\nexport function constant(value) {\n return {\n onDirty() {\n return () => {};\n },\n getValue() {\n return value;\n },\n };\n}\n\n/**\n * Derives a cell from other cells (or plain values).\n *\n * const total = derive([price, qty], (p, q) => p * q);\n *\n * The result is memoised while subscribed: `compute` runs on the first read\n * after an upstream invalidation and not again until the next one. If any\n * dependency is `PENDING` the derived cell is `PENDING` too and `compute` is\n * not called at all.\n */\nexport function derive(dependencies, compute) {\n const deps = Array.isArray(dependencies) ? dependencies : [dependencies];\n const {listeners, notify} = notifier();\n let unsubscribes = null;\n let cached = NOTHING;\n\n const invalidate = () => {\n cached = NOTHING;\n notify();\n };\n\n const recompute = () => {\n const values = new Array(deps.length);\n for (let i = 0; i < deps.length; i++) {\n const value = readCell(deps[i]);\n if (value === PENDING) return PENDING;\n values[i] = value;\n }\n return compute(...values);\n };\n\n return {\n onDirty(fn) {\n listeners.add(fn);\n if (listeners.size === 1) {\n cached = NOTHING;\n unsubscribes = deps.map(dep => (isCell(dep) ? dep.onDirty(invalidate) : null));\n }\n let removed = false;\n return () => {\n if (removed) return;\n removed = true;\n listeners.delete(fn);\n if (listeners.size === 0 && unsubscribes) {\n for (const unsubscribe of unsubscribes) unsubscribe?.();\n unsubscribes = null;\n cached = NOTHING;\n }\n };\n },\n getValue() {\n // Without listeners there is nothing telling us when the cache went\n // stale, so an unsubscribed derived cell always recomputes.\n if (cached === NOTHING || !unsubscribes) {\n cached = recompute();\n }\n return cached;\n },\n };\n}\n\n/** Convenience for the single dependency case. */\nexport function mapCell(source, fn) {\n return derive([source], fn);\n}\n\n/**\n * Adapts an observer-style observable: `subscribe({next, error, complete})`,\n * as produced by RxJS, the TC39 proposal, and bones' own `Observable`.\n *\n * The cell reports `PENDING` until the first emission unless `initial` is\n * given, and rethrows from `getValue()` if the source errors.\n */\nexport function fromObservable(observable, {initial = PENDING} = {}) {\n return fromSource(observable, {initial}, (source, handlers) =>\n source.subscribe({\n next: handlers.next,\n error: handlers.error,\n complete: handlers.complete,\n }),\n );\n}\n\n/**\n * Adapts a callback-style subscription: `subscribe(value => ...)` returning\n * either an unsubscribe function or `{unsubscribe}`. This covers Svelte stores,\n * preact signals' own `.subscribe`, and most hand-rolled stores.\n */\nexport function fromSubscribe(subscribable, {initial = PENDING} = {}) {\n return fromSource(subscribable, {initial}, (source, handlers) => {\n const subscribe = typeof source === 'function' ? source : source.subscribe.bind(source);\n return subscribe(handlers.next);\n });\n}\n\nfunction fromSource(source, {initial}, subscribe) {\n let value = initial;\n let failure = NOTHING;\n\n const cellApi = connectable(\n notify => {\n const handlers = {\n next(newValue) {\n value = newValue;\n failure = NOTHING;\n notify();\n },\n error(err) {\n failure = err;\n notify();\n },\n complete() {},\n };\n return subscribe(source, handlers);\n },\n () => {\n if (failure !== NOTHING) throw failure;\n return value;\n },\n );\n\n return cellApi;\n}\n\n/**\n * Adapts a preact signal (`@preact/signals-core` and friends).\n *\n * Reads go through `signal.peek()`, so consuming a signal through a cell never\n * registers a tracking dependency on whatever effect happens to be running, and\n * the cell can never hand back a stale copy of the signal's value.\n *\n * Invalidation uses `signal.subscribe` when available; pass `{effect}` (the\n * library's own `effect` function) if you would rather drive it that way, or if\n * you are adapting a computed from a build that has no `subscribe`.\n */\nexport function fromSignal(signal, {effect} = {}) {\n if (signal == null || (typeof signal !== 'object' && typeof signal !== 'function')) {\n throw new TypeError('fromSignal expects a signal object');\n }\n const read = typeof signal.peek === 'function' ? () => signal.peek() : () => signal.value;\n\n return connectable(notify => {\n // Both `effect` and `signal.subscribe` invoke their callback once up front.\n // That first call carries no news — the consumer is about to pull anyway —\n // so it is swallowed to avoid an immediate redundant render.\n let primed = false;\n const onChange = () => {\n if (!primed) {\n primed = true;\n return;\n }\n notify();\n };\n\n if (typeof effect === 'function') {\n return effect(() => {\n signal.value; // establishes the dependency\n onChange();\n });\n }\n if (typeof signal.subscribe === 'function') {\n return signal.subscribe(onChange);\n }\n throw new TypeError('fromSignal needs either signal.subscribe or an {effect} option');\n }, read);\n}\n\n/**\n * Exposes a cell as a minimal observer-style observable, for handing dodo state\n * back to code that speaks that protocol.\n */\nexport function toObservable(source) {\n return {\n subscribe(observerOrNext) {\n const observer =\n typeof observerOrNext === 'function' ? {next: observerOrNext} : (observerOrNext ?? {});\n const emit = () => {\n let value;\n try {\n value = readCell(source);\n } catch (err) {\n observer.error?.(err);\n return;\n }\n if (value !== PENDING) observer.next?.(value);\n };\n const unsubscribe = isCell(source) ? source.onDirty(emit) : () => {};\n emit();\n return {unsubscribe};\n },\n };\n}\n\n/**\n * Runs `fn` with the cell's value now and again on every change. Returns a\n * dispose function. This is the escape hatch for reacting to state outside of\n * rendering (logging, persistence, imperative DOM work).\n */\nexport function effect(source, fn) {\n const run = () => {\n let value;\n try {\n value = readCell(source);\n } catch (err) {\n console.error('Error reading cell in effect:', err);\n return;\n }\n if (value === PENDING) return;\n fn(value);\n };\n const unsubscribe = isCell(source) ? source.onDirty(run) : () => {};\n run();\n return unsubscribe;\n}\n\nconst WATCH_STATE = Symbol('dodo.reactive.watch');\n\n/**\n * Builds the dodo-aware half of the module: the `watch` component.\n *\n * const {watch} = reactive({dodo});\n *\n * Settings:\n *\n * | setting | purpose |\n * | ------------- | -------------------------------------------------------- |\n * | `dodo` | the instance to render into (required) |\n * | `schedule` | how re-renders are deferred and coalesced |\n * | `renderError` | the fallback error view, when `watch` is given no `error` |\n *\n * Each call builds a new `watch`, and a `special` component's identity is its\n * descriptor object. Build one per application and pass it around — in\n * particular, hand it to `context` — rather than calling this per module.\n *\n * Cells themselves are instance-independent; only `watch` needs to know which\n * dodo it renders into.\n */\nexport default function reactiveFactory(userSettings) {\n const settings = resolveSettings(userSettings);\n const {dodo, schedule, renderError} = settings;\n const {special, reconcile} = dodo;\n const rawMapGet = settings.mapGet ?? ((m, k) => m[k]);\n // `options` is optional at every call site, and a custom `mapGet` is under no\n // obligation to tolerate a nullish map.\n const mapGet = (map, key) => (map == null ? undefined : rawMapGet(map, key));\n const shouldUpdate = settings.shouldUpdate ?? ((a, b) => a !== b);\n\n const watch = special({\n attach(element) {\n element[WATCH_STATE] = {\n source: NOTHING,\n builder: null,\n placeholder: undefined,\n errorBuilder: undefined,\n unsubscribe: null,\n abortController: null,\n renderScheduled: false,\n lastValue: NOTHING,\n lastBuilder: NOTHING,\n };\n },\n\n update(element, [source, builder, options]) {\n const state = element[WATCH_STATE];\n if (!state) return;\n\n state.builder = builder;\n state.placeholder = mapGet(options, 'placeholder');\n state.errorBuilder = mapGet(options, 'error');\n\n if (state.source !== source) {\n state.unsubscribe?.();\n state.unsubscribe = null;\n state.abortController?.abort();\n state.abortController = new AbortController();\n state.source = source;\n state.lastValue = NOTHING;\n if (isCell(source)) {\n try {\n // Subscribing can emit synchronously (a subject replaying its\n // current value), which schedules a render that the direct call\n // below then finds nothing left to do for.\n state.unsubscribe = source.onDirty(() => this.invalidate(element));\n } catch (err) {\n // Connecting is as much a part of reading the cell as getValue is —\n // an adapter with no observer to attach to fails here, not there.\n this.renderError(element, err);\n return;\n }\n }\n }\n\n this.render(element);\n },\n\n invalidate(element) {\n const state = element[WATCH_STATE];\n if (!state || state.renderScheduled) return;\n state.renderScheduled = true;\n schedule(() => this.render(element), {signal: state.abortController?.signal});\n },\n\n render(element) {\n const state = element[WATCH_STATE];\n if (!state) return;\n state.renderScheduled = false;\n\n let value;\n try {\n value = readCell(state.source === NOTHING ? undefined : state.source);\n } catch (err) {\n this.renderError(element, err);\n return;\n }\n\n // Re-rendering identical output is the common case for a cell shared by\n // several watchers, so it is worth short-circuiting before the builder runs.\n if (\n state.builder === state.lastBuilder &&\n state.lastValue !== NOTHING &&\n !shouldUpdate(state.lastValue, value)\n ) {\n return;\n }\n state.lastValue = value;\n state.lastBuilder = state.builder;\n\n try {\n if (value === PENDING) {\n reconcile(element, state.placeholder ? [state.placeholder()] : []);\n } else {\n reconcile(element, [state.builder(value)]);\n }\n } catch (err) {\n this.renderError(element, err);\n }\n },\n\n renderError(element, error) {\n const state = element[WATCH_STATE];\n if (!state) return;\n state.lastValue = NOTHING;\n state.lastBuilder = NOTHING;\n console.error('Error in watched cell:', error);\n try {\n reconcile(element, [(state.errorBuilder ?? renderError)(error)]);\n } catch (err) {\n console.error('Error rendering the error view:', err);\n }\n },\n\n detach(element) {\n const state = element[WATCH_STATE];\n if (!state) return;\n state.unsubscribe?.();\n state.abortController?.abort();\n delete element[WATCH_STATE];\n reconcile(element, null);\n },\n });\n\n return {watch};\n}\n",
11
+ "/**\n * `@3sln/dodo/reactive` — the reactive module bound to dodo's default instance.\n *\n * import {cell, watch} from '@3sln/dodo/reactive';\n *\n * `@3sln/dodo/context` is built with this exact `watch` injected, so the two\n * entry points render through one component.\n *\n * If you build your own dodo with `dodo(userSettings)`, or you want to replace\n * the scheduler or the error view, bake your own copy — and inject it into\n * `context` so the two stay one system:\n *\n * import reactive from '@3sln/dodo/src/reactive.js';\n * import context from '@3sln/dodo/src/context.js';\n *\n * const {watch} = reactive({dodo: myDodo});\n * const {withContext} = context({dodo: myDodo, reactive: {watch}});\n */\nimport * as dodo from './index.js';\nimport reactiveFactory from './src/reactive.js';\n\nexport * from './src/reactive.js';\nexport {default as reactive} from './src/reactive.js';\nexport {settings} from './src/settings.js';\n\nexport const {watch} = reactiveFactory({dodo});\n",
12
+ "// Wire the 3sln stack for Trove's web client.\n//\n// - dodo: the VDOM (h, reconcile, element helpers, alias/special)\n// - dodo/reactive: cells, and the `watch` component that renders one\n//\n// bones is gone; what Trove used of it — `watch`, a writable subject, and a way\n// to combine several of them — moved into dodo as the **Cell** protocol:\n//\n// { onDirty(fn) -> unsubscribe, getValue() -> any }\n//\n// That is a smaller contract than the observable it replaces, and the difference\n// shows up in two places we care about. It is push-to-invalidate / pull-to-read,\n// so any number of invalidations in one frame coalesce into a single render;\n// and a cell always HAS a value, so a `watch` renders its store's current state\n// on the first pass instead of waiting for an emission that already happened.\n//\n// `PENDING` is how a cell says \"no value yet\" — `watch` renders its placeholder\n// instead of calling the builder. An error is reported by THROWING from\n// `getValue()`, which `watch` renders as its error view.\n\nimport * as dodo from '@3sln/dodo';\nimport {\n watch, cell, derive, constant, mapCell, connectable,\n fromObservable, toObservable, effect, isCell, readCell, PENDING,\n} from '@3sln/dodo/reactive';\n\nexport const dd = dodo;\n\nexport {\n watch, cell, derive, constant, mapCell, connectable,\n fromObservable, toObservable, effect, isCell, readCell, PENDING,\n};\n\n/** The reactive API as one object, for `platform.reactive` (and plugin-facing code). */\nexport const reactive = {\n watch, cell, derive, constant, mapCell, connectable,\n fromObservable, toObservable, effect, isCell, readCell, PENDING,\n};\n",
13
+ "// A small, deliberate error taxonomy. Everything that can fail in Trove throws\n// (or rejects with) a TroveError subclass so callers — and ultimately the user —\n// get a stable `code`, a human `message`, and a `retryable` signal that the\n// retry helper and the HTTP layer both key off of. Wrapping a lower-level cause\n// (an S3 SDK error, a fetch TypeError) preserves it under `.cause` for logs\n// while presenting a clean surface upward.\n\n/** Stable, machine-readable codes. Mirrored by the HTTP layer → status codes. */\nexport const ErrorCode = Object.freeze({\n NOT_FOUND: 'not_found',\n ALREADY_EXISTS: 'already_exists',\n INVALID: 'invalid', // bad request / validation\n CONFLICT: 'conflict', // version/etag mismatch, concurrent edit\n UNAUTHORIZED: 'unauthorized',\n FORBIDDEN: 'forbidden',\n UNSUPPORTED: 'unsupported', // backend can't do this (e.g. presign on fs)\n QUOTA: 'quota', // out of space (507) / rate limited by capacity (429) — see below\n TOO_LARGE: 'too_large', // this request is bigger than a configured limit allows\n BAD_RANGE: 'bad_range', // the requested byte range doesn't exist in this object (416)\n TRANSIENT: 'transient', // network blip, 5xx, throttle — safe to retry\n TIMEOUT: 'timeout',\n ABORTED: 'aborted', // caller cancelled (AbortSignal)\n INTERNAL: 'internal', // unexpected; a bug\n});\n\n// Which codes are, by default, safe to retry with backoff.\nconst RETRYABLE = new Set([ErrorCode.TRANSIENT, ErrorCode.TIMEOUT, ErrorCode.QUOTA]);\n\n// HTTP status for each code, so the server layer stays declarative.\nconst HTTP_STATUS = {\n [ErrorCode.NOT_FOUND]: 404,\n [ErrorCode.ALREADY_EXISTS]: 409,\n [ErrorCode.INVALID]: 400,\n [ErrorCode.CONFLICT]: 412,\n [ErrorCode.UNAUTHORIZED]: 401,\n [ErrorCode.FORBIDDEN]: 403,\n [ErrorCode.UNSUPPORTED]: 501,\n [ErrorCode.QUOTA]: 429,\n [ErrorCode.TOO_LARGE]: 413,\n [ErrorCode.BAD_RANGE]: 416,\n [ErrorCode.TRANSIENT]: 503,\n [ErrorCode.TIMEOUT]: 504,\n [ErrorCode.ABORTED]: 499,\n [ErrorCode.INTERNAL]: 500,\n};\n\nexport class TroveError extends Error {\n /**\n * @param {string} code one of ErrorCode\n * @param {string} message human-readable, safe to surface to the user\n * @param {{cause?: unknown, retryable?: boolean, details?: object}} [opts]\n */\n constructor(code, message, opts = {}) {\n super(message, opts.cause !== undefined ? { cause: opts.cause } : undefined);\n this.name = 'TroveError';\n this.code = code || ErrorCode.INTERNAL;\n // Explicit override wins; otherwise derive from the code.\n this.retryable = opts.retryable ?? RETRYABLE.has(this.code);\n this.details = opts.details ?? null;\n this.status = HTTP_STATUS[this.code] ?? 500;\n // QUOTA covers two failures that deserve different statuses. A rate limit is 429 —\n // back off and try again. Being out of DISK is 507: retrying changes nothing, and\n // telling a client to retry sends it into a loop against a condition only a human\n // can clear. `retryable` is what tells them apart.\n //\n // \"Your file is bigger than we allow\" is neither, and has its own code (TOO_LARGE,\n // 413): the store is not full, and nothing about waiting or freeing space helps.\n if (this.code === ErrorCode.QUOTA && !this.retryable) this.status = 507;\n }\n\n /** Shape sent over the wire and logged. Never leaks the raw cause. */\n toJSON() {\n return {\n error: {\n code: this.code,\n message: this.message,\n retryable: this.retryable,\n ...(this.details ? { details: this.details } : {}),\n },\n };\n }\n\n // Ergonomic constructors — read like prose at the call site.\n static notFound(what, opts) {\n return new TroveError(ErrorCode.NOT_FOUND, what ? `${what} not found` : 'Not found', opts);\n }\n static alreadyExists(what, opts) {\n return new TroveError(ErrorCode.ALREADY_EXISTS, `${what} already exists`, opts);\n }\n static invalid(message, opts) {\n return new TroveError(ErrorCode.INVALID, message, opts);\n }\n static conflict(message, opts) {\n return new TroveError(ErrorCode.CONFLICT, message, opts);\n }\n static unsupported(message, opts) {\n return new TroveError(ErrorCode.UNSUPPORTED, message, opts);\n }\n static transient(message, opts) {\n return new TroveError(ErrorCode.TRANSIENT, message, { retryable: true, ...opts });\n }\n static timeout(message, opts) {\n return new TroveError(ErrorCode.TIMEOUT, message, { retryable: true, ...opts });\n }\n static aborted(message = 'Operation aborted', opts) {\n return new TroveError(ErrorCode.ABORTED, message, { retryable: false, ...opts });\n }\n static unauthorized(message = 'Unauthorized', opts) {\n return new TroveError(ErrorCode.UNAUTHORIZED, message, opts);\n }\n static tooLarge(message = 'Too large', opts) {\n return new TroveError(ErrorCode.TOO_LARGE, message, { retryable: false, ...opts });\n }\n /** The requested byte range doesn't exist in this object — 416, not 400 or 500. */\n static badRange(message = 'Range not satisfiable', opts) {\n return new TroveError(ErrorCode.BAD_RANGE, message, { retryable: false, ...opts });\n }\n static forbidden(message = 'Forbidden', opts) {\n return new TroveError(ErrorCode.FORBIDDEN, message, opts);\n }\n /**\n * Rate limited — 429, and retryable, which is what tells it apart from being out of\n * disk. See the constructor: QUOTA is 507 when it is NOT retryable, because telling a\n * client to retry against a full volume sends it into a loop only a human can end.\n */\n static rateLimited(message, opts) {\n return new TroveError(ErrorCode.QUOTA, message, { retryable: true, ...opts });\n }\n static internal(message = 'Internal error', opts) {\n return new TroveError(ErrorCode.INTERNAL, message, opts);\n }\n}\n\n/**\n * Normalize any thrown value into a TroveError. Recognises AbortError, common\n * fetch/network failures, and Node fs errno codes so lower layers can just\n * `throw wrapError(e)` and get sane classification for free.\n */\nexport function wrapError(err, fallbackMessage = 'Unexpected error') {\n if (err instanceof TroveError) return err;\n\n // Cancellation.\n if (err?.name === 'AbortError' || err?.code === 'ABORT_ERR') {\n return TroveError.aborted(err.message || 'Operation aborted', { cause: err });\n }\n\n // Node/browser network failures are transient by nature.\n const netCodes = new Set([\n 'ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'EAI_AGAIN', 'EPIPE', 'ENOTFOUND', 'UND_ERR_SOCKET',\n ]);\n if (netCodes.has(err?.code) || (err instanceof TypeError && /fetch|network/i.test(err.message || ''))) {\n return TroveError.transient(err.message || 'Network error', { cause: err });\n }\n\n // Node fs errnos.\n switch (err?.code) {\n case 'ENOENT':\n return TroveError.notFound(null, { cause: err });\n case 'EEXIST':\n return TroveError.alreadyExists('Path', { cause: err });\n case 'EACCES':\n case 'EPERM':\n return new TroveError(ErrorCode.FORBIDDEN, 'Permission denied', { cause: err });\n // Out of room. NOT retryable, unlike the rate-limit sense of QUOTA that shares this\n // code — retrying a full disk just burns the user's time to reach the same answer.\n // The message is what someone can act on, rather than the kernel's phrasing.\n case 'ENOSPC':\n return new TroveError(ErrorCode.QUOTA, 'The storage volume is full — free some space and try again', { cause: err, retryable: false });\n case 'EDQUOT':\n return new TroveError(ErrorCode.QUOTA, 'The storage quota for this volume has been reached', { cause: err, retryable: false });\n case 'EFBIG':\n return new TroveError(ErrorCode.QUOTA, 'That file is larger than this filesystem can store', { cause: err, retryable: false });\n }\n\n return TroveError.internal(err?.message || fallbackMessage, { cause: err });\n}\n\n/**\n * Did this fail because the store is out of room?\n *\n * QUOTA covers two different things — \"no space left\" and \"you are being rate limited\"\n * — and only the first is a standing condition someone has to go and fix. Callers that\n * want to raise a persistent, actionable problem need to tell them apart, and the\n * distinguishing fact is that a full disk is not retryable.\n */\nexport function isOutOfSpace(err) {\n return err instanceof TroveError && err.code === ErrorCode.QUOTA && err.retryable === false;\n}\n\n/** True if the thrown value should be retried. */\nexport function isRetryable(err) {\n if (err instanceof TroveError) return err.retryable;\n return wrapError(err).retryable;\n}\n",
14
+ "// Small runtime-agnostic helpers. No Node or browser globals beyond what's\n// standard in both (crypto.randomUUID, TextEncoder, Web Streams).\n\nimport { TroveError } from './errors.js';\n\n/** URL-safe unique id. */\nexport function newId(prefix = '') {\n const uuid = (globalThis.crypto?.randomUUID?.() ?? fallbackUuid()).replace(/-/g, '');\n return prefix ? `${prefix}_${uuid}` : uuid;\n}\n\nfunction fallbackUuid() {\n // Only used where crypto.randomUUID is unavailable; good enough for ids.\n let s = '';\n for (let i = 0; i < 32; i++) s += Math.floor(Math.random() * 16).toString(16);\n return s;\n}\n\n// ---- item names -------------------------------------------------------------\n// There are no paths: a collection is a flat namespace, and a name is the whole\n// address within it. Slashes are rejected because a name has to survive the `/name`\n// shorthand of a trove: link without splitting.\n\n/**\n * A user-visible ITEM name. Distinct from the `isValidName` in plugins/identity.js,\n * which validates a *name segment in the contribution address space* — same word, very\n * different rule, so they get different names rather than colliding across the two\n * public entry points that export them.\n */\nexport function isValidItemName(name) {\n return (\n typeof name === 'string' &&\n name.length > 0 &&\n name.length <= 255 &&\n !name.includes('/') &&\n name !== '.' &&\n name !== '..' &&\n // eslint-disable-next-line no-control-regex\n !/[\\x00-\\x1f]/.test(name)\n );\n}\n\n/** The lowercased extension of an item name, including the dot ('' if none). */\nexport function extname(name) {\n const i = String(name || '').lastIndexOf('.');\n return i > 0 ? String(name).slice(i).toLowerCase() : '';\n}\n\n/**\n * Does a contribution/opener/indexer `selector` match a file node? One matcher shared\n * by the client contribution registry and the server indexers so they can't drift.\n * A selector has any of: `match(node)` (a predicate, built-ins only), `ext` (with or\n * without leading dot), `mime`/`contentType` (exact or a `type/*` prefix).\n */\nexport function selectorMatches(selector, node) {\n if (!selector || !node) return false;\n if (typeof selector.match === 'function') {\n try { if (selector.match(node)) return true; } catch { /* ignore a bad matcher */ }\n }\n const ext = extname(node.name || '');\n if (ext && (selector.ext || []).some((e) => (e.startsWith('.') ? e : '.' + e).toLowerCase() === ext)) return true;\n const ct = node.contentType || '';\n const mimes = selector.mime || selector.contentType || [];\n return mimes.some((m) => (m.endsWith('/*') ? ct.startsWith(m.slice(0, -1)) : ct === m));\n}\n\n// ---- byte helpers -----------------------------------------------------------\n\n/** Concatenate Uint8Array chunks into one. */\nexport function concatBytes(chunks) {\n let total = 0;\n for (const c of chunks) total += c.length;\n const out = new Uint8Array(total);\n let off = 0;\n for (const c of chunks) { out.set(c, off); off += c.length; }\n return out;\n}\n\n/** Drain a web ReadableStream into a single Uint8Array. */\nexport async function readAll(stream) {\n const reader = stream.getReader();\n const chunks = [];\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n chunks.push(value instanceof Uint8Array ? value : new Uint8Array(value));\n }\n return concatBytes(chunks);\n}\n\n\n/**\n * Refuse a URL that would make the server fetch something on its own network.\n *\n * Anywhere a caller supplies a URL the SERVER will later request, this is the gate. The\n * dangerous targets are not exotic: `169.254.169.254` is cloud instance metadata (and\n * with it, credentials), `127.0.0.1` and private ranges are whatever else the box is\n * running, and `.internal`/`.local` are the names those things usually have.\n *\n * DNS names that resolve to private addresses are a residual risk — rebinding cannot be\n * settled at this layer — so a deployment that cares should egress-filter too.\n *\n * @param {string} url\n * @param {string} what named in the error, so the message says which field was wrong\n */\nexport function assertPublicUrl(url, what = 'URL') {\n let u;\n try { u = new URL(String(url)); } catch { throw TroveError.invalid(`${what} is not a valid URL`); }\n if (u.protocol !== 'https:' && u.protocol !== 'http:') {\n throw TroveError.invalid(`${what} must be http(s)`);\n }\n const h = u.hostname.toLowerCase();\n if (h === 'localhost' || h.endsWith('.localhost') || h.endsWith('.local') || h.endsWith('.internal')) {\n throw TroveError.invalid(`${what} points at an internal host`);\n }\n if (/^\\d{1,3}(\\.\\d{1,3}){3}$/.test(h)) {\n const [a, b] = h.split('.').map(Number);\n if (a === 10 || a === 127 || a === 0 || (a === 192 && b === 168)\n || (a === 172 && b >= 16 && b <= 31) || (a === 169 && b === 254) || a >= 224) {\n throw TroveError.invalid(`${what} points at a private address`);\n }\n }\n if (h.includes(':') || h.startsWith('[')) throw TroveError.invalid(`${what} may not be an IP literal`);\n return u;\n}\n",
15
+ "// Plugin identity and contribution URIs.\n//\n// A plugin is identified by its DOMAIN plus its NAME — never by a self-chosen opaque\n// id. The domain is proven (the package is signed, and the domain publishes the\n// signing key via assetlinks), so identity is verifiable rather than claimed. That\n// gives us three things at once:\n//\n// • no squatting: only acme.com can publish acme.com/docs\n// • versioning: acme.com/docs@2 is the same plugin as acme.com/docs@1, and a\n// different plugin from acme.com/sheets — which a self-chosen id can't express\n// • no cross-kind collisions: every contribution lives under its plugin, so an\n// opener, a status slot, a register and a command can all be called \"status\"\n// without colliding with each other or with another plugin's \"status\".\n//\n// Every contribution is addressed by a URI:\n//\n// trove+contrib:<domain>/<plugin>/<contribution>\n// e.g. trove+contrib:acme.com/docs/pdfViewer\n//\n// The host's own built-in contributions use the reserved `core` domain, so the\n// address space has exactly one shape: trove+contrib:core/workbench/explorer.delete\n\nimport { TroveError } from '../errors.js';\n\nexport const CONTRIB_SCHEME = 'trove+contrib:';\nexport const CORE_DOMAIN = 'core';\n\n// A DNS-ish domain (lowercase labels, dots) — or the reserved `core`.\nconst DOMAIN_RE = /^(?:core|[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+)$/;\n// A plugin or contribution name: lowercase-ish segment, no slashes or spaces.\nconst NAME_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;\n\nexport function isValidDomain(domain) {\n return typeof domain === 'string' && DOMAIN_RE.test(domain);\n}\nexport function isValidName(name) {\n return typeof name === 'string' && NAME_RE.test(name);\n}\n\n/** The plugin's identity: `<domain>/<name>`. Stable across versions. */\nexport function pluginId(manifest) {\n assertIdentity(manifest);\n return `${manifest.domain}/${manifest.name}`;\n}\n\n/** The full URI for one of a plugin's contributions. */\nexport function contribUri(manifest, contributionName) {\n if (!isValidName(contributionName)) {\n throw TroveError.invalid(`Invalid contribution name \"${contributionName}\"`);\n }\n return `${CONTRIB_SCHEME}${pluginId(manifest)}/${contributionName}`;\n}\n\n// The host's own contributions are addressed exactly like a plugin's: the reserved\n// `core` domain, and `workbench` as the package within it. So the address space has\n// one shape everywhere, and core names share a single namespace just as a plugin's do.\nexport const CORE_PACKAGE = 'workbench';\n\n/** A URI for one of the host's own built-in contributions. */\nexport function coreUri(name) {\n return `${CONTRIB_SCHEME}${CORE_DOMAIN}/${CORE_PACKAGE}/${name}`;\n}\n\n/** Parse a contribution URI into its parts, or null if it isn't one. */\nexport function parseContribUri(uri) {\n if (typeof uri !== 'string' || !uri.startsWith(CONTRIB_SCHEME)) return null;\n const rest = uri.slice(CONTRIB_SCHEME.length);\n const i = rest.indexOf('/');\n const j = rest.indexOf('/', i + 1);\n if (i < 0 || j < 0) return null;\n const domain = rest.slice(0, i);\n const plugin = rest.slice(i + 1, j);\n const name = rest.slice(j + 1);\n if (!domain || !plugin || !name) return null;\n return { domain, plugin, name, pluginId: `${domain}/${plugin}` };\n}\n\n/** Whether `uri` belongs to the plugin described by `manifest`. */\nexport function ownsUri(manifest, uri) {\n const p = parseContribUri(uri);\n return !!p && p.pluginId === `${manifest.domain}/${manifest.name}`;\n}\n\n/**\n * Every package must carry a verifiable identity: a domain it belongs to and a name\n * within that domain. Anonymous/self-identified packages are not installable.\n */\nexport function assertIdentity(manifest) {\n if (!isValidDomain(manifest?.domain)) {\n throw TroveError.invalid(`Plugin manifest needs a valid \"domain\" (got ${JSON.stringify(manifest?.domain)})`);\n }\n if (!isValidName(manifest?.name)) {\n throw TroveError.invalid(`Plugin manifest needs a valid \"name\" (got ${JSON.stringify(manifest?.name)})`);\n }\n if (manifest.domain === CORE_DOMAIN) {\n throw TroveError.invalid('The \"core\" domain is reserved for built-in contributions');\n }\n}\n",
16
+ "// What a package contributes — declared in its manifest as ONE map of\n// `name -> contribution`, where each contribution states its own `type` and that\n// type's options:\n//\n// \"contributes\": {\n// \"player\": { \"type\": \"opener\", \"title\": \"Demo Player\",\n// \"match\": { \"ext\": [\".demo\"] }, \"entry\": \"src/openers/player.js\" },\n// \"pdf\": { \"type\": \"indexer\", \"match\": { \"ext\": [\".pdf\"] }, \"entry\": \"src/indexers/pdf.js\" },\n// \"tap\": { \"type\": \"command\", \"title\": \"Demo: Tap\" },\n// \"status\": { \"type\": \"statusItem\", \"slot\": \"right\" },\n// \"busy\": { \"type\": \"register\", \"default\": false },\n// \"keys\": { \"type\": \"keymap\", \"path\": \"keymaps/default.json\" }\n// }\n//\n// One map, not a collection per kind, because the kinds never needed separate\n// namespaces — they needed a shared one. Here \"status\" is a single name under this\n// plugin, so its status item, its register and its command can't shadow each other,\n// and `trove+contrib:acme.com/docs/status` names exactly one thing in the world.\n//\n//\n// TWO SENSES OF \"CONTRIBUTION\", and this is one of them. Here it is an EXTENSION POINT a\n// package declares in its manifest and the host addresses by URI —\n// `trove+contrib:acme.com/docs/player`. The other sense lives in core/src/indexers/\n// contribution.js: per-node ENRICHMENT produced at runtime and addressed by contributorId,\n// which is what an `indexer` declared here goes on to emit. So a plugin declares a\n// contribution (this sense) which produces contributions (that one).\n//\n// The rule for telling them apart: this sense is DECLARED, static, and named by URI; that\n// sense is PRODUCED, per node, and named by contributor. Renaming the second was weighed\n// and declined — it is a wire rename on `node.contributions` and `/api/index/:indexerId`,\n// needing a dual-read window for a stored field, which is a lot of churn for a distinction\n// two sentences can carry.\n// Each contribution's `entry` (openers, indexers) points into the plugin's ONE module\n// tree — they are not nested sub-packages, so everything in a plugin shares modules\n// and code. What gets opened or indexed depends only on which entry module runs.\n\nimport { TroveError } from '../errors.js';\nimport { contribUri, isValidName, pluginId } from './identity.js';\n\n/** Every contribution type a package may declare, with how its options are normalized. */\nconst TYPES = {\n // A command in the palette. Its handler lives in the plugin's primary frame.\n command: {\n normalize: (c) => ({\n title: c.title || null, category: c.category || null, icon: c.icon || null,\n when: c.when || null, palette: c.palette !== false, offline: !!c.offline,\n }),\n },\n // A viewer for matching files, rendered by `entry` in its own sandboxed frame.\n opener: {\n needsEntry: true,\n normalize: (c) => ({\n title: c.title || null, match: normalizeMatch(c.match), priority: c.priority ?? 50,\n when: c.when || null, offline: !!c.offline, dock: c.dock || null,\n }),\n },\n // Indexes matching files. ALWAYS runs on the server (see serverIndexers).\n indexer: {\n needsEntry: true,\n normalize: (c) => ({ title: c.title || null, match: normalizeMatch(c.match) }),\n },\n // A slot in the status bar. The plugin pushes content into it at runtime; for now\n // the only content type is sanitized HTML.\n statusItem: {\n normalize: (c) => {\n const slot = c.slot === 'left' ? 'left' : 'right';\n const render = c.render || 'html';\n if (render !== 'html') throw TroveError.invalid(`statusItem \"render\" must be \"html\" (got ${JSON.stringify(render)})`);\n return { slot, render, order: c.order ?? 0, when: c.when || null, offline: !!c.offline, command: c.command || null };\n },\n },\n // A context value slot the plugin drives at runtime, referenceable from when-clauses\n // in keymaps, commands and other contributions (the equivalent of a VS Code context key).\n register: {\n normalize: (c) => ({ default: c.default ?? null, description: c.description || null }),\n },\n // A keymap JSON file in the package: [{ key, command, when?, args? }, …].\n keymap: {\n normalize: (c) => {\n if (!c.path || typeof c.path !== 'string') throw TroveError.invalid('keymap contribution needs a \"path\" to a JSON file in the package');\n return { path: c.path };\n },\n },\n};\n\nexport const CONTRIBUTION_TYPES = Object.keys(TYPES);\n\n/**\n * Every contribution a manifest declares, normalized and addressed by URI.\n * Throws INVALID on a malformed declaration — a package that lies about what it\n * contributes must not install, because the install review is what the user approved.\n * @returns {Array<{name:string, uri:string, type:string, entry?:string}>}\n */\nexport function declaredContributions(manifest) {\n const map = manifest?.contributes;\n if (map == null) return [];\n if (typeof map !== 'object' || Array.isArray(map)) {\n throw TroveError.invalid('manifest \"contributes\" must be a map of name -> contribution');\n }\n const out = [];\n for (const [name, raw] of Object.entries(map)) {\n if (!raw || typeof raw !== 'object') throw TroveError.invalid(`Contribution \"${name}\" must be an object`);\n if (!isValidName(name)) throw TroveError.invalid(`Invalid contribution name \"${name}\"`);\n const spec = TYPES[raw.type];\n if (!spec) {\n throw TroveError.invalid(`Contribution \"${name}\" has unknown type ${JSON.stringify(raw.type)} (expected one of ${CONTRIBUTION_TYPES.join(', ')})`);\n }\n const entry = raw.entry || manifest.entry;\n if (spec.needsEntry && !entry) throw TroveError.invalid(`Contribution \"${name}\" (${raw.type}) needs an \"entry\" module`);\n out.push({\n name,\n uri: contribUri(manifest, name),\n pluginId: pluginId(manifest),\n type: raw.type,\n ...spec.normalize(raw),\n ...(spec.needsEntry ? { entry } : {}),\n });\n }\n return out;\n}\n\n/** Just the declared contributions of one type. */\nexport function contributionsOfType(manifest, type) {\n return declaredContributions(manifest).filter((c) => c.type === type);\n}\n\n/**\n * The indexers the server will run. Indexing is a property of the DRIVE, not of\n * whoever happens to have a tab open: it must happen once per upload regardless of\n * which client did the uploading, so an indexer contribution is always server-side.\n * (Not to be confused with the `indexer` capability, which lets a plugin push its own\n * contributions for a node it's looking at — that one is a client action.)\n */\nexport function serverIndexers(manifest) {\n return contributionsOfType(manifest, 'indexer').map((i) => ({\n id: i.uri, name: i.name, title: i.title || i.name, match: i.match, entry: i.entry,\n }));\n}\n\n/** Openers a package declares, each pointing at the entry module that renders it. */\nexport function declaredOpeners(manifest) {\n return contributionsOfType(manifest, 'opener');\n}\n\n/**\n * Parse a keymap file's contents: a JSON array of `{ key, command, when?, args? }`\n * (an object with a `bindings` array is also accepted). Entries missing a key or a\n * command are dropped rather than failing the whole map — one bad line shouldn't cost\n * a plugin every other shortcut it ships.\n */\nexport function parseKeymap(text) {\n let doc;\n try {\n doc = JSON.parse(text);\n } catch (err) {\n throw TroveError.invalid('Keymap file is not valid JSON', { cause: err });\n }\n const list = Array.isArray(doc) ? doc : Array.isArray(doc?.bindings) ? doc.bindings : null;\n if (!list) throw TroveError.invalid('Keymap file must be a JSON array of bindings');\n return list\n .filter((b) => b && typeof b.key === 'string' && typeof b.command === 'string')\n .map((b) => ({\n key: b.key, command: b.command,\n when: typeof b.when === 'string' ? b.when : null,\n args: Array.isArray(b.args) ? b.args : undefined,\n }));\n}\n\n/**\n * A file-match selector, coerced into the shape `selectorMatches` actually indexes.\n *\n * It was passed through verbatim, so `\"match\": { \"ext\": \".demo\" }` — a string where an\n * array belongs, which no validation rejected — installed cleanly and then threw\n * `(selector.ext || []).some is not a function` at selection time. Server-side the\n * throw was swallowed, so the plugin backfilled nothing and indexed nothing with no\n * error anywhere; in the browser `openersFor` is unguarded, so ONE bad declaration\n * broke opener selection for every file in the drive.\n */\nfunction normalizeMatch(match) {\n if (!match || typeof match !== 'object' || Array.isArray(match)) return {};\n const list = (v) => (v == null ? undefined : (Array.isArray(v) ? v : [v]).filter((x) => typeof x === 'string'));\n const out = {};\n const ext = list(match.ext);\n const mime = list(match.mime ?? match.contentType);\n if (ext) out.ext = ext;\n if (mime) out.mime = mime;\n // A `match` function can only come from in-process code, never from a manifest.\n if (typeof match.match === 'function') out.match = match.match;\n return out;\n}\n",
17
+ "// ContributionRegistry — ONE map of `uri -> contribution`, where every contribution\n// carries its own `type` and that type's options.\n//\n// There used to be a separate collection per kind (commands, openers, statusItems…),\n// which meant a name could mean different things in different collections and nothing\n// tied a contribution back to a verifiable owner. Now there is a single address space:\n//\n// trove+contrib:acme.com/docs/pdfViewer { type: 'opener', match, entry }\n// trove+contrib:acme.com/docs/status { type: 'statusItem', slot, render }\n// trove+contrib:acme.com/docs/busy { type: 'register', default }\n// trove+contrib:acme.com/docs/keys { type: 'keymap', bindings }\n// trove+contrib:core/workbench/… built-ins, reserved `core` domain\n//\n// So a plugin's opener, status slot, register and command may all be called \"status\"\n// without colliding — with each other, or with another plugin's.\n//\n// Contribution types (see @3sln/trove/core/plugins/contributions.js for the manifest form):\n// command { title, category?, icon?, when?, offline?, palette? }\n// opener { title, match:{ext,mime}, entry, priority?, offline?, dock? }\n// indexer { title, match, entry } (declared here; the SERVER runs it)\n// statusItem { slot:'left'|'right', render:'html', order?, when?, offline? }\n// register { default?, description? } (a context value slot)\n// keymap { bindings:[{key, command, when?, args?}] }\n// view { title, icon?, match?, priority?, render, move? }\n\nimport { cell } from '../runtime.js';\nimport { selectorMatches } from '@3sln/trove/core/util.js';\nimport { parseContribUri, coreUri, CONTRIB_SCHEME } from '@3sln/trove/core/plugins/identity.js';\nimport { CONTRIBUTION_TYPES as PACKAGE_TYPES } from '@3sln/trove/core/plugins/contributions.js';\n\n// Everything a package can declare, plus the workbench's own. `view` — how a list of\n// results is drawn — is the second kind: it is not part of the package format, so core\n// (which is where the manifest is parsed) has no reason to know the word.\nexport const CONTRIBUTION_TYPES = [...PACKAGE_TYPES, 'view'];\n\n/**\n * Address normalization — the one rule: a bare name belongs to the host's reserved\n * `core` domain, anything from a plugin is always fully qualified. So the workbench\n * keeps saying `exec('explorer.delete')` while every contribution still has a real,\n * unambiguous URI (`trove+contrib:core/workbench/explorer.delete`).\n */\nexport function toUri(nameOrUri) {\n return String(nameOrUri).startsWith(CONTRIB_SCHEME) ? nameOrUri : coreUri(nameOrUri);\n}\n\nexport class ContributionRegistry {\n constructor() {\n this.items = new Map(); // uri -> { uri, type, id, name, pluginId, ...options }\n this.cell = cell([]);\n }\n\n #emit() {\n this.cell.setValue([...this.items.values()]);\n }\n\n /**\n * Register one contribution at its URI. Returns a dispose fn.\n * @param {string} nameOrUri a bare core name, or trove+contrib:<domain>/<plugin>/<name>\n * @param {{type: string}} contribution\n */\n register(nameOrUri, contribution) {\n const type = contribution?.type;\n if (!CONTRIBUTION_TYPES.includes(type)) {\n throw new Error(`Unknown contribution type \"${type}\" for ${nameOrUri}`);\n }\n const uri = toUri(nameOrUri);\n const parsed = parseContribUri(uri);\n if (!parsed) throw new Error(`Not a contribution URI: ${uri}`);\n const pluginId = contribution.pluginId ?? (parsed.domain === 'core' ? null : parsed.pluginId);\n const entry = {\n ...contribution, uri, type,\n // `id` is the short name the workbench uses to address it (bare for built-ins,\n // the URI for plugin contributions, which are only ever addressed fully).\n id: parsed.domain === 'core' ? parsed.name : uri,\n name: parsed.name,\n pluginId,\n };\n this.items.set(uri, entry);\n this.#emit();\n return () => this.unregister(uri);\n }\n\n /** Merge new options into an existing contribution (a plugin driving its own slot). */\n update(nameOrUri, patch) {\n const uri = toUri(nameOrUri);\n const cur = this.items.get(uri);\n if (!cur) return false;\n this.items.set(uri, { ...cur, ...patch });\n this.#emit();\n return true;\n }\n\n unregister(nameOrUri) {\n if (this.items.delete(toUri(nameOrUri))) this.#emit();\n }\n get(nameOrUri) {\n return nameOrUri ? this.items.get(toUri(nameOrUri)) || null : null;\n }\n all() {\n return [...this.items.values()];\n }\n ofType(type) {\n return this.all().filter((c) => c.type === type);\n }\n observe() {\n return this.cell;\n }\n // --- typed lookups ---------------------------------------------------------\n\n /** Every opener whose selector matches `node`, best (highest priority) first. */\n openersFor(node) {\n return this.ofType('opener')\n .filter((o) => selectorMatches(o.match, node))\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }\n\n /** Every keybinding from every registered keymap, in registration order. */\n keybindings() {\n return this.ofType('keymap').flatMap((k) =>\n (k.bindings || []).map((b) => ({ ...b, keymap: k.uri, pluginId: k.pluginId })));\n }\n}\n",
18
+ "// A parser/evaluator for \"when\" clauses — the same conditional mini-language VS\n// Code uses to gate commands, keybindings, and menu items on UI state. It reads\n// a context (a flat key→value map from the ContextKeyService) and returns a\n// boolean.\n//\n// Supported: bare keys (truthy), !key, ==, !=, >, <, >=, <=, =~ /re/flags, && , ||,\n// parentheses, string/number/boolean literals. Expressions are parsed once into\n// a predicate function and cached, so evaluation on every keydown is cheap.\n//\n// Every clause is evaluated against the WHOLE context snapshot, which is what the palette,\n// the keybindings and the openers all do. A per-clause subscription layer lived here once —\n// the parser collected the keys an expression named and ContextRegistry derived a cell over\n// exactly those — and nothing ever used it, while `evaluate` over the snapshot did all the\n// work. If per-clause reactivity is ever wanted (a palette that becomes its own region is\n// the case for it), the lexer already sees the key/literal distinction in one pass, so it\n// is ~25 lines to bring back. Shipping both halves and using neither is the one thing that\n// was not defensible.\n//\n// A key is either a core context key (`view.active`, `explorer.hasSelection`) or a\n// contribution URI naming a plugin's `register` — `trove+contrib:acme.com/docs/busy`.\n// Registers are addressed by their full URI precisely because they're contributions\n// like any other: a plugin can only ever gate on a value someone declared and owns.\n\nconst cache = new Map();\n\nexport function compileWhen(expr) {\n if (!expr) return () => true;\n if (cache.has(expr)) return cache.get(expr);\n let fn;\n try {\n fn = new Parser(expr).parseExpression();\n } catch (err) {\n console.warn(`Invalid when clause: \"${expr}\" — ${err.message}`);\n fn = () => false;\n }\n cache.set(expr, fn);\n return fn;\n}\n\nexport function evaluateWhen(expr, ctx) {\n return compileWhen(expr)(ctx || {});\n}\n\n// Note the `trove+contrib:` alternative comes before the regex-literal one: a URI's\n// slashes would otherwise start a /…/ literal and swallow the rest of the expression.\nconst TOKEN = /\\s*(=~|==|!=|>=|<=|&&|\\|\\||[()!<>]|trove\\+contrib:[A-Za-z0-9_./-]+|\\/(?:\\\\.|[^/])*\\/[a-z]*|'(?:\\\\.|[^'])*'|\"(?:\\\\.|[^\"])*\"|[A-Za-z0-9_.:-]+)/y;\n\nclass Parser {\n constructor(src) {\n this.src = src;\n this.tokens = this.#lex(src);\n this.pos = 0;\n }\n #lex(src) {\n const out = [];\n let i = 0;\n TOKEN.lastIndex = 0;\n while (i < src.length) {\n TOKEN.lastIndex = i;\n const m = TOKEN.exec(src);\n if (!m || m.index == null) {\n if (!src.slice(i).trim()) break;\n throw new Error(`Unexpected \"${src.slice(i)}\"`);\n }\n out.push(m[1]);\n i = TOKEN.lastIndex;\n }\n return out;\n }\n #peek() {\n return this.tokens[this.pos];\n }\n #next() {\n return this.tokens[this.pos++];\n }\n #eat(t) {\n if (this.#peek() !== t) throw new Error(`Expected \"${t}\"`);\n this.pos++;\n }\n\n parseExpression() {\n const fn = this.#or();\n if (this.pos !== this.tokens.length) throw new Error(`Trailing \"${this.#peek()}\"`);\n return fn;\n }\n #or() {\n let left = this.#and();\n while (this.#peek() === '||') {\n this.#next();\n const right = this.#and();\n const l = left;\n left = (c) => l(c) || right(c);\n }\n return left;\n }\n #and() {\n let left = this.#unary();\n while (this.#peek() === '&&') {\n this.#next();\n const right = this.#unary();\n const l = left;\n left = (c) => l(c) && right(c);\n }\n return left;\n }\n #unary() {\n if (this.#peek() === '!') {\n this.#next();\n const operand = this.#unary();\n return (c) => !operand(c);\n }\n return this.#comparison();\n }\n #comparison() {\n const left = this.#primary();\n const op = this.#peek();\n if (['==', '!=', '>=', '<=', '>', '<', '=~'].includes(op)) {\n this.#next();\n if (op === '=~') {\n const reTok = this.#next();\n const re = parseRegex(reTok);\n return (c) => re.test(String(left(c) ?? ''));\n }\n const right = this.#primary();\n return (c) => compare(op, left(c), right(c));\n }\n // Bare value → truthiness.\n return (c) => truthy(left(c));\n }\n #primary() {\n const t = this.#next();\n if (t === undefined) throw new Error('Unexpected end');\n if (t === '(') {\n const inner = this.#or();\n this.#eat(')');\n return inner;\n }\n if (t === 'true') return () => true;\n if (t === 'false') return () => false;\n if (/^-?\\d+(\\.\\d+)?$/.test(t)) {\n const n = Number(t);\n return () => n;\n }\n if (t[0] === \"'\" || t[0] === '\"') {\n const s = t.slice(1, -1).replace(/\\\\(.)/g, '$1');\n return () => s;\n }\n // A context key.\n return (c) => c[t];\n }\n}\n\nfunction parseRegex(tok) {\n const m = /^\\/((?:\\\\.|[^/])*)\\/([a-z]*)$/.exec(tok);\n if (!m) throw new Error(`Bad regex ${tok}`);\n return new RegExp(m[1], m[2]);\n}\nfunction truthy(v) {\n return !(v === undefined || v === null || v === false || v === '' || v === 0);\n}\nfunction compare(op, a, b) {\n switch (op) {\n case '==': return a == b; // eslint-disable-line eqeqeq\n case '!=': return a != b; // eslint-disable-line eqeqeq\n case '>': return a > b;\n case '<': return a < b;\n case '>=': return a >= b;\n case '<=': return a <= b;\n }\n return false;\n}\n",
19
+ "// ContextRegistry — the named facts a when-clause is evaluated against.\n//\n// A REGISTRY of cells, not a bag of values, and the difference is the whole design:\n//\n// - Every key is backed by a cell somebody OWNS. The registry never hands the cell out,\n// only its value, so a key can be read by anyone and written by exactly one thing.\n// - A contributor registers while it exists and unregisters when it is disposed, so the\n// set of keys is a fact about what is currently installed rather than a pile that only\n// grows.\n// - Because the backings are cells, a derived layer sits on top for free: a built-in key\n// is a `derive` over the resource it summarises, and so cannot go stale.\n//\n// That last point is why this replaced a plain map with setters. Context keys are DERIVED\n// state — what is selected, what is open, what is focused — and they were maintained by\n// pushing: OverlayService wrote `palette.open` as a side effect of opening the palette,\n// NavigationService wrote three `editor.*` keys, WorkbenchService four more, ViewportService\n// three, and an effect in bl/index.js the explorer's two. Five writers for one derivation,\n// and the bug that shape produces is on the record: selecting a file never flipped\n// `explorer.hasSelection`, so the Delete keybinding silently did nothing, because only\n// NavigateAction had been taught to set it. The fix at the time was to add another writer.\n//\n// Nothing sets a built-in key now. They are derived — see bl/context.js.\n\nimport { cell } from '../runtime.js';\nimport { evaluateWhen } from './whenclause.js';\n\n/** A cell whose value never changes — for facts about the machine rather than the drive. */\nconst constant = (value) => ({ onDirty: () => () => {}, getValue: () => value });\n\nexport class ContextRegistry {\n #cells = new Map(); // key -> a Cell its owner holds\n #offs = new Map(); // key -> unsubscribe\n #snapshot = cell({});\n\n constructor(initial = {}) {\n const fixed = {\n platform: navigatorPlatform(),\n isMac: /mac/i.test(navigatorPlatform()),\n ...initial,\n };\n for (const [key, value] of Object.entries(fixed)) this.register(key, constant(value));\n }\n\n /**\n * Back `key` with a cell. Returns the unregister function.\n *\n * The caller keeps the cell, and that is what makes it the owner: writing means writing\n * something the registry cannot reach. Registering a key twice is refused rather than\n * silently taken over — two owners for one fact is exactly the confusion this shape\n * exists to prevent, so it should be loud.\n *\n * @param {string} key\n * @param {{onDirty: Function, getValue: Function}} source\n * @returns {() => void} unregister\n */\n register(key, source) {\n if (this.#cells.has(key)) {\n throw new Error(`Context key \"${key}\" already has an owner`);\n }\n this.#cells.set(key, source);\n this.#offs.set(key, source.onDirty(() => this.#changed(key)));\n this.#changed(key); // gaining an owner is itself a change\n return () => this.unregister(key);\n }\n\n unregister(key) {\n const off = this.#offs.get(key);\n if (!off) return;\n off();\n this.#offs.delete(key);\n this.#cells.delete(key);\n this.#changed(key); // and so is losing one\n }\n\n #changed() {\n this.#recompute();\n }\n\n /**\n * Own a key outright: the registry makes the cell and hands back the writer.\n *\n * For the facts that genuinely are pushed rather than derived — a plugin setting its own\n * declared register over RPC. The write capability IS the returned `set`, so holding a\n * reference to the registry is not enough to change anything.\n */\n own(key, initial = undefined) {\n const held = cell(initial);\n const dispose = this.register(key, held);\n return { set: (value) => held.setValue(value), dispose };\n }\n\n #recompute() {\n const next = {};\n for (const [key, source] of this.#cells) next[key] = source.getValue();\n this.#snapshot.setValue(next);\n }\n\n /** Every key and its current value. */\n snapshot() {\n return this.#snapshot.getValue();\n }\n get(key) {\n return this.#cells.get(key)?.getValue();\n }\n observe() {\n return this.#snapshot;\n }\n\n /** True if `whenExpr` holds against the current context. */\n evaluate(whenExpr) {\n return evaluateWhen(whenExpr, this.snapshot());\n }\n}\n\nfunction navigatorPlatform() {\n return typeof navigator !== 'undefined' ? navigator.platform || navigator.userAgent || '' : '';\n}\n",
20
+ "// Waiting for a dispatched action to actually finish.\n//\n// `dispatch(action)` answers an event FEED — `DispatchFeed extends EventTarget`, with no\n// `then` — and ngin schedules the body on a `setTimeout`. So `await engine.dispatch(x)`\n// resolves immediately and is *guaranteed* to return before the action has started. It\n// reads as sequencing and is the opposite of it.\n//\n// Six sites did it, one of them eighty lines below the comment in the same class explaining\n// why it cannot work, and at least one was visible: creating a collection navigated to it\n// before the collections list had loaded, so the status bar showed a raw `col_…` id where\n// the name belongs.\n//\n// The completion signal is the terminal event. It RESOLVES with whichever of\n// complete/error/abort fired rather than rejecting, so a failing action does not throw at\n// the call site — the caller decides whether the next step still makes sense.\n//\n// Takes anything with a `dispatch`, so the engine and CommandService (which dispatches\n// through its own seam) share one implementation instead of two spellings of it.\n\n/**\n * @param {{dispatch: (action: object) => {next: (types: string[]) => Promise<object>}}} dispatcher\n * @param {object} action\n * @returns {Promise<{type: 'complete'|'error'|'abort'}>}\n */\nexport const runAction = (dispatcher, action) =>\n dispatcher.dispatch(action).next(['complete', 'error', 'abort']);\n",
21
+ "// CommandService — the one way anything happens in the workbench. Buttons,\n// menu items, keybindings, the palette, and plugins all funnel through\n// `execute(id, ...args)`. A command's metadata (title/category/icon/when/palette)\n// lives in the contribution registry; its handler lives here (core handlers are\n// plain functions, plugin handlers proxy over RPC). Errors surface as a\n// notification instead of a silent console log — failure is always visible.\n\nimport { runAction } from '../dispatch.js';\n\nexport class CommandService {\n /**\n * @param {import('./contributions.js').ContributionRegistry} contributions\n * @param {import('./context.js').ContextKeyService} context\n * @param {import('./notifications.js').NotificationService} notifications\n */\n constructor(contributions, context, notifications) {\n this.contributions = contributions;\n this.context = context;\n this.notifications = notifications;\n this.handlers = new Map(); // id -> (...args) => Action | Action[] | null\n // How a resolved command reaches the engine. Filled in by createApp, because this\n // service is built with the rest of the platform and the engine does not exist yet.\n //\n // It is a seam rather than a smell: keystrokes and plugin RPC arrive from outside the\n // engine and something has to carry them in. Until it is set, a command says so instead\n // of silently doing nothing.\n this.dispatch = () => {\n throw new Error('CommandService has no dispatcher yet — see createApp');\n };\n }\n\n /**\n * Register a command. Accepts either register(id, actions) or a full spec object\n * { id, title, actions, category, icon, when, palette }.\n *\n * `actions` is a PURE FACTORY: `(...args) => Action | Action[] | null`. It is not a\n * handler, and the difference is the point — a handler did the work, which meant every\n * menu item, keybinding and palette entry a person triggered went around the engine. A\n * factory only says what should be dispatched, and `execute` dispatches it.\n */\n register(idOrSpec, actions) {\n const spec = typeof idOrSpec === 'string' ? { id: idOrSpec, actions } : idOrSpec;\n if (spec.actions) this.handlers.set(spec.id, spec.actions);\n const dispose = this.contributions.register(spec.id, {\n type: 'command',\n title: spec.title ?? spec.id,\n category: spec.category,\n icon: spec.icon,\n when: spec.when,\n palette: spec.palette ?? true,\n // Provenance + offline capability, for availability filtering.\n pluginId: spec.pluginId,\n offline: spec.offline,\n });\n return () => {\n this.handlers.delete(spec.id);\n dispose();\n };\n }\n\n isEnabled(id) {\n const cmd = this.contributions.get(id);\n if (cmd?.when && !this.context.evaluate(cmd.when)) return false;\n return this.isAvailable(cmd);\n }\n\n /** A command is available unless it's a plugin command that's currently offline/dead. */\n isAvailable(cmd) {\n if (!cmd) return true;\n return this.availability ? this.availability(cmd) : true;\n }\n\n /**\n * Run a command: resolve what it means, then dispatch it.\n *\n * The gating stays here rather than moving into an action, because it is the same three\n * questions for every command however it was triggered — does it exist, is the plugin\n * behind it answering, does its when-clause hold — and answering them in one place is\n * what keeps a keybinding and a palette entry behaving identically.\n *\n * What is NOT here any more is the work. `actions` returns descriptions and this\n * dispatches them, so the engine sees the command AND everything it causes.\n */\n async execute(id, ...args) {\n const actionsFor = this.handlers.get(id);\n if (!actionsFor) {\n this.notifications.error(`Command not found: ${id}`);\n return;\n }\n const cmd = this.contributions.get(id);\n if (!this.isAvailable(cmd)) {\n // Not \"…isn't available OFFLINE\": that word was printed whenever an availability\n // hook was installed, which platform/index.js makes unconditionally true, and\n // `#availableSpec` answers false for a plugin frame that is inactive or has stopped\n // answering its heartbeat BEFORE it ever consults `this.online`. So a crashed iframe\n // on a perfectly connected machine told the user to check their network.\n this.notifications.warn(`“${cmd?.title || id}” isn’t available right now.`);\n return;\n }\n if (!this.isEnabled(id)) return; // gated by when-clause\n try {\n const actions = actionsFor(...args);\n if (!actions) return;\n // One at a time, each genuinely finished before the next begins — see\n // src/dispatch.js for why a bare `await dispatch(a)` in this loop would start them\n // all at once while looking like it sequenced them.\n //\n // A failing action does not throw here, but it does stop the rest: a command whose\n // first step failed rarely wants its second.\n for (const action of [].concat(actions)) {\n const settled = await runAction(this, action);\n if (settled?.type !== 'complete') break;\n }\n } catch (err) {\n console.error(`Command ${id} failed`, err);\n this.notifications.error(err?.message || `Command failed: ${id}`);\n throw err;\n }\n }\n\n /** Commands eligible for the palette right now (respecting when-clauses). */\n paletteCommands() {\n return this.contributions\n .ofType('command')\n .filter((c) => c.palette !== false && (!c.when || this.context.evaluate(c.when)))\n .sort((a, b) => (a.category || '').localeCompare(b.category || '') || a.title.localeCompare(b.title));\n }\n}\n",
22
+ "// KeybindingService — turns keystrokes into command executions, honouring\n// when-clauses and chords (multi-key sequences like \"ctrl+k ctrl+s\").\n//\n// Bindings come from `keymap` CONTRIBUTIONS: the host contributes one built-in keymap,\n// and a plugin contributes one by declaring `{ type: 'keymap', path: 'keymaps/x.json' }`\n// in its manifest (the host reads and validates that file at install). So core and\n// plugins share exactly one keymap and the shortcuts UI can render all of it.\n// User rebinds live in settings under `keybindings.overrides` (command -> key) and win\n// over whatever a keymap declared. Typing in an input is respected: only bindings with\n// a modifier (or Escape) fire while editing.\n\nexport const OVERRIDES_KEY = 'keybindings.overrides';\n\nexport function normalizeKey(str) {\n // Canonical form: sorted modifiers + key, lowercased. \"Cmd+Shift+P\" → \"meta+shift+p\"\n const parts = str.trim().toLowerCase().split('+').map((p) => p.trim());\n const mods = new Set();\n let key = '';\n for (const p of parts) {\n if (['ctrl', 'control'].includes(p)) mods.add('ctrl');\n else if (['cmd', 'meta', 'super', 'win'].includes(p)) mods.add('meta');\n else if (p === 'alt' || p === 'option') mods.add('alt');\n else if (p === 'shift') mods.add('shift');\n else if (['ctrlcmd', 'mod'].includes(p)) mods.add(isMac() ? 'meta' : 'ctrl');\n else key = p;\n }\n const order = ['ctrl', 'meta', 'alt', 'shift'];\n return [...order.filter((m) => mods.has(m)), key].filter(Boolean).join('+');\n}\n\nexport function eventToKey(e) {\n const mods = [];\n if (e.ctrlKey) mods.push('ctrl');\n if (e.metaKey) mods.push('meta');\n if (e.altKey) mods.push('alt');\n if (e.shiftKey) mods.push('shift');\n let key = e.key.toLowerCase();\n const named = { ' ': 'space', escape: 'escape', enter: 'enter', arrowup: 'up', arrowdown: 'down', arrowleft: 'left', arrowright: 'right' };\n key = named[key] || key;\n return [...mods.filter((m) => key !== m), key].join('+');\n}\n\nexport class KeybindingService {\n /**\n * @param {import('./contributions.js').ContributionRegistry} contributions\n * @param {import('./commands.js').CommandService} commands\n * @param {import('./context.js').ContextKeyService} context\n * @param {import('./settings.js').SettingsService} [settings] source of user rebinds\n */\n constructor(contributions, commands, context, settings = null) {\n this.contributions = contributions;\n this.commands = commands;\n this.context = context;\n this.settings = settings;\n this.chordPrefix = null;\n this.chordTimer = null;\n this._onKeyDown = this.#onKeyDown.bind(this);\n }\n\n install(target = window) {\n target.addEventListener('keydown', this._onKeyDown);\n return () => target.removeEventListener('keydown', this._onKeyDown);\n }\n\n /**\n * User rebinds, keyed by BINDING rather than by command.\n *\n * Keyed by command, one shortcut could not be changed without changing the others:\n * `workbench.view.home` ships bound twice (⌘⇧F and ⌘⇧E), so rebinding either\n * collapsed both onto the new chord — two identical rows in Settings and one shortcut\n * silently gone. A binding's identity is (command, the key it was DECLARED with),\n * which is stable across restarts and unique per row.\n */\n overrides() {\n return this.settings?.get(OVERRIDES_KEY) || {};\n }\n\n /** The override key for one declared binding. */\n static bindingId(binding) {\n return `${binding.command}\\u0000${normalizeKey(binding.defaultKey || binding.key)}`;\n }\n\n /**\n * Rebind one BINDING (null clears it back to what its keymap declared).\n * @param {{command: string, defaultKey?: string, key: string}|string} binding\n * a resolved binding, or a bare command id for the legacy single-binding case.\n */\n rebind(binding, key) {\n if (!this.settings) return;\n const id = typeof binding === 'string'\n ? this.#idForCommand(binding)\n : KeybindingService.bindingId(binding);\n if (!id) return;\n const next = { ...this.overrides() };\n if (key) next[id] = key; else delete next[id];\n this.settings.set(OVERRIDES_KEY, next);\n }\n\n /** Resolve a bare command id to its (single) binding id, for older callers. */\n #idForCommand(command) {\n const b = this.contributions.keybindings().find((x) => x?.command === command && x.key);\n return b ? KeybindingService.bindingId({ ...b, defaultKey: b.key }) : null;\n }\n\n /** Current effective bindings (every keymap's, plus user overrides). */\n resolved() {\n const overrides = this.overrides();\n return this.contributions.keybindings()\n .filter((b) => b?.key && b.command)\n .map((b) => {\n // `defaultKey` is what the keymap declared — the row's stable identity, and what\n // \"reset\" restores to.\n const defaultKey = normalizeKey(b.key);\n const id = KeybindingService.bindingId({ command: b.command, defaultKey });\n return { ...b, defaultKey, bindingId: id, key: normalizeKey(overrides[id] || b.key) };\n });\n }\n\n #matchFor(keyChord) {\n const snapshot = this.context.snapshot();\n // Later registrations win (plugins can override), so scan in reverse.\n const list = this.resolved();\n for (let i = list.length - 1; i >= 0; i--) {\n const b = list[i];\n if (b.key !== keyChord) continue;\n if (b.when && !this.context.evaluate(b.when)) continue;\n return b;\n }\n return null;\n }\n\n #onKeyDown(e) {\n if (e.defaultPrevented) return;\n const chord = eventToKey(e);\n const hasMod = e.ctrlKey || e.metaKey || e.altKey;\n const typing = isTyping(e.target);\n\n // While typing, only modifier chords and Escape are eligible (don't eat text).\n if (typing && !hasMod && e.key !== 'Escape') {\n this.#resetChord();\n return;\n }\n\n const full = this.chordPrefix ? `${this.chordPrefix} ${chord}` : chord;\n const binding = this.#matchFor(full);\n\n if (binding) {\n e.preventDefault();\n this.#resetChord();\n this.commands.execute(binding.command, ...(binding.args || []));\n return;\n }\n\n // Could this be the first key of a chord?\n if (!this.chordPrefix && this.resolved().some((b) => b.key.startsWith(chord + ' '))) {\n e.preventDefault();\n this.chordPrefix = chord;\n this.chordTimer = setTimeout(() => this.#resetChord(), 1500);\n return;\n }\n this.#resetChord();\n }\n\n #resetChord() {\n this.chordPrefix = null;\n if (this.chordTimer) clearTimeout(this.chordTimer);\n this.chordTimer = null;\n }\n\n /** Human-readable label for a command's binding, for menus/tooltips. */\n labelFor(command) {\n const b = this.resolved().find((x) => x.command === command);\n return b ? prettyKey(b.key) : null;\n }\n}\n\nfunction isTyping(el) {\n if (!el) return false;\n const tag = el.tagName;\n return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || el.isContentEditable;\n}\nfunction isMac() {\n return typeof navigator !== 'undefined' && /mac/i.test(navigator.platform || navigator.userAgent || '');\n}\nexport function prettyKey(key) {\n const mac = isMac();\n const map = mac\n ? { ctrl: '⌃', meta: '⌘', alt: '⌥', shift: '⇧', enter: '↵', escape: 'esc', up: '↑', down: '↓', left: '←', right: '→', space: '␣' }\n : { ctrl: 'Ctrl', meta: 'Win', alt: 'Alt', shift: 'Shift', enter: 'Enter', escape: 'Esc', up: '↑', down: '↓', left: '←', right: '→', space: 'Space' };\n return key\n .split(' ')\n .map((chord) =>\n chord\n .split('+')\n .map((p) => map[p] || (p.length === 1 ? p.toUpperCase() : p[0].toUpperCase() + p.slice(1)))\n .join(mac ? '' : '+'),\n )\n .join(' ');\n}\n",
23
+ "// SettingsService — schema-driven, persisted, reactive settings (VS Code's\n// settings model). Core and plugins register typed setting schemas; values are\n// stored in localStorage, namespaced, and merged over defaults. The Settings UI\n// is generated from the schema, so adding a setting never means touching UI code.\n// Plugin keys are namespaced under the plugin id.\n\nimport { cell } from '../runtime.js';\n\nconst STORAGE_KEY = 'trove.settings';\n\nexport class SettingsService {\n constructor() {\n this.schema = new Map(); // key -> { type, default, title, description, enum?, minimum?, maximum?, category, order }\n this.values = read();\n this.cell = cell(this.effective());\n }\n\n /**\n * Register one or more settings. Each: { key, type, default, title,\n * description?, enum?, enumLabels?, minimum?, maximum?, category?, order? }\n */\n register(schemas) {\n for (const s of [].concat(schemas)) this.schema.set(s.key, s);\n this.cell.setValue(this.effective());\n return () => {\n for (const s of [].concat(schemas)) this.schema.delete(s.key);\n this.cell.setValue(this.effective());\n };\n }\n\n get(key) {\n if (key in this.values) return this.values[key];\n return this.schema.get(key)?.default;\n }\n\n set(key, value) {\n const schema = this.schema.get(key);\n if (schema && value === schema.default) delete this.values[key];\n else this.values[key] = value;\n write(this.values);\n this.cell.setValue(this.effective());\n }\n\n reset(key) {\n delete this.values[key];\n write(this.values);\n this.cell.setValue(this.effective());\n }\n\n /** Full resolved values (defaults ⊕ overrides). */\n effective() {\n const out = {};\n for (const [key, s] of this.schema) out[key] = key in this.values ? this.values[key] : s.default;\n // Include stored keys with no (current) schema, so unknown/plugin values survive.\n for (const [key, v] of Object.entries(this.values)) if (!(key in out)) out[key] = v;\n return out;\n }\n\n observe() {\n return this.cell;\n }\n\n /** Schema entries grouped by category, for the Settings UI. */\n grouped() {\n const groups = new Map();\n for (const s of [...this.schema.values()].sort((a, b) => (a.order ?? 0) - (b.order ?? 0))) {\n // `hidden` settings are state the app keeps under the settings key, not choices a\n // person makes — the opener associations, for one, which are edited through the\n // opener chooser and have their own section below. Rendering them anyway put a row\n // reading \"[object Object]\" at the top of Settings.\n if (s.hidden) continue;\n const cat = s.category || 'General';\n if (!groups.has(cat)) groups.set(cat, []);\n groups.get(cat).push({ ...s, value: this.get(s.key) });\n }\n return [...groups.entries()].map(([category, items]) => ({ category, items }));\n }\n\n scopedFor(pluginId) {\n const prefix = `${pluginId}.`;\n return {\n register: (schemas) =>\n this.register([].concat(schemas).map((s) => ({ ...s, key: prefix + s.key, category: s.category || pluginId }))),\n get: (key) => this.get(prefix + key),\n set: (key, value) => this.set(prefix + key, value),\n };\n }\n}\n\nfunction read() {\n try {\n return JSON.parse(localStorage.getItem(STORAGE_KEY)) || {};\n } catch {\n return {};\n }\n}\nfunction write(values) {\n try {\n localStorage.setItem(STORAGE_KEY, JSON.stringify(values));\n } catch { /* quota / private mode */ }\n}\n",
24
+ "// NotificationService — transient toasts + a small log. Everything user-facing\n// that fails routes here so problems are never silent. Reactive: the status/UI\n// watches `observe()`.\n\nimport { cell } from '../runtime.js';\n\nlet seq = 0;\n\nexport class NotificationService {\n constructor() {\n this.items = [];\n this.cell = cell([]);\n }\n observe() {\n return this.cell;\n }\n #push(level, message, opts = {}) {\n const item = {\n id: ++seq, level, message,\n actions: opts.actions || null,\n createdAt: Date.now(),\n sticky: opts.sticky || level === 'error',\n };\n this.items = [...this.items, item];\n this.cell.setValue(this.items);\n if (!item.sticky) setTimeout(() => this.dismiss(item.id), opts.timeout ?? 4000);\n return item.id;\n }\n info(m, o) {\n return this.#push('info', m, o);\n }\n success(m, o) {\n return this.#push('success', m, o);\n }\n warn(m, o) {\n return this.#push('warn', m, o);\n }\n error(m, o) {\n return this.#push('error', m, o);\n }\n /** Update a notification in place (e.g. a progress message). */\n update(id, patch) {\n this.items = this.items.map((i) => (i.id === id ? { ...i, ...patch } : i));\n this.cell.setValue(this.items);\n }\n dismiss(id) {\n this.items = this.items.filter((i) => i.id !== id);\n this.cell.setValue(this.items);\n }\n}\n",
25
+ "// Retry with exponential backoff + full jitter. Only retries errors classified\n// retryable (see errors.js), respects an AbortSignal between attempts, and\n// surfaces the last error untouched when it gives up — so the caller still sees\n// a clean TroveError, not a generic \"retries exhausted\".\n\nimport { isRetryable, wrapError, TroveError } from './errors.js';\n\nconst DEFAULTS = {\n retries: 4, // attempts after the first = 5 total tries\n minDelayMs: 250,\n maxDelayMs: 8000,\n factor: 2,\n jitter: true,\n};\n\nfunction sleep(ms, signal) {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) return reject(TroveError.aborted());\n // `{ once: true }` removes the listener when it FIRES — not when the timer wins,\n // which is the normal case. One long-lived signal driving a few retried operations\n // therefore accumulated a listener per attempt and released none of them.\n const done = (fn) => (arg) => {\n clearTimeout(t);\n signal?.removeEventListener('abort', onAbort);\n fn(arg);\n };\n const t = setTimeout(() => done(resolve)(), ms);\n const onAbort = () => done(reject)(TroveError.aborted());\n signal?.addEventListener('abort', onAbort, { once: true });\n });\n}\n\n/**\n * @template T\n * @param {(attempt: number) => Promise<T>} fn\n * @param {object} [opts]\n * @param {number} [opts.retries]\n * @param {AbortSignal} [opts.signal]\n * @param {(info: {attempt: number, delayMs: number, error: TroveError}) => void} [opts.onRetry]\n * @param {(err: unknown) => boolean} [opts.shouldRetry] override classification\n * @returns {Promise<T>}\n */\nexport async function withRetry(fn, opts = {}) {\n const cfg = { ...DEFAULTS, ...opts };\n const shouldRetry = cfg.shouldRetry ?? isRetryable;\n let attempt = 0;\n\n for (;;) {\n if (cfg.signal?.aborted) throw TroveError.aborted();\n try {\n return await fn(attempt);\n } catch (raw) {\n const err = wrapError(raw);\n const canRetry = attempt < cfg.retries && shouldRetry(err) && err.code !== 'aborted';\n if (!canRetry) throw err;\n\n const base = Math.min(cfg.maxDelayMs, cfg.minDelayMs * cfg.factor ** attempt);\n const delayMs = cfg.jitter ? Math.random() * base : base;\n cfg.onRetry?.({ attempt: attempt + 1, delayMs, error: err });\n await sleep(delayMs, cfg.signal);\n attempt++;\n }\n }\n}\n\n/** Reject after `ms`, unless `promise` settles first. Cleans up its timer. */\nexport function withTimeout(promise, ms, message = 'Operation timed out') {\n if (!ms || ms <= 0) return promise;\n let t;\n const timeout = new Promise((_, reject) => {\n t = setTimeout(() => reject(TroveError.timeout(message)), ms);\n });\n return Promise.race([promise, timeout]).finally(() => clearTimeout(t));\n}\n",
26
+ "// TroveApiClient — the browser's view of the server API. Thin JSON calls with\n// transient-error retry, plus the upload orchestrator, which is where the \"handle\n// large uploads well\" requirement lives:\n//\n// • Chooses nothing itself — it follows the plan the server returns (single /\n// presigned-multipart / direct-multipart), so an S3 deployment uploads parts\n// straight to S3 and a filesystem deployment streams through the server, with\n// the same client code.\n// • Uploads parts concurrently (bounded), each with its own retry, and reports\n// aggregate byte progress for a live progress bar.\n// • Resumable: on retry it asks the server which parts already landed and skips\n// them, so a dropped connection doesn't restart a 4 GB upload.\n//\n// Uploads use XMLHttpRequest because fetch can't report upload progress.\n\nimport { withRetry } from '@3sln/trove/core/retry.js';\nimport { TroveError } from '@3sln/trove/core/errors.js';\n\nexport class TroveApiClient {\n /**\n * @param {{baseUrl?: string, fetch?: Function, token?: string|(() => string|null)}} [opts]\n * `token` is a bearer JWT, or a function returning one. Optional because the common\n * deployment puts an authenticating proxy in front (Cloudflare Access sets its own\n * header and the browser sends nothing) — but a deployment where the user HOLDS a\n * token has no way to present it otherwise, which is why this exists.\n */\n constructor({ baseUrl = '', fetch: f = globalThis.fetch.bind(globalThis), token = null } = {}) {\n this.baseUrl = baseUrl.replace(/\\/$/, '');\n this._fetch = f;\n this._token = token;\n }\n\n /** The bearer token to present, if any. Read per request so a refresh takes effect. */\n token() {\n const t = typeof this._token === 'function' ? this._token() : this._token;\n return t || null;\n }\n /** Auth headers for a request, or nothing at all when there is no token to send. */\n authHeaders() {\n const t = this.token();\n return t ? { authorization: `Bearer ${t}` } : {};\n }\n\n async request(method, path, { body, query, signal, raw } = {}) {\n const url = this.baseUrl + path + (query ? '?' + new URLSearchParams(query) : '');\n return withRetry(\n async () => {\n const res = await this._fetch(url, {\n method,\n headers: { ...this.authHeaders(), ...(body ? { 'content-type': 'application/json' } : {}) },\n body: body ? JSON.stringify(body) : undefined,\n signal,\n });\n if (res.status === 429 || res.status >= 500) {\n // Read the structured error to decide retry: an explicitly non-retryable\n // failure (e.g. a per-file size limit) must fail fast with its real message,\n // not be retried 3× into a generic \"Server 429\". `raw` requests can't consume\n // the body here, so they stay status-based.\n if (!raw) {\n let e;\n try { const t = await res.text(); e = (t ? JSON.parse(t) : null)?.error; } catch { /* non-JSON body */ }\n if (e && e.retryable === false) throw new TroveError(e.code, e.message, { retryable: false, details: e.details });\n throw TroveError.transient(e?.message || `Server ${res.status}`);\n }\n throw TroveError.transient(`Server ${res.status}`);\n }\n if (raw) return res;\n const text = await res.text();\n const json = text ? JSON.parse(text) : null;\n if (!res.ok) {\n const e = json?.error || { code: 'internal', message: `Request failed (${res.status})` };\n throw new TroveError(e.code, e.message, { retryable: e.retryable, details: e.details });\n }\n return json;\n },\n { signal, retries: 3 },\n );\n }\n\n // --- browse / mutate -------------------------------------------------------\n\n capabilities() {\n return this.request('GET', '/api/capabilities');\n }\n /** Single-shot reachability probe (short timeout, no retries) — is the server\n * actually reachable, vs. `navigator.onLine` merely reporting an up interface? */\n async reachable(timeoutMs = 4000) {\n try {\n const signal = AbortSignal.timeout ? AbortSignal.timeout(timeoutMs) : undefined;\n const res = await this._fetch(this.baseUrl + '/api/capabilities', { method: 'GET', signal, headers: this.authHeaders() });\n return res.ok;\n } catch { return false; }\n }\n // Collection-scoped calls name their collection in the PATH. There is no default and\n // no `?collection=`: the server refuses a request that does not say which collection it\n // means, so a caller that forgets gets an error here rather than silently reaching one.\n /** Every item in a collection. */\n list(collection, opts = {}) {\n return this.request('GET', `${this.#scope(collection)}/items`, { query: opts });\n }\n /** Resolve an item by id, by `trove:` URI, or by name within a collection. */\n stat(ref, { collection, ...opts } = {}) {\n const key = String(ref).startsWith('trove:') ? 'uri' : 'id';\n // A name is only unique inside a collection, so resolving one needs the scope. An id\n // or a trove: URI names itself, and the flat resolve is fine for those.\n const base = collection ? `${this.#scope(collection)}/items/resolve` : '/api/items/resolve';\n return this.request('GET', base, { query: { [key]: ref, ...opts } });\n }\n #scope(collection) {\n if (!collection) throw new Error('This call is scoped to a collection — pass one');\n return `/api/collections/${encodeURIComponent(collection)}`;\n }\n /** What links to this item. */\n backlinks(id, opts = {}) {\n return this.request('GET', '/api/items/backlinks', { query: { id, ...opts } });\n }\n rename(id, newName) {\n return this.request('POST', '/api/items/rename', { body: { id, newName } });\n }\n remove(id) {\n return this.request('POST', '/api/items/delete', { body: { id } });\n }\n /** What's been deleted but not yet destroyed. */\n trash(collection) {\n return this.request('GET', `${this.#scope(collection)}/trash`);\n }\n restore(id) {\n return this.request('POST', '/api/trash/restore', { body: { id } });\n }\n /** Destroy for real — one item, or everything in a collection's trash. */\n purgeTrash({ id, collection } = {}) {\n // One item names itself; emptying a whole collection has to name the collection, and\n // says so in the URL — \"everything in here\" is the request that must never be able\n // to mean somewhere you did not point at.\n return id\n ? this.request('POST', '/api/trash/purge', { body: { id } })\n : this.request('POST', `${this.#scope(collection)}/trash/purge`);\n }\n search(q, { collection, ...opts } = {}) {\n const base = collection ? `${this.#scope(collection)}/search` : '/api/search';\n return this.request('GET', base, { query: { q, ...opts } });\n }\n // Unified query: server transforms the raw string (parse/LLM) → runs it → returns\n // { query, results, resolved }. `resolved` is what was actually searched.\n query(q, { collection, ...opts } = {}) {\n const base = collection ? `${this.#scope(collection)}/query` : '/api/query';\n return this.request('POST', base, { body: { q, ...opts } });\n }\n // Drive-wide tag/property filter (launcher #tag / #key:op:value).\n tagSearch(filters, q, { collection, ...opts } = {}) {\n const base = collection ? `${this.#scope(collection)}/tags/search` : '/api/tags/search';\n return this.request('POST', base, { body: { filters, q, ...opts } });\n }\n indexers() {\n return this.request('GET', '/api/indexers');\n }\n\n // --- background work + standing problems -----------------------------------\n // Tasks are in-flight and ephemeral; issues are what a failure left behind and are\n // durable. Ids can contain anything (an issue id embeds a node id), so every one of\n // these encodes before it becomes a path segment.\n tasks() {\n return this.request('GET', '/api/tasks');\n }\n cancelTask(id) {\n return this.request('POST', `/api/tasks/${encodeURIComponent(id)}/cancel`);\n }\n dismissTask(id) {\n return this.request('DELETE', `/api/tasks/${encodeURIComponent(id)}`);\n }\n issues() {\n return this.request('GET', '/api/issues');\n }\n retryIssue(id) {\n return this.request('POST', `/api/issues/${encodeURIComponent(id)}/retry`);\n }\n dismissIssue(id) {\n return this.request('DELETE', `/api/issues/${encodeURIComponent(id)}`);\n }\n reindex() {\n return this.request('POST', '/api/reindex');\n }\n /** Reconcile a collection against its object store (changes made outside Trove). */\n scanCollection(id) {\n return this.request('POST', `/api/collections/${encodeURIComponent(id)}/scan`);\n }\n\n /**\n * Check every collection's backing store for problems a browser would hit — chiefly a\n * missing CORS policy, which leaves the file list and search working while every file\n * fails to open.\n *\n * Worth asking from the browser rather than only on a timer: the server checks against\n * the origin of THIS request, and a bucket policy may name exactly one origin.\n */\n checkStorage() {\n return this.request('POST', '/api/diagnostics/storage');\n }\n\n // --- server plugin installs (account-scoped, synced across devices) ---------\n /** Upload a package zip for account install; returns the server install record. */\n async installPlugin(bytes, grants) {\n const q = grants && grants.length ? '?grants=' + encodeURIComponent(grants.join(',')) : '';\n const res = await this._fetch(this.baseUrl + '/api/plugins/install' + q, { method: 'POST', body: bytes, headers: this.authHeaders() });\n const json = await res.json().catch(() => null);\n if (!res.ok) {\n const e = json?.error || { code: 'internal', message: `Install failed (${res.status})` };\n throw new TroveError(e.code, e.message, { details: e.details });\n }\n return json.install;\n }\n installedPlugins() {\n return this.request('GET', '/api/plugins/installed');\n }\n async pluginPackage(id) {\n const res = await this._fetch(`${this.baseUrl}/api/plugins/${encodeURIComponent(id)}/package`, { headers: this.authHeaders() });\n if (!res.ok) throw new TroveError('not_found', `Package for \"${id}\" not found`);\n return new Uint8Array(await res.arrayBuffer());\n }\n uninstallPluginServer(id) {\n return this.request('DELETE', `/api/plugins/${encodeURIComponent(id)}/install`);\n }\n // contribution: { semanticTexts?, tags?, metadata? } (legacy { documents, facet } ok).\n pushIndex(indexerId, nodeId, contribution) {\n return this.request('POST', `/api/index/${encodeURIComponent(indexerId)}`, { body: { nodeId, ...contribution } });\n }\n\n // --- identity --------------------------------------------------------------\n me() {\n return this.request('GET', '/api/me');\n }\n\n // --- collections -----------------------------------------------------------\n collections() {\n return this.request('GET', '/api/collections');\n }\n createCollection(body) {\n return this.request('POST', '/api/collections', { body });\n }\n\n /** Change a collection's settings — including turning encryption on. */\n updateCollection(id, patch) {\n return this.request('PATCH', `/api/collections/${encodeURIComponent(id)}`, { body: patch });\n }\n\n // --- key rotation ---------------------------------------------------------\n //\n // What a rotation would cost before anyone starts one: on a metered store it is a real\n // bill, and the button should not be the first place that becomes apparent.\n rotationEstimate(id) {\n return this.request('GET', `/api/collections/${encodeURIComponent(id)}/rotate/estimate`);\n }\n /** Who has access to a collection. Admin-only, server-side. */\n collectionGrants(id) {\n return this.request('GET', `/api/collections/${encodeURIComponent(id)}/grants`);\n }\n\n /**\n * Add, change or remove one grant.\n *\n * Upsert by (type, subject); an empty capability list REMOVES the grant, which is the\n * shape `setGrant` already had — so revoking is the same call as granting, with nothing.\n */\n setCollectionGrant(id, grant) {\n return this.request('POST', `/api/collections/${encodeURIComponent(id)}/grants`, { body: grant });\n }\n\n rotationState(id) {\n return this.request('GET', `/api/collections/${encodeURIComponent(id)}/rotate`);\n }\n beginRotation(id) {\n return this.request('POST', `/api/collections/${encodeURIComponent(id)}/rotate`);\n }\n cancelRotation(id) {\n return this.request('DELETE', `/api/collections/${encodeURIComponent(id)}/rotate`);\n }\n\n // --- conversations, tags, sidecar ------------------------------------------\n sidecar(id) {\n return this.request('GET', `/api/items/${encodeURIComponent(id)}/sidecar`);\n }\n addComment(id, { body, parentId, mentions } = {}) {\n return this.request('POST', `/api/items/${encodeURIComponent(id)}/comments`, { body: { body, parentId, mentions } });\n }\n editComment(id, cid, body) {\n return this.request('POST', `/api/items/${encodeURIComponent(id)}/comments/${encodeURIComponent(cid)}/edit`, { body: { body } });\n }\n deleteComment(id, cid) {\n return this.request('DELETE', `/api/items/${encodeURIComponent(id)}/comments/${encodeURIComponent(cid)}`);\n }\n reactComment(id, cid, emoji, on) {\n return this.request('POST', `/api/items/${encodeURIComponent(id)}/comments/${encodeURIComponent(cid)}/react`, { body: { emoji, on } });\n }\n setTag(id, name, value) {\n return this.request('POST', `/api/items/${encodeURIComponent(id)}/tags`, { body: { name, value } });\n }\n removeTag(id, name) {\n return this.request('DELETE', `/api/items/${encodeURIComponent(id)}/tags/${encodeURIComponent(name)}`);\n }\n\n // --- notifications & push --------------------------------------------------\n notifications() {\n return this.request('GET', '/api/notifications');\n }\n markNotificationsRead(ids) {\n return this.request('POST', '/api/notifications/read', { body: { ids } });\n }\n vapidKey() {\n return this.request('GET', '/api/push/vapid');\n }\n\n // --- API keys (admin) -------------------------------------------------------\n // Capability-only credentials; see core/apiKeys.js. `mintApiKey` is the one call in\n // this client whose response contains a secret, and it is the only chance to see it.\n apiKeys() {\n return this.request('GET', '/api/keys');\n }\n mintApiKey({ name, scopes, expiresAt = null }) {\n return this.request('POST', '/api/keys', { body: { name, scopes, expiresAt } });\n }\n revokeApiKey(id) {\n return this.request('DELETE', `/api/keys/${encodeURIComponent(id)}`);\n }\n subscribePush(subscription) {\n return this.request('POST', '/api/push/subscribe', { body: { subscription } });\n }\n\n /** URL for GET-ing bytes (used by <img>/<audio>/<video> and downloads). */\n downloadUrl(id, { attachment } = {}) {\n return `${this.baseUrl}/api/items/download?id=${encodeURIComponent(id)}${attachment ? '&disposition=attachment' : ''}`;\n }\n\n /**\n * Mint URLs that carry their own authorization, for the things that cannot send a\n * header — an <img src>, a <video src>, cache.add(). Batched: a gallery asks for what\n * it is about to draw, in one request. See platform/mediaUrls.js.\n */\n mintUrls(ids, op = 'media') {\n return this.request('POST', '/api/items/urls', { body: { ids, op } });\n }\n\n /**\n * Start a download in the browser.\n *\n * With no bearer token this is a plain navigation to the download URL — the browser\n * streams it, handles Range, and never buffers a 4 GB file in a tab. When a token IS\n * in play that isn't possible: an `<a href>` cannot carry an Authorization header, so\n * the navigation would arrive unauthenticated and 401. Rather than move the token into\n * the query string (where it lands in logs, history, and referrers), fetch the bytes\n * with the header and hand the browser a blob.\n *\n * The cost is honest and worth stating: the blob path holds the file in memory. It is\n * the price of bearer auth without a token-bearing URL, and it does not apply to the\n * common proxy-authenticated deployment, which takes the streaming path.\n */\n async download(id, name, { attachment = true } = {}) {\n const url = this.downloadUrl(id, { attachment });\n if (!this.token()) return { url, streamed: true };\n const res = await this._fetch(url, { headers: this.authHeaders() });\n if (!res.ok) throw new TroveError('internal', `Download failed (${res.status})`);\n return { url: URL.createObjectURL(await res.blob()), streamed: false, revoke: true };\n }\n\n /** Read a whole file as text/bytes (small files, indexers). */\n async readBytes(id, { signal } = {}) {\n const res = await this._fetch(this.downloadUrl(id), { signal, headers: this.authHeaders() });\n if (!res.ok) throw new TroveError('internal', `Download failed (${res.status})`);\n return new Uint8Array(await res.arrayBuffer());\n }\n async readText(id, opts) {\n return new TextDecoder().decode(await this.readBytes(id, opts));\n }\n\n /**\n * Read `[start, end)` of a file.\n *\n * HALF-OPEN, like every other range in JavaScript — `slice`, `subarray`, `TypedArray`.\n * HTTP's is inclusive, and the conversion happens at this one boundary rather than in\n * every caller, because an off-by-one that only shows up as a missing final byte of a\n * container header is the kind of bug that reads as a corrupt file.\n *\n * `etag` comes back with the bytes, and callers are expected to care: a file overwritten\n * in place keeps its id, so anything cached off these bytes — a chunk store, a parsed\n * atom layout — has to notice that the head of the old file and the tail of the new one\n * are not the same file. `total` is parsed from `content-range`, which is the only place\n * a ranged read learns how big the whole thing is.\n *\n * @returns {Promise<{bytes: Uint8Array, etag: string|null, total: number|null}>}\n */\n async readRange(id, { start = 0, end, signal } = {}) {\n const range = end == null ? `bytes=${start}-` : `bytes=${start}-${end - 1}`;\n const res = await this._fetch(this.downloadUrl(id), {\n signal,\n headers: { ...this.authHeaders(), range },\n });\n // A zero-length file has no satisfiable range, and asking for one is not an error the\n // caller can do anything with — it is an empty file, which is a legitimate answer.\n if (res.status === 416) return { bytes: new Uint8Array(0), etag: res.headers.get('etag'), total: 0 };\n if (!res.ok && res.status !== 206) throw new TroveError('internal', `Read failed (${res.status})`);\n const bytes = new Uint8Array(await res.arrayBuffer());\n const total = Number(/\\/(\\d+)$/.exec(res.headers.get('content-range') || '')?.[1])\n || (res.status === 200 ? bytes.length : null);\n return { bytes, etag: res.headers.get('etag'), total };\n }\n\n /**\n * Read at most `maxBytes` of a file as text.\n *\n * A viewer must never pull a whole file just to show the top of it. A drive holds\n * logs, exports and dumps that are hundreds of megabytes; `readText` on one of those\n * buffers the entire thing in the tab before a single character is drawn, and the\n * browser is gone before the user learns anything. A Range request costs one extra\n * byte over the wire and bounds the damage at the transfer rather than the render.\n *\n * The cut is at a BYTE boundary, which can land mid-character in UTF-8, so the\n * decoder is told to tolerate it — a trailing replacement glyph beats throwing away\n * the read. The last partial line is dropped for the same reason.\n *\n * @returns {Promise<{text: string, truncated: boolean, total: number|null}>}\n */\n async readTextCapped(id, { maxBytes = 512 * 1024, size = null, signal } = {}) {\n // Skip the Range when we already know the file fits. An empty file has no\n // satisfiable range, so asking for one turned \"open an empty note\" into an error\n // page; a 416 from any backend would do the same.\n const ranged = size == null || size > maxBytes;\n const res = await this._fetch(this.downloadUrl(id), {\n signal,\n headers: { ...this.authHeaders(), ...(ranged ? { range: `bytes=0-${maxBytes - 1}` } : {}) },\n });\n if (res.status === 416) return { text: '', truncated: false, total: 0 };\n if (!res.ok && res.status !== 206) throw new TroveError('internal', `Download failed (${res.status})`);\n const bytes = new Uint8Array(await res.arrayBuffer());\n // `Content-Range: bytes 0-N/TOTAL` is how we learn the real size; a server that\n // ignored the Range header just sent everything, which is also fine.\n const total = Number(/\\/(\\d+)$/.exec(res.headers.get('content-range') || '')?.[1]) || null;\n const truncated = bytes.length >= maxBytes && (total == null || total > bytes.length);\n let text = new TextDecoder('utf-8', { fatal: false }).decode(bytes);\n if (truncated) {\n const lastBreak = text.lastIndexOf('\\n');\n if (lastBreak > 0) text = text.slice(0, lastBreak);\n }\n return { text, truncated, total };\n }\n\n /**\n * Upload a File/Blob with progress + resume.\n * @param {Blob & {name?:string}} file\n * @param {object} opts\n * @param {string} opts.parentId\n * @param {string} [opts.name]\n * @param {(p:{loaded:number,total:number,ratio:number}) => void} [opts.onProgress]\n * @param {AbortSignal} [opts.signal]\n * @param {number} [opts.concurrency]\n * @returns {Promise<object>} the created node\n */\n async upload(file, opts) {\n const name = opts.name || file.name || 'untitled';\n const size = file.size;\n // Every step of an upload is retried, not just the parts.\n //\n // Multipart parts already had this; nothing else did — so a transient failure on\n // `create`, on the single presigned PUT, or on `complete` killed the whole upload on\n // the first stumble, while the same failure mid-multipart was shrugged off. The\n // single-PUT path is the one most uploads take (anything under the multipart floor),\n // which is to say the retries were on the rarer half.\n //\n // `withRetry` decides what is worth retrying — see errors.js. Notably a lost upload\n // session is NOT retryable, and must not be: a session that has genuinely expired or\n // been aborted will never come back, and hammering it just delays the error. That\n // case is what the manual retry is for.\n const step = (fn) => withRetry(fn, {\n signal: opts.signal,\n retries: 4,\n onRetry: ({ attempt, delayMs, error }) => opts.onRetry?.({ attempt, delayMs, message: error.message }),\n });\n\n const plan = await step(() => this.request('POST', `${this.#scope(opts.collection)}/uploads`, {\n body: { name, size, contentType: file.type || undefined },\n signal: opts.signal,\n }));\n // Hand the caller the server upload id so a cancel/failure can abort the session\n // (otherwise a multipart upload leaks server + storage state).\n if (plan.uploadId) opts.onStart?.(plan.uploadId);\n\n // Progress is measured against what TRAVELS, which is now the file itself even for an\n // encrypted collection: the drive seals it on the way to the store, so nothing larger\n // than the file ever leaves this tab.\n const progress = new ProgressAggregator(size, opts.onProgress);\n const t = plan.transfer || {};\n const completeUrl = plan.endpoints?.complete || `/api/uploads/${plan.uploadId}/complete`;\n\n if (plan.strategy === 'single') {\n // One presigned PUT straight to storage (bytes never touch our server). The plan\n // only ever chooses this for an UNENCRYPTED collection now — a presigned PUT of a\n // file this client has not sealed would put plaintext in the bucket.\n const body = file;\n await step(() => xhrPut(t.url || plan.url, body, { headers: t.requiredHeaders, signal: opts.signal, onProgress: (l) => progress.set('single', l) }));\n const done = await step(() => this.request('POST', completeUrl, { body: {}, signal: opts.signal }));\n return done.node;\n }\n if (plan.strategy === 'direct-single') {\n const body = file;\n await step(() => xhrPut(this.baseUrl + this.#partUrl(plan, 1), body, {\n // Our own server, so it needs our bearer token; `t.authHeaders` lets the plan\n // add its own and wins on a clash.\n headers: { ...this.authHeaders(), ...t.authHeaders },\n signal: opts.signal, onProgress: (l) => progress.set(1, l),\n }));\n const done = await step(() => this.request('POST', completeUrl, { body: {}, signal: opts.signal }));\n return done.node;\n }\n\n // Multipart (presign or direct).\n const partSize = plan.partSize;\n const partCount = plan.partCount ?? Math.ceil(size / partSize);\n // Resume: which parts already exist?\n let received = new Set();\n try {\n const statusUrl = plan.endpoints?.status || `/api/uploads/${plan.uploadId}/status`;\n const status = await this.request('GET', statusUrl, { signal: opts.signal });\n received = new Set(status.received || []);\n } catch { /* fresh upload */ }\n\n const parts = [];\n const jobs = [];\n for (let n = 1; n <= partCount; n++) {\n const start = (n - 1) * partSize;\n const blob = file.slice(start, Math.min(start + partSize, size));\n jobs.push({ n, blob });\n }\n\n const results = new Array(partCount);\n const concurrency = Math.min(opts.concurrency ?? 4, jobs.length);\n let cursor = 0;\n // When one part fails for good, abort the sibling workers' in-flight parts instead\n // of letting them keep PUTting bytes whose result we're about to discard. The inner\n // controller is chained to the caller's signal so a user cancel still propagates.\n const inner = new AbortController();\n const onOuterAbort = () => inner.abort();\n if (opts.signal) {\n if (opts.signal.aborted) inner.abort();\n else opts.signal.addEventListener('abort', onOuterAbort, { once: true });\n }\n const worker = async () => {\n while (cursor < jobs.length) {\n if (inner.signal.aborted) return;\n const { n, blob } = jobs[cursor++];\n if (received.has(n)) {\n progress.set(n, blob.size);\n continue;\n }\n const etag = await withRetry(\n () => this.#uploadPart(plan, n, blob, {\n signal: inner.signal, onProgress: (l) => progress.set(n, l),\n }),\n {\n signal: inner.signal,\n retries: 4,\n onRetry: ({ attempt, delayMs, error }) => opts.onRetry?.({ attempt, delayMs, part: n, message: error.message }),\n },\n );\n results[n - 1] = { partNumber: n, etag };\n }\n };\n try {\n await Promise.all(Array.from({ length: concurrency }, worker));\n } catch (err) {\n inner.abort(); // stop the other workers before surfacing the failure\n throw err;\n } finally {\n opts.signal?.removeEventListener('abort', onOuterAbort);\n }\n\n const reportedParts = results.filter(Boolean);\n const done = await step(() => this.request('POST', completeUrl, {\n body: { parts: reportedParts }, signal: opts.signal,\n }));\n return done.node;\n }\n\n // Expand an endpoint/transfer URL template's {partNumber} placeholder.\n #partUrl(plan, n) {\n const tmpl = plan.transfer?.partUrl || `/api/uploads/${plan.uploadId}/parts/{partNumber}`;\n return tmpl.replace('{partNumber}', String(n));\n }\n\n\n async #uploadPart(plan, n, blob, { signal, onProgress }) {\n const t = plan.transfer || {};\n if (plan.strategy === 'presign') {\n const part = (t.parts || plan.parts)?.find((p) => p.partNumber === n);\n let url = part?.url;\n if (!url) {\n const signTmpl = plan.endpoints?.sign || `/api/uploads/${plan.uploadId}/parts/{partNumber}/sign`;\n const r = await this.request('POST', signTmpl.replace('{partNumber}', String(n)), { signal });\n url = r.url;\n }\n const res = await xhrPut(url, blob, { signal, onProgress, wantEtag: true });\n const etag = res.etag;\n const reportTmpl = plan.endpoints?.report || `/api/uploads/${plan.uploadId}/parts/{partNumber}/report`;\n await this.request('POST', reportTmpl.replace('{partNumber}', String(n)), { body: { etag }, signal });\n return etag;\n }\n // proxied: server records the etag; response body has it.\n const res = await xhrPut(this.baseUrl + this.#partUrl(plan, n), blob, {\n headers: { ...this.authHeaders(), ...t.authHeaders },\n signal, onProgress, wantJson: true,\n });\n return res.json?.etag;\n }\n\n async abortUpload(uploadId) {\n return this.request('DELETE', `/api/uploads/${uploadId}`);\n }\n}\n\nclass ProgressAggregator {\n constructor(total, cb) {\n this.total = total;\n this.cb = cb;\n this.parts = new Map();\n }\n set(key, loaded) {\n // Monotonic per part: a retried part restarts its XHR progress at 0, which would\n // otherwise pull the aggregate bar backwards. Never let a part's reported bytes drop.\n const prev = this.parts.get(key) || 0;\n if (loaded < prev) return;\n this.parts.set(key, loaded);\n if (!this.cb) return;\n let sum = 0;\n for (const v of this.parts.values()) sum += v;\n const loadedTotal = Math.min(sum, this.total);\n this.cb({ loaded: loadedTotal, total: this.total, ratio: this.total ? loadedTotal / this.total : 1 });\n }\n}\n\n// XHR PUT with upload progress + abort. Returns { status, etag?, json? }.\nfunction xhrPut(url, body, { signal, onProgress, wantEtag, wantJson, headers } = {}) {\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.open('PUT', url, true);\n for (const [k, v] of Object.entries(headers || {})) { try { xhr.setRequestHeader(k, v); } catch { /* forbidden header */ } }\n if (signal) {\n if (signal.aborted) {\n xhr.abort();\n return reject(TroveError.aborted());\n }\n signal.addEventListener('abort', () => xhr.abort(), { once: true });\n }\n xhr.upload.onprogress = (e) => onProgress?.(e.loaded);\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n const out = { status: xhr.status };\n if (wantEtag) out.etag = xhr.getResponseHeader('ETag') || xhr.getResponseHeader('etag');\n if (wantJson) {\n try {\n out.json = JSON.parse(xhr.responseText);\n } catch { /* ignore */ }\n }\n resolve(out);\n } else if (xhr.status === 429 || xhr.status >= 500) {\n reject(TroveError.transient(`Upload part failed (${xhr.status})`));\n } else {\n reject(new TroveError('internal', `Upload failed (${xhr.status})`));\n }\n };\n xhr.onerror = () => reject(TroveError.transient('Network error during upload'));\n xhr.onabort = () => reject(TroveError.aborted());\n xhr.send(body);\n });\n}\n",
27
+ "// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Some of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var w = new Worker(ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([\n c + ';addEventListener(\"error\",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'\n ], { type: 'text/javascript' }))));\n w.onmessage = function (e) {\n var d = e.data, ed = d.$e$;\n if (ed) {\n var err = new Error(ed[0]);\n err['code'] = ed[1];\n err.stack = ed[2];\n cb(err, null);\n }\n else\n cb(null, d);\n };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;\n// fixed length extra bits\nvar fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\nvar fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new i32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return { b: b, r: r };\n};\nvar _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b.b, revfd = _b.r;\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i) {\n if (cd[i])\n ++l[cd[i] - 1];\n }\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 1; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i) {\n if (cd[i]) {\n co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);\n }\n }\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p + 7) / 8) | 0; };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n return new u8(v.subarray(s, e));\n};\n/**\n * Codes for errors generated within this library\n */\nexport var FlateErrorCode = {\n UnexpectedEOF: 0,\n InvalidBlockType: 1,\n InvalidLengthLiteral: 2,\n InvalidDistance: 3,\n StreamFinished: 4,\n NoStreamHandler: 5,\n InvalidHeader: 6,\n NoCallback: 7,\n InvalidUTF8: 8,\n ExtraFieldTooLong: 9,\n InvalidDate: 10,\n FilenameTooLong: 11,\n StreamFinishing: 12,\n InvalidZipData: 13,\n UnknownCompressionMethod: 14\n};\n// error codes\nvar ec = [\n 'unexpected EOF',\n 'invalid block type',\n 'invalid length/literal',\n 'invalid distance',\n 'stream finished',\n 'no stream handler',\n , // determined by compression function\n 'no callback',\n 'invalid UTF-8 data',\n 'extra field too long',\n 'date not in range 1980-2099',\n 'filename too long',\n 'stream finishing',\n 'invalid zip data'\n // determined by unknown compression method\n];\n;\nvar err = function (ind, msg, nt) {\n var e = new Error(msg || ec[ind]);\n e.code = ind;\n if (Error.captureStackTrace)\n Error.captureStackTrace(e, err);\n if (!nt)\n throw e;\n return e;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, st, buf, dict) {\n // source length dict length\n var sl = dat.length, dl = dict ? dict.length : 0;\n if (!sl || st.f && !st.l)\n return buf || new u8(0);\n var noBuf = !buf;\n // have to estimate size\n var resize = noBuf || st.i != 2;\n // no state\n var noSt = st.i;\n // Assumes roughly 33% compression ratio average\n if (noBuf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n err(0);\n break;\n }\n // ensure size\n if (resize)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8, st.f = final;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n err(1);\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17\n if (resize)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var lpos = pos;\n for (;; lpos = pos) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >> 4;\n pos += c & 15;\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (!c)\n err(2);\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lpos = pos, lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;\n if (!d)\n err(3);\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & (1 << b) - 1, pos += b;\n }\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (resize)\n cbuf(bt + 131072);\n var end = bt + add;\n if (bt < dt) {\n var shift = dl - dt, dend = Math.min(dt, end);\n if (shift + bt < 0)\n err(3);\n for (; bt < dend; ++bt)\n buf[bt] = dict[shift + bt];\n }\n for (; bt < end; ++bt)\n buf[bt] = buf[bt - dt];\n }\n }\n st.l = lm, st.p = lpos, st.b = bt, st.f = final;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n // don't reallocate for streams or user buffers\n return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) | 0;\n d[o] |= v;\n d[o + 1] |= v >> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) | 0;\n d[o] |= v;\n d[o + 1] |= v >> 8;\n d[o + 2] |= v >> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return { t: et, l: 0 };\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return { t: v, l: 1 };\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return { t: new u8(tr), l: mbt };\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return { c: cl.subarray(0, cli), n: s };\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a.t, mlb = _a.l;\n var _b = hTree(df, 15), ddt = _b.t, mdb = _b.l;\n var _c = lc(dlt), lclt = _c.c, nlc = _c.n;\n var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n ++lcfreq[lclt[i] & 31];\n for (var i = 0; i < lcdt.length; ++i)\n ++lcfreq[lcdt[i] & 31];\n var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];\n if (bs >= 0 && flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >> 5) & 127), p += clct[i] >> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n var sym = syms[i];\n if (sym > 255) {\n var len = (sym >> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (sym >> 23) & 31), p += fleb[len];\n var dst = sym & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (sym >> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[sym]), p += ll[sym];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, st) {\n var s = st.z || dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var lst = st.l;\n var pos = (st.r || 0) & 7;\n if (lvl) {\n if (pos)\n w[0] = st.r >> 3;\n var opt = deo[lvl - 1];\n var n = opt >> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new i32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx blkpos\n var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;\n for (; i + 2 < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768 previous index mod\n var imod = i & 32767, pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && (rem > 423 || !lst)) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = i - dif + j & 32767;\n var pti = prev[ti];\n var cd = ti - pti & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += imod - pimod & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one int32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n for (i = Math.max(i, wi); i < s; ++i) {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n if (!lst) {\n st.r = (pos & 7) | w[(pos / 8) | 0] << 3;\n // shft(pos) now 1 less if pos & 7 != 0\n pos -= 7;\n st.h = head, st.p = prev, st.i = i, st.w = wi;\n }\n }\n else {\n for (var i = st.w || 0; i < s + lst; i += 65535) {\n // end\n var e = i + 65535;\n if (e >= s) {\n // write final block\n w[(pos / 8) | 0] = lst;\n e = s;\n }\n pos = wfblk(w, pos + 1, dat.subarray(i, e));\n }\n st.i = s;\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new Int32Array(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && -306674912) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = -1;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return ~c; }\n };\n};\n// Adler32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length | 0;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 2655, l);\n for (; i < e; ++i)\n m += n += d[i];\n n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);\n }\n a = n, b = m;\n },\n d: function () {\n a %= 65521, b %= 65521;\n return (a & 255) << 24 | (a & 0xFF00) << 8 | (b & 255) << 8 | (b >> 8);\n }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n if (!st) {\n st = { l: 1 };\n if (opt.dictionary) {\n var dict = opt.dictionary.subarray(-32768);\n var newDat = new u8(dict.length + dat.length);\n newDat.set(dict);\n newDat.set(dat, dict.length);\n dat = newDat;\n st.w = dict.length;\n }\n }\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? (st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20) : (12 + opt.mem), pre, post, st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/\\s+/g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return fnStr;\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k].buffer) {\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n fnStr = wcln(fns[i], fnStr, td_1);\n ch[id] = { c: wcln(fns[m], fnStr, td_1), e: td_1 };\n }\n var td = mrg({}, ch[id].e);\n return wk(ch[id].c + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, i32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, ec, hMap, max, bits, bits16, shft, slc, err, inflt, inflateSync, pbf, gopt]; };\nvar bDflt = function () { return [u8, u16, i32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zls]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get opts\nvar gopt = function (o) { return o && {\n out: o.size && new u8(o.size),\n dictionary: o.dictionary\n}; };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n w.postMessage([dat, opts], opts.consume ? [dat.buffer] : []);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) {\n if (ev.data[0]) {\n strm.push(ev.data[0], ev.data[1]);\n postMessage([ev.data[0].length]);\n }\n else\n strm.flush(ev.data[1]);\n };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id, flush, ext) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else if (!Array.isArray(dat))\n ext(dat);\n else if (dat.length == 1) {\n strm.queuedSize -= dat[0];\n if (strm.ondrain)\n strm.ondrain(dat[0]);\n }\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.queuedSize = 0;\n strm.push = function (d, f) {\n if (!strm.ondata)\n err(5);\n if (t)\n strm.ondata(err(4, 0, 1), null, !!f);\n strm.queuedSize += d.length;\n // can fail for cross-realm Uint8Array, but ok - only a small performance penalty\n w.postMessage([d, t = f], d.buffer instanceof ArrayBuffer ? [d.buffer] : []);\n };\n strm.terminate = function () { w.terminate(); };\n if (flush) {\n strm.flush = function (sync) { w.postMessage([0, sync]); };\n }\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };\n// read 8 bytes\nvar b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n err(6, 'invalid gzip data');\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += (d[10] | d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + (o.filename ? o.filename.length + 1 : 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (o.dictionary && 32);\n c[1] |= 31 - ((c[0] << 8) | c[1]) % 31;\n if (o.dictionary) {\n var h = adler();\n h.p(o.dictionary);\n wbytes(c, 2, h.d());\n }\n};\n// zlib start\nvar zls = function (d, dict) {\n if ((d[0] & 15) != 8 || (d[0] >> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n err(6, 'invalid zlib data');\n if ((d[1] >> 5 & 1) == +!dict)\n err(6, 'invalid zlib data: ' + (d[1] & 32 ? 'need' : 'unexpected') + ' dictionary');\n return (d[1] >> 3 & 4) + 2;\n};\nfunction StrmOpt(opts, cb) {\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n this.s = { l: 0, i: 32768, w: 32768, z: 32768 };\n // Buffer length must always be 0 mod 32768 for index calculations to be correct when modifying head and prev\n // 98304 = 32768 (lookback) + 65536 (common chunk size)\n this.b = new u8(98304);\n if (this.o.dictionary) {\n var dict = this.o.dictionary.subarray(-32768);\n this.b.set(dict, 32768 - dict.length);\n this.s.i = 32768 - dict.length;\n }\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, this.s), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (this.s.l)\n err(4);\n var endLen = chunk.length + this.s.z;\n if (endLen > this.b.length) {\n if (endLen > 2 * this.b.length - 32768) {\n var newBuf = new u8(endLen & -32768);\n newBuf.set(this.b.subarray(0, this.s.z));\n this.b = newBuf;\n }\n var split = this.b.length - this.s.z;\n this.b.set(chunk.subarray(0, split), this.s.z);\n this.s.z = this.b.length;\n this.p(this.b, false);\n this.b.set(this.b.subarray(-32768));\n this.b.set(chunk.subarray(split), 32768);\n this.s.z = chunk.length - split + 32768;\n this.s.i = 32766, this.s.w = 32768;\n }\n else {\n this.b.set(chunk, this.s.z);\n this.s.z += chunk.length;\n }\n this.s.l = final & 1;\n if (this.s.z > this.s.w + 8191 || final) {\n this.p(this.b, final || false);\n this.s.w = this.s.i, this.s.i -= 2;\n }\n if (final) {\n // cleanup unneeded buffers/state to reduce memory usage\n this.s = this.o = {};\n this.b = et;\n }\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * deflated output for small inputs.\n * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5\n * extra bytes, but guarantees all pushed data is immediately\n * decompressible. A separate DEFLATE stream may be concatenated\n * with the current output after a sync flush.\n */\n Deflate.prototype.flush = function (sync) {\n if (!this.ondata)\n err(5);\n if (this.s.l)\n err(4);\n this.p(this.b, false);\n this.s.w = this.s.i, this.s.i -= 2;\n // could technically skip writing the type-0 block for (this.s.r & 7) == 0,\n // but the deterministic trailer (00 00 FF FF) is useful in some situations\n if (sync) {\n var c = new u8(6);\n c[0] = this.s.r >> 3;\n // write empty, non-final type-0 block\n var ep = wfblk(c, this.s.r, et);\n this.s.r = 0;\n this.ondata(c.subarray(0, ep >> 3), false);\n }\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6, 1);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n return dopt(data, opts || {}, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n function Inflate(opts, cb) {\n // no StrmOpt here to avoid adding to workerizer\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n var dict = opts && opts.dictionary && opts.dictionary.subarray(-32768);\n this.s = { i: 0, b: dict ? dict.length : 0 };\n this.o = new u8(32768);\n this.p = new u8(0);\n if (dict)\n this.o.set(dict);\n }\n Inflate.prototype.e = function (c) {\n if (!this.ondata)\n err(5);\n if (this.d)\n err(4);\n if (!this.p.length)\n this.p = c;\n else if (c.length) {\n var n = new u8(this.p.length + c.length);\n n.set(this.p), n.set(c, this.p.length), this.p = n;\n }\n };\n Inflate.prototype.c = function (final) {\n this.s.i = +(this.d = final || false);\n var bts = this.s.b;\n var dt = inflt(this.p, this.s, this.o);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) | 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n function AsyncInflate(opts, cb) {\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Inflate(ev.data);\n onmessage = astrm(strm);\n }, 7, 0);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gopt(ev.data[1]))); }, 1, cb);\n}\nexport function inflateSync(data, opts) {\n return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n this.c.p(chunk);\n this.l += chunk.length;\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, this.s);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * GZIPped output for small inputs.\n * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5\n * extra bytes, but guarantees all pushed data is immediately\n * decompressible.\n */\n Gzip.prototype.flush = function (sync) {\n Deflate.prototype.flush.call(this, sync);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8, 1);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (!opts)\n opts = {};\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming single or multi-member GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n function Gunzip(opts, cb) {\n this.v = 1;\n this.r = 0;\n Inflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n this.r += chunk.length;\n if (this.v) {\n var p = this.p.subarray(this.v - 1);\n var s = p.length > 3 ? gzs(p) : 4;\n if (s > p.length) {\n if (!final)\n return;\n }\n else if (this.v > 1 && this.onmember) {\n this.onmember(this.r - p.length);\n }\n this.p = p.subarray(s), this.v = 0;\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, 0);\n // process concatenated GZIP\n if (this.s.f && !this.s.l) {\n this.v = shft(this.s.p) + 9;\n this.s = { i: 0 };\n this.o = new u8(0);\n this.push(new u8(0), final);\n }\n else if (final) {\n Inflate.prototype.c.call(this, final);\n }\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming single or multi-member GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n function AsyncGunzip(opts, cb) {\n var _this = this;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Gunzip(ev.data);\n strm.onmember = function (offset) { return postMessage(offset); };\n onmessage = astrm(strm);\n }, 9, 0, function (offset) { return _this.onmember && _this.onmember(offset); });\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0], ev.data[1])); }, 3, cb);\n}\nexport function gunzipSync(data, opts) {\n var st = gzs(data);\n if (st + 8 > data.length)\n err(6, 'invalid gzip data');\n return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary);\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n this.c.p(chunk);\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n var raw = dopt(c, this.o, this.v && (this.o.dictionary ? 6 : 2), f && 4, this.s);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * zlibbed output for small inputs.\n * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5\n * extra bytes, but guarantees all pushed data is immediately\n * decompressible.\n */\n Zlib.prototype.flush = function (sync) {\n Deflate.prototype.flush.call(this, sync);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10, 1);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (!opts)\n opts = {};\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, opts.dictionary ? 6 : 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n function Unzlib(opts, cb) {\n Inflate.call(this, opts, cb);\n this.v = opts && opts.dictionary ? 2 : 1;\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 6 && !final)\n return;\n this.p = this.p.subarray(zls(this.p, this.v - 1)), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n err(6, 'invalid zlib data');\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n function AsyncUnzlib(opts, cb) {\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Unzlib(ev.data);\n onmessage = astrm(strm);\n }, 11, 0);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gopt(ev.data[1]))); }, 5, cb);\n}\nexport function unzlibSync(data, opts) {\n return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n function Decompress(opts, cb) {\n this.o = StrmOpt.call(this, opts, cb) || {};\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n }\n // init substream\n // overriden by AsyncDecompress\n Decompress.prototype.i = function () {\n var _this = this;\n this.s.ondata = function (dat, final) {\n _this.ondata(dat, final);\n };\n };\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(this.o)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(this.o)\n : new this.Z(this.o);\n this.i();\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n function AsyncDecompress(opts, cb) {\n Decompress.call(this, opts, cb);\n this.queuedSize = 0;\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n }\n AsyncDecompress.prototype.i = function () {\n var _this = this;\n this.s.ondata = function (err, dat, final) {\n _this.ondata(err, dat, final);\n };\n this.s.ondrain = function (size) {\n _this.queuedSize -= size;\n if (_this.ondrain)\n _this.ondrain(size);\n };\n };\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n this.queuedSize += chunk.length;\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, opts) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, opts)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, opts)\n : unzlibSync(data, opts);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k, op = o;\n if (Array.isArray(val))\n op = mrg(o, val[1]), val = val[0];\n if (ArrayBuffer.isView(val))\n t[n] = [val, op];\n else {\n t[n += '/'] = [new u8(0), op];\n fltn(val, n, t, o);\n }\n }\n};\n// text encoder\nvar te = typeof TextEncoder != 'undefined' && /*#__PURE__*/ new TextEncoder();\n// text decoder\nvar td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();\n// text decoder stream\nvar tds = 0;\ntry {\n td.decode(et, { stream: true });\n tds = 1;\n}\ncatch (e) { }\n// decode UTF8\nvar dutf8 = function (d) {\n for (var r = '', i = 0;;) {\n var c = d[i++];\n var eb = (c > 127) + (c > 223) + (c > 239);\n if (i + eb > d.length)\n return { s: r, r: slc(d, i - 1) };\n if (!eb)\n r += String.fromCharCode(c);\n else if (eb == 3) {\n c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n else if (eb & 1)\n r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));\n else\n r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));\n }\n};\n/**\n * Streaming UTF-8 decoding\n */\nvar DecodeUTF8 = /*#__PURE__*/ (function () {\n /**\n * Creates a UTF-8 decoding stream\n * @param cb The callback to call whenever data is decoded\n */\n function DecodeUTF8(cb) {\n this.ondata = cb;\n if (tds)\n this.t = new TextDecoder();\n else\n this.p = et;\n }\n /**\n * Pushes a chunk to be decoded from UTF-8 binary\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n DecodeUTF8.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n final = !!final;\n if (this.t) {\n this.ondata(this.t.decode(chunk, { stream: true }), final);\n if (final) {\n if (this.t.decode().length)\n err(8);\n this.t = null;\n }\n return;\n }\n if (!this.p)\n err(4);\n var dat = new u8(this.p.length + chunk.length);\n dat.set(this.p);\n dat.set(chunk, this.p.length);\n var _a = dutf8(dat), s = _a.s, r = _a.r;\n if (final) {\n if (r.length)\n err(8);\n this.p = null;\n }\n else\n this.p = r;\n this.ondata(s, final);\n };\n return DecodeUTF8;\n}());\nexport { DecodeUTF8 };\n/**\n * Streaming UTF-8 encoding\n */\nvar EncodeUTF8 = /*#__PURE__*/ (function () {\n /**\n * Creates a UTF-8 decoding stream\n * @param cb The callback to call whenever data is encoded\n */\n function EncodeUTF8(cb) {\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be encoded to UTF-8\n * @param chunk The string data to push\n * @param final Whether this is the last chunk\n */\n EncodeUTF8.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (this.d)\n err(4);\n this.ondata(strToU8(chunk), this.d = final || false);\n };\n return EncodeUTF8;\n}());\nexport { EncodeUTF8 };\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n if (latin1) {\n var ar_1 = new u8(str.length);\n for (var i = 0; i < str.length; ++i)\n ar_1[i] = str.charCodeAt(i);\n return ar_1;\n }\n if (te)\n return te.encode(str);\n var l = str.length;\n var ar = new u8(str.length + (str.length >> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >> 18)), w(128 | ((c >> 12) & 63)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >> 12)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n if (latin1) {\n var r = '';\n for (var i = 0; i < dat.length; i += 16384)\n r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));\n return r;\n }\n else if (td) {\n return td.decode(dat);\n }\n else {\n var _a = dutf8(dat), s = _a.s, r = _a.r;\n if (r.length)\n err(8);\n return s;\n }\n}\n;\n// deflate bit flag\nvar dbf = function (l) { return l == 1 ? 3 : l < 6 ? 2 : l == 9 ? 1 : 0; };\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), efl = b2(d, b + 30), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;\n var _a = z64hs(d, es, efl, z, b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)), sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + efl + b2(d, b + 32), off];\n};\n// read zip64 header sizes\nvar z64hs = function (d, b, l, z, sc, su, off) {\n var nsc = sc == 4294967295, nsu = su == 4294967295, noff = off == 4294967295, e = b + l;\n var nf = nsc + nsu + noff;\n if (z && nf) {\n for (; b + 4 < e; b += 4 + b2(d, b + 2)) {\n if (b2(d, b) == 1) {\n return [\n nsc ? b8(d, b + 4 + 8 * nsu) : sc,\n nsu ? b8(d, b + 4) : su,\n noff ? b8(d, b + 4 + 8 * (nsu + nsc)) : off,\n 1\n ];\n }\n }\n // z == 2 for unknown whether or not zip64\n if (z < 2)\n err(13);\n }\n return [sc, su, off, 0];\n};\n// extra field length\nvar exfl = function (ex) {\n var le = 0;\n if (ex) {\n for (var k in ex) {\n var l = ex[k].length;\n if (l > 65535)\n err(9);\n le += l + 4;\n }\n }\n return le;\n};\n// write zip header\nvar wzh = function (d, b, f, fn, u, c, ce, co) {\n var fl = fn.length, ex = f.extra, col = co && co.length;\n var exl = exfl(ex);\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b++] = 20, d[b++] = f.os;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (f.flag << 1) | (c < 0 && 8), d[b++] = u && 8;\n d[b++] = f.compression & 255, d[b++] = f.compression >> 8;\n var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n err(10);\n wbytes(d, b, (y << 25) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >> 1)), b += 4;\n if (c != -1) {\n wbytes(d, b, f.crc);\n wbytes(d, b + 4, c < 0 ? -c - 2 : c);\n wbytes(d, b + 8, f.size);\n }\n wbytes(d, b + 12, fl);\n wbytes(d, b + 14, exl), b += 16;\n if (ce != null) {\n wbytes(d, b, col);\n wbytes(d, b + 6, f.attrs);\n wbytes(d, b + 10, ce), b += 14;\n }\n d.set(fn, b);\n b += fl;\n if (exl) {\n for (var k in ex) {\n var exf = ex[k], l = exf.length;\n wbytes(d, b, +k);\n wbytes(d, b + 2, l);\n d.set(exf, b + 4), b += 4 + l;\n }\n }\n if (col)\n d.set(co, b), b += col;\n return b;\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\n/**\n * A pass-through stream to keep data uncompressed in a ZIP archive.\n */\nvar ZipPassThrough = /*#__PURE__*/ (function () {\n /**\n * Creates a pass-through stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n */\n function ZipPassThrough(filename) {\n this.filename = filename;\n this.c = crc();\n this.size = 0;\n this.compression = 0;\n }\n /**\n * Processes a chunk and pushes to the output stream. You can override this\n * method in a subclass for custom behavior, but by default this passes\n * the data through. You must call this.ondata(err, chunk, final) at some\n * point in this method.\n * @param chunk The chunk to process\n * @param final Whether this is the last chunk\n */\n ZipPassThrough.prototype.process = function (chunk, final) {\n this.ondata(null, chunk, final);\n };\n /**\n * Pushes a chunk to be added. If you are subclassing this with a custom\n * compression algorithm, note that you must push data from the source\n * file only, pre-compression.\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n ZipPassThrough.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n this.c.p(chunk);\n this.size += chunk.length;\n if (final)\n this.crc = this.c.d();\n // we shouldn't really do this cast, but properly handling ArrayBufferLike\n // makes the API unergonomic with Buffer\n this.process(chunk, final || false);\n };\n return ZipPassThrough;\n}());\nexport { ZipPassThrough };\n// I don't extend because TypeScript extension adds 1kB of runtime bloat\n/**\n * Streaming DEFLATE compression for ZIP archives. Prefer using AsyncZipDeflate\n * for better performance\n */\nvar ZipDeflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n * @param opts The compression options\n */\n function ZipDeflate(filename, opts) {\n var _this = this;\n if (!opts)\n opts = {};\n ZipPassThrough.call(this, filename);\n this.d = new Deflate(opts, function (dat, final) {\n _this.ondata(null, dat, final);\n });\n this.compression = 8;\n this.flag = dbf(opts.level);\n }\n ZipDeflate.prototype.process = function (chunk, final) {\n try {\n this.d.push(chunk, final);\n }\n catch (e) {\n this.ondata(e, null, final);\n }\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n ZipDeflate.prototype.push = function (chunk, final) {\n ZipPassThrough.prototype.push.call(this, chunk, final);\n };\n return ZipDeflate;\n}());\nexport { ZipDeflate };\n/**\n * Asynchronous streaming DEFLATE compression for ZIP archives\n */\nvar AsyncZipDeflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous DEFLATE stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n * @param opts The compression options\n */\n function AsyncZipDeflate(filename, opts) {\n var _this = this;\n if (!opts)\n opts = {};\n ZipPassThrough.call(this, filename);\n this.d = new AsyncDeflate(opts, function (err, dat, final) {\n _this.ondata(err, dat, final);\n });\n this.compression = 8;\n this.flag = dbf(opts.level);\n this.terminate = this.d.terminate;\n }\n AsyncZipDeflate.prototype.process = function (chunk, final) {\n this.d.push(chunk, final);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncZipDeflate.prototype.push = function (chunk, final) {\n ZipPassThrough.prototype.push.call(this, chunk, final);\n };\n return AsyncZipDeflate;\n}());\nexport { AsyncZipDeflate };\n// TODO: Better tree shaking\n/**\n * A zippable archive to which files can incrementally be added\n */\nvar Zip = /*#__PURE__*/ (function () {\n /**\n * Creates an empty ZIP archive to which files can be added\n * @param cb The callback to call whenever data for the generated ZIP archive\n * is available\n */\n function Zip(cb) {\n this.ondata = cb;\n this.u = [];\n this.d = 1;\n }\n /**\n * Adds a file to the ZIP archive\n * @param file The file stream to add\n */\n Zip.prototype.add = function (file) {\n var _this = this;\n if (!this.ondata)\n err(5);\n // finishing or finished\n if (this.d & 2)\n this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, false);\n else {\n var f = strToU8(file.filename), fl_1 = f.length;\n var com = file.comment, o = com && strToU8(com);\n var u = fl_1 != file.filename.length || (o && (com.length != o.length));\n var hl_1 = fl_1 + exfl(file.extra) + 30;\n if (fl_1 > 65535)\n this.ondata(err(11, 0, 1), null, false);\n var header = new u8(hl_1);\n wzh(header, 0, file, f, u, -1);\n var chks_1 = [header];\n var pAll_1 = function () {\n for (var _i = 0, chks_2 = chks_1; _i < chks_2.length; _i++) {\n var chk = chks_2[_i];\n _this.ondata(null, chk, false);\n }\n chks_1 = [];\n };\n var tr_1 = this.d;\n this.d = 0;\n var ind_1 = this.u.length;\n var uf_1 = mrg(file, {\n f: f,\n u: u,\n o: o,\n t: function () {\n if (file.terminate)\n file.terminate();\n },\n r: function () {\n pAll_1();\n if (tr_1) {\n var nxt = _this.u[ind_1 + 1];\n if (nxt)\n nxt.r();\n else\n _this.d = 1;\n }\n tr_1 = 1;\n }\n });\n var cl_1 = 0;\n file.ondata = function (err, dat, final) {\n if (err) {\n _this.ondata(err, dat, final);\n _this.terminate();\n }\n else {\n cl_1 += dat.length;\n chks_1.push(dat);\n if (final) {\n var dd = new u8(16);\n wbytes(dd, 0, 0x8074B50);\n wbytes(dd, 4, file.crc);\n wbytes(dd, 8, cl_1);\n wbytes(dd, 12, file.size);\n chks_1.push(dd);\n uf_1.c = cl_1, uf_1.b = hl_1 + cl_1 + 16, uf_1.crc = file.crc, uf_1.size = file.size;\n if (tr_1)\n uf_1.r();\n tr_1 = 1;\n }\n else if (tr_1)\n pAll_1();\n }\n };\n this.u.push(uf_1);\n }\n };\n /**\n * Ends the process of adding files and prepares to emit the final chunks.\n * This *must* be called after adding all desired files for the resulting\n * ZIP file to work properly.\n */\n Zip.prototype.end = function () {\n var _this = this;\n if (this.d & 2) {\n this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, true);\n return;\n }\n if (this.d)\n this.e();\n else\n this.u.push({\n r: function () {\n if (!(_this.d & 1))\n return;\n _this.u.splice(-1, 1);\n _this.e();\n },\n t: function () { }\n });\n this.d = 3;\n };\n Zip.prototype.e = function () {\n var bt = 0, l = 0, tl = 0;\n for (var _i = 0, _a = this.u; _i < _a.length; _i++) {\n var f = _a[_i];\n tl += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0);\n }\n var out = new u8(tl + 22);\n for (var _b = 0, _c = this.u; _b < _c.length; _b++) {\n var f = _c[_b];\n wzh(out, bt, f, f.f, f.u, -f.c - 2, l, f.o);\n bt += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0), l += f.b;\n }\n wzf(out, bt, this.u.length, tl, l);\n this.ondata(null, out, true);\n this.d = 2;\n };\n /**\n * A method to terminate any internal workers used by the stream. Subsequent\n * calls to add() will fail.\n */\n Zip.prototype.terminate = function () {\n for (var _i = 0, _a = this.u; _i < _a.length; _i++) {\n var f = _a[_i];\n f.t();\n }\n this.d = 2;\n };\n return Zip;\n}());\nexport { Zip };\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbd = function (a, b) {\n mt(function () { cb(a, b); });\n };\n mt(function () { cbd = cb; });\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n var l = f.c.length;\n wzh(out, tot, f, f.f, f.u, l);\n var badd = 30 + f.f.length + exfl(f.extra);\n var loc = tot + badd;\n out.set(f.c, loc);\n wzh(out, o, f, f.f, f.u, l, tot, f.m), o += 16 + badd + (f.m ? f.m.length : 0), tot = loc + l;\n }\n catch (e) {\n return cbd(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cbd(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), size = file.length;\n c.p(file);\n var f = strToU8(fn), s = f.length;\n var com = p.comment, m = com && strToU8(com), ms = m && m.length;\n var exl = exfl(p.extra);\n var compression = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cbd(e, null);\n }\n else {\n var l = d.length;\n files[i] = mrg(p, {\n size: size,\n crc: c.d(),\n c: d,\n f: f,\n m: m,\n u: s != fn.length || (m && (com.length != ms)),\n compression: compression\n });\n o += 30 + s + exl + l;\n tot += 76 + 2 * (s + exl) + (ms || 0) + l;\n if (!--lft)\n cbf();\n }\n };\n if (s > 65535)\n cbl(err(11, 0, 1), null);\n if (!compression)\n cbl(null, file);\n else if (size < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (!opts)\n opts = {};\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var compression = p.level == 0 ? 0 : 8;\n var f = strToU8(fn), s = f.length;\n var com = p.comment, m = com && strToU8(com), ms = m && m.length;\n var exl = exfl(p.extra);\n if (s > 65535)\n err(11);\n var d = compression ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push(mrg(p, {\n size: file.length,\n crc: c.d(),\n c: d,\n f: f,\n m: m,\n u: s != fn.length || (m && (com.length != ms)),\n o: o,\n compression: compression\n }));\n o += 30 + s + exl + l;\n tot += 76 + 2 * (s + exl) + (ms || 0) + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f, f.f, f.u, f.c.length);\n var badd = 30 + f.f.length + exfl(f.extra);\n out.set(f.c, f.o + badd);\n wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Streaming pass-through decompression for ZIP archives\n */\nvar UnzipPassThrough = /*#__PURE__*/ (function () {\n function UnzipPassThrough() {\n }\n UnzipPassThrough.prototype.push = function (chunk, final) {\n // same as ZipPassThrough: cast to retain Buffer ergonomics\n this.ondata(null, chunk, final);\n };\n UnzipPassThrough.compression = 0;\n return UnzipPassThrough;\n}());\nexport { UnzipPassThrough };\n/**\n * Streaming DEFLATE decompression for ZIP archives. Prefer AsyncZipInflate for\n * better performance.\n */\nvar UnzipInflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE decompression that can be used in ZIP archives\n */\n function UnzipInflate() {\n var _this = this;\n this.i = new Inflate(function (dat, final) {\n _this.ondata(null, dat, final);\n });\n }\n UnzipInflate.prototype.push = function (chunk, final) {\n try {\n this.i.push(chunk, final);\n }\n catch (e) {\n this.ondata(e, null, final);\n }\n };\n UnzipInflate.compression = 8;\n return UnzipInflate;\n}());\nexport { UnzipInflate };\n/**\n * Asynchronous streaming DEFLATE decompression for ZIP archives\n */\nvar AsyncUnzipInflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE decompression that can be used in ZIP archives\n */\n function AsyncUnzipInflate(_, sz) {\n var _this = this;\n if (sz < 320000) {\n this.i = new Inflate(function (dat, final) {\n _this.ondata(null, dat, final);\n });\n }\n else {\n this.i = new AsyncInflate(function (err, dat, final) {\n _this.ondata(err, dat, final);\n });\n this.terminate = this.i.terminate;\n }\n }\n AsyncUnzipInflate.prototype.push = function (chunk, final) {\n if (this.i.terminate)\n chunk = slc(chunk, 0);\n this.i.push(chunk, final);\n };\n AsyncUnzipInflate.compression = 8;\n return AsyncUnzipInflate;\n}());\nexport { AsyncUnzipInflate };\n/**\n * A ZIP archive decompression stream that emits files as they are discovered\n */\nvar Unzip = /*#__PURE__*/ (function () {\n /**\n * Creates a ZIP decompression stream\n * @param cb The callback to call whenever a file in the ZIP archive is found\n */\n function Unzip(cb) {\n this.onfile = cb;\n this.k = [];\n this.o = {\n 0: UnzipPassThrough\n };\n this.p = et;\n }\n /**\n * Pushes a chunk to be unzipped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzip.prototype.push = function (chunk, final) {\n var _this = this;\n if (!this.onfile)\n err(5);\n if (!this.p)\n err(4);\n if (this.c > 0) {\n var len = Math.min(this.c, chunk.length);\n var toAdd = chunk.subarray(0, len);\n this.c -= len;\n if (this.d)\n this.d.push(toAdd, !this.c);\n else\n this.k[0].push(toAdd);\n chunk = chunk.subarray(len);\n if (chunk.length)\n return this.push(chunk, final);\n }\n else {\n var f = 0, i = 0, is = void 0, buf = void 0;\n if (!this.p.length)\n buf = chunk;\n else if (!chunk.length)\n buf = this.p;\n else {\n buf = new u8(this.p.length + chunk.length);\n buf.set(this.p), buf.set(chunk, this.p.length);\n }\n var l = buf.length, oc = this.c, add = oc && this.d;\n var _loop_2 = function () {\n var sig = b4(buf, i);\n if (sig == 0x4034B50) {\n f = 1, is = i;\n this_1.d = null;\n this_1.c = 0;\n var bf = b2(buf, i + 6), cmp_1 = b2(buf, i + 8), u = bf & 2048, dd = bf & 8, fnl = b2(buf, i + 26), es = b2(buf, i + 28);\n if (l > i + 30 + fnl + es) {\n var chks_3 = [];\n this_1.k.unshift(chks_3);\n f = 2;\n var lsc = b4(buf, i + 18), lsu = b4(buf, i + 22);\n var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);\n var _a = z64hs(buf, i, es, 2, lsc, lsu, 0), sc_1 = _a[0], su_1 = _a[1], z64 = _a[3];\n if (dd)\n sc_1 = -1 - z64;\n i += es;\n this_1.c = sc_1;\n var d_1;\n var file_1 = {\n name: fn_1,\n compression: cmp_1,\n start: function () {\n if (!file_1.ondata)\n err(5);\n if (!sc_1)\n file_1.ondata(null, et, true);\n else {\n var ctr = _this.o[cmp_1];\n if (!ctr)\n file_1.ondata(err(14, 'unknown compression type ' + cmp_1, 1), null, false);\n d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);\n d_1.ondata = function (err, dat, final) { file_1.ondata(err, dat, final); };\n for (var _i = 0, chks_4 = chks_3; _i < chks_4.length; _i++) {\n var dat = chks_4[_i];\n d_1.push(dat, false);\n }\n if (_this.k[0] == chks_3 && _this.c)\n _this.d = d_1;\n else\n d_1.push(et, true);\n }\n },\n terminate: function () {\n if (d_1 && d_1.terminate)\n d_1.terminate();\n }\n };\n if (sc_1 >= 0)\n file_1.size = sc_1, file_1.originalSize = su_1;\n this_1.onfile(file_1);\n }\n return \"break\";\n }\n else if (oc) {\n if (sig == 0x8074B50) {\n is = i += 12 + (oc == -2 && 8), f = 3, this_1.c = 0;\n return \"break\";\n }\n else if (sig == 0x2014B50) {\n is = i -= 4, f = 3, this_1.c = 0;\n return \"break\";\n }\n }\n };\n var this_1 = this;\n for (; i < l - 4; ++i) {\n var state_1 = _loop_2();\n if (state_1 === \"break\")\n break;\n }\n this.p = et;\n if (oc < 0) {\n var dat = f ? buf.subarray(0, is - 12 - (oc == -2 && 8) - (b4(buf, is - 16) == 0x8074B50 && 4)) : buf.subarray(0, i);\n if (add)\n add.push(dat, !!f);\n else\n this.k[+(f == 2)].push(dat);\n }\n if (f & 2)\n return this.push(buf.subarray(i), final);\n this.p = buf.subarray(i);\n }\n if (final) {\n if (this.c)\n err(13);\n this.p = null;\n }\n };\n /**\n * Registers a decoder with the stream, allowing for files compressed with\n * the compression type provided to be expanded correctly\n * @param decoder The decoder constructor\n */\n Unzip.prototype.register = function (decoder) {\n this.o[decoder.compression] = decoder;\n };\n return Unzip;\n}());\nexport { Unzip };\nvar mt = typeof queueMicrotask == 'function' ? queueMicrotask : typeof setTimeout == 'function' ? setTimeout : function (fn) { fn(); };\nexport function unzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var cbd = function (a, b) {\n mt(function () { cb(a, b); });\n };\n mt(function () { cbd = cb; });\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cbd(err(13, 0, 1), null);\n return tAll;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (lft) {\n var c = lft;\n var o = b4(data, e + 16);\n var z = b4(data, e - 20) == 0x7064B50;\n if (z) {\n var ze = b4(data, e - 12);\n z = b4(data, ze) == 0x6064B50;\n if (z) {\n c = lft = b4(data, ze + 32);\n o = b4(data, ze + 48);\n }\n }\n var fltr = opts && opts.filter;\n var _loop_3 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cbd(e, null);\n }\n else {\n if (d)\n files[fn] = d;\n if (!--lft)\n cbd(null, files);\n }\n };\n if (!fltr || fltr({\n name: fn,\n size: sc,\n originalSize: su,\n compression: c_1\n })) {\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n // Synchronously decompress under 512KB, or barely-compressed data\n if (su < 524288 || sc > 0.8 * su) {\n try {\n cbl(null, inflateSync(infl, { out: new u8(su) }));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl(err(14, 'unknown compression type ' + c_1, 1), null);\n }\n else\n cbl(null, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_3(i);\n }\n }\n else\n cbd(null, {});\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @param opts The ZIP extraction options\n * @returns The decompressed files\n */\nexport function unzipSync(data, opts) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n err(13);\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = b4(data, e - 20) == 0x7064B50;\n if (z) {\n var ze = b4(data, e - 12);\n z = b4(data, ze) == 0x6064B50;\n if (z) {\n c = b4(data, ze + 32);\n o = b4(data, ze + 48);\n }\n }\n var fltr = opts && opts.filter;\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!fltr || fltr({\n name: fn,\n size: sc,\n originalSize: su,\n compression: c_2\n })) {\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });\n else\n err(14, 'unknown compression type ' + c_2);\n }\n }\n return files;\n}\n",
28
+ "// PluginRegistry — install records (manifest, package files, granted caps, trust\n// status, settings, secrets) persisted in IndexedDB so plugins survive reloads on\n// this device. Package bytes stay on-device (they can be large); non-secret\n// settings can also be mirrored to the server (see the settings service) so they\n// follow the user. A plugin's OWN data lives in per-scope SQLite databases (server\n// via the host API; on-device via the wasm store) — not here.\n\nconst DB = 'trove-plugins';\nconst STORE = 'installs';\n\nfunction openDb() {\n return new Promise((resolve, reject) => {\n const req = indexedDB.open(DB, 1);\n req.onupgradeneeded = () => {\n const db = req.result;\n if (!db.objectStoreNames.contains(STORE)) db.createObjectStore(STORE, { keyPath: 'id' });\n };\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n });\n}\nfunction tx(db, mode, fn) {\n return new Promise((resolve, reject) => {\n const t = db.transaction(STORE, mode);\n const s = t.objectStore(STORE);\n let out;\n Promise.resolve(fn(s)).then((r) => (out = r));\n t.oncomplete = () => resolve(out);\n t.onerror = () => reject(t.error);\n });\n}\nconst reqP = (r) => new Promise((res, rej) => { r.onsuccess = () => res(r.result); r.onerror = () => rej(r.error); });\n\nexport class PluginRegistry {\n constructor() {\n this._db = null;\n }\n async #db() {\n return (this._db ??= await openDb());\n }\n /** record: { id, manifest, files:{path:Uint8Array}, grants, trust, settings, secrets, installedAt } */\n async save(record) {\n const db = await this.#db();\n await tx(db, 'readwrite', (s) => s.put(record));\n return record;\n }\n async get(id) {\n const db = await this.#db();\n return tx(db, 'readonly', (s) => reqP(s.get(id)));\n }\n async list() {\n const db = await this.#db();\n return tx(db, 'readonly', (s) => reqP(s.getAll()));\n }\n async remove(id) {\n const db = await this.#db();\n await tx(db, 'readwrite', (s) => s.delete(id));\n }\n async patch(id, patch) {\n const rec = await this.get(id);\n if (!rec) return null;\n const next = { ...rec, ...patch };\n await this.save(next);\n return next;\n }\n}\n\n",
29
+ "// Client-side plugin storage: an on-device SQLite database per scope, run in the\n// HOST with sql.js (wasm) and persisted to IndexedDB. The sandboxed iframe can't\n// touch IndexedDB (opaque origin), so — like everything else — the host holds the\n// store and the plugin reaches it over RPC. It exposes the SAME async\n// SqliteDatabase surface as the server side, so ctx.storage.*.client mirrors\n// .server. Lazy: the wasm only loads the first time a plugin uses client storage.\n\nlet sqlPromise = null;\nfunction loadSql() {\n // locateFile points at the wasm we serve at the app root (build copies it; dev &\n // test serve it via middleware). Only fetched on first use. On failure we clear\n // the cached promise so a later attempt can retry rather than wedging forever.\n if (!sqlPromise) {\n sqlPromise = import('sql.js')\n .then((m) => (m.default || m)({ locateFile: () => '/sql-wasm.wasm' }))\n .catch((err) => { sqlPromise = null; throw err; });\n }\n return sqlPromise;\n}\n\n// --- IndexedDB blob persistence (host origin) --------------------------------\n\nconst IDB = 'trove-plugin-clientdb';\nconst STORE = 'dbs';\n\nfunction openIdb() {\n return new Promise((resolve, reject) => {\n const req = indexedDB.open(IDB, 1);\n req.onupgradeneeded = () => {\n const db = req.result;\n if (!db.objectStoreNames.contains(STORE)) db.createObjectStore(STORE);\n };\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n });\n}\nfunction idbOp(mode, fn) {\n return openIdb().then((db) => new Promise((resolve, reject) => {\n const t = db.transaction(STORE, mode);\n let out;\n Promise.resolve(fn(t.objectStore(STORE))).then((r) => (out = r));\n t.oncomplete = () => { db.close(); resolve(out); };\n t.onerror = () => { db.close(); reject(t.error); };\n }));\n}\nconst reqP = (r) => new Promise((res, rej) => { r.onsuccess = () => res(r.result); r.onerror = () => rej(r.error); });\nconst loadBytes = (key) => idbOp('readonly', (s) => reqP(s.get(key)));\nconst saveBytes = (key, bytes) => idbOp('readwrite', (s) => s.put(bytes, key));\nconst dropBytes = (key) => idbOp('readwrite', (s) => s.delete(key));\n\n// --- a single scoped database (conforms to SqliteDatabase) -------------------\n\nclass ClientDatabase {\n constructor(key, db) {\n this.key = key;\n this.db = db;\n this._saveTimer = null;\n }\n // Debounce persistence: export the whole (small, per-scope) db to IndexedDB\n // shortly after the last write.\n //\n // The write already returned `{ok:true}` to the plugin by the time this runs, so a\n // failure here is data the plugin believes it saved and hasn't. Nothing can be\n // returned to it any more — but it must at least be visible, not swallowed.\n #dirty() {\n clearTimeout(this._saveTimer);\n this._saveTimer = setTimeout(() => {\n this.flush().catch((err) => {\n console.error(`persisting plugin storage \"${this.key}\" failed`, err);\n this.onError?.(err, this.key);\n });\n }, 150);\n }\n async flush() {\n clearTimeout(this._saveTimer);\n this._saveTimer = null;\n await saveBytes(this.key, this.db.export());\n }\n async exec(sql) { this.db.exec(sql); this.#dirty(); return { ok: true }; }\n async run(sql, ...params) { this.db.run(sql, params); this.#dirty(); return { ok: true }; }\n async get(sql, ...params) {\n const stmt = this.db.prepare(sql);\n try { stmt.bind(params); return stmt.step() ? stmt.getAsObject() : null; }\n finally { stmt.free(); }\n }\n async all(sql, ...params) {\n const stmt = this.db.prepare(sql);\n const out = [];\n try { stmt.bind(params); while (stmt.step()) out.push(stmt.getAsObject()); }\n finally { stmt.free(); }\n return out;\n }\n async batch(statements = []) {\n this.db.run('BEGIN');\n try {\n for (const { sql, params = [] } of statements) this.db.run(sql, params);\n this.db.run('COMMIT');\n } catch (err) {\n try { this.db.run('ROLLBACK'); } catch { /* already rolled back */ }\n throw err;\n }\n this.#dirty();\n return { ok: true };\n }\n close() { clearTimeout(this._saveTimer); this.db.close(); }\n}\n\n// --- the pool ----------------------------------------------------------------\n\nexport class ClientSqlProvider {\n constructor({ onError } = {}) { this._pool = new Map(); this.onError = onError || null; }\n\n async obtain(key) {\n let db = this._pool.get(key);\n if (!db) {\n const SQL = await loadSql();\n const bytes = await loadBytes(key);\n db = new ClientDatabase(key, new SQL.Database(bytes || undefined));\n db.onError = this.onError;\n this._pool.set(key, db);\n }\n return db;\n }\n\n /** Drop a scope's database. Throws if the bytes can't be deleted — the caller\n * (uninstall) reports leftover on-device data rather than claiming a clean wipe. */\n async drop(key) {\n const db = this._pool.get(key);\n if (db) { db.close(); this._pool.delete(key); }\n await dropBytes(key);\n }\n}\n",
30
+ "// Plugin package signing + domain verification, on Web Crypto.\n//\n// A package is a zip of files including manifest.json. Signing binds two things:\n// 1. every non-manifest file, via `contentHash` (SHA-256 over the sorted file\n// set) recorded in the manifest — tamper any file and it breaks;\n// 2. the manifest itself, via an ECDSA-P256 `signature` over its canonical\n// JSON (with `signature` removed) — tamper the manifest and it breaks.\n// The signer's public key (SPKI) travels in the manifest; its fingerprint is\n// SHA-256 of that key. A plugin is \"domain verified\" when the manifest declares\n// a `domain` and that domain publishes the signer's fingerprint at\n// https://<domain>/.well-known/trove-assetlinks.json\n// (Digital-Asset-Links style), proving the domain owner vouches for the key.\n//\n// Verification is best-effort and layered: unsigned → \"unverified\"; signed but\n// the domain doesn't list the key → \"signed (self)\"; signed + listed → \"verified\n// · <domain>\". None of this sandboxes the plugin (the iframe does); it's a trust\n// signal for the human deciding whether to install.\n\nconst enc = new TextEncoder();\n\nfunction b64ToBytes(b64) {\n const bin = atob(b64.replace(/-/g, '+').replace(/_/g, '/'));\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\nfunction bytesToB64(bytes) {\n let s = '';\n const b = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);\n for (let i = 0; i < b.length; i++) s += String.fromCharCode(b[i]);\n return btoa(s);\n}\nfunction hex(buf) {\n const b = new Uint8Array(buf);\n let s = '';\n for (let i = 0; i < b.length; i++) s += b[i].toString(16).padStart(2, '0');\n return s;\n}\nasync function sha256(bytes) {\n return new Uint8Array(await crypto.subtle.digest('SHA-256', bytes));\n}\n\n/** Stable JSON: recursively sorted keys, `signature` stripped from the top. */\nexport function canonicalManifest(manifest) {\n const strip = { ...manifest };\n delete strip.signature;\n return JSON.stringify(sortKeys(strip));\n}\nfunction sortKeys(v) {\n if (Array.isArray(v)) return v.map(sortKeys);\n if (v && typeof v === 'object') {\n const out = {};\n for (const k of Object.keys(v).sort()) out[k] = sortKeys(v[k]);\n return out;\n }\n return v;\n}\n\n/** SHA-256 over every file except manifest.json, in sorted-path order. */\nexport async function contentHash(files) {\n const paths = [...files.keys()].filter((p) => p !== 'manifest.json').sort();\n const chunks = [];\n for (const p of paths) {\n const bytes = files.get(p);\n const pathBytes = enc.encode(p);\n const len = new Uint8Array(4);\n new DataView(len.buffer).setUint32(0, bytes.length);\n chunks.push(pathBytes, new Uint8Array([0]), len, bytes);\n }\n const total = chunks.reduce((n, c) => n + c.length, 0);\n const buf = new Uint8Array(total);\n let o = 0;\n for (const c of chunks) {\n buf.set(c, o);\n o += c.length;\n }\n return hex(await sha256(buf));\n}\n\n/** SHA-256 fingerprint of an SPKI public key (lowercase hex). */\nexport async function fingerprintOf(publicKeyB64) {\n return hex(await sha256(b64ToBytes(publicKeyB64)));\n}\nexport function displayFingerprint(hexStr) {\n return (hexStr.match(/.{2}/g) || []).join(':');\n}\n\n/**\n * Verify a package's integrity + signature (does NOT check the domain).\n * @returns {Promise<{signed:boolean, valid:boolean, fingerprint?:string, reason?:string}>}\n */\nexport async function verifyPackage({ manifest, files }) {\n if (!manifest.signature || !manifest.publicKey) return { signed: false, valid: false };\n // 1. content hash binds all other files.\n const expected = await contentHash(files);\n if (manifest.contentHash && manifest.contentHash !== expected) {\n return { signed: true, valid: false, reason: 'File contents do not match the manifest hash' };\n }\n // 2. signature binds the manifest.\n try {\n const key = await crypto.subtle.importKey('spki', b64ToBytes(manifest.publicKey), { name: 'ECDSA', namedCurve: 'P-256' }, false, ['verify']);\n const ok = await crypto.subtle.verify({ name: 'ECDSA', hash: 'SHA-256' }, key, b64ToBytes(manifest.signature), enc.encode(canonicalManifest(manifest)));\n if (!ok) return { signed: true, valid: false, reason: 'Signature does not verify' };\n return { signed: true, valid: true, fingerprint: await fingerprintOf(manifest.publicKey) };\n } catch (err) {\n return { signed: true, valid: false, reason: 'Bad key/signature: ' + err.message };\n }\n}\n\n/**\n * Given the domain's assetlinks doc, is this key fingerprint vouched for this plugin?\n * Format:\n * { \"version\": 1, \"keys\": [ { \"fingerprint\": \"<hex|colon-hex>\", \"plugins\": [\"docs\" | \"*\"] } ] }\n *\n * The doc is served BY the domain, so a plugin is named by its name within that domain\n * (\"docs\"); the fully-qualified \"acme.com/docs\" is accepted too, for docs that prefer\n * to be explicit.\n */\nexport function checkAssetlinks(assetlinks, fingerprint, manifest) {\n const norm = (f) => (f || '').toLowerCase().replace(/:/g, '');\n const want = norm(fingerprint);\n const names = [manifest.name, `${manifest.domain}/${manifest.name}`];\n for (const k of assetlinks?.keys || []) {\n if (norm(k.fingerprint) !== want) continue;\n if ((k.plugins || []).some((p) => p === '*' || names.includes(p))) return true;\n }\n return false;\n}\n\n/**\n * Full trust status for a package.\n * @param {(domain:string)=>Promise<object|null>} fetchAssetlinks resolves the domain's assetlinks doc (or null)\n * @returns {Promise<{status:'unverified'|'invalid'|'signed'|'verified', domain?:string, fingerprint?:string, reason?:string}>}\n */\nexport async function assessTrust({ manifest, files }, fetchAssetlinks) {\n const sig = await verifyPackage({ manifest, files });\n if (!sig.signed) return { status: 'unverified', reason: 'Package is not signed' };\n // A present-but-failed signature is evidence of tampering — a distinct, alarming\n // status, NOT the same grey \"unverified\" as an ordinary unsigned package.\n if (!sig.valid) return { status: 'invalid', reason: sig.reason || 'Invalid signature — the package may have been tampered with' };\n let doc = null;\n try {\n doc = await fetchAssetlinks(manifest.domain);\n } catch { /* unreachable domain */ }\n if (doc && checkAssetlinks(doc, sig.fingerprint, manifest)) {\n return { status: 'verified', domain: manifest.domain, fingerprint: sig.fingerprint };\n }\n return { status: 'signed', domain: manifest.domain, fingerprint: sig.fingerprint, reason: doc ? 'Domain does not list this key' : 'Could not reach the domain' };\n}\n\n// --- signing (tooling / tests) ---------------------------------------------\n\nexport async function generateSigningKey() {\n return crypto.subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, true, ['sign', 'verify']);\n}\n\n/** Produce a signed manifest for a package. Returns the manifest with\n * contentHash + publicKey + signature filled in. */\nexport async function signManifest(manifest, files, keyPair) {\n const withHash = { ...manifest, contentHash: await contentHash(files) };\n const spki = new Uint8Array(await crypto.subtle.exportKey('spki', keyPair.publicKey));\n withHash.publicKey = bytesToB64(spki);\n const sig = new Uint8Array(await crypto.subtle.sign({ name: 'ECDSA', hash: 'SHA-256' }, keyPair.privateKey, enc.encode(canonicalManifest(withHash))));\n withHash.signature = bytesToB64(sig);\n return withHash;\n}\n\nexport { b64ToBytes, bytesToB64 };\n",
31
+ "// Declared network endpoints — the allowlist a plugin must publish before it can\n// talk to the web. The sandboxed iframe can't reach the network at all (strict\n// `connect-src 'none'` CSP + opaque origin); every request is brokered by the host\n// over the MessagePort, and the host only makes it if the URL matches one of these\n// declared endpoints. So the manifest's `network` array is the *complete* list of\n// hosts a plugin can ever reach, shown to the user at install time and enforced at\n// runtime.\n//\n// An endpoint is a URL prefix: scheme + host (optionally `*.`-wildcarded) + port +\n// path prefix. A request matches when its scheme, host, port, and path-prefix all\n// agree. Query strings and fragments are ignored in the pattern.\n\n/** Parse one endpoint pattern; throws on anything that isn't an http(s) URL. */\nexport function parseEndpoint(pattern) {\n // Strip a leading `*.` wildcard BEFORE parsing — `*` isn't a valid host code\n // point, and URL parsers disagree on how to mangle it (Chromium vs ada/Node),\n // so we never hand it to `new URL()`.\n const wild = /^([a-z][a-z0-9+.-]*:\\/\\/)\\*\\.(.+)$/i.exec(pattern);\n const wildcard = !!wild;\n let u;\n try {\n u = new URL(wildcard ? wild[1] + wild[2] : pattern);\n } catch {\n throw new Error(`Invalid network endpoint \"${pattern}\" (must be an absolute http(s) URL)`);\n }\n if (u.protocol !== 'http:' && u.protocol !== 'https:') {\n throw new Error(`Network endpoint \"${pattern}\" must use http or https`);\n }\n const host = u.hostname.toLowerCase();\n if (!host) throw new Error(`Network endpoint \"${pattern}\" has no host`);\n return { scheme: u.protocol, host, wildcard, port: u.port, pathPrefix: u.pathname || '/', raw: pattern };\n}\n\n/** Parse a manifest's `network` list, silently dropping malformed entries. */\nexport function normalizeEndpoints(list) {\n const out = [];\n for (const p of list || []) {\n try { out.push(parseEndpoint(p)); } catch { /* skip — validated separately at parse time */ }\n }\n return out;\n}\n\n/** Does a request URL fall under a single parsed endpoint? */\nexport function matchesEndpoint(ep, url) {\n let u;\n try { u = new URL(url); } catch { return false; }\n if (u.protocol !== ep.scheme) return false;\n const host = u.hostname.toLowerCase();\n if (ep.wildcard) {\n if (host !== ep.host && !host.endsWith('.' + ep.host)) return false;\n } else if (host !== ep.host) {\n return false;\n }\n if (u.port !== ep.port) return false; // '' === '' for default ports (browser normalizes)\n return u.pathname.startsWith(ep.pathPrefix);\n}\n\n/** Is `url` allowed by the plugin's declared endpoint list? */\nexport function isAllowedUrl(endpoints, url) {\n return normalizeEndpoints(endpoints).some((ep) => matchesEndpoint(ep, url));\n}\n\n/** A human-friendly summary of declared endpoints for the review UI. */\nexport function endpointSummary(endpoints) {\n return normalizeEndpoints(endpoints).map((e) => ({\n scheme: e.scheme.replace(':', ''),\n host: (e.wildcard ? '*.' : '') + e.host + (e.port ? ':' + e.port : ''),\n path: e.pathPrefix === '/' ? '' : e.pathPrefix,\n raw: e.raw,\n }));\n}\n",
32
+ "// Plugin packages — a plugin is a zip: manifest.json + an entry script + assets.\n// This parses/validates a package (from an uploaded file or a fetched URL) and\n// produces the summary shown in the pre-install review. Nothing here runs plugin\n// code — that only happens later, inside a sandboxed iframe.\n\nimport { unzipSync } from 'fflate';\nimport { parseEndpoint, endpointSummary } from './pluginNet.js';\nimport { assertIdentity, pluginId, ownsUri, parseContribUri } from '@3sln/trove/core/plugins/identity.js';\nimport { declaredContributions } from '@3sln/trove/core/plugins/contributions.js';\n\nconst CAP_DESCRIPTIONS = {\n files: 'Read your files, folders, and search index (via the host).',\n storage: 'Keep its own SQLite database(s) — on the server and/or on this device.',\n ui: 'Show a popup panel and toasts.',\n commands: 'Add commands to the palette, and run the specific host commands it lists.',\n opener: 'Preview/open file types.',\n // Distinct from a declared indexer (which the SERVER runs on every upload): this\n // capability lets the plugin itself push searchable content for a file it's looking at.\n indexer: 'Add searchable content to your files.',\n network: 'Connect to the internet — only the endpoints it declares (shown below).',\n media: 'Show playback controls on your lock screen and notifications while it plays media.',\n dock: 'Keep its viewer in a small floating window when you navigate away.',\n};\n\n// Capabilities that need an admin to grant (they touch shared data). None at the\n// moment — the `storage.domain` scope is instead gated on domain verification.\nexport const ADMIN_ONLY_CAPS = new Set();\n\n/**\n * The storage scopes a manifest declares: `{ plugin, domain }`. Each is a separate\n * lazily-created SQLite database (server + client). The `domain` scope — shared\n * across a vendor's plugins — is only usable by a domain-verified package.\n */\nexport function storageScopes(manifest) {\n const opt = capabilityOptions(manifest, 'storage');\n if (!opt) return { plugin: false, domain: false };\n // `storage: true` (or `{}`) → the private plugin scope, nothing shared.\n if (opt === true || (typeof opt === 'object' && !('plugin' in opt) && !('domain' in opt))) {\n return { plugin: true, domain: false };\n }\n return { plugin: !!opt.plugin, domain: !!opt.domain };\n}\n\nexport function describeCapability(cap) {\n return CAP_DESCRIPTIONS[cap] || cap;\n}\n\n// Capabilities are declared as an object: each key is a capability, each value is\n// that capability's options. A capability that takes no options uses `true` (or an\n// empty object). e.g. { ui: true, network: { endpoints: [\"https://api.example.com/\"] } }.\n// A plain array of ids is also accepted (each treated as options-less) so simple\n// or hand-written manifests stay easy.\nexport function capabilityEntries(manifest) {\n const caps = manifest && manifest.capabilities;\n const out = {};\n if (Array.isArray(caps)) {\n for (const id of caps) if (id) out[id] = {};\n } else if (caps && typeof caps === 'object') {\n for (const [id, val] of Object.entries(caps)) {\n if (val === false || val == null) continue; // explicitly not requested\n out[id] = val === true ? {} : val;\n }\n }\n return out;\n}\n\n/** The declared capability ids. */\nexport function capabilityList(manifest) {\n return Object.keys(capabilityEntries(manifest));\n}\n\n/** Options declared for one capability, or null if it isn't declared. */\nexport function capabilityOptions(manifest, id) {\n const e = capabilityEntries(manifest);\n return Object.prototype.hasOwnProperty.call(e, id) ? e[id] : null;\n}\n\n/** The network capability's declared endpoint prefixes (accepts a few shapes). */\nexport function networkEndpoints(manifest) {\n const opt = capabilityOptions(manifest, 'network');\n if (opt) {\n if (Array.isArray(opt)) return opt; // network: [\"https://…\"]\n if (Array.isArray(opt.endpoints)) return opt.endpoints;\n if (Array.isArray(opt.prefixes)) return opt.prefixes;\n }\n if (Array.isArray(manifest.network)) return manifest.network; // legacy top-level\n return [];\n}\n\n/** The human-facing name: `displayName` if given, else the package name. */\nexport function displayName(manifest) {\n // A STRING, always — and this is a security boundary, not tidiness.\n //\n // dodo decides \"is this argument a props map or a child?\" by `x.constructor === Object`,\n // and every prop on an HTML element is assigned as a DOM PROPERTY. `JSON.parse` gives\n // objects whose constructor is Object, so a manifest with\n // `\"displayName\": {\"innerHTML\": \"<img src=x onerror=…>\"}` — nothing validates it —\n // reaches `span(plugin.name)` in the plugin panel and `h3(g.category)` in Settings as\n // the FIRST argument, becomes the element's prop map, and executes in the host page.\n // That is a complete escape from the opaque-origin, connect-src 'none' iframe.\n const name = manifest?.displayName ?? manifest?.name;\n return typeof name === 'string' && name.trim() ? name : 'Plugin';\n}\n\n/**\n * The exact commands this plugin may ASK THE HOST TO RUN (ctx.commands.execute), each\n * named by the URI it's contributed at — a built-in like `explorer.download`, or\n * another plugin's `trove+contrib:acme.com/docs/export`. Like `network`, the\n * capability carries its allowlist rather than being a blanket grant: \"can run\n * commands\" is meaningless as a yes/no, because the interesting question is always\n * *which* ones (`explorer.delete` is not `workbench.view.home`).\n * Accepted shapes:\n * commands: true → contribute-only; executes nothing external\n * commands: [\"explorer.download\", …] → exactly these\n * commands: { execute: [\"…\"] } → exactly these\n * A plugin may always execute its own commands — that's just calling itself.\n */\nexport function executableCommands(manifest) {\n const opt = capabilityOptions(manifest, 'commands');\n if (!opt) return [];\n if (Array.isArray(opt)) return opt.filter(Boolean);\n if (Array.isArray(opt.execute)) return opt.execute.filter(Boolean);\n return [];\n}\n\n/**\n * Whether `commandUri` is executable by the plugin described by `manifest`. A plugin\n * always owns its own contributions (the URI is scoped under its domain and name), so\n * ownership is decided by the address itself rather than by a naming convention or a\n * registry lookup that could be raced.\n */\nexport function canExecuteCommand(manifest, commandUri, _ownerPluginId) {\n if (!commandUri) return false;\n if (parseContribUri(commandUri) && ownsUri(manifest, commandUri)) return true;\n return executableCommands(manifest).includes(commandUri);\n}\n\n/** Parse zip bytes into { manifest, files:Map<path,Uint8Array>, raw }. */\nexport function parsePackage(zipBytes) {\n let entries;\n try {\n entries = unzipSync(zipBytes instanceof Uint8Array ? zipBytes : new Uint8Array(zipBytes));\n } catch (err) {\n throw new Error('Not a valid zip archive: ' + err.message);\n }\n const files = new Map();\n for (const [path, bytes] of Object.entries(entries)) {\n if (!path.endsWith('/')) files.set(path.replace(/^\\.?\\//, ''), bytes);\n }\n const manifestBytes = files.get('manifest.json');\n if (!manifestBytes) throw new Error('Package is missing manifest.json');\n let manifest;\n try {\n manifest = JSON.parse(new TextDecoder().decode(manifestBytes));\n } catch (err) {\n throw new Error('manifest.json is not valid JSON: ' + err.message);\n }\n validateManifest(manifest, files);\n return { manifest, files, raw: zipBytes };\n}\n\nfunction validateManifest(m, files) {\n const need = (c, msg) => { if (!c) throw new Error(msg); };\n // Identity is mandatory: a package must say which DOMAIN it belongs to and its NAME\n // within that domain. There is no anonymous/self-identified install — every\n // contribution is addressed under `<domain>/<name>`, and the domain is what makes\n // that address verifiable rather than merely claimed.\n assertIdentity(m);\n need(m.entry, 'manifest.entry (path to the plugin script) is required');\n need(files.has(m.entry), `entry \"${m.entry}\" is not in the package`);\n if (m.capabilities != null) {\n need(Array.isArray(m.capabilities) || typeof m.capabilities === 'object',\n 'capabilities must be an object of { capability: options } (or an array of ids)');\n }\n if (m.icon) need(files.has(m.icon), `icon \"${m.icon}\" is not in the package`);\n // Throws on a bad type, a missing entry module, or a malformed option — the review\n // dialog must be able to show exactly what will be registered.\n for (const c of declaredContributions(m)) {\n if (c.entry) need(files.has(c.entry), `contribution \"${c.name}\" points at \"${c.entry}\", which is not in the package`);\n if (c.type === 'keymap') need(files.has(c.path), `keymap \"${c.name}\" points at \"${c.path}\", which is not in the package`);\n }\n for (const ep of networkEndpoints(m)) parseEndpoint(ep); // throws on anything but an http(s) URL\n}\n\n/** Fetch a package from a URL (must be a zip). */\nexport async function fetchPackage(url, fetchFn = globalThis.fetch.bind(globalThis)) {\n let res;\n try {\n res = await fetchFn(url);\n } catch (err) {\n throw new Error('Could not fetch the plugin: ' + err.message);\n }\n if (!res.ok) throw new Error(`Could not fetch the plugin (HTTP ${res.status})`);\n const bytes = new Uint8Array(await res.arrayBuffer());\n return parsePackage(bytes);\n}\n\n/** A flat, review-friendly summary of everything the package declares. */\nexport function reviewSummary(pkg, trust) {\n const m = pkg.manifest;\n const contributions = declaredContributions(m).map((c) => ({\n kind: c.type, name: c.name, uri: c.uri,\n title: c.title || c.name,\n detail: c.type === 'opener' || c.type === 'indexer' ? selectorText(c.match)\n // What it RUNS, not just where it sits. A status item can carry a command, and a\n // review that only said \"right of the status bar\" gave the user nothing to refuse.\n : c.type === 'statusItem' ? `${c.slot} of the status bar${c.command ? ` — runs ${c.command}` : ''}`\n : c.type === 'keymap' ? c.path : '',\n offline: !!c.offline,\n }));\n const verified = trust?.status === 'verified';\n const scopes = storageScopes(m);\n return {\n id: pluginId(m), name: displayName(m), version: m.version || '0.0.0', description: m.description || '',\n author: m.author || 'Unknown', domain: m.domain,\n capabilities: capabilityList(m).map((cap) => ({ id: cap, description: describeCapability(cap), adminOnly: ADMIN_ONLY_CAPS.has(cap) })),\n contributions,\n settings: (m.settings || []).map((s) => ({ key: s.key, title: s.title || s.key, type: s.type, secret: !!s.secret })),\n network: endpointSummary(networkEndpoints(m)),\n // Exactly which host commands it may run. Resolved to titles by the review UI,\n // which has the command registry; here we just surface the declared ids.\n commands: executableCommands(m),\n // Which SQLite stores it wants. `domain` (shared across a vendor's plugins) is\n // only grantable for a verified package; flag it so the review can say why.\n storage: (scopes.plugin || scopes.domain)\n ? { plugin: scopes.plugin, domain: scopes.domain, domainBlocked: scopes.domain && !verified }\n : null,\n fileCount: pkg.files.size,\n sizeBytes: [...pkg.files.values()].reduce((n, b) => n + b.length, 0),\n trust,\n };\n}\n\n/** The storage scopes actually granted at install: plugin if declared, domain if\n * declared AND the package is domain-verified. */\nexport function grantedStorageScopes(manifest, trust) {\n const s = storageScopes(manifest);\n return { plugin: s.plugin, domain: s.domain && trust?.status === 'verified' };\n}\n\nfunction selectorText(sel) {\n if (!sel) return '';\n const parts = [];\n if (sel.ext?.length) parts.push(sel.ext.join(', '));\n if (sel.mime?.length) parts.push(sel.mime.join(', '));\n return parts.join(' · ');\n}\n",
33
+ "// MediaController — bridges a plugin frame's playback to the OS via\n// navigator.mediaSession, so a sandboxed audio/video viewer surfaces real transport\n// controls (lock screen, media keys, notification shade).\n//\n// The host owns the single global mediaSession; the LAST frame to touch it becomes\n// the owner. OS actions fire back over that frame's own RPC channel, so a handler is\n// only ever wired to a live frame — and the handlers a frame registered are released\n// when it goes away (otherwise the OS would call into a dead channel).\n\nexport class MediaController {\n constructor() {\n this.owner = null; // the frame currently driving navigator.mediaSession\n }\n\n #session() {\n return typeof navigator !== 'undefined' ? navigator.mediaSession : null;\n }\n\n /** Apply one media operation for `frame`. kind: metadata|playbackState|position|action|clear */\n apply(frame, kind, params = {}) {\n const ms = this.#session();\n if (!ms) return { ok: false };\n if (frame && kind !== 'clear') { this.owner = frame; frame.mediaOwner = true; }\n try {\n if (kind === 'metadata') {\n ms.metadata = typeof MediaMetadata !== 'undefined'\n ? new MediaMetadata({ title: params.title || '', artist: params.artist || '', album: params.album || '', artwork: params.artwork || [] })\n : ms.metadata;\n } else if (kind === 'playbackState') {\n ms.playbackState = params.state || 'none';\n } else if (kind === 'position' && ms.setPositionState) {\n ms.setPositionState({ duration: params.duration || 0, position: params.position || 0, playbackRate: params.playbackRate || 1 });\n } else if (kind === 'action') {\n ms.setActionHandler?.(params.action, params.on ? () => frame?.channel?.emit('media:action', { action: params.action }) : null);\n // Remember which actions this frame registered, so we can release them when\n // the frame goes away (otherwise the OS handler points at a dead channel).\n if (frame) { frame.mediaActions ||= new Set(); params.on ? frame.mediaActions.add(params.action) : frame.mediaActions.delete(params.action); }\n } else if (kind === 'clear') {\n if (frame && this.owner && this.owner !== frame) return { ok: true }; // don't clear someone else's session\n this.releaseActions(frame);\n ms.metadata = null;\n ms.playbackState = 'none';\n this.owner = null;\n }\n } catch { /* unsupported action/state */ }\n return { ok: true };\n }\n\n /** Detach the OS media-transport handlers a frame registered (on teardown). */\n releaseActions(frame) {\n const ms = this.#session();\n if (!ms || !frame?.mediaActions) return;\n for (const action of frame.mediaActions) { try { ms.setActionHandler?.(action, null); } catch { /* ignore */ } }\n frame.mediaActions.clear();\n }\n\n /** Frame teardown: give up the session if this frame owned it, then drop its handlers. */\n releaseFrame(frame) {\n if (this.owner === frame) { this.owner = null; this.apply(frame, 'clear', {}); }\n this.releaseActions(frame); // drop handlers even if this frame wasn't the owner\n }\n}\n",
34
+ "// FrameDock — where a plugin frame's iframe is *shown*, and the floating dock (PiP).\n//\n// A frame's iframe is created once and stays a child of <body> for its life — we\n// NEVER re-parent it, because moving an <iframe> in the DOM reloads its document (per\n// the HTML spec) and would kill the running plugin + its MessagePort. To show a frame\n// \"inside\" a panel/viewer/dock we float it as a position:fixed overlay whose inset\n// tracks the target element's box (`place`), recomputed on intersection/resize/scroll\n// rather than every animation frame — the viewer area only moves on layout changes,\n// so this stays idle when nothing shifts.\n//\n// The dock is the single floating mini-player a viewer becomes when you navigate away\n// (video → PiP, audio → mini transport), if the viewer opted in via `dock.enable`.\n\nexport class FrameDock {\n /**\n * @param {object} deps\n * @param {(frame:object)=>void} deps.destroyFrame tear a frame down for good\n * @param {(node:object, openerId:string)=>void} deps.openFile reopen the docked file\n * @param {()=>void} [deps.onChange] notify listeners (the dock affects plugin state)\n */\n constructor({ destroyFrame, openFile, onChange } = {}) {\n this.destroyFrame = destroyFrame;\n this.openFile = openFile;\n this.onChange = onChange || (() => {});\n this.docked = null; // the frame currently in the dock\n this.el = null; // the dock's DOM host (created lazily)\n }\n\n // --- placement -------------------------------------------------------------\n\n /** Float `frame`'s iframe over `targetEl` and keep its inset aligned. */\n place(frame, targetEl, z, radius = '') {\n this.stopPlace(frame);\n const f = frame.iframe;\n f.style.cssText = `position:fixed;border:0;visibility:visible;display:block;background:transparent;z-index:${z};margin:0;padding:0;border-radius:${radius};`;\n const sync = () => {\n const r = targetEl.getBoundingClientRect();\n const shown = r.width > 0 && r.height > 0 && document.contains(targetEl);\n f.style.left = `${r.left}px`;\n f.style.top = `${r.top}px`;\n f.style.width = `${r.width}px`;\n f.style.height = `${r.height}px`;\n f.style.visibility = shown ? 'visible' : 'hidden';\n };\n sync();\n const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(sync) : null;\n ro?.observe(targetEl);\n if (document.body) ro?.observe(document.body);\n const io = typeof IntersectionObserver !== 'undefined' ? new IntersectionObserver(sync, { threshold: [0, 1] }) : null;\n io?.observe(targetEl);\n window.addEventListener('scroll', sync, true);\n window.addEventListener('resize', sync);\n frame.place = {\n target: targetEl,\n stop: () => {\n ro?.disconnect();\n io?.disconnect();\n window.removeEventListener('scroll', sync, true);\n window.removeEventListener('resize', sync);\n },\n };\n }\n\n stopPlace(frame) {\n if (frame.place) { frame.place.stop(); frame.place = null; }\n }\n\n /** Stop tracking and park the iframe offscreen (kept alive, just not shown). */\n hide(frame) {\n this.stopPlace(frame);\n frame.iframe.style.cssText = 'position:fixed;left:0;top:0;width:0;height:0;border:0;visibility:hidden;';\n }\n\n /** Frame teardown hook: stop placement and drop the dock if this frame was in it. */\n releaseFrame(frame) {\n this.stopPlace(frame);\n if (this.docked === frame) { this.docked = null; this.#hideEl(); }\n }\n\n // --- dock ------------------------------------------------------------------\n\n #hideEl() {\n if (this.el) this.el.style.display = 'none';\n }\n\n /** Float a viewer frame as the single floating dock, sized by its declared minimums. */\n dock(frame) {\n if (this.docked && this.docked !== frame) this.closeDock(this.docked);\n const min = frame.dock?.minSize || { width: 300, height: 90 };\n const el = this.#dockEl();\n el.style.width = `${clampDim(min.width, 200, 480)}px`;\n el.style.height = `${clampDim(min.height, 56, 360) + 26}px`; // + header\n el.querySelector('.vd-title').textContent = frame.node?.name || (frame.record.manifest.displayName || frame.record.manifest.name);\n el.style.display = 'flex';\n // Round the frame's bottom corners to match the dock's rounded body.\n this.place(frame, el.querySelector('.vd-body'), 61, '0 0 11px 11px');\n this.docked = frame;\n frame.channel?.emit('dock:state', { docked: true });\n this.onChange();\n }\n\n /** Un-dock without destroying — used when a docked frame is re-adopted into a viewer. */\n undock(frame) {\n this.#hideEl();\n if (this.docked === frame) this.docked = null;\n frame.channel?.emit('dock:state', { docked: false });\n }\n\n /** Dismiss the dock: the user closed it, or the viewer disabled docking. The frame\n * is done, so tear it down. */\n closeDock(frame) {\n this.#hideEl();\n if (this.docked === frame) this.docked = null;\n frame.channel?.emit('dock:state', { docked: false, closed: true });\n this.destroyFrame?.(frame);\n this.onChange();\n }\n\n #dockEl() {\n if (this.el) return this.el;\n const el = document.createElement('div');\n el.className = 'viewer-dock';\n el.innerHTML = '<div class=\"vd-bar\"><span class=\"vd-title\"></span><button class=\"vd-expand\" title=\"Reopen\">↗</button><button class=\"vd-close\" title=\"Close\">✕</button></div><div class=\"vd-body\"></div>';\n el.querySelector('.vd-expand').addEventListener('click', () => {\n const frame = this.docked;\n if (frame?.node) this.openFile?.(frame.node, frame.openerId);\n });\n el.querySelector('.vd-close').addEventListener('click', () => {\n if (this.docked) this.closeDock(this.docked);\n });\n document.body.appendChild(el);\n this.el = el;\n return el;\n }\n}\n\n// Clamp a viewer-declared dock dimension into a sane host range (defaulting to the\n// low bound when the viewer gives nothing).\nfunction clampDim(v, lo, hi) {\n return Math.max(lo, Math.min(hi, v || lo));\n}\n",
35
+ "// Shared internals. Not part of the public API.\n\n// Reports an error that has nowhere to go: one thrown by an observer callback,\n// by a teardown routine, or by a provider being disposed. Funnelled through a\n// single helper so every \"swallowed\" error surfaces the same way.\nexport function report(error) {\n console.error(error);\n}\n",
36
+ "// Layer 1: dependency injection.\n//\n// This module is self contained: it knows nothing about actions or queries.\n// Import it on its own if all you want is providers and a container.\n\nimport { report } from './internal.js';\n\nconst DISPOSED = 'The provider has been disposed';\n\n// The base class for all providers, which manage external resources.\nexport class Provider {\n static deps = [];\n\n async obtain(options = {}) {\n throw new Error('obtain() not implemented');\n }\n\n release(resource, options = {}) {}\n\n async flush() {}\n\n // The `create`, `destroy` and `dispose` callbacks below are handed the\n // dependency *providers*, not their resources -- the same thing a provider\n // written by hand gets in its constructor. That is deliberate: a resource\n // built by `create` usually outlives the call, so it has to be able to hold\n // a dependency for its own lifetime (obtain in `create`, release in\n // `destroy`). Handing over an already-obtained resource would release it\n // out from under the thing still using it.\n\n // Creates a provider that manages a single shared resource (singleton).\n static fromSingleton(resource, { dispose, deps = [] } = {}) {\n return class SingletonProvider extends Provider {\n static deps = deps;\n\n #deps;\n #disposed = false;\n\n constructor(injectedDeps = {}) {\n super();\n this.#deps = injectedDeps;\n }\n\n async obtain() {\n return resource;\n }\n\n release() {\n // Nothing to do for a singleton.\n }\n\n async dispose() {\n if (this.#disposed) {\n return;\n }\n this.#disposed = true;\n\n if (typeof dispose === 'function') {\n await dispose(resource, this.#deps);\n }\n }\n };\n }\n\n // Creates a provider that manages a pool of at most `size` resources.\n //\n // Every `obtain` joins a FIFO queue which is drained against the available\n // resources and the unused slots, so concurrent obtains can never overshoot\n // `size`, and a failed `create` hands the failure to the caller that is\n // actually waiting on it instead of deadlocking the queue.\n static fromPool(create, destroy, { size = 1, deps = [] } = {}) {\n if (!Number.isInteger(size) || size < 1) {\n throw new RangeError('fromPool() requires an integer size of at least 1');\n }\n\n return class PoolProvider extends Provider {\n static deps = deps;\n\n #deps;\n #available = [];\n #inUse = new Set();\n #waiting = [];\n #slots = 0;\n #disposed = false;\n\n constructor(injectedDeps = {}) {\n super();\n this.#deps = injectedDeps;\n }\n\n async #destroySafely(resource) {\n try {\n await destroy(resource, this.#deps);\n } catch (err) {\n report(err);\n }\n }\n\n // Hands resources to waiters, creating new ones while slots remain.\n #pump() {\n while (this.#waiting.length > 0) {\n if (this.#available.length > 0) {\n const resource = this.#available.shift();\n this.#inUse.add(resource);\n this.#waiting.shift().resolve(resource);\n continue;\n }\n\n if (this.#slots >= size) {\n return;\n }\n\n const waiter = this.#waiting.shift();\n this.#slots++;\n // The slot is reserved before awaiting, so a concurrent obtain sees\n // it as taken and the pool never exceeds `size`.\n Promise.resolve()\n .then(() => create(this.#deps))\n .then(\n (resource) => {\n if (this.#disposed) {\n this.#slots--;\n this.#destroySafely(resource);\n waiter.reject(new Error(DISPOSED));\n return;\n }\n this.#inUse.add(resource);\n waiter.resolve(resource);\n },\n (err) => {\n this.#slots--;\n waiter.reject(err);\n this.#pump();\n }\n );\n }\n }\n\n async obtain() {\n if (this.#disposed) {\n throw new Error(DISPOSED);\n }\n\n const waiter = Promise.withResolvers();\n this.#waiting.push(waiter);\n this.#pump();\n return await waiter.promise;\n }\n\n release(resource) {\n if (!this.#inUse.delete(resource)) {\n return;\n }\n\n if (this.#disposed) {\n this.#slots--;\n this.#destroySafely(resource);\n return;\n }\n\n this.#available.push(resource);\n this.#pump();\n }\n\n async dispose() {\n if (this.#disposed) {\n return;\n }\n this.#disposed = true;\n\n const waiting = this.#waiting.splice(0);\n for (const { reject } of waiting) {\n reject(new Error(DISPOSED));\n }\n\n const available = this.#available.splice(0);\n this.#slots -= available.length;\n // Resources still checked out are destroyed as they come back in.\n await Promise.all(available.map((resource) => this.#destroySafely(resource)));\n }\n };\n }\n\n // Creates a provider for a single shared resource that is built lazily, shared\n // by every consumer at once, and destroyed only when the container is.\n //\n // This is the shape a long-lived backbone has -- a database handle, a storage\n // client, a search index -- and none of the three above fits it.\n // `fromSingleton` cannot build one, because building is asynchronous and often\n // ordered (`await db.connect()`). `fromPool` with a size of one is a MUTEX:\n // the second `obtain` blocks until the first releases, so one slow consumer\n // stops every other. `fromRefCounted` shares correctly but destroys at zero,\n // so an ordinary lease/release cycle tears the resource down and the next\n // consumer silently gets a different one while the old is still referenced.\n //\n // `release` is a synchronous no-op here, deliberately: a consumer that leases\n // the backbone on every request should not pay teardown on the way out.\n static fromLazySingleton(create, destroy, { deps = [] } = {}) {\n return class LazySingletonProvider extends Provider {\n static deps = deps;\n\n #deps;\n #creation = null;\n #resource = null;\n #disposed = false;\n\n constructor(injectedDeps = {}) {\n super();\n this.#deps = injectedDeps;\n }\n\n async obtain() {\n if (this.#disposed) {\n throw new Error(DISPOSED);\n }\n\n // Memoized on the promise rather than the value, so two obtains during a\n // slow `create` get the same resource instead of racing to build two.\n this.#creation ??= Promise.resolve().then(() => create(this.#deps));\n\n try {\n this.#resource = await this.#creation;\n return this.#resource;\n } catch (err) {\n // A failed creation must not poison every later obtain.\n this.#creation = null;\n this.#resource = null;\n throw err;\n }\n }\n\n // Nothing: the resource outlives whoever borrowed it.\n release() {}\n\n async dispose() {\n if (this.#disposed) {\n return;\n }\n this.#disposed = true;\n\n if (!this.#creation || typeof destroy !== 'function') {\n return;\n }\n\n // Creation may still be in flight; destroy what it produces rather than\n // leaking a half-built resource.\n const resource = this.#resource ?? (await this.#creation.catch(() => null));\n if (resource != null) {\n await destroy(resource, this.#deps);\n }\n }\n };\n }\n\n // Creates a provider for a single shared resource that is lazily created and\n // ref-counted, and destroyed when the count drops to zero.\n static fromRefCounted(create, destroy, { deps = [] } = {}) {\n return class RefCountedProvider extends Provider {\n static deps = deps;\n\n #deps;\n #refCount = 0;\n #creation = null;\n #resource = null;\n #teardown = null;\n #disposed = false;\n\n constructor(injectedDeps = {}) {\n super();\n this.#deps = injectedDeps;\n }\n\n async obtain() {\n if (this.#disposed) {\n throw new Error(DISPOSED);\n }\n\n this.#refCount++;\n\n // A previous resource may still be tearing down. Let it finish so we\n // never hold a half-destroyed resource.\n while (this.#teardown) {\n await this.#teardown;\n }\n\n if (this.#disposed) {\n this.#refCount--;\n throw new Error(DISPOSED);\n }\n\n if (!this.#creation) {\n this.#creation = Promise.resolve().then(() => create(this.#deps));\n }\n\n try {\n this.#resource = await this.#creation;\n return this.#resource;\n } catch (err) {\n // A failed creation must not poison every later obtain.\n this.#refCount--;\n if (this.#refCount <= 0) {\n this.#refCount = 0;\n this.#creation = null;\n this.#resource = null;\n }\n throw err;\n }\n }\n\n async release() {\n if (this.#refCount <= 0) {\n return;\n }\n\n this.#refCount--;\n if (this.#refCount > 0) {\n return;\n }\n\n const resource = this.#resource;\n const creation = this.#creation;\n this.#resource = null;\n this.#creation = null;\n\n if (!creation) {\n return;\n }\n\n this.#teardown = (async () => {\n try {\n // Creation may still be in flight; destroy what it produces.\n const created = resource ?? (await creation.catch(() => null));\n if (created != null) {\n await destroy(created, this.#deps);\n }\n } catch (err) {\n report(err);\n } finally {\n this.#teardown = null;\n }\n })();\n\n await this.#teardown;\n }\n\n async dispose() {\n this.#disposed = true;\n\n if (this.#refCount > 0) {\n this.#refCount = 1;\n await this.release();\n }\n\n while (this.#teardown) {\n await this.#teardown;\n }\n }\n };\n }\n}\n\n// A resolved dependency set held for the duration of some work. Leases are the\n// single seam between this layer and the ones above it: actions take a lease\n// for one dispatch, queries hold one from boot until kill.\nclass Lease {\n #entries;\n #released = false;\n\n constructor(resources, entries) {\n this.resources = resources;\n this.#entries = entries;\n }\n\n get released() {\n return this.#released;\n }\n\n // Idempotent: releasing twice never double-releases a resource.\n async release() {\n if (this.#released) {\n return;\n }\n this.#released = true;\n\n for (const { name, provider, options } of this.#entries) {\n try {\n await provider.release(this.resources[name], options);\n } catch (err) {\n report(err);\n }\n }\n this.#entries = [];\n }\n}\n\n// Instantiates and owns a graph of providers, and hands out their resources.\n//\n// Consumers above this layer only ever need `feed`, `resolve`, `lease` and\n// `use`, so anything implementing those four can stand in for a Container.\nexport class Container {\n #providers = new Map();\n #resolutions = new WeakMap();\n #feed;\n #disposed = false;\n\n constructor({ providers, feed } = {}) {\n this.#feed = feed ?? new EventTarget();\n\n if (!providers) {\n return;\n }\n\n // Memoized so a provider named by two dependents is built exactly once,\n // and so a diamond-shaped graph is walked in linear time.\n const build = (name, path) => {\n if (this.#providers.has(name)) {\n return this.#providers.get(name);\n }\n\n const ProviderClass = providers[name];\n if (!ProviderClass) {\n throw new Error(`Dependency not found: ${name}`);\n }\n\n const nextPath = [...path, name];\n if (path.includes(name)) {\n throw new Error(`Cyclic dependency detected: ${nextPath.join(' -> ')}`);\n }\n\n const resolvedDeps = {};\n for (const depName of ProviderClass.deps ?? []) {\n resolvedDeps[depName] = build(depName, nextPath);\n }\n\n const provider = new ProviderClass(resolvedDeps, {\n engineFeed: this.#feed,\n container: this,\n });\n this.#providers.set(name, provider);\n return provider;\n };\n\n for (const name of Object.keys(providers)) {\n build(name, []);\n }\n }\n\n // The shared event bus. Providers, actions and queries all see this one.\n get feed() {\n return this.#feed;\n }\n\n get disposed() {\n return this.#disposed;\n }\n\n has(name) {\n return this.#providers.has(name);\n }\n\n get(name) {\n const provider = this.#providers.get(name);\n if (!provider) {\n throw new Error(`Dependency not found: ${name}`);\n }\n return provider;\n }\n\n // Turns a deps declaration -- either `['a', 'b']` or `{ a: options }` -- into\n // a map of `{ provider, options }`. Results are memoized against the\n // declaration object, so declarations must not be mutated after first use.\n resolve(depsConfig) {\n if (!depsConfig) {\n return {};\n }\n\n const cached = this.#resolutions.get(depsConfig);\n if (cached) {\n return cached;\n }\n\n const resolved = {};\n if (Array.isArray(depsConfig)) {\n for (const name of depsConfig) {\n resolved[name] = { provider: this.get(name), options: undefined };\n }\n } else {\n for (const name of Object.keys(depsConfig)) {\n resolved[name] = { provider: this.get(name), options: depsConfig[name] };\n }\n }\n\n this.#resolutions.set(depsConfig, resolved);\n return resolved;\n }\n\n // Merges several declarations; later ones win.\n resolveAll(...depsConfigs) {\n const present = depsConfigs.filter(Boolean);\n if (present.length === 1) {\n return this.resolve(present[0]);\n }\n return Object.assign({}, ...present.map((config) => this.resolve(config)));\n }\n\n // Obtains every declared resource, or none of them: if one `obtain` fails,\n // the ones already obtained are released before the error propagates.\n async lease(...depsConfigs) {\n if (this.#disposed) {\n throw new Error('The container has been disposed');\n }\n\n const deps = this.resolveAll(...depsConfigs);\n const resources = {};\n const entries = [];\n\n try {\n for (const [name, { provider, options }] of Object.entries(deps)) {\n resources[name] = await provider.obtain(options);\n entries.push({ name, provider, options });\n }\n } catch (err) {\n await new Lease(resources, entries).release();\n throw err;\n }\n\n return new Lease(resources, entries);\n }\n\n // Scoped lease: obtain, run, release -- even if `fn` throws.\n async use(depsConfig, fn) {\n const lease = await this.lease(depsConfig);\n try {\n return await fn(lease.resources);\n } finally {\n await lease.release();\n }\n }\n\n // Flushes then disposes every provider. Idempotent.\n async dispose() {\n if (this.#disposed) {\n return;\n }\n this.#disposed = true;\n\n // Providers are built dependencies-first, so tearing down in reverse\n // insertion order means a provider is always disposed before anything it\n // depends on -- its flush/dispose can still use its dependencies.\n const teardownOrder = [...this.#providers.values()].reverse();\n\n for (const provider of teardownOrder) {\n try {\n await provider.flush?.();\n } catch (err) {\n report(err);\n }\n }\n\n for (const provider of teardownOrder) {\n try {\n await provider.dispose?.();\n } catch (err) {\n report(err);\n }\n }\n }\n}\n",
37
+ "// Layer 2: actions and interceptors.\n//\n// Depends only on the container seam (`feed`, `resolve`, `lease`, `use`), so it\n// can be used with providers but without queries.\n\nimport { Container } from './providers.js';\n\n// `ErrorEvent` is not a global everywhere JavaScript runs, so fall back to an\n// equivalent shape. Listeners read `event.error` either way.\nconst DispatchErrorEvent =\n typeof ErrorEvent === 'function'\n ? ErrorEvent\n : class DispatchErrorEvent extends Event {\n constructor(type, { error, message = '' } = {}) {\n super(type);\n this.error = error;\n this.message = message;\n }\n };\n\nfunction messageOf(error) {\n return error && typeof error.message === 'string' ? error.message : String(error);\n}\n\n// The event an aborted dispatch ends on. `reason` is what `abort()` was given;\n// `error` is set only if the action threw on its way out, so nothing is lost by\n// reporting the abort instead of the throw.\nclass DispatchAbortEvent extends Event {\n constructor({ reason, error = null } = {}) {\n super('abort');\n this.reason = reason;\n this.error = error;\n }\n}\n\n// How a dispatch can end. All three are terminal: exactly one fires, once.\nconst TERMINAL = ['complete', 'error', 'abort'];\n\n// What `abort()` uses when given no reason. The same shape an AbortController\n// picks for itself, so `feed.reason` and `signal.reason` agree; `DOMException`\n// is not a global absolutely everywhere, hence the fallback.\nfunction abortError() {\n return typeof DOMException === 'function'\n ? new DOMException('The dispatch was aborted', 'AbortError')\n : Object.assign(new Error('The dispatch was aborted'), { name: 'AbortError' });\n}\n\nexport class Action {\n execute() {\n throw new Error('execute() not implemented');\n }\n}\n\n// The channel a dispatch reports on.\n//\n// Still an EventTarget, and still the only way results leave an action -- an\n// action that emits `progress` five times and then `result` is saying more than\n// a return value could. Two things are layered on top:\n//\n// feed.abort(reason) -- the caller is no longer interested. `signal` is\n// handed to the action and its interceptors, so the\n// work can stop; cooperatively, since nothing can\n// interrupt a running function.\n// feed.next(names) -- await one of `names`. This is the shape a request\n// handler wants: dispatch, await the event that\n// carries the answer, reply.\n//\n// A dispatch ends on exactly one of `complete`, `error` or `abort`. An aborted\n// one ends on `abort` and never on `complete`, because a scan that was stopped\n// at thirty percent did not complete, and saying it did is how \"it worked\" gets\n// reported about work that did not happen.\n//\n// `next` treats all three as terminal unless you ask for one by name. A promise\n// that never settles is the worst thing this could do to a caller -- there is no\n// timeout, no cancellation, and no error to log -- and an action that ends\n// without emitting what was awaited would otherwise hang it forever.\nexport class DispatchFeed extends EventTarget {\n #controller = new AbortController();\n #reason; // why this was aborted -- see abort()\n #settled = null; // { type, event } once complete/error has fired\n\n constructor() {\n super();\n // Registered before any caller's listener, so `settled` is already true by\n // the time their handler runs. This is what lets `next()` answer a caller\n // that arrives after the action is over instead of waiting for an event\n // that can no longer fire.\n for (const type of TERMINAL) {\n this.addEventListener(\n type,\n (event) => { this.#settled ??= { type, event }; },\n { once: true }\n );\n }\n }\n\n // Aborted when the caller gives up. Handed to the action, and to every\n // interceptor, as `signal`.\n get signal() {\n return this.#controller.signal;\n }\n\n // The terminal event, if the dispatch is over: `'complete'`, `'error'`, or\n // null while it is still running.\n get settled() {\n return this.#settled?.type ?? null;\n }\n\n // Why this was aborted, once it has been. Held here rather than read back off\n // `signal.reason` at the point of use: that value belongs to the runtime, and\n // it is what `next()` rejects with, so it must never come back undefined --\n // rejecting with `undefined` breaks every caller that writes `catch (e) {\n // e.message }`. (Bun 1.3 does drop it under memory pressure; even without\n // that, the guarantee is cheaper to make than to depend on.)\n get reason() {\n return this.#reason;\n }\n\n // Stop caring about this dispatch. The action decides when to notice --\n // there is no way to interrupt a running function -- but anything waiting on\n // `next()` rejects at once, because the point of aborting is not to wait.\n abort(reason) {\n if (this.#controller.signal.aborted) {\n return; // first abort wins, as with AbortController\n }\n // Recorded BEFORE aborting. `abort()` dispatches synchronously, so a\n // `next()` waiting on the signal rejects during this call -- with the reason\n // if it is already here, and with undefined if it is not.\n this.#reason = reason ?? abortError();\n this.#controller.abort(this.#reason);\n }\n\n /**\n * Resolve with the first of `names` to fire.\n *\n * @param {string|string[]} names event name, or names, to wait for\n * @param {{signal?: AbortSignal}} [options] the caller's own cancellation,\n * separate from `feed.abort()` -- an HTTP handler passes the request's\n * signal here so a disconnect unblocks it without aborting the action.\n * @returns {Promise<Event>} the event that fired\n */\n next(names, { signal } = {}) {\n const wanted = new Set(Array.isArray(names) ? names : [names]);\n if (wanted.size === 0) {\n throw new TypeError('next() requires at least one event name');\n }\n\n // Aborting and then awaiting `abort` is the ordinary wind-down: you have\n // stopped caring about the answer but still need to know the work stopped,\n // to release something or to reply. So a wait for the abort event is not\n // pre-empted by the abort itself -- everything else is, because the point of\n // giving up is not to keep waiting for the action to notice.\n const awaitingTheEnd = wanted.has('abort');\n\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(signal.reason);\n return;\n }\n if (this.#controller.signal.aborted && !awaitingTheEnd && !this.#settled) {\n reject(this.#reason);\n return;\n }\n // Already over. Answer from what was recorded rather than waiting for an\n // event that has fired once and will not fire again.\n if (this.#settled) {\n this.#finish(resolve, reject, this.#settled, wanted);\n return;\n }\n\n // One controller unregisters every listener below at once, on whichever\n // path settles first.\n const stop = new AbortController();\n const options = { signal: stop.signal };\n const settle = (fn) => (value) => {\n stop.abort();\n fn(value);\n };\n\n for (const name of wanted) {\n this.addEventListener(name, settle(resolve), options);\n }\n // Every terminal event not asked for by name ends the wait, because after\n // one of them nothing else will ever fire.\n for (const type of TERMINAL) {\n if (wanted.has(type)) {\n continue;\n }\n this.addEventListener(\n type,\n (event) => settle(reject)(endedWithout(type, event, wanted)),\n options\n );\n }\n if (!awaitingTheEnd) {\n this.#controller.signal.addEventListener(\n 'abort',\n () => settle(reject)(this.#reason),\n options\n );\n }\n signal?.addEventListener('abort', () => settle(reject)(signal.reason), options);\n });\n }\n\n #finish(resolve, reject, settled, wanted) {\n if (wanted.has(settled.type)) {\n resolve(settled.event);\n } else {\n reject(endedWithout(settled.type, settled.event, wanted));\n }\n }\n}\n\n// Why a wait ended without what it was waiting for. The action's own error and\n// the abort reason are handed back unwrapped, so a caller mapping them onto\n// something else -- an HTTP status, say -- still can.\nfunction endedWithout(type, event, wanted) {\n if (type === 'error') {\n return event.error;\n }\n if (type === 'abort') {\n return event.reason;\n }\n return missing(wanted);\n}\n\nfunction missing(wanted) {\n return new Error(\n `The dispatch completed without emitting ${[...wanted].map((n) => `'${n}'`).join(' or ')}`\n );\n}\n\n// Runs actions through a stack of interceptors.\nexport class Dispatcher {\n #container;\n #interceptors;\n\n constructor({ container, interceptors } = {}) {\n this.#container = container ?? new Container();\n this.#interceptors = interceptors ? [...interceptors] : [];\n }\n\n get container() {\n return this.#container;\n }\n\n get feed() {\n return this.#container.feed;\n }\n\n // Dispatch an action. Returns the dispatch feed immediately; the action\n // itself runs on a later turn of the event loop.\n dispatch(actionInstance) {\n if (!(actionInstance instanceof Action)) {\n throw new TypeError('dispatch() requires an instance of Action');\n }\n\n const container = this.#container;\n const interceptors = this.#interceptors;\n const engineFeed = container.feed;\n const dispatchFeed = new DispatchFeed();\n\n setTimeout(async () => {\n const enteredInterceptors = [];\n let state = {};\n let error = null;\n\n const applyState = (nextState) => {\n if (nextState !== undefined) {\n state = nextState;\n }\n };\n\n try {\n // Phase 1: Run 'enter' interceptors.\n for (const interceptor of interceptors) {\n // Recorded before running so a failing 'enter' still gets unwound.\n enteredInterceptors.push(interceptor);\n if (!interceptor.enter) {\n continue;\n }\n\n applyState(\n await container.use(interceptor.deps, (resources) =>\n interceptor.enter(resources, {\n dispatchFeed,\n engineFeed,\n signal: dispatchFeed.signal,\n state,\n action: actionInstance,\n })\n )\n );\n }\n\n // Phase 2: Obtain and execute the main action. Instance deps override\n // static ones of the same name.\n const lease = await container.lease(\n actionInstance.constructor.deps,\n actionInstance.deps\n );\n try {\n await actionInstance.execute(lease.resources, {\n dispatchFeed,\n engineFeed,\n // Cooperative: aborting cannot interrupt a running function, so an\n // action that wants to be stoppable checks this, or hands it to\n // something that does (fetch, a scan loop, another dispatch).\n signal: dispatchFeed.signal,\n state,\n });\n } finally {\n await lease.release();\n }\n } catch (e) {\n error = e;\n } finally {\n // Phase 3: Unwind the stack in reverse.\n //\n // Every interceptor that entered gets exactly ONE unwind call. That is\n // what makes it safe to acquire something in `enter`, so `abort` falls\n // back to the hook that would have run without it rather than to\n // nothing -- an interceptor that does not know about aborting must\n // still be given the chance to close what it opened.\n //\n // aborted -> abort ?? (error ? error : leave)\n // error -> error ?? nothing\n // otherwise -> leave ?? nothing\n //\n // Which matters because of what `leave` means to the obvious\n // interceptor: enter/begin, leave/commit, error/rollback. Without an\n // `abort` hook that one commits the work of a dispatch that was\n // cancelled half way through -- the same lie the feed used to tell by\n // ending an aborted dispatch on `complete`.\n for (let i = enteredInterceptors.length - 1; i >= 0; i--) {\n const interceptor = enteredInterceptors[i];\n // Read per iteration: an abort landing mid-unwind is reflected by the\n // interceptors that have not run yet, rather than being missed.\n const aborted = dispatchFeed.signal.aborted;\n try {\n if (aborted && interceptor.abort) {\n applyState(\n await container.use(interceptor.deps, (resources) =>\n interceptor.abort(resources, {\n dispatchFeed,\n engineFeed,\n signal: dispatchFeed.signal,\n action: actionInstance,\n state,\n reason: dispatchFeed.reason,\n // Set when the action threw on its way out -- usually\n // because it honoured the signal. There is no `handled()`\n // here: a cancellation cannot be handled into a success,\n // because the work did not happen.\n error,\n })\n )\n );\n } else if (error && interceptor.error) {\n const errorContext = {\n dispatchFeed,\n engineFeed,\n signal: dispatchFeed.signal,\n action: actionInstance,\n state,\n error,\n handled: () => {\n error = null;\n },\n };\n applyState(\n await container.use(interceptor.deps, (resources) =>\n interceptor.error(resources, errorContext)\n )\n );\n } else if (!error && interceptor.leave) {\n applyState(\n await container.use(interceptor.deps, (resources) =>\n interceptor.leave(resources, {\n dispatchFeed,\n engineFeed,\n signal: dispatchFeed.signal,\n state,\n action: actionInstance,\n })\n )\n );\n }\n } catch (e) {\n error = e;\n }\n }\n\n // An aborted dispatch ends on `abort`, whatever the action did on its\n // way out. It did not complete -- it was stopped -- and an action that\n // threw because it honoured the signal threw *because* of the abort, so\n // reporting the throw would name the symptom rather than the cause. The\n // error is carried on the event either way, so nothing is lost.\n if (dispatchFeed.signal.aborted) {\n dispatchFeed.dispatchEvent(\n new DispatchAbortEvent({ reason: dispatchFeed.reason, error })\n );\n } else if (error) {\n dispatchFeed.dispatchEvent(\n new DispatchErrorEvent('error', { error, message: messageOf(error) })\n );\n } else {\n dispatchFeed.dispatchEvent(new Event('complete'));\n }\n }\n });\n\n return dispatchFeed;\n }\n}\n",
38
+ "// Layer 3: queries.\n//\n// Depends on the container seam, and optionally on *anything* with a\n// `dispatch(action)` method for queries that declare a `bootAction` or\n// `killAction`. It does not import the actions layer, so queries can be used\n// with providers alone.\n\nimport { Container } from './providers.js';\nimport { report } from './internal.js';\n\nexport class Query {\n // A query that implements `fetch` and not `boot` is a ONE-SHOT: subscribing to\n // it fetches once, hands the value over, and completes. See QueryController's\n // boot() for why that is the fallback rather than an error.\n boot() {\n throw new Error('boot() not implemented, and no fetch() to fall back to');\n }\n kill() {}\n}\n\n// One live realization of a query instance, shared by all of its observers.\nclass QueryController {\n #store;\n #query;\n #lease = null;\n #booting = null;\n #booted = false;\n #killing = null;\n #received = Promise.withResolvers();\n #hasValue = false;\n #currentValue = undefined;\n #dead = false;\n #bootFeed = undefined;\n #killFeed = undefined;\n\n observers = new Set();\n\n constructor(store, query) {\n this.#store = store;\n this.#query = query;\n this.notify = this.notify.bind(this);\n }\n\n get hasValue() {\n return this.#hasValue;\n }\n\n get currentValue() {\n return this.#currentValue;\n }\n\n // Resolves true once a value has arrived, false if the query died first.\n // A live query that never notifies leaves this pending -- that is what makes\n // peek() on such a query wait rather than fall back to fetch().\n get received() {\n return this.#received.promise;\n }\n\n get bootFeed() {\n return this.#bootFeed;\n }\n\n get killFeed() {\n return this.#killFeed;\n }\n\n // A lifecycle action is fire-and-forget -- nothing is waiting on its feed, so\n // a failure would otherwise vanish. Route it to the same channel as every\n // other unpropagatable error, with enough context to place it.\n #dispatchLifecycleAction(action, label) {\n const feed = this.#store._dispatch(action);\n\n feed.addEventListener(\n 'error',\n (event) => {\n report(\n new Error(\n `${this.#query.constructor.name} ${label} (${action.constructor.name}) failed`,\n { cause: event.error }\n )\n );\n },\n { once: true }\n );\n\n return feed;\n }\n\n notify(nextValue) {\n if (this.#dead) {\n return;\n }\n\n this.#currentValue = nextValue;\n\n if (!this.#hasValue) {\n this.#hasValue = true;\n this.#received.resolve(true);\n }\n\n // Copied so an observer unsubscribing mid-notify doesn't skip its peers.\n for (const observer of [...this.observers]) {\n try {\n observer.next?.(nextValue);\n } catch (err) {\n report(err);\n }\n }\n }\n\n boot() {\n if (this.#booting) {\n return this.#booting;\n }\n\n this.#booting = (async () => {\n try {\n if (this.#query.bootAction) {\n this.#bootFeed = this.#dispatchLifecycleAction(\n this.#query.bootAction,\n 'bootAction'\n );\n }\n\n this.#lease = await this.#store._container.lease(\n this.#query.constructor.deps,\n this.#query.deps\n );\n\n const context = {\n notify: this.notify,\n engineFeed: this.#store._container.feed,\n bootFeed: this.#bootFeed,\n };\n\n // A query that never overrode `boot` is a read: it has one answer and no\n // way to learn of a second. Rather than failing -- which is what the\n // base `boot` would do, and it failed QUIETLY, leaving the subscriber\n // waiting for a value that was never coming -- fetch once, hand the\n // value over, and complete. That is an ordinary single-value\n // observable, so a consumer can subscribe to any query without knowing\n // in advance whether it is live.\n if (this.#query.boot === Query.prototype.boot) {\n if (typeof this.#query.fetch !== 'function') {\n throw new Error(\n `${this.#query.constructor.name} implements neither boot() nor fetch()`\n );\n }\n this.notify(await this.#query.fetch(this.#lease.resources, context));\n // Evicts, completes every observer, and releases the lease -- and\n // evicting is what makes the NEXT subscribe fetch again rather than\n // serving a value that has no way of ever being refreshed.\n await this.#teardown();\n } else {\n await this.#query.boot(this.#lease.resources, context);\n }\n } catch (err) {\n report(err);\n // A query that failed to boot is not a query anyone can wait on.\n await this.#teardown(err);\n } finally {\n this.#booted = true;\n }\n })();\n\n return this.#booting;\n }\n\n kill() {\n if (this.#killing) {\n return this.#killing;\n }\n\n // Never tear down on top of an in-flight boot -- but when boot has already\n // settled, run the teardown eagerly rather than punting it to a later tick.\n this.#killing = this.#booted\n ? this.#runKill()\n : Promise.resolve(this.#booting).then(() => this.#runKill());\n\n return this.#killing;\n }\n\n async #runKill() {\n if (this.#dead) {\n return;\n }\n\n try {\n if (this.#query.killAction) {\n this.#killFeed = this.#dispatchLifecycleAction(\n this.#query.killAction,\n 'killAction'\n );\n }\n if (this.#query.kill) {\n await this.#query.kill(this.#lease?.resources ?? {}, {\n bootFeed: this.#bootFeed,\n killFeed: this.#killFeed,\n engineFeed: this.#store._container.feed,\n notify: this.notify,\n });\n }\n } catch (err) {\n report(err);\n } finally {\n await this.#teardown();\n }\n }\n\n /**\n * @param {any} [error] when the query is ending BECAUSE something failed.\n * Delivered to observers that implement `error`, which matters most for a\n * one-shot read: a fetch that threw must not look to its subscriber like an\n * empty success. Observers that do not implement it still get `complete`,\n * so nothing that worked before behaves differently, and `report` still runs\n * either way so a failure is never simply swallowed.\n */\n async #teardown(error) {\n if (this.#dead) {\n return;\n }\n this.#dead = true;\n\n this.#store._evict(this.#query, this);\n\n const observers = [...this.observers];\n this.observers.clear();\n for (const observer of observers) {\n try {\n if (error !== undefined && observer.error) {\n observer.error(error);\n } else {\n observer.complete?.();\n }\n } catch (err) {\n report(err);\n }\n }\n\n if (!this.#hasValue) {\n this.#received.resolve(false);\n }\n\n const lease = this.#lease;\n this.#lease = null;\n if (lease) {\n await lease.release();\n }\n }\n}\n\n// Realizes queries and keeps one live controller per query instance.\nexport class QueryStore {\n #container;\n #dispatcher;\n #controllers;\n #disposed = false;\n\n constructor({ container, dispatcher, createControllerMap } = {}) {\n this.#container = container ?? new Container();\n this.#dispatcher = dispatcher ?? null;\n this.#controllers = createControllerMap?.() ?? new Map();\n }\n\n get container() {\n return this.#container;\n }\n\n get feed() {\n return this.#container.feed;\n }\n\n // Internal seams used by QueryController.\n get _container() {\n return this.#container;\n }\n\n _dispatch(action) {\n if (!this.#dispatcher) {\n throw new Error(\n 'A query declared a bootAction/killAction but no dispatcher was given to QueryStore'\n );\n }\n return this.#dispatcher.dispatch(action);\n }\n\n _evict(queryInstance, controller) {\n if (this.#controllers.get(queryInstance) === controller) {\n this.#controllers.delete(queryInstance);\n }\n }\n\n #queryDeps(queryInstance) {\n return [queryInstance.constructor.deps, queryInstance.deps];\n }\n\n // Realizes a query. Call `subscribe` on the returned object to use it as an\n // RxJS style observable, or `peek` to get a look at the current value if the\n // query is active, or fetch it otherwise.\n query(queryInstance) {\n if (!(queryInstance instanceof Query)) {\n throw new TypeError('query() requires an instance of Query');\n }\n\n return {\n subscribe: (observerOrNext) => {\n if (this.#disposed) {\n throw new Error('The query store has been disposed');\n }\n\n const observer =\n typeof observerOrNext === 'function'\n ? { next: observerOrNext }\n : observerOrNext || {};\n\n let controller = this.#controllers.get(queryInstance);\n if (controller) {\n controller.observers.add(observer);\n if (controller.hasValue) {\n try {\n observer.next?.(controller.currentValue);\n } catch (err) {\n report(err);\n }\n }\n } else {\n controller = new QueryController(this, queryInstance);\n this.#controllers.set(queryInstance, controller);\n controller.observers.add(observer);\n controller.boot();\n }\n\n let closed = false;\n return {\n get closed() {\n return closed;\n },\n unsubscribe: () => {\n if (closed) {\n return;\n }\n closed = true;\n\n // No complete() for the unsubscriber: withdrawing is not the query\n // ending. complete() stays reserved for a query dying underneath\n // observers that are still attached (see #teardown).\n controller.observers.delete(observer);\n if (controller.observers.size === 0) {\n // Dropped from the registry first, so a subscribe that arrives\n // while the controller is dying gets a fresh one.\n this._evict(queryInstance, controller);\n controller.kill();\n }\n },\n };\n },\n\n // Resolves with the active query's current value, waiting for its first\n // one if it has not emitted yet. If the query is not active -- or dies\n // before emitting -- falls through to the query's fetch().\n //\n // A live query that never emits therefore leaves this pending until it\n // is killed. That is deliberate: peek() on an active query answers from\n // that query, and a query with subscribers is expected to produce a\n // value. Callers that cannot block should race it themselves.\n peek: async () => {\n const controller = this.#controllers.get(queryInstance);\n if (controller && (await controller.received)) {\n return controller.currentValue;\n }\n\n if (typeof queryInstance.fetch !== 'function') {\n throw new TypeError(\n `${queryInstance.constructor.name} is not active and does not implement fetch()`\n );\n }\n\n const lease = await this.#container.lease(...this.#queryDeps(queryInstance));\n try {\n return await queryInstance.fetch(lease.resources, {\n engineFeed: this.#container.feed,\n bootFeed: controller?.bootFeed,\n killFeed: controller?.killFeed,\n });\n } finally {\n await lease.release();\n }\n },\n };\n }\n\n // Kills every live query. Idempotent.\n async dispose() {\n if (this.#disposed) {\n return;\n }\n this.#disposed = true;\n\n // A custom controller map is not required to be enumerable.\n for (const controller of [...(this.#controllers.values?.() ?? [])]) {\n await controller.kill();\n }\n }\n}\n",
39
+ "// The full stack: providers + actions + queries, wired together.\n//\n// `Engine` is a facade. Everything it does is available from the three layers\n// directly; it exists so the common case stays a one-liner.\n\nimport { Container } from './providers.js';\nimport { Dispatcher } from './actions.js';\nimport { QueryStore } from './queries.js';\n\nexport class Engine {\n #container;\n #dispatcher;\n #queries;\n #disposed = false;\n\n constructor({ providers, interceptors, hooks, container, dispatcher, queries } = {}) {\n // Each layer can be supplied pre-built, which is how you swap one out\n // (a stub container in tests, a dispatcher shared with another engine).\n this.#container = container ?? new Container({ providers });\n this.#dispatcher =\n dispatcher ?? new Dispatcher({ container: this.#container, interceptors });\n this.#queries =\n queries ??\n new QueryStore({\n container: this.#container,\n dispatcher: this.#dispatcher,\n createControllerMap: hooks?.createQueryControllersMap,\n });\n }\n\n get container() {\n return this.#container;\n }\n\n get dispatcher() {\n return this.#dispatcher;\n }\n\n get queries() {\n return this.#queries;\n }\n\n get feed() {\n return this.#container.feed;\n }\n\n // Dispatch an action.\n dispatch(actionInstance) {\n return this.#dispatcher.dispatch(actionInstance);\n }\n\n // Realizes a query.\n query(queryInstance) {\n return this.#queries.query(queryInstance);\n }\n\n async dispose() {\n if (this.#disposed) {\n return;\n }\n this.#disposed = true;\n\n // Queries first: killing them releases resources back to the providers\n // that are about to be disposed.\n await this.#queries.dispose();\n await this.#container.dispose();\n }\n}\n",
40
+ "// View state: what the UI is in the middle of doing.\n//\n// Which keybinding is mid-capture, what has been typed into a dialog that has not been\n// submitted, which capabilities are ticked in a plugin review. None of it is drive state —\n// it is thrown away when the dialog closes — but all of it decides what is on screen, and\n// anything that decides what is on screen is engine state. A component reads it through a\n// query and writes it through an action, the same as everything else.\n//\n// The history is worth keeping because it went wrong twice in the same direction. It began\n// as module-level `let`s mutated in place, with a `rerender()` hook threaded through\n// fourteen modules so the leaf that changed one could poke the root into redrawing — data\n// down, invalidation back up out of band. Moving it into a cell fixed the invalidation and\n// left a second version of the same mistake: components still READ it by calling the module\n// during their own render, and two of them WROTE to it there as well, to lazily initialise a\n// default. A render that writes state is a render with a side effect.\n//\n// So this is a resource now, and the lazy-initialise trick is gone: where a component used\n// to write a default on first render, it now computes one and writes nothing until the user\n// does something. `ref` is what makes that possible — it records which dialog instance the\n// value belongs to, so a stale entry is simply ignored rather than needing to be cleared.\n//\n// The holder itself is a slice in bl/state.js; what stays here is how to read one.\n\n/**\n * The slice for `key`, or `fallback` when it belongs to a different dialog instance.\n *\n * Two components keep a draft that must reset when the dialog is reopened. They used to do\n * that by writing the default during the render that noticed the mismatch. Deriving it\n * instead means the render stays a pure function of the state it was given, and the first\n * write happens when the user actually changes something.\n *\n * @param {object} slice the view-state slice from the query\n * @param {string} key\n * @param {object} ref the dialog instance the value must belong to\n * @param {any} fallback\n */\nexport function draftFor(slice, key, ref, fallback) {\n const held = slice?.[key];\n return held && held.ref === ref ? held : { ref, ...fallback };\n}\n\n/** Where a prompt dialog's typed value lives while it is being typed. */\nexport const PROMPT = 'promptValue';\n\n/**\n * Where the plugin review's ticked capabilities live.\n *\n * Named here rather than privately in the component, because the action that performs the\n * install READS it — the dialog is data, so what the user ticked has to be state the action\n * can find rather than something a callback closes over.\n */\nexport const PLUGIN_REVIEW = 'pluginReview';\n\n/**\n * What has been typed into the open prompt, or its initial value.\n *\n * The prompt kept this in a `let` closed over by the render and mutated by the input\n * handler, and handed it back through an `onSubmit` callback — which meant a FUNCTION was\n * living in the dialog spec, and the dialog spec is engine state. Keeping the value here\n * instead lets a prompt carry actions like everything else, and each action reads what was\n * typed rather than being handed it.\n *\n * `ref` ties it to the dialog instance, so reopening starts from the new initial value\n * rather than whatever the last prompt left behind.\n */\nexport function promptValueOf(slice, dialog) {\n const held = slice?.[PROMPT];\n return held && held.ref === dialog ? held.value : (dialog?.value ?? '');\n}\n",
41
+ "// What a plugin package's signature actually means.\n//\n// This is a security classification, not a label. It decided the same four states in two\n// different components — the installed-plugin list and the install-review dialog — with two\n// different sets of words, and the distinction that matters most was the one that drifted:\n//\n// `invalid` is NOT `unverified`. Unverified means nobody signed it, which is the ordinary\n// case for a plugin you got from a friend. Invalid means it WAS signed and the signature\n// does not verify — the bytes are not the bytes that were signed. That is the one state\n// implying someone altered the package, and the list once rendered it in the same amber as\n// the benign case, because the two `if` ladders were maintained separately and one of them\n// was missing a branch.\n//\n// So the classification lives here, once, and the components choose their own wording from\n// `status`. What is a security judgement is in the business layer; how many characters fit\n// in a badge is not.\n\n/**\n * Whether a package may be installed at all, and on what terms.\n *\n * Three answers, because the states differ in kind rather than in degree:\n *\n * - `invalid` is REFUSED. It means the package was signed and the signature does not\n * verify — the bytes are not the bytes that were signed. No development workflow\n * produces that; it means the package was altered in transit or at rest. There is\n * nothing for a user to weigh, so they are not asked.\n *\n * - `unverified` is installable but only DELIBERATELY. Nobody signed it, which is the\n * ordinary state of a plugin you are writing: you cannot sign a package you are still\n * changing. So it stays possible, behind an acknowledgement that says what is being\n * given up — no publisher, no proof the code is what its author shipped.\n *\n * - `signed` carries a real signature whose domain does not vouch for the key. That is a\n * claim to a namespace rather than a proof of one, so it is said prominently and left\n * to the user; refusing it would block a valid publisher whose assetlinks are merely\n * misconfigured.\n *\n * This is also what closes namespace squatting. A package claiming another publisher's\n * domain is unverified by construction — the real domain does not publish its key — so it\n * cannot be installed without the user being told exactly that.\n */\nexport function installPolicyFor(trust) {\n const t = describeTrust(trust);\n if (t.status === 'invalid') {\n return {\n status: t.status,\n allowed: false,\n requiresAcknowledgement: false,\n headline: 'This package has been altered',\n detail: `${t.explanation}. It was signed, and the signature does not match its contents — so it is not what its author published. Trove will not install it.`,\n };\n }\n if (t.status === 'unverified') {\n return {\n status: t.status,\n allowed: true,\n requiresAcknowledgement: true,\n headline: 'Unsigned — for development only',\n detail: 'Nobody has signed this package, so there is no way to tell who wrote it or whether it has been altered since. Install it only if you built it yourself or you trust wherever you got it from.',\n };\n }\n if (t.status === 'signed') {\n return {\n status: t.status,\n allowed: true,\n requiresAcknowledgement: false,\n headline: 'Signed, but the domain does not vouch for the key',\n detail: `${t.explanation}. The signature is real; what is unproven is that ${t.domain || 'the publisher'} authorised it.`,\n };\n }\n return { status: t.status, allowed: true, requiresAcknowledgement: false, headline: null, detail: null };\n}\n\n/**\n * @param {{status?: string, domain?: string, reason?: string}|null} trust\n * @returns {{status: string, tone: string, icon: string, domain: string|null, explanation: string, severity: number}}\n */\nexport function describeTrust(trust) {\n const t = trust || {};\n switch (t.status) {\n case 'verified':\n return {\n status: 'verified', tone: 'verified', icon: 'check', domain: t.domain || null,\n explanation: t.domain\n ? `Signed by a key published at ${t.domain}`\n : 'Signed by a key the publishing domain vouches for',\n severity: 0,\n };\n case 'signed':\n return {\n status: 'signed', tone: 'signed', icon: 'info', domain: t.domain || null,\n explanation: t.reason || 'Signed, but the domain does not vouch for the key',\n severity: 1,\n };\n case 'invalid':\n return {\n status: 'invalid', tone: 'invalid', icon: 'warn', domain: t.domain || null,\n // Said plainly. This is the only state that means tampering rather than absence.\n explanation: t.reason || 'The signature did not verify — this package may have been altered',\n severity: 3,\n };\n default:\n return {\n status: 'unverified', tone: 'unverified', icon: 'warn', domain: t.domain || null,\n explanation: t.reason || 'This plugin is not signed',\n severity: 2,\n };\n }\n}\n",
42
+ "// Install flow: turn an uploaded .zip or a URL into a parsed package, assess its\n// trust (signature + domain verification), and present the pre-install review so\n// the user can make an informed decision before any plugin code runs.\n//\n// Takes the four resources it actually needs rather than the whole `app`. That is what let\n// the last two actions stop leasing `app` — and a lease that names notifications, plugins,\n// workbench and social says what an install touches, where `app` said nothing at all.\n\nimport { parsePackage, fetchPackage, reviewSummary, displayName } from '../platform/pluginPackage.js';\nimport { pluginId } from '@3sln/trove/core/plugins/identity.js';\nimport { installPolicyFor } from './trust.js';\nimport { InstallReviewedPluginAction } from './actions.js';\n\n/**\n * What an install touches. The parameter list below is the same set spelled out, so a lease\n * that forgot one is a missing ARGUMENT at the top of the function rather than an\n * `undefined` several lines in — which is how a missing `overlay` came to be reported to\n * the user as \"Couldn't read the plugin\", about a file that read perfectly.\n *\n * @typedef {{notifications: object, overlay: object, plugins: object, social: object, workbench: object}} InstallResources\n */\n\n/** @param {InstallResources} r */\nexport async function beginInstallFromFile(r, file) {\n try {\n const bytes = new Uint8Array(await file.arrayBuffer());\n await review(r, parsePackage(bytes));\n } catch (err) {\n r.notifications.error(`Couldn't read the plugin: ${err.message}`);\n }\n}\n\n/** @param {InstallResources} r */\nexport async function beginInstallFromUrl(r, url) {\n try {\n const pkg = await fetchPackage(url, (u, o) => fetch(u, o));\n await review(r, pkg);\n } catch (err) {\n r.notifications.error(`Couldn't fetch the plugin: ${err.message}`);\n }\n}\n\n/** @param {InstallResources} r */\nasync function review({ notifications, overlay, plugins, social, workbench }, pkg) {\n const label = displayName(pkg.manifest);\n if (plugins.plugins.has(pluginId(pkg.manifest))) {\n notifications.warn(`“${label}” is already installed.`);\n return;\n }\n // Trust assessment can hit the network (domain assetlinks); do it before review.\n let trust = { status: 'unverified' };\n try {\n trust = await plugins.assessTrust(pkg);\n } catch { /* offline / unreachable */ }\n\n // A tampered package is refused here rather than presented with a warning. The review\n // dialog exists to let someone weigh what a plugin asks for against who is asking; a\n // signature that does not match its contents means the \"who\" is unknown and the contents\n // are not what was signed, so there is nothing to weigh. See installPolicyFor.\n const policy = installPolicyFor(trust);\n if (!policy.allowed) {\n notifications.error(`“${label}” was not installed. ${policy.detail}`, { sticky: true });\n return;\n }\n\n // `installActions`, not an `onInstall` closure. Two docblocks state the invariant —\n // \"Nothing in a dialog spec is callable, which matters because the spec lives in\n // workbench state\" (actions.js) and \"the dialog spec holds no functions\" (overlays.js) —\n // and this dialog was the sole violation. That closure cleared the overlay, moved the\n // workbench, raised a notification and performed the network install, all after the\n // dispatching action's lease had been released and none of it on the feed.\n //\n // The alternative was already here: pluginReview keeps its ticked grants in viewState and\n // dispatches per toggle, so the action needs to carry only `pkg` and `trust` and can read\n // the grants from the key the dialog already writes.\n overlay.set({ dialog: {\n kind: 'plugin-review',\n summary: reviewSummary(pkg, trust),\n policy,\n isAdmin: !!social.get().admin,\n installActions: [new InstallReviewedPluginAction(pkg, trust, label)],\n } });\n}\n",
43
+ "// One tag matcher, for everybody.\n//\n// There were four: this logic in `transformer.js` (post-filtering semantic results), a\n// near-copy in the memory metadata store, a third in the browser (used by the offline\n// path), and SQL in the sqlite store. Each pair \"mirrored\" the others in a comment and\n// diverged in fact:\n//\n// - the client lowercased both operands for `<`/`<=`/`>`/`>=`; the server did not, so\n// `#author:>Bob` against `author: \"alice\"` was false online and true offline;\n// - the sqlite store bound `String(value)` against `json_extract`, which preserves JSON\n// types, so a numeric tag `pages: 120` matched `#pages:!=120` and not `#pages:120`;\n// - the sqlite store treated `present` as `IS NOT NULL`, so a tag explicitly set to\n// `false` counted as present — everywhere else it does not;\n// - the sqlite store never consulted `meta`, which the interface documents as part of\n// what a filter matches.\n//\n// So the semantics live here, once, and the SQL in `metadata/sqlite.js` is written to\n// agree with THIS file rather than with its own history.\n//\n// The rules:\n// present the tag exists and is not `false` and not `''`\n// = / != numeric compare when BOTH sides are numbers, else case-insensitive text\n// < <= > >= same, and text comparison is case-insensitive (it was not on the server,\n// which is the one difference a user could actually observe between an\n// online and an offline search)\n\n/** A node's filterable properties: `meta`, overlaid by its merged tags. */\nexport function tagProps(node, mergedTags = null) {\n return { ...(node?.meta || {}), ...(mergedTags || node?.tags || {}) };\n}\n\n/** Does one value satisfy one parsed filter? */\nexport function matchesFilter(value, filter) {\n if (filter.present) return value != null && value !== false && value !== '';\n if (value == null) return false;\n const na = Number(value);\n const nb = Number(filter.value);\n // `Number('')` is 0, which would make an empty string compare as a number — hence\n // the explicit emptiness checks rather than `!Number.isNaN` alone.\n const numeric = value !== '' && value !== true && value !== false\n && filter.value !== '' && filter.value != null\n && !Number.isNaN(na) && !Number.isNaN(nb);\n const x = numeric ? na : String(value).toLowerCase();\n const y = numeric ? nb : String(filter.value).toLowerCase();\n switch (filter.op) {\n case '!=': return x !== y;\n case '<': return x < y;\n case '<=': return x <= y;\n case '>': return x > y;\n case '>=': return x >= y;\n default: return x === y;\n }\n}\n\n/** Does a node satisfy every filter? `mergedTags` when the caller already computed them. */\nexport function matchTagFilters(node, filters, mergedTags = null) {\n const props = tagProps(node, mergedTags);\n return (filters || []).every((f) => matchesFilter(props[f.key], f));\n}\n",
44
+ "// Parse `#tag` / `#key:op:value` filter tokens out of a launcher query and match\n// nodes against them. Grammar (each token, space-separated):\n// #tag → the property/tag is present\n// #key:=v #key:!=v #key:<v #key:<=v #key:>v #key:>=v → compare\n// #key:v → equality shorthand (same as #key:=v)\n// Values may be \"quoted\" to include spaces. Comparisons are numeric when both\n// sides parse as numbers, otherwise case-insensitive string comparisons.\n\nimport { matchTagFilters } from '@3sln/trove/core/search/tagMatch.js';\n\nconst TOKEN = /#([\\w.-]+)(?::(<=|>=|!=|=|<|>)?(\"[^\"]*\"|[^#\\s]+)?)?/g;\n\n/** @returns {{ text: string, filters: {key,op,value,present}[] }} */\nexport function parseTagQuery(query) {\n const filters = [];\n let text = query;\n for (const m of query.matchAll(TOKEN)) {\n const [, key, op, rawValue] = m;\n const value = rawValue && rawValue.startsWith('\"') ? rawValue.slice(1, -1) : rawValue;\n filters.push(value == null || value === ''\n ? { key, present: true }\n : { key, op: op || '=', value, present: false });\n text = text.replace(m[0], ' ');\n }\n return { text: text.replace(/\\s+/g, ' ').trim(), filters };\n}\n\n/**\n * True if `node` satisfies ALL filters (AND).\n *\n * Delegates to core rather than re-implementing. This file had its own copy, and the\n * two drifted on the ordering operators — the client lowercased both operands, the\n * server did not — so `#author:>Bob` against `author: \"alice\"` answered differently\n * online and offline. Same query, same drive, different files.\n */\nexport function matchesTagFilters(node, filters) {\n if (!filters || !filters.length) return true;\n return matchTagFilters(node, filters);\n}\n\n/** Short human label for a filter (for the results heading). */\nexport function filterLabel(f) {\n return f.present ? `#${f.key}` : `#${f.key}:${f.op}${f.value}`;\n}\n",
45
+ "// One place that knows how to classify a file by type — extension extraction and a\n// single format table. Previously the ext/mime lists were re-derived (and drifted)\n// across openers.extOf, contributions.matchesSelector, iconForNode, and offline.isTexty;\n// now the icon shown, the \"is this text?\" decision, and the type label all agree.\n\n/** The extension (\".pdf\") for a node, lowercased, or '' if none. */\nexport function extOf(node) {\n const name = (node?.name || '').toLowerCase();\n return name.includes('.') ? name.slice(name.lastIndexOf('.')) : '';\n}\n\n// Category → { mime: prefixes/exact it matches, ext: extensions }. Order matters:\n// kindOf checks these top-down.\nconst CATEGORIES = [\n { kind: 'audio', icon: 'file-audio', mime: ['audio/'], ext: ['.mp3', '.flac', '.wav', '.opus', '.ogg', '.m4a', '.m4b'] },\n { kind: 'image', icon: 'file-image', mime: ['image/'], ext: ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', '.avif'] },\n { kind: 'video', icon: 'file-video', mime: ['video/'], ext: ['.mp4', '.webm', '.mkv', '.mov'] },\n {\n kind: 'text', icon: 'file-text', mime: ['text/', 'application/json'],\n ext: ['.txt', '.md', '.markdown', '.json', '.js', '.mjs', '.ts', '.jsx', '.tsx', '.css', '.html',\n '.xml', '.yaml', '.yml', '.toml', '.ini', '.log', '.csv', '.py', '.rb', '.go', '.rs', '.sh', '.c', '.h', '.cpp', '.java'],\n },\n];\n\nfunction matchesCategory(cat, ext, ct) {\n if (cat.ext.includes(ext)) return true;\n // A mime entry ending in '/' is a prefix (audio/), otherwise an exact type.\n return cat.mime.some((m) => (m.endsWith('/') ? ct.startsWith(m) : ct === m));\n}\n\n/** Classify an item → 'audio'|'image'|'video'|'text'|'file'. */\nexport function kindOf(node) {\n const ext = extOf(node);\n const ct = node?.contentType || '';\n for (const cat of CATEGORIES) if (matchesCategory(cat, ext, ct)) return cat.kind;\n return 'file';\n}\n\nconst ICONS = { ...Object.fromEntries(CATEGORIES.map((c) => [c.kind, c.icon])), file: 'file' };\n\n/** The icon name for a node, derived from its kind. */\nexport function iconForKind(node) {\n return ICONS[kindOf(node)] || 'file';\n}\n\n/** Whether a node holds indexable text (drives offline text extraction). */\nexport function isTexty(node) {\n return kindOf(node) === 'text';\n}\n",
46
+ "// Opener choice: which viewer opens a file when several can. Built-in and plugin\n// openers register the same way (a selector + priority), so a file can match more\n// than one — e.g. a plugin PDF viewer alongside a built-in, or a rich player vs the\n// plain audio player for an .m4a. When that happens and the user hasn't expressed a\n// preference, we ask; their choice can be remembered per file type.\n//\n// Preferences live in settings under `openers.associations`: a map from a *type key*\n// (an extension like \".pdf\", an exact mime, or a \"type/*\" wildcard) to an opener id.\n\nimport { selectorMatches } from '@3sln/trove/core/util.js';\nimport { extOf } from './fileType.js';\n\nexport const ASSOC_KEY = 'openers.associations';\n\nexport { extOf };\n\n/**\n * One opener as the chooser and the switcher need to see it: what it is called, what it\n * claims, and where it came from.\n *\n * `source` is resolved here because it needs the plugin host to answer, which a component\n * has no business holding. `match` stays so the selector can be applied later, by\n * `openersFor`, against a node the caller already has.\n *\n * No `component`, only because nothing on this path renders — both callers are picking\n * between openers, not drawing with one. (A renderer would be fine to pass: it is a pure\n * vnode builder. See the `views` query, which does exactly that.)\n */\nexport function describeOpener(opener, plugins) {\n return {\n id: opener.id,\n title: opener.title ?? opener.name ?? opener.id,\n match: opener.match ?? null,\n priority: opener.priority ?? 0,\n pluginId: opener.pluginId ?? null,\n source: opener.pluginId\n ? (plugins?.plugins?.get(opener.pluginId)?.manifest?.displayName || opener.pluginId)\n : 'Built-in',\n };\n}\n\n/**\n * Which of these openers claim this node, best first.\n *\n * Pure, and deliberately so — see the `openers` query. Every reactive decision (when-clause,\n * plugin health, priority order) has already been made; all that is left is running a\n * selector over a file, which needs nothing but its two arguments.\n */\nexport function openersFor(openers, node) {\n return (openers || []).filter((o) => selectorMatches(o.match, node));\n}\n\n/** The canonical type key we remember a choice under: prefer extension, else mime. */\nexport function typeKeyFor(node) {\n return extOf(node) || node?.contentType || '';\n}\n\n/** A human label for the type, for \"Always use … for {label}\". */\nexport function typeLabelFor(node) {\n const ext = extOf(node);\n if (ext) return `${ext} files`;\n const mime = node?.contentType || '';\n return mime ? `${mime} files` : 'this file type';\n}\n\n/**\n * All openers that can handle this node right now (selector + when + availability),\n * best (highest priority) first — for an ACTION, which holds the resources to ask.\n *\n * The render layer gets the same answer the other way round: the `openers` query resolves\n * when/availability, `openersFor` applies the selector. Both end at `describeOpener`, so\n * the opener-chooser dialog looks the same whichever side opened it.\n */\nexport function availableOpeners(r, node) {\n return r.contributions\n .openersFor(node)\n .filter((o) => (!o.when || r.context.evaluate(o.when)) && r.plugins.isAvailable(o))\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))\n .map((o) => describeOpener(o, r.plugins));\n}\n\n/** The remembered opener id for a node's type (ext → exact mime → type/* ), or null. */\nexport function rememberedOpenerId(r, node) {\n const assoc = r.settings.get(ASSOC_KEY) || {};\n const ext = extOf(node);\n const mime = node?.contentType || '';\n const wild = mime.includes('/') ? `${mime.slice(0, mime.indexOf('/') + 1)}*` : '';\n return (ext && assoc[ext]) || (mime && assoc[mime]) || (wild && assoc[wild]) || null;\n}\n\n/**\n * The associations with one type key changed, or removed with a null openerId.\n *\n * Returns the next map rather than writing it: the write is `RememberOpenerAction`'s, and\n * keeping the arithmetic separate from the effect is what lets both the settings screen and\n * the opener chooser reach it without either touching `settings`.\n */\nexport function withAssociation(assoc, typeKey, openerId) {\n const next = { ...(assoc || {}) };\n if (openerId) next[typeKey] = openerId;\n else delete next[typeKey];\n return next;\n}\n",
47
+ "// `trove:` — the URI that addresses an ITEM in the drive.\n//\n// There is no folder hierarchy. A collection is a flat namespace of uniquely-named\n// items, and structure comes from items linking to each other — a markdown document\n// that links its sources is what a folder used to be, except it can say *why* things\n// belong together, an item can appear in several of them, and the grouping is\n// searchable content rather than an invisible container.\n//\n// So a link has to be something a person can type into a markdown file:\n//\n// trove:default?name=sailing.txt canonical, by name\n// trove:default/sailing.txt shorthand for the same thing\n// trove:default?id=fil_01H2X8F4KQ by id — survives a rename, unreadable\n//\n// The selector is EXPLICIT (`?name=` vs `?id=`) rather than inferred from the shape\n// of the segment: a name that happens to look like an id would otherwise resolve to\n// something else entirely, and a link that silently retargets is worse than one that\n// visibly breaks. The `/name` shorthand is unambiguous for the same reason — that\n// slot only ever means a name.\n//\n// Names are unique per collection, which is what makes `?name=` resolve to exactly one\n// item. Renaming therefore breaks inbound links, on purpose and visibly: the alternative\n// is opaque ids nobody can hand-write, which would put linking back in the UI's hands.\n// `?id=` is there for links a tool inserts, where stability matters more than legibility.\n\nimport { TroveError } from './errors.js';\n\nexport const TROVE_SCHEME = 'trove:';\n\n// An item name is capped at 255 chars (isValidItemName), so a longer selector can never\n// resolve to anything. Refusing it at parse time keeps garbage out of the links index\n// rather than storing kilobytes that will never match.\nconst MAX_SELECTOR = 255;\n// How many distinct links one item may record. A document is a grouping, not a database\n// dump; past this the value is in the search index, not the link graph. Not exported: it\n// is the default for `extractTroveLinks`'s `limit`, and nothing outside chose a different\n// one — an exported cap nobody passes reads as a knob when it is a constant.\nconst MAX_LINKS_PER_ITEM = 500;\n\n// Collection ids are slugs (see CollectionService); a name is anything but a slash,\n// since the pathname shorthand has to stop somewhere.\nconst COLLECTION_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;\n\n/**\n * Parse a `trove:` URI into `{ collection, by: 'name'|'id', value }`, or null if it\n * isn't one. Never throws — callers parse untrusted document text with this, where a\n * malformed link is a thing to render as broken, not an exception.\n */\nexport function parseTroveUri(uri) {\n if (typeof uri !== 'string' || !uri.toLowerCase().startsWith(TROVE_SCHEME)) return null;\n let url;\n try {\n url = new URL(uri);\n } catch {\n return null;\n }\n // `trove:default/sailing.txt` → pathname \"default/sailing.txt\"; the slash-free case\n // is `trove:default?name=…`, where the whole pathname is the collection.\n const path = url.pathname;\n const slash = path.indexOf('/');\n const collection = slash < 0 ? path : path.slice(0, slash);\n if (!COLLECTION_RE.test(collection)) return null;\n\n const id = url.searchParams.get('id');\n const name = url.searchParams.get('name');\n let shorthand = '';\n if (slash >= 0) {\n // A malformed percent-escape is a malformed link, not an exception to propagate\n // out of a document render.\n try { shorthand = decodeURIComponent(path.slice(slash + 1)); } catch { return null; }\n }\n\n // Both selectors at once is a contradiction, not something to silently pick between.\n if (id != null && (name != null || shorthand)) return null;\n const by = id != null ? 'id' : 'name';\n const value = id != null ? id : (name != null ? name : shorthand);\n if (!value || value.length > MAX_SELECTOR) return null;\n return { collection, by, value };\n}\n\n/** Whether `uri` is a well-formed trove: reference. */\nexport function isTroveUri(uri) {\n return parseTroveUri(uri) != null;\n}\n\n/**\n * The canonical string for one address. The ONE place the template lives.\n *\n * There were five hand-written copies of it, which is five chances to get the encoding or\n * the separator subtly different — and `canonicalTroveUri`, whose whole docstring is\n * \"two links that address the same item by the same selector must produce the same\n * string\", was one of the copies rather than the source.\n */\nexport function formatTroveUri({ collection, by, value }) {\n return `${TROVE_SCHEME}${collection}?${by}=${encodeURIComponent(value)}`;\n}\n\n/**\n * Build a `trove:` URI. `by` defaults to 'name' — the legible form, which is what\n * gets written into documents; pass 'id' for a link that must survive a rename.\n */\nexport function troveUri(node, by = 'name') {\n const collection = node?.collectionId || 'default';\n if (by === 'id') {\n if (!node?.id) throw TroveError.invalid('trove: link by id needs a node id');\n return formatTroveUri({ collection, by: 'id', value: node.id });\n }\n if (!node?.name) throw TroveError.invalid('trove: link by name needs a node name');\n return formatTroveUri({ collection, by: 'name', value: node.name });\n}\n\n/**\n * Every distinct `trove:` reference in a block of text, in first-appearance order.\n *\n * Deliberately scans raw text rather than parsing markdown: a link is just as real in\n * an HTML `href`, a bare mention, or a front-matter list, and the point of extraction\n * is to know what an item references — not to reproduce one renderer's idea of a link.\n * Trailing punctuation is trimmed so `see trove:default/a.md.` doesn't capture the dot.\n */\nexport function extractTroveLinks(text, { limit = MAX_LINKS_PER_ITEM } = {}) {\n if (typeof text !== 'string' || !text) return [];\n const out = [];\n const seen = new Set();\n // Stop at whitespace and at the delimiters that wrap a URL in markdown/HTML.\n const re = /trove:[^\\s<>\"'`)\\]}]+/gi;\n for (const m of text.matchAll(re)) {\n if (out.length >= limit) break;\n const raw = m[0].replace(/[.,;:!?]+$/, '');\n const parsed = parseTroveUri(raw);\n if (!parsed) continue;\n const canonical = formatTroveUri(parsed);\n if (seen.has(canonical)) continue;\n seen.add(canonical);\n out.push({ uri: canonical, raw, ...parsed });\n }\n return out;\n}\n\n/**\n * The canonical form of a reference, for storing and comparing. Two links that address\n * the same item by the same selector must produce the same string, or backlinks would\n * miss `trove:default/a.md` when the target stored `trove:default?name=a.md`.\n */\nexport function canonicalTroveUri(uri) {\n const p = parseTroveUri(uri);\n return p ? formatTroveUri(p) : null;\n}\n\n/** Both canonical forms an item can be addressed by — what a backlink query looks for. */\nexport function troveUrisFor(node) {\n const out = [];\n if (node?.collectionId && node?.name) out.push(troveUri(node, 'name'));\n if (node?.collectionId && node?.id) out.push(troveUri(node, 'id'));\n return out;\n}\n\n// --- shareable web links -------------------------------------------------------\n//\n// `trove:` addresses an item INSIDE the drive: it is what one document writes to link\n// another, and it means nothing to a browser. A share link is the other half — a URL you\n// can paste into a message so that someone else's browser opens the same item.\n//\n// They are deliberately the same addressing, not two competing schemes. A share link is a\n// `trove:` URI wearing an http(s) coat: same collection, same explicit `name`-or-`id`\n// selector, same refusal to infer which one you meant. So anything that can already\n// resolve a `trove:` URI can resolve a share link by parsing it back, and a rename breaks\n// both in the same visible way rather than one silently retargeting.\n//\n// The path form — /c/<collection>/i/<selector> — rather than the query form\n// `?coll=&item=`. Both put the ids in the URL and therefore in server logs and browser\n// history, so that is not the difference; the path reads as a location, survives being\n// truncated in a chat client more gracefully, and leaves the query string free for the\n// things that genuinely are parameters.\n//\n// Nothing secret ever rides in one. An encrypted collection's key is not in the link and\n// must not be: a link is pasted into chats, logged by proxies, and kept in history\n// forever. The recipient gets the item because they are allowed the collection, which is\n// the same rule as everywhere else here.\n\n/** The path a share link uses. Exported so a client router and the server agree. */\nexport const SHARE_PATH = '/c';\n\n/**\n * A URL that opens this item in a browser.\n *\n * @param {object} node\n * @param {string} [origin] where the drive is served; omitted gives a root-relative link\n * @param {'name'|'id'} [by] `name` reads better and breaks on rename; `id` is the reverse\n */\nexport function shareUrl(node, origin = '', by = 'name') {\n if (!node?.collectionId) throw TroveError.invalid('An item needs a collection to be linked to');\n const selector = by === 'id'\n ? `id:${node.id}`\n : encodeURIComponent(node.name);\n if (!selector || (by === 'id' && !node.id)) throw TroveError.invalid('Nothing to link to');\n const path = `${SHARE_PATH}/${encodeURIComponent(node.collectionId)}/i/${selector}`;\n return origin ? `${String(origin).replace(/\\/$/, '')}${path}` : path;\n}\n\n/**\n * Read a share link back, from a full URL or just a path.\n *\n * Returns the same shape `parseTroveUri` does, so a caller resolves either without caring\n * which it was handed. Null rather than a throw: this parses whatever was in the address\n * bar, and a URL that is not a share link is an ordinary page, not an error.\n */\nexport function parseShareUrl(url) {\n let path;\n try {\n path = url.startsWith('/') ? url : new URL(url).pathname;\n } catch {\n return null;\n }\n const m = /^\\/c\\/([^/]+)\\/i\\/(.+)$/.exec(path);\n if (!m) return null;\n let collection;\n let raw;\n try {\n collection = decodeURIComponent(m[1]);\n raw = decodeURIComponent(m[2]);\n } catch {\n return null; // a malformed escape is not a link to anything\n }\n if (!COLLECTION_RE.test(collection)) return null;\n // `id:` is the explicit selector, mirroring `?id=` — a name is never guessed at just\n // because it happens to look like an id.\n const byId = raw.startsWith('id:');\n const value = byId ? raw.slice(3) : raw;\n if (!value || value.length > MAX_SELECTOR) return null;\n return { collection, by: byId ? 'id' : 'name', value };\n}\n\n/** The `trove:` URI a share link denotes — the two are the same address. */\nexport function troveUriFromShareUrl(url) {\n const parsed = parseShareUrl(url);\n if (!parsed) return null;\n return formatTroveUri(parsed);\n}\n",
48
+ "// What is left of the data services, plus the derivations that were methods on them.\n//\n// The explorer, search and API-key services were state bags — a `state`, a `cell`, and a\n// `set` that wrote both — and are slices now (bl/state.js). TransfersService stays,\n// because it holds things a state snapshot cannot: AbortControllers, per-file retry\n// thunks closing over the File itself, and a projection into the activity list.\n//\n// The functions below were METHODS on those bags. They are derivations, so they belong to\n// whoever is asking rather than to whatever happens to hold the data.\n\nimport { cell } from '../runtime.js';\n\n\n/**\n * The nodes the selection refers to — a pure function of explorer state.\n *\n * It was a method, which meant every caller reached for the service to ask a question about\n * data it could already see. As a function it can be used two ways without either being a\n * back door: the explorer QUERY folds it into the view, so the UI is handed the answer; and\n * an effect that needs it right now computes it from the state it already holds.\n *\n * Resolving ids against `items` only finds rows on the LOADED PAGE of the CURRENT\n * collection — and the launcher's rows come from search (which the server scopes to every\n * readable collection) and from recents (which survive a collection switch). So every row\n * reached by searching resolved to nothing, and rename / move-to-trash / copy-link returned\n * silently while `explorer.hasSelection` said there was a selection. Preferring the nodes\n * the selecting caller already held fixes the whole class; the `items` lookup stays for\n * callers that only have ids.\n */\nexport function selectedNodesOf(state) {\n // Tolerant of a partial state: a view is computed on every emission, including the first\n // one, and a projection that throws takes the whole query down rather than the field.\n const selection = state?.selection || [];\n const held = state?.selectionNodes;\n if (held?.length) return held.filter((n) => selection.includes(n.id));\n return (state?.items || []).filter((i) => selection.includes(i.id));\n}\n\n\n\n/**\n * Uploads in flight.\n *\n * This owns the DETAIL an upload needs and a generic task doesn't — bytes moved, an\n * AbortController, per-file retry. It also projects each transfer into ActivityService\n * so the drive has ONE list of \"what is happening\", covering work on both sides of the\n * wire: an upload running in this browser and a reindex running on the server show up\n * together, because a user doesn't care which machine is busy.\n *\n * The projection is one-way and this stays the owner. Two writable copies of the same\n * fact is how they drift.\n */\nexport class TransfersService {\n #state;\n\n /** @param {import('./activity.js').ActivityService} [activity] */\n constructor(activity = null) {\n this.#state = { items: [] }; // { id, name, direction, ratio, loaded, total, status, error, retryable }\n this.cell = cell(this.#state);\n this._controllers = new Map();\n this.activity = activity;\n this._tasks = new Map(); // transfer id -> activity task handle\n // How to run this transfer again. Held here rather than in state because it closes\n // over the File itself, which is not something a state snapshot should carry.\n //\n // It exists because automatic retry cannot cover everything: a lost upload session is\n // `notFound`, which is correctly classified non-retryable and will never succeed on\n // its own no matter how many times it is tried. Someone has to decide to start over,\n // and the alternative is asking the user to find the file and drag it in again.\n this._retries = new Map();\n }\n /** The value, for whoever is about to decide something from it. See bl/state.js: one\n * value, one way to read it — a public `state` field is a second, writable door. */\n get() {\n return this.#state;\n }\n\n observe() {\n return this.cell;\n }\n #emit() {\n this.cell.setValue(this.#state);\n }\n /**\n * @param {{retry?: () => Promise<any>}} [opts] how to run this transfer again, if it can be\n */\n start(id, name, total, controller, { retry = null } = {}) {\n this._controllers.set(id, controller);\n if (retry) this._retries.set(id, retry);\n this.#state = {\n items: [...this.#state.items, {\n id, name, direction: 'up', ratio: 0, loaded: 0, total, status: 'active', error: null,\n // Surfaced in state so the tray renders from a snapshot rather than interrogating\n // the service — it is a fact about the row, like `status`.\n retryable: !!retry,\n }],\n };\n this.#emit();\n this.#task(id, name, total);\n }\n\n #task(id, name, total) {\n const task = this.activity?.start({\n kind: 'transfer', title: `Uploading ${name}`, total: total || null, unit: 'bytes',\n onCancel: () => this.cancel(id),\n });\n if (task) this._tasks.set(id, task);\n }\n\n /**\n * Run a failed transfer again, in place.\n *\n * The same row rather than a new one: a retry is another attempt at the thing the user\n * already asked for, and a tray that grew an entry per attempt would report one upload\n * as four.\n */\n retry(id) {\n const again = this._retries.get(id);\n if (!again) return null;\n const item = this.#state.items.find((t) => t.id === id);\n if (!item || item.status === 'active') return null;\n return again();\n }\n\n /** Put an existing row back into flight — see `retry`. */\n restart(id, controller) {\n this._controllers.set(id, controller);\n const item = this.#state.items.find((t) => t.id === id);\n this.#state = {\n items: this.#state.items.map((t) => (t.id === id\n ? { ...t, status: 'active', error: null, ratio: 0, loaded: 0 }\n : t)),\n };\n this.#emit();\n // A fresh activity task: the previous one already ended as failed, and reporting\n // progress into a finished task would leave the panel showing a failure that is\n // actively being retried.\n this.#task(id, item?.name || 'file', item?.total || null);\n }\n progress(id, { loaded, total, ratio }) {\n this.#state = { items: this.#state.items.map((t) => (t.id === id ? { ...t, loaded, total, ratio } : t)) };\n this.#emit();\n this._tasks.get(id)?.progress({ done: loaded, total: total || null });\n }\n finish(id, status = 'done', error = null) {\n this.#state = { items: this.#state.items.map((t) => (t.id === id ? { ...t, status, error, ratio: status === 'done' ? 1 : t.ratio } : t)) };\n this._controllers.delete(id);\n this.#emit();\n const task = this._tasks.get(id);\n if (task) {\n if (status === 'done') task.succeed();\n else if (status === 'cancelled') task.cancel();\n else task.fail(error || new Error('Upload failed'));\n this._tasks.delete(id);\n }\n if (status === 'done') setTimeout(() => this.dismiss(id), 4000);\n }\n cancel(id) {\n this._controllers.get(id)?.abort();\n this.finish(id, 'cancelled');\n }\n dismiss(id) {\n this.#state = { items: this.#state.items.filter((t) => t.id !== id) };\n this._retries.delete(id);\n this.#emit();\n }\n clearDone() {\n const kept = this.#state.items.filter((t) => t.status === 'active');\n const keptIds = new Set(kept.map((t) => t.id));\n // Drop the retry thunks of the rows that just left, so a dismissed upload does not\n // hold its File alive for the rest of the session.\n for (const id of [...this._retries.keys()]) if (!keptIds.has(id)) this._retries.delete(id);\n this.#state = { items: kept };\n this.#emit();\n }\n}\n\n\n/**\n * The API-key draft as the API wants it, or null when it would grant nothing.\n *\n * A pure function rather than a method, for the same reason as `selectedNodesOf`: it is a\n * derivation, so it belongs to the view that shows it and to the action that submits it,\n * not to the resource that happens to hold the draft.\n */\nexport function draftScopesOf(state) {\n const caps = state?.draft?.caps || {};\n const scopes = Object.entries(caps)\n .filter(([, list]) => list.length)\n .map(([collectionId, capabilities]) => ({ collectionId, capabilities }));\n return scopes.length ? scopes : null;\n}\n\n\n/**\n * The collection switcher's menu, derived from what the explorer knows.\n *\n * A pure function for the same reason as `selectedNodesOf`: it answers a question about\n * state, so it belongs to the view that shows it. It used to be a closure hung on `app` by\n * `registerCommands` — reachable only through that one field, and impossible to see from\n * the component that rendered it.\n *\n * Items carry `actions`, like every other menu item; see ui/activate.js.\n *\n * @param {object} state explorer state\n * @param {(id?: string) => object} switchTo builds the action for picking a collection\n * @param {() => object} create builds the action for making a new one\n */\n/**\n * The administration screen's row per collection.\n *\n * Built here rather than in the component for the same reason `collectionMenuOf` is: these\n * rows carry ACTIONS, and deciding which actions a collection offers is a question about\n * the collection, not about rendering. A component that assembled them would have to know\n * that rotation lives behind Settings and that scanning applies to the OPEN collection.\n *\n * `scan` and `rotate` are sequenced pairs — switch first, then do the thing — because both\n * operate on whatever is open. That is what makes them work from a screen that lists every\n * collection rather than only the current one. Rotation routes to Settings rather than\n * starting one: the estimate and the confirmation live there, and a rotation begun without\n * seeing its cost is exactly the button nobody should have.\n */\nexport function collectionAdminOf(state, { open, scan, rotate, create, access }) {\n const current = state?.collectionId;\n const rows = (state?.collections || []).map((c) => ({\n id: c.id,\n name: c.name || c.id,\n driver: c.driver || 'unknown',\n system: !!c.system,\n current: c.id === current,\n // `describeEncryption` gives the fingerprint and nothing secret, so this is safe to show\n // and is the only way to tell two keys apart across a rotation.\n fingerprint: c.encryption?.fingerprint || null,\n encrypted: !!c.encryption,\n capabilities: c.capabilities || [],\n actions: {\n open: [open(c.id)],\n scan: [open(c.id), scan()],\n rotate: c.encryption ? [open(c.id), rotate()] : null,\n // Access needs no switch: the ACL is read by collection id, not by what is open.\n access: c.capabilities?.includes('admin') ? [access(c.id)] : null,\n },\n }));\n return { rows, canCreate: !!state?.canCreateCollection, create: [create()] };\n}\n\nexport function collectionMenuOf(state, switchTo, create) {\n // No fallback: this only decides which row gets a tick, and with nothing open the answer\n // is that none of them do. `|| 'default'` ticked a collection the user had not chosen,\n // and on a drive with one actually called \"default\", the wrong one.\n const current = state?.collectionId;\n const items = (state?.collections || []).map((c) => ({\n label: c.name || c.id,\n icon: c.id === current ? 'check' : 'files',\n actions: [switchTo(c.id)],\n }));\n if (state?.canCreateCollection) {\n if (items.length) items.push({ sep: true });\n items.push({ label: 'New collection…', icon: 'plus', actions: [create()] });\n }\n return items;\n}\n",
49
+ "// The two things only the browser can do: ask for a file, and save one.\n//\n// These are effects, so they are reached from actions rather than from a render — but they\n// are effects on the DOCUMENT rather than on the drive, which is why they live in\n// `platform` and not in `bl`. An action that needs a file from the user calls in here; the\n// action is still the thing that decides what happens to it.\n//\n// They were private to bl/commands.js, where the command handlers that used them lived.\n\n/**\n * Open a native file picker. Resolves with the chosen files, or `null` if cancelled.\n *\n * A PROMISE rather than a callback, because the action that opens the picker has to be able\n * to wait for it. It could not before: `execute` returned while the OS dialog was still on\n * screen, ngin released the leases in its `finally`, the feed emitted `complete` for an\n * upload that had not begun, and the callback then used `engine` and `explorer` afterwards.\n *\n * SETTLING ON BOTH PATHS is the whole difficulty, and the reason this shape was not taken\n * earlier: cancelling fires no `change` event at all. It is detected the only way the\n * platform allows — the OS dialog returns focus to the window, and after a short grace the\n * input still holds no files. Both paths go through `done`, and `resolve` is idempotent, so\n * whichever happens first settles the promise and the other is a no-op. A picker that could\n * fail to settle would hold its action's lease forever and never emit a terminal event,\n * which is strictly worse than the early `complete` this replaces.\n *\n * The hidden `<input>` is removed on both paths too, so a cancelled picker does not leak\n * one per attempt.\n */\nfunction pick(configure) {\n return new Promise((resolve) => {\n const input = document.createElement('input');\n input.type = 'file';\n configure(input);\n input.style.display = 'none';\n document.body.appendChild(input);\n const done = (files) => {\n resolve(files);\n input.remove();\n window.removeEventListener('focus', onFocus);\n };\n const onFocus = () => setTimeout(() => { if (!input.files.length) done(null); }, 300);\n input.addEventListener('change', () => done(input.files), { once: true });\n window.addEventListener('focus', onFocus);\n input.click();\n });\n}\n\n/** @returns {Promise<FileList|null>} */\nexport function pickFiles() {\n return pick((input) => { input.multiple = true; });\n}\n\n/** @returns {Promise<File|null>} */\nexport function pickZip() {\n return pick((input) => { input.accept = '.zip,application/zip'; }).then((files) => files?.[0] ?? null);\n}\n\n/** Hand a URL to the browser as a download. */\nexport function triggerDownload(url, name) {\n const a = document.createElement('a');\n a.href = url;\n a.download = name || '';\n document.body.appendChild(a);\n a.click();\n a.remove();\n}\n",
50
+ "// The drive's own state, as named slices.\n//\n// These were classes: an `ExplorerService`, a `SearchClientService`, an `ApiKeysService`,\n// each holding a `state` field, a `cell`, and a `set` that wrote both. Nothing else. A\n// service should cover something complex and offer it through a narrow door — these\n// covered an object.\n//\n// Two things came of that shape and both are gone with it.\n//\n// TWO DOORS. Actions read `.state` and queries read `.cell`, and the two are only equal by\n// habit: most services wrote `this.state = {...}; this.cell.setValue(this.state)`, but not\n// all did, and `settings` still has a cell holding `effective()` and no `state` field at\n// all. A slice has one value and one way to read it.\n//\n// LOGIC IN THE HOLDER. `toggleCap` computed a capability set inside the service while an\n// action stood in front of it forwarding two arguments — and dropped one of them, which is\n// how a minted key came to be rejected by the server. Arithmetic over state belongs to the\n// action that decides to change it; the slice only holds.\n//\n// Each slice is still its OWN provider, so `static deps = ['explorer']` keeps meaning what\n// it says. A single `appState` covering everything would put the whole drive back behind\n// one lease, which is what naming the resources individually was for.\n\nimport { cell } from '../runtime.js';\n\n/**\n * One named piece of the drive's state.\n *\n * `set` merges, because every caller was already merging and doing it here removes the\n * chance of a caller replacing a slice by forgetting to spread it. There is no `replace`:\n * one existed for \"the cases that genuinely mean all of it\" and no caller ever turned out\n * to mean that, so a slice has exactly one way to be written.\n *\n * @param {object} initial\n */\nexport function slice(initial = {}) {\n const held = cell(initial);\n return {\n /** The cell, for a query to watch. */\n observe: () => held,\n /** The value, for an action about to decide something from it. */\n get: () => held.getValue(),\n /** Merge a patch in. A new object every time — a cell compares with Object.is. */\n set: (patch) => held.setValue({ ...held.getValue(), ...patch }),\n };\n}\n\n/** Items, selection, the open collection, and the gate. */\nexport const explorerState = (settings) => slice({\n items: [], loading: false, error: null,\n selection: [], sort: settings.get('explorer.sort'), order: settings.get('explorer.sortOrder'),\n // No collection until one is chosen or created. `gate` is 'create' | 'choose' | null —\n // when set, it is the ONLY thing the workbench shows, because every request needs a\n // collection and there is nothing sensible to render without one.\n collectionId: null, collections: [], canCreateCollection: false, gate: null,\n // `stats` is the whole collection; `items` is the page on screen. Keeping both is what\n // lets the UI say \"500 of 3,006\" instead of quietly claiming 500.\n stats: null, usage: null, nextCursor: null, loadingMore: false, trash: null,\n // The selected NODES, not just their ids — the primary read path in `selectedNodesOf`,\n // with `items` as the fallback for when a selection was made somewhere `items` covers.\n // That function exists to end the class of silent bug where rename/trash/copy-link\n // returned quietly while `hasSelection` said there was something to act on.\n selectionNodes: null,\n});\n\n/** Query text, results, and the palette's separate file list. */\nexport const searchState = () => slice({\n query: '', mode: 'hybrid', results: [], loading: false, error: null, ran: false,\n paletteFiles: [], paletteQuery: '', paletteLoading: false, paletteError: null,\n // `filtered` is a tag/type filter rather than a query; `offline` says the results came\n // from the local pinned index; `resolved` is the query the results on screen are FOR,\n // and it is what `pickView` reads to decide whether to show them at all.\n filtered: false, offline: false, resolved: null,\n});\n\n/**\n * The admin API-key list.\n *\n * `minted` holds the one secret a mint returns. It lives here, in memory, and is dropped\n * the moment the admin dismisses it — the server cannot show it again, so the UI is the\n * only place it ever exists and it must not outlive the tab.\n *\n * `draft` is the mint form. Held in state rather than in the DOM so the section stays a\n * pure function of state, and so a half-filled form survives a re-render caused by\n * something else on the settings screen.\n */\nexport const apiKeysState = () => slice({\n keys: [], loading: false, loaded: false, error: null, minted: null, busy: null, draft: null,\n // `forbidden` is not `error`. A non-admin's 403 is the correct answer to this request, so\n // the section is simply absent for them; anything else is a failure worth reporting, with\n // a way to try again. Conflating the two rendered a blank space for both.\n forbidden: false,\n});\n\n/**\n * What the UI is in the middle of doing — a keybinding mid-capture, text typed into a\n * dialog that has not been submitted, the boxes ticked in a plugin review.\n *\n * None of it is drive state; all of it decides what is on screen, which is what makes it\n * engine state. Keyed by component, so `set` here replaces one key rather than merging a\n * patch — see SetViewStateAction.\n */\nexport const viewState = () => slice({});\n\n/**\n * The shell's transient overlays: the command palette, a modal dialog, the right-click\n * menu, and the plugin popup panel.\n *\n * Four things that are independent of the panel stack and of each other, which is why they\n * were split out of the workbench in the first place. What they are NOT is complex enough\n * to need a service — the class was four setters and a `wrapIndex`, with an action standing\n * in front of each one. The wrapping now lives in the action that moves a cursor, which is\n * where it was needed: MovePaletteAction lost the count argument once already, precisely\n * because deciding and writing were on opposite sides of a forwarding layer.\n */\nexport const overlayState = () => slice({\n palette: null, // { mode: 'commands'|'files', query, index } when open\n dialog: null,\n contextMenu: null,\n pluginPanel: null,\n // The activity panel. It lived inside ActivityService's state, beside `tasks` and\n // `issues` — the one field there with no justification while its neighbours had five\n // lines of it — which made CloseOverlaysAction lease a task/issue poller in order to\n // close a panel, and broke form on the sixth rung of an Escape ladder whose other five\n // go through here.\n activityPanel: false,\n});\n\n/**\n * The shell itself: which activity is showing, and the launcher's own cursor.\n *\n * The panel stack is NOT here — that is NavigationService, which stays a service because it\n * mirrors the stack into browser history and persists recents, neither of which a state bag\n * can do.\n */\nexport const workbenchState = () => slice({\n activity: 'home', // home (stack) | plugins | settings\n sidebarVisible: true,\n launch: { query: '', index: 0 },\n // Which collection's access list an administrator has opened, if any. Shell state\n // rather than a component field: it decides what is on screen.\n aclFor: null,\n searchModal: false, // the double-shift modal search overlay\n // Phone chrome: which bottom sheet is up, if any ('status' | 'more'). A phone has no room\n // for a permanent status bar or a left rail, so both fold into a sheet pulled up on demand.\n sheet: null,\n infoPanel: false,\n});\n\n/** Wrap a list cursor by `delta` within `[0, count)` — the palette and the launcher share it. */\nexport function wrapIndex(index, delta, count) {\n return (index + delta + count) % count;\n}\n\n/**\n * What the open collection's key is doing.\n *\n * Rotation is long-running and lives on the server, so this is a local view of it kept in\n * step by polling while the settings screen is open — see `RotationQuery`. It is state\n * rather than a fetch-per-render because two things read it (the progress line and whether\n * Start is offered) and they must not disagree.\n */\n/**\n * Who may do what on one collection, while an administrator is looking at it.\n *\n * Keyed by collection like the rotation slice next door, and for the same reason: the\n * answer belongs to a collection rather than to the drive, so switching is a different\n * question rather than a change to notice.\n */\nexport const aclState = () => slice({\n collectionId: null, grants: [], admins: [], loading: false, error: null, busy: false,\n});\n\nexport const rotationState = () => slice({\n collectionId: null, rotation: null, estimate: null, loading: false, error: null, busy: false,\n});\n",
51
+ "// ngin Actions — the workbench's business logic as thin, dispatchable verbs\n// (CQRS-style). Each depends on the `app` provider (platform + reactive\n// services) and performs one user intent: navigate, mutate the tree, upload,\n// search, open a file. Errors surface as notifications; the reactive services\n// they update flow straight back into the UI via `watch`.\n\nimport { Action } from '@3sln/ngin';\nimport { runAction } from '../dispatch.js';\nimport { PROMPT, PLUGIN_REVIEW } from './viewState.js';\nimport { beginInstallFromUrl } from './pluginInstall.js';\nimport { newId } from '@3sln/trove/core/util.js';\nimport { matchesTagFilters } from './tagQuery.js';\nimport { availableOpeners, rememberedOpenerId, withAssociation, ASSOC_KEY } from './openers.js';\n// A share link and a `trove:` URI are the same address in two spellings — see core/links.js.\nimport { parseShareUrl, troveUri, shareUrl } from '@3sln/trove/core/links.js';\nimport { selectedNodesOf, draftScopesOf, collectionMenuOf } from './services.js';\nimport { beginInstallFromFile } from './pluginInstall.js';\nimport { pickFiles, pickZip, triggerDownload } from '../platform/pickers.js';\nimport { wrapIndex } from './state.js';\n\n/**\n * Load a collection's items. There is nothing to navigate INTO any more — a drive is\n * browsed by search and by following links — so this only ever switches which\n * collection is on screen, or refreshes the current one.\n */\nexport class NavigateAction extends Action {\n static deps = ['api', 'explorer', 'notifications', 'settings'];\n\n constructor(collectionId) {\n super();\n this.collectionId = collectionId;\n }\n async execute(r) {\n const { api, explorer, notifications, settings } = r;\n // No `|| 'default'`. Navigating nowhere in particular used to land on a collection\n // that may not exist and may not be readable; now it is a bug in the caller, said out\n // loud rather than papered over with a guess.\n const collectionId = this.collectionId || explorer.get().collectionId;\n if (!collectionId) {\n explorer.set({ loading: false, gate: 'choose' });\n return;\n }\n const switching = collectionId !== explorer.get().collectionId;\n // A collection's trash belongs to that collection. Carrying it across a switch\n // listed the OLD collection's deleted files under the new one — above an \"Empty\n // trash\" button that purges the new one, so the rows and the button disagreed\n // about which drive they were talking about.\n explorer.set({ loading: true, error: null, collectionId, ...(switching ? { trash: null } : {}) });\n try {\n const sort = settings.get('explorer.sort');\n const order = settings.get('explorer.sortOrder');\n const res = await api.list(collectionId, { sort, order });\n explorer.set({\n items: res.items, loading: false, selection: [], sort, order,\n collectionId: res.collectionId || collectionId,\n // What the COLLECTION holds, as against the page we were handed. Reporting the\n // page length would tell someone with 3,000 files that they have 500.\n stats: res.stats || null,\n usage: res.usage || null,\n nextCursor: res.nextCursor || null,\n });\n // Remember where they were, so the next visit opens there rather than guessing.\n settings.set('explorer.lastCollection', collectionId);\n explorer.set({ gate: null });\n // Explorer→context projection (collectionId/hasSelection) lives in bl/index.js\n // so it stays in sync with selection too — nothing to mirror here.\n } catch (err) {\n explorer.set({ loading: false, error: err.message });\n notifications.error(`Couldn't load this collection: ${err.message}`);\n }\n }\n}\n\nexport class LoadCollectionsAction extends Action {\n static deps = ['api', 'explorer'];\n\n async execute(r) {\n try {\n const res = await r.api.collections();\n const collections = res.collections || [];\n r.explorer.set({ collections, canCreateCollection: !!res.canCreate });\n return collections;\n } catch { /* collections disabled */ return []; }\n }\n}\n\n/**\n * Open the drive the user should land on.\n *\n * NOT simply 'default'. On a multi-user deployment plenty of people have no access to\n * the default collection at all, and starting there shows them a permission error\n * instead of their own files — the drive appears broken to the exact users for whom it\n * is working correctly. So: keep the last collection if it is still readable, otherwise\n * take the first one they can actually see.\n */\nexport class OpenInitialCollectionAction extends Action {\n static deps = ['api', 'engine', 'explorer', 'notifications', 'settings'];\n\n async execute(r) {\n // A share link decides where we land, ahead of everything below.\n //\n // Arriving at a link to a specific item and being asked which collection you would\n // like to open would be absurd — the link already said. So this runs before the\n // remembered choice and before the gate, and only falls through to them when the URL\n // is not a share link or cannot be honoured.\n const shared = parseShareUrl(typeof location !== 'undefined' ? location.pathname : '');\n if (shared) return this.#openShared(r, shared);\n\n // Calls the API directly rather than dispatching LoadCollectionsAction: ngin's\n // dispatch() returns an event feed, not the action's value, so awaiting it would\n // hand back an EventTarget and this would fail in a way nothing reports.\n let collections = [];\n let canCreate = false;\n try {\n const res = await r.api.collections();\n collections = res.collections || [];\n canCreate = !!res.canCreate;\n r.explorer.set({ collections, canCreateCollection: canCreate });\n } catch (err) {\n r.explorer.set({ loading: false, error: `Couldn't load your collections: ${err.message}` });\n return;\n }\n\n const ids = collections.map((c) => c.id);\n const remembered = r.settings.get('explorer.lastCollection');\n\n // Nothing exists yet. Two different situations that used to read as one:\n if (!ids.length) {\n r.explorer.set({\n loading: false, items: [], collections: [],\n // Someone who may create one is on a fresh drive and should be asked to. Someone\n // who may not has no grants, and telling them to create a collection they cannot\n // create is worse than telling them nothing.\n gate: canCreate ? 'create' : null,\n error: canCreate\n ? null\n : 'You do not have access to any collections yet. Ask an administrator to grant you one.',\n });\n return;\n }\n\n // There is no fallback to a first or a favourite. Landing somewhere the user did not\n // pick is how the old 'default' behaved, and on a shared drive it opened a collection\n // plenty of people could not read — a permission error presented as their drive.\n // A remembered choice is theirs; anything else is a question.\n if (!remembered || !ids.includes(remembered)) {\n r.explorer.set({ loading: false, items: [], gate: 'choose', error: null });\n return;\n }\n\n r.explorer.set({ gate: null });\n return r.engine.dispatch(new NavigateAction(remembered));\n }\n\n /**\n * Open the collection and item a share link names.\n *\n * Every way this can fail says which way it failed. A link to a collection you cannot\n * read, and a link to an item that has been renamed, are different problems with\n * different answers, and both used to be indistinguishable from an empty drive.\n */\n async #openShared(r, shared) {\n const { api, engine, explorer, notifications } = r;\n // The URL is consumed rather than kept. The app does not otherwise reflect its state\n // in the address bar, so leaving a share path there would go stale the moment the user\n // navigated anywhere — a URL that lies is worse than one that is merely uninformative.\n if (typeof history !== 'undefined') history.replaceState(null, '', '/');\n\n let collections = [];\n try {\n const res = await api.collections();\n collections = res.collections || [];\n explorer.set({ collections, canCreateCollection: !!res.canCreate });\n } catch (err) {\n explorer.set({ loading: false, error: `Couldn’t load your collections: ${err.message}` });\n return;\n }\n\n if (!collections.some((c) => c.id === shared.collection)) {\n // Said plainly rather than shown as an empty drive. The recipient may simply not\n // have been granted this collection, and that is worth knowing rather than guessing.\n explorer.set({\n loading: false, items: [], gate: null,\n error: `This link points at a collection you do not have access to (“${shared.collection}”). Ask whoever shared it to grant you access.`,\n });\n return;\n }\n\n explorer.set({ gate: null });\n // Sequenced, so the panel this opens below lands on top of the collection rather than\n // racing its load — see src/dispatch.js for why a bare `await` here did nothing.\n await runAction(engine, new NavigateAction(shared.collection));\n\n let node;\n try {\n // `stat` answers `{ node }` rather than the node — see bl/links.js, which unwraps it\n // the same way. Reading `.id` off the envelope silently looks like \"not found\".\n const res = shared.by === 'id'\n ? await api.stat(shared.value)\n : await api.stat(shared.value, { collection: shared.collection });\n node = res?.node || null;\n } catch {\n node = null;\n }\n if (!node?.id) {\n // A link by name breaks on rename, deliberately and visibly. Saying so beats\n // landing in the right collection with no explanation of what was expected.\n notifications.warn(\n shared.by === 'name'\n ? `“${shared.value}” is not in this collection any more — it may have been renamed or removed.`\n : 'That item no longer exists.',\n );\n return;\n }\n engine.dispatch(new OpenFileAction(node, { reset: true }));\n }\n}\n\n/**\n * Uninstall a plugin.\n *\n * An action rather than a closure threaded through the render tree. Uninstalling is engine\n * work — it is not a render concern in any sense — and it had exactly one call site,\n * reached by carrying a function through fourteen modules of components that had no use\n * for it except to hand it to their children.\n */\n/**\n * Run a command.\n *\n * Commands used to be invoked straight on the command service, which meant every command a\n * user ran from the UI — every menu item, every keybinding, every palette entry — went\n * around the engine rather than through it. Nothing could intercept one, nothing could\n * observe one, and the engine's own view of what the app was doing had a hole in it exactly\n * the shape of everything a person actually did.\n *\n * Running one is an action like any other, so it is one.\n *\n * The command's return value is not available here — `dispatch` answers with an event feed\n * rather than the handler's result. That costs nothing today: every one of the call sites\n * is fire-and-forget, and a command that needs to answer its caller wants a query.\n */\nexport class ExecCommandAction extends Action {\n static deps = ['commands'];\n constructor(id, ...args) {\n super();\n this.id = id;\n this.args = args;\n }\n async execute({ commands }) {\n return commands.execute(this.id, ...this.args);\n }\n}\n\nexport class UninstallPluginAction extends Action {\n static deps = ['notifications', 'plugins'];\n\n constructor(pluginId) {\n super();\n this.pluginId = pluginId;\n }\n async execute(r) {\n try {\n await r.plugins.uninstall(this.pluginId);\n } catch (err) {\n r.notifications.error(`Couldn’t uninstall: ${err.message}`);\n }\n }\n}\n\nexport class CreateCollectionAction extends Action {\n static deps = ['api', 'engine', 'notifications'];\n\n constructor(record) {\n super();\n this.record = record;\n }\n async execute(r) {\n try {\n const res = await r.api.createCollection(this.record);\n r.notifications.success(`Created collection “${res.collection.name}”`);\n // Sequenced: `NavigateAction` writes `collectionId` synchronously while the load\n // writes `collections` after a round trip, so navigating first left the status bar's\n // `collectionLabelOf` with nothing to look the id up in — it showed a raw `col_…`.\n await runAction(r.engine, new LoadCollectionsAction());\n r.engine.dispatch(new NavigateAction(res.collection.id));\n } catch (err) {\n r.notifications.error(`Couldn’t create collection: ${err.message}`);\n }\n }\n}\n\n/** Append the next page of a collection to what's already on screen. */\nexport class LoadMoreAction extends Action {\n static deps = ['api', 'explorer', 'notifications'];\n\n async execute(r) {\n const { api, explorer, notifications } = r;\n const cursor = explorer.get().nextCursor;\n if (!cursor || explorer.get().loadingMore) return;\n explorer.set({ loadingMore: true });\n try {\n const res = await api.list(explorer.get().collectionId, {\n sort: explorer.get().sort, order: explorer.get().order, cursor,\n });\n explorer.set({\n items: [...explorer.get().items, ...res.items],\n nextCursor: res.nextCursor || null,\n loadingMore: false,\n });\n } catch (err) {\n explorer.set({ loadingMore: false });\n notifications.error(`Couldn't load more: ${err.message}`);\n }\n }\n}\n\nexport class RefreshAction extends Action {\n static deps = ['engine', 'explorer'];\n\n async execute(r) {\n return r.engine.dispatch(new NavigateAction(r.explorer.get().collectionId));\n }\n}\n\n/** Show what's been deleted but not destroyed, and act on it. */\nexport class TrashAction extends Action {\n static deps = ['api', 'engine', 'explorer', 'notifications'];\n\n constructor(op = 'list', id = null) {\n super();\n this.op = op;\n this.id = id;\n }\n async execute(r) {\n const { api, explorer, notifications } = r;\n const collection = explorer.get().collectionId;\n // Putting it away is one of the things you can do to the trash. Without this the\n // section, once opened, stayed on screen until a page reload — there was no way\n // back to a plain list of files.\n if (this.op === 'hide') {\n explorer.set({ trash: null });\n return;\n }\n try {\n if (this.op === 'restore') {\n const { node } = await api.restore(this.id);\n notifications.success(`Restored “${node.name}”`);\n } else if (this.op === 'purge') {\n await api.purgeTrash({ id: this.id });\n } else if (this.op === 'empty') {\n const { purged } = await api.purgeTrash({ collection });\n notifications.success(`Deleted ${purged} item${purged === 1 ? '' : 's'} for good`);\n }\n const { items } = await api.trash(collection);\n explorer.set({ trash: items });\n // Restoring puts something back in the drive, so the list on screen is now stale.\n if (this.op !== 'list') r.engine.dispatch(new NavigateAction(collection));\n } catch (err) {\n notifications.error(`Trash: ${err.message}`);\n }\n }\n}\n\nexport class DeleteAction extends Action {\n // `navigation`, not `workbench`: the panel stack and the recents list are both its, and a\n // deleted file must not survive in either.\n static deps = ['api', 'engine', 'navigation', 'notifications'];\n\n constructor(ids) {\n super();\n this.ids = ids;\n }\n async execute(r) {\n try {\n for (const id of this.ids) await r.api.remove(id);\n r.notifications.info(`Deleted ${this.ids.length} item${this.ids.length > 1 ? 's' : ''}`);\n for (const id of this.ids) r.navigation.forget(id);\n } catch (err) {\n r.notifications.error(`Couldn’t delete: ${err.message}`);\n }\n r.engine.dispatch(new RefreshAction());\n }\n}\n\nexport class RenameAction extends Action {\n // The renamed node has to reach the open panel too, or the title bar keeps the old name\n // until something else refreshes it. That stack belongs to `navigation`.\n static deps = ['api', 'engine', 'navigation', 'notifications'];\n\n constructor(id, newName) {\n super();\n this.id = id;\n this.newName = newName;\n }\n async execute(r) {\n try {\n const node = await r.api.rename(this.id, this.newName);\n r.navigation.updateTabNode(node.node);\n r.engine.dispatch(new RefreshAction());\n } catch (err) {\n r.notifications.error(`Couldn’t rename: ${err.message}`);\n }\n }\n}\n\n\nexport class OpenFileAction extends Action {\n static deps = ['context', 'contributions', 'engine', 'plugins', 'settings'];\n\n /** @param {object} node @param {{reset?:boolean}} [opts] reset → start a fresh stack (modal search) */\n constructor(node, opts = {}) {\n super();\n this.node = node;\n this.opts = opts;\n }\n async execute(r) {\n // Guard against being invoked with no target (e.g. a command fired with an empty\n // selection) — dereferencing a null node would throw an unhandled rejection.\n if (!this.node) return;\n const open = (openerId) => r.engine.dispatch(new OpenInPanelAction(this.node, openerId, { reset: !!this.opts.reset }));\n\n // An explicit opener (e.g. the switch-opener control) wins outright.\n if (this.opts.openerId) return open(this.opts.openerId);\n\n // Only openers available right now (a plugin previewer needing the network while\n // offline is skipped, so we fall back to a built-in one).\n const avail = availableOpeners(r, this.node);\n\n // A remembered choice for this file type, if that opener is still available.\n const remembered = rememberedOpenerId(r, this.node);\n if (remembered && avail.some((o) => o.id === remembered)) return open(remembered);\n\n // Several openers and no saved preference → let the user choose (with an option to\n // remember). One or none → just open the best (or the download fallback).\n if (avail.length > 1) {\n return r.engine.dispatch(new ShowDialogAction({ kind: 'opener-chooser', node: this.node, openers: avail, reset: !!this.opts.reset }));\n }\n open(avail[0]?.id || 'core.fallback');\n }\n}\n\nexport class UploadFilesAction extends Action {\n static deps = ['api', 'engine', 'explorer', 'notifications', 'settings', 'transfers'];\n\n constructor(files, collectionId) {\n super();\n this.files = files;\n this.collectionId = collectionId;\n }\n async execute(r) {\n const collection = this.collectionId || r.explorer.get().collectionId;\n // Uploading with no collection open has nowhere to put the bytes. Refused visibly:\n // the old fallback sent them to whatever 'default' happened to be.\n if (!collection) {\n r.notifications.error('Open a collection before uploading');\n return;\n }\n const concurrency = r.settings.get('uploads.concurrency');\n const uploads = [...this.files].map((file) => this.#one(r, file, collection, concurrency));\n await Promise.allSettled(uploads);\n r.engine.dispatch(new NavigateAction(collection));\n }\n /**\n * One file, once — and again, on the same tray row, if the user asks.\n *\n * `existingTid` is what makes a manual retry a second attempt at the row already on\n * screen rather than a new entry beside it. The retry closes over the File, which is why\n * it can run at all without asking the user to find the file again; it is also why the\n * offer does not survive a reload, since nothing here is persisted.\n */\n async #one(r, file, collection, concurrency, existingTid = null) {\n const { api, notifications, transfers } = r;\n const tid = existingTid || newId('xfer');\n const controller = new AbortController();\n if (existingTid) {\n transfers.restart(tid, controller);\n } else {\n transfers.start(tid, file.name, file.size, controller, {\n retry: () => this.#one(r, file, collection, concurrency, tid),\n });\n }\n let uploadId = null;\n try {\n const node = await api.upload(file, {\n collection, concurrency, signal: controller.signal,\n onStart: (id) => { uploadId = id; },\n onProgress: (p) => transfers.progress(tid, p),\n });\n transfers.finish(tid, 'done');\n // The server disambiguates a same-name collision rather than overwriting — tell\n // the user when the saved name differs from what they dropped.\n if (node?.name && node.name !== file.name) {\n notifications.info(`\"${file.name}\" already existed — saved as \"${node.name}\".`);\n }\n } catch (err) {\n // Release the server-side session so a cancelled/failed multipart upload doesn't\n // leak an open multipart object (best-effort; the server also sweeps stale ones).\n if (uploadId) api.abortUpload(uploadId).catch(() => {});\n if (err.code === 'aborted') transfers.finish(tid, 'cancelled');\n else {\n transfers.finish(tid, 'error', err.message);\n // The toast says what happened; the tray row is where it can be acted on, and\n // pointing at it is the difference between a dead end and an offer.\n notifications.error(`Upload failed: ${file.name} — ${err.message}. Retry it from the transfers tray.`);\n }\n }\n }\n}\n\n/** Drive-wide tag/property filter (`#tag`, `#key:op:value`), optionally narrowed\n * by free text. Falls back to filtering the loaded folder when offline. */\nexport class FilterAction extends Action {\n static deps = ['api', 'explorer', 'offline', 'search'];\n\n constructor(filters, text) {\n super();\n this.filters = filters || [];\n this.text = text || '';\n }\n async execute(r) {\n const { api, search } = r;\n if (!this.filters.length) {\n search.set({ results: [], ran: false, filtered: false });\n return;\n }\n search.set({ query: this.text, loading: true, error: null, filtered: true });\n if (r.offline && !r.offline.get().online) {\n const items = (r.explorer.get().items || []).filter((n) => matchesTagFilters(n, this.filters));\n search.set({ results: items.map((node) => ({ node })), loading: false, ran: true, filtered: true, offline: true });\n return;\n }\n try {\n const res = await api.tagSearch(this.filters, this.text.trim() || undefined, { limit: 100 });\n search.set({ results: (res.items || []).map((node) => ({ node })), loading: false, ran: true, filtered: true, offline: false });\n } catch (err) {\n search.set({ loading: false, error: err.message, ran: true, filtered: true });\n }\n }\n}\n\n/** Command-palette quick-open: a keyword file search whose results live in the search\n * service (state.se.paletteFiles) instead of ad-hoc state hung off the UI. */\nexport class QuickOpenAction extends Action {\n static deps = ['api', 'overlay', 'search'];\n\n constructor(query) {\n super();\n this.query = query;\n }\n async execute(r) {\n const { api, overlay, search } = r;\n // The palette's mode as it is NOW, not as it was when the keystroke's timer was set.\n // This guard used to live in the debounce callback in the component, which had to read\n // it back off the service for exactly this reason — a listener belongs to the render\n // that created it, and the mode can change under a pending timer.\n if (overlay.get().palette?.mode !== 'files') return;\n const q = (this.query || '').trim();\n if (!q) { search.set({ paletteFiles: [], paletteQuery: '', paletteError: null, paletteLoading: false }); return; }\n // Keystrokes outrun the network: a slower request for an earlier query must not\n // land on top of a newer one's results. The query itself is the sequence token —\n // whatever the palette input holds now is the only answer worth showing.\n search.set({ paletteQuery: q, paletteLoading: true, paletteError: null });\n try {\n const res = await api.search(q, { mode: 'keyword', limit: 30 });\n if (search.get().paletteQuery !== q) return; // superseded\n search.set({ paletteFiles: res.results || [], paletteLoading: false });\n } catch (err) {\n if (search.get().paletteQuery !== q) return;\n // A failed search must not look like \"no files matched\" — that reads as a fact\n // about the drive when it's actually a fact about the request.\n search.set({ paletteFiles: [], paletteLoading: false, paletteError: err?.message || 'Search failed' });\n }\n }\n}\n\nexport class SearchAction extends Action {\n static deps = ['api', 'contributions', 'offline', 'search', 'settings'];\n\n constructor(query, mode) {\n super();\n this.query = query;\n this.mode = mode;\n }\n async execute(r) {\n const { api, contributions, search, settings } = r;\n const q = this.query.trim();\n if (!q) {\n search.set({ query: '', results: [], ran: false, error: null, resolved: null });\n return;\n }\n const mode = this.mode || settings.get('search.mode');\n search.set({ query: this.query, mode, loading: true, error: null, resolved: null, filtered: false });\n // The query itself is the sequence token, the same guard QuickOpenAction uses and for\n // the same reason: keystrokes outrun the network, and a slower request for an earlier\n // query must not land on top of a newer one's results. It matters most for the query\n // that was CLEARED — pressing Escape inside the debounce window used to let\n // `SearchAction('contract')` land after the clear, leaving \"Searching for contract\"\n // over the home list.\n const superseded = () => search.get().query !== this.query;\n const offline = r.offline;\n // Offline (or server unreachable) → search the pinned corpus locally.\n if (offline && !offline.get().online) {\n try {\n const results = await offline.searchOffline(q, { limit: 40 });\n if (superseded()) return;\n search.set({ results, loading: false, ran: true, offline: true, resolved: null });\n } catch (err) {\n if (superseded()) return;\n search.set({ results: [], loading: false, ran: true, offline: true, error: err.message });\n }\n return;\n }\n try {\n // The server transforms the raw query (parse/LLM) and tells us what it actually\n // searched — surfaced to the user via `resolved` so search is honest.\n //\n // We send the views we can draw with, because the transformer is the only thing in\n // the stack that read the sentence: \"photos from the trip last summer\" asks for a\n // gallery, and by the time the results are back all anyone can do is guess from\n // content types. It can only name a view from this list.\n const views = contributions.ofType('view').map((v) => ({ id: v.id, title: v.title || v.id }));\n const res = await api.query(q, { mode, limit: 40, views });\n if (superseded()) return;\n search.set({ results: res.results, resolved: res.resolved || null, loading: false, ran: true, offline: false });\n } catch (err) {\n if (superseded()) return;\n if (offline) {\n const results = await offline.searchOffline(q, { limit: 40 });\n if (superseded()) return;\n search.set({ results, loading: false, ran: true, offline: true, error: results.length ? null : err.message });\n } else {\n search.set({ loading: false, error: err.message, ran: true });\n }\n }\n }\n}\n\n// --- API keys (admin) ----------------------------------------------------------\n\n/**\n * Load the key list.\n *\n * Silent on REFUSAL rather than noisy: this fires when Settings opens, and a non-admin\n * opening Settings gets a 403 that is the correct answer, not an error worth a toast. That\n * is `loaded` with an empty list — the section simply is not part of their settings screen.\n *\n * Any other failure sets `error` and leaves `loaded` alone, because they are different\n * facts. Setting both meant one transient failure rendered the section blank with no\n * message and no way back: `loaded` was true so the \"not yet\" branch passed, and the empty\n * list was indistinguishable from a drive with no keys.\n */\nexport class LoadApiKeysAction extends Action {\n static deps = ['api', 'apiKeys'];\n\n async execute(r) {\n r.apiKeys.set({ loading: true, error: null });\n try {\n const res = await r.api.apiKeys();\n r.apiKeys.set({ keys: res.keys || [], loading: false, loaded: true, error: null });\n } catch (err) {\n if (err?.status === 403 || err?.code === 'forbidden') {\n r.apiKeys.set({ keys: [], loading: false, loaded: true, error: null, forbidden: true });\n return;\n }\n r.apiKeys.set({ loading: false, error: err?.message || 'Could not load API keys' });\n }\n }\n}\n\n/**\n * Mint a key and hold the secret for display.\n *\n * The secret is the whole point of the round trip and cannot be fetched again, so it is\n * put into state before anything else can fail. A refresh of the list afterwards is a\n * convenience; losing the secret because the refresh threw would not be.\n */\nexport class MintApiKeyAction extends Action {\n static deps = ['api', 'apiKeys', 'notifications'];\n\n constructor(spec) {\n super();\n this.spec = spec;\n }\n async execute(r) {\n r.apiKeys.set({ busy: 'mint', error: null });\n try {\n const { key, secret } = await r.api.mintApiKey(this.spec);\n r.apiKeys.set({ minted: { key, secret }, busy: null });\n const res = await r.api.apiKeys().catch(() => null);\n if (res) r.apiKeys.set({ keys: res.keys || [] });\n return key;\n } catch (err) {\n r.apiKeys.set({ busy: null, error: err?.message || 'Could not create the key' });\n r.notifications.error(err?.message || 'Could not create the key');\n return null;\n }\n }\n}\n\nexport class RevokeApiKeyAction extends Action {\n static deps = ['api', 'apiKeys', 'notifications'];\n\n constructor(id) {\n super();\n this.id = id;\n }\n async execute(r) {\n r.apiKeys.set({ busy: this.id, error: null });\n try {\n await r.api.revokeApiKey(this.id);\n const res = await r.api.apiKeys().catch(() => null);\n r.apiKeys.set({ busy: null, ...(res ? { keys: res.keys || [] } : {}) });\n r.notifications.success('Key revoked');\n } catch (err) {\n r.apiKeys.set({ busy: null });\n r.notifications.error(err?.message || 'Could not revoke the key');\n }\n }\n}\n\n\n/**\n * Rebind a keyboard shortcut, or clear it with `key: null`.\n *\n * Carries the binding ID rather than the binding, because a view emits descriptions and an\n * action carries an id — the component that dispatches this has never held the binding\n * object, only a row describing it.\n */\nexport class RebindKeyAction extends Action {\n static deps = ['keybindings'];\n constructor(bindingId, key) {\n super();\n this.bindingId = bindingId;\n this.key = key;\n }\n\n async execute({ keybindings: kb }) {\n // `rebind` resolves a binding object or a command id, not a binding id, so look the\n // row back up. Resolving here rather than widening the service keeps the id the only\n // thing that crosses the boundary.\n const binding = kb.resolved().find((b) => b.bindingId === this.bindingId);\n if (!binding) return;\n kb.rebind(binding, this.key);\n }\n}\n\n/**\n * Copy text to the clipboard, and say so.\n *\n * Four components had their own version of this, each written slightly differently — two\n * with `.then/.catch`, one with `await` in a `try`, one optional-chaining the clipboard and\n * one not. All four ended the same way, and the ending is the part that matters: a copy that\n * FAILS must still put the text where it can be selected by hand, or the user is left with a\n * button that did nothing and no way to get at what it was for. That is what the sticky\n * fallback is, and it is exactly the sort of detail that rots when it lives in four places.\n *\n * Clipboard access is denied outside a user gesture and in an insecure context, so the\n * failure path is ordinary rather than exceptional.\n */\nexport class CopyTextAction extends Action {\n static deps = ['notifications'];\n /**\n * @param {string} text\n * @param {string} [label] what the toast says on success\n */\n constructor(text, label = 'Copied') {\n super();\n this.text = text;\n this.label = label;\n }\n\n async execute({ notifications: notes }) {\n try {\n await navigator.clipboard.writeText(this.text);\n notes.success(this.label);\n } catch {\n notes.info(this.text, { sticky: true });\n }\n }\n}\n\n/** Dismiss one notification, by id. */\nexport class DismissNotificationAction extends Action {\n static deps = ['notifications'];\n constructor(id) {\n super();\n this.id = id;\n }\n\n async execute({ notifications }) {\n notifications.dismiss(this.id);\n }\n}\n\n// --- the shell's own surface ----------------------------------------------------\n//\n// Opening and closing the workbench's overlays. These were direct calls on\n// `platform.workbench`, which meant the engine could not see a person close a dialog or\n// move through the palette — the same hole `ExecCommandAction` closed for commands.\n//\n// One class per operation rather than a single ShellAction carrying a method name. The\n// point of routing these through the engine is that the feed says what happened; a\n// discriminated blob would make every one of them read as \"ShellAction\" and give back\n// exactly the observability this is for.\n//\n// `showDialog` and `showContextMenu` are here too, and the reason they arrived last is the\n// reason they are worth having: both used to take callbacks — a dialog carried `onConfirm`,\n// a menu carried an item's `run` — so converting them mechanically would have posted a\n// closure through the engine and called it an action. Every outcome is an ACTION TO\n// DISPATCH now, which is why nothing in a dialog spec or a menu item is callable.\n\nclass ShellAction extends Action {\n static deps = ['workbench'];\n async execute({ workbench }) {\n this.apply(workbench);\n }\n}\n\n/**\n * The overlays: palette, dialog, context menu, plugin panel.\n *\n * Their own lease. Closing a dialog used to go through the workbench facade and therefore\n * leased the entire shell — the panel stack, the launcher cursor and the sheet included —\n * to set one field to null.\n */\nclass OverlayAction extends Action {\n static deps = ['overlay'];\n async execute({ overlay }) {\n this.apply(overlay);\n }\n}\n\n/** The panel stack. Still a service: it mirrors into browser history and persists recents. */\nclass NavAction extends Action {\n static deps = ['navigation'];\n async execute({ navigation }) {\n this.apply(navigation);\n }\n}\n\nexport class CloseDialogAction extends OverlayAction {\n apply(o) { o.set({ dialog: null }); }\n}\n\n/** Merge a patch into the open dialog — a reactive dialog, like the opener chooser. */\nexport class UpdateDialogAction extends OverlayAction {\n constructor(patch) { super(); this.patch = patch; }\n apply(o) {\n const dialog = o.get().dialog;\n if (dialog) o.set({ dialog: { ...dialog, ...this.patch } });\n }\n}\n\nexport class CloseContextMenuAction extends OverlayAction {\n apply(o) { o.set({ contextMenu: null }); }\n}\n\nexport class ClosePaletteAction extends OverlayAction {\n apply(o) { o.set({ palette: null }); }\n}\n\nexport class SetPaletteQueryAction extends OverlayAction {\n constructor(query) { super(); this.query = query; }\n apply(o) {\n const palette = o.get().palette;\n // Back to the top: the previous highlight belonged to the previous result set.\n if (palette) o.set({ palette: { ...palette, query: this.query, index: 0 } });\n }\n}\n\nexport class SetPaletteIndexAction extends OverlayAction {\n constructor(index) { super(); this.index = index; }\n apply(o) {\n const palette = o.get().palette;\n if (palette) o.set({ palette: { ...palette, index: this.index } });\n }\n}\n\n/**\n * Move the palette's highlight, wrapping at either end.\n *\n * The wrapping is HERE now. It used to be in the service with this action forwarding two\n * arguments to it — and it forwarded one, so the service could not tell where the end was,\n * returned early, and the arrow keys did nothing at all. Deciding and writing in one place\n * is what removes the chance.\n */\nexport class MovePaletteAction extends OverlayAction {\n constructor(delta, count) { super(); this.delta = delta; this.count = count; }\n apply(o) {\n const palette = o.get().palette;\n if (!palette || !this.count) return;\n o.set({ palette: { ...palette, index: wrapIndex(palette.index, this.delta, this.count) } });\n }\n}\n\n/** The double-shift overlay: a search that starts empty and resets the stack on a pick. */\nexport class OpenSearchModalAction extends ShellAction {\n apply(wb) { wb.set({ searchModal: true, launch: { query: '', index: 0 } }); }\n}\n\nexport class CloseSearchModalAction extends ShellAction {\n apply(wb) { wb.set({ searchModal: false }); }\n}\n\n/** Open (or close) one collection's access list on the administration screen. */\nexport class ShowCollectionAccessAction extends ShellAction {\n constructor(collectionId) { super(); this.collectionId = collectionId; }\n apply(wb) { wb.set({ aclFor: wb.get().aclFor === this.collectionId ? null : this.collectionId }); }\n}\n\nexport class SetLaunchQueryAction extends ShellAction {\n constructor(query) { super(); this.query = query; }\n // Back to the top, for the same reason the palette does: the old highlight belonged to\n // the old results.\n apply(wb) { wb.set({ launch: { query: this.query, index: 0 } }); }\n}\n\nexport class SetLaunchIndexAction extends ShellAction {\n constructor(index) { super(); this.index = index; }\n apply(wb) { wb.set({ launch: { ...wb.get().launch, index: this.index } }); }\n}\n\n/** Raise, swap, or drop the phone bottom sheet. Tapping the open one closes it. */\nexport class OpenSheetAction extends ShellAction {\n constructor(which) { super(); this.which = which; }\n apply(wb) { wb.set({ sheet: wb.get().sheet === this.which ? null : this.which }); }\n}\n\nexport class CloseSheetAction extends ShellAction {\n apply(wb) { wb.set({ sheet: null }); }\n}\n\nexport class ToggleInfoPanelAction extends ShellAction {\n constructor(open) { super(); this.open = open; }\n apply(wb) { wb.set({ infoPanel: this.open ?? !wb.get().infoPanel }); }\n}\n\nexport class OpenPluginPanelAction extends OverlayAction {\n constructor(pluginId) { super(); this.pluginId = pluginId; }\n apply(o) { o.set({ pluginPanel: this.pluginId }); }\n}\n\nexport class ClosePluginPanelAction extends OverlayAction {\n apply(o) { o.set({ pluginPanel: null }); }\n}\n\n/**\n * Open a node in a panel, with a chosen opener.\n *\n * Three things at once, and they belong together: the panel goes on the stack, the shell\n * switches to the drive, and the modal search — if that is where the pick came from —\n * closes behind it. The workbench service used to do the coordinating because the stack\n * lives in one place and the activity in another; an action is a better home for \"these\n * happen together\" than a facade over both.\n */\nexport class OpenInPanelAction extends Action {\n static deps = ['navigation', 'workbench'];\n constructor(node, openerId, opts = {}) {\n super();\n this.node = node;\n this.openerId = openerId;\n this.opts = opts;\n }\n async execute({ navigation, workbench }) {\n workbench.set({ activity: 'home', searchModal: false });\n navigation.openFile(this.node, this.openerId, this.opts);\n }\n}\n\n// --- the drive's services --------------------------------------------------------\n//\n// Cancelling a transfer, retrying an issue, tagging a file. These were direct method calls\n// on the service, so the engine saw an upload being cancelled only as the state change that\n// followed, with nothing to say a person had asked for it.\n//\n// Named per operation for the same reason the shell actions are: the feed is the point.\n\nclass ActivityAction extends Action {\n static deps = ['activity'];\n async execute(r) { this.apply(r.activity); }\n}\n/**\n * Show or hide the activity panel.\n *\n * The FLAG is overlay state like every other transient surface; the REFRESH is the\n * poller's. Opening has to refresh because polling backs off to 60s when nothing is\n * running, so a panel opened on an idle drive would otherwise show a list up to a minute\n * stale — which is exactly the moment someone is looking to find out what just happened.\n */\nexport class ToggleActivityPanelAction extends Action {\n static deps = ['activity', 'overlay'];\n constructor(which) { super(); this.which = which; }\n async execute({ activity, overlay }) {\n const open = this.which ?? !overlay.get().activityPanel;\n overlay.set({ activityPanel: open });\n if (open) await activity.refresh();\n }\n}\nexport class CancelTaskAction extends ActivityAction {\n constructor(id) { super(); this.id = id; }\n apply(s) { s.cancel(this.id); }\n}\nexport class DismissTaskAction extends ActivityAction {\n constructor(id) { super(); this.id = id; }\n apply(s) { s.dismiss(this.id); }\n}\nexport class RetryIssueAction extends ActivityAction {\n constructor(id) { super(); this.id = id; }\n apply(s) { s.retryIssue(this.id); }\n}\nexport class DismissIssueAction extends ActivityAction {\n constructor(id) { super(); this.id = id; }\n apply(s) { s.dismissIssue(this.id); }\n}\n\nclass TransfersAction extends Action {\n static deps = ['transfers'];\n async execute(r) { this.apply(r.transfers); }\n}\nexport class CancelTransferAction extends TransfersAction {\n constructor(id) { super(); this.id = id; }\n apply(s) { s.cancel(this.id); }\n}\nexport class RetryTransferAction extends TransfersAction {\n constructor(id) { super(); this.id = id; }\n apply(s) { s.retry(this.id); }\n}\nexport class DismissTransferAction extends TransfersAction {\n constructor(id) { super(); this.id = id; }\n apply(s) { s.dismiss(this.id); }\n}\nexport class ClearFinishedTransfersAction extends TransfersAction {\n apply(s) { s.clearDone(); }\n}\n\nclass SocialAction extends Action {\n static deps = ['social'];\n // Awaited: several of these are network calls, and a dispatch feed that settles before\n // the work does reports success for something still in flight.\n async execute(r) { return this.apply(r.social); }\n}\nexport class ToggleInboxAction extends SocialAction {\n constructor(open) { super(); this.open = open; }\n apply(s) { s.toggleInbox(this.open); }\n}\n\n/** Ask the browser for push permission and register. */\nexport class EnablePushAction extends SocialAction {\n apply(s) { return s.enablePush(); }\n}\n\n/** Post a comment on the open item. */\nexport class PostCommentAction extends SocialAction {\n constructor(body) { super(); this.body = body; }\n apply(s) { return s.comment(this.body); }\n}\n\nexport class DeleteCommentAction extends SocialAction {\n constructor(commentId) { super(); this.commentId = commentId; }\n apply(s) { return s.deleteComment(this.commentId); }\n}\n\nexport class ReactToCommentAction extends SocialAction {\n constructor(commentId, emoji) { super(); this.commentId = commentId; this.emoji = emoji; }\n apply(s) { return s.react(this.commentId, this.emoji); }\n}\n\n/** Aim the comment box at a comment, or clear it with `null`. */\nexport class SetReplyToAction extends SocialAction {\n constructor(target) { super(); this.target = target; }\n apply(s) { s.setReplyTo(this.target); }\n}\nexport class AddTagAction extends SocialAction {\n constructor(name, value) { super(); this.name = name; this.value = value; }\n apply(s) { s.addTag(this.name, this.value); }\n}\nexport class RemoveTagAction extends SocialAction {\n constructor(name) { super(); this.name = name; }\n apply(s) { s.removeTag(this.name); }\n}\nexport class LoadSidecarAction extends SocialAction {\n constructor(nodeId) { super(); this.nodeId = nodeId; }\n apply(s) { s.loadSidecar(this.nodeId); }\n}\n\nclass ApiKeysAction extends Action {\n static deps = ['apiKeys'];\n async execute(r) { this.apply(r.apiKeys); }\n}\n\n/** Change one field of the mint form. Does nothing when there is no form open. */\nexport class PatchApiKeyDraftAction extends ApiKeysAction {\n constructor(patch) { super(); this.patch = patch; }\n apply(s) {\n const draft = s.get().draft;\n if (draft) s.set({ draft: { ...draft, ...this.patch } });\n }\n}\n\n/**\n * Toggle one capability on one collection in the draft.\n *\n * Per COLLECTION and capability: a key is scoped, so a capability without the collection\n * it applies to is meaningless. This used to be arithmetic inside the service with an\n * action in front of it forwarding two arguments — and it forwarded one, so the collection\n * id arrived as the capability and the server refused every mint. Deciding and writing are\n * one step now, with nothing in between to drop.\n *\n * `admin` is not treated specially. It is offered as itself and the server expands it;\n * pre-ticking read/write/delete alongside it would suggest they are separable afterwards,\n * and they are not.\n */\nexport class ToggleApiKeyCapAction extends ApiKeysAction {\n constructor(collectionId, capability) { super(); this.collectionId = collectionId; this.capability = capability; }\n apply(s) {\n const draft = s.get().draft;\n if (!draft) return;\n const caps = { ...draft.caps };\n const held = new Set(caps[this.collectionId] || []);\n if (held.has(this.capability)) held.delete(this.capability);\n else held.add(this.capability);\n if (held.size) caps[this.collectionId] = [...held];\n else delete caps[this.collectionId];\n s.set({ draft: { ...draft, caps } });\n }\n}\n\n/**\n * Move the launcher's highlight and sync the selection to whatever it landed on.\n *\n * ONE action because the two halves are not separable. Moving computes a new index — with\n * wrapping, so it is not `index + delta` — and the selection has to follow the row that\n * index now names. Written as two steps in the component it read the index back out of the\n * store immediately after writing it, which only worked because a direct method call is\n * synchronous. Dispatching is not: the highlight would move and the selection would sync to\n * the previously highlighted row, one keystroke behind, forever, without anything throwing.\n *\n * Here the read-back is inside the action, where it IS sequenced. `nodes` is the results in\n * display order — the component knows the running order, the store only knows the index.\n */\nexport class MoveLaunchAction extends Action {\n static deps = ['explorer', 'workbench'];\n constructor(delta, nodes) { super(); this.delta = delta; this.nodes = nodes; }\n async execute({ workbench, explorer }) {\n const count = this.nodes.length;\n if (!count) return;\n const index = wrapIndex(workbench.get().launch.index, this.delta, count);\n workbench.set({ launch: { ...workbench.get().launch, index } });\n selectNode(explorer, this.nodes[index]);\n }\n}\n\n/** Highlight a launcher row by position and select it — the pointer/Enter counterpart. */\nexport class SelectLaunchAction extends Action {\n static deps = ['explorer', 'workbench'];\n constructor(index, node) { super(); this.index = index; this.node = node; }\n async execute({ workbench, explorer }) {\n workbench.set({ launch: { ...workbench.get().launch, index: this.index } });\n selectNode(explorer, this.node);\n }\n}\n\n/**\n * Select exactly one node, or nothing.\n *\n * `selectionNodes` carries the NODE and not just the id, because the selection often cannot\n * be resolved from the loaded page: the launcher's rows come from search, which is scoped\n * across collections, so the node has to travel with the id or `selectedNodesOf` finds\n * nothing and rename/trash/copy-link return quietly while `hasSelection` disagrees.\n *\n * Selecting what is already selected must not emit. The launcher syncs the highlighted row\n * into here on every mouseenter, and a state push per mouse move would re-render the list\n * under the pointer. The rule lives with the mutation rather than inside the resource, so\n * the resource only holds and only `set` writes.\n */\nfunction selectNode(explorer, node) {\n const ids = node?.id ? [node.id] : [];\n const current = explorer.get().selection;\n if (ids.length === current.length && ids.every((id, i) => id === current[i])) return;\n explorer.set({ selection: ids, selectionNodes: node ? [node] : null });\n}\n\n/**\n * Write one slice of view state — a draft, a capture, a set of ticked boxes.\n *\n * Components used to call the store directly, and two of them did it DURING their own\n * render to install a default. The default is derived now (see `draftFor`), so this only\n * ever runs because a person did something.\n */\nexport class SetViewStateAction extends Action {\n static deps = ['viewState'];\n constructor(key, value) { super(); this.key = key; this.value = value; }\n async execute({ viewState }) { viewState.set({ [this.key]: this.value }); }\n}\n\n\n/**\n * Show a context menu at a point.\n *\n * Only possible now that items carry `actions` rather than `run` closures — this used to be\n * a direct call precisely because dispatching a menu would have meant putting functions on\n * the feed. See ui/activate.js.\n */\nexport class ShowContextMenuAction extends OverlayAction {\n /**\n * @param {Array} items\n * @param {{x?: number, y?: number, rect?: DOMRect, prefer?: 'up'|'down'}|null} [at]\n * A POINT (a right-click) or a rect to hang off (a button), not a resolved position.\n * Callers used to resolve it themselves — `r.top - 8 - items.length * 34`, a row height\n * hardcoded in two files that had to agree with the CSS and did not have to agree with\n * the overlay's clamp, which compensated by a different amount. Only the overlay can\n * measure, so only the overlay decides. Omit `at` for a keyboard-invoked menu.\n */\n constructor(items, at = null) {\n super();\n this.items = items;\n // Flattened to plain numbers: a DOMRect is a live object with methods, and this lands\n // in engine state, where nothing is callable.\n this.at = at?.rect\n ? { prefer: at.prefer || 'down', rect: { left: at.rect.left, top: at.rect.top, right: at.rect.right, bottom: at.rect.bottom } }\n : (at ? { x: at.x, y: at.y } : null);\n }\n\n apply(o) { o.set({ contextMenu: { items: this.items, at: this.at } }); }\n}\n\n/**\n * Show a dialog.\n *\n * The spec is data. A confirm carries `confirmActions`; so does a prompt, whose actions read\n * what was typed out of view state rather than being handed it — see PromptAction. Nothing\n * in a dialog spec is callable, which matters because the spec lives in workbench state.\n */\nexport class ShowDialogAction extends OverlayAction {\n constructor(dialog) { super(); this.dialog = dialog; }\n apply(o) { o.set({ dialog: this.dialog }); }\n}\n\n/** Change one setting. */\nexport class SetSettingAction extends Action {\n static deps = ['settings'];\n constructor(key, value) { super(); this.key = key; this.value = value; }\n async execute({ settings }) { settings.set(this.key, this.value); }\n}\n\n/**\n * Remember which opener a file type should use, or forget it with a null openerId.\n *\n * Not `SetSettingAction` with a pre-merged map, because building that map means reading the\n * current one — and a component that reads settings to compute what to write is the same\n * stale-base race as the drafts had (see PatchDraftAction). The merge happens here, against\n * what is stored.\n */\nexport class RememberOpenerAction extends Action {\n static deps = ['settings'];\n constructor(typeKey, openerId) { super(); this.typeKey = typeKey; this.openerId = openerId; }\n async execute({ settings }) {\n if (!this.typeKey) return;\n settings.set(ASSOC_KEY, withAssociation(settings.get(ASSOC_KEY), this.typeKey, this.openerId));\n }\n}\n\n/** Back through the panel stack. */\nexport class NavigateBackAction extends NavAction {\n apply(nav) { nav.back(); }\n}\n\n/** Close the viewer stack and return to the drive. */\nexport class ShowHomeAction extends Action {\n static deps = ['navigation', 'workbench'];\n async execute({ navigation, workbench }) {\n workbench.set({ activity: 'home', searchModal: false });\n navigation.reset();\n }\n}\n\n/** Reload one plugin — re-read its manifest and restart its worker. */\nexport class RefreshPluginAction extends Action {\n static deps = ['plugins'];\n constructor(pluginId) { super(); this.pluginId = pluginId; }\n async execute({ plugins }) { return plugins.refresh(this.pluginId); }\n}\n\n/**\n * Store a plugin secret.\n *\n * Not a setting: secrets go somewhere settings do not, which is why this is its own action\n * rather than SetSettingAction with a different key.\n */\nexport class SetPluginSecretAction extends Action {\n static deps = ['plugins'];\n constructor(pluginId, key, value) { super(); this.pluginId = pluginId; this.key = key; this.value = value; }\n async execute({ plugins }) { return plugins.setSecret(this.pluginId, this.key, this.value); }\n}\n\n/**\n * Open whatever a notification points at.\n *\n * The stat, the open, the panel and the failure message are one action because they are one\n * intent. Spread across a component they were a `.then` chain that had to know the API\n * answers `{ node }` rather than a node, and had to remember that a notification can\n * outlive its target — the item may be deleted, or live somewhere the reader has since\n * lost access to. Either way the click must say so rather than do nothing.\n */\nexport class OpenNotificationTargetAction extends Action {\n // Five of these used to exist only to feed a hand-call of `OpenFileAction.execute(r)` —\n // the one `.execute(` in the package — and one of them, `explorer`, fed nothing at all.\n // The coupling was invisible: a dep added to OpenFileAction broke THIS action at runtime\n // with an `undefined`, the same failure mode as the missing `overlay` above. Dispatching\n // instead also puts the open on the feed, which it never was: opening from a notification\n // and opening from a row click are the same intent and the engine should see both.\n static deps = ['api', 'engine', 'notifications', 'workbench'];\n\n constructor(nodeId) { super(); this.nodeId = nodeId; }\n\n async execute({ api, engine, notifications, workbench }) {\n let node;\n try {\n ({ node } = await api.stat(this.nodeId));\n } catch (err) {\n notifications.warn(err?.status === 403 || err?.code === 'forbidden'\n ? 'You no longer have access to that item.'\n : 'That item no longer exists.');\n return;\n }\n // `.next([...])`, because `dispatch` returns a feed and the panel must open AFTER the\n // file does — see platform/commands.js, which names this trap.\n await runAction(engine, new OpenFileAction(node));\n workbench.set({ infoPanel: true });\n }\n}\n\n/**\n * The base for anything a prompt dialog submits.\n *\n * The typed value is engine state (see viewState.js), so the action READS it rather than\n * being handed it by a callback. Subclasses implement `withValue`; the dialog closes first,\n * because every one of these used to do that by hand and two forgot to do it consistently.\n */\nexport class PromptAction extends Action {\n static deps = ['overlay', 'viewState'];\n\n async execute(r) {\n const held = r.viewState.get()[PROMPT];\n const value = (held?.value ?? '').trim();\n r.overlay.set({ dialog: null });\n if (value) await this.withValue(value, r);\n }\n}\n\n/** Rename the node this prompt was opened for. */\nexport class RenamePromptAction extends PromptAction {\n static deps = ['engine', 'overlay', 'viewState'];\n constructor(node) { super(); this.node = node; }\n async withValue(name, { engine }) {\n if (name !== this.node.name) engine.dispatch(new RenameAction(this.node.id, name));\n }\n}\n\n/**\n * Install the package the review dialog is about, with the capabilities that were ticked.\n *\n * The dialog used to carry an `onInstall` closure that did all of this, which put an effect\n * inside engine state — and ran it after the dispatching action's lease had been released,\n * with nothing of it on the feed. Two docblocks assert that a dialog spec holds no\n * functions; this is what makes that true.\n *\n * `pkg` and `trust` ride on the instance because they are what the review WAS; the grants\n * are read from viewState, because they are what the user did to it while it was open.\n */\nexport class InstallReviewedPluginAction extends Action {\n static deps = ['notifications', 'overlay', 'plugins', 'viewState', 'workbench'];\n\n constructor(pkg, trust, label) { super(); this.pkg = pkg; this.trust = trust; this.label = label; }\n\n async execute({ notifications, overlay, plugins, viewState, workbench }) {\n const grants = [...(viewState.get()[PLUGIN_REVIEW]?.grants || [])];\n overlay.set({ dialog: null });\n // Account installs upload the package and run a handshake that can take a while —\n // switch to the plugins view (which shows the plugin's loading state) and hold a sticky\n // \"Installing…\" toast so the user isn't left staring at nothing.\n workbench.set({ activity: 'plugins', sidebarVisible: true });\n const pending = notifications.info(`Installing “${this.label}”…`, { sticky: true });\n try {\n await plugins.install(this.pkg, { grants, trust: this.trust });\n notifications.dismiss(pending);\n notifications.success(`Installed “${this.label}”`);\n } catch (err) {\n notifications.dismiss(pending);\n notifications.error(`Install failed: ${err.message}`);\n }\n }\n}\n\n/** Fetch and review a plugin package from the URL that was typed. */\nexport class InstallPluginFromUrlPromptAction extends PromptAction {\n static deps = ['notifications', 'overlay', 'plugins', 'social', 'viewState', 'workbench'];\n async withValue(url, r) { await beginInstallFromUrl(r, url); }\n}\n\n/**\n * Create the collection the dialog's form describes.\n *\n * The form is already engine state — the dialog puts it in viewState as it is typed — so\n * this reads it rather than being handed a record through a callback. The form-to-record\n * shaping stays in the dialog, which is the thing that knows which fields the chosen\n * driver declared.\n */\nexport class CreateCollectionFromFormAction extends Action {\n static deps = ['engine', 'overlay'];\n constructor(record) { super(); this.record = record; }\n async execute({ engine, overlay }) {\n overlay.set({ dialog: null });\n if (this.record) engine.dispatch(new CreateCollectionAction(this.record));\n }\n}\n\n/**\n * Change one field of a draft, merging against what is stored RATHER than against what the\n * render saw.\n *\n * Every field handler used to build `{ ...form, [k]: value }` from the `form` its own render\n * closed over. Two changes to different fields before the next render therefore both merged\n * onto the same stale base, and the second silently dropped the first — type a name, switch\n * the storage driver in the same frame, and the name is gone with the Create button quietly\n * disabled. Renders are coalesced by rAF, so \"in the same frame\" is not rare, and a\n * backgrounded tab makes it certain.\n *\n * Reading current state inside the action removes the window entirely.\n *\n * @param {string} key which draft\n * @param {object} ref the dialog instance it belongs to\n * @param {object} patch the field(s) being changed\n * @param {object} fallback the draft's default, for when the held one is another dialog's\n */\nexport class PatchDraftAction extends Action {\n static deps = ['viewState'];\n\n constructor(key, ref, patch, fallback = {}) {\n super();\n this.key = key;\n this.ref = ref;\n this.patch = patch;\n this.fallback = fallback;\n }\n\n async execute({ viewState }) {\n const held = viewState.get()[this.key];\n const base = held && held.ref === this.ref ? held.form : this.fallback;\n viewState.set({ [this.key]: { ref: this.ref, form: { ...base, ...this.patch } } });\n }\n}\n\n// --- what commands used to do inline ---------------------------------------------\n//\n// bl/commands.js registered 40 commands and 36 of them were CLOSURES over `app` — the whole\n// world — doing effects outside the engine. That mattered more than the line count suggests,\n// because commands are the entry point for everything a person actually does: the palette,\n// every keybinding, every menu item, every row button. `ExecCommandAction` routed the intent\n// in and the handler walked straight back out, so the engine saw a command being run and\n// then nothing of what it did.\n//\n// A command is a DESCRIPTION now — `{ id, title, actions(...args) }`, where `actions` is a\n// pure factory. Everything below is where those handler bodies went.\n\n/**\n * The file a command acts on: the one it was handed, else the selection, else what is open.\n *\n * Three commands resolved this identically and a fourth got it slightly wrong. \"Nothing is\n * selected\" is a real answer and has to be said out loud — returning silently is\n * indistinguishable from a broken command.\n */\nfunction subjectOf({ explorer, navigation, notifications }, node = null) {\n const found = node || selectedNodesOf(explorer.get())[0] || navigation.activeTab()?.node;\n if (!found) notifications.info('Pick a file first — highlight one in the list, or open it.');\n return found;\n}\n\n/** Open the command palette, or quick-open, depending on the mode. */\nexport class OpenPaletteAction extends OverlayAction {\n constructor(mode = 'commands', query = '') { super(); this.mode = mode; this.query = query; }\n apply(o) { o.set({ palette: { mode: this.mode, query: this.query, index: 0 } }); }\n}\n\n/** Switch the main area between the drive, plugins and settings. */\nexport class SetActivityAction extends ShellAction {\n constructor(activity) { super(); this.activity = activity; }\n apply(wb) { wb.set({ activity: this.activity, sidebarVisible: true }); }\n}\n\n/**\n * Close the topmost transient thing — what Escape does.\n *\n * The ORDER is the whole content of this action, and it spans four resources: the menu\n * over the dialog, the dialog over the phone sheet, the sheet over the modal search, and\n * only when none of those is up does Escape start popping the panel stack. Getting it wrong\n * is not a crash — it is Escape closing the wrong thing, which is why it is written out\n * once, here, rather than distributed over whoever owns each overlay.\n */\nexport class CloseOverlaysAction extends Action {\n static deps = ['navigation', 'overlay', 'workbench'];\n async execute({ navigation, overlay, workbench }) {\n const o = overlay.get();\n const wb = workbench.get();\n if (o.contextMenu) return overlay.set({ contextMenu: null });\n if (o.dialog) return overlay.set({ dialog: null });\n if (wb.sheet) return workbench.set({ sheet: null });\n if (wb.searchModal) return workbench.set({ searchModal: false });\n if (o.palette) return overlay.set({ palette: null });\n if (o.pluginPanel) return overlay.set({ pluginPanel: null });\n // The activity panel floats over the page and carries a close button like everything\n // else in this ladder, and was the one such surface Escape did not reach. Below the\n // plugin panel deliberately: it opens BY ITSELF when a storage check finishes, and\n // Escape should not close what you opened on purpose in order to dismiss what\n // appeared on its own.\n if (o.activityPanel) return overlay.set({ activityPanel: false });\n // Nothing floating: Escape pops the top viewer panel instead.\n if (navigation.get().stack.length > 1) navigation.back();\n }\n}\n\n/**\n * Speak to search.\n *\n * On a TV this is mostly NOT about recognising anything: a remote's mic dictates into\n * whatever text field the platform keyboard is attached to, and is swallowed by the system\n * assistant when there isn't one. So the first job is to put the search field on screen and\n * focused, which is a feature on every TV whether or not the browser can transcribe. Where\n * it can — on-device only, see platform/voice.js — it also starts listening and types what\n * it hears.\n */\nexport class VoiceSearchAction extends Action {\n static deps = ['engine', 'voice'];\n async execute({ engine, voice }) {\n await voice.run({\n onText: (text, { final }) => {\n if (!text) return;\n engine.dispatch(new SetLaunchQueryAction(text));\n // Interim results keep the box in step with the speaker; only the settled\n // transcript is worth a round trip to the server.\n if (final) engine.dispatch(new SearchAction(text));\n },\n });\n }\n}\n\n/** Reindex the whole drive. Reports as a task rather than blocking — it takes minutes. */\nexport class RebuildIndexAction extends Action {\n static deps = ['activity', 'api', 'engine', 'notifications'];\n async execute({ activity, api, engine, notifications }) {\n try {\n const res = await api.reindex();\n await activity.refreshTasks();\n // \"…and show the user\" belongs to the action that decided to do the work, not to\n // the service that holds the list. Three network verbs used to open the panel as a\n // side effect of a fetch, from inside a resource.\n engine.dispatch(new ToggleActivityPanelAction(true));\n if (res.alreadyRunning) notifications.info('A rebuild is already running');\n } catch (err) {\n notifications.error(`Couldn't rebuild the index: ${err.message}`);\n }\n }\n}\n\n/**\n * Pick up files added, replaced or removed in the bucket by something other than Trove.\n *\n * No collection means no scan. This used to fall back to one called 'default', which on a\n * drive that has none scanned a collection that does not exist and reported the failure as\n * a scan error.\n */\nexport class ScanCollectionAction extends Action {\n static deps = ['activity', 'api', 'engine', 'explorer', 'notifications'];\n async execute({ activity, api, engine, explorer, notifications }) {\n const id = explorer.get().collectionId;\n if (!id) return notifications.info('Open a collection first — a scan is per collection.');\n try {\n const res = await api.scanCollection(id);\n await activity.refreshTasks();\n engine.dispatch(new ToggleActivityPanelAction(true));\n if (res.alreadyRunning) notifications.info('A scan of this collection is already running');\n activity.followUp();\n } catch (err) {\n notifications.error(`Couldn't scan “${id}”: ${err.message}`);\n }\n }\n}\n\n/**\n * Whether the backing stores are reachable from a browser at all.\n *\n * Separate from a scan: a scan asks what the store HOLDS, this asks whether it can be READ\n * from here — the failure that makes every file open to a spinner.\n */\nexport class CheckStorageAction extends Action {\n static deps = ['activity', 'api', 'engine', 'notifications'];\n async execute({ activity, api, engine, notifications }) {\n try {\n const res = await api.checkStorage();\n await activity.refresh();\n engine.dispatch(new ToggleActivityPanelAction(true));\n const problems = (res.results || []).reduce((n, r) => n + (r.findings?.length || 0), 0);\n if (problems) {\n notifications.warn(`Found ${problems} storage problem${problems === 1 ? '' : 's'} — see Activity`);\n } else if (!res.checked) {\n notifications.info('There are no collections to check yet');\n } else if (!res.corsChecked) {\n // Honest about what was not checked. Reporting \"all good\" having skipped the check\n // that matters is how a diagnostic stops being believed.\n notifications.info('Stores are reachable. Browser access was not checked — this drive has no public URL configured.');\n } else {\n notifications.success('Stores are reachable and allow browser access');\n }\n } catch (err) {\n notifications.error(`Couldn't check the stores: ${err.message}`);\n }\n }\n}\n\n/** Ask for files, then upload them into the open collection. */\nexport class PickAndUploadAction extends Action {\n static deps = ['engine', 'explorer'];\n async execute({ engine, explorer }) {\n const collection = explorer.get().collectionId;\n // Awaited, so the feed's `complete` means the upload started rather than the dialog\n // opened — and so the leases below it are still held when the upload uses them.\n const files = await pickFiles();\n if (files?.length) await runAction(engine, new UploadFilesAction(files, collection));\n }\n}\n\n/**\n * Copy a link to the subject, in one of its two spellings.\n *\n * `trove:` is what one document writes to link another; it means nothing to a browser. A\n * share link is a URL you can paste into a message. Both end at CopyTextAction, which is\n * the thing that knows a failed copy must still leave the text somewhere selectable.\n */\nexport class CopyLinkAction extends Action {\n static deps = ['engine', 'explorer', 'navigation', 'notifications'];\n /** @param {'trove'|'share'} kind */\n constructor(kind = 'trove', node = null) { super(); this.kind = kind; this.node = node; }\n async execute(r) {\n const node = subjectOf(r, this.node);\n if (!node) return;\n return r.engine.dispatch(this.kind === 'share'\n ? new CopyTextAction(shareUrl(node, location.origin),\n 'Link copied — anyone with access to this collection can open it')\n : new CopyTextAction(troveUri(node), `Copied ${troveUri(node)}`));\n }\n}\n\n/** Ask for a new name for the subject. The prompt's value is read by RenamePromptAction. */\nexport class RenameSubjectAction extends Action {\n static deps = ['engine', 'explorer', 'navigation', 'notifications'];\n constructor(node = null) { super(); this.node = node; }\n async execute(r) {\n const node = subjectOf(r, this.node);\n if (!node) return;\n r.engine.dispatch(new ShowDialogAction({\n kind: 'prompt', title: 'Rename', label: 'New name', value: node.name, confirmLabel: 'Rename',\n confirmActions: [new RenamePromptAction(node)],\n }));\n }\n}\n\n/**\n * Move the selection to the trash, confirming first unless that was turned off.\n *\n * Deleting the file you have OPEN is the obvious intent when nothing is selected, so it\n * counts as the subject. The confirmation says what actually happens: telling someone a\n * file will be \"permanently deleted\" when it goes to the trash trains them to fear a safe\n * action, and the reverse — promising recovery that doesn't exist — is worse.\n */\nexport class DeleteSubjectAction extends Action {\n static deps = ['engine', 'explorer', 'navigation', 'notifications', 'settings'];\n async execute(r) {\n const nodes = selectedNodesOf(r.explorer.get());\n const open = nodes.length ? null : r.navigation.activeTab()?.node;\n if (open) nodes.push(open);\n if (!nodes.length) {\n r.notifications.info('Pick a file first — highlight one in the list, or open it.');\n return;\n }\n const deleteThem = new DeleteAction(nodes.map((n) => n.id));\n if (!r.settings.get('explorer.confirmDelete')) return r.engine.dispatch(deleteThem);\n r.engine.dispatch(new ShowDialogAction({\n kind: 'confirm',\n title: `Move ${nodes.length} item${nodes.length > 1 ? 's' : ''} to the trash?`,\n body: nodes.length === 1\n ? `\"${nodes[0].name}\" leaves the drive but is kept, and can be restored from the trash.`\n : 'They leave the drive but are kept, and can be restored from the trash.',\n confirmLabel: 'Move to trash',\n confirmActions: [deleteThem],\n }));\n }\n}\n\n/** Show the trash, and get back to the drive to see it. */\nexport class ShowTrashAction extends Action {\n static deps = ['engine'];\n async execute({ engine }) {\n engine.dispatch(new TrashAction('list'));\n engine.dispatch(new ShowHomeAction());\n }\n}\n\n/** Open the subject in a viewer. */\nexport class OpenSubjectAction extends Action {\n static deps = ['engine', 'explorer', 'navigation', 'notifications'];\n constructor(node = null) { super(); this.node = node; }\n async execute(r) {\n const node = subjectOf(r, this.node);\n if (node) return r.engine.dispatch(new OpenFileAction(node));\n }\n}\n\n/** Save the subject to the machine. */\nexport class DownloadSubjectAction extends Action {\n static deps = ['api', 'explorer', 'navigation', 'notifications'];\n constructor(node = null) { super(); this.node = node; }\n async execute(r) {\n const target = subjectOf(r, this.node);\n if (!target?.id) return;\n try {\n const { url, revoke } = await r.api.download(target.id, target.name);\n triggerDownload(url, target.name);\n // A blob URL pins the bytes until it is released; the click has already happened by\n // the time this runs.\n if (revoke) setTimeout(() => URL.revokeObjectURL(url), 60_000);\n } catch (err) {\n r.notifications.error(`Couldn't download ${target.name}: ${err.message}`);\n }\n }\n}\n\n/** Keep a copy of the subject for offline use, or stop keeping one. */\nexport class PinAction extends Action {\n static deps = ['explorer', 'navigation', 'notifications', 'offline'];\n constructor(node = null, pinned = true) { super(); this.node = node; this.pinned = pinned; }\n async execute(r) {\n const target = subjectOf(r, this.node);\n if (!target?.id) return;\n return this.pinned ? r.offline.pin(target) : r.offline.unpin(target.id);\n }\n}\n\n// --- API keys (admin) ------------------------------------------------------------\n\nexport class StartApiKeyDraftAction extends ApiKeysAction {\n apply(s) { s.set({ draft: { name: '', expiresInDays: '', caps: {} }, error: null }); }\n}\nexport class CancelApiKeyDraftAction extends ApiKeysAction {\n apply(s) { s.set({ draft: null }); }\n}\n/** Forget the freshly minted secret. On dismiss, and after a copy. */\nexport class ClearMintedApiKeyAction extends ApiKeysAction {\n apply(s) { if (s.get().minted) s.set({ minted: null }); }\n}\n\n/**\n * Mint the key the draft describes.\n *\n * The days-to-instant conversion is here rather than in the form because the server compares\n * against its own clock: \"30 days from whenever this arrives\" is not what was chosen. The\n * draft is cleared BEFORE the mint so the form cannot be submitted twice while it is in\n * flight.\n */\nexport class MintApiKeyFromDraftAction extends Action {\n static deps = ['apiKeys', 'engine'];\n async execute({ apiKeys, engine }) {\n const draft = apiKeys.get().draft;\n const scopes = draftScopesOf(apiKeys.get());\n if (!draft?.name?.trim() || !scopes) return;\n const days = Number(draft.expiresInDays);\n const expiresAt = draft.expiresInDays !== '' && Number.isFinite(days) && days > 0\n ? Date.now() + days * 86400_000\n : null;\n apiKeys.set({ draft: null });\n return engine.dispatch(new MintApiKeyAction({ name: draft.name.trim(), scopes, expiresAt }));\n }\n}\n\n// --- collections -----------------------------------------------------------------\n\n/**\n * Switch to a collection, or offer the choice when none was named.\n *\n * From the palette or a keybinding there is no pointer to anchor a menu to, so it opens\n * centred near the top.\n */\nexport class SwitchCollectionAction extends Action {\n static deps = ['engine', 'explorer', 'notifications'];\n constructor(collectionId = null) { super(); this.collectionId = collectionId; }\n async execute({ engine, explorer, notifications }) {\n if (this.collectionId) {\n engine.dispatch(new NavigateAction(this.collectionId));\n engine.dispatch(new ShowHomeAction());\n return;\n }\n const items = collectionMenuOf(explorer.get(),\n (id) => new ExecCommandAction('collections.switch', id),\n () => new ExecCommandAction('collections.create'));\n if (!items.length) return notifications.info('This drive has one collection.');\n // No geometry: this comes from a command, not from a click, so the overlay centres it.\n // The arithmetic that used to be here needed `window` and carried a `typeof window`\n // guard precisely because layout has no business in the bl layer.\n engine.dispatch(new ShowContextMenuAction(items));\n }\n}\n\n/**\n * Show the details panel — but only when there is a file for it to be about.\n *\n * With nothing open there is nothing to show, and flipping the flag silently was\n * indistinguishable from a broken command.\n */\nexport class ToggleDetailsAction extends Action {\n static deps = ['navigation', 'notifications', 'workbench'];\n async execute({ navigation, notifications, workbench }) {\n if (!navigation.activeTab()) {\n notifications.info('Open a file to see its details and conversation.');\n return;\n }\n workbench.set({ infoPanel: !workbench.get().infoPanel });\n }\n}\n\n// --- plugins ---------------------------------------------------------------------\n\n/** Ask for a .zip and take it through the install review. */\nexport class PickAndInstallPluginAction extends Action {\n static deps = ['notifications', 'overlay', 'plugins', 'social', 'workbench'];\n async execute(r) {\n const file = await pickZip();\n if (file) await beginInstallFromFile(r, file);\n }\n}\n\n/**\n * Run a command a PLUGIN registered.\n *\n * Plugin commands used to be handlers proxying straight over RPC, which left the same hole\n * for them that `ExecCommandAction` closed for the host's own: the engine could see a plugin\n * command being invoked only as whatever state changed afterwards. Now every command in the\n * registry — host or plugin — resolves to actions.\n */\nexport class InvokePluginCommandAction extends Action {\n static deps = ['plugins'];\n constructor(pluginId, name, args = []) {\n super();\n this.pluginId = pluginId;\n this.name = name;\n this.args = args;\n }\n async execute({ plugins }) {\n return plugins.invokeCommand(this.pluginId, this.name, this.args);\n }\n}\n\n/**\n * Forget the open item's conversation — but only if it is still the one named.\n *\n * Dispatched when the last observer of a `sidecarFor` query goes away. Scoped to the node\n * because kill and boot are not ordered against each other: switching from A to B can kill\n * A's query after B's has booted, and an unscoped clear would wipe what B just loaded.\n */\nexport class ClearSidecarAction extends Action {\n static deps = ['social'];\n constructor(nodeId) { super(); this.nodeId = nodeId; }\n async execute({ social }) {\n if (social.get().sidecar?.nodeId === this.nodeId) social.loadSidecar(null);\n }\n}\n\n// --- key rotation ---------------------------------------------------------------\n//\n// Rotation moves a collection onto a fresh key, object by object, bounded by wall-clock\n// time per slice. It runs on the server; what the UI needs is to see where it is, what it\n// would cost before anyone starts, and a way to stop it.\n\n/**\n * Read where the rotation stands, and what one would cost.\n *\n * The estimate comes with the state rather than only before starting: on a metered store\n * this is a real bill, and the number is worth having in front of the button.\n */\n/**\n * Read one collection's access list.\n *\n * Takes the collection rather than reading the open one, because this is asked from a\n * screen that lists every collection — the rotation equivalent next door can assume the\n * open one and this cannot.\n */\nexport class LoadGrantsAction extends Action {\n static deps = ['acl', 'api', 'notifications'];\n constructor(collectionId) { super(); this.collectionId = collectionId; }\n async execute({ acl, api, notifications }) {\n const collectionId = this.collectionId;\n if (!collectionId) return;\n acl.set({ collectionId, loading: true, error: null });\n try {\n const res = await api.collectionGrants(collectionId);\n acl.set({ grants: res?.grants || [], admins: res?.admins || [], loading: false });\n } catch (err) {\n // A non-admin gets a 403, and that is the correct answer rather than an error worth\n // a toast — the section simply does not offer itself. Same reasoning as the rotation\n // loader immediately below.\n acl.set({ loading: false, error: err?.message || 'Could not read the access list' });\n if (err?.status !== 403) notifications.error?.(err?.message || 'Could not read the access list');\n }\n }\n}\n\n/**\n * Grant or revoke, which are one operation.\n *\n * An empty capability list removes the grant — that is `setGrant`'s existing shape, and\n * keeping it means revoking cannot drift from granting. Reloads afterwards rather than\n * patching the slice, because the server expands capabilities (admin implies the rest) and\n * a client that guessed the expansion would eventually disagree with it.\n */\nexport class SetGrantAction extends Action {\n static deps = ['acl', 'api', 'engine', 'notifications'];\n constructor(collectionId, grant) { super(); this.collectionId = collectionId; this.grant = grant; }\n async execute({ acl, api, engine, notifications }) {\n acl.set({ busy: true });\n try {\n await api.setCollectionGrant(this.collectionId, this.grant);\n const who = this.grant.type === 'anyone' ? 'everyone' : this.grant.subject;\n notifications.success?.(this.grant.capabilities?.length\n ? `Access for ${who} updated`\n : `Access for ${who} removed`);\n } catch (err) {\n notifications.error?.(err?.message || 'Could not change access');\n } finally {\n acl.set({ busy: false });\n await runAction(engine, new LoadGrantsAction(this.collectionId));\n }\n }\n}\n\nexport class LoadRotationAction extends Action {\n static deps = ['api', 'explorer', 'notifications', 'rotation'];\n\n /** @param {string} [collectionId] which collection; defaults to the open one */\n constructor(collectionId = null) { super(); this.collectionId = collectionId; }\n\n async execute({ api, explorer, notifications, rotation }) {\n const collectionId = this.collectionId || explorer.get().collectionId;\n if (!collectionId) return;\n // CLEARED when the collection changes, not merely re-stamped. `rotation` is one slice\n // for whichever collection the settings screen is looking at, and stamping the new id\n // while leaving the previous collection's `rotation` and `estimate` in place meant a\n // failed load — which sets only `{loading, error}` — left collection A's running\n // progress on screen under B's fingerprint, indefinitely, with a Start/Stop button\n // beside it.\n const switching = rotation.get().collectionId !== collectionId;\n rotation.set(switching\n ? { collectionId, rotation: null, estimate: null, loading: true, error: null }\n : { collectionId, loading: true, error: null });\n try {\n // Both together: the estimate is meaningless without knowing whether one is already\n // running, and a screen showing one without the other invites starting a second.\n const [state, estimate] = await Promise.all([\n api.rotationState(collectionId),\n api.rotationEstimate(collectionId).catch(() => null),\n ]);\n rotation.set({ rotation: state?.rotation ?? null, estimate: estimate ?? null, loading: false });\n } catch (err) {\n // A non-admin gets a 403 here and that is the correct answer, not an error worth a\n // toast — the section simply does not render.\n rotation.set({ loading: false, error: err?.message || 'Could not read the rotation state' });\n if (err?.status !== 403) notifications.error?.(err?.message || 'Could not read the rotation state');\n }\n }\n}\n\n/** Start moving this collection onto a new key. */\nexport class BeginRotationAction extends Action {\n static deps = ['api', 'engine', 'explorer', 'notifications', 'rotation'];\n async execute({ api, engine, explorer, notifications, rotation }) {\n const collectionId = explorer.get().collectionId;\n if (!collectionId) return;\n rotation.set({ busy: true });\n try {\n const res = await api.beginRotation(collectionId);\n rotation.set({ rotation: res?.rotation ?? null, busy: false });\n // The new key becomes current immediately, before any file moves — so the\n // fingerprint on screen is already out of date. Reload the collections or it keeps\n // showing the key the collection is moving OFF, which is the one thing this field\n // exists to get right.\n engine.dispatch(new LoadCollectionsAction());\n notifications.info('Key rotation started. It runs in the background and survives a reload.');\n } catch (err) {\n rotation.set({ busy: false });\n notifications.error(err?.message || 'Could not start the rotation');\n }\n return engine.dispatch(new LoadRotationAction());\n }\n}\n\n/**\n * Stop one.\n *\n * What has already moved stays moved and the new key stays current, so this is untidy\n * rather than destructive — worth saying, because \"cancel\" on a job that has rewritten\n * half a collection sounds like it might undo something.\n */\nexport class CancelRotationAction extends Action {\n static deps = ['api', 'engine', 'explorer', 'notifications', 'rotation'];\n async execute({ api, engine, explorer, notifications, rotation }) {\n const collectionId = explorer.get().collectionId;\n if (!collectionId) return;\n rotation.set({ busy: true });\n try {\n await api.cancelRotation(collectionId);\n notifications.info('Rotation stopped. Files already moved stay on the new key.');\n } catch (err) {\n notifications.error(err?.message || 'Could not stop the rotation');\n }\n rotation.set({ busy: false });\n return engine.dispatch(new LoadRotationAction());\n }\n}\n",
52
+ "// A minimal, symmetric JSON-RPC-ish channel over a MessagePort. Used on both\n// ends of the host↔plugin boundary: the host keeps one port, the sandboxed\n// iframe gets the other (transferred cross-origin at init), so neither side ever\n// touches the other's globals — everything is messages. Requests get a reply;\n// events are fire-and-forget. Handlers may be async and may throw; the error is\n// serialized (code/message) back to the caller as a rejected promise.\n\nexport class RpcChannel {\n /**\n * @param {MessagePort|Window} port a MessagePort (preferred) or window\n * @param {object} [opts]\n * @param {(method:string, params:any) => any} [opts.onCall] handler for incoming requests\n * @param {(method:string, params:any) => void} [opts.onEvent] handler for incoming events\n * @param {string} [opts.targetOrigin] required when port is a Window\n */\n constructor(port, opts = {}) {\n this.port = port;\n this.onCall = opts.onCall;\n this.onEvent = opts.onEvent;\n this.targetOrigin = opts.targetOrigin;\n this.seq = 0;\n this.pending = new Map();\n this._listener = (e) => this._receive(e.data, e);\n if (typeof port.addEventListener === 'function') port.addEventListener('message', this._listener);\n else port.onmessage = this._listener;\n port.start?.();\n }\n\n _post(msg, transfer) {\n if (this.targetOrigin) this.port.postMessage(msg, this.targetOrigin, transfer);\n else this.port.postMessage(msg, transfer);\n }\n\n /** Call a remote method, awaiting its result. */\n call(method, params, { timeout = 30000, transfer } = {}) {\n const id = ++this.seq;\n return new Promise((resolve, reject) => {\n const timer = timeout\n ? setTimeout(() => {\n this.pending.delete(id);\n reject(new Error(`RPC timeout: ${method}`));\n }, timeout)\n : null;\n this.pending.set(id, { resolve, reject, timer });\n this._post({ __trove: 'req', id, method, params }, transfer);\n });\n }\n\n /** Fire an event; no reply expected. */\n emit(method, params, transfer) {\n this._post({ __trove: 'event', method, params }, transfer);\n }\n\n async _receive(msg, event) {\n if (!msg || msg.__trove == null) return;\n if (msg.__trove === 'res') {\n const p = this.pending.get(msg.id);\n if (!p) return;\n this.pending.delete(msg.id);\n if (p.timer) clearTimeout(p.timer);\n if (msg.error) p.reject(Object.assign(new Error(msg.error.message), msg.error));\n else p.resolve(msg.result);\n return;\n }\n if (msg.__trove === 'event') {\n try {\n await this.onEvent?.(msg.method, msg.params, event);\n } catch (err) {\n console.error('rpc event handler error', err);\n }\n return;\n }\n if (msg.__trove === 'req') {\n let result, error;\n try {\n result = await this.onCall?.(msg.method, msg.params, event);\n } catch (err) {\n error = { message: err?.message || String(err), code: err?.code || 'error' };\n }\n this._post({ __trove: 'res', id: msg.id, result, error });\n }\n }\n\n dispose() {\n if (typeof this.port.removeEventListener === 'function') {\n this.port.removeEventListener('message', this._listener);\n }\n for (const p of this.pending.values()) {\n if (p.timer) clearTimeout(p.timer);\n p.reject(new Error('RPC channel disposed'));\n }\n this.pending.clear();\n this.port.close?.();\n }\n}\n",
53
+ "// The host ↔ plugin wire protocol, in one place.\n//\n// Envelope (over the transferred MessagePort):\n// { __trove: 'req', id, method, params } plugin → host, expects a 'res'\n// { __trove: 'res', id, result | error } host → plugin\n// { __trove: 'event', method, params } either direction, fire-and-forget\n// Bootstrap (over postMessage, before the port exists):\n// { __trove: 'ready', protocolVersion } plugin → host\n// { __trove: 'init', manifest, capabilities, storage, online, role, protocolVersion }\n// { __trove: 'boot-error', error } plugin → host (module load failed)\n//\n// NOTE: browser.js is injected into the sandboxed frame as a TEXT blob (it must be a\n// self-contained IIFE with no imports), so it cannot import this module. It declares\n// its own `SDK_PROTOCOL_VERSION` constant instead, and protocol.test.js asserts the\n// two stay equal — a drift guard in place of an import.\n\n/** Bumped MAJOR when a change breaks older plugins; MINOR for additive changes. */\nexport const PROTOCOL_VERSION = '1.0';\n\nexport function majorOf(version) {\n return String(version || '').split('.')[0] || '0';\n}\n\n/** Whether a plugin built against `version` can talk to this host. */\nexport function isCompatible(version) {\n // An SDK older than versioning itself reports nothing — accept it (it predates the\n // field and the protocol hasn't broken yet); a differing MAJOR is a hard mismatch.\n if (!version) return true;\n return majorOf(version) === majorOf(PROTOCOL_VERSION);\n}\n\n// There are no `contribute:*` methods: contributions are DECLARED IN THE MANIFEST and\n// registered by the host before the plugin boots. A plugin can only ever drive what it\n// declared (`ui:status`, `context:setRegister`), never add to it.\n\n/** Canonical host methods a plugin may call. Grouped by namespace. */\nexport const METHODS = {\n activated: 'activated',\n // Note: 'command:execute' travels BOTH ways on the same channel — the host calls it\n // to run a plugin-contributed command, and a plugin calls it (needs that command in\n // its `commands` allowlist) to run someone else's. The direction disambiguates.\n command: { execute: 'command:execute' },\n resources: { list: 'resources:list', read: 'resources:read' },\n files: {\n read: 'files:read', list: 'files:list', stat: 'files:stat', downloadUrl: 'files:downloadUrl',\n index: 'files:index',\n // Bytes by range — the only way a viewer gets binary content at all, since `read`\n // answers text and a sandboxed frame cannot authenticate a bare download URL.\n bytes: 'files:bytes',\n // A minted URL for a media element. See pluginRpc.js for why this one host URL crosses.\n mediaUrl: 'files:mediaUrl',\n offline: {\n start: 'files:offline:start', status: 'files:offline:status',\n cancel: 'files:offline:cancel', remove: 'files:offline:remove',\n },\n },\n net: { fetch: 'net:fetch' },\n storage: { sql: 'storage:sql' },\n settings: { get: 'settings:get', set: 'settings:set', getSecret: 'settings:getSecret' },\n ui: { showPanel: 'ui:showPanel', status: 'ui:status' },\n context: { setRegister: 'context:setRegister' },\n media: { metadata: 'media:metadata', playbackState: 'media:playbackState', position: 'media:position', action: 'media:action', clear: 'media:clear' },\n dock: { enable: 'dock:enable', disable: 'dock:disable', close: 'dock:close' },\n};\n\n/** Events a plugin may emit to the host (fire-and-forget, no reply). */\nexport const EVENTS = {\n manifest: 'manifest',\n uiToast: 'ui:toast',\n uiBadge: 'ui:badge',\n};\n",
54
+ "/* es-module-lexer 1.7.0 */\nexport var ImportType;!function(A){A[A.Static=1]=\"Static\",A[A.Dynamic=2]=\"Dynamic\",A[A.ImportMeta=3]=\"ImportMeta\",A[A.StaticSourcePhase=4]=\"StaticSourcePhase\",A[A.DynamicSourcePhase=5]=\"DynamicSourcePhase\",A[A.StaticDeferPhase=6]=\"StaticDeferPhase\",A[A.DynamicDeferPhase=7]=\"DynamicDeferPhase\"}(ImportType||(ImportType={}));const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];export function parse(E,g=\"@\"){if(!C)return init.then((()=>parse(E)));const I=E.length+1,w=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;w>0&&C.memory.grow(Math.ceil(w/65536));const K=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,K,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split(\"\\n\").length}:${C.e()-E.lastIndexOf(\"\\n\",C.e()-1)}`),{idx:C.e()});const o=[],D=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.it(),g=C.ai(),I=C.id(),w=C.ss(),K=C.se();let D;C.ip()&&(D=k(E.slice(-1===I?A-1:A,-1===I?Q+1:Q))),o.push({n:D,t:B,s:A,e:Q,ss:w,se:K,d:I,a:g})}for(;C.re();){const A=C.es(),Q=C.ee(),B=C.els(),g=C.ele(),I=E.slice(A,Q),w=I[0],K=B<0?void 0:E.slice(B,g),o=K?K[0]:\"\";D.push({s:A,e:Q,ls:B,le:g,n:'\"'===w||\"'\"===w?k(I):I,ln:'\"'===o||\"'\"===o?k(K):K})}function k(A){try{return(0,eval)(A)}catch(A){}}return[o,D,!!C.f(),!!C.ms()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++)}let C;const E=()=>{return A=\"AGFzbQEAAAABKwhgAX8Bf2AEf39/fwBgAAF/YAAAYAF/AGADf39/AX9gAn9/AX9gA39/fwADMTAAAQECAgICAgICAgICAgICAgICAgIAAwMDBAQAAAUAAAAAAAMDAwAGAAAABwAGAgUEBQFwAQEBBQMBAAEGDwJ/AUHA8gALfwBBwPIACwd6FQZtZW1vcnkCAAJzYQAAAWUAAwJpcwAEAmllAAUCc3MABgJzZQAHAml0AAgCYWkACQJpZAAKAmlwAAsCZXMADAJlZQANA2VscwAOA2VsZQAPAnJpABACcmUAEQFmABICbXMAEwVwYXJzZQAUC19faGVhcF9iYXNlAwEKzkQwaAEBf0EAIAA2AoAKQQAoAtwJIgEgAEEBdGoiAEEAOwEAQQAgAEECaiIANgKECkEAIAA2AogKQQBBADYC4AlBAEEANgLwCUEAQQA2AugJQQBBADYC5AlBAEEANgL4CUEAQQA2AuwJIAEL0wEBA39BACgC8AkhBEEAQQAoAogKIgU2AvAJQQAgBDYC9AlBACAFQSRqNgKICiAEQSBqQeAJIAQbIAU2AgBBACgC1AkhBEEAKALQCSEGIAUgATYCACAFIAA2AgggBSACIAJBAmpBACAGIANGIgAbIAQgA0YiBBs2AgwgBSADNgIUIAVBADYCECAFIAI2A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AhAsGkEAKAKwCiEEDAELIAIQGkEAQQAoArAKQQJqIgQ2ArAKC0EBECkhA0EAKAKwCiECCwJAIAIgBUYNACAFIARBACAAIAAgAUYiAhtBACABIAIbEAILIAMLcgEEf0EAKAKwCiEAQQAoArQKIQECQAJAA0AgAEECaiECIAAgAU8NAQJAAkAgAi8BACIDQaR/ag4CAQQACyACIQAgA0F2ag4EAgEBAgELIABBBGohAAwACwtBACACNgKwChAlQQAPC0EAIAI2ArAKQd0AC0kBA39BACEDAkAgAkUNAAJAA0AgAC0AACIEIAEtAAAiBUcNASABQQFqIQEgAEEBaiEAIAJBf2oiAg0ADAILCyAEIAVrIQMLIAMLC+wBAgBBgAgLzgEAAHgAcABvAHIAdABtAHAAbwByAHQAZgBvAHIAZQB0AGEAbwB1AHIAYwBlAHIAbwBtAHUAbgBjAHQAaQBvAG4AcwBzAGUAcgB0AHYAbwB5AGkAZQBkAGUAbABlAGMAbwBuAHQAaQBuAGkAbgBzAHQAYQBuAHQAeQBiAHIAZQBhAHIAZQB0AHUAcgBkAGUAYgB1AGcAZwBlAGEAdwBhAGkAdABoAHIAdwBoAGkAbABlAGkAZgBjAGEAdABjAGYAaQBuAGEAbABsAGUAbABzAABB0AkLEAEAAAACAAAAAAQAAEA5AAA=\",\"undefined\"!=typeof Buffer?Buffer.from(A,\"base64\"):Uint8Array.from(atob(A),(A=>A.charCodeAt(0)));var A};export const init=WebAssembly.compile(E()).then(WebAssembly.instantiate).then((({exports:A})=>{C=A}));export const initSync=()=>{if(C)return;const A=new WebAssembly.Module(E());C=new WebAssembly.Instance(A).exports};",
55
+ "// Multi-file plugins — native ESM without a bundler. A package can put its code\n// under `src/` and use ordinary relative imports (`import './util.js'`); assets\n// live anywhere else and are reached as opaque resources. We can't just let the\n// sandboxed frame import these: it's on an opaque origin and can't fetch its own\n// files, and a blob: module's base URL is meaningless so `./util.js` wouldn't\n// resolve. So the host loads every `src/*.js` module as a blob: URL inside the\n// frame and wires them together with an import map — and, because an import map is\n// keyed by name (not text order), circular imports and any load order just work.\n//\n// The one preprocessing step: relative specifiers are rewritten to a canonical\n// `trove:/<path>` key (resolved against the importing module) so they match the\n// import map instead of resolving against the opaque blob base. We use\n// es-module-lexer to find the exact specifier spans, so strings/comments/regex are\n// never touched. The SDK is exposed as the bare specifier `trove`, so plugins can\n// write either `import { activate } from 'trove'` or use the `globalThis.trove`\n// the injected SDK also sets.\n\nimport { init, parse } from 'es-module-lexer';\n\nconst JS_RE = /\\.m?js$/i;\n\n/** A file that participates in the module graph (code under `src/`). */\nexport function isSourceModule(path) {\n return /^src\\//i.test(path) && JS_RE.test(path);\n}\n\n/** Whether a package should run in ESM module mode (its entry is a src module). */\nexport function isModuleEntry(manifest) {\n return isSourceModule(manifest.entry || '');\n}\n\nfunction dirParts(p) {\n const i = p.lastIndexOf('/');\n return (i < 0 ? '' : p.slice(0, i)).split('/').filter(Boolean);\n}\n\n/** Resolve a relative specifier against the importer's package path. */\nfunction resolvePath(importer, spec) {\n const stack = dirParts(importer);\n for (const part of spec.split('/')) {\n if (part === '' || part === '.') continue;\n else if (part === '..') stack.pop();\n else stack.push(part);\n }\n return stack.join('/');\n}\n\n/**\n * Build the rewritten module set + entry for a package. Returns\n * { modules: { path: code }, entry } where each module's relative imports point at\n * canonical `trove:/<path>` keys. Only `src/*.js` files are included.\n */\nexport async function buildModuleGraph(pkg) {\n await init;\n const modules = {};\n for (const [path, bytes] of pkg.files) {\n if (isSourceModule(path)) modules[path] = new TextDecoder().decode(bytes);\n }\n const has = (p) => Object.prototype.hasOwnProperty.call(modules, p);\n const resolveModule = (importer, spec) => {\n const r = resolvePath(importer, spec);\n if (has(r)) return r;\n if (has(r + '.js')) return r + '.js';\n if (has(r + '.mjs')) return r + '.mjs';\n if (has(r + '/index.js')) return r + '/index.js';\n return r; // unresolved → import fails with a clear \"no such module\" error\n };\n const rewritten = {};\n for (const [path, code] of Object.entries(modules)) {\n rewritten[path] = rewriteSpecifiers(code, path, resolveModule);\n }\n return { modules: rewritten, entry: pkg.manifest.entry };\n}\n\n/** Rewrite relative import specifiers in one module to canonical map keys. */\nexport function rewriteSpecifiers(code, path, resolveModule) {\n const [imports] = parse(code);\n let out = '';\n let last = 0;\n for (const imp of imports) {\n if (imp.n == null) continue; // dynamic import with a non-literal argument\n if (imp.n[0] !== '.') continue; // only relative specifiers are remapped\n const key = 'trove:/' + resolveModule(path, imp.n);\n // Static spans exclude the quotes; dynamic import() spans include them.\n const replacement = imp.d === -1 ? key : JSON.stringify(key);\n out += code.slice(last, imp.s) + replacement;\n last = imp.e;\n }\n return out + code.slice(last);\n}\n",
56
+ "// FrameManager — the sandbox seam: everything about creating, handshaking with, and\n// destroying a plugin's iframe.\n//\n// A plugin's code runs inside a sandboxed iframe on an OPAQUE origin (sandbox\n// allow-scripts, no allow-same-origin): it can't touch the host DOM, can't read\n// cookies/storage, and can't even fetch its own package files. The host injects our\n// browser SDK + the plugin's entry into the frame's srcdoc; everything else flows over\n// a single transferred MessagePort, capability-gated by what the user granted.\n//\n// Every frame — the plugin's primary (background) instance and each viewer/panel —\n// comes from `spawn()`, so they all share the same wiring and capabilities.\n\nimport { RpcChannel } from '@3sln/trove/plugin-sdk/rpc.js';\nimport SDK_SOURCE from '@3sln/trove/plugin-sdk/browser.js' with { type: 'text' };\nimport { PROTOCOL_VERSION, isCompatible } from '@3sln/trove/plugin-sdk/protocol.js';\nimport { buildModuleGraph, isModuleEntry } from './pluginModules.js';\n\nconst HANDSHAKE_TIMEOUT_MS = 15000;\n\nexport class FrameManager {\n /**\n * @param {object} deps\n * @param {import('./pluginMedia.js').MediaController} deps.media\n * @param {import('./pluginDock.js').FrameDock} deps.dock\n */\n constructor({ media, dock } = {}) {\n this.media = media;\n this.dock = dock;\n }\n\n /**\n * Create ONE sandboxed iframe wired with `record`'s granted capabilities, run the\n * handshake, and resolve to a live frame `{ role, iframe, channel, record }`.\n * @param {object} record the plugin runtime record\n * @param {'primary'|'viewer'} role\n * @param {{onCall:Function, onEvent:Function, online:boolean}} wiring\n */\n async spawn(record, role, wiring) {\n const iframe = document.createElement('iframe');\n iframe.style.cssText = HIDDEN_STYLE;\n // Opaque-origin sandbox: scripts only, no same-origin, no top navigation.\n //\n // Deliberately NO `allow-popups`. The CSP below blocks fetch/XHR/WebSocket/beacon\n // so that all network access is brokered by the host against the plugin's declared\n // endpoints — but no CSP directive covers `window.open`, so a popup is a hole\n // straight through that broker: one real click and a plugin granted `files` but not\n // `network` can navigate a new context to `https://attacker/?d=<file bytes>`.\n // A plugin that genuinely needs to send the user somewhere asks the host to do it.\n iframe.setAttribute('sandbox', 'allow-scripts allow-forms');\n iframe.setAttribute('referrerpolicy', 'no-referrer');\n // A frame can boot at a different ENTRY MODULE of the plugin's one module tree —\n // that's all an opener is. Same package, same shared code, different entry.\n const entry = wiring?.entry;\n if (entry) {\n record._entrySrcdoc ||= {};\n record._entrySrcdoc[entry] ||= await buildSrcdoc({ ...record.manifest, entry }, record.files);\n iframe.srcdoc = record._entrySrcdoc[entry];\n } else {\n record._srcdoc ||= await buildSrcdoc(record.manifest, record.files);\n iframe.srcdoc = record._srcdoc;\n }\n const frame = { role, iframe, channel: null, record, place: null, dock: null, mediaActions: null };\n document.body.appendChild(iframe);\n try {\n await this.#handshake(record, frame, wiring);\n } catch (err) {\n // Never leave a hung/failed frame's iframe (or its channel) behind.\n try { frame.channel?.dispose(); } catch { /* ignore */ }\n iframe.remove();\n throw err;\n }\n return frame;\n }\n\n // Resolves once the frame's plugin calls activate(); rejects (and fully cleans up\n // its global message listener + timer) on boot error, iframe error, or timeout.\n #handshake(record, frame, { onCall, onEvent, online }) {\n return new Promise((resolve, reject) => {\n const { iframe } = frame;\n const manifest = record.manifest;\n let settled = false;\n let timer = 0;\n const cleanup = () => { window.removeEventListener('message', onReady); if (timer) clearTimeout(timer); };\n const fail = (msg) => { if (settled) return; settled = true; cleanup(); reject(new Error(msg)); };\n const onReady = (e) => {\n if (e.source !== iframe.contentWindow) return;\n if (e.data?.__trove === 'boot-error') return fail(e.data.error || 'Plugin failed to load its modules');\n if (e.data?.__trove !== 'ready') return;\n // A plugin built against an incompatible protocol MAJOR can't be talked to —\n // fail loudly here rather than letting calls misbehave in obscure ways.\n if (!isCompatible(e.data.protocolVersion)) {\n return fail(`Plugin speaks protocol ${e.data.protocolVersion}, this host speaks ${PROTOCOL_VERSION}`);\n }\n // Ready received — the transferred port takes over; stop listening globally.\n window.removeEventListener('message', onReady);\n const channel = new MessageChannel();\n frame.channel = new RpcChannel(channel.port1, {\n onCall: (m, p) => onCall(record, m, p, frame),\n onEvent: (m, p) => onEvent(record, m, p, frame),\n });\n // activate() success/failure settles this promise (and clears the timer).\n frame.resolveActivated = (f) => { if (settled) return; settled = true; if (timer) clearTimeout(timer); resolve(f); };\n frame.rejectActivated = (err) => { if (settled) return; settled = true; if (timer) clearTimeout(timer); reject(err); };\n // Opaque origin → target '*'; the transferred port is the real capability.\n iframe.contentWindow.postMessage(\n { __trove: 'init', manifest, capabilities: record.grants, storage: record.storage, online, role: frame.role, protocolVersion: PROTOCOL_VERSION },\n '*',\n [channel.port2],\n );\n };\n timer = setTimeout(() => fail('Plugin handshake timed out'), HANDSHAKE_TIMEOUT_MS);\n window.addEventListener('message', onReady);\n iframe.addEventListener('error', () => fail('Failed to load plugin iframe'));\n });\n }\n\n /**\n * Tear a frame down for good: stop tracking it, drop the dock/media session if it\n * held them, close its RPC channel, and remove the iframe from the DOM.\n */\n destroy(frame) {\n if (!frame) return;\n this.dock?.releaseFrame(frame);\n this.media?.releaseFrame(frame);\n try { frame.channel?.emit('deactivate'); } catch { /* ignore */ }\n try { frame.channel?.dispose(); } catch { /* ignore */ }\n frame.iframe.remove();\n frame.record?.frames?.delete(frame);\n }\n}\n\nconst HIDDEN_STYLE = 'position:fixed;left:0;top:0;width:0;height:0;border:0;visibility:hidden;';\n\n// The frame's CSP. `connect-src 'none'` means it cannot make ANY direct network\n// request (fetch/XHR/WebSocket/beacon) — all web access is brokered by the host and\n// confined to the plugin's declared endpoints. img/media/font are limited to\n// in-frame blob:/data: so remote loads can't be an exfiltration side-channel.\n// `blob:` in script-src is only for the plugin's own package modules (below), which\n// are same-origin blobs — no external code can load.\nconst CSP = [\n \"default-src 'none'\",\n \"script-src 'unsafe-inline' 'unsafe-eval' blob:\",\n \"style-src 'unsafe-inline'\",\n 'img-src blob: data:',\n 'media-src blob: data:',\n \"font-src 'none'\",\n \"connect-src 'none'\",\n \"base-uri 'none'\",\n \"form-action 'none'\",\n].join('; ');\n\nconst HEAD = `<!doctype html><html><head><meta charset=\"utf-8\"><meta http-equiv=\"Content-Security-Policy\" content=\"${CSP}\"></head><body>`;\n\n/** Build the iframe document — classic single-file, or ESM module mode (src/). */\nexport async function buildSrcdoc(manifest, files) {\n if (isModuleEntry(manifest)) return moduleBootstrapHtml(await buildModuleGraph({ manifest, files }));\n const entryJs = new TextDecoder().decode(files.get(manifest.entry) ?? new Uint8Array());\n return `${HEAD}\n<script>${SDK_SOURCE}<\\/script>\n<script>${entryJs}<\\/script>\n</body></html>`;\n}\n\n// Escape a value for safe inlining inside <script> (so `</script>` and JS line\n// separators in package code can't break out of the tag).\nfunction safeJson(value) {\n return JSON.stringify(value).replace(/</g, '\\\\u003c').replace(/\\u2028/g, '\\\\u2028').replace(/\\u2029/g, '\\\\u2029');\n}\n\n// ESM module mode: ship every src/ module as a blob: URL and wire them with an\n// import map keyed by canonical `trove:/<path>` specifiers (the specifiers in the\n// code were rewritten to match). `trove` resolves to a shim over the injected SDK.\nfunction moduleBootstrapHtml(graph) {\n const entryKey = safeJson('trove:/' + graph.entry);\n return `${HEAD}\n<script>${SDK_SOURCE}<\\/script>\n<script id=\"__trove_src\" type=\"application/json\">${safeJson(graph.modules)}<\\/script>\n<script>\n(function () {\n var src = JSON.parse(document.getElementById('__trove_src').textContent);\n var imports = {};\n for (var p in src) imports['trove:/' + p] = URL.createObjectURL(new Blob([src[p] + '\\\\n//# sourceURL=trove:/' + p], { type: 'text/javascript' }));\n imports['trove'] = URL.createObjectURL(new Blob(['export const activate = globalThis.trove.activate;\\\\nexport default globalThis.trove;'], { type: 'text/javascript' }));\n var im = document.createElement('script');\n im.type = 'importmap';\n im.textContent = JSON.stringify({ imports: imports });\n document.head.appendChild(im);\n import(${entryKey}).catch(function (e) {\n try { parent.postMessage({ __trove: 'boot-error', error: String((e && e.message) || e) }, '*'); } catch (_) {}\n });\n})();\n<\\/script>\n</body></html>`;\n}\n",
57
+ "// Which SQL a plugin may run against its own database.\n//\n// Its own module rather than part of sqlite.js because BOTH sides of the mirror need it\n// and only one of them can load a driver: the server checks before touching the on-disk\n// store, and the browser checks before touching the wasm one. Importing sqlite.js from\n// the web bundle would drag `bun:sqlite` in behind it.\n\nimport { TroveError } from '../errors.js';\n\n// Plugins run SQL against their OWN isolated database, but on a shared-filesystem\n// provider the sibling scope files are guessable, so `ATTACH DATABASE` would be an\n// isolation escape (and `DETACH` its pair). Strip comments + string/identifier\n// literals first so the keyword can't hide inside a value, then reject.\n\n// ATTACH/DETACH would reach a sibling scope's file. VACUUM INTO is worse and less\n// obvious: it writes a complete SQLite database to any path the server process can\n// create, whose pages contain rows the caller chose — attacker-chosen bytes at an\n// attacker-chosen path (a cron file, a webroot, authorized_keys). PRAGMA is refused\n// because several of them (database_list, temp_store_directory) either disclose host\n// paths or move where files land.\nconst DANGEROUS_SQL = /\\b(ATTACH|DETACH|VACUUM|PRAGMA)\\b/i;\n\n/** Blank out --/**-comments and '..'/\"..\"/`..`/[..] literals, preserving length-ish. */\nexport function stripSqlLiterals(sql) {\n let out = '';\n let i = 0;\n while (i < sql.length) {\n const c = sql[i];\n if (c === '-' && sql[i + 1] === '-') { const nl = sql.indexOf('\\n', i); i = nl < 0 ? sql.length : nl; continue; }\n if (c === '/' && sql[i + 1] === '*') { const e = sql.indexOf('*/', i + 2); i = e < 0 ? sql.length : e + 2; out += ' '; continue; }\n if (c === \"'\" || c === '\"' || c === '`') {\n const q = c; i++;\n while (i < sql.length) {\n if (sql[i] === q) { if (sql[i + 1] === q) { i += 2; continue; } i++; break; }\n i++;\n }\n out += ' '; continue;\n }\n if (c === '[') { const e = sql.indexOf(']', i); i = e < 0 ? sql.length : e + 1; out += ' '; continue; }\n out += c; i++;\n }\n return out;\n}\n\n/** Throw if plugin-supplied SQL tries to escape its isolated database. */\nexport function assertSafePluginSql(sql) {\n if (typeof sql !== 'string' || !sql) throw TroveError.invalid('SQL statement is required');\n if (DANGEROUS_SQL.test(stripSqlLiterals(sql))) {\n throw TroveError.invalid('ATTACH, DETACH, VACUUM and PRAGMA are not permitted in plugin storage');\n }\n}\n\n",
58
+ "// PluginRpcRouter — the trusted boundary: every call a sandboxed plugin makes into\n// the host lands here, is capability-gated against what the user granted at install\n// time, and is then serviced against host APIs the plugin can never reach directly.\n//\n// The frame has NO ambient authority: no host DOM, no cookies, no network\n// (connect-src 'none'), no access to its own package bytes. Everything it can do is\n// one of the methods below, and each one that touches something sensitive calls\n// `cap(...)` first. Extracted from PluginHost so the allow/deny logic is one focused\n// unit rather than sharing a class with iframe lifecycle and DOM placement.\n\nimport { networkEndpoints, canExecuteCommand, displayName } from './pluginPackage.js';\nimport { isAllowedUrl } from './pluginNet.js';\nimport { isSourceModule } from './pluginModules.js';\n// pluginHost.js already imports actions to build this router, so this widens an existing\n// edge rather than creating one — and it removes the third seam assigned onto `platform`\n// after construction, which is the shape that makes the resource graph not the whole story.\nimport { OpenPluginPanelAction } from '../bl/actions.js';\nimport { contribUri, parseContribUri } from '@3sln/trove/core/plugins/identity.js';\nimport { assertSafePluginSql } from '@3sln/trove/core/plugins/sql.js';\n\n// Response bodies larger than this are refused, so a plugin can't exhaust host\n// memory through the brokered fetch.\nconst MAX_FETCH_BYTES = 25 * 1024 * 1024;\n\n/**\n * Read a response body, aborting the moment it exceeds `max`.\n *\n * `await res.arrayBuffer()` then checking `.byteLength` does not achieve the thing the\n * cap exists for: by the time the check runs the whole body is already resident, so a\n * declared endpoint returning a multi-GB stream OOMs the tab before we ever refuse it.\n * Check the declared length first, then enforce while streaming in case it lied.\n */\nasync function readCappedBody(res, max) {\n const declared = Number(res.headers.get('content-length') || 0);\n if (declared && declared > max) throw new Error('Response too large');\n const reader = res.body?.getReader?.();\n if (!reader) {\n const buf = await res.arrayBuffer();\n if (buf.byteLength > max) throw new Error('Response too large');\n return buf;\n }\n const chunks = [];\n let total = 0;\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n total += value.byteLength;\n if (total > max) { await reader.cancel().catch(() => {}); throw new Error('Response too large'); }\n chunks.push(value);\n }\n const out = new Uint8Array(total);\n let at = 0;\n for (const c of chunks) { out.set(c, at); at += c.byteLength; }\n return out.buffer;\n}\n\nexport class PluginRpcRouter {\n /**\n * @param {object} deps\n * @param {object} deps.platform host services (api, commands, contributions, settings, …)\n * @param {object} deps.clientDb on-device scoped SQLite provider\n * @param {import('./pluginMedia.js').MediaController} deps.media\n * @param {import('./pluginDock.js').FrameDock} deps.dock\n * @param {()=>void} deps.onChange notify listeners that plugin state changed\n */\n constructor({ platform, clientDb, media, dock, onChange } = {}) {\n this.platform = platform;\n this.clientDb = clientDb;\n this.media = media;\n this.dock = dock;\n this.onChange = onChange || (() => {});\n }\n\n // --- plugin → host RPC (calls: awaited, may return a value) -----------------\n\n async hostCall(record, method, params, frame) {\n const cap = (c) => { if (!record.grants.includes(c)) throw new Error(`Capability \"${c}\" not granted`); };\n const pid = record.id;\n switch (method) {\n case 'activated': {\n const f = frame || record.frame;\n clearTimeout(f?._timer);\n if (params.ok) f?.resolveActivated?.(f);\n else f?.rejectActivated?.(new Error(params.error || 'activate() failed'));\n return { ok: true };\n }\n\n // Run a command (the SDK's ctx.commands.execute). Gated per COMMAND, not per\n // capability: the plugin's manifest lists exactly which commands it may run\n // (plus its own, implicitly). A blanket \"commands\" grant would let a plugin that\n // wanted `workbench.view.home` also call `explorer.delete`.\n case 'command:execute': {\n const target = this.#resolveCommand(record, params.id);\n if (!canExecuteCommand(record.manifest, target)) {\n throw new Error(`Command \"${params.id}\" is not in this plugin's declared commands`);\n }\n const result = await this.platform.commands.execute(target, ...(params.args || []));\n return { ok: true, result: result ?? null };\n }\n\n // Drive a DECLARED status slot: push sanitized HTML into it, or show/hide it.\n // The slot itself is a manifest contribution — this only fills one in, so a\n // plugin can never grow its footprint in the shell past what was approved.\n case 'ui:status': {\n cap('ui');\n const slot = this.#ownContribution(record, params.name, 'statusItem');\n this.platform.contributions.update(slot.uri, {\n ...(params.html !== undefined ? { html: String(params.html ?? '') } : {}),\n ...(params.tooltip !== undefined ? { tooltip: String(params.tooltip ?? '') } : {}),\n ...(params.visible !== undefined ? { visible: !!params.visible } : { visible: true }),\n });\n return { ok: true };\n }\n\n // Set a DECLARED register — a context value slot other contributions' when-clauses\n // can read, addressed by its contribution URI.\n case 'context:setRegister': {\n const slot = this.#ownContribution(record, params.name, 'register');\n // The writer for a register the plugin declared. There is no path to a key it did\n // not declare, because it was never handed a setter for one.\n const write = record.registers?.get(slot.uri);\n if (!write) throw new Error(`Register \"${params.name}\" is not available`);\n write(params.value);\n return { ok: true };\n }\n // Package resources — opaque byte handles (transferred, no host URLs). Code\n // under src/ and the manifest are not resources (src/ is loaded as modules).\n case 'resources:list':\n return [...record.files.keys()].filter(isResourcePath);\n case 'resources:read': {\n if (!isResourcePath(params.path)) throw new Error(`No such resource ${params.path}`);\n const bytes = record.files.get(params.path);\n if (!bytes) throw new Error(`No such resource ${params.path}`);\n return { bytes: bytes.slice().buffer }; // copied into the iframe by structured clone\n }\n\n // Files — inherit the host's authenticated API client.\n case 'files:read': return cap('files'), { text: await this.platform.api.readText(params.id) };\n // ONE options object — `api.list(opts)`. Called as `list(pathOrId, params)` the\n // collection became the query string's key and everything else was dropped, so a\n // plugin asking for `photos` silently got the default collection unsorted.\n // A plugin has to say which collection it means, like everything else. The host\n // does not pick one for it — a plugin reaching into whatever collection happened to\n // be the default is exactly the ambient authority the capability list exists to stop.\n case 'files:list': return cap('files'), this.platform.api.list(\n params.collection || params.pathOrId,\n { sort: params.sort, order: params.order, limit: params.limit, cursor: params.cursor },\n );\n case 'files:stat': return cap('files'), this.platform.api.stat(params.id);\n\n // BYTES, by range. `files:read` answers text, which for an audiobook or any other\n // container is not slow, it is corrupt — and `files:downloadUrl` used to hand out a\n // bare route URL carrying no authorization, which an opaque-origin sandbox cannot\n // make good on: no cookies, no `Authorization` header, a 401 on any drive that\n // authenticates. So this is how a viewer gets bytes at all.\n //\n // Half-open `[start, end)`, and through `fileChunks` rather than the API directly:\n // a pinned file answers from disk, a file being kept offline contributes what it\n // fetches, and a file nobody asked to keep leaves nothing behind. See fileChunks.js.\n case 'files:bytes': {\n cap('files');\n const r = await this.platform.fileChunks.read(params.id, { start: params.start, end: params.end });\n // Transferred rather than copied: a 4 MiB chunk crossing by structured clone twice\n // per read is the difference between a seek and a stutter.\n return { bytes: r.bytes.buffer, etag: r.etag, total: r.total };\n }\n\n // Keeping a file offline, which is a DIFFERENT act from reading it — see\n // fileChunks.js. Until `start` is called, ranging over a file stores nothing.\n case 'files:offline:start': return cap('files'), this.platform.fileChunks.start(params.id);\n case 'files:offline:status': return cap('files'), this.platform.fileChunks.status(params.id);\n case 'files:offline:cancel': return cap('files'), (this.platform.fileChunks.cancel(params.id), { ok: true });\n case 'files:offline:remove': return cap('files'), this.platform.fileChunks.remove(params.id).then(() => ({ ok: true }));\n\n /**\n * A URL a media element can load on its own.\n *\n * The one place a host URL deliberately crosses into the sandbox, and it is minted —\n * it carries its own grant and expires, which is exactly what `platform/mediaUrls.js`\n * exists for: \"URLs for things that cannot send a header … an <img src>, a <video\n * src>\". The rule it bends is that plugins hold only opaque handles; the reason is\n * that `<audio src>` is the only way to stream a progressive MP4 without a\n * fragmenter, because MSE refuses one and a Blob has to be whole before it can\n * become an object URL. A viewer that can range-read for chapters and stream for\n * playback needs both, and this is the streaming half.\n */\n case 'files:mediaUrl': {\n cap('files');\n const { url, expiresAt } = await this.platform.mediaUrls.url(params.id, { op: params.op || 'media' });\n return { url, expiresAt };\n }\n case 'files:index': {\n cap('indexer');\n const ns = parseContribUri(params.indexerId) ? params.indexerId : contribUri(record.manifest, params.indexerId || 'default');\n return this.platform.api.pushIndex(ns, params.nodeId, {\n semanticTexts: params.semanticTexts, tags: params.tags, metadata: params.metadata,\n documents: params.documents, facet: params.facet, // legacy\n });\n }\n\n // Network — brokered by the host and confined to declared endpoints. The\n // sandboxed frame has no direct network at all (connect-src 'none').\n case 'net:fetch': cap('network'); return this.#brokerFetch(record, params);\n\n // Persistent storage — an isolated SQLite database per scope (plugin/domain),\n // on the server or on-device. SQL runs only against the plugin's own scoped db.\n case 'storage:sql': cap('storage'); return this.#pluginSql(record, params);\n\n // Plugin settings + secrets.\n case 'settings:get': return this.platform.settings.get(`${pid}.${params.key}`);\n case 'settings:getSecret': return record.secrets?.[params.key] ?? null;\n case 'settings:set':\n this.platform.settings.set(`${pid}.${params.key}`, params.value);\n return { ok: true };\n\n // Putting a panel on screen is a UI action, and this was the one `ui:` method with\n // no check — so a plugin granted nothing at all could open its own panel (and, with\n // an unvalidated displayName, render into the host page from `activate()`).\n case 'ui:showPanel':\n cap('ui');\n record.hasUi = true;\n this.platform.dispatch(new OpenPluginPanelAction(pid));\n this.onChange();\n return { ok: true };\n\n // Media session — the host owns navigator.mediaSession; the calling frame\n // (a viewer) surfaces its playback so the OS shows transport controls. Actions\n // fire back over that same frame's RPC channel.\n // Artwork is a URL the BROWSER fetches on the plugin's behalf, so it is egress\n // and belongs under the same allowlist the broker enforces. Left open, `media`\n // alone bought an outbound GET to any URL the plugin chose — the exfiltration\n // channel `connect-src 'none'` and the broker exist to close.\n case 'media:metadata': {\n cap('media');\n const artwork = (params.artwork || []).filter((a) => this.#artworkAllowed(record, a?.src));\n return this.media.apply(frame, 'metadata', { ...params, artwork });\n }\n case 'media:playbackState': cap('media'); return this.media.apply(frame, 'playbackState', params);\n case 'media:position': cap('media'); return this.media.apply(frame, 'position', params);\n case 'media:action': cap('media'); return this.media.apply(frame, 'action', params);\n case 'media:clear': return this.media.apply(frame, 'clear', params);\n\n // Dock — the calling frame registers/unregisters itself for the floating dock.\n case 'dock:enable': cap('dock'); if (frame) frame.dock = { enabled: true, minSize: params.minSize, maxSize: params.maxSize, dismissed: false }; return { ok: true };\n case 'dock:disable': cap('dock'); if (frame?.dock) frame.dock.enabled = false; if (frame && this.dock.docked === frame) this.dock.closeDock(frame); return { ok: true };\n case 'dock:close': if (frame) this.dock.closeDock(frame); return { ok: true };\n\n default:\n throw new Error(`Unknown host method ${method}`);\n }\n }\n\n // --- plugin → host events (fire-and-forget) --------------------------------\n\n hostEvent(record, method, params, frame) {\n switch (method) {\n case 'manifest':\n // Only the primary frame's manifest defines the plugin's live feature list;\n // a viewer frame re-announces its own (opener-only) manifest — ignore it.\n if (frame && frame.role !== 'primary') break;\n record.live = params; record.responsive = true;\n this.onChange();\n break;\n case 'ui:toast':\n this.platform.notifications[params.level || 'info'](`${displayName(record.manifest)}: ${params.text}`);\n break;\n case 'ui:badge':\n record.badge = params.text; this.onChange();\n break;\n }\n }\n\n // --- addressing ------------------------------------------------------------\n\n /**\n * Resolve a command reference from inside a plugin frame. A plugin names its OWN\n * commands by their short contribution name (that's the only name it knows); anything\n * else must be a full address — a built-in like `explorer.download`, or another\n * plugin's contribution URI.\n */\n #resolveCommand(record, id) {\n if (!id || parseContribUri(id)) return id;\n const own = this.platform.contributions.get(contribUri(record.manifest, id));\n return own?.type === 'command' ? own.uri : id;\n }\n\n /**\n * The plugin's own contribution called `name`, of the expected type. Anything else —\n * a name it never declared, or one of the wrong type — is refused: a plugin drives\n * only slots the user saw and approved at install.\n */\n #ownContribution(record, name, type) {\n const c = name ? this.platform.contributions.get(contribUri(record.manifest, name)) : null;\n if (!c || c.pluginId !== record.id || c.type !== type) {\n throw new Error(`\"${name}\" is not a ${type} declared by this plugin`);\n }\n return c;\n }\n\n // --- brokered capabilities -------------------------------------------------\n\n /**\n * Perform a network request on a plugin's behalf, but only to a URL it declared\n * in its manifest `network` allowlist. The request runs from the host with\n * credentials omitted (no ambient cookies/auth), and any redirect that lands\n * off the allowlist is rejected.\n */\n /** blob:/data: carry their own bytes; anything else must be a declared endpoint. */\n #artworkAllowed(record, src) {\n if (!src) return false;\n if (/^(blob:|data:image\\/)/i.test(src)) return true;\n return isAllowedUrl(networkEndpoints(record.manifest), src);\n }\n\n async #brokerFetch(record, { url, method = 'GET', headers, body }) {\n const allow = networkEndpoints(record.manifest);\n // The drive itself is never a \"network endpoint\".\n //\n // The broker runs in the HOST page, which is same-origin with the API. A manifest\n // declaring `network: [\"https://*.com/\"]` matches essentially any drive host, so a\n // plugin approved only for \"connect to the internet\" could call /api/items,\n // /api/items/delete, and other plugins' /api/plugins/:id/sql directly — collecting\n // the whole `files` capability, the per-command grant system, and every other\n // plugin's server-side store in one hop, none of which the user approved. Those\n // routes have a legitimate caller: the host, through the capability-gated methods\n // above.\n if (sameOrigin(url, this.platform.api?.baseUrl)) {\n throw new Error('Blocked: a plugin may not call the drive\\'s own API through the network broker');\n }\n if (!isAllowedUrl(allow, url)) {\n throw new Error(`Blocked: \"${url}\" is not one of this plugin's declared network endpoints`);\n }\n const init = { method, credentials: 'omit', redirect: 'follow', headers: sanitizeHeaders(headers) };\n if (body != null && method !== 'GET' && method !== 'HEAD') {\n init.body = body instanceof ArrayBuffer ? new Uint8Array(body) : body;\n }\n const res = await fetch(url, init);\n // A redirect chain must not escape the declared endpoints — nor land back on the\n // drive, which a declared endpoint is free to redirect to.\n if (res.url && res.url !== url) {\n if (sameOrigin(res.url, this.platform.api?.baseUrl)) {\n throw new Error('Blocked: request redirected onto the drive\\'s own API');\n }\n if (!isAllowedUrl(allow, res.url)) {\n throw new Error(`Blocked: request redirected off this plugin's declared endpoints (${res.url})`);\n }\n }\n const buf = await readCappedBody(res, MAX_FETCH_BYTES);\n const outHeaders = {};\n res.headers.forEach((v, k) => { outHeaders[k] = v; });\n return { ok: res.ok, status: res.status, statusText: res.statusText, url: res.url, headers: outHeaders, bytes: buf };\n }\n\n /**\n * Plugin storage: run a SQL op against one scoped, isolated database. `scope` is\n * 'plugin' or 'domain' (each granted separately); `side` is 'server' or 'client'.\n */\n async #pluginSql(record, { scope = 'plugin', side = 'server', op, sql, params = [], statements }) {\n if (!record.storage?.[scope]) {\n throw new Error(`Storage scope \"${scope}\" not granted${scope === 'domain' ? ' (needs a verified domain)' : ''}`);\n }\n if (side === 'client') {\n // On-device: an isolated wasm SQLite db per scope, held by the host. Domain\n // scope keys by the verified domain so a vendor's plugins share it.\n //\n // Same guard as the server path. The client dbs share ONE emscripten module\n // across every scope, so ATTACH / VACUUM INTO / PRAGMA are an isolation escape\n // here for the same reason they are on disk — the blast radius is the browser's\n // in-memory filesystem rather than the host's, which makes it smaller, not fine.\n if (op === 'batch') for (const s of (Array.isArray(statements) ? statements : [])) assertSafePluginSql(s?.sql);\n else assertSafePluginSql(sql);\n const key = scope === 'domain' ? `dom:${record.manifest.domain}` : `plg:${record.id}`;\n const db = await this.clientDb.obtain(key);\n return runSqlOp(db, op, sql, params, statements);\n }\n // Server: the host proxies to the scoped db over the authenticated API; the\n // domain (for the shared scope) comes from the verified install record, never\n // the plugin.\n const body = { scope, op, sql, params, statements, domain: scope === 'domain' ? record.manifest.domain : undefined };\n const res = await this.platform.api.request('POST', `/api/plugins/${encodeURIComponent(record.id)}/sql`, { body });\n return res.result;\n }\n}\n\n/**\n * Is `url` on the drive's own origin?\n *\n * `baseUrl` is '' in the shipped app (the API is served from the same origin as the\n * page), so the comparison is against `location.origin`; a library caller pointing the\n * client at another host gets that one. A redirect is checked separately, on the way\n * back, since a declared endpoint could redirect here.\n */\nfunction sameOrigin(url, baseUrl) {\n try {\n const here = new URL(baseUrl || '', globalThis.location?.href || 'http://localhost/');\n return new URL(url, here).origin === here.origin;\n } catch {\n return false;\n }\n}\n\n/** True for files a plugin can read as opaque resources (not code, not manifest). */\nfunction isResourcePath(path) {\n return path !== 'manifest.json' && !isSourceModule(path);\n}\n\n// Drop headers the plugin isn't allowed to set (the browser forbids most of these\n// anyway; we strip explicitly so intent is clear and cookies never ride along).\nconst FORBIDDEN_HEADERS = new Set(['host', 'cookie', 'cookie2', 'set-cookie', 'origin', 'referer', 'content-length', 'connection']);\nfunction sanitizeHeaders(headers) {\n const out = {};\n for (const [k, v] of Object.entries(headers || {})) {\n if (!FORBIDDEN_HEADERS.has(String(k).toLowerCase())) out[k] = v;\n }\n return out;\n}\n\n// Dispatch one SQL op onto a SqliteDatabase-shaped handle (the client store; the\n// server mirrors this in routes.js).\nfunction runSqlOp(db, op, sql, params = [], statements) {\n switch (op) {\n case 'exec': return db.exec(sql);\n case 'run': return db.run(sql, ...params);\n case 'get': return db.get(sql, ...params);\n case 'all': return db.all(sql, ...params);\n case 'batch': return db.batch(statements);\n default: throw new Error(`Unknown storage op \"${op}\"`);\n }\n}\n",
59
+ "// Server-side plugin package parsing. The server independently re-parses an uploaded\n// package (never trusting the client that produced it), pulling out the manifest, the\n// verified identity, the declared capabilities and contributions, and a content digest\n// used for dedupe/integrity.\n\nimport { unzipSync, strFromU8 } from 'fflate';\nimport { TroveError } from '../errors.js';\nimport { assertIdentity, pluginId } from './identity.js';\nimport { declaredContributions, serverIndexers, declaredOpeners } from './contributions.js';\n\nexport const ALL_CAPABILITIES = ['files', 'storage', 'ui', 'commands', 'indexer', 'opener', 'network', 'media', 'dock'];\n\nexport { serverIndexers, declaredOpeners, declaredContributions };\n\n/** SHA-256 hex digest of the raw package bytes (content address). */\nexport async function digestBytes(bytes) {\n const buf = await crypto.subtle.digest('SHA-256', bytes);\n return 'sha256:' + [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, '0')).join('');\n}\n\n/** Declared capability ids from a manifest (object `{cap: opts}` or array form). */\nexport function capabilityList(manifest) {\n const caps = manifest && manifest.capabilities;\n if (Array.isArray(caps)) return caps.filter(Boolean);\n if (caps && typeof caps === 'object') {\n return Object.entries(caps).filter(([, v]) => v !== false && v != null).map(([k]) => k);\n }\n return [];\n}\n\n/** Whether the granted storage includes the shared `domain` scope. */\nexport function usesSharedStorage(manifest) {\n const opt = manifest?.capabilities?.storage;\n return !!(opt && typeof opt === 'object' && opt.domain);\n}\n\n// A package's COMPRESSED size is capped at the route; its INFLATED size was not, and a\n// zip will happily turn 1 MB into 1 GB. `unzipSync` is synchronous, so that is a\n// gigabyte of RSS and thirteen seconds of blocked event loop for one request — from an\n// unauthenticated caller on the zero-config drive, since the install route only asks for\n// a principal and the shared anonymous one satisfies it.\n//\n// fflate's `filter` runs against the central directory BEFORE any entry is inflated, so\n// the declared sizes are the cheapest possible place to refuse. 64 MiB and 2,000 files\n// are far beyond any real plugin (the largest thing in one is a wasm blob) and far below\n// what hurts.\nconst MAX_INFLATED_BYTES = 64 * 1024 * 1024;\nconst MAX_ENTRIES = 2000;\n\nexport function boundedUnzip(bytes) {\n let total = 0;\n let count = 0;\n try {\n return unzipSync(bytes, {\n filter(file) {\n if (++count > MAX_ENTRIES) throw TroveError.tooLarge(`Package has more than ${MAX_ENTRIES} files`);\n total += file.originalSize || 0;\n if (total > MAX_INFLATED_BYTES) {\n throw TroveError.tooLarge(`Package expands to more than ${Math.round(MAX_INFLATED_BYTES / 1024 / 1024)} MB`);\n }\n return true;\n },\n });\n } catch (err) {\n if (err instanceof TroveError) throw err;\n throw TroveError.invalid('Package is not a valid zip', { cause: err });\n }\n}\n\n/**\n * Parse an uploaded package zip. Returns { manifest, pluginId, files, capabilities,\n * contributions, indexers, openers, digest }. Throws INVALID on a missing/malformed\n * manifest, an unverifiable identity, or a bad contribution declaration.\n * @param {Uint8Array} bytes\n */\nexport async function parsePluginPackage(bytes) {\n const files = boundedUnzip(bytes);\n const manifestRaw = files['manifest.json'];\n if (!manifestRaw) throw TroveError.invalid('Package is missing manifest.json');\n let manifest;\n try {\n manifest = JSON.parse(strFromU8(manifestRaw));\n } catch (err) {\n throw TroveError.invalid('manifest.json is not valid JSON', { cause: err });\n }\n // Identity first: everything else (contribution URIs, install records, storage\n // scopes) is addressed under `<domain>/<name>`, so an anonymous package has no\n // address space to live in and is rejected outright.\n assertIdentity(manifest);\n const capabilities = capabilityList(manifest).filter((c) => ALL_CAPABILITIES.includes(c));\n return {\n manifest,\n pluginId: pluginId(manifest),\n files,\n capabilities,\n contributions: declaredContributions(manifest),\n indexers: serverIndexers(manifest),\n openers: declaredOpeners(manifest),\n sharedStorage: usesSharedStorage(manifest),\n digest: await digestBytes(bytes),\n };\n}\n",
60
+ "// PluginHost — the plugin lifecycle orchestrator. It owns the set of installed\n// plugins and their runtime records, and composes four focused collaborators:\n//\n// FrameManager (pluginFrames.js) — sandboxed iframe spawn/handshake/destroy\n// PluginRpcRouter (pluginRpc.js) — the trusted boundary: capability-gated RPC\n// FrameDock (pluginDock.js) — where a frame is shown; the floating dock\n// MediaController (pluginMedia.js) — navigator.mediaSession bridging\n//\n// What stays here is the lifecycle proper: install/restore/reconcile/uninstall, the\n// availability heartbeat, and mounting a plugin into a panel or viewer.\n//\n// A plugin's code runs inside a sandboxed iframe on an OPAQUE origin: it can't touch\n// the host DOM, read cookies/storage, or fetch its own package files. Everything it\n// can do flows over one transferred MessagePort, gated by the capabilities the user\n// granted at install time. Plugins are persisted (PluginRegistry, IndexedDB) so they\n// survive reloads, and re-announce a live capability manifest so the workbench knows\n// what works right now (incl. offline). See pluginPackage.js / pluginSigning.js for\n// install-time validation and the domain-verified trust signal.\n\nimport { zipSync } from 'fflate';\nimport { PluginRegistry } from './pluginStore.js';\nimport { ClientSqlProvider } from './pluginClientDb.js';\nimport { assessTrust } from './pluginSigning.js';\nimport { ADMIN_ONLY_CAPS, capabilityList, networkEndpoints, grantedStorageScopes, parsePackage, displayName, canExecuteCommand } from './pluginPackage.js';\nimport { declaredContributions, parseKeymap, serverIndexers } from '@3sln/trove/core/plugins/contributions.js';\nimport { pluginId, contribUri } from '@3sln/trove/core/plugins/identity.js';\nimport { endpointSummary } from './pluginNet.js';\nimport { MediaController } from './pluginMedia.js';\nimport { FrameDock } from './pluginDock.js';\nimport { InvokePluginCommandAction, OpenInPanelAction } from '../bl/actions.js';\nimport { FrameManager } from './pluginFrames.js';\nimport { PluginRpcRouter } from './pluginRpc.js';\n// The canonical capability list lives in core (the server's authority); import it so\n// client and server can't drift when a capability is added.\nimport { ALL_CAPABILITIES } from '@3sln/trove/core/plugins/package.js';\n\nexport class PluginHost {\n constructor(platform, { heartbeatMs = 20000 } = {}) {\n this.platform = platform;\n this.plugins = new Map(); // id -> runtime record\n this.registry = new PluginRegistry();\n // On-device per-scope SQLite (wasm). A failed background persist is data a plugin\n // already believes it saved, so it surfaces rather than disappearing into a log.\n this.clientDb = new ClientSqlProvider({\n onError: (err, key) => this.platform.notifications.error(`A plugin's on-device data couldn't be saved (${key}): ${err.message}`),\n });\n this.online = typeof navigator !== 'undefined' ? navigator.onLine : true;\n this.heartbeatMs = heartbeatMs;\n this._heartbeat = null;\n this._probing = false;\n this.cell = platform.reactive.cell([]);\n\n // Collaborators. The dock destroys frames through the frame manager (assigned\n // just below — the callback is lazy), and both are consulted on frame teardown.\n this.media = new MediaController();\n this.dock = new FrameDock({\n destroyFrame: (frame) => this.frames.destroy(frame),\n // Dispatched, not called: opening a file from a docked plugin frame is the same\n // intent as opening one from the drive, and the engine should see both.\n // Not `dispatch?.()`. An unwired seam here silently drops a docked frame's\n // open-file, which is exactly the shape server/src/index.js records as having turned\n // a sweep into a permanent no-op.\n openFile: (node, openerId) => this.platform.dispatch(new OpenInPanelAction(node, openerId)),\n onChange: () => this.#emit(),\n });\n this.frames = new FrameManager({ media: this.media, dock: this.dock });\n this.rpc = new PluginRpcRouter({\n platform, clientDb: this.clientDb, media: this.media, dock: this.dock,\n onChange: () => this.#emit(),\n });\n }\n\n observe() {\n return this.cell;\n }\n #emit() {\n this.cell.setValue(this.list());\n }\n\n /**\n * Spawn one sandboxed frame for `record`, wired to this host's RPC router.\n * `entry` boots a different module of the plugin's tree (that's what an opener is).\n */\n #spawnFrame(record, role, entry) {\n return this.frames.spawn(record, role, {\n onCall: (rec, m, p, f) => this.rpc.hostCall(rec, m, p, f),\n onEvent: (rec, m, p, f) => this.rpc.hostEvent(rec, m, p, f),\n online: this.online,\n entry,\n });\n }\n\n /**\n * Register everything the MANIFEST declares, each at its own contribution URI. The\n * manifest is authoritative — this runs before the plugin boots, so: the user's\n * install-time review matches exactly what gets registered, openers/indexers exist\n * without activating the plugin, and they survive a plugin whose primary frame is\n * broken or unresponsive. Nothing a plugin does at runtime can add a contribution;\n * it can only drive the ones declared here (push status content, set a register).\n */\n #registerContributions(runtime) {\n const pid = runtime.id;\n const reg = this.platform.contributions;\n const keep = (dispose) => runtime.disposers.push(dispose);\n const label = displayName(runtime.manifest);\n\n for (const c of declaredContributions(runtime.manifest)) {\n const base = { ...c, pluginId: pid };\n switch (c.type) {\n // A viewer: `entry` names the module that renders it, in its own frame.\n // Skipped entirely if the user declined \"provides viewers\" at install.\n case 'opener':\n if (runtime.grants.includes('opener')) keep(reg.register(c.uri, base));\n break;\n\n // Declared, implemented by the plugin's primary frame. Addressed over RPC by the\n // contribution's short NAME — inside its own frame a plugin addresses its commands\n // by name, not by URI.\n case 'command':\n keep(this.platform.commands.register({\n id: c.uri, title: c.title || `${label}: ${c.name}`,\n category: c.category || label, icon: c.icon,\n when: c.when, offline: c.offline, palette: c.palette, pluginId: pid,\n // A description, like every other command. It used to be a closure over\n // `runtime` proxying straight to the channel, which left a plugin command\n // running invisible to the engine — the same hole ExecCommandAction closed for\n // the host's own commands, still open for everyone else's.\n actions: (...args) => new InvokePluginCommandAction(pid, c.name, args),\n }));\n break;\n\n // A slot in the status bar, empty and hidden until the plugin pushes content.\n // A CLICKABLE one is the plugin asking the host to run something — the same ask\n // a keyboard shortcut makes — so it goes through the same per-command grant.\n // Without this, a manifest holding only the `ui` capability could put an\n // inviting button in the status bar wired to `explorer.delete` or\n // `plugins.installFromUrl`, and the install review never mentioned the field.\n case 'statusItem': {\n const command = c.command\n ? this.#resolveCommand(runtime, c.command, label, `status item “${c.name}”`)\n : null;\n keep(reg.register(c.uri, { ...base, command, html: '', visible: false }));\n break;\n }\n\n // A context value slot — the one kind of key that genuinely is PUSHED rather than\n // derived, because only the plugin knows what it means. Owned here, on the\n // plugin's behalf: the registry hands back a writer, which goes on the runtime\n // record so `context:setRegister` can reach it and nothing else can.\n //\n // Seeded with its declared default so when-clauses referencing it evaluate\n // sensibly before the plugin has run at all.\n case 'register': {\n keep(reg.register(c.uri, base));\n const owned = this.platform.context.own(c.uri, c.default);\n runtime.registers.set(c.uri, owned.set);\n keep(() => { runtime.registers.delete(c.uri); owned.dispose(); });\n break;\n }\n\n // A keymap JSON file inside the package. Read + validated here, at register\n // time, so a malformed keymap is a visible install-time problem rather than a\n // shortcut that silently never fires.\n case 'keymap': {\n const bytes = runtime.files.get(c.path);\n if (!bytes) {\n this.platform.notifications.warn(`Plugin \"${label}\": keymap file \"${c.path}\" is not in the package.`);\n break;\n }\n try {\n const bindings = this.#resolveBindings(runtime, parseKeymap(new TextDecoder().decode(bytes)), label);\n keep(reg.register(c.uri, { ...base, bindings }));\n } catch (err) {\n this.platform.notifications.warn(`Plugin \"${label}\": ${err.message}`);\n }\n break;\n }\n\n // Indexers are deliberately NOT registered client-side. They run on the server\n // (PluginIndexers registers them from the install record), because indexing\n // must happen once per upload for the drive — not in whichever tab is open.\n case 'indexer':\n break;\n }\n }\n }\n\n /**\n * Resolve a keymap's bindings into real addresses, and refuse the ones the plugin\n * isn't allowed to trigger. A binding naming one of the plugin's own commands is\n * rewritten to that contribution's URI (inside its package a plugin knows only short\n * names); anything else is a foreign address and must be in the manifest's `commands`\n * allowlist — a shortcut is still the plugin asking the host to run something, so it\n * can't be a way around the per-command grant the user approved.\n */\n #resolveBindings(runtime, bindings, label) {\n const out = [];\n for (const b of bindings) {\n const command = this.#resolveCommand(runtime, b.command, label, `shortcut ${b.key}`);\n if (command) out.push({ ...b, command });\n }\n return out;\n }\n\n /**\n * One command address the plugin wants to be able to trigger, resolved and checked.\n *\n * A short name is one of the plugin's own commands and becomes its contribution URI.\n * Anything else is a FOREIGN address and must appear in the manifest's `commands`\n * allowlist. Returns null (with a warning naming `what`) when it isn't allowed, so\n * every route by which a plugin can ask the host to run something — keymaps, status\n * items — passes through the same grant the user actually approved.\n */\n #resolveCommand(runtime, wanted, label, what) {\n const uri = contribUri(runtime.manifest, wanted);\n const own = declaredContributions(runtime.manifest).some((c) => c.uri === uri && c.type === 'command');\n if (own) return uri;\n if (!canExecuteCommand(runtime.manifest, wanted)) {\n this.platform.notifications.warn(`Plugin \"${label}\": ${what} runs \"${wanted}\", which it isn't allowed to run — ignored.`);\n return null;\n }\n return wanted;\n }\n\n list() {\n return [...this.plugins.values()].map((p) => ({\n id: p.id, name: displayName(p.manifest), version: p.manifest.version, status: p.status,\n capabilities: p.grants, error: p.error || null, hasUi: p.hasUi, badge: p.badge || null,\n trust: p.trust || null, settingsSchema: p.manifest.settings || [],\n endpoints: endpointSummary(networkEndpoints(p.manifest)),\n responsive: !!p.responsive, manifest: p.live || null, features: this.#featureList(p),\n }));\n }\n\n /**\n * What this plugin contributes — read from the MANIFEST, so the list is known\n * without the plugin running (and stays accurate if it stops responding). `live`\n * is only used for liveness/availability, not for what exists.\n */\n #featureList(record) {\n let declared;\n try { declared = declaredContributions(record.manifest); } catch { return []; }\n return declared.map((c) => ({\n kind: c.type, id: c.uri, name: c.name, title: c.title || c.name,\n offline: !!c.offline, available: this.#availableSpec(record, c),\n }));\n }\n #availableSpec(record, spec) {\n if (record.status !== 'active' || !record.responsive) return false;\n return this.online || !!spec.offline;\n }\n isAvailable(contrib) {\n if (!contrib?.pluginId) return true;\n const record = this.plugins.get(contrib.pluginId);\n if (!record) return false;\n return this.#availableSpec(record, contrib);\n }\n\n // --- install / restore -----------------------------------------------------\n\n /** Whether the current user may grant a capability (some need admin). */\n canGrant(cap, isAdmin) {\n return !ADMIN_ONLY_CAPS.has(cap) || !!isAdmin;\n }\n\n /**\n * Install a parsed package. `grants` is the subset of requested capabilities\n * the user approved (the review UI filters admin-only caps for non-admins).\n */\n async install(pkg, { grants, trust } = {}) {\n const id = pluginId(pkg.manifest);\n const requested = capabilityList(pkg.manifest);\n const granted = (grants || requested).filter((c) => ALL_CAPABILITIES.includes(c) && requested.includes(c));\n // Account-scoped plugins (server storage or a server indexer) upload their full\n // package to the server: it re-validates, gates admin-only packages, and becomes\n // the canonical copy so the plugin syncs to the user's other devices and its\n // capabilities are enforced server-side. Throws if the server rejects (e.g. admin\n // required) — surfaced to the user by the install UI. Device-scoped plugins stay local.\n const scope = accountScoped(pkg.manifest, granted) ? 'account' : 'device';\n if (scope === 'account') {\n if (!pkg.raw) throw new Error('Package bytes unavailable for a server install');\n await this.platform.api.installPlugin(pkg.raw, granted);\n }\n const storage = granted.includes('storage')\n ? grantedStorageScopes(pkg.manifest, trust)\n : { plugin: false, domain: false };\n const record = {\n id, manifest: pkg.manifest,\n files: Object.fromEntries([...pkg.files.entries()]),\n grants: granted, storage, trust: trust || null, scope,\n settings: {}, secrets: {}, installedAt: Date.now(),\n };\n await this.registry.save(record);\n this.#registerSettings(record);\n await this.#run(record);\n return this.plugins.get(id);\n }\n\n /** Load all persisted plugins (call once at startup), then sync account plugins. */\n async restore() {\n let records = [];\n try {\n records = await this.registry.list();\n } catch { /* no IndexedDB */ }\n for (const rec of records) {\n // A single corrupt persisted record (missing manifest, etc.) must not abort the\n // restore of every other plugin — guard per record.\n try {\n this.#registerSettings(rec);\n this.#run(rec).catch((e) => console.error('restore plugin failed', rec.id, e));\n } catch (e) {\n console.error('skipping corrupt plugin record', rec?.id, e);\n this.platform.notifications.warn(`Couldn't restore plugin \"${rec?.manifest ? displayName(rec.manifest) : rec?.id || 'unknown'}\" — its saved data looks corrupt.`);\n }\n }\n // Reconcile with the server's account plugins (best-effort, offline-tolerant).\n this.#reconcile(records).catch(() => {});\n }\n\n // Two-way sync of account plugins with the server: push any local account plugin the\n // server is missing (migration for pre-existing local installs), and pull any server\n // account plugin not yet on this device (cross-device sync).\n async #reconcile(localRecords) {\n let serverList;\n try { serverList = (await this.platform.api.installedPlugins()).plugins || []; } catch { return; }\n const serverIds = new Set(serverList.map((p) => p.pluginId));\n const localIds = new Set(localRecords.map((r) => r.id));\n let pushFailures = 0;\n let pulled = 0;\n let pullFailures = 0;\n\n // Push: local account plugins the server doesn't have → re-upload (re-zipped).\n for (const rec of localRecords) {\n if (rec.scope !== 'account' || serverIds.has(rec.id)) continue;\n try {\n await this.platform.api.installPlugin(zipSync(toU8Files(rec.files)), rec.grants || []);\n } catch (e) { console.error('re-upload plugin failed', rec.id, e); pushFailures++; }\n }\n\n // Pull: server account plugins not on this device → download + enable.\n for (const rec of serverList) {\n if (localIds.has(rec.pluginId)) continue;\n try {\n const pkg = parsePackage(await this.platform.api.pluginPackage(rec.pluginId));\n const grants = rec.grants || [];\n const record = {\n id: rec.pluginId, manifest: pkg.manifest,\n files: Object.fromEntries([...pkg.files.entries()]),\n grants,\n // The SHARED domain scope comes from the server's install record, not from\n // the package's own manifest. The install path gates it on verified domain\n // ownership (`grantedStorageScopes` requires trust.status === 'verified') and\n // the review UI shows it as blocked; this sync path set `trust: null` and read\n // the self-declared manifest — so a package refused the shared store on the\n // device it was installed on got it on the next device that synced.\n storage: grants.includes('storage')\n ? { plugin: true, domain: !!rec.sharedStorage }\n : { plugin: false, domain: false },\n trust: null, scope: 'account',\n settings: {}, secrets: {}, installedAt: rec.createdAt || Date.now(),\n };\n await this.registry.save(record);\n this.#registerSettings(record);\n await this.#run(record);\n pulled++;\n } catch (e) { console.error('sync plugin failed', rec.pluginId, e); pullFailures++; }\n }\n\n if (pulled) this.platform.notifications.info(`Synced ${pulled} account plugin${pulled > 1 ? 's' : ''} from the server.`);\n if (pushFailures || pullFailures) {\n const parts = [];\n if (pullFailures) parts.push(`${pullFailures} couldn't be downloaded`);\n if (pushFailures) parts.push(`${pushFailures} couldn't be uploaded`);\n this.platform.notifications.warn(`Some account plugins didn't sync: ${parts.join(', ')}.`);\n }\n }\n\n #registerSettings(record) {\n const schema = (record.manifest.settings || []).filter((s) => !s.secret);\n if (schema.length) {\n record._settingsDispose = this.platform.settings.scopedFor(record.id).register(\n schema.map((s) => ({ ...s, category: displayName(record.manifest) })),\n );\n }\n }\n\n // --- run (create the plugin's primary sandboxed iframe) --------------------\n\n async #run(record) {\n if (this.plugins.get(record.id)?.status === 'active') return;\n const runtime = {\n ...record, iframe: null, status: 'loading', error: null, disposers: [], channel: null,\n // Writers for the context registers this plugin DECLARED, keyed by contribution URI.\n // Holding them here is what makes \"a plugin may only set its own registers\" structural\n // rather than a check: there is no setter for a key it did not declare.\n registers: new Map(),\n hasUi: false, responsive: false, frame: null, frames: new Set(),\n // Storage scopes (defaulted for records saved before this field existed).\n storage: record.storage || (record.grants?.includes('storage') ? grantedStorageScopes(record.manifest, record.trust) : { plugin: false, domain: false }),\n files: mapFromFiles(record.files),\n };\n this.plugins.set(record.id, runtime);\n // Register declared contributions BEFORE booting — they don't depend on the\n // plugin running, and this keeps them alive if its frame never comes up.\n try { this.#registerContributions(runtime); } catch (e) { console.error('registering contributions failed', record.id, e); }\n this.#emit();\n\n try {\n // The primary (background) frame: registers commands/indexers, does one-time\n // setup. Its channel is the record's channel used for probes and commands.\n const frame = await this.#spawnFrame(runtime, 'primary');\n // Uninstalled while the handshake was in flight? The record is no longer in the\n // map — tear this frame down instead of leaving a live, unreachable iframe.\n if (this.plugins.get(record.id) !== runtime) { this.frames.destroy(frame); return runtime; }\n runtime.frame = frame;\n runtime.iframe = frame.iframe;\n runtime.channel = frame.channel;\n runtime.status = 'active';\n runtime.responsive = true;\n this.#probe(runtime).then(() => this.#emit());\n this.#startHeartbeat();\n } catch (err) {\n runtime.status = 'error';\n runtime.error = err?.message || String(err);\n this.platform.notifications.error(`Plugin \"${displayName(record.manifest)}\" failed to load: ${runtime.error}`);\n }\n this.#emit();\n return runtime;\n }\n\n // --- settings & secrets (host-side, for the UI) ----------------------------\n\n async setSecret(pluginId, key, value) {\n const rec = await this.registry.get(pluginId);\n if (!rec) return;\n rec.secrets = { ...rec.secrets, [key]: value };\n await this.registry.save(rec);\n const runtime = this.plugins.get(pluginId);\n if (runtime) runtime.secrets = rec.secrets;\n runtime?.channel?.emit('settings:changed', { key, value: '••••' });\n }\n async getSecret(pluginId, key) {\n const rec = await this.registry.get(pluginId);\n return rec?.secrets?.[key] ?? '';\n }\n\n // --- heartbeat / availability ----------------------------------------------\n\n #startHeartbeat() {\n if (this._heartbeat || !this.heartbeatMs) return;\n this._heartbeat = setInterval(() => this.#heartbeat(), this.heartbeatMs);\n if (this._heartbeat?.unref) this._heartbeat.unref();\n }\n #stopHeartbeat() {\n if (this._heartbeat) clearInterval(this._heartbeat);\n this._heartbeat = null;\n }\n async #heartbeat() {\n if (this._probing) return;\n this._probing = true;\n try {\n let changed = false;\n for (const r of this.plugins.values()) if (r.status === 'active') changed = (await this.#probe(r)) || changed;\n if (changed) this.#emit();\n } finally {\n this._probing = false;\n }\n }\n /**\n * Run one of a plugin's own commands, in its frame.\n *\n * Public because `InvokePluginCommandAction` is what reaches it now, rather than a closure\n * captured at registration. Addressed by short NAME: the URI is the host's way of keeping\n * two plugins' `status` commands apart and means nothing on the other side.\n *\n * A plugin that is not running answers undefined rather than throwing. Its commands are\n * already filtered out of the palette by `isAvailable`, so getting here at all means a\n * stale reference, which is not worth an error.\n */\n invokeCommand(pluginId, name, args = []) {\n return this.plugins.get(pluginId)?.channel?.call('command:execute', { id: name, args });\n }\n\n setHeartbeat(ms) {\n this.heartbeatMs = ms;\n this.#stopHeartbeat();\n if (ms && [...this.plugins.values()].some((r) => r.status === 'active')) this.#startHeartbeat();\n }\n async #probe(record) {\n if (record.status !== 'active' || !record.channel) return false;\n const before = { responsive: record.responsive, sig: signature(record.live) };\n try {\n record.live = await record.channel.call('manifest', {}, { timeout: 4000 });\n record.responsive = true;\n } catch {\n record.responsive = false;\n }\n return before.responsive !== record.responsive || before.sig !== signature(record.live);\n }\n async setOnline(online) {\n if (this.online === online) return;\n this.online = online;\n await Promise.all([...this.plugins.values()].filter((r) => r.status === 'active').map(async (r) => {\n try { r.channel?.emit('connectivity', { online }); } catch { /* ignore */ }\n for (const frame of r.frames || []) { try { frame.channel?.emit('connectivity', { online }); } catch { /* ignore */ } }\n await this.#probe(r);\n }));\n this.#emit();\n }\n async refresh(pluginId) {\n const record = this.plugins.get(pluginId);\n if (record) { await this.#probe(record); this.#emit(); }\n }\n\n // --- mounting (panel / viewer) ---------------------------------------------\n //\n // Where a frame is *shown* is FrameDock's job (position:fixed overlay tracking a\n // target element — we never re-parent an iframe, which would reload it). These\n // methods own the mount lifecycle: which frame, opened with what, and what happens\n // when it detaches.\n\n mountPanel(pluginId, container, { width = 380, height = 480 } = {}) {\n const record = this.plugins.get(pluginId);\n if (!record?.frame) return null;\n container.style.width = `${width}px`;\n container.style.height = `${height}px`;\n this.dock.place(record.frame, container, 50);\n record.hasUi = true;\n return () => this.dock.hide(record.frame);\n }\n\n /**\n * Mount a plugin opener as the viewer for `node`. Each viewer runs in its OWN\n * sandboxed iframe (spawned with the plugin's capabilities), so viewers are\n * isolated from the background instance and from each other. Returns a detach fn:\n * if the viewer registered `dock`, its frame is kept alive as a floating dock,\n * otherwise it is destroyed.\n */\n mountViewer(pluginId, container, node, openerId, hooks = {}) {\n const record = this.plugins.get(pluginId);\n if (!record) { hooks.onError?.('Plugin is not available'); return null; }\n\n // Re-adopt the docked frame if it's the same file — preserves live playback\n // (the docked <video>/<audio> keeps running) instead of spawning a fresh viewer.\n const docked = this.dock.docked;\n if (docked && docked.record === record && docked.node?.id === node.id && docked.openerId === openerId) {\n this.dock.undock(docked);\n this.dock.place(docked, container, 3);\n hooks.onReady?.();\n return () => this.#detachViewer(docked);\n }\n\n // Boot the frame at the OPENER's entry module — not the plugin's main entry, so a\n // viewer loads only the code it needs and never re-runs the plugin's background setup.\n const opener = this.platform.contributions.get(openerId);\n const mount = { cancelled: false, frame: null };\n this.#spawnFrame(record, 'viewer', opener?.entry).then(async (frame) => {\n if (mount.cancelled) { this.frames.destroy(frame); return; }\n mount.frame = frame;\n frame.node = node;\n frame.openerId = openerId;\n record.frames.add(frame);\n this.dock.place(frame, container, 3);\n try {\n await frame.channel?.call('opener:open', { openerId, file: node, context: {} });\n if (!mount.cancelled) hooks.onReady?.();\n } catch (err) {\n if (!mount.cancelled) hooks.onError?.(err?.message || 'Failed to open');\n }\n }).catch((e) => {\n console.error('viewer frame failed to load', e);\n if (!mount.cancelled) hooks.onError?.(e?.message || 'This viewer failed to load');\n });\n record.hasUi = true;\n\n return () => {\n mount.cancelled = true;\n if (mount.frame) this.#detachViewer(mount.frame);\n };\n }\n\n // A viewer went off-screen: dock it (if it opted in and isn't dismissed) or destroy it.\n #detachViewer(frame) {\n if (frame.dock?.enabled && !frame.dock.dismissed) this.dock.dock(frame);\n else this.frames.destroy(frame);\n }\n\n // --- uninstall --------------------------------------------------------------\n\n /** Uninstall: stop the plugin, forget it, and wipe everything it owns. */\n async uninstall(pluginId, { wipeData = true } = {}) {\n const record = this.plugins.get(pluginId);\n const name = record?.manifest ? displayName(record.manifest) : pluginId;\n const isAccount = record?.scope === 'account'\n || (await this.registry.get(pluginId).catch(() => null))?.scope === 'account';\n\n // Account plugins: the server holds the canonical copy. Remove it there FIRST — if\n // that fails we must NOT tear down locally, or the plugin silently resurrects on the\n // next reload (server still lists it) with no sign anything went wrong.\n if (wipeData && isAccount) {\n try {\n await this.platform.api.uninstallPluginServer(pluginId);\n } catch (err) {\n this.platform.notifications.error(`Couldn't uninstall \"${name}\" from the server: ${err.message}. It's still installed.`);\n return;\n }\n }\n\n if (record) {\n try { record.channel?.emit('deactivate'); } catch { /* ignore */ }\n for (const d of record.disposers) { try { d(); } catch { /* ignore */ } }\n record._settingsDispose?.();\n for (const frame of [...(record.frames || [])]) this.frames.destroy(frame); // viewer/dock frames\n // The primary frame may have an open panel placement (observers + listeners).\n if (record.frame) { this.dock.stopPlace(record.frame); this.media.releaseActions(record.frame); }\n record.channel?.dispose();\n record.iframe?.remove();\n this.plugins.delete(pluginId);\n }\n // Best-effort cleanup of the plugin's private stores. A failure here doesn't block\n // uninstall, but the user is told so leftover data isn't silently orphaned.\n const wipeFailures = [];\n if (wipeData) {\n if (!isAccount) await this.platform.api.request('DELETE', `/api/plugins/${encodeURIComponent(pluginId)}/data`).catch(() => wipeFailures.push('server-side data'));\n await this.clientDb.drop(`plg:${pluginId}`).catch(() => wipeFailures.push('on-device data'));\n }\n // The persisted record is what restore() reads: if this fails and we say nothing,\n // the plugin silently reappears on the next reload looking like a bug in uninstall.\n let resurrects = false;\n try {\n await this.registry.remove(pluginId);\n } catch (err) {\n resurrects = true;\n console.error('removing the persisted plugin record failed', pluginId, err);\n }\n if (![...this.plugins.values()].some((r) => r.status === 'active')) this.#stopHeartbeat();\n this.#emit();\n if (resurrects) {\n this.platform.notifications.error(`Removed \"${name}\", but its saved record couldn't be deleted — it may come back when you reload.`);\n } else if (wipeFailures.length) {\n this.platform.notifications.warn(`Uninstalled \"${name}\", but couldn't clear its ${wipeFailures.join(' and ')}.`);\n }\n }\n\n // --- trust ------------------------------------------------------------------\n\n /** Fetch a domain's assetlinks doc through the server (avoids CORS). */\n fetchAssetlinks = async (domain) => {\n const res = await this.platform.api.request('GET', '/api/plugins/assetlinks', { query: { domain } });\n return res?.assetlinks || null;\n };\n assessTrust(pkg) {\n return assessTrust(pkg, this.fetchAssetlinks);\n }\n}\n\nfunction mapFromFiles(files) {\n const m = new Map();\n for (const [k, v] of Object.entries(files)) m.set(k, v instanceof Uint8Array ? v : new Uint8Array(v));\n return m;\n}\n\n// Coerce a stored files object (path -> bytes, possibly ArrayBuffer after IndexedDB\n// round-trip) into the { path: Uint8Array } shape fflate's zipSync expects.\nfunction toU8Files(files) {\n const out = {};\n for (const [k, v] of Object.entries(files || {})) out[k] = v instanceof Uint8Array ? v : new Uint8Array(v);\n return out;\n}\n\n// A plugin is account-scoped (must install to the server) if it has a server\n// footprint: server storage, or an indexer (which the SERVER runs). Purely\n// client-side plugins stay device-local.\nfunction accountScoped(manifest, granted) {\n if (granted.includes('storage')) return true;\n return serverIndexers(manifest).length > 0;\n}\n\n// A cheap fingerprint of a plugin's live self-report, used to tell whether a heartbeat\n// changed anything worth re-rendering for.\nfunction signature(live) {\n if (!live) return '';\n return `${live.online ? 1 : 0}|${[...(live.handlers || [])].sort().join(',')}`;\n}\n",
61
+ "// What kind of screen is this, and how is it being driven?\n//\n// The drive runs on three shapes of device that want genuinely different chrome: a\n// desktop with a mouse and a left rail, a phone held in one hand, and a TV across the\n// room driven by a d-pad. This is the one place that decides which, so components ask\n// `state.vp.mode` instead of each inventing its own breakpoint — and so a single\n// override flips the whole shell at once.\n//\n// Detection is a guess, and guesses about TVs are especially bad (a browser on a set-top\n// box reports a large screen and, often, a mouse it does not have). So the guess is only\n// the default: `?ui=phone` in the URL, or the `workbench.layout` setting, wins outright.\n// Someone whose TV we mis-detect can fix it in Settings rather than living with it.\n\nimport { cell, effect } from '../runtime.js';\n\nexport const LAYOUTS = ['auto', 'desktop', 'phone', 'tv'];\n\n// Below this, the left rail plus a panel leaves nothing for the panel.\nconst PHONE_MAX = 720;\n// A TV is a big screen you sit far away from. Only consulted alongside a UA hint —\n// width alone would call every large monitor a television.\nconst TV_MIN = 1100;\nconst TV_UA = /\\b(smart-?tv|smarttv|appletv|googletv|android\\s*tv|hbbtv|netcast|web0s|webos|tizen|viera|bravia|aquos|crkey|nettv|dtv|philipstv|roku|aft[a-z]{1,3})\\b/i;\n\n/** Does the user agent say, unprompted, that it is a television? */\nexport function looksLikeTv(ua = '', width = 0) {\n if (!ua) return false;\n return TV_UA.test(ua) && width >= TV_MIN;\n}\n\nexport class ViewportService {\n #state;\n\n /**\n * @param {object} [deps]\n * @param {Window} [deps.window] the window to measure and listen to\n * @param {import('./settings.js').SettingsService} [deps.settings]\n */\n constructor({ window: win = globalThis, settings = null } = {}) {\n this.window = win;\n this.settings = settings;\n // A URL override outranks the setting: it is how someone checks the phone layout on\n // a laptop, and how the e2e suite drives each shell without a device farm.\n this.urlOverride = readUrlOverride(win);\n this.#state = this.#measure();\n this.cell = cell(this.#state);\n this._onResize = () => this.refresh();\n }\n\n /** The value, for whoever is about to decide something from it. See bl/state.js: one\n * value, one way to read it — a public `state` field is a second, writable door. */\n get() {\n return this.#state;\n }\n\n observe() {\n return this.cell;\n }\n\n /** Start listening. Separate from the constructor so tests can measure without hooks. */\n install() {\n this.window.addEventListener?.('resize', this._onResize);\n this.window.addEventListener?.('orientationchange', this._onResize);\n // `effect` runs now and on every change. The old form was\n // `settings.observe().subscribe?.(…)` — optional-chained, so when `observe()`\n // stopped returning something with `.subscribe` it would have become a silent\n // no-op and the viewport would have stopped following its own setting.\n if (this.settings) effect(this.settings.observe(), () => this.refresh());\n this.#publish(this.#state);\n return this;\n }\n\n dispose() {\n this.window.removeEventListener?.('resize', this._onResize);\n this.window.removeEventListener?.('orientationchange', this._onResize);\n }\n\n refresh() {\n const next = this.#measure();\n const same = next.mode === this.#state.mode && next.width === this.#state.width\n && next.height === this.#state.height && next.coarse === this.#state.coarse;\n if (same) return;\n this.#state = next;\n this.#publish(next);\n this.cell.setValue(next);\n }\n\n #publish(vp) {\n // Context keys so plugin `when` clauses and keybindings can target a form factor\n // the same way they target a view.\n // The root element carries it too, so CSS can respond without every rule needing a\n // media query that would disagree with the JS branch above it.\n const el = this.window.document?.documentElement;\n if (el) el.dataset.layout = vp.mode;\n }\n\n #measure() {\n const win = this.window;\n const width = win.innerWidth || 1280;\n const height = win.innerHeight || 800;\n const coarse = matches(win, '(pointer: coarse)');\n const ua = win.navigator?.userAgent || '';\n const forced = this.urlOverride || this.settings?.get?.('workbench.layout') || 'auto';\n const mode = forced !== 'auto' && LAYOUTS.includes(forced) ? forced : detect({ width, coarse, ua });\n return { mode, width, height, coarse, forced: forced !== 'auto' };\n }\n}\n\nfunction detect({ width, coarse, ua }) {\n if (looksLikeTv(ua, width)) return 'tv';\n // Narrow is a phone whether or not the pointer is coarse — a desktop window dragged\n // small has the same problem a phone does, and the layout that fits one fits the other.\n if (width <= PHONE_MAX) return 'phone';\n return 'desktop';\n}\n\nfunction matches(win, query) {\n try { return !!win.matchMedia?.(query)?.matches; } catch { return false; }\n}\n\nfunction readUrlOverride(win) {\n try {\n const value = new URL(win.location.href).searchParams.get('ui');\n return value && LAYOUTS.includes(value) ? value : null;\n } catch { return null; }\n}\n",
62
+ "// Driving the drive with a remote control.\n//\n// A TV has four arrows, an OK button, and a Back button. It has no pointer and no Tab\n// key, so a layout that is perfectly usable with a mouse can be completely unreachable\n// from a sofa: focus lands somewhere, the arrows do nothing, and there is no way out.\n//\n// This maps the arrows onto GEOMETRY rather than DOM order. Pressing right should move\n// to the thing that is visually to the right, which is what someone holding a remote\n// expects and what tab order — written for reading order — does not give. Two rules keep\n// it from fighting the rest of the app:\n//\n// 1. If something already handled the key (the launcher's own list navigation, a text\n// field's caret), it is left alone. `defaultPrevented` is the contract.\n// 2. Anything the app made clickable is reachable, whether or not the browser thinks\n// it is focusable. A div with a click handler is a destination on a TV; the\n// alternative is a list of files that cannot be opened.\n//\n// Only installed when the layout is 'tv'. On a desktop the pointer and Tab already work,\n// and remapping the arrow keys there would break scrolling.\n\n// Natively focusable, plus the app's own clickable rows. Keeping this list explicit\n// (rather than \"anything with a click handler\", which the DOM cannot tell us) means a\n// new clickable component is opted in deliberately.\nimport { effect } from '../runtime.js';\n\nconst NATIVE = 'a[href], button:not([disabled]), input:not([disabled]), select, textarea, [tabindex]:not([tabindex=\"-1\"])';\n// `.setting-row` used to be listed here and has never existed — the rendered class is\n// `.setting`, and it isn't clickable anyway (its control is). Every entry below is\n// checked by probe15-tv-reach, so a renamed class fails a test instead of silently\n// dropping a destination.\nconst APP_CLICKABLE = '.launch-item, .grid-tile, .sheet-row, .inbox-item, .plugin-card, .act-task, .act-issue, .chapter';\nconst SELECTOR = `${NATIVE}, ${APP_CLICKABLE}`;\n\n// Keys a television sends for \"back\". The named ones are the web standard; the numbers\n// are Tizen (Samsung) and webOS (LG), which predate it and still ship.\nconst BACK_KEYS = new Set(['BrowserBack', 'GoBack', 'Backspace']);\nconst BACK_CODES = new Set([10009, 461]);\n\nconst DIRS = { ArrowLeft: 'left', ArrowRight: 'right', ArrowUp: 'up', ArrowDown: 'down' };\n// Elements the browser already fires a click on when Enter is pressed.\nconst ACTIVATES_ITSELF = new Set(['A', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA']);\n\nexport class SpatialNavigationService {\n /**\n * @param {object} deps\n * @param {import('./viewport.js').ViewportService} deps.viewport\n * @param {Window} [deps.window]\n */\n constructor({ workbench, viewport, window: win = globalThis }) {\n this.viewport = viewport;\n this.window = win;\n this.active = false;\n this._onKey = (e) => this.handleKey(e);\n this._observer = null;\n this._pending = 0;\n this._bootstrapped = false;\n }\n\n /** Follow the viewport: arrows are remapped only while the TV layout is showing. */\n install() {\n if (this.viewport) effect(this.viewport.observe(), (vp) => this.setActive(vp.mode === 'tv'));\n this.setActive(this.viewport?.get().mode === 'tv');\n return this;\n }\n\n setActive(on) {\n if (on === this.active) return;\n this.active = on;\n // Bubble phase, so a component that wants the key gets it first and this only sees\n // what nothing else claimed.\n if (on) {\n this.window.addEventListener?.('keydown', this._onKey);\n this.#watchDom();\n // The first frame may not have rendered yet; a TV with nothing focused is a TV\n // where the first arrow press has no origin and appears to do nothing at all.\n this.prime();\n this.window.setTimeout?.(() => this.prime(), 60);\n } else {\n this.window.removeEventListener?.('keydown', this._onKey);\n this._observer?.disconnect();\n this._observer = null;\n this._bootstrapped = false;\n }\n }\n\n /**\n * Make everything clickable focusable, and make sure something IS focused.\n *\n * Both halves matter. A div with a click handler is a destination on a TV but the\n * browser will not focus it without a tabindex, and the app re-renders constantly, so\n * this has to run again after every render rather than once at startup.\n */\n prime() {\n this.candidates(); // stamps tabindex as a side effect\n this.focusFirst();\n }\n\n #watchDom() {\n const Obs = this.window.MutationObserver;\n if (!Obs || this._observer) return;\n // Coalesced to one pass per frame: the workbench replaces whole subtrees on a\n // re-render, and stamping per mutation would be thousands of calls per second.\n this._observer = new Obs(() => {\n if (this._pending) return;\n this._pending = this.window.requestAnimationFrame?.(() => {\n this._pending = 0;\n if (this.active) this.prime();\n }) || 0;\n });\n this._observer.observe(this.window.document.body, { childList: true, subtree: true });\n }\n\n handleKey(e) {\n if (!this.active || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;\n const doc = this.window.document;\n const from = doc.activeElement;\n\n if (BACK_KEYS.has(e.key) || BACK_CODES.has(e.keyCode)) {\n // Backspace with something to delete is a backspace. Getting this wrong throws\n // away what someone typed on an on-screen keyboard. But an EMPTY field has nothing\n // to delete, and a remote whose only Back button silently does nothing while a\n // search box happens to hold focus is a remote that can't leave the screen.\n if (e.key === 'Backspace' && isTextEntry(from) && (from.value ?? '').length > 0) return;\n e.preventDefault();\n this.goBack();\n return;\n }\n\n const dir = DIRS[e.key];\n if (!dir) {\n // Enter on a real button already activates it. Enter on one of the app's clickable\n // divs does nothing at all unless we say so — and note the test is the TAG, not\n // \"is it focusable\": we stamped a tabindex on those divs ourselves, so asking\n // whether they look focusable would answer yes for every one of them and OK would\n // silently do nothing on every file in the list.\n if (e.key === 'Enter' && from && !ACTIVATES_ITSELF.has(from.tagName) && from.matches(APP_CLICKABLE)) {\n e.preventDefault();\n from.click();\n }\n return;\n }\n // Inside a text field, left and right move the caret — until the caret runs out of\n // text. Then the next press leaves the field. Without the second half the search box\n // is a trap: focus goes in and the only way out is a key a remote doesn't have.\n if ((dir === 'left' || dir === 'right') && isTextEntry(from) && !atTextEdge(from, dir)) return;\n\n // A re-render can drop the focused node, leaving focus on <body> with no origin to\n // navigate from. Any arrow press should recover rather than appear to do nothing.\n const origin = from && from !== doc.body ? from : null;\n const next = this.find(dir, origin);\n if (!next) return;\n e.preventDefault();\n focusIt(next);\n }\n\n goBack() {\n // An open overlay is what \"back\" means while one is open. Only past that does back\n // mean the viewer stack, and only past THAT does it mean the browser.\n if (this.workbench?.closeOverlays()) return;\n this.window.history?.back?.();\n }\n\n /** Every candidate currently on screen, in whatever order the DOM gives them. */\n candidates() {\n const doc = this.window.document;\n const out = [];\n for (const el of doc.querySelectorAll(SELECTOR)) {\n if (el.getAttribute?.('aria-hidden') === 'true' || el.hasAttribute?.('disabled')) continue;\n const r = el.getBoundingClientRect();\n if (r.width < 2 || r.height < 2) continue;\n // Off-screen is not a destination — a remote can't scroll to something it can't\n // move to, so anything outside the viewport is skipped until it scrolls in.\n if (r.bottom < 0 || r.top > this.window.innerHeight || r.right < 0 || r.left > this.window.innerWidth) continue;\n // The app's clickable rows aren't focusable until we make them so. Doing it here,\n // lazily, keeps tabindex out of every component for a mode most users never see.\n if (!el.matches(NATIVE) && !el.hasAttribute('tabindex')) el.setAttribute('tabindex', '0');\n out.push({ el, rect: r });\n }\n return out;\n }\n\n /** The best thing to move to from `from` in `dir`, or null if there isn't one. */\n find(dir, from) {\n const all = this.candidates();\n if (!all.length) return null;\n const origin = from && from.getBoundingClientRect && from.getBoundingClientRect().width\n ? from.getBoundingClientRect()\n : null;\n if (!origin) return all[0].el;\n\n let best = null;\n let bestScore = Infinity;\n for (const { el, rect } of all) {\n if (el === from) continue;\n const score = scoreCandidate(origin, rect, dir);\n if (score == null || score >= bestScore) continue;\n bestScore = score;\n best = el;\n }\n return best;\n }\n\n /**\n * Put focus somewhere sensible, once.\n *\n * Deliberately only ONCE. Every re-render replaces DOM nodes and drops focus to\n * <body>, and re-running this each time would repeatedly yank the selection back to\n * the top of the screen while someone is halfway down a list. Recovering from lost\n * focus is the arrow handler's job instead — it navigates from the first candidate\n * when there is no origin, so a press always does something.\n */\n focusFirst() {\n if (this._bootstrapped) return;\n const doc = this.window.document;\n if (doc?.activeElement && doc.activeElement !== doc.body) return;\n const all = this.candidates();\n if (!all.length) return;\n // Search is what the drive is for, so that is where a remote should start.\n const target = all.find((c) => c.el.classList?.contains('launch-input')) || all[0];\n focusIt(target.el);\n this._bootstrapped = true;\n }\n}\n\n/** Is the caret already at the end it would be moving toward? */\nfunction atTextEdge(el, dir) {\n const start = el.selectionStart;\n const end = el.selectionEnd;\n // contenteditable and some input types report nothing; treat \"can't tell\" as at the\n // edge, since being unable to leave is the worse failure.\n if (start == null || end == null) return true;\n if (start !== end) return false; // a selection: the arrow collapses it\n return dir === 'left' ? start === 0 : end >= (el.value ?? '').length;\n}\n\nfunction isTextEntry(el) {\n if (!el) return false;\n const tag = el.tagName;\n if (tag === 'TEXTAREA') return true;\n if (el.isContentEditable) return true;\n if (tag !== 'INPUT') return false;\n return !['checkbox', 'radio', 'button', 'submit', 'range', 'file'].includes(el.type);\n}\n\nfunction focusIt(el) {\n el.focus?.({ preventScroll: true });\n // A TV screen is mostly not where your eye is; scrolling the target to the middle is\n // what makes a long list navigable without the selection hugging an edge.\n el.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });\n}\n\n/**\n * How good a move is, lower being better — or null if the candidate isn't in that\n * direction at all.\n *\n * Two distances matter and they are not equal. How far it is ALONG the direction of\n * travel is the honest cost. How far it is OFF to the side is worse than it looks: a\n * candidate that is 10px further right but 400px down is not \"to the right\" in any sense\n * that matters to someone pressing right, so the sideways distance is weighted heavily.\n */\nfunction scoreCandidate(from, to, dir) {\n const vertical = dir === 'up' || dir === 'down';\n // Near edges along the axis of travel.\n const [fromNear, toNear] = vertical\n ? (dir === 'down' ? [from.bottom, to.top] : [from.top, to.bottom])\n : (dir === 'right' ? [from.right, to.left] : [from.left, to.right]);\n const forward = dir === 'down' || dir === 'right';\n const along = forward ? toNear - fromNear : fromNear - toNear;\n // A tolerance, so items in the same row that overlap by a pixel or two still count.\n if (along < -2) return null;\n\n // Overlap on the cross axis is what makes something feel \"in line\". Where they overlap\n // the sideways cost is zero; where they don't, it is the gap between them.\n const [fs, fe, ts, te] = vertical\n ? [from.left, from.right, to.left, to.right]\n : [from.top, from.bottom, to.top, to.bottom];\n const aside = Math.max(0, Math.max(fs, ts) - Math.min(fe, te));\n // Also break ties by centre alignment, so a wide row doesn't beat the one directly\n // under the cursor just because they both overlap.\n const centerGap = Math.abs((fs + fe) / 2 - (ts + te) / 2);\n return Math.max(0, along) + aside * 3 + centerGap * 0.2;\n}\n\nexport { scoreCandidate };\n",
63
+ "// Dictating into the search box.\n//\n// THE REMOTE'S MIC BUTTON IS NOT OURS. On every TV platform it belongs to the system:\n// webOS's SDK exposes no way for an app to listen to the Magic Remote, Tizen's voice\n// control is a packaged-app API that does not exist for a page in the TV browser, and\n// on Android TV the button raises Assistant. No key event reaches the document, so\n// there is nothing to intercept and no shortcut to bind.\n//\n// What the button DOES do is dictate into a focused text field, through the platform's\n// own keyboard. That is the whole opportunity: the mic is useful exactly when there is\n// somewhere for its text to land. `search.voice` therefore does not try to capture a\n// button — it makes sure the search field is open and focused, so the mic on the remote\n// has a target. That half works on every TV, with no API at all.\n//\n// This module is the OTHER half, for browsers that can transcribe themselves (Chrome,\n// so Android TV and the desktop). It is deliberately narrow:\n//\n// ON-DEVICE ONLY. By default `SpeechRecognition` streams audio to the browser\n// vendor's servers. Trove is a drive you host so that your files stay yours, and\n// shipping a microphone that quietly forwards your voice to a third party would\n// contradict the entire point of it. `processLocally` asks for recognition that never\n// leaves the machine; a browser that cannot promise that is simply reported as\n// unsupported, and the button is never offered.\n\n/**\n * Resolved per call, not captured at import.\n *\n * A module-level constant would freeze the answer at load time, which is wrong twice\n * over: the page may gain the API later (a polyfill, a flag flipped behind a restart),\n * and a test could never stand in for it. Reading it when asked costs a property lookup.\n */\nfunction impl() {\n if (typeof window === 'undefined') return null;\n return window.SpeechRecognition || window.webkitSpeechRecognition || null;\n}\n\n/**\n * Whether this browser can transcribe WITHOUT sending audio anywhere.\n *\n * `available()` is the on-device half of the API; a browser that lacks it has no notion\n * of local recognition, which for us is the same as having no recognition. Detecting\n * the constructor alone would be the bug: every Chrome has that, and most of them would\n * happily record you into a datacentre.\n */\nexport function canTranscribeLocally() {\n const Impl = impl();\n return !!Impl && typeof Impl.available === 'function';\n}\n\nconst optionsFor = (lang) => ({ langs: [lang], processLocally: true });\n\n/**\n * `'available' | 'downloadable' | 'downloading' | 'unavailable'`\n *\n * A language pack that is merely `downloadable` is not usable yet, and downloading one\n * unasked would spend someone's bandwidth on a button they have not pressed.\n */\nexport async function localAvailability(lang = navigator.language || 'en-US') {\n if (!canTranscribeLocally()) return 'unavailable';\n try {\n return await impl().available(optionsFor(lang));\n } catch {\n return 'unavailable';\n }\n}\n\n/** Fetch the on-device language pack. Only ever called from an explicit user action. */\nexport async function installLocal(lang = navigator.language || 'en-US') {\n if (typeof impl()?.install !== 'function') return false;\n try {\n return await impl().install(optionsFor(lang));\n } catch {\n return false;\n }\n}\n\n/**\n * Listen, and report what was heard.\n *\n * `onText(text, { final })` fires for interim results too, so the query updates as\n * someone speaks rather than landing in one lump at the end — on a TV that feedback is\n * the difference between \"it is listening\" and \"did it hear me\".\n *\n * @returns {{stop: () => void}}\n */\nexport function listen({ lang = navigator.language || 'en-US', onText, onEnd, onError } = {}) {\n if (!canTranscribeLocally()) throw new Error('On-device speech recognition is not available here');\n const rec = new (impl())();\n rec.lang = lang;\n rec.interimResults = true;\n rec.continuous = false;\n // Both spellings: `options` is the shape the explainer settled on, and shipping\n // builds also read the flag straight off the instance. Setting one the browser\n // ignores is harmless; setting neither would mean asking for local processing and\n // silently getting the remote kind.\n rec.options = optionsFor(lang);\n rec.processLocally = true;\n\n let stopped = false;\n rec.onresult = (event) => {\n let text = '';\n let final = false;\n for (let i = event.resultIndex; i < event.results.length; i++) {\n text += event.results[i][0].transcript;\n if (event.results[i].isFinal) final = true;\n }\n onText?.(text.trim(), { final });\n };\n // `no-speech` and `aborted` are what happens when someone changes their mind. They\n // are not failures worth a toast.\n rec.onerror = (event) => {\n if (event.error === 'no-speech' || event.error === 'aborted') return;\n onError?.(new Error(event.error || 'Speech recognition failed'));\n };\n rec.onend = () => { if (!stopped) { stopped = true; onEnd?.(); } };\n\n try {\n rec.start();\n } catch (err) {\n stopped = true;\n onError?.(err);\n onEnd?.();\n }\n\n return {\n stop() {\n if (stopped) return;\n stopped = true;\n try { rec.stop(); } catch { /* already finished */ }\n onEnd?.();\n },\n };\n}\n",
64
+ "// The \"speak to search\" surface, and the part of it that works with no API at all.\n//\n// Two jobs, and they are independent on purpose:\n//\n// 1. PUT THE SEARCH FIELD UNDER THE MICROPHONE. A TV remote's mic dictates into\n// whatever text field the platform keyboard is attached to, and does nothing at\n// all when there isn't one. So the command opens the search surface and focuses\n// its input. On webOS and Tizen that is the entire feature — the platform does\n// the listening, the text arrives as ordinary input events, and Trove never asks\n// for a microphone.\n//\n// 2. TRANSCRIBE OURSELVES, where the browser can do it on-device (see voice.js).\n// Additive: if it isn't available the field is still focused and the remote's own\n// mic still works.\n\nimport { cell } from '../runtime.js';\nimport { canTranscribeLocally, localAvailability, installLocal, listen } from './voice.js';\n\nexport class VoiceSearchService {\n #state;\n\n /**\n * @param {object} deps\n * @param {object} deps.notifications\n */\n constructor({ notifications, settings } = {}) {\n this.notifications = notifications;\n this.settings = settings;\n this.session = null;\n this.#state = { supported: canTranscribeLocally(), status: 'unknown', listening: false };\n this.cell = cell(this.#state);\n }\n\n /** The value, for whoever is about to decide something from it. See bl/state.js: one\n * value, one way to read it — a public `state` field is a second, writable door. */\n get() {\n return this.#state;\n }\n\n observe() {\n return this.cell;\n }\n #set(patch) {\n this.#state = { ...this.#state, ...patch };\n this.cell.setValue(this.#state);\n }\n\n /** Ask once whether an on-device language pack is ready, and remember the answer. */\n async refresh() {\n if (!this.#state.supported) return 'unavailable';\n const status = await localAvailability(this.#lang());\n this.#set({ status });\n return status;\n }\n\n #lang() {\n return this.settings?.get?.('search.voiceLanguage') || navigator.language || 'en-US';\n }\n\n /** Can we offer a microphone button right now? */\n canListen() {\n return this.#state.supported && (this.#state.status === 'available' || this.#state.status === 'downloadable');\n }\n\n /**\n * The command behind `search.voice`.\n *\n * `focus` is what makes this worth binding on a TV even when we cannot transcribe:\n * it is the difference between the remote's mic having a target and being swallowed\n * by the platform assistant.\n */\n async run({ onText } = {}) {\n this.openSearchSurface();\n // Focus AFTER the surface has rendered — the input does not exist yet on the frame\n // that opened it.\n await this.focusInput();\n if (!this.#state.supported) return { listening: false, reason: 'unsupported' };\n\n const status = this.#state.status === 'unknown' ? await this.refresh() : this.#state.status;\n if (status === 'downloadable') {\n // Pressing the button IS the consent to fetch it; nothing downloads before that.\n this.notifications?.info('Downloading the on-device voice model — this happens once.');\n const ok = await installLocal(this.#lang());\n this.#set({ status: ok ? 'available' : 'unavailable' });\n if (!ok) return { listening: false, reason: 'install-failed' };\n } else if (status !== 'available') {\n return { listening: false, reason: status };\n }\n return this.toggle({ onText });\n }\n\n /** Start listening, or stop if already. */\n toggle({ onText } = {}) {\n if (this.session) {\n this.stop();\n return { listening: false };\n }\n try {\n this.session = listen({\n lang: this.#lang(),\n onText,\n onEnd: () => { this.session = null; this.#set({ listening: false }); },\n onError: (err) => {\n this.session = null;\n this.#set({ listening: false });\n // A refused microphone is a decision, not a fault worth shouting about.\n if (!/not-allowed|service-not-allowed|denied/i.test(err.message)) {\n this.notifications?.warn(`Couldn't listen: ${err.message}`);\n }\n },\n });\n this.#set({ listening: true });\n return { listening: true };\n } catch (err) {\n this.notifications?.warn(`Couldn't listen: ${err.message}`);\n return { listening: false, reason: 'error' };\n }\n }\n\n stop() {\n this.session?.stop();\n this.session = null;\n this.#set({ listening: false });\n }\n\n /**\n * Make sure a search field is on screen.\n *\n * Already on the launcher with nothing open → it is the search surface, use it. Any\n * other view, or a file open over it → the modal, which is the one search box that\n * can appear over anything.\n */\n openSearchSurface() {\n const wb = this.workbench;\n if (!wb) return;\n const onLauncher = wb.state.activity === 'home' && !wb.nav?.get?.().activeTabId;\n if (onLauncher) wb.closeSearchModal?.();\n else wb.openSearchModal();\n }\n\n /** @returns {Promise<boolean>} whether an input actually took focus */\n focusInput({ tries = 12 } = {}) {\n return new Promise((resolve) => {\n let left = tries;\n const attempt = () => {\n const el = document.querySelector('.search-modal .launch-input') || document.querySelector('.launch-input');\n if (el) {\n el.focus();\n // Put the caret at the end so dictation appends rather than overwriting a\n // query someone already typed.\n try { el.setSelectionRange(el.value.length, el.value.length); } catch { /* not a text input */ }\n resolve(document.activeElement === el);\n return;\n }\n if (--left <= 0) { resolve(false); return; }\n requestAnimationFrame(attempt);\n };\n attempt();\n });\n }\n}\n",
65
+ "// URLs for things that cannot send a header.\n//\n// An `<img src>`, a `<video src>` and `cache.add()` all fetch without our Authorization\n// header, so on a token-authenticated deployment they 401 and the preview shows a\n// fallback. The server can mint a URL that carries its own grant (see\n// docs/design/signed-urls.md); this is the client half.\n//\n// Two things it exists to get right:\n//\n// BATCHING — a gallery draws hundreds of tiles at once. Per-object signing is right for\n// scoping and hopeless as one round trip each, so ids asked for in the same tick go out\n// together.\n//\n// EXPIRY — a minted URL dies. Callers get `expiresAt` alongside and are expected to\n// cycle (see ui/media.js); this service will not hand back a URL that is about to\n// expire, so a caller that re-asks always gets something usable.\n\n// Re-mint at 80% of the remaining life rather than at the end: a URL handed out at 99%\n// of its life is one the caller will be back for almost immediately.\nconst FRESH_ENOUGH = 0.8;\n// Ids asked for within this window go out as one request. A frame is 16ms; this is long\n// enough to collect a grid's first paint and short enough not to be felt.\nconst BATCH_MS = 20;\nconst MAX_BATCH = 200;\n\nexport class MediaUrlService {\n /** @param {{api: object, settings?: object}} deps */\n constructor({ api, settings = null }) {\n this.api = api;\n this.settings = settings;\n this.cache = new Map(); // `${op}:${id}` -> { url, expiresAt }\n this._queue = new Map(); // op -> Map(id -> {resolve, reject})\n this._timer = null;\n }\n\n /**\n * Whether URLs need minting at all.\n *\n * With no bearer token the browser authenticates itself — a cookie or a proxy header\n * rides along on a subresource load — so the plain route URL works, needs no round\n * trip, and stays stable enough to be a cache key. Minting there would be a cost with\n * nothing bought. This is the one branch, and it lives here so callers have none.\n *\n * `media.signedUrls` overrides the guess: a deployment behind a proxy that still wants\n * media fetched straight from S3 sets `always`.\n */\n get needed() {\n const mode = this.settings?.get('media.signedUrls');\n if (mode === 'always') return true;\n if (mode === 'never') return false;\n return !!this.api.token?.();\n }\n\n /**\n * A stable identifier for this node's bytes.\n *\n * NOT the URL to fetch — a minted one carries a signature and changes every time. The\n * offline cache keys on this, because a key that changes per mint means `unpin` stops\n * matching what `pin` stored and the bytes are never reclaimed.\n */\n cacheKey(id) {\n return this.api.downloadUrl(id);\n }\n\n /**\n * A URL for this node's bytes, good for a while.\n *\n * @returns {Promise<{url: string, expiresAt: number}>} `expiresAt` is Infinity when\n * nothing was minted, so a caller's cycling logic simply never fires.\n */\n async url(id, { op = 'media' } = {}) {\n if (!this.needed) return { url: this.api.downloadUrl(id, { attachment: op === 'download' }), expiresAt: Infinity };\n const key = `${op}:${id}`;\n const hit = this.cache.get(key);\n if (hit && this.#fresh(hit)) return hit;\n return this.#enqueue(id, op);\n }\n\n /** Forget what we hold for a node, so the next ask re-mints. */\n invalidate(id, op = 'media') {\n if (id == null) this.cache.clear();\n else this.cache.delete(`${op}:${id}`);\n }\n\n #fresh(entry) {\n if (entry.expiresAt === Infinity) return true;\n const life = entry.expiresAt - entry.mintedAt;\n return Date.now() < entry.mintedAt + life * FRESH_ENOUGH;\n }\n\n #enqueue(id, op) {\n if (!this._queue.has(op)) this._queue.set(op, new Map());\n const forOp = this._queue.get(op);\n const existing = forOp.get(id);\n if (existing) return existing.promise;\n\n let resolve;\n let reject;\n const promise = new Promise((res, rej) => { resolve = res; reject = rej; });\n forOp.set(id, { resolve, reject, promise });\n\n // Flush immediately at the cap rather than waiting out the window — a drive view that\n // asks for a thousand tiles should not hold the first two hundred hostage.\n if (forOp.size >= MAX_BATCH) this.#flush();\n else if (!this._timer) this._timer = setTimeout(() => this.#flush(), BATCH_MS);\n return promise;\n }\n\n async #flush() {\n clearTimeout(this._timer);\n this._timer = null;\n const queue = this._queue;\n this._queue = new Map();\n\n for (const [op, waiting] of queue) {\n const ids = [...waiting.keys()];\n try {\n const res = await this.api.mintUrls(ids, op);\n const now = Date.now();\n // Sweep before inserting. An expired entry can never be served again — `#fresh`\n // only decides whether a HIT is usable — and nothing else ever removed one: the\n // sole `invalidate` caller is a media element's error handler. Browsing a large\n // collection mints per pictorial tile, so the map grew an entry per image, none\n // reachable and none collectable for the life of the page. Two lines, and unlike\n // the interning table in bl/intern.js, evicting here costs a re-mint rather than a\n // duplicate realization.\n for (const [key, entry] of this.cache) {\n if (entry.expiresAt && entry.expiresAt < now) this.cache.delete(key);\n }\n for (const [id, w] of waiting) {\n const got = res.urls?.[id];\n if (got) {\n const entry = { url: got.url, expiresAt: got.expiresAt, mintedAt: now };\n this.cache.set(`${op}:${id}`, entry);\n w.resolve(entry);\n } else {\n // Absent from the answer means this caller may not read it. A rejection, not\n // a broken URL — the tile shows its icon rather than a broken-image glyph.\n w.reject(new Error(res.failed?.[id] === 'not_found' ? 'That file is gone' : 'You cannot open that file'));\n }\n }\n } catch (err) {\n for (const w of waiting.values()) w.reject(err);\n }\n }\n }\n}\n",
66
+ "// Where a file's bytes come from, and which of them are worth keeping.\n//\n// A viewer reading a range asks here rather than asking the network, and the answer comes\n// from the first of three places that has it:\n//\n// 1. A PINNED whole-file copy. bl/offline.js already puts the whole Response into Cache\n// Storage under `mediaUrls.cacheKey(id)` — a deliberately stable key, so `unpin` can\n// find what `pin` stored. Slicing that cached blob is disk-backed and costs nothing,\n// so a pinned book plays with the network off and this tier comes almost free.\n// 2. CHUNKS of a download in progress. Playing from the middle fetches the middle, and\n// if that file is also being taken offline those bytes are worth keeping — so the\n// read contributes them and the background filler skips them later.\n// 3. The network, keeping NOTHING.\n//\n// THE THIRD CASE IS THE DEFAULT, and it is the rule the whole design hangs off: a plugin\n// ranging over a file nobody asked to keep must not quietly fill the disk with it. Bytes\n// are retained only for an item someone has actually asked to have offline, and `start(id)`\n// is that asking. Until it is called this is a plain ranged reader with a cache lookup in\n// front of it.\n//\n// THE ETAG IS IN THE KEY. A file overwritten in place keeps its id, so an id-keyed chunk\n// cache would hand a reader the head of the old file and the tail of the new one. For a\n// container format that is a parse failure, and a confusing one — the bytes are all valid,\n// they are just from two different files. A changed etag makes every old chunk stop\n// matching, and the sweep reclaims them.\n\nconst CHUNKS_CACHE = 'trove-chunks-v1';\n\n/**\n * 4 MiB.\n *\n * A long audiobook is a few hundred entries at this size rather than a few thousand, and\n * Cache Storage is a real database — the per-entry overhead is what makes a small chunk\n * size expensive, not the bytes. Big enough that one chunk usually covers a seek, small\n * enough that the first one arrives quickly.\n */\nexport const CHUNK_SIZE = 4 * 1024 * 1024;\n\nconst chunkOf = (offset) => Math.floor(offset / CHUNK_SIZE);\nconst concat = (parts, total) => {\n const out = new Uint8Array(total);\n let at = 0;\n for (const p of parts) { out.set(p, at); at += p.length; }\n return out;\n};\n\nexport class FileChunks {\n /** @param {{api: object, mediaUrls: object}} deps */\n constructor({ api, mediaUrls }) {\n this.api = api;\n this.mediaUrls = mediaUrls;\n // What someone asked to keep: id -> { etag, total, cancel, filling, done, failed }.\n // In memory because it is about THIS session's background work; what survives a reload\n // is the chunks themselves, which is the durable half.\n this.kept = new Map();\n this.listeners = new Set();\n }\n\n /** Progress, for a viewer drawing a bar. `off()` to stop listening. */\n onProgress(fn) {\n this.listeners.add(fn);\n return () => this.listeners.delete(fn);\n }\n #emit(id) {\n const s = this.status(id);\n for (const fn of [...this.listeners]) { try { fn(id, s); } catch { /* a listener is not our problem */ } }\n }\n\n #key(id, etag, index) {\n // The stable download URL, plus a QUERY parameter. Not a fragment: the Cache API keys\n // on a Request, and a Request's url excludes its fragment — so `…#chunk=0` and\n // `…#chunk=1` are the same key, and every chunk of every file would collide on the\n // first one. It reads as \"part of this file\" in devtools either way.\n return `${this.mediaUrls.cacheKey(id)}&chunk=${etag || 'none'}:${CHUNK_SIZE}:${index}`;\n }\n\n async #cache(name) {\n if (!('caches' in globalThis)) return null;\n return caches.open(name).catch(() => null);\n }\n\n /**\n * The pinned whole-file copy, if there is one.\n *\n * Tier 1, and the reason it is first: it needs no chunking, no etag bookkeeping and no\n * network, because `bl/offline.js` already put the entire Response there.\n */\n async #pinned(id) {\n const cache = await this.#cache('trove-files-v1');\n if (!cache) return null;\n return cache.match(this.mediaUrls.cacheKey(id), { ignoreVary: true }).catch(() => null);\n }\n\n /**\n * Read `[start, end)`.\n *\n * @param {string} id\n * @param {{start?: number, end?: number, signal?: AbortSignal}} range\n * @returns {Promise<{bytes: Uint8Array, etag: string|null, total: number|null}>}\n */\n async read(id, { start = 0, end, signal } = {}) {\n const whole = await this.#pinned(id);\n if (whole) {\n const blob = await whole.blob();\n const stop = end == null ? blob.size : Math.min(end, blob.size);\n const bytes = new Uint8Array(await blob.slice(start, stop).arrayBuffer());\n return { bytes, etag: whole.headers.get('etag'), total: blob.size };\n }\n\n const keep = this.kept.get(id);\n // Not kept: a plain ranged read, and nothing is written anywhere. This is the branch\n // that runs for every file nobody asked to keep, which is almost all of them.\n if (!keep) return this.api.readRange(id, { start, end, signal });\n\n return this.#readChunked(id, keep, start, end, signal);\n }\n\n /** The kept path: whole chunks, from the cache where possible, contributed on a miss. */\n async #readChunked(id, keep, start, end, signal) {\n const cache = await this.#cache(CHUNKS_CACHE);\n if (!cache) return this.api.readRange(id, { start, end, signal });\n\n // The total has to be known before the last chunk can be sized, and the cheapest way\n // to learn it is the first read — which we were doing anyway.\n if (keep.total == null) {\n const head = await this.api.readRange(id, { start: 0, end: 1, signal });\n keep.total = head.total;\n keep.etag = head.etag;\n }\n const stop = Math.min(end == null ? keep.total : end, keep.total);\n if (stop <= start) return { bytes: new Uint8Array(0), etag: keep.etag, total: keep.total };\n\n const parts = [];\n let got = 0;\n for (let i = chunkOf(start); i <= chunkOf(stop - 1); i++) {\n const chunk = await this.#chunk(id, keep, i, cache, signal);\n // The window this chunk contributes, in the chunk's own coordinates.\n const from = Math.max(0, start - i * CHUNK_SIZE);\n const to = Math.min(chunk.length, stop - i * CHUNK_SIZE);\n const piece = chunk.subarray(from, to);\n parts.push(piece);\n got += piece.length;\n }\n return { bytes: concat(parts, got), etag: keep.etag, total: keep.total };\n }\n\n /** One chunk: cached if it is there, fetched and KEPT if it is not. */\n async #chunk(id, keep, index, cache, signal) {\n const key = this.#key(id, keep.etag, index);\n const hit = await cache.match(key).catch(() => null);\n if (hit) {\n keep.have.add(index);\n return new Uint8Array(await hit.arrayBuffer());\n }\n\n const start = index * CHUNK_SIZE;\n const end = Math.min(start + CHUNK_SIZE, keep.total);\n const res = await this.api.readRange(id, { start, end, signal });\n // The etag can change under us mid-download — someone replaced the file. Everything\n // already stored is from a file that no longer exists, so it is dropped rather than\n // mixed with what is arriving.\n if (res.etag && keep.etag && res.etag !== keep.etag) {\n await this.#dropChunks(id);\n keep.have.clear();\n keep.etag = res.etag;\n keep.total = res.total ?? keep.total;\n }\n await cache.put(key, new Response(res.bytes)).catch(() => {});\n keep.have.add(index);\n this.#emit(id);\n return res.bytes;\n }\n\n /**\n * Keep this item offline, and fill in what is missing in the background.\n *\n * IDEMPOTENT: starting a download that is already running returns its status rather than\n * racing a second filler over the same chunks — two fillers would each fetch every chunk\n * the other had not written yet, which is the whole file twice.\n */\n async start(id) {\n const running = this.kept.get(id);\n if (running) return this.status(id);\n\n const head = await this.api.readRange(id, { start: 0, end: 1 });\n const controller = new AbortController();\n const keep = {\n etag: head.etag, total: head.total, filling: true, done: false, failed: null,\n // Which chunk indices are stored. `loaded` is DERIVED from this rather than counted\n // up as bytes arrive, so a chunk written by a viewer's seek and a chunk written by\n // the background filler are the same fact and neither double-counts the other.\n have: new Set(),\n controller,\n };\n this.kept.set(id, keep);\n this.#emit(id);\n // Not awaited: `start` answers immediately so a viewer can begin playing while the\n // rest arrives. Failures land on the status, which is what a progress bar reads.\n this.#fill(id, keep, controller.signal).catch((err) => {\n keep.filling = false;\n keep.failed = err?.message || String(err);\n this.#emit(id);\n });\n return this.status(id);\n }\n\n /** In order, skipping what is already there — which is what makes a seek pay for itself. */\n async #fill(id, keep, signal) {\n const cache = await this.#cache(CHUNKS_CACHE);\n if (!cache) throw new Error('This browser has no Cache Storage, so nothing can be kept offline');\n const count = Math.max(1, Math.ceil((keep.total || 0) / CHUNK_SIZE));\n for (let i = 0; i < count; i++) {\n if (signal.aborted) return;\n await this.#chunk(id, keep, i, cache, signal);\n }\n keep.filling = false;\n keep.done = true;\n this.#emit(id);\n }\n\n /**\n * How much of it is here.\n *\n * `loaded` counts what has been WRITTEN, not what has been asked for, so a bar built on\n * it never runs ahead of the bytes.\n */\n status(id) {\n const keep = this.kept.get(id);\n if (!keep) return { kept: false, loaded: 0, total: null, ratio: 0, filling: false, done: false, error: null };\n const total = keep.total ?? null;\n // The last chunk is short, so counting every stored chunk as a whole one would report\n // more bytes than the file has.\n const last = total ? Math.ceil(total / CHUNK_SIZE) - 1 : -1;\n let loaded = 0;\n for (const i of keep.have) loaded += i === last ? total - last * CHUNK_SIZE : CHUNK_SIZE;\n return {\n kept: true,\n total,\n loaded,\n ratio: total ? Math.min(1, loaded / total) : 0,\n filling: keep.filling,\n done: keep.done,\n error: keep.failed,\n };\n }\n\n /** Stop filling. What is already stored stays — a resumed download starts from it. */\n cancel(id) {\n const keep = this.kept.get(id);\n if (!keep) return;\n keep.controller?.abort();\n keep.filling = false;\n this.#emit(id);\n }\n\n /** Stop keeping it, and reclaim the bytes. */\n async remove(id) {\n const keep = this.kept.get(id);\n this.cancel(id);\n this.kept.delete(id);\n keep?.have?.clear();\n await this.#dropChunks(id);\n this.#emit(id);\n }\n\n /**\n * Drop every chunk for this file, whatever etag they were stored under.\n *\n * Prefix-matched rather than index-counted: after an etag change we no longer know how\n * many chunks the old file had, and leaving them would be a leak nothing ever reclaims.\n */\n async #dropChunks(id) {\n const cache = await this.#cache(CHUNKS_CACHE);\n if (!cache) return;\n const prefix = `${this.mediaUrls.cacheKey(id)}&chunk=`;\n const keys = await cache.keys().catch(() => []);\n for (const req of keys) {\n if (req.url.startsWith(prefix)) await cache.delete(req).catch(() => {});\n }\n }\n}\n",
67
+ "// createPlatform — assemble every service into one object the whole app shares.\n// This is the \"workbench platform\": the reactive registries and services that core\n// features and plugins both build on. It also registers the default settings schema and\n// keybindings so the shell has sensible behaviour out of the box.\n//\n// It does NOT hold the shell's state. Which activity is open, whether the palette is\n// showing, what is on the panel stack — those are engine resources, built by createApp\n// (see ../bl/state.js). The platform is the machinery underneath them.\n\nimport { reactive } from '../runtime.js';\nimport { ContributionRegistry } from './contributions.js';\nimport { ContextRegistry } from './context.js';\nimport { CommandService } from './commands.js';\nimport { KeybindingService } from './keybindings.js';\nimport { SettingsService } from './settings.js';\nimport { NotificationService } from './notifications.js';\nimport { TroveApiClient } from './api.js';\nimport { PluginHost } from './pluginHost.js';\nimport { ViewportService } from './viewport.js';\nimport { SpatialNavigationService } from './spatialNav.js';\nimport { VoiceSearchService } from './voiceSearch.js';\nimport { MediaUrlService } from './mediaUrls.js';\nimport { FileChunks } from './fileChunks.js';\n\n/**\n * The bearer token for this browser, if any.\n *\n * `localStorage` rather than a cookie because the token is presented as an\n * Authorization header, not sent ambiently — which is what makes CSRF a non-issue here.\n * Wrapped in try/catch because storage access throws outright in some privacy modes,\n * and a drive that white-screens because it couldn't read a key that is usually absent\n * would be a poor trade.\n */\nexport function readToken() {\n try { return localStorage.getItem('trove.token') || null; } catch { return null; }\n}\n// Read only, deliberately: nothing in the workbench signs in. The key is written by the\n// page that EMBEDS the workbench — see test/multiuser.e2e.mjs, which is the arrangement\n// this is built for — so a writer here would be a second owner of somebody else's fact.\nexport function createPlatform({ baseUrl = '' } = {}) {\n const contributions = new ContributionRegistry();\n // Only the fixed facts are seeded. Everything else is registered by whoever owns it —\n // the built-in keys are derived from the shell and the drive (see bl/context.js), so\n // there is nothing sensible to pre-fill them with and nothing that would go stale if\n // there were.\n //\n // It used to be seeded with `view.active: 'home'` for a reason worth remembering: nothing\n // wrote that key until the user navigated, so every `when: view.active == 'home'`\n // binding — the Delete shortcut among them — was dead from boot until the first click on\n // the rail, while the row menu cheerfully advertised \"Del\" as the way to delete. A\n // derived key is never unwritten, so the seed is not needed and cannot drift from the\n // state it was standing in for.\n const context = new ContextRegistry();\n const notifications = new NotificationService();\n const commands = new CommandService(contributions, context, notifications);\n const settings = new SettingsService();\n const keybindings = new KeybindingService(contributions, commands, context, settings);\n // A bearer token, when this deployment uses one. Most don't: an authenticating proxy\n // (Cloudflare Access, oauth2-proxy) sets its own header and the browser sends nothing.\n // But a deployment where the user HOLDS a token has no other way to present it, and\n // reading it here — once, from one place — keeps that out of every call site.\n const api = new TroveApiClient({ baseUrl, token: () => readToken() });\n // Which shell to render — phone, desktop, or TV. Constructed before the defaults are\n // registered, so it reads the setting through `settings.get` once that exists.\n const viewport = new ViewportService({ settings });\n // Arrow keys → geometry, but only on a TV. Inert everywhere else.\n const spatialNav = new SpatialNavigationService({ viewport });\n // Speak to search. Mostly this just puts the search field under the remote's mic —\n // see voiceSearch.js for why that is the whole feature on a TV.\n const voice = new VoiceSearchService({ notifications, settings });\n\n const platform = {\n reactive,\n contributions, context, commands, keybindings, settings, notifications, api,\n viewport, spatialNav, voice,\n // The shell's own state is the engine's, not the platform's — createApp builds it and\n // hands back what the few imperative edges below still need.\n };\n platform.mediaUrls = new MediaUrlService({ api: platform.api, settings });\n // Where a viewer's ranged reads go: a pinned copy, chunks of a download someone asked\n // for, or the network keeping nothing. See fileChunks.js — the retention rule is the\n // whole point of it having a name of its own.\n platform.fileChunks = new FileChunks({ api: platform.api, mediaUrls: platform.mediaUrls });\n platform.plugins = new PluginHost(platform);\n // Commands consult the plugin host to hide/disable plugin commands that aren't\n // available right now (offline, or the plugin isn't responding).\n commands.availability = (cmd) => platform.plugins.isAvailable(cmd);\n\n registerDefaults(platform);\n // Defaults are in place now, so re-measure: `workbench.layout` was unreadable a moment\n // ago and a forced layout must not need a resize to take effect.\n viewport.refresh();\n return platform;\n}\n\nfunction registerDefaults(p) {\n // --- default settings schema ----------------------------------------------\n p.settings.register([\n { key: 'workbench.theme', type: 'enum', enum: ['dark', 'light', 'midnight'], enumLabels: ['Dark', 'Light', 'Midnight'], default: 'dark', title: 'Color theme', category: 'Appearance', order: 1 },\n { key: 'workbench.density', type: 'enum', enum: ['comfortable', 'compact'], default: 'comfortable', title: 'List density', category: 'Appearance', order: 2 },\n // Auto gets it right for phones and desktops. TVs are the reason this is a setting:\n // a browser on a set-top box usually looks like a large desktop, so someone using\n // one with a remote needs a way to say so.\n { key: 'workbench.layout', type: 'enum', enum: ['auto', 'desktop', 'phone', 'tv'],\n enumLabels: ['Automatic', 'Desktop', 'Phone', 'TV / remote'], default: 'auto',\n title: 'Layout', description: 'Automatic follows the screen size. Choose TV for d-pad remote navigation.',\n category: 'Appearance', order: 3 },\n { key: 'explorer.sort', type: 'enum', enum: ['name', 'size', 'updatedAt'], enumLabels: ['Name', 'Size', 'Modified'], default: 'name', title: 'Sort files by', category: 'Explorer', order: 1 },\n { key: 'explorer.sortOrder', type: 'enum', enum: ['asc', 'desc'], default: 'asc', title: 'Sort order', category: 'Explorer', order: 2 },\n { key: 'explorer.confirmDelete', type: 'boolean', default: true, title: 'Confirm before deleting', category: 'Explorer', order: 3 },\n { key: 'search.mode', type: 'enum', enum: ['hybrid', 'semantic', 'keyword'], default: 'hybrid', title: 'Search mode', description: 'Hybrid blends semantic meaning with keyword matches.', category: 'Search', order: 1 },\n { key: 'uploads.concurrency', type: 'number', minimum: 1, maximum: 8, default: 4, title: 'Parallel upload parts', category: 'Transfers', order: 1 },\n // Which viewer opens which file type. When several openers match a file and there\n // is no entry here, the user is asked (and can save their answer) — see bl/openers.\n // Markdown ships with an answer already: it matches both the markdown renderer and\n // the plain-text viewer, and since documents are how things are grouped now,\n // prompting on every first .md would be friction over a decision that's obvious.\n // It stays changeable in Settings, and the text viewer is still reachable through\n // the opener switcher.\n { key: 'openers.associations', type: 'object', hidden: true, title: 'Default viewers',\n default: { '.md': 'core.markdown', '.markdown': 'core.markdown' } },\n // How results are drawn (see ui/components/views). Hidden and with no default on\n // purpose: unset means \"you decide\", and the launcher then offers the grid by itself\n // for a collection full of pictures. Picking one in the switcher pins it.\n { key: 'explorer.view', type: 'string', hidden: true, title: 'Results view' },\n // Whether media fetches use a URL that carries its own grant (see\n // platform/mediaUrls.js). `auto` mints only where the browser cannot authenticate\n // itself, which is the right answer almost everywhere — hence hidden.\n { key: 'media.signedUrls', type: 'enum', enum: ['auto', 'always', 'never'], default: 'auto',\n hidden: true, title: 'Signed media URLs' },\n ]);\n\n // --- the built-in keymap (commands themselves are registered in ../bl) -----\n // One `keymap` contribution, exactly like a plugin's — the host has no privileged\n // path into the keybinding service.\n p.contributions.register('keymap.default', {\n type: 'keymap',\n bindings: [\n { key: 'mod+shift+p', command: 'workbench.showCommandPalette' },\n { key: 'mod+p', command: 'workbench.quickOpen' },\n { key: 'mod+shift+f', command: 'workbench.view.home' },\n { key: 'mod+shift+e', command: 'workbench.view.home' },\n { key: 'mod+,', command: 'workbench.openSettings' },\n { key: 'mod+shift+l', command: 'explorer.copyLink' },\n { key: 'mod+u', command: 'explorer.upload' },\n { key: 'delete', command: 'explorer.delete', when: \"view.active == 'home' && explorer.hasSelection\" },\n { key: 'escape', command: 'workbench.closeOverlays' },\n { key: 'f5', command: 'explorer.refresh' },\n { key: 'mod+shift+i', command: 'workbench.toggleInfoPanel' },\n // Some remotes and keyboards send a dedicated search key; where they do, it lands\n // on the one command that opens the search field ready for dictation.\n { key: 'mod+shift+v', command: 'search.voice' },\n { key: 'browsersearch', command: 'search.voice' },\n ],\n });\n}\n",
68
+ "// The built-in context keys, DERIVED.\n//\n// Every key here is a function of a resource's state. That is not a refactor of where the\n// writes live — it removes the writes. A derived key cannot be forgotten when a new code\n// path changes the thing it summarises, which is the failure the old shape kept producing:\n// `explorer.hasSelection` was set by NavigateAction and by nothing else, so selecting a file\n// in the launcher left it false and the Delete keybinding silently did nothing.\n//\n// Registered in one place because that is what makes the list reviewable. A when-clause is\n// only as trustworthy as the least-maintained key it names, and they were spread across five\n// services.\n\nimport { derive } from '../runtime.js';\n\n/**\n * Register every built-in key against the resources it is derived from.\n *\n * @param {import('../platform/context.js').ContextRegistry} registry\n * @param {object} r the resources these summarise\n * @returns {() => void} unregister them all\n */\nexport function registerCoreContext(registry, { workbench, overlay, navigation, explorer }) {\n const wb = workbench.observe();\n const nav = navigation.observe();\n const ov = overlay.observe();\n const ex = explorer.observe();\n\n const keys = {\n // Which screen is showing. Seeded as 'home' because that is where the app starts, and a\n // `when: view.active == 'home'` binding — the Delete shortcut among them — was dead from\n // boot until the first click on the rail when nothing had written the key yet.\n 'view.active': derive([wb], (s) => s.activity),\n 'sidebar.visible': derive([wb], (s) => s.sidebarVisible),\n 'searchModal.open': derive([wb], (s) => !!s.searchModal),\n 'sheet.open': derive([wb], (s) => s.sheet || ''),\n 'infoPanel.open': derive([wb], (s) => !!s.infoPanel),\n\n 'palette.open': derive([ov], (s) => !!s.palette),\n\n // What is open in the viewer, for openers and viewer-scoped shortcuts.\n 'editor.open': derive([nav], (s) => !!s.activeFile),\n 'editor.openerId': derive([nav], (s) => s.stack?.at(-1)?.openerId || ''),\n 'editor.contentType': derive([nav], (s) => s.activeFile?.contentType || ''),\n\n // `null` when no collection is open, never the string 'default'. A when-clause reading\n // this is asking WHICH collection is open, and answering with the name of one that may\n // not exist made every such clause true before the user had chosen anything.\n 'explorer.collectionId': derive([ex], (s) => s.collectionId ?? null),\n 'explorer.hasSelection': derive([ex], (s) => (s.selection?.length || 0) > 0),\n };\n\n const offs = Object.entries(keys).map(([key, source]) => registry.register(key, source));\n return () => offs.forEach((off) => off());\n}\n\n/**\n * The viewport's keys, registered separately because the viewport is measured rather than\n * derived from a resource — it comes from the window, and the service already holds a cell\n * of what it measured.\n */\nexport function registerViewportContext(registry, viewport) {\n const vp = viewport.observe();\n const offs = [\n registry.register('viewport.mode', derive([vp], (s) => s.mode)),\n registry.register('viewport.phone', derive([vp], (s) => s.mode === 'phone')),\n registry.register('viewport.tv', derive([vp], (s) => s.mode === 'tv')),\n ];\n return () => offs.forEach((off) => off());\n}\n",
69
+ "// NavigationService — the main panel STACK and its browser-history mirror. The base\n// of the stack is the launcher (search); opening a file pushes a viewer panel; back\n// pops. The stack is mirrored into window.history (pushState/popState) so the browser\n// back/forward buttons navigate it. Also owns the \"recent files\" list. Extracted from\n// WorkbenchService; the workbench coordinates the couplings it can't own (setting the\n// activity to 'home' and closing the modal search when a file opens).\n\nimport { cell } from '../runtime.js';\n\nconst RECENTS_KEY = 'trove.recents';\nconst RECENTS_MAX = 12;\n\nexport class NavigationService {\n #state;\n\n constructor() {\n this.#state = {\n stack: [{ kind: 'search' }], // [{kind:'search'}, {kind:'file', id, node, openerId}, …]\n activeTabId: null, // top file panel id (or null)\n activeFile: null, // top file panel node (or null)\n recents: loadRecents(),\n };\n this.cell = cell(this.#state);\n }\n\n /**\n * The value, for whoever is about to decide something from it.\n *\n * The same door every slice offers. Actions read `.state` and queries read `.cell`, and\n * the two are only equal by habit — bl/state.js says so, and says a resource has one\n * value and one way to read it. `state` is also a public field on a service, which is one\n * typo from `social.state.sidecar = null` bypassing the cell and notifying nothing.\n */\n get() {\n return this.#state;\n }\n\n observe() {\n return this.cell;\n }\n #set(patch) {\n this.#state = { ...this.#state, ...patch };\n this.cell.setValue(this.#state);\n }\n\n #top() {\n return this.#state.stack[this.#state.stack.length - 1];\n }\n /** The active file panel (top of the stack, if it's a file). */\n activeTab() {\n const t = this.#top();\n return t?.kind === 'file' ? t : null; // panel kind, not node kind\n }\n\n #applyStack(stack, { history = true } = {}) {\n const top = stack[stack.length - 1];\n const file = top && top.kind === 'file' ? top : null;\n this.#set({ stack, activeTabId: file ? file.id : null, activeFile: file ? file.node : null });\n if (history) this.#pushHistory();\n }\n\n /** Reset to the base launcher (used by showHome). */\n reset() {\n this.#applyStack([{ kind: 'search' }]);\n }\n\n /**\n * Open a file into the viewer stack. `reset` (used by the modal search) starts a\n * fresh stack (base search + this file). Opening a file already in the stack\n * jumps back to it; otherwise it's pushed on top.\n */\n openFile(node, openerId, { reset = false } = {}) {\n const panel = { kind: 'file', id: node.id, node, openerId };\n let stack;\n if (reset) {\n stack = [{ kind: 'search' }, panel];\n } else {\n const at = this.#state.stack.findIndex((p) => p.kind === 'file' && p.id === node.id);\n if (at >= 0) {\n // Already open — jump back to it, but adopt the (possibly new) opener so\n // reopening with a different one actually switches the viewer.\n stack = this.#state.stack.slice(0, at + 1);\n stack[at] = panel;\n } else {\n stack = [...this.#state.stack, panel];\n }\n }\n this.#pushRecent(node);\n this.#applyStack(stack);\n }\n back() {\n if (this.#state.stack.length <= 1) return;\n try { history.back(); } catch { this.pop(); }\n }\n pop() {\n if (this.#state.stack.length > 1) this.#applyStack(this.#state.stack.slice(0, -1), { history: false });\n }\n /**\n * The node is GONE — drop it from everywhere this service holds a copy.\n *\n * Named for what happened rather than for the stack, because it was `closeTab` and so\n * only closed the panel: a deleted file kept its recent tile, and clicking that tile\n * opened nothing. Recents are a snapshot, not a reference, so nothing else was ever\n * going to notice.\n *\n * Trashing is reversible and this is not, quite: restoring a file does not put it back\n * in recents, it just stops being listed until opened again. That is the right way\n * round — a tile that leads nowhere is worse than one that is missing.\n */\n forget(id) {\n const recents = this.#state.recents.filter((r) => r.id !== id);\n if (recents.length !== this.#state.recents.length) {\n this.#set({ recents });\n saveRecents(recents);\n }\n const stack = this.#state.stack.filter((p) => !(p.kind === 'file' && p.id === id));\n this.#applyStack(stack.length ? stack : [{ kind: 'search' }], { history: false });\n }\n /**\n * A node changed underneath us — a rename — so every copy of it here has to change.\n *\n * BOTH the stack and the recents list, because recents hold a SNAPSHOT (id, name,\n * contentType) rather than a reference: updating only the stack renamed the open panel's\n * title and left the recent tile showing the old name until it aged off the end of the\n * list, which reads as the rename half-failing.\n */\n updateTabNode(node) {\n const recents = this.#state.recents.map((r) => (r.id === node.id\n ? { ...r, name: node.name, contentType: node.contentType || r.contentType }\n : r));\n if (recents.some((r, i) => r !== this.#state.recents[i])) {\n this.#set({ recents });\n saveRecents(recents);\n }\n const stack = this.#state.stack.map((p) => (p.kind === 'file' && p.id === node.id ? { ...p, node } : p));\n this.#applyStack(stack, { history: false });\n }\n\n // --- history sync ----------------------------------------------------------\n #pushHistory(replace = false) {\n const top = this.#top();\n const n = top?.node;\n const entry = {\n troveDepth: this.#state.stack.length,\n node: n ? { id: n.id, name: n.name, contentType: n.contentType, collectionId: n.collectionId } : null,\n openerId: top?.openerId || null,\n };\n try { (replace ? history.replaceState : history.pushState).call(history, entry, ''); } catch { /* no history API */ }\n }\n /** Handle a browser back/forward: sync the stack depth (re-open on forward). */\n onPopState(e) {\n const s = e?.state || {};\n const depth = s.troveDepth || 1;\n if (depth <= this.#state.stack.length) {\n this.#applyStack(this.#state.stack.slice(0, depth), { history: false });\n } else if (s.node) {\n this.#applyStack([...this.#state.stack, { kind: 'file', id: s.node.id, node: s.node, openerId: s.openerId }], { history: false });\n }\n }\n\n #pushRecent(node) {\n if (!node) return;\n const entry = { id: node.id, name: node.name, contentType: node.contentType || '', collectionId: node.collectionId };\n const recents = [entry, ...this.#state.recents.filter((r) => r.id !== node.id)].slice(0, RECENTS_MAX);\n this.#set({ recents });\n saveRecents(recents);\n }\n}\n\nfunction loadRecents() {\n try { return JSON.parse(localStorage.getItem(RECENTS_KEY)) || []; } catch { return []; }\n}\nfunction saveRecents(recents) {\n try { localStorage.setItem(RECENTS_KEY, JSON.stringify(recents)); } catch { /* private mode / no storage */ }\n}\n",
70
+ "// SocialService — the client side of identity, conversations, tags, and mention\n// notifications. Reactive (the workbench `watch`es it): it holds the current\n// principal, the notification inbox (polled + refreshed on demand), and the\n// active file's sidecar (tags + threaded comments). It also owns the web-push\n// subscription flow (register the service worker, subscribe with the server's\n// VAPID key). All mutations optimistically reload the affected sidecar.\n\nimport { cell } from '../runtime.js';\n\nexport class SocialService {\n #state;\n\n constructor(platform, offline = null) {\n // How a comment or tag written while disconnected reaches the server later.\n this.offline = offline;\n this.platform = platform;\n this.api = platform.api;\n this.#state = {\n me: null,\n notifications: { items: [], unread: 0 },\n inboxOpen: false,\n pushSupported: 'serviceWorker' in navigator && 'PushManager' in window,\n pushEnabled: false,\n sidecar: null, // { nodeId, tags, comments, subscribers, loading, error }\n backlinks: null, // { nodeId, items, loading, error } — what links to the open item\n posting: false,\n replyTo: null, // { id, author } when composing a reply\n };\n this.cell = cell(this.#state);\n this._pollTimer = null;\n }\n\n /**\n * The value, for whoever is about to decide something from it.\n *\n * The same door every slice offers. Actions read `.state` and queries read `.cell`, and\n * the two are only equal by habit — bl/state.js says so, and says a resource has one\n * value and one way to read it. `state` is also a public field on a service, which is one\n * typo from `social.state.sidecar = null` bypassing the cell and notifying nothing.\n */\n get() {\n return this.#state;\n }\n\n observe() {\n return this.cell;\n }\n #set(patch) {\n this.#state = { ...this.#state, ...patch };\n this.cell.setValue(this.#state);\n }\n\n async init() {\n try {\n const me = await this.api.me();\n this.#set({ me: me.principal, admin: !!me.admin });\n } catch { /* anonymous / offline */ }\n await this.refreshNotifications();\n // Light polling; the service worker also nudges on push.\n this._pollTimer = setInterval(() => this.refreshNotifications(), 45_000);\n if (this._pollTimer.unref) this._pollTimer.unref();\n this.#detectPush();\n window.addEventListener('focus', () => this.refreshNotifications());\n navigator.serviceWorker?.addEventListener?.('message', (e) => {\n if (e.data?.type === 'trove-push') this.refreshNotifications();\n });\n }\n\n async refreshNotifications() {\n try {\n const n = await this.api.notifications();\n this.#set({ notifications: n });\n } catch { /* not enabled / offline */ }\n }\n\n toggleInbox(open) {\n const next = open ?? !this.#state.inboxOpen;\n this.#set({ inboxOpen: next });\n if (next && this.#state.notifications.unread) this.markAllRead();\n }\n async markAllRead() {\n try {\n await this.api.markNotificationsRead();\n this.#set({ notifications: { ...this.#state.notifications, unread: 0, items: this.#state.notifications.items.map((i) => ({ ...i, read: true })) } });\n } catch { /* ignore */ }\n }\n\n // --- sidecar (per active file) ---------------------------------------------\n\n async loadSidecar(nodeId) {\n if (!nodeId) return this.#set({ sidecar: null, backlinks: null });\n this.#set({ sidecar: { nodeId, loading: true, tags: [], comments: [], subscribers: [] } });\n this.loadBacklinks(nodeId);\n try {\n const view = await this.api.sidecar(nodeId);\n // A slower request for a previously-open item must not land on this one — the\n // same guard loadBacklinks already had. Without it, opening A then quickly opening\n // B let A resolve last, so `state.sidecar.nodeId` became A while B was on screen\n // and comment()/addTag()/removeTag() all wrote to A.\n if (this.#state.sidecar?.nodeId !== nodeId) return;\n this.#set({ sidecar: { ...view, loading: false } });\n } catch (err) {\n if (this.#state.sidecar?.nodeId !== nodeId) return;\n this.#set({ sidecar: { nodeId, loading: false, error: err.message, tags: [], comments: [] } });\n }\n }\n\n /**\n * What links to this item. With no folders, this is how you find out where an item\n * \"lives\" — which documents gather it up — so a failure has to be visible rather\n * than rendering as \"nothing links here\", which would be a claim about the drive.\n */\n async loadBacklinks(nodeId) {\n if (!nodeId) return this.#set({ backlinks: null });\n this.#set({ backlinks: { nodeId, items: [], loading: true, error: null } });\n try {\n const res = await this.api.backlinks(nodeId);\n // A slower request for a previously-open item must not land on this one.\n if (this.#state.backlinks?.nodeId !== nodeId) return;\n this.#set({ backlinks: { nodeId, items: res.items || [], loading: false, error: null } });\n } catch (err) {\n if (this.#state.backlinks?.nodeId !== nodeId) return;\n this.#set({ backlinks: { nodeId, items: [], loading: false, error: err.message } });\n }\n }\n async #reload() {\n if (this.#state.sidecar?.nodeId) await this.loadSidecar(this.#state.sidecar.nodeId);\n }\n\n setReplyTo(target) {\n this.#set({ replyTo: target });\n }\n async comment(body) {\n const nodeId = this.#state.sidecar?.nodeId;\n if (!nodeId || !body.trim()) return;\n const parentId = this.#state.replyTo?.id || null;\n // Offline → queue the op; it replays (CRDT-merges) on reconnect.\n if (this.offline && !this.offline.get().online) {\n await this.offline.queueOp({ method: 'POST', path: `/api/items/${encodeURIComponent(nodeId)}/comments`, body: { body, parentId } });\n this.#set({ replyTo: null });\n this.platform.notifications.info('Offline — your comment will post when you reconnect.');\n return;\n }\n this.#set({ posting: true });\n try {\n await this.api.addComment(nodeId, { body, parentId });\n this.#set({ replyTo: null });\n await this.#reload();\n } catch (err) {\n this.platform.notifications.error(`Couldn't post comment: ${err.message}`);\n } finally {\n this.#set({ posting: false });\n }\n }\n async deleteComment(cid) {\n const nodeId = this.#state.sidecar?.nodeId;\n await this.api.deleteComment(nodeId, cid).catch((e) => this.platform.notifications.error(e.message));\n await this.#reload();\n }\n async react(cid, emoji) {\n const nodeId = this.#state.sidecar?.nodeId;\n const comment = findComment(this.#state.sidecar?.comments || [], cid);\n const on = !(comment?.reactions?.[emoji] || []).includes(this.#state.me?.id);\n try {\n await this.api.reactComment(nodeId, cid, emoji, on);\n } catch (err) {\n this.platform.notifications.error(`Couldn't react: ${err.message}`);\n }\n await this.#reload();\n }\n async addTag(name, value) {\n const nodeId = this.#state.sidecar?.nodeId;\n if (!name.trim()) return;\n if (this.offline && !this.offline.get().online) {\n await this.offline.queueOp({ method: 'POST', path: `/api/items/${encodeURIComponent(nodeId)}/tags`, body: { name: name.trim(), value } });\n this.platform.notifications.info('Offline — tag will sync when you reconnect.');\n return;\n }\n await this.api.setTag(nodeId, name.trim(), value).catch((e) => this.platform.notifications.error(e.message));\n await this.#reload();\n }\n async removeTag(name) {\n const nodeId = this.#state.sidecar?.nodeId;\n // Offline → queue like addTag so the removal isn't silently lost.\n if (this.offline && !this.offline.get().online) {\n await this.offline.queueOp({ method: 'DELETE', path: `/api/items/${encodeURIComponent(nodeId)}/tags/${encodeURIComponent(name)}` });\n this.platform.notifications.info('Offline — tag removal will sync when you reconnect.');\n return;\n }\n try {\n await this.api.removeTag(nodeId, name);\n } catch (err) {\n this.platform.notifications.error(`Couldn't remove tag: ${err.message}`);\n }\n await this.#reload();\n }\n\n // --- web push --------------------------------------------------------------\n\n async #detectPush() {\n if (!this.#state.pushSupported) return;\n try {\n const reg = await navigator.serviceWorker.getRegistration();\n const sub = await reg?.pushManager?.getSubscription();\n this.#set({ pushEnabled: !!sub });\n } catch { /* ignore */ }\n }\n\n async enablePush() {\n if (!this.#state.pushSupported) {\n this.platform.notifications.warn('Push notifications are not supported in this browser.');\n return;\n }\n try {\n const { publicKey } = await this.api.vapidKey();\n if (!publicKey) {\n this.platform.notifications.warn('This server has no VAPID key configured for web push.');\n return;\n }\n const reg = await navigator.serviceWorker.register('/sw.js');\n await navigator.serviceWorker.ready;\n const perm = await Notification.requestPermission();\n if (perm !== 'granted') return this.platform.notifications.info('Notifications permission was denied.');\n const sub = await reg.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: urlBase64ToUint8Array(publicKey) });\n await this.api.subscribePush(sub.toJSON());\n this.#set({ pushEnabled: true });\n this.platform.notifications.success('Notifications enabled — you’ll be pinged when someone @mentions you.');\n } catch (err) {\n this.platform.notifications.error(`Couldn't enable notifications: ${err.message}`);\n }\n }\n}\n\nfunction findComment(list, cid) {\n for (const c of list) {\n if (c.id === cid) return c;\n const inner = findComment(c.replies || [], cid);\n if (inner) return inner;\n }\n return null;\n}\n\nfunction urlBase64ToUint8Array(base64) {\n const padding = '='.repeat((4 - (base64.length % 4)) % 4);\n const b64 = (base64 + padding).replace(/-/g, '+').replace(/_/g, '/');\n const raw = atob(b64);\n const out = new Uint8Array(raw.length);\n for (let i = 0; i < raw.length; i++) out[i] = raw.charCodeAt(i);\n return out;\n}\n",
71
+ "// EmbeddingProvider — turns text into vectors. Pluggable so deployments choose\n// their model/cost tradeoff. Two are bundled:\n// - LocalHashEmbedding: zero-dependency, offline, deterministic. A hashed\n// bag-of-bigrams projected to a fixed dim and L2-normalised. Not as good as\n// a real model, but makes semantic search work out of the box and in tests.\n// - HttpEmbedding: POSTs to any OpenAI-compatible /embeddings endpoint (OpenAI,\n// Ollama, LM Studio, a self-hosted model). This is the production path.\n// Both expose `dimensions` and `embed(texts) -> number[][]`.\n\nimport { withRetry } from '../retry.js';\nimport { TroveError, wrapError } from '../errors.js';\n\nexport class EmbeddingProvider {\n get dimensions() {\n return 0;\n }\n /** @param {string[]} texts @returns {Promise<number[][]>} */\n async embed(texts) {\n throw TroveError.unsupported('embed not implemented');\n }\n async embedOne(text) {\n return (await this.embed([text]))[0];\n }\n}\n\nconst STOP = new Set('a an the of to in on for and or is are be as at by with from this that it'.split(' '));\n\nfunction tokenize(text) {\n return String(text)\n .toLowerCase()\n .replace(/[^a-z0-9\\s]/g, ' ')\n .split(/\\s+/)\n .filter((t) => t.length > 1 && !STOP.has(t));\n}\n\n// FNV-1a → 32-bit, used to bucket features into vector dims.\nfunction fnv(str) {\n let h = 2166136261;\n for (let i = 0; i < str.length; i++) {\n h ^= str.charCodeAt(i);\n h = Math.imul(h, 16777619);\n }\n return h >>> 0;\n}\n\nexport class LocalHashEmbedding extends EmbeddingProvider {\n constructor({ dimensions = 256 } = {}) {\n super();\n this._dim = dimensions;\n }\n get dimensions() {\n return this._dim;\n }\n async embed(texts) {\n return texts.map((t) => this.#vec(t));\n }\n #vec(text) {\n const v = new Float64Array(this._dim);\n const tokens = tokenize(text);\n // Unigrams + bigrams give a little word-order sensitivity.\n const feats = [...tokens];\n for (let i = 0; i < tokens.length - 1; i++) feats.push(tokens[i] + '_' + tokens[i + 1]);\n for (const f of feats) {\n const h = fnv(f);\n const idx = h % this._dim;\n const sign = (h >> 31) & 1 ? -1 : 1; // signed hashing reduces collisions\n v[idx] += sign;\n }\n // L2 normalise so dot product == cosine similarity.\n let norm = 0;\n for (let i = 0; i < v.length; i++) norm += v[i] * v[i];\n norm = Math.sqrt(norm) || 1;\n return Array.from(v, (x) => x / norm);\n }\n}\n\nexport class HttpEmbedding extends EmbeddingProvider {\n /**\n * @param {object} cfg\n * @param {string} cfg.url e.g. https://api.openai.com/v1/embeddings\n * @param {string} [cfg.apiKey]\n * @param {string} [cfg.model] e.g. text-embedding-3-small\n * @param {number} cfg.dimensions the model's output dim (must match your index)\n * @param {number} [cfg.batchSize]\n */\n constructor(cfg) {\n super();\n if (!cfg?.url || !cfg?.dimensions) throw TroveError.invalid('HttpEmbedding requires url and dimensions');\n this.cfg = cfg;\n }\n get dimensions() {\n return this.cfg.dimensions;\n }\n async embed(texts) {\n const batchSize = this.cfg.batchSize ?? 64;\n const out = [];\n for (let i = 0; i < texts.length; i += batchSize) {\n const batch = texts.slice(i, i + batchSize);\n out.push(...(await this.#embedBatch(batch)));\n }\n return out;\n }\n async #embedBatch(batch) {\n return withRetry(async () => {\n let res;\n try {\n res = await fetch(this.cfg.url, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n ...(this.cfg.apiKey ? { authorization: `Bearer ${this.cfg.apiKey}` } : {}),\n },\n body: JSON.stringify({ model: this.cfg.model, input: batch }),\n });\n } catch (err) {\n throw wrapError(err);\n }\n if (res.status === 429 || res.status >= 500) {\n throw TroveError.transient(`Embedding endpoint ${res.status}`);\n }\n if (!res.ok) throw TroveError.internal(`Embedding endpoint failed: ${res.status}`);\n const json = await res.json();\n // OpenAI shape: { data: [{ embedding: [...] }, ...] }\n const data = json.data ?? json.embeddings ?? [];\n return data.map((d) => d.embedding ?? d);\n });\n }\n}\n",
72
+ "// IndexerRegistry — server-side indexers that extract structured content from\n// files. An indexer declares which nodes it handles and, for each, produces a\n// *contribution* with up to three scopes:\n// - semanticTexts: text chunks that become embeddings + keyword entries (search)\n// - tags: filterable key/values (merged into the node's queryable tags)\n// - metadata: arbitrary structured data (e.g. an audiobook's chapter index)\n// Everything is namespaced under the indexer's `id`, so indexers never clobber one\n// another and an indexer's whole contribution can be removed independently.\n//\n// This complements *plugin* indexers, which run in the browser sandbox and push\n// the same contribution shape through the API under their own namespace.\n//\n// Two built-ins ship here: a text/markdown extractor (the reference indexer) and a\n// links extractor, which is what makes a drive with no folders navigable.\n\nimport { extname } from '../util.js';\nimport { extractTroveLinks } from '../links.js';\nimport { LINKS_CONTRIBUTOR, LINKS_KEY } from '../metadata/interface.js';\n\n/**\n * @typedef {object} Indexer\n * @property {string} id unique namespace\n * @property {string} [displayName]\n * @property {(node: object) => boolean} match\n * @property {(node: object, ctx: IndexContext) => Promise<Contribution>} index\n *\n * @typedef {object} Contribution\n * @property {Doc[]} [semanticTexts] text chunks → embeddings + keyword search\n * @property {object} [tags] filterable key/values, e.g. { language: 'en' }\n * @property {object} [metadata] arbitrary structured data, e.g. { chapters: [...] }\n *\n * @typedef {object} Doc\n * @property {string} [id] stable per (node, chunk); defaults to `${node.id}:${i}`\n * @property {string} text\n * @property {object} [fields] e.g. { title, page, chapter }\n *\n * @typedef {object} IndexContext\n * @property {() => Promise<Uint8Array>} readBytes\n * @property {() => Promise<string>} readText\n * @property {number} maxBytes\n */\n\nexport class IndexerRegistry {\n /** @param {{builtins?: boolean}} [opts] register the reference text indexer (default on) */\n constructor({ builtins = true } = {}) {\n this.indexers = new Map();\n if (builtins) {\n this.register(textIndexer);\n this.register(linksIndexer);\n }\n }\n register(indexer) {\n if (!indexer?.id || typeof indexer.index !== 'function') {\n throw new Error('Indexer requires an id and an index() function');\n }\n this.indexers.set(indexer.id, indexer);\n // Only unregister if THIS registration is still the live one. Indexer ids are\n // contribution URIs, which are account-independent, so a second account installing\n // the same package replaces the first's entry — and the first's stale closure then\n // deleted the second's, taking that account's indexer out of the drive-wide registry\n // and purging its contributions.\n return () => { if (this.indexers.get(indexer.id) === indexer) this.indexers.delete(indexer.id); };\n }\n unregister(id) {\n this.indexers.delete(id);\n }\n list() {\n return [...this.indexers.values()].map((i) => ({ id: i.id, displayName: i.displayName || i.id }));\n }\n matching(node) {\n return [...this.indexers.values()].filter((i) => {\n try {\n return i.match(node);\n } catch {\n return false;\n }\n });\n }\n}\n\n// --- Reference indexer: plain text / markdown / code ------------------------\n\nconst TEXT_EXTS = new Set([\n '.txt', '.md', '.markdown', '.rst', '.log', '.csv', '.tsv',\n '.json', '.yaml', '.yml', '.toml', '.ini', '.env',\n '.js', '.mjs', '.ts', '.jsx', '.tsx', '.py', '.rb', '.go', '.rs', '.java',\n '.c', '.h', '.cpp', '.css', '.html', '.xml', '.sh',\n]);\n\nfunction isTexty(node) {\n if (node.contentType?.startsWith('text/')) return true;\n return TEXT_EXTS.has(extname(node.name));\n}\n\nexport const textIndexer = {\n id: 'core.text',\n displayName: 'Text & code',\n match: isTexty,\n async index(node, ctx) {\n const text = await ctx.readText();\n if (!text.trim()) return { semanticTexts: [] };\n const chunks = chunkText(text, 1200, 200);\n // Fields describe the CHUNK (which chunk it is), not the node. The node's name\n // deliberately isn't copied in: field values are indexed, so a name duplicated\n // across every chunk goes stale the moment the item is renamed — leaving the file\n // findable under a name it no longer has. Name search belongs to the `core.name`\n // index, which is a single document and is refreshed on rename.\n const semanticTexts = chunks.map((chunk, i) => ({\n id: `${node.id}:${i}`,\n text: chunk,\n fields: { chunk: i },\n }));\n return {\n semanticTexts,\n metadata: { chars: text.length, chunks: chunks.length, excerpt: text.slice(0, 280) },\n };\n },\n};\n\n// --- Links indexer: what this item points at --------------------------------\n//\n// With no folder hierarchy, an item's place in the drive is defined by what links to\n// it. This indexer records the outbound `trove:` URIs found in an item's text, which\n// is what MetadataStore.findLinksTo reads to answer the inverse question — \"what\n// gathers this up?\" — for the backlinks panel.\n//\n// It stores the links as `metadata`, not `semanticTexts`: a URI is an edge, not prose,\n// and embedding it would only pollute semantic results. `links` is also surfaced as a\n// tag count so `#links > 0` finds the documents that act as indexes.\n\nexport const linksIndexer = {\n id: LINKS_CONTRIBUTOR,\n displayName: 'Links',\n match: isTexty,\n async index(node, ctx) {\n const text = await ctx.readText();\n const links = extractTroveLinks(text).map((l) => l.uri);\n return {\n metadata: { [LINKS_KEY]: links },\n tags: { links: links.length },\n };\n },\n};\n\n/** Split into overlapping windows on sentence/line boundaries where possible. */\nexport function chunkText(text, size, overlap) {\n const out = [];\n let i = 0;\n while (i < text.length) {\n let end = Math.min(i + size, text.length);\n if (end < text.length) {\n // Prefer to break at a paragraph/sentence boundary within the last 25%.\n const window = text.slice(i, end);\n const brk = Math.max(window.lastIndexOf('\\n\\n'), window.lastIndexOf('. '), window.lastIndexOf('\\n'));\n if (brk > size * 0.75) end = i + brk + 1;\n }\n out.push(text.slice(i, end).trim());\n if (end >= text.length) break;\n i = end - overlap;\n }\n return out.filter(Boolean);\n}\n",
73
+ "// KeywordStore — the pluggable lexical (sparse) half of hybrid search, mirroring\n// VectorStore's async, injectable shape. The in-memory default keeps a token set\n// per document and scores by query-term coverage; swap in an implementation over\n// SQLite FTS5, Postgres tsvector, Elasticsearch, etc. for durability/scale.\n// SearchService composes a VectorStore + a KeywordStore, so a deployment can mix\n// (e.g. Qdrant for vectors, Postgres FTS for keywords) — core hardcodes neither.\n\nimport { TroveError } from '../errors.js';\n\nconst STOP = new Set('a an the of to in on for and or is are be as at by with from this that it'.split(' '));\n\nexport function tokenize(text) {\n return String(text)\n .toLowerCase()\n .replace(/[^a-z0-9\\s]/g, ' ')\n .split(/\\s+/)\n .filter((t) => t.length > 1 && !STOP.has(t));\n}\n\nexport class KeywordStore {\n async add(docs) {\n throw TroveError.unsupported('add not implemented');\n }\n async removeByNode(nodeId) {\n throw TroveError.unsupported('removeByNode not implemented');\n }\n async removeByIndexer(indexerId) {\n throw TroveError.unsupported('removeByIndexer not implemented');\n }\n async removeByNodeIndexer(nodeId, indexerId) {\n throw TroveError.unsupported('removeByNodeIndexer not implemented');\n }\n /** @returns {Promise<Array<{docId,nodeId,indexerId,score,fields}>>} */\n async search(query, opts) {\n throw TroveError.unsupported('search not implemented');\n }\n /** Optional: a highlighted excerpt for a doc (null if unavailable). */\n async snippet(docId, query) {\n return null;\n }\n /** Optional: number of stored documents. Null when the store can't say — which is\n * not the same as zero, and the startup rebuild check depends on the difference. */\n async count() {\n return null;\n }\n}\n\nexport class MemoryKeywordStore extends KeywordStore {\n constructor() {\n super();\n this.docs = new Map(); // docId -> { nodeId, indexerId, text, tokens:Set, fields }\n }\n\n async add(docs) {\n for (const d of docs) {\n const text = d.text || '';\n this.docs.set(d.id, {\n nodeId: d.nodeId, indexerId: d.indexerId, text,\n tokens: new Set(tokenize(text + ' ' + Object.values(d.fields || {}).join(' '))),\n fields: d.fields || {},\n });\n }\n }\n async removeByNode(nodeId) {\n for (const [id, r] of this.docs) if (r.nodeId === nodeId) this.docs.delete(id);\n }\n async removeByIndexer(indexerId) {\n for (const [id, r] of this.docs) if (r.indexerId === indexerId) this.docs.delete(id);\n }\n async removeByNodeIndexer(nodeId, indexerId) {\n for (const [id, r] of this.docs) if (r.nodeId === nodeId && r.indexerId === indexerId) this.docs.delete(id);\n }\n\n async search(query, opts = {}) {\n const q = tokenize(query);\n if (!q.length) return [];\n const allow = opts.indexers ? new Set(opts.indexers) : null;\n const out = [];\n for (const [docId, r] of this.docs) {\n if (allow && !allow.has(r.indexerId)) continue;\n let hit = 0;\n for (const t of q) if (r.tokens.has(t)) hit++;\n if (hit > 0) out.push({ docId, nodeId: r.nodeId, indexerId: r.indexerId, score: hit / q.length, fields: r.fields });\n }\n out.sort((a, b) => b.score - a.score);\n return out.slice(0, opts.limit ?? 40);\n }\n\n async snippet(docId, query) {\n const r = this.docs.get(docId);\n if (!r?.text) return null;\n const q = tokenize(query);\n const lower = r.text.toLowerCase();\n let at = -1;\n for (const t of q) {\n const i = lower.indexOf(t);\n if (i >= 0) { at = i; break; }\n }\n if (at < 0) return r.text.slice(0, 160).trim();\n const start = Math.max(0, at - 60);\n return (start > 0 ? '…' : '') + r.text.slice(start, start + 200).trim() + '…';\n }\n\n async count() {\n return this.docs.size;\n }\n}\n",
74
+ "// OfflineService — a limited but real offline mode.\n// • Pin (\"make available offline\"): file bytes go into the SW's trove-files\n// cache (so every opener reads them with no network), and — for text — the\n// content is chunked, embedded with the same LocalHash model the server can\n// use, and stored in IndexedDB for offline search.\n// • Offline search: lexical (names/tags/content) blended with local\n// semantic (cosine over the cached chunk vectors) — the same hybrid shape as\n// the server, just over what you took offline.\n// • Sidecar op queue: while offline, comment/tag mutations are queued and\n// replayed on reconnect. Because the sidecar is a CRDT, replay merges cleanly\n// with whatever changed server-side meanwhile.\n// Reactive: the workbench watches `online`, the pinned set, and the queue depth.\n\nimport { cell } from '../runtime.js';\nimport { LocalHashEmbedding } from '@3sln/trove/core/search/embeddings.js';\n// Chunking and tokenizing must MATCH the server's — offline results are compared\n// against embeddings the server produced, so a local variant would quietly skew them.\nimport { chunkText } from '@3sln/trove/core/indexers/registry.js';\nimport { tokenize } from '@3sln/trove/core/search/keywordStore.js';\nimport { isTexty } from './fileType.js';\n\nconst DB = 'trove-offline';\nconst FILES_CACHE = 'trove-files-v1';\nconst embed = new LocalHashEmbedding({ dimensions: 256 });\n\nexport class OfflineService {\n #state;\n\n constructor(platform) {\n this.platform = platform;\n this.api = platform.api;\n this.db = null;\n this.#state = { online: navigator.onLine, pins: [], queued: 0, syncing: false };\n this.cell = cell(this.#state);\n }\n /**\n * The value, for whoever is about to decide something from it.\n *\n * The same door every slice offers. Actions read `.state` and queries read `.cell`, and\n * the two are only equal by habit — bl/state.js says so, and says a resource has one\n * value and one way to read it. `state` is also a public field on a service, which is one\n * typo from `social.state.sidecar = null` bypassing the cell and notifying nothing.\n */\n get() {\n return this.#state;\n }\n\n observe() {\n return this.cell;\n }\n #set(patch) {\n this.#state = { ...this.#state, ...patch };\n this.cell.setValue(this.#state);\n }\n\n async init() {\n this.db = await openDb();\n await this.#refreshPins();\n await this.#refreshQueue();\n window.addEventListener('online', () => this.#onOnline());\n window.addEventListener('offline', () => this.#onOffline());\n // `navigator.onLine` only reflects that an interface is up — on a captive portal or\n // dead uplink it's `true` while the server is unreachable, which would leave us\n // falsely \"online\" with every request silently failing. Confirm real reachability.\n if (this.#state.online && !(await this.api.reachable())) this.#set({ online: false });\n // Tell the plugin host our initial connectivity so it can probe plugins.\n this.platform.plugins?.setOnline?.(this.#state.online);\n if (this.#state.online) this.flushQueue();\n }\n\n async #onOnline() {\n // The interface came up, but verify the server is actually reachable before\n // declaring online — a captive portal fires 'online' with no real connectivity.\n if (!(await this.api.reachable())) { this.#set({ online: false }); await this.platform.plugins?.setOnline?.(false); return; }\n this.#set({ online: true });\n // Plugins re-announce what works now that we're back online.\n await this.platform.plugins?.setOnline?.(true);\n await this.flushQueue();\n }\n async #onOffline() {\n this.#set({ online: false });\n // Plugins re-announce; network-only features become unavailable.\n await this.platform.plugins?.setOnline?.(false);\n }\n\n // --- pinning ---------------------------------------------------------------\n\n async pin(node) {\n if (!node?.id) return;\n try {\n // Two URLs, deliberately. The KEY is the plain route URL — stable, so `unpin` and\n // the service worker's cache-first lookup both find what `pin` stored. The FETCH\n // may need a minted one, because `cache.add` sends no Authorization header and\n // would 401 on a token-authenticated deployment. Keying on the minted URL instead\n // would have worked exactly once: it carries a signature, so the next session's\n // `unpin` looks for a string that was never there and the bytes are never reclaimed.\n if ('caches' in window) {\n const cache = await caches.open(FILES_CACHE);\n const urls = this.platform.mediaUrls;\n const key = urls.cacheKey(node.id);\n const { url } = await urls.url(node.id, { op: 'download' });\n const res = await fetch(url);\n if (!res.ok) throw new Error(`Couldn't fetch the file (${res.status})`);\n await cache.put(new Request(key), res);\n }\n // Index text content for offline search.\n let chunks = [];\n let text = '';\n if (isTexty(node)) {\n try {\n text = await this.api.readText(node.id);\n const parts = chunkText(text, 1000, 150);\n const vectors = await embed.embed(parts.length ? parts : [node.name]);\n chunks = (parts.length ? parts : [node.name]).map((t, i) => ({ text: t, vector: vectors[i] }));\n } catch { /* keep name-only */ }\n }\n const nameVec = (await embed.embed([node.name]))[0];\n await idbPut(this.db, 'pins', node.id, { node, text, chunks, nameVec, pinnedAt: Date.now() });\n await this.#refreshPins();\n this.platform.notifications.success(`“${node.name}” is available offline`);\n } catch (err) {\n this.platform.notifications.error(`Couldn't make available offline: ${err.message}`);\n }\n }\n\n async unpin(id) {\n const pin = this.#state.pins.find((p) => p.id === id);\n if (pin && 'caches' in window) {\n const cache = await caches.open(FILES_CACHE);\n // The same stable key `pin` stored under — never a freshly minted URL.\n await cache.delete(this.platform.mediaUrls.cacheKey(id), { ignoreVary: true }).catch(() => {});\n }\n await idbDelete(this.db, 'pins', id);\n await this.#refreshPins();\n }\n\n async #refreshPins() {\n const all = await idbAll(this.db, 'pins');\n this.#set({ pins: all.map((r) => ({ id: r.node.id, name: r.node.name, contentType: r.node.contentType, collectionId: r.node.collectionId, pinnedAt: r.pinnedAt })) });\n }\n\n // --- offline search --------------------------------------------------------\n\n async searchOffline(query, { limit = 40 } = {}) {\n const rows = await idbAll(this.db, 'pins');\n if (!rows.length) return [];\n const qTokens = tokenize(query);\n const qv = (await embed.embed([query]))[0];\n const results = [];\n for (const r of rows) {\n const hay = tokenize(`${r.node.name} ${r.text || ''}`);\n const lex = lexicalScore(qTokens, new Set(hay));\n let dense = cosine(qv, r.nameVec);\n for (const c of r.chunks || []) dense = Math.max(dense, cosine(qv, c.vector));\n const score = 0.6 * dense + 0.4 * lex;\n if (score > 0.02) results.push({ nodeId: r.node.id, node: r.node, score, snippet: snippet(r.text, qTokens), indexerId: 'offline' });\n }\n return results.sort((a, b) => b.score - a.score).slice(0, limit);\n }\n\n // --- offline sidecar op queue ---------------------------------------------\n\n async queueOp(op) {\n await idbAdd(this.db, 'queue', { ...op, at: Date.now() });\n await this.#refreshQueue();\n }\n\n async #refreshQueue() {\n const q = await idbAll(this.db, 'queue');\n this.#set({ queued: q.length });\n }\n\n async flushQueue() {\n if (!this.#state.online || this.#state.syncing) return;\n // Claim the sync BEFORE any await — two 'online' events (or init + an event) can\n // fire concurrently, and a check-then-act guard after an await let both pass and\n // replay the queue twice (double-posting). Setting syncing synchronously here makes\n // the second caller bail at the guard above.\n this.#set({ syncing: true });\n let synced = 0;\n let dropped = 0;\n try {\n const q = await idbAllWithKeys(this.db, 'queue');\n for (const { key, value } of q) {\n try {\n await this.api.request(value.method, value.path, { body: value.body });\n await idbDelete(this.db, 'queue', key);\n synced++;\n } catch (err) {\n // Anything that could succeed later stays queued. `unauthorized` is the case\n // that mattered: a session expiring while offline is not a permanent failure,\n // and dropping the entry destroyed a comment the user had written and told\n // them it \"couldn't be applied\" — when signing in again would have applied it.\n if (['transient', 'timeout', 'unauthorized', 'quota'].includes(err.code)) break;\n // A permanent failure (e.g. the file was deleted) — drop it so we don't loop,\n // but don't pretend it synced.\n await idbDelete(this.db, 'queue', key);\n dropped++;\n }\n }\n } finally {\n await this.#refreshQueue();\n this.#set({ syncing: false });\n // Be honest: only claim success for what actually applied, and surface drops.\n if (dropped) this.platform.notifications.warn(`${dropped} offline change${dropped > 1 ? 's' : ''} couldn't be applied and ${dropped > 1 ? 'were' : 'was'} discarded.`);\n if (synced && this.#state.queued === 0) this.platform.notifications.info(`${synced} offline change${synced > 1 ? 's' : ''} synced.`);\n }\n }\n}\n\n// --- IndexedDB helpers ------------------------------------------------------\n\nfunction openDb() {\n return new Promise((resolve, reject) => {\n const req = indexedDB.open(DB, 1);\n req.onupgradeneeded = () => {\n const db = req.result;\n if (!db.objectStoreNames.contains('pins')) db.createObjectStore('pins');\n if (!db.objectStoreNames.contains('queue')) db.createObjectStore('queue', { autoIncrement: true });\n };\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n });\n}\nfunction tx(db, store, mode, fn) {\n return new Promise((resolve, reject) => {\n const t = db.transaction(store, mode);\n const s = t.objectStore(store);\n let out;\n Promise.resolve(fn(s)).then((r) => (out = r));\n t.oncomplete = () => resolve(out);\n t.onerror = () => reject(t.error);\n });\n}\nconst reqP = (r) => new Promise((res, rej) => { r.onsuccess = () => res(r.result); r.onerror = () => rej(r.error); });\nconst idbPut = (db, store, key, val) => tx(db, store, 'readwrite', (s) => s.put(val, key));\nconst idbAdd = (db, store, val) => tx(db, store, 'readwrite', (s) => s.add(val));\nconst idbDelete = (db, store, key) => tx(db, store, 'readwrite', (s) => s.delete(key));\nconst idbAll = (db, store) => tx(db, store, 'readonly', (s) => reqP(s.getAll()));\nfunction idbAllWithKeys(db, store) {\n return tx(db, store, 'readonly', (s) =>\n new Promise((resolve, reject) => {\n const out = [];\n const req = s.openCursor();\n req.onsuccess = () => {\n const cur = req.result;\n if (!cur) return resolve(out);\n out.push({ key: cur.key, value: cur.value });\n cur.continue();\n };\n req.onerror = () => reject(req.error);\n }),\n );\n}\n\n// --- search math (mirrors the server's LocalHash hybrid) --------------------\n\nfunction lexicalScore(q, docTokens) {\n if (!q.length || !docTokens.size) return 0;\n let hit = 0;\n for (const t of q) if (docTokens.has(t)) hit++;\n return hit / q.length;\n}\nfunction cosine(a, b) {\n if (!a || !b) return 0;\n let s = 0;\n for (let i = 0; i < a.length; i++) s += a[i] * b[i];\n return s; // both L2-normalised\n}\nfunction snippet(text, qTokens) {\n if (!text) return null;\n const lower = text.toLowerCase();\n let at = -1;\n for (const t of qTokens) { const i = lower.indexOf(t); if (i >= 0) { at = i; break; } }\n if (at < 0) return text.slice(0, 160).trim();\n const start = Math.max(0, at - 60);\n return (start > 0 ? '…' : '') + text.slice(start, start + 200).trim() + '…';\n}\n",
75
+ "// ActivityService — the client's answer to \"what is going on, and what is stuck\".\n//\n// It holds two lists that look similar and mean different things, and keeping them\n// distinct is the whole design:\n//\n// TASKS work happening now. Ephemeral. A task disappears when it finishes (after a\n// moment on screen) and when the process running it stops. That is correct:\n// the work stopped too.\n// ISSUES a standing problem left behind by something that already failed. Durable on\n// the server. It stays until the thing it complains about actually works —\n// not until it is acknowledged, and not until a reload.\n//\n// WHY ONE SERVICE FOR BOTH SIDES. Work happens in two places — an upload runs in this\n// browser, a reindex runs on the server — and a user does not care which. So this holds\n// one list, with each task tagged by where it lives:\n//\n// local started here, driven here. The owner (TransfersService) reports progress\n// directly, and cancelling calls a function.\n// server a read-only MIRROR of the server's registry. Nothing here drives it;\n// cancelling posts, and the next poll shows the result. Treating a mirror as\n// writable is how two sources of truth get invented.\n//\n// WHY POLLING. There is no streaming transport in this server, and adding SSE through\n// three runtime adapters to move a progress bar is not a trade worth making yet. So:\n// poll fast (1s) only while something is running, drop to nothing when the drive is\n// idle, and re-check when the tab regains focus. At rest this costs one request when\n// the app loads. If a real-time channel ever exists, only `#poll` changes.\n\nimport { cell } from '../runtime.js';\n\nconst ACTIVE_MS = 1000; // while something is running, we want a live-feeling bar\nconst IDLE_MS = 60_000; // otherwise just enough to notice a task someone else started\n\nexport class ActivityService {\n #state;\n\n constructor(platform) {\n this.platform = platform;\n this.api = platform.api;\n this.#state = {\n tasks: [], // merged: local first, then the server mirror\n issues: [],\n issuesLoading: false,\n // A load failure is state, not a shrug: \"no problems\" and \"we couldn't ask\" look\n // identical on screen unless one of them says so. TWO fields, not one, because\n // these are independent requests — a tasks poll that succeeds must not erase the\n // news that the issues poll failed, which is exactly the bug one shared field\n // produced.\n tasksError: null,\n issuesError: null,\n };\n this.cell = cell(this.#state);\n this._local = new Map(); // id -> local task (this browser owns these)\n this._server = [];\n this._timer = null;\n this._pollMs = null;\n }\n\n /**\n * The value, for whoever is about to decide something from it.\n *\n * The same door every slice offers. Actions read `.state` and queries read `.cell`, and\n * the two are only equal by habit — bl/state.js says so, and says a resource has one\n * value and one way to read it. `state` is also a public field on a service, which is one\n * typo from `social.state.sidecar = null` bypassing the cell and notifying nothing.\n */\n get() {\n return this.#state;\n }\n\n observe() {\n return this.cell;\n }\n #set(patch) {\n this.#state = { ...this.#state, ...patch };\n this.cell.setValue(this.#state);\n }\n #merge() {\n this.#set({ tasks: [...this._local.values(), ...this._server] });\n }\n\n // --- local tasks -----------------------------------------------------------\n\n /**\n * Register work happening in this browser. Returns a handle with the same shape the\n * server's registry hands its callers, so code that reports progress doesn't need to\n * know which side it is running on.\n *\n * @param {{title: string, kind?: string, detail?: string, total?: number|null,\n * unit?: string, onCancel?: () => void}} spec\n */\n start(spec = {}) {\n const id = spec.id || `local_${Math.random().toString(36).slice(2, 10)}`;\n const task = {\n id,\n source: 'local',\n kind: spec.kind || 'general',\n title: spec.title || 'Working',\n detail: spec.detail ?? null,\n status: 'running',\n done: 0,\n // No total means indeterminate, and that is a legitimate answer. A caller that\n // doesn't know how much work there is must not invent a number: a progress bar\n // that lies is worse than a spinner that admits it doesn't know.\n total: spec.total ?? null,\n unit: spec.unit || null,\n cancellable: !!spec.onCancel,\n startedAt: Date.now(),\n endedAt: null,\n error: null,\n };\n this._local.set(id, task);\n this._cancels ||= new Map();\n if (spec.onCancel) this._cancels.set(id, spec.onCancel);\n this.#merge();\n this.#schedule();\n\n const patch = (p) => {\n const cur = this._local.get(id);\n if (!cur || cur.status !== 'running') return; // finished tasks are final\n this._local.set(id, { ...cur, ...p });\n this.#merge();\n };\n return {\n id,\n progress: (p = {}) => patch({\n done: p.done ?? this._local.get(id)?.done ?? 0,\n total: p.total === undefined ? this._local.get(id)?.total : p.total,\n unit: p.unit ?? this._local.get(id)?.unit,\n detail: p.detail ?? this._local.get(id)?.detail,\n }),\n succeed: (detail) => { patch({ status: 'done', endedAt: Date.now(), detail: detail ?? this._local.get(id)?.detail }); this.#expire(id); },\n fail: (err) => { patch({ status: 'failed', endedAt: Date.now(), error: err?.message || String(err || 'failed') }); },\n cancel: () => { patch({ status: 'cancelled', endedAt: Date.now() }); this.#expire(id); },\n };\n }\n\n /** A finished task lingers briefly so it is seen to finish, then goes. */\n #expire(id, after = 5000) {\n setTimeout(() => {\n this._local.delete(id);\n this._cancels?.delete(id);\n this.#merge();\n }, after);\n }\n\n async cancel(id) {\n const local = this._local.get(id);\n if (local) {\n this._cancels?.get(id)?.();\n return;\n }\n // A server task is a mirror: ask, then let the next poll tell the truth.\n try {\n await this.api.cancelTask(id);\n await this.refreshTasks();\n } catch (err) {\n this.#set({ tasksError: err.message });\n }\n }\n\n dismiss(id) {\n if (this._local.delete(id)) { this.#merge(); return; }\n this.api.dismissTask(id).catch(() => {});\n this._server = this._server.filter((t) => t.id !== id);\n this.#merge();\n }\n\n // --- server mirror + issues ------------------------------------------------\n\n async init() {\n await this.refresh();\n this.#schedule();\n // Coming back to the tab is the moment a stale list is most obvious.\n window.addEventListener('focus', () => this.refresh());\n }\n\n async refresh() {\n await Promise.all([this.refreshTasks(), this.refreshIssues()]);\n }\n\n async refreshTasks() {\n const wasRunning = this.running.length > 0;\n try {\n const { tasks } = await this.api.tasks();\n this._server = (tasks || []).map((t) => ({ ...t, source: 'server' }));\n this.#set({ tasksError: null });\n this.#merge();\n } catch (err) {\n // Offline or a server that doesn't have the endpoint: stop claiming to know.\n this._server = [];\n this.#set({ tasksError: err.message });\n this.#merge();\n }\n // The moment work STOPS is the moment an issue is most likely to have been fixed,\n // so re-read them then. Without this, a retry that succeeds in 50 ms leaves the\n // problem on screen until the next idle poll — up to a minute of the user being\n // told something is broken that isn't.\n if (wasRunning && !this.running.length) this.refreshIssues();\n this.#schedule();\n }\n\n async refreshIssues() {\n this.#set({ issuesLoading: true });\n try {\n const { issues } = await this.api.issues();\n this.#set({ issues: issues || [], issuesLoading: false, issuesError: null });\n } catch (err) {\n // Deliberately NOT clearing `issues`: the last known list is better than an empty\n // one that reads as \"nothing is wrong\".\n this.#set({ issuesLoading: false, issuesError: err.message });\n }\n }\n\n async retryIssue(id) {\n try {\n await this.api.retryIssue(id);\n // The fix runs as a task; adopt it now so the click visibly did something, and\n // let the poll clear the issue when the work actually succeeds. The retry may\n // finish faster than a poll interval, so re-read the issues directly too — a\n // Retry button that leaves the problem sitting there reads as a broken button.\n await this.refreshTasks();\n // A retry can finish faster than one poll interval — in which case there is no\n // running→idle transition to notice and the fixed problem would sit on screen\n // until the next idle poll. A couple of bounded follow-ups cover that window\n // without turning this into a busy loop.\n this.followUp();\n this.platform.notifications.info('Retrying — watch its progress in Activity');\n } catch (err) {\n this.platform.notifications.error(`Couldn't retry: ${err.message}`);\n }\n }\n\n async dismissIssue(id) {\n const before = this.#state.issues;\n this.#set({ issues: before.filter((i) => i.id !== id) });\n try {\n await this.api.dismissIssue(id);\n } catch (err) {\n this.#set({ issues: before }); // put it back rather than pretend\n this.platform.notifications.error(`Couldn't dismiss: ${err.message}`);\n }\n }\n\n /**\n * Two bounded re-reads after an action that may have resolved something.\n *\n * Public, because the action that started the work is the thing that knows it may have\n * resolved something — a small, real loss of encapsulation in exchange for the three\n * network verbs no longer living inside a resource.\n */\n followUp() {\n for (const ms of [400, 1500]) {\n const t = setTimeout(() => { this.refreshTasks(); this.refreshIssues(); }, ms);\n t?.unref?.();\n }\n }\n\n get running() {\n return this.#state.tasks.filter((t) => t.status === 'running');\n }\n\n /**\n * Poll fast while something is running, slowly otherwise. Rescheduled rather than\n * fixed, so an idle drive costs one request a minute and a running rebuild feels\n * live — without a second transport to maintain.\n */\n #schedule() {\n const want = this.running.length ? ACTIVE_MS : IDLE_MS;\n if (this._timer && this._pollMs === want) return;\n clearTimeout(this._timer);\n this._pollMs = want;\n this._timer = setTimeout(() => {\n this._timer = null;\n this.refreshTasks().then(() => {\n // Issues change when tasks end, so re-read them then rather than on their own\n // clock — a retry that fixed something should stop being listed promptly.\n if (!this.running.length) this.refreshIssues();\n });\n }, want);\n this._timer?.unref?.();\n }\n\n dispose() {\n clearTimeout(this._timer);\n this._timer = null;\n }\n}\n",
76
+ "// The workbench's built-in commands.\n//\n// A command is a DESCRIPTION: an id, a title, and `actions(...args)` — a pure factory\n// saying what should be dispatched. It does not do anything itself.\n//\n// That is the whole change here, and it matters more than it looks. Commands are the entry\n// point for everything a person actually does: the palette, every keybinding, every menu\n// item, every row button. These were closures over `app` — the whole world — calling\n// services directly, so `ExecCommandAction` routed the intent into the engine and the\n// handler walked straight back out. The engine saw a command being run and nothing of what\n// it did: no feed entry for the delete, the upload, or the collection switch, and nothing\n// able to intercept or observe one.\n//\n// The bodies moved into actions (bl/actions.js, \"what commands used to do inline\"). What is\n// left is a table, which is what a command registry should have been.\n//\n// `palette: false` where a command is a button on a screen rather than a verb someone would\n// go looking for. Revoking a credential by fuzzy-searching for it is not a thing to make\n// easy.\n\nimport {\n NavigateAction, RefreshAction, LoadMoreAction, TrashAction, ShowTrashAction,\n UploadFilesAction, PickAndUploadAction, OpenSubjectAction, DownloadSubjectAction,\n CopyLinkAction, RenameSubjectAction, DeleteSubjectAction, PinAction,\n SearchAction, VoiceSearchAction,\n RebuildIndexAction, ScanCollectionAction, CheckStorageAction, ToggleActivityPanelAction,\n LoadApiKeysAction, RevokeApiKeyAction, MintApiKeyFromDraftAction,\n StartApiKeyDraftAction, CancelApiKeyDraftAction, ClearMintedApiKeyAction,\n OpenPaletteAction, SetActivityAction, CloseOverlaysAction, ShowHomeAction,\n ShowDialogAction, SwitchCollectionAction, ToggleDetailsAction,\n ToggleInboxAction, EnablePushAction,\n InstallPluginFromUrlPromptAction, PickAndInstallPluginAction,\n} from './actions.js';\n\n// Everything that acts on \"the file you mean\" — the selection, or the one you have open.\n//\n// Without this the palette offered Rename and Delete on an empty drive, accepted the click,\n// and answered with \"Pick a file first\". A when-clause greys them instead, which is the\n// difference between an offer the drive cannot honour and an accurate menu.\n//\n// Row menus satisfy it because opening one SELECTS the row first (see openRowMenu), so a\n// command reached that way always has a subject even though the clause cannot see the node\n// argument it was handed.\nconst HAS_SUBJECT = 'explorer.hasSelection || editor.open';\n\nexport function registerCommands(app) {\n const cmd = (id, title, actions, extra = {}) =>\n app.platform.commands.register({ id, title, actions, ...extra });\n\n // --- navigation / views ----------------------------------------------------\n cmd('workbench.showCommandPalette', 'Show All Commands', () => new OpenPaletteAction('commands'), { category: 'View', icon: 'command' });\n cmd('workbench.quickOpen', 'Go to File…', () => new OpenPaletteAction('files'), { category: 'File', icon: 'search' });\n cmd('workbench.view.home', 'Go Home (search & browse)', () => new ShowHomeAction(), { category: 'View', icon: 'search' });\n cmd('workbench.view.plugins', 'Show Plugins', () => new SetActivityAction('plugins'), { category: 'View' });\n cmd('workbench.view.admin', 'Show Administration', () => new SetActivityAction('admin'), { category: 'View', icon: 'gear' });\n cmd('workbench.openSettings', 'Open Settings', () => new SetActivityAction('settings'), { category: 'Preferences', icon: 'gear' });\n cmd('workbench.closeOverlays', 'Close', () => new CloseOverlaysAction(), { palette: false });\n cmd('search.voice', 'Search by Voice', () => new VoiceSearchAction(), { category: 'View', icon: 'search' });\n\n // --- background work + standing problems -----------------------------------\n cmd('workbench.showActivity', 'Show Activity (running work & problems)',\n () => new ToggleActivityPanelAction(true), { category: 'View', icon: 'refresh' });\n cmd('workbench.rebuildIndex', 'Rebuild Search Index',\n () => new RebuildIndexAction(), { category: 'View', icon: 'refresh' });\n // Trove is not the only thing that can write to the bucket. This is how files added,\n // replaced, or removed by something else get picked up.\n cmd('workbench.scanCollection', 'Scan Collection for Outside Changes',\n () => new ScanCollectionAction(), { category: 'Explorer', icon: 'refresh' });\n cmd('workbench.checkStorage', 'Check Storage Configuration',\n () => new CheckStorageAction(), { category: 'View', icon: 'plug' });\n\n // --- explorer --------------------------------------------------------------\n cmd('explorer.refresh', 'Refresh', () => new RefreshAction(), { category: 'Explorer', icon: 'refresh' });\n cmd('explorer.loadMore', 'Show More Items', () => new LoadMoreAction(), { palette: false });\n cmd('explorer.upload', 'Upload Files…', () => new PickAndUploadAction(), { category: 'Explorer', icon: 'upload' });\n // Two spellings of one address, and which you want depends on where it is going.\n // `trove:` is what one document writes to link another; a share link is a URL you can\n // paste into a message. Offered under both names, labelled for the destination rather\n // than for the format, which is the difference between a choice and a riddle.\n cmd('explorer.copyShareLink', 'Copy Shareable Link', (node) => new CopyLinkAction('share', node), { category: 'Explorer', icon: 'link', when: HAS_SUBJECT });\n cmd('explorer.copyLink', 'Copy Link to Item', (node) => new CopyLinkAction('trove', node), { category: 'Explorer', icon: 'link', when: HAS_SUBJECT });\n cmd('explorer.rename', 'Rename', (node) => new RenameSubjectAction(node), { category: 'Explorer', when: HAS_SUBJECT });\n cmd('explorer.delete', 'Delete', () => new DeleteSubjectAction(), { category: 'Explorer', icon: 'trash', when: HAS_SUBJECT });\n cmd('explorer.open', 'Open', (node) => new OpenSubjectAction(node), { palette: false });\n cmd('explorer.download', 'Download', (node) => new DownloadSubjectAction(node), { category: 'Explorer', icon: 'download', when: HAS_SUBJECT });\n\n // --- trash -----------------------------------------------------------------\n cmd('explorer.showTrash', 'Show Trash', () => new ShowTrashAction(), { category: 'Explorer', icon: 'trash' });\n cmd('explorer.hideTrash', 'Hide Trash', () => new TrashAction('hide'), { palette: false });\n cmd('explorer.restore', 'Restore from Trash', (id) => (id ? new TrashAction('restore', id) : null), { palette: false });\n cmd('explorer.purgeOne', 'Delete Forever', (id) => (id ? new TrashAction('purge', id) : null), { palette: false });\n // Wholly declarative: the confirmation is data, and what it confirms is an action.\n cmd('explorer.emptyTrash', 'Empty Trash', () => new ShowDialogAction({\n kind: 'confirm', title: 'Empty the trash?',\n body: 'Everything in the trash will be destroyed. This cannot be undone.',\n danger: true, confirmLabel: 'Delete forever',\n confirmActions: [new TrashAction('empty')],\n }), { category: 'Explorer', icon: 'trash' });\n\n // --- API keys (admin) ---------------------------------------------------------\n cmd('keys.load', 'Load API Keys', () => new LoadApiKeysAction(), { palette: false });\n cmd('keys.new', 'New API Key', () => new StartApiKeyDraftAction(), { palette: false });\n cmd('keys.cancel', 'Cancel API Key', () => new CancelApiKeyDraftAction(), { palette: false });\n cmd('keys.dismissMinted', 'Dismiss API Key', () => new ClearMintedApiKeyAction(), { palette: false });\n cmd('keys.revoke', 'Revoke API Key', (id) => (id ? new RevokeApiKeyAction(id) : null), { palette: false });\n cmd('keys.mint', 'Create API Key', () => new MintApiKeyFromDraftAction(), { palette: false });\n\n // --- offline ---------------------------------------------------------------\n cmd('offline.pin', 'Make Available Offline', (node) => new PinAction(node, true), { category: 'Offline', icon: 'download', when: HAS_SUBJECT });\n cmd('offline.unpin', 'Remove from Offline', (node) => new PinAction(node, false), { palette: false });\n\n // --- collections -----------------------------------------------------------\n cmd('collections.switch', 'Switch Collection…', (cid) => new SwitchCollectionAction(cid), { category: 'Collections', icon: 'files' });\n cmd('collections.create', 'New Collection…', () => new ShowDialogAction({ kind: 'collection', title: 'New collection' }), { category: 'Collections', icon: 'files' });\n\n // --- conversations & notifications -----------------------------------------\n cmd('workbench.toggleInfoPanel', 'Toggle Details & Conversation', () => new ToggleDetailsAction(), { category: 'View', icon: 'info' });\n cmd('notifications.show', 'Show Notifications', () => new ToggleInboxAction(true), { category: 'View' });\n cmd('notifications.enablePush', 'Enable Push Notifications', () => new EnablePushAction(), { category: 'Notifications' });\n\n // --- plugins ---------------------------------------------------------------\n cmd('plugins.installFromUrl', 'Install Plugin from URL…', () => new ShowDialogAction({\n kind: 'prompt', title: 'Install plugin from URL', label: 'Plugin package (.zip) URL',\n placeholder: 'https://example.com/plugin.zip', confirmLabel: 'Fetch',\n confirmActions: [new InstallPluginFromUrlPromptAction()],\n }), { category: 'Plugins', icon: 'plug' });\n cmd('plugins.installFromFile', 'Install Plugin from File…', () => new PickAndInstallPluginAction(), { category: 'Plugins', icon: 'plug' });\n}\n\n// Kept for the one caller that still hands a File list straight to an upload — the drop\n// target, which already has the files and has nothing to pick.\nexport { UploadFilesAction, NavigateAction, SearchAction };\n",
77
+ "// Assemble the ngin engine: one provider per named resource, then commands, the built-in\n// context keys, and the boot dispatches.\n//\n// There is no `app` provider. It existed, and it made the engine's state one opaque blob —\n// every query and every action leased the whole world, and a lease that always covers\n// everything tells you nothing about what a piece of work touches or how long it needs it.\n// It survived longest as the thing command handlers closed over, and went when they stopped\n// being closures (see bl/commands.js). `static deps = ['explorer']` means what it says now,\n// and web/test/leases.test.js checks that it stays true.\n//\n// `app` the OBJECT is still returned, because the shell and the e2e harness hold the\n// services directly — but nothing leases it.\n\nimport { Engine, Provider } from '@3sln/ngin';\nimport { cell } from '../runtime.js';\nimport { registerCoreContext, registerViewportContext } from './context.js';\nimport { TransfersService } from './services.js';\nimport { explorerState, searchState, apiKeysState, viewState as viewStateSlice, overlayState, workbenchState, aclState, rotationState } from './state.js';\nimport { NavigationService } from '../platform/navigation.js';\nimport { SocialService } from './social.js';\nimport { OfflineService } from './offline.js';\nimport { ActivityService } from './activity.js';\nimport { registerCommands } from './commands.js';\nimport { NavigateAction } from './actions.js';\n\nexport function createApp(platform) {\n // Named slices, not services — see bl/state.js. Each is still its own provider, so a\n // lease naming `explorer` still says what it touches.\n const explorer = explorerState(platform.settings);\n const search = searchState();\n const apiKeys = apiKeysState();\n const rotation = rotationState();\n const acl = aclState();\n // One place for \"what's running\" and \"what's stuck\", covering both sides of the wire.\n const activity = new ActivityService(platform);\n // What the UI is in the middle of doing — see bl/state.js. A resource, because it\n // decides what is on screen.\n const viewState = viewStateSlice();\n // The shell, split into what it actually is. `workbench` and `overlay` are slices; the\n // panel stack stays a service, because it mirrors itself into browser history and\n // persists recents — neither of which a state bag can do. The WorkbenchService that used\n // to sit over all three was a 17-method delegation facade, and the provider graph could\n // not see through it: closing a dialog leased the whole shell.\n const workbench = workbenchState();\n const overlay = overlayState();\n const navigation = new NavigationService();\n const transfers = new TransfersService(activity);\n // Offline first: social queues comment and tag writes through it while disconnected, so\n // it is a dependency rather than something bolted on afterwards. It used to be assigned\n // onto `social` after both existed, which reads as optional and is not — a social service\n // built without it silently drops every offline write.\n const offline = new OfflineService(platform);\n const social = new SocialService(platform, offline);\n\n const app = { platform, explorer, search, transfers, social, offline, activity, apiKeys, rotation, workbench, overlay, navigation, engine: null };\n\n // Every resource the engine has, named. The engine's STATE is the state of its\n // resources, so the single `app` provider this started with made that state one opaque\n // blob: every query and every action leased the whole world, and a lease that always\n // covers everything tells you nothing about what a piece of work touches or how long it\n // needs it.\n //\n // `app` is gone. It survived longest as the thing command handlers closed over, and went\n // when they stopped being closures — see bl/commands.js. Every lease now names what it\n // touches, and `static deps = ['explorer']` means what it says.\n const engine = new Engine({\n providers: {\n // Where a live query keeps its subscription — see bl/queries.js. A provider, so it\n // is per engine; keyed by the query instance, so an entry belongs to exactly one\n // realization. A query instance is shared (it is interned), so it is the wrong place\n // to put anything that is true only while it is being watched.\n appState: Provider.fromSingleton(new Map()),\n\n // The drive.\n explorer: Provider.fromSingleton(explorer),\n search: Provider.fromSingleton(search),\n transfers: Provider.fromSingleton(transfers),\n social: Provider.fromSingleton(social),\n offline: Provider.fromSingleton(offline),\n activity: Provider.fromSingleton(activity),\n apiKeys: Provider.fromSingleton(apiKeys),\n rotation: Provider.fromSingleton(rotation),\n acl: Provider.fromSingleton(acl),\n viewState: Provider.fromSingleton(viewState),\n\n // The engine itself, for actions that choreograph — dispatching a follow-up rather\n // than doing the follow-up's work inline. LAZY because the engine does not exist\n // when its own providers are declared; by the time anything leases this, it does.\n // ngin's execute context carries a dispatchFeed but no dispatcher, so this is the\n // seam for it.\n engine: Provider.fromLazySingleton(async () => engine, () => {}),\n\n // The shell.\n workbench: Provider.fromSingleton(workbench),\n overlay: Provider.fromSingleton(overlay),\n navigation: Provider.fromSingleton(navigation),\n settings: Provider.fromSingleton(platform.settings),\n notifications: Provider.fromSingleton(platform.notifications),\n context: Provider.fromSingleton(platform.context),\n commands: Provider.fromSingleton(platform.commands),\n keybindings: Provider.fromSingleton(platform.keybindings),\n contributions: Provider.fromSingleton(platform.contributions),\n viewport: Provider.fromSingleton(platform.viewport),\n voice: Provider.fromSingleton(platform.voice),\n\n // The outside world.\n api: Provider.fromSingleton(platform.api),\n\n // What this deployment can do: which storage drivers it offers, whether it can\n // suggest searches, how transfers reach the bucket.\n //\n // A PROVIDER, not an action and not a query holding a promise. Nobody asks for\n // capabilities — they are ambient facts other things consult in order to decide, so\n // there is no intent to dispatch and nothing to put on the feed. It was a query that\n // memoised `api.capabilities()` on its own instance to avoid re-fetching, which is a\n // cache with no invalidation living inside a view.\n //\n // It provides a CELL rather than the value, and the fetch is deliberately not\n // awaited. Awaiting would make every lease of this block until the server answered,\n // so a query that merely consults capabilities would be PENDING and the shell would\n // render nothing until the round trip finished. The cell starts null — \"not known\n // yet\", which every reader already treats correctly — and fills in, so anything\n // watching simply re-projects when the answer lands.\n //\n // One fetch for the life of the page, because `fromLazySingleton` memoises on the\n // creation promise. That is the provider's job, which is where it belongs.\n // Closes over `platform.api` rather than declaring `{ deps: ['api'] }`: a provider's\n // deps arrive as the PROVIDER INSTANCES, not as resources, so the dependency form\n // would hand over something you must `obtain()` and release. Every other provider\n // here closes over what it needs, and this is the same client either way.\n capabilities: Provider.fromLazySingleton(\n async () => {\n const held = cell(null);\n platform.api.capabilities().then(\n (caps) => held.setValue(caps),\n // A drive whose capabilities cannot be read still works; every reader treats\n // null as \"not known\" and falls back. Failing the provider would take the\n // whole shell down over an optional answer.\n () => {},\n );\n return held;\n },\n () => {},\n ),\n plugins: Provider.fromSingleton(platform.plugins),\n },\n });\n app.engine = engine;\n\n // How a command reaches the engine. A command resolves to actions and the CommandService\n // dispatches them; it is built with the platform, before the engine exists, so the\n // dispatcher is handed over here.\n //\n // This is the boundary, not a shortcut: a keystroke and a plugin's RPC both originate\n // outside the engine, and one of them has to carry the intent in. Everything past this\n // point is an action on the feed.\n platform.commands.dispatch = (action) => engine.dispatch(action);\n // The same seam for everything that originates outside the engine: a docked plugin frame\n // opening a file, and the plugin RPC asking for its panel. ONE seam — there was a second,\n // `openPluginPanel`, which was `dispatch` with one action pre-applied, declared\n // differently (a field in the platform literal versus one materialising from nowhere) and\n // guarded differently (`dispatch?.()` optional, `openPluginPanel()` not), so a reader\n // looking for how the plugin layer reaches the engine had to find both.\n platform.dispatch = (action) => engine.dispatch(action);\n\n registerCommands(app);\n\n // Every built-in when-clause key, derived from the resource it summarises. Registered\n // here because this is where those resources exist; see bl/context.js for the list and\n // for why deriving them is not the same as moving the writes.\n registerCoreContext(platform.context, { workbench, overlay, navigation, explorer });\n registerViewportContext(platform.context, platform.viewport);\n\n social.init();\n offline.init();\n activity.init();\n // NOT `LoadCollectionsAction` as well. `OpenInitialCollectionAction`, dispatched at boot\n // by workbench.js, fetches and writes the same two fields on both its normal and its\n // share-link path — so every cold start made two identical GETs to /api/collections and\n // installed two writers for one fact.\n\n return { engine, app };\n}\n\nexport { NavigateAction };\n",
78
+ "// Reading an engine query from the render layer.\n//\n// Mostly this exists to be the ONE place that knows how a query reaches a component. The\n// bridging itself is a single call; the value is that it is not re-derived at fifteen call\n// sites, and that if it ever needs an initial value or an error view, there is somewhere to\n// put it.\n//\n// `engine.query(q)` answers an observable — `subscribe({next, error, complete})` — and dodo's\n// `watch` takes a Cell — `onDirty(fn)` plus `getValue()`. `fromObservable` already bridges\n// exactly those two shapes, so this is thin on purpose: the point is that there is ONE place\n// that knows how a query reaches a component, rather than the adapter being re-derived at\n// every call site.\n//\n// The subscription belongs to the CELL, not to the component: dodo connects a cell when its\n// first watcher attaches and disconnects when the last one leaves, which is the same\n// lifetime ngin gives a query realization. So a region that scrolls out of the tree stops\n// observing, the query's `kill` runs, and whatever it was holding is released — without any\n// component writing teardown.\n//\n// See docs/tickets/009.\n\nimport { fromObservable, PENDING } from '../runtime.js';\n\n/**\n * Cache the bridged cell per (engine, query instance).\n *\n * Not, as this first claimed, because two cells would \"undo ngin's sharing\" — they would\n * not. Measured: two independent `fromObservable(engine.query(q))` over one instance boot\n * the query ONCE and kill it once, because ngin shares the realization by instance and does\n * not care how many observers arrive or through what. The sharing was never at risk.\n *\n * What the cache actually buys is smaller and worth stating accurately:\n *\n * - **Idempotence.** `watchQuery` can be called freely and returns the same cell, so it\n * is safe in a render. Without it, `watch` — which compares its source by identity and\n * resubscribes when it changes — would tear down and re-establish every pass.\n * - **One fan-out per change** instead of one per bridge. Each extra cell is another\n * observer on the controller and another invalidation to propagate.\n *\n * Neither is correctness, so this is an optimisation and a convenience, not a safeguard.\n * The safeguard against duplicate realizations is interning the query instance — see\n * bl/intern.js, which is where that problem is actually solved.\n *\n * Weak on the engine so a disposed engine takes its cells with it, and weak on the query so\n * an interned instance that falls out of use does too.\n */\nconst cells = new WeakMap();\n\n/**\n * @param {object} engine\n * @param {object} queryInstance an INTERNED instance — see bl/intern.js\n * @returns {object} a dodo Cell, PENDING until the query produces its first value\n */\nexport function watchQuery(engine, queryInstance) {\n let forEngine = cells.get(engine);\n if (!forEngine) {\n forEngine = new WeakMap();\n cells.set(engine, forEngine);\n }\n let cell = forEngine.get(queryInstance);\n if (!cell) {\n cell = fromObservable(engine.query(queryInstance), { initial: PENDING });\n forEngine.set(queryInstance, cell);\n }\n return cell;\n}\n",
79
+ "// A region: one part of the shell, subscribed to only the queries it reads.\n//\n// The workbench is a single `watch` over a `derive` of eighteen cells, so any change to any\n// of them rebuilds the whole VDOM — activity bar, status bar, every overlay, the file list.\n// dodo reconciles, so the DOM update stays small; the REBUILD does not. An upload progress\n// tick reconstructs all 500 rows of a file list to move one number in the transfer tray.\n//\n// A region fixes that by narrowing the subscription instead of the render: it watches the\n// queries it actually reads, and a change to anything else never reaches it. That also makes\n// the dependency legible — the region's queries are its argument list, rather than something\n// you infer by reading which snapshot keys the body touches.\n//\n// The teardown matters as much as the render. A region that leaves the tree drops its\n// watchers; dodo disconnects the cells; ngin kills the query realizations, releasing their\n// leases and whatever they held open. That is what makes a query the right home for\n// something like a minted media URL — alive while a region is looking at it, gone when it\n// stops — with no component writing cleanup.\n//\n// See docs/tickets/009.\n\nimport { dd, watch, derive } from '../runtime.js';\nimport { watchQuery } from '../bl/watchQuery.js';\n\n/**\n * @param {object} engine\n * @param {Record<string, object>} queries name → SHARED query instance (see bl/queries.js)\n * @param {(state: Record<string, any>) => any} build the region's view; close over `ui`\n * @param {{placeholder?: () => any, error?: (err: Error) => any}} [opts]\n * @returns {() => any} a component, built ONCE — see below for why that matters\n */\nexport function region(engine, queries, build, opts) {\n const names = Object.keys(queries);\n // Resolved at composition, not per render. `watchQuery` caches per (engine, query) so\n // these would be the same cells either way, but doing it here says the subscription\n // belongs to the region rather than being re-established on every pass.\n const cells = names.map((name) => watchQuery(engine, queries[name]));\n // `derive` coalesces: several of these changing in one frame still costs one render.\n const combined = derive(cells, (...values) =>\n Object.fromEntries(names.map((name, i) => [name, values[i]])));\n\n // ONE alias function, and one options object, for the life of the app.\n //\n // dodo identifies an alias by the FUNCTION: \"swapping the alias function ... is a\n // different component, and reusing the state would skip the old one's detach and the new\n // one's attach\". So `alias(...)` built inside the render would detach and re-attach the\n // watch — dropping the subscription, killing the query realization and booting a fresh\n // one — on every pass of the parent. That is the precise opposite of what a region is\n // for, and it would have looked like it worked.\n //\n // `build` and `opts` are hoisted for the same reason one level down: `watch` compares its\n // arguments, and a builder closure rebuilt per render is a new argument every time.\n return dd.alias(() => watch(combined, build, opts));\n}\n",
80
+ "// One instance per logical query.\n//\n// ngin shares a live query realization by INSTANCE identity — its controller map is keyed on\n// the object, and neither the class nor the fields are consulted. That is fine for a query\n// with no arguments, which can be a module singleton. It is a trap for a parameterised one:\n// `new MediaUrl('n1')` in two places is two realizations of the same question, so two minted\n// URLs and two leases for one file, and nothing fails to say so.\n//\n// So a parameterised query declares a shared factory and is asked for, not constructed:\n//\n// class MediaUrl extends ViewQuery {\n// static of = queryOf(MediaUrl);\n// constructor(nodeId) { ... }\n// }\n//\n// MediaUrl.of('n1') // same id, same instance, one realization\n//\n// A field holding a factory rather than a base class or a mixin, which is what makes this\n// small: the query keeps whatever base it already had, each factory closes over its own\n// table, and there is no name resolved through a prototype chain for anything to shadow.\n\n/**\n * Eviction, without a policy to get wrong.\n *\n * Entries are weak, and a finalizer sweeps the key once the instance is collected. That is\n * sound because LIVENESS PINS THE INSTANCE: ngin's controller map is a plain Map holding the\n * query as a key, deleted only on teardown, so a query with observers is strongly reachable\n * and cannot be collected. An idle one can be, and re-asking simply builds a fresh instance.\n *\n * The alternative — an LRU with a cap — is actively wrong here: evicting a LIVE entry means\n * the next `of()` mints a second instance while the first is still running, which is the\n * exact bug this exists to prevent, arriving on a timer.\n *\n * (This leans on ngin's default controller map being strong. `hooks.createQueryControllersMap`\n * could replace it with a weak one; we do not, and a weak one would break this.)\n */\nconst sweeper = new FinalizationRegistry(({ table, key }) => {\n // Only if it is still the dead entry — a fresh instance may have claimed the key already.\n if (table.get(key) && !table.get(key).deref()) table.delete(key);\n});\n\n/**\n * Reject anything a canonical key cannot capture.\n *\n * A function stringifies to `undefined` in JSON, so two queries taking different callbacks\n * would key identically and silently share one realization — the very bug this exists to\n * prevent, reintroduced by the fix. Fail at the call site instead. A query with arguments\n * like that passes its own key function and never comes through here.\n */\nfunction assertKeyable(value, path) {\n const t = typeof value;\n if (value === null || t === 'string' || t === 'number' || t === 'boolean') return;\n if (t !== 'object') {\n throw new TypeError(\n `Query argument ${path} is a ${t}, which cannot be part of a sharing key. ` +\n 'Pass an id and let the query look the thing up, or give queryOf a key function.',\n );\n }\n if (Array.isArray(value)) return value.forEach((v, i) => assertKeyable(v, `${path}[${i}]`));\n const proto = Object.getPrototypeOf(value);\n if (proto === Object.prototype || proto === null) {\n return Object.entries(value).forEach(([k, v]) => assertKeyable(v, `${path}.${k}`));\n }\n throw new TypeError(\n `Query argument ${path} is a ${value.constructor?.name ?? 'non-plain object'}, which ` +\n 'cannot be part of a sharing key. Pass an id and let the query look the thing up, ' +\n 'or give queryOf a key function.',\n );\n}\n\n/** A canonical string for a value: object keys sorted, so `{a,b}` and `{b,a}` are one key. */\nexport function stableKey(value) {\n if (value === null || typeof value !== 'object') return JSON.stringify(value) ?? 'null';\n if (Array.isArray(value)) return `[${value.map(stableKey).join(',')}]`;\n return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${stableKey(value[k])}`).join(',')}}`;\n}\n\n/** The default key: every argument, in order, canonically. Types count, so 1 and '1' differ. */\nexport function keyOfArgs(...args) {\n args.forEach((a, i) => assertKeyable(a, `#${i}`));\n return args.map(stableKey).join('|');\n}\n\n/**\n * A factory returning the shared instance of `Class` for a given argument list.\n *\n * class Thing extends ViewQuery { static of = queryOf(Thing); }\n *\n * `key` defaults to the arguments, canonically. Pass one to share more coarsely than the\n * arguments do — an option that changes how something is displayed but not what is fetched\n * should not split one realization into two — or to key arguments the default refuses:\n *\n * static of = queryOf(Thing, (nodeId, opts) => nodeId);\n *\n * A key rather than a hash plus a comparator: a comparator only earns its complexity when\n * keys can collide, and a canonical key does not collide.\n *\n * The class is captured, so a subclass inheriting this field would build the PARENT —\n * `Sub.of('x')` returning a `Base` is the sort of wrong that reads as right. The factory is\n * a plain function rather than an arrow so that `this` is the class it was reached through,\n * and it refuses to run when that is not the class it was built for. A subclass that wants\n * sharing declares its own `static of`.\n *\n * A detached call — `const of = Thing.of; of('x')` — has no receiver at all, and in a module\n * `this` is `undefined` rather than the global. That is the ordinary way to pass the factory\n * around, so it is allowed; only a DIFFERENT class is an error.\n *\n * @param {Function} Class the query class, referenced from inside its own body\n * @param {(...args: any[]) => string} [key]\n */\nexport function queryOf(Class, key = keyOfArgs) {\n const table = new Map();\n return function of(...args) {\n if (this !== undefined && this !== Class) {\n throw new TypeError(\n `${this?.name ?? 'A subclass'}.of() would build a ${Class.name}, because \\`of\\` ` +\n `captures the class it was declared on. Give ${this?.name ?? 'the subclass'} its own ` +\n '`static of = queryOf(...)`, or call it on ' + Class.name + ' directly.',\n );\n }\n const k = key(...args);\n const existing = table.get(k)?.deref();\n if (existing) return existing;\n const instance = new Class(...args);\n table.set(k, new WeakRef(instance));\n sweeper.register(instance, { table, key: k });\n return instance;\n };\n}\n",
81
+ "// Ranking what someone typed against a list of things.\n//\n// There were two of these, for one question. The command palette scored per matched\n// character and added 10 for a contiguous substring; the launcher's `!` mode returned\n// `1000 - index` for a substring and a flat 1 otherwise. So typing the same three letters\n// ranked the same commands differently depending on which way you had reached them — and\n// the launcher's version could not distinguish two commands that both merely contained the\n// letters, because every non-substring match scored exactly 1.\n//\n// Neither was wrong so much as unaware of the other. Ranking is a decision about the\n// drive's own vocabulary, so it belongs here, once.\n\n/**\n * How well `hay` matches `term`. 0 means no match at all.\n *\n * Subsequence first — the letters must appear in order, which is what makes \"cmp\" find\n * \"Command Palette\". Then three things push a better match up:\n *\n * - a contiguous substring beats scattered letters, by a lot\n * - an earlier hit beats a later one, so typing \"set\" prefers \"Settings\" to \"Reset\"\n * - adjacent letters beat gaps, which is the difference between \"op\" matching \"Open\" and\n * matching \"Only Photographs\"\n *\n * @param {string} hay already lowercased\n * @param {string} term already lowercased and trimmed\n */\nexport function matchScore(hay, term) {\n if (!term) return 1;\n let score = 0;\n let from = 0;\n for (const ch of term) {\n const at = hay.indexOf(ch, from);\n if (at < 0) return 0; // not a subsequence — not a match\n score += at === from ? 3 : 1; // adjacency is worth more than mere presence\n from = at + 1;\n }\n const sub = hay.indexOf(term);\n if (sub >= 0) {\n // A contiguous run is the strongest signal there is, and the earlier it starts the\n // more likely it is what was meant.\n score += 100 - Math.min(50, sub);\n }\n return score;\n}\n\n/**\n * Commands matching `term`, best first.\n *\n * The haystack is \"category title\" because someone typing \"view\" means the View category\n * as readily as they mean a command with View in its name.\n *\n * @param {Array<{id: string, title: string, category?: string}>} commands\n * @param {string} term what was typed, without any leading `!`\n * @param {number} [limit]\n */\nexport function rankCommands(commands, term, limit = 60) {\n const q = (term || '').trim().toLowerCase();\n const all = commands || [];\n if (!q) return all.slice(0, limit);\n const scored = [];\n for (const c of all) {\n const s = matchScore(`${c.category || ''} ${c.title}`.toLowerCase(), q);\n if (s > 0) scored.push([s, c]);\n }\n // Ties break by title, so a list that cannot decide is at least stable rather than\n // ordered by whatever registered first.\n return scored\n .sort((a, b) => b[0] - a[0] || String(a[1].title).localeCompare(String(b[1].title)))\n .slice(0, limit)\n .map(([, c]) => c);\n}\n",
82
+ "// What the drive is doing and how full it is — one answer, for every surface that says so.\n//\n// This lived in the status bar and was imported from there by the phone chrome, which is\n// how it was already admitting to being shared: two shells rendering the same facts in\n// different shapes. It is a derivation over four resources, so it belongs here, and it is\n// reached as the `statusFacts` query rather than recomputed per render.\n//\n// The reason it has to be derived ONCE rather than twice is on the record: the phone bar\n// rendered `collectionId` raw and showed an opaque `col_…` where the desktop bar showed the\n// collection's name — the same fact, said two ways, because each surface worked it out.\n\n/**\n * The facts every shell reports.\n *\n * @param {{ex: object, tr: object, act: object, off: object}} slices\n */\nexport function statusFactsOf({ ex = {}, tr = {}, act = {}, off = {} } = {}) {\n const items = ex.items || [];\n const tasks = act.tasks || [];\n return {\n // `null` with nothing open — `collectionLabelOf` renders that as \"no collection\". The\n // old fallback made the bar name a collection that may not exist, on a drive where the\n // user had not yet chosen one.\n collectionId: ex.collectionId ?? null,\n // What to CALL it, so the phone shell and the desktop bar cannot end up saying\n // different things.\n collectionLabel: collectionLabelOf(ex),\n // The COLLECTION's totals when the server could give them, not the page's. Summing what\n // happens to be loaded reports a 3,000-file drive as 500 files — a wrong number, not a\n // rounded one. Falls back to the page only when the server didn't say.\n totalItems: ex.stats?.items ?? items.length,\n // Whether that total is the COLLECTION's or just the page we happen to hold. With more\n // pages waiting, the page length is a floor, not a total, and must read as one.\n totalKnown: ex.stats?.items != null,\n totalBytes: ex.stats?.bytes ?? items.reduce((n, i) => n + (i.size || 0), 0),\n shown: items.length,\n partial: !!ex.nextCursor,\n usage: ex.usage ?? null,\n usageLevel: usageLevelOf(ex.usage),\n uploading: (tr.items || []).filter((t) => t.status === 'active'),\n running: tasks.filter((t) => t.status === 'running'),\n issues: act.issues || [],\n off: { online: true, pins: [], queued: 0, syncing: false, ...off },\n };\n}\n\n/** The open collection's name, or the plainest true thing when there isn't one. */\nexport function collectionLabelOf(ex) {\n if (!ex?.collectionId) return 'no collection';\n const match = (ex.collections || []).find((c) => c.id === ex.collectionId);\n return match?.name || ex.collectionId;\n}\n\n/**\n * How worried to be about space, or '' when there is nothing to say.\n *\n * A filesystem or NAS can answer exactly, and that is where it matters: a disk fills up and\n * every upload starts failing with no warning that anything was coming. An object store has\n * no equivalent number, so this answers '' and the meter is not drawn at all rather than\n * being drawn meaninglessly.\n *\n * The thresholds are a judgement about when someone still has time to act, which is why\n * they are here and not in whichever bar happens to be on screen.\n */\nexport function usageLevelOf(usage) {\n if (!usage?.total) return '';\n const free = usage.available / usage.total;\n return free < 0.05 ? 'critical' : free < 0.1 ? 'low' : '';\n}\n\n/**\n * The one thing worth saying about the drive right now, most urgent first.\n *\n * The phone has room for a single glyph, so something has to decide what outranks what:\n * being offline beats a standing problem, a standing problem beats work in progress, and\n * anything beats running low on space. That ordering is a claim about which condition a\n * person most needs to know, which makes it a decision rather than a rendering.\n *\n * Answers a KIND, not an icon. Which glyph draws a kind is the shell's business.\n */\nexport function driveConditionOf(facts) {\n const f = facts || {};\n if (!f.off?.online) return { kind: 'offline', label: 'Offline' };\n if (f.issues?.length) {\n return {\n kind: 'issues',\n label: `${f.issues.length} need${f.issues.length === 1 ? 's' : ''} attention`,\n count: f.issues.length,\n };\n }\n if (f.running?.length || f.uploading?.length || f.off?.syncing) {\n return { kind: 'working', label: 'Working…', count: (f.running?.length || 0) + (f.uploading?.length || 0) };\n }\n if (f.usageLevel) return { kind: 'lowSpace', label: 'Low on space' };\n return { kind: 'idle', label: 'Status' };\n}\n",
83
+ "// What the launcher is showing.\n//\n// This was ~100 lines inside the launcher COMPONENT, deciding — mid-render, where nothing\n// else could see it — which nodes are on screen, what each heading says, whether \"All\n// items\" is a lie because another page is waiting, and what the empty state should read\n// when a load FAILED as against when the drive is genuinely empty. Every one of those is a\n// question about engine state.\n//\n// It also made a smaller thing impossible: `pickView` needs the nodes on screen, and while\n// they were assembled in a render they looked like render-layer data. They are not — they\n// come from the explorer and search resources. Deriving them here is what lets the choice\n// of view become engine state too.\n//\n// Groups are DATA. A header control is `{ icon, label, title, actions }`, not a button —\n// the launcher used to put a rendered vnode in `group.action`, which is the same\n// carrying-a-handle problem that menu items had before they carried `actions`.\n\nimport { parseTagQuery, filterLabel } from './tagQuery.js';\nimport { iconForKind } from './fileType.js';\nimport {\n ExecCommandAction, CloseSearchModalAction, OpenFileAction, SearchAction, FilterAction,\n SetLaunchQueryAction,\n} from './actions.js';\n\n/** Which mode the typed query puts the launcher in. */\nexport function launcherMode(query) {\n const q = query || '';\n return q.startsWith('!') ? 'command' : q.includes('#') ? 'filter' : 'search';\n}\n\n/**\n * Everything you can do to a file, as descriptions.\n *\n * `pinned` and `keys` are resolved by the caller because both are questions about engine\n * state: whether THIS file is already available offline, and what the shortcut for a\n * command actually is on this machine. Hardcoding \"⌘⇧L\" told a Windows user about a key\n * they do not have, and told everyone the default even after they had rebound it.\n */\nexport function fileMenuOf(node, { pinned = false, keys = {} } = {}) {\n const kbd = (id) => keys[id] || undefined;\n return [\n { label: 'Open', icon: 'file-text', actions: [new ExecCommandAction('explorer.open', node)] },\n { label: 'Download', icon: 'download', actions: [new ExecCommandAction('explorer.download', node)] },\n // Labelled by destination rather than by format: one goes in a document, the other\n // goes to a person.\n { label: 'Copy shareable link', icon: 'link', actions: [new ExecCommandAction('explorer.copyShareLink')] },\n { label: 'Copy trove: link', icon: 'link', kbd: kbd('explorer.copyLink'), actions: [new ExecCommandAction('explorer.copyLink')] },\n { sep: true },\n { label: 'Rename…', actions: [new ExecCommandAction('explorer.rename')] },\n pinned\n ? { label: 'Remove from offline', icon: 'close', actions: [new ExecCommandAction('offline.unpin', node)] }\n : { label: 'Make available offline', icon: 'download', actions: [new ExecCommandAction('offline.pin', node)] },\n { sep: true },\n { label: 'Move to trash', icon: 'trash', danger: true, kbd: kbd('explorer.delete'), actions: [new ExecCommandAction('explorer.delete')] },\n ];\n}\n\n/** What you can do to something already in the trash. */\nexport function trashMenuOf(node) {\n return [\n { label: 'Restore', icon: 'refresh', actions: [new ExecCommandAction('explorer.restore', node.id)] },\n { sep: true },\n { label: 'Delete forever', icon: 'trash', danger: true, actions: [new ExecCommandAction('explorer.purgeOne', node.id)] },\n ];\n}\n\n/**\n * One row for a file.\n *\n * `menu` stays a thunk. A drive can have hundreds of rows on screen and almost none of\n * their menus are ever opened, so building them all would be work nobody asked for — and a\n * pure function deferring pure work is data as much as the array it would have returned.\n */\nfunction fileItem(node, { modal, pinnedIds, keys }) {\n return {\n icon: iconForKind(node),\n title: node.name,\n detail: node.contentType || '',\n node,\n // From the modal search, `reset` starts a fresh viewer stack; then close it.\n actions: [\n new OpenFileAction(node, { reset: !!modal }),\n ...(modal ? [new CloseSearchModalAction()] : []),\n ],\n menu: () => fileMenuOf(node, { pinned: pinnedIds.has(node.id), keys }),\n };\n}\n\n/**\n * The groups on screen.\n *\n * @param {object} s the slices this reads, already plain\n * @param {boolean} modal whether this is the double-shift overlay rather than the home\n * screen — the one input that is genuinely about which INSTANCE is rendering, since both\n * are on screen at once when the overlay is up\n */\nexport function launcherGroupsOf(s, modal = false) {\n const { ex = {}, se = {}, nav = {}, query = '', commandMatches = [], pinnedIds = new Set(), keys = {} } = s;\n const mode = launcherMode(query);\n const row = (node) => fileItem(node, { modal, pinnedIds, keys });\n const closeModal = modal ? [new CloseSearchModalAction()] : [];\n\n if (mode === 'command') {\n return [{\n id: 'commands',\n title: 'Commands',\n items: commandMatches.map((c) => ({\n icon: 'command', title: c.title, detail: c.category, badge: 'command',\n actions: [new ExecCommandAction(c.id), ...closeModal],\n })),\n empty: 'No matching commands.',\n }];\n }\n\n const { text, filters } = parseTagQuery(query);\n const nodes = (se.results || []).map((r) => r.node);\n const err = se.error;\n // A one-click retry so a transient search/filter failure isn't a dead end.\n const retry = (actions) => (err ? [{ icon: 'refresh', label: 'Retry', title: 'Retry', actions }] : []);\n\n // Drive-wide tag/property filter (server-side), optionally narrowed by free text.\n if (filters.length) {\n const label = filters.map(filterLabel).join(' ') + (text.trim() ? ` · \"${text.trim()}\"` : '');\n return [{\n id: 'filtered',\n title: se.loading ? 'Filtering…' : err ? 'Filter failed' : 'Filtered',\n // Shown as typed: a tag is a value, not a heading.\n verbatim: se.loading || err ? null : label,\n controls: retry([new FilterAction(filters, text)]),\n items: nodes.map(row),\n empty: se.loading ? 'Filtering…' : err ? `Couldn’t filter: ${err}` : 'No files match those filters.',\n }];\n }\n\n // Free-text search.\n if (text.trim()) {\n return [{\n id: 'results',\n title: se.loading ? 'Searching…' : err ? 'Search failed' : 'Results',\n controls: retry([new SearchAction(query)]),\n items: nodes.map(row),\n empty: se.loading ? 'Searching…' : err ? `Couldn’t search: ${err}` : 'No files match.',\n }];\n }\n\n // Home: recents, then everything in the collection. There is nothing to descend into —\n // this is the \"show me everything\" fallback for when search isn't the answer.\n const groups = [];\n const recents = (nav.recents || []).map(row);\n if (recents.length) groups.push({ id: 'recent', title: 'Recent', items: recents });\n\n const shown = (ex.items || []).length;\n // `stats` is the collection; `items` is the page. When the server didn't report stats we\n // only know the page — and saying \"500\" while a next page exists is a claim about the\n // drive that is false, so say \"500+\" instead.\n const knownTotal = ex.stats?.items ?? null;\n const total = knownTotal ?? shown;\n const totalLabel = knownTotal != null ? knownTotal.toLocaleString() : `${shown.toLocaleString()}+`;\n const items = (ex.items || []).map(row);\n // A partial list must not be titled \"All items\" — that is a claim about the drive, and on\n // a collection bigger than one page it is false. Say what is on screen, and offer the rest\n // rather than leaving it unreachable.\n if (ex.nextCursor) {\n items.push({\n icon: 'refresh',\n title: ex.loadingMore ? 'Loading…'\n : knownTotal != null ? `Show more (${(knownTotal - shown).toLocaleString()} more)` : 'Show more',\n detail: 'or search to jump straight to something',\n actions: [new ExecCommandAction('explorer.loadMore')],\n });\n }\n\n // The trash, when it has been opened. Not shown by default: it is a place you go to\n // recover a mistake, not part of browsing the drive.\n if (ex.trash) {\n groups.push({\n id: 'trash',\n // One line, not two: a header reading \"0 items\" above a body reading \"the trash is\n // empty\" is the same sentence twice, permanently parked above the drive.\n title: ex.trash.length\n ? `Trash · ${ex.trash.length} item${ex.trash.length === 1 ? '' : 's'}`\n : 'Trash',\n controls: [\n ...(ex.trash.length\n ? [{ icon: 'trash', label: 'Empty trash', title: 'Destroy everything in the trash', actions: [new ExecCommandAction('explorer.emptyTrash')] }]\n : []),\n // The way back out. Opening the trash used to be one-way until a page reload.\n { icon: 'close', label: 'Close', title: 'Hide the trash', actions: [new ExecCommandAction('explorer.hideTrash')] },\n ],\n items: (ex.trash || []).map((n) => ({\n icon: 'trash',\n title: n.name,\n detail: `deleted ${new Date(n.deletedAt).toLocaleString()} — restore`,\n actions: [new ExecCommandAction('explorer.restore', n.id)],\n menu: () => trashMenuOf(n),\n })),\n empty: 'The trash is empty.',\n });\n }\n\n groups.push({\n id: 'all',\n title: ex.nextCursor ? `All items · showing ${shown.toLocaleString()} of ${totalLabel}` : 'All items',\n // The empty state told people to upload a file, and on desktop and TV there was nothing\n // anywhere that would let them. (Phone has the + in its bottom bar.)\n controls: modal ? [] : [{ icon: 'upload', label: 'Upload', title: 'Upload files to this collection', actions: [new ExecCommandAction('explorer.upload')] }],\n items,\n // Don't show a false \"empty\" when the load actually FAILED (e.g. server unreachable) —\n // say so, so the user knows to retry rather than believing the collection is empty. (A\n // toast also fires, but the persistent state must be honest.)\n empty: ex.loading ? 'Loading…' : ex.error ? `Couldn’t load this collection: ${ex.error}` : 'Nothing here yet — upload a file to get started.',\n });\n return groups;\n}\n\n/**\n * The suggestions shown when a search came back with nothing.\n *\n * Two halves, both settled by the `launcherContent` query: whether an offer applies at all\n * — a search ran, it succeeded, it found nothing — and what to suggest, which the server\n * decides and reaches the engine through the `capabilities` resource. Each example carries\n * the actions that run it, so the component only draws them.\n */\nexport function searchHelpOf({ eligible = false, caps = null } = {}) {\n if (!eligible) return null;\n const p = caps?.searchPrompt;\n if (!p?.hint && !p?.examples?.length) return null;\n return {\n hint: p.hint || null,\n examples: (p.examples || []).map((ex) => {\n const { text, filters } = parseTagQuery(ex.query);\n return {\n query: ex.query,\n label: ex.label || null,\n // Running an example is the same two steps as typing it: put it in the box, then\n // ask whichever of search or filter that spelling means.\n actions: [\n new SetLaunchQueryAction(ex.query),\n filters.length ? new FilterAction(filters, text) : new SearchAction(text),\n ],\n };\n }),\n };\n}\n",
84
+ "// Which of the registered views should draw the results.\n//\n// The reactive half — which views exist, their when-clauses, which one the user pinned —\n// is the `views` query. This is the rest: arithmetic over the items on screen.\n//\n// Still a plain function rather than part of that query only because the launcher assembles\n// the items mid-render. They are themselves derived from the explorer and search state, so\n// this folds into a query as soon as that assembly does.\n//\n// It lived in ui/components/views/index.js, which was half a job: the registry reads moved\n// into the engine and the DECISION stayed in the render layer. Choosing a layout from what\n// a collection contains is a claim about the drive, not about markup.\n\n/** Where a pinned view choice is remembered. */\nexport const SETTING = 'explorer.view';\n\n/**\n * The view to draw with, in order of how much someone meant it.\n *\n * 1. A saved choice — they pressed a button. Nothing infers its way past that.\n * 2. The search transformer's hint, when there is a search on screen. It read the\n * sentence: \"photos from the trip last summer\" is a request for a gallery as much as\n * it is a query, and nothing downstream can recover that from a list of content types.\n * 3. A view whose `match` suits what is actually there — a collection of photographs\n * opens as a grid without anyone asking.\n * 4. The highest priority, which is the list.\n *\n * A hint naming a view this build doesn't have is ignored, not an error: the transformer\n * is deployment configuration and may outlive the build it was written against.\n *\n * PURE. It used to take `platform` and read the contribution registry, the context keys and\n * the settings mid-render — three reads that nothing invalidated on, so the launcher only\n * kept up because the shell's snapshot was coarse enough to redraw it anyway. The reactive\n * half is the `views` query now; what is left is arithmetic over the items already on\n * screen, which is the one input that cannot be a query (there is no sensible key for \"these\n * forty search results\").\n *\n * @param {{views: Array, saved: string|null}} slice from the `views` query\n * @param {Array} items the rows being drawn, `{ node }`-shaped\n * @param {string|null} hint the search transformer's suggestion, if this is a search\n */\nexport function pickView({ views = [], saved = null } = {}, items = [], hint = null) {\n if (!views.length) return null;\n const chosen = saved && views.find((v) => v.id === saved);\n if (chosen) return chosen;\n const suggested = hint && views.find((v) => v.id === hint);\n if (suggested) return suggested;\n const nodes = items.map((i) => i.node).filter(Boolean);\n if (nodes.length >= 3) {\n const suits = (v) => v.match && Object.keys(v.match).length\n && nodes.filter((n) => matchesView(v, n)).length / nodes.length > 0.6;\n const fitted = views.find(suits);\n if (fitted) return fitted;\n }\n return views[0];\n}\n\nfunction matchesView(view, node) {\n const ct = node.contentType || '';\n const name = (node.name || '').toLowerCase();\n const ext = name.includes('.') ? name.slice(name.lastIndexOf('.')) : '';\n if ((view.match.ext || []).includes(ext)) return true;\n return (view.match.mime || []).some((m) => (m.endsWith('/*') ? ct.startsWith(m.slice(0, -1)) : ct === m));\n}\n",
85
+ "// The drive's state, as engine queries.\n//\n// The web layer grew a second reactive system beside the engine: services holding cells, a\n// `platform` bag of subsystems, an `app` bag of stores, and one derived snapshot threaded\n// through every component. ngin already had all of it — see queries.js in the package:\n// `QueryController` is \"one live realization of a query instance, shared by all of its\n// observers\", `boot`/`kill` bracket a query's life, and a lease holds the providers it needs\n// for exactly that long.\n//\n// That move is DONE. The state bags became slices (see bl/state.js) and most of these\n// queries now view a slice rather than wrapping a service — which is why the base class is\n// `CellQuery`: one cell, viewed, whatever is behind it. `ViewQuery` is the other shape,\n// composing several cells into an answer the UI actually asks for.\n//\n// Four resources stayed services because they cover something a state bag cannot — history\n// and recents, polling, a queue that replays on reconnect — and they answer `get()` and\n// `observe()` like everything else, so a query cannot tell which it is looking at.\n//\n// INSTANCE IDENTITY IS THE SHARING KEY. ngin keys live realizations by the query INSTANCE —\n// `#controllers` is a Map keyed on the object — and nothing anywhere looks at the class or\n// the fields. So `new Explorer()` twice is two realizations, two boots and two subscriptions\n// to the same underlying cell, quietly, because nothing fails.\n//\n// Two instances carrying the SAME arguments are still two instances. `new MediaUrl('n1')`\n// twice mints two URLs and holds two leases for one file. That is the trap, and \"remember to\n// memoise\" is not a defence: forgetting is silent, and it is the parameterised queries —\n// exactly the ones worth sharing — that need it.\n//\n// So a parameterised query declares `static of = queryOf(TheClass)` and is asked for rather\n// than constructed: the same arguments give back the same instance, which makes identity\n// mean logical equality and lets both ngin's cache and watchQuery's work. See bl/intern.js.\n// Parameterless queries are exported as singletons below. Either way the CLASSES stay\n// private to this module and only instances leave it — which is also what stops anyone\n// calling `new` on a shared query and quietly getting a second realization.\n\nimport { Query } from '@3sln/ngin';\nimport { queryOf } from './intern.js';\nimport { selectedNodesOf, draftScopesOf, collectionMenuOf, collectionAdminOf } from './services.js';\nimport {\n ExecCommandAction, LoadSidecarAction, ClearSidecarAction, LoadRotationAction, LoadGrantsAction,\n LoadApiKeysAction, ShowCollectionAccessAction,\n} from './actions.js';\nimport { ASSOC_KEY, describeOpener } from './openers.js';\nimport { rankCommands } from './match.js';\nimport { statusFactsOf, driveConditionOf } from './status.js';\nimport { launcherGroupsOf, launcherMode, searchHelpOf } from './launcher.js';\nimport { pickView } from './views.js';\nimport { prettyKey } from '../platform/keybindings.js';\n\n/**\n * A live query over ONE cell — whatever holds it.\n *\n * Named for what it does rather than for what used to be behind it: most of these view a\n * slice now, not a service, and `ServiceQuery` told a reader its dep was a service when\n * usually it is not. `ViewQuery` below is the other shape, composing several cells.\n *\n * The resource exposes dodo's Cell protocol — `onDirty(fn)` to learn it changed,\n * `getValue()` to read it — and a query wants push. Bridging is two lines, so rather than\n * write them per resource this takes the cell as a function of the leased one.\n *\n * It reads the CELL and nothing else. That is not a stylistic preference: `settings`' cell\n * holds `effective()`, the defaults merged with the overrides, which no field anywhere\n * holds. Reading the cell is what makes these queries and the shell's snapshot describe the\n * same state rather than two subtly different ones.\n */\nclass CellQuery extends Query {\n /**\n * @param {string} dep the engine resource this views\n * @param {(resource: object) => {onDirty: Function, getValue: Function}} cellOf\n */\n /** Empty at the class level; the lease is per instance — see `deps` below. */\n static deps = [];\n\n /**\n * @param {string} dep the engine resource this views\n * @param {(resource: object) => {onDirty: Function, getValue: Function}} cellOf\n * @param {(value: any, resource: object) => any} [project] shape the value into a view\n * @param {{bootAction?: object}} [opts] dispatched when the first observer arrives — for\n * a value that has to be FETCHED before there is anything to view.\n */\n constructor(dep, cellOf, project, { bootAction = null } = {}) {\n super();\n this.dep = dep;\n this.cellOf = cellOf;\n this.project = project;\n if (bootAction) this.bootAction = bootAction;\n }\n\n /**\n * Leased per instance rather than per class, because these all share one class and each\n * views a different resource. ngin leases `constructor.deps` AND `this.deps`, so an\n * instance can name its own.\n */\n get deps() {\n return [this.dep, 'appState'];\n }\n\n boot(resources, { notify }) {\n const cell = this.cellOf(resources[this.dep]);\n // A service may not exist in every build — `plugins` is absent when the plugin host is\n // not installed, which is why the snapshot has a `?? constant([])` beside it.\n if (!cell) {\n notify(null);\n return;\n }\n const resource = resources[this.dep];\n const read = () => (this.project ? this.project(cell.getValue(), resource) : cell.getValue());\n // The current value first: a subscriber that arrives after the last change should not\n // wait for the next one to find out what is true now.\n notify(read());\n hold(resources, this, cell.onDirty(() => notify(read())));\n }\n\n kill(resources) {\n release(resources, this);\n }\n}\n\n/**\n * Where a live query keeps its subscription.\n *\n * NOT on the query. These instances are module-level singletons, interned so that the same\n * arguments give back the same object — which is what makes ngin share one realization per\n * engine. Writing `this.off` on a shared instance is therefore writing per-REALIZATION\n * state onto something that outlives any one of them: two engines observing the same\n * instance boot it twice, the second overwrites the first's unsubscribe, and killing either\n * releases the wrong one while the other leaks.\n *\n * `appState` is a provider, so it is per engine; keyed by the instance, an entry is per\n * (engine, instance) — which is exactly one realization. The query stays a description of\n * what to watch, and nothing about it changes when it is being watched.\n */\nfunction hold(resources, query, off) {\n resources.appState.set(query, off);\n}\n\nfunction release(resources, query) {\n const off = resources.appState?.get(query);\n if (Array.isArray(off)) off.forEach((fn) => fn());\n else off?.();\n resources.appState?.delete(query);\n}\n\n// --- the drive -----------------------------------------------------------------\n\n/**\n * Items, selection, the open collection, and the gate — plus the nodes the selection\n * actually refers to.\n *\n * `selectedNodes` is folded in rather than left as something to call, because resolving it\n * is not trivial: ids alone only match the loaded page of the current collection, and the\n * launcher's rows come from search across every readable one. A view that hands over the\n * answer is the difference between a component knowing what is selected and a component\n * knowing how selection resolution works.\n */\nexport const explorer = new CellQuery('explorer', (r) => r.observe(), (v) => ({\n ...v,\n selectedNodes: selectedNodesOf(v),\n // The collection switcher's rows. In the view because it is a question about state, and\n // because the component that shows it could not otherwise see where it came from.\n collectionMenu: collectionMenuOf(v,\n (id) => new ExecCommandAction('collections.switch', id),\n () => new ExecCommandAction('collections.create')),\n // The administration screen's view of the same collections: what each is on, whether it\n // is sealed, and what may be done to it.\n collectionAdmin: collectionAdminOf(v, {\n open: (id) => new ExecCommandAction('collections.switch', id),\n scan: () => new ExecCommandAction('workbench.scanCollection'),\n rotate: () => new ExecCommandAction('workbench.openSettings'),\n create: () => new ExecCommandAction('collections.create'),\n access: (id) => new ShowCollectionAccessAction(id),\n }),\n}));\n/** Query text, results, and the palette's file list. */\nexport const search = new CellQuery('search', (r) => r.observe());\n/** Uploads and downloads in flight. */\nexport const transfers = new CellQuery('transfers', (r) => r.observe());\n/** Running tasks and standing issues, both sides of the wire. */\nexport const activity = new CellQuery('activity', (r) => r.observe());\n/** Conversations, tags and backlinks for the open item. */\nexport const social = new CellQuery('social', (r) => r.observe());\n/**\n * Online state, pinned files, and the queue waiting to sync.\n *\n * `pinnedIds` is folded in so a component can ask whether THIS file is pinned without\n * calling a method on the service to find out. A Set rather than a repeated scan: the\n * question is asked once per row.\n */\nexport const offline = new CellQuery('offline', (r) => r.observe(),\n (v) => ({ ...v, pinnedIds: new Set((v?.pins || []).map((p) => p.id)) }));\n/**\n * The open collection's key, and any rotation running over it.\n *\n * Keyed by collection, so switching collections is a different query rather than a change\n * to notice. `bootAction` loads it when the settings screen first looks — the alternative,\n * which the API-keys section still does, is to dispatch from inside a render behind a\n * module-level \"have I asked yet\" flag, which is a render with a side effect.\n *\n * It POLLS while a rotation is running, because the work is happening on the server and\n * there is nothing to push. The interval belongs to the realization: it starts when\n * somebody looks and stops when they look away, so a settings screen nobody has open costs\n * nothing.\n */\nexport const rotationFor = (collectionId) => RotationView.of(collectionId);\n\nclass RotationView extends Query {\n static deps = ['rotation', 'appState', 'engine'];\n static of = queryOf(RotationView);\n\n constructor(collectionId) {\n super();\n this.collectionId = collectionId;\n // The id is PASSED, so the load stops depending on `explorer` happening to agree with\n // the query's key — which is what makes the key mean anything at all.\n this.bootAction = new LoadRotationAction(collectionId);\n }\n\n boot(r, { notify }) {\n const cell = r.rotation.observe();\n notify(cell.getValue());\n const off = cell.onDirty(() => notify(cell.getValue()));\n const timer = setInterval(() => {\n if (r.rotation.get().rotation?.status === 'running') r.engine.dispatch(new LoadRotationAction(this.collectionId));\n }, 2500);\n hold(r, this, [off, () => clearInterval(timer)]);\n }\n\n kill(r) {\n release(r, this);\n }\n}\n/**\n * Who may do what on one collection.\n *\n * Keyed by collection and loaded by `bootAction`, the same shape as `rotationFor` above —\n * it loads when an administrator opens the row and stops mattering when they close it.\n * No polling: an ACL only changes when somebody changes it, and the action that does so\n * reloads.\n */\nexport const grantsFor = (collectionId) => GrantsView.of(collectionId);\n\nclass GrantsView extends Query {\n static deps = ['acl', 'appState'];\n static of = queryOf(GrantsView);\n\n constructor(collectionId) {\n super();\n this.collectionId = collectionId;\n this.bootAction = new LoadGrantsAction(collectionId);\n }\n\n boot(r, { notify }) {\n const cell = r.acl.observe();\n notify(cell.getValue());\n hold(r, this, cell.onDirty(() => notify(cell.getValue())));\n }\n\n kill(r) {\n release(r, this);\n }\n}\n\n/**\n * The admin API-key list, with the unsubmitted draft resolved into what it would grant.\n *\n * `bootAction`, like `rotationFor` and `grantsFor`: it loads when the settings region is\n * first realized and the list is admin-only, so most sessions never ask. The alternative\n * was what this section used to do — dispatch from inside a render behind a module-level\n * \"have I asked yet\" flag, which is a render with a side effect, and module state the\n * engine cannot see or reset. A second `createWorkbench` on the page (a documented\n * embedding entry point) found the flag already true against a fresh slice and never\n * loaded at all.\n */\nexport const apiKeys = new CellQuery('apiKeys', (r) => r.observe(),\n (v) => ({ ...v, draftScopes: draftScopesOf(v) }),\n { bootAction: new LoadApiKeysAction() });\n\n// --- the shell -----------------------------------------------------------------\n\n/** Which activity is showing, and the rest of the shell's own state. */\nexport const workbench = new CellQuery('workbench', (r) => r.observe());\n/** The tab and panel stack. */\nexport const navigation = new CellQuery('navigation', (r) => r.observe());\n/** Dialogs, menus and panels. */\nexport const overlay = new CellQuery('overlay', (r) => r.observe());\n/** Toasts. */\nexport const notifications = new CellQuery('notifications', (r) => r.observe());\n/** Settings, defaults merged with overrides. */\nexport const settings = new CellQuery('settings', (r) => r.observe());\n/**\n * The settings SCHEMA, grouped by category, for the screen that edits them.\n *\n * Separate from `settings` rather than folded in, because that one emits the effective\n * values keyed by setting name — adding a `groups` key to it would put a made-up entry in\n * among the real ones.\n */\nexport const settingsGroups = new CellQuery('settings', (r) => r.observe(), (_v, r) => r.grouped());\n\n/** The when-clause keys: what is selected, what is open, what is focused. */\nexport const context = new CellQuery('context', (r) => r.observe());\n/** Phone, desktop or TV. */\nexport const viewport = new CellQuery('viewport', (r) => r.observe());\n/**\n * Whether this browser can transcribe on-device, and whether it is listening now.\n *\n * `canListen` is folded in: it is a question about the state, so a component should not\n * have to call the service to find out.\n */\nexport const voice = new CellQuery('voice', (r) => r.observe(),\n (v, r) => ({ ...v, canListen: !!r.canListen?.() }));\n/** Installed plugins; null where the plugin host is not installed. */\nexport const plugins = new CellQuery('plugins', (r) => r?.observe?.());\n/** What the UI is in the middle of doing: drafts, captures, ticked boxes. See viewState.js. */\nexport const viewState = new CellQuery('viewState', (r) => r.observe());\n\n// --- view queries ---------------------------------------------------------------\n//\n// The ones above hand a service's state through unchanged. These COMPOSE: they answer a\n// question the UI actually asks, in plain renderable data, with every decision already made.\n//\n// The rule, and it is the important one: a query emits a VIEW, never a handle. A list of\n// commands is a list of descriptions — id, title, whether it is enabled right now — not the\n// command objects, and never a `run` function. Interaction goes the other way, as an action\n// carrying the thing's id. So a component renders what it is given and dispatches an id; it\n// does not reach into a service to find out whether to draw something, and it cannot reach\n// into one to make something happen.\n//\n// That is what takes `platform` out of the components. The status bar used to ask\n// `context.evaluate(item.when)` and `plugins.isAvailable(item)` per item, mid-render, which\n// is why it needed the bag at all. Those are view decisions; they belong on this side.\n\n/**\n * A query composed from several services rather than passed through from one.\n *\n * `sources` names the cells whose changes should recompute it; `project` builds the value.\n * Split apart because what a view DEPENDS on is usually wider than what it reads from —\n * the palette's command list changes when a contribution is registered, but also when a\n * context key flips, because that is what decides `enabled`.\n */\nclass ViewQuery extends Query {\n static deps = [];\n\n /**\n * @param {string[]} deps the engine resources this composes\n * @param {(r: object) => Array<{onDirty: Function}>} sources\n * @param {(r: object) => any} project must return plain data — see the note above\n */\n constructor(deps, sources, project) {\n super();\n this.deps = [...deps, 'appState'];\n this.sources = sources;\n this.project = project;\n }\n\n boot(r, { notify }) {\n const emit = () => notify(this.project(r));\n emit();\n hold(r, this, this.sources(r).filter(Boolean).map((c) => c.onDirty(emit)));\n }\n\n kill(r) {\n release(r, this);\n }\n}\n\n/** Contributions, context keys and plugin health — what most of these views depend on. */\nconst REGISTRY_DEPS = ['contributions', 'context', 'plugins', 'settings', 'commands', 'keybindings'];\nconst registries = (r) => [\n r.contributions.observe(),\n r.context.observe(),\n r.plugins?.observe?.(),\n r.settings.observe(),\n];\n\n/**\n * The command palette's list: every palette command, with its keybinding label resolved\n * and `enabled` already decided.\n *\n * No `when` expression and no handler. A component shows the title, greys out what is\n * disabled, and dispatches `ExecCommandAction(id)`.\n */\nfunction paletteCommandsOf(r) {\n return r.commands.paletteCommands().map((c) => ({\n id: c.id,\n title: c.title ?? c.id,\n category: c.category ?? null,\n icon: c.icon ?? null,\n keybinding: r.keybindings.labelFor(c.id),\n // Only `available` — the plugin behind this command being reachable. There was an\n // `enabled` beside it, under a paragraph explaining that collapsing the two would tag a\n // context-disabled command as \"offline\", and the code made the distinction impossible:\n // `paletteCommands()` has already dropped every when-clause failure, so for every row\n // that survives, `isEnabled` re-evaluates the same clause against the same registry and\n // agrees with `isAvailable` by construction. Nothing rendered it. If greying a gated\n // command out with a reason is wanted, do the other half — stop filtering in\n // `paletteCommands()` — rather than keeping the label for a state that cannot occur.\n available: r.commands.isAvailable(c),\n }));\n}\n\n// The same list, narrowed to what was typed.\n//\n// Ranking used to happen mid-render, in two components, with two different algorithms (see\n// bl/match.js). The typed term is engine state — the palette's lives in the overlay — so\n// this is an ordinary query with no arguments, and the ranking is settled before a\n// component sees anything. The launcher's `!` mode ranks the same way inside\n// `launcherContent`, which already holds everything it needs.\nconst OVERLAY_DEPS = [...REGISTRY_DEPS, 'overlay', 'workbench'];\nconst withShell = (r) => [...registries(r), r.workbench.observe(), r.overlay.observe()];\n\n/** What the command palette should list right now. */\nexport const paletteMatches = new ViewQuery(OVERLAY_DEPS, withShell, (r) =>\n rankCommands(paletteCommandsOf(r), r.overlay.get().palette?.query || ''));\n\n\n/**\n * Plugin-contributed status bar slots, already filtered to the ones that should show.\n *\n * `when` and availability are resolved here rather than in the render, which is the whole\n * reason the status bar had to carry `platform` at all. `html` is still untrusted plugin\n * markup and is still sanitised at the point it becomes nodes — a query emitting plain data\n * says nothing about that data being safe.\n */\nexport const statusItems = new ViewQuery(REGISTRY_DEPS, registries, (r) => {\n return r.contributions.ofType('statusItem')\n .filter((i) => i.visible !== false && i.html)\n .filter((i) => !i.when || r.context.evaluate(i.when))\n .filter((i) => r.plugins?.isAvailable?.(i) ?? true)\n .sort((a, b) => (a.order ?? 0) - (b.order ?? 0) || String(a.name).localeCompare(String(b.name)))\n .map((i) => ({\n id: i.id,\n slot: i.slot === 'left' ? 'left' : 'right',\n html: i.html,\n tooltip: i.tooltip ?? null,\n command: i.command ?? null,\n }));\n});\n\n/**\n * The effective keybindings, for the settings view: what is bound to what, right now.\n *\n * Everything the UI decides from is decided here — the command's title, whether the binding\n * is a user override, and whether another command answers to the same chord. That last one\n * is why the view carries `clash`: nothing rejects a collision and `#matchFor` scans in\n * reverse so the LAST registration wins, which means binding Delete onto ⌘P silently stops\n * Quick Open from opening. Detecting that needs the whole list at once, which is exactly the\n * sort of thing a component rendering one row cannot do and a view can.\n */\nexport const keybindings = new ViewQuery(REGISTRY_DEPS, registries, (r) => {\n const resolved = r.keybindings.resolved();\n const overrides = r.keybindings.overrides();\n const perKey = new Map();\n for (const b of resolved) perKey.set(b.key, (perKey.get(b.key) || 0) + 1);\n return resolved.map((b) => ({\n bindingId: b.bindingId,\n command: b.command,\n title: r.contributions.get(b.command)?.title ?? b.command,\n key: b.key,\n label: prettyKey(b.key),\n custom: !!overrides[b.bindingId],\n clash: perKey.get(b.key) > 1,\n }));\n});\n\n/**\n * What the launcher is showing: its groups, the view drawing them, and the help offered\n * when a search found nothing. See bl/launcher.js.\n *\n * Parameterised by `modal` — the double-shift overlay and the home screen are BOTH on\n * screen when the overlay is up, so which instance is rendering is the one input that\n * genuinely is not engine state. Two values, so interning gives at most two realizations.\n *\n * `view` is folded in because choosing it needs the items, and the items are right here.\n * That was the last thing keeping `pickView` outside the engine.\n */\nexport const launcherContent = (modal = false) => LauncherContent.of(!!modal);\n\nconst LAUNCHER_DEPS = [...REGISTRY_DEPS, 'explorer', 'search', 'workbench', 'navigation', 'offline', 'capabilities'];\n\nclass LauncherContent extends ViewQuery {\n static of = queryOf(LauncherContent);\n\n constructor(modal) {\n super(\n LAUNCHER_DEPS,\n (r) => [\n ...registries(r),\n r.explorer.observe(), r.search.observe(),\n r.workbench.observe(), r.navigation.observe(), r.offline.observe(),\n // Capabilities arrive after the first render — the provider hands out a cell that\n // fills in — so this has to be watched, not merely read, or the search help would\n // never appear on a drive whose prompt the server supplies.\n r.capabilities,\n ],\n (r) => {\n const wb = r.workbench.get();\n const off = r.offline.observe().getValue() || {};\n const slices = {\n ex: r.explorer.observe().getValue() || {},\n se: r.search.observe().getValue() || {},\n nav: r.navigation.observe().getValue() || {},\n query: wb.launch.query || '',\n commandMatches: rankCommands(paletteCommandsOf(r), (wb.launch.query || '').slice(1)),\n pinnedIds: new Set((off.pins || []).map((p) => p.id)),\n keys: commandKeysOf(r),\n };\n const groups = launcherGroupsOf(slices, this.modal);\n const mode = launcherMode(slices.query);\n return {\n groups,\n mode,\n // Which view draws them. Needs the nodes on screen, which is exactly what this\n // query has just worked out — see bl/views.js. This was the last thing keeping\n // the choice outside the engine.\n view: pickView(viewsOf(r), groups.flatMap((g) => g.items),\n mode === 'search' ? slices.se.resolved?.view ?? null : null),\n // What to offer when a search found nothing. Both halves are here now: whether\n // an offer applies at all (a search ran, it succeeded, it found nothing) and\n // what to suggest, which the server decides — see the `capabilities` resource.\n help: searchHelpOf({\n eligible: mode !== 'command'\n && !!slices.se.ran && !slices.se.loading && !slices.se.error\n && !(slices.se.results || []).length,\n caps: r.capabilities.getValue(),\n }),\n };\n },\n );\n this.modal = modal;\n }\n}\n\n/**\n * What the drive is doing and how full it is — see bl/status.js.\n *\n * Both shells render these, in different shapes. Derived once, here, because the last time\n * each worked them out for itself the phone bar showed a raw `col_…` id where the desktop\n * bar showed the collection's name.\n */\nexport const statusFacts = new ViewQuery(\n ['explorer', 'transfers', 'activity', 'offline'],\n (r) => [r.explorer.observe(), r.transfers.observe(), r.activity.observe(), r.offline.observe()],\n (r) => {\n const facts = statusFactsOf({\n ex: r.explorer.observe().getValue(),\n tr: r.transfers.observe().getValue(),\n act: r.activity.observe().getValue(),\n off: r.offline.observe().getValue(),\n });\n // The single most urgent thing, for a shell with room for one glyph. Folded in rather\n // than left to the phone, because deciding that offline outranks a standing problem is\n // a claim about what someone needs to know.\n return { ...facts, condition: driveConditionOf(facts) };\n },\n);\n\n/**\n * Every opener that could run right now — `when` and plugin availability already decided,\n * and the plugin's display name resolved into `source`.\n *\n * The SELECTOR is left on, which is the whole trick: which openers exist is a question\n * about engine state and belongs here, but which of them suits the file a component is\n * drawing is pure matching against data that component already holds. So the query answers\n * the reactive half and `openersFor` (a pure function, below) answers the rest — rather\n * than the query being parameterised by a node, which would need one live realization per\n * file on screen.\n *\n * Descriptors, not contributions: no `component`, no `entry`. Rendering resolves the\n * callable by id — see ui/components/openers.\n */\nexport const openers = new ViewQuery(REGISTRY_DEPS, registries, (r) =>\n r.contributions.ofType('opener')\n .filter((o) => !o.when || r.context.evaluate(o.when))\n .filter((o) => r.plugins?.isAvailable?.(o) ?? true)\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))\n .map((o) => describeOpener(o, r.plugins)));\n\n/**\n * How results can be drawn, and which one the user pinned.\n *\n * `saved` travels with the list because choosing between them needs both, and a component\n * that had to fetch the setting separately would be reaching for `settings` mid-render —\n * which is what this replaces. The CHOICE itself is `pickView`, a pure function, because it\n * also depends on the items on screen, and items are not something to key a query by.\n *\n * `render` and `move` come along. The rule about a query emitting a view rather than a\n * handle is about SIDE EFFECTS — a `run()` that mutates the drive is a back door around\n * actions and the feed. A view's renderer is a pure vnode builder over the arguments it is\n * given, so passing it is passing data; making the component look it up by id would have\n * been the registry access this is trying to remove, relocated rather than deleted.\n */\nexport const views = new ViewQuery(REGISTRY_DEPS, registries, viewsOf);\n\nfunction viewsOf(r) {\n return {\n views: r.contributions.ofType('view')\n .filter((v) => !v.when || r.context.evaluate(v.when))\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))\n .map((v) => ({\n id: v.id,\n title: v.title ?? v.name ?? v.id,\n icon: v.icon ?? null,\n match: v.match ?? null,\n render: v.render,\n move: v.move,\n })),\n saved: r.settings.get('explorer.view') || null,\n };\n}\n\n/**\n * The saved \"always open .pdf with…\" choices, for the settings screen.\n *\n * `missing` is decided here: an association can name an opener that has since been\n * uninstalled, and the row has to say so rather than showing a bare id.\n */\nexport const openerAssociations = new ViewQuery(REGISTRY_DEPS, registries, (r) => {\n const assoc = r.settings.get(ASSOC_KEY) || {};\n return Object.entries(assoc).map(([typeKey, openerId]) => {\n const opener = r.contributions.get(openerId);\n return { typeKey, openerId, openerTitle: opener?.title || openerId, missing: !opener };\n });\n});\n\n/**\n * The conversation, tags and backlinks for one file.\n *\n * Keyed by node, and the KEY is what replaces a reaction. This used to be an `effect` in\n * bl/index.js watching the nav stack with a module-scoped `let lastTab` for change\n * detection, calling `social.loadSidecar` directly — a subscription outside the engine\n * doing effect work, and the last place that still worked that way.\n *\n * ngin already brackets this. `bootAction` is dispatched when the first observer arrives\n * and `killAction` when the last one leaves, so opening a file loads its conversation and\n * closing it clears it, because the query is alive for exactly as long as something is\n * looking. Switching files is not a change to detect: it is one instance dying and another\n * booting.\n *\n * The clear is SCOPED to this node. Kill and boot are not ordered against each other, so\n * switching from A to B can kill A after B has booted — an unscoped clear would then wipe\n * the sidecar B just asked for. It is the same race the loading path already guards, and\n * naming the node is what makes it impossible rather than unlikely.\n */\nexport const sidecarFor = (nodeId) => Sidecar.of(nodeId);\n\nclass Sidecar extends CellQuery {\n static of = queryOf(Sidecar);\n\n constructor(nodeId) {\n super('social', (r) => r.observe(), (v) => v?.sidecar ?? null);\n this.nodeId = nodeId;\n this.bootAction = new LoadSidecarAction(nodeId);\n this.killAction = new ClearSidecarAction(nodeId);\n }\n}\n\n/**\n * A file's text, capped.\n *\n * The first query keyed by something unbounded, which is what `queryOf` interning and the\n * weak eviction were built for: one instance per (node, cap), shared by every viewer\n * looking at that file, and collected once nothing is. A viewer that scrolls out of the\n * tree stops observing, ngin kills the realization, and the text goes with it — no cache\n * to invalidate and nothing to remember to release.\n *\n * `size` is a hint the API uses to decide whether a range request is worth it. It is part\n * of the key because it is part of the request, and it is derived from the node id anyway,\n * so it cannot split one file into two entries.\n *\n * Capped at the TRANSFER, not just the render: a character limit in a viewer stops us\n * laying out a huge document, but the whole file still crosses the wire without this.\n */\nexport class FileText extends Query {\n static deps = ['api'];\n\n static of = queryOf(FileText);\n\n constructor(nodeId, maxBytes, size) {\n super();\n this.nodeId = nodeId;\n this.maxBytes = maxBytes;\n this.size = size;\n }\n\n async boot({ api }, { notify }) {\n notify(await api.readTextCapped(this.nodeId, { maxBytes: this.maxBytes, size: this.size }));\n }\n\n kill() {}\n}\n\n/**\n * Command id → its keybinding label, for anything that shows a shortcut next to an action.\n *\n * Hardcoding \"⌘⇧L\" told a Windows or Linux user about a key their machine does not have,\n * and told everyone the default even after they had rebound it. A map rather than a list\n * because every caller is asking about one command it already knows the id of.\n */\nexport const commandKeys = new ViewQuery(REGISTRY_DEPS, registries, commandKeysOf);\n\nfunction commandKeysOf(r) {\n return Object.fromEntries(r.keybindings.resolved()\n .map((b) => [b.command, r.keybindings.labelFor(b.command)])\n .filter(([, label]) => label));\n}\n\n/**\n * What this deployment can do.\n *\n * A plain view over the `capabilities` resource — see bl/index.js, where the provider hands\n * out a cell that fills in once the server answers. This used to be a query that kept the\n * PROMISE on its own instance so a re-boot would not re-fetch, which is a cache with no\n * invalidation living inside a view; and it needed `initial = null` to stop the shell going\n * PENDING while the request was in flight. Both go away when the fetch belongs to the\n * provider: the cell already holds null, and reading a cell is all this does.\n */\nexport const capabilities = new CellQuery('capabilities', (r) => r);\n",
86
+ "// Inline SVG icons. One function, a path table, sized via viewBox 24. Using\n// dodo's element helpers so icons are just vnodes like everything else.\n\nimport { dd } from '../runtime.js';\n\nconst { svg, h } = dd;\n\n// Each entry is an array of <path>/<primitive> specs (attrs use SVG names).\nconst PATHS = {\n link: [{ d: 'M10 13a5 5 0 0 0 7.07 0l3-3A5 5 0 0 0 13 3l-1.5 1.5' }, { d: 'M14 11a5 5 0 0 0-7.07 0l-3 3A5 5 0 0 0 11 21l1.5-1.5' }],\n file: [{ d: 'M6 3h8l5 5v13a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z' }, { d: 'M14 3v5h5' }],\n 'file-text': [{ d: 'M6 3h8l5 5v13a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z' }, { d: 'M14 3v5h5M9 13h6M9 17h6M9 9h2' }],\n 'file-image': [{ d: 'M6 3h8l5 5v13a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z' }, { d: 'M14 3v5h5' }, { d: 'M8.5 15l2-2 3 3 2-1.5' }, { d: 'M10 12a1 1 0 1 0 0-.01' }],\n 'file-audio': [{ d: 'M6 3h8l5 5v13a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z' }, { d: 'M14 3v5h5M10 12v5M13 10v9' }],\n 'file-video': [{ d: 'M6 3h8l5 5v13a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z' }, { d: 'M14 3v5h5M10 12l4 2.5-4 2.5z' }],\n book: [{ d: 'M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z' }, { d: 'M4 19a2 2 0 0 1 2-2h13' }],\n search: [{ d: 'M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14zM20 20l-3.5-3.5' }],\n mic: [{ d: 'M12 3a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V6a3 3 0 0 0-3-3z' }, { d: 'M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6' }],\n command: [{ d: 'M8 6a2 2 0 1 0-2 2h12a2 2 0 1 0-2-2v12a2 2 0 1 0 2-2H6a2 2 0 1 0 2 2z' }],\n gear: [{ d: 'M12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z' }, { d: 'M19 12a7 7 0 0 0-.1-1.2l2-1.6-2-3.4-2.4 1a7 7 0 0 0-2-1.2L14 2h-4l-.5 2.6a7 7 0 0 0-2 1.2l-2.4-1-2 3.4 2 1.6A7 7 0 0 0 5 12a7 7 0 0 0 .1 1.2l-2 1.6 2 3.4 2.4-1a7 7 0 0 0 2 1.2L10 22h4l.5-2.6a7 7 0 0 0 2-1.2l2.4 1 2-3.4-2-1.6A7 7 0 0 0 19 12z' }],\n upload: [{ d: 'M12 16V4M7 9l5-5 5 5M4 20h16' }],\n download: [{ d: 'M12 4v12M7 11l5 5 5-5M4 20h16' }],\n trash: [{ d: 'M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 11v6M14 11v6' }],\n refresh: [{ d: 'M20 11a8 8 0 1 0-.5 4M20 5v6h-6' }],\n 'chevron-right': [{ d: 'M9 6l6 6-6 6' }],\n 'chevron-left': [{ d: 'M15 6l-6 6 6 6' }],\n 'chevron-down': [{ d: 'M6 9l6 6 6-6' }],\n close: [{ d: 'M6 6l12 12M18 6L6 18' }],\n tag: [{ d: 'M4 4h6.5a1 1 0 0 1 .7.3l8.5 8.5a1 1 0 0 1 0 1.4l-5.5 5.5a1 1 0 0 1-1.4 0L4.3 11.2a1 1 0 0 1-.3-.7V4z' }, { d: 'M8 8a0.6 0.6 0 1 0 0-.01' }],\n play: [{ d: 'M8 5v14l11-7z', fill: 'currentColor', stroke: 'none' }],\n pause: [{ d: 'M8 5h3v14H8zM13 5h3v14h-3z', fill: 'currentColor', stroke: 'none' }],\n 'skip-back': [{ d: 'M11 6v12L3 12zM13 6l8 6-8 6zM21 6v12', fill: 'none' }],\n 'skip-forward': [{ d: 'M13 6v12l8-6zM3 6l8 6-8 6zM3 6v12' }],\n 'back-30': [{ d: 'M11 8a7 7 0 1 0 7 7' }, { d: 'M11 4l-3 4 4 1' }],\n 'fwd-30': [{ d: 'M13 8a7 7 0 1 1-7 7' }, { d: 'M13 4l3 4-4 1' }],\n plug: [{ d: 'M9 3v6M15 3v6M6 9h12v3a6 6 0 0 1-12 0zM12 18v3' }],\n bell: [{ d: 'M18 8a6 6 0 1 0-12 0c0 7-3 9-3 9h18s-3-2-3-9z' }, { d: 'M13.73 21a2 2 0 0 1-3.46 0' }],\n files: [{ d: 'M4 4h9l3 3v3M8 8h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2v-9a2 2 0 0 1 2-2z' }],\n dots: [{ d: 'M5 12h.01M12 12h.01M19 12h.01' }],\n check: [{ d: 'M5 12l5 5L20 6' }],\n plus: [{ d: 'M12 5v14M5 12h14' }],\n 'arrow-up': [{ d: 'M12 19V5M6 11l6-6 6 6' }],\n star: [{ d: 'M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z' }],\n info: [{ d: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM12 11v5M12 8h.01' }],\n warn: [{ d: 'M12 3l9 16H3zM12 10v4M12 17h.01' }],\n x: [{ d: 'M6 6l12 12M18 6L6 18' }],\n list: [{ d: 'M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01' }],\n grid: [{ d: 'M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z' }],\n};\n\n// Map a node to an icon name via the shared file-type classifier.\nexport { iconForKind as iconForNode } from '../bl/fileType.js';\n\nexport function icon(name, { size = 18, strokeWidth = 1.6, className } = {}) {\n // `Object.hasOwn`, not a bare lookup: `PATHS` is a plain object, so a contribution\n // declaring `\"icon\": \"constructor\"` (kept verbatim from the manifest) otherwise\n // resolves to a function and takes down the whole render with `specs.map is not a\n // function`.\n const specs = Object.hasOwn(PATHS, name) ? PATHS[name] : PATHS.file;\n // `class` through `$attrs`, not `className`. An SVGElement's `className` is a\n // read-only SVGAnimatedString, so the prop is written out as a literal `className=\"…\"`\n // attribute — which no selector matches. `.sheet-row .sr-go` was styling nothing.\n return svg(\n {\n $attrs: {\n viewBox: '0 0 24 24', width: size, height: size, fill: 'none',\n stroke: 'currentColor', 'stroke-width': strokeWidth,\n 'stroke-linecap': 'round', 'stroke-linejoin': 'round',\n ...(className ? { class: className } : {}),\n },\n },\n ...specs.map((s) => h('path', { $attrs: filterAttrs(s) })),\n );\n}\n\nfunction filterAttrs(s) {\n const out = { d: s.d };\n if (s.fill) out.fill = s.fill;\n if (s.stroke) out.stroke = s.stroke;\n return out;\n}\n",
87
+ "// Formatting helpers for the UI.\n\nexport function bytes(n) {\n if (n == null || Number.isNaN(n)) return '—';\n const u = ['B', 'KB', 'MB', 'GB', 'TB'];\n let i = 0;\n let v = n;\n while (v >= 1024 && i < u.length - 1) {\n v /= 1024;\n i++;\n }\n return `${v >= 100 || i === 0 ? Math.round(v) : v.toFixed(1)} ${u[i]}`;\n}\n\nexport function duration(sec) {\n if (sec == null || Number.isNaN(sec) || !isFinite(sec)) return '0:00';\n sec = Math.max(0, Math.floor(sec));\n const h = Math.floor(sec / 3600);\n const m = Math.floor((sec % 3600) / 60);\n const s = sec % 60;\n return h > 0 ? `${h}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}` : `${m}:${String(s).padStart(2, '0')}`;\n}\n\nexport function relativeDate(ms) {\n if (!ms) return '';\n const diff = Date.now() - ms;\n const day = 86400000;\n if (diff < 60000) return 'just now';\n if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`;\n if (diff < day) return `${Math.floor(diff / 3600000)}h ago`;\n if (diff < 7 * day) return `${Math.floor(diff / day)}d ago`;\n return new Date(ms).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: diff > 330 * day ? 'numeric' : undefined });\n}\n",
88
+ "// The `@someone` syntax in a comment body.\n//\n// A sibling of bl/tagQuery.js, which parses the `#tag` syntax — and it sat in the social\n// COMPONENT instead, a regex splitting a text format mid-render. Parsing the drive's own\n// notation is business-layer work wherever it happens to be displayed, and having half of\n// it here and half of it in a view is how the two end up disagreeing about what a name\n// may contain.\n//\n// Two spellings, because they arrive from different places. The resolved form\n// `@[Display Name](user-id)` is what the server writes once it knows who was meant; the\n// bare form `@handle` is what someone types before anything has resolved it.\n\nconst MENTION = /@\\[([^\\]]+)\\]\\(([^)]+)\\)|(?:^|\\s)@([a-zA-Z0-9._@-]{2,})/g;\n\n/**\n * Split a comment body into runs of plain text and mentions.\n *\n * @param {string} body\n * @returns {Array<{type: 'text', value: string} | {type: 'mention', name: string, id: string|null}>}\n */\nexport function parseMentions(body) {\n const text = body || '';\n const out = [];\n const re = new RegExp(MENTION.source, 'g'); // own lastIndex — the module-level one is shared\n let last = 0;\n let m;\n while ((m = re.exec(text))) {\n // The bare form's match deliberately includes the space in front of the `@`, so that\n // \"a@b\" is an address rather than a mention. That leading space belongs to the text\n // run, not to the mention.\n const bare = !!m[3];\n const start = m.index + (bare && m[0].startsWith(' ') ? 1 : 0);\n if (start > last) out.push({ type: 'text', value: text.slice(last, start) });\n out.push({ type: 'mention', name: m[1] || m[3], id: m[2] || null });\n last = re.lastIndex;\n }\n if (last < text.length) out.push({ type: 'text', value: text.slice(last) });\n return out;\n}\n",
89
+ "// Social UI: the notification bell (title bar) and the info panel (a right rail\n// with the active file's tags and threaded conversation). Both render from the\n// reactive SocialService; actions call back into it.\n\nimport { dd } from '../../runtime.js';\nimport { icon } from '../icon.js';\nimport { relativeDate } from '../format.js';\nimport { AddTagAction, CopyTextAction, DeleteCommentAction, EnablePushAction, ExecCommandAction, LoadSidecarAction, OpenFileAction, OpenNotificationTargetAction, PostCommentAction, ReactToCommentAction, RemoveTagAction, SetReplyToAction, ToggleInboxAction, ToggleInfoPanelAction } from '../../bl/actions.js';\nimport { troveUri } from '@3sln/trove/core/links.js';\nimport { parseMentions } from '../../bl/mentions.js';\nimport { sidecarFor } from '../../bl/queries.js';\nimport { watchQuery } from '../../bl/watchQuery.js';\n\nconst { div, span, button, textarea, input, p } = dd;\n\nconst REACTIONS = ['👍', '❤️', '🎉', '👀', '🚀'];\n\n// ---- title-bar principal chip + bell ---------------------------------------\n\nexport function principalChip(state) {\n const me = state.so.me;\n // No identity, no profile. On a deployment with no login the server hands back a\n // shared anonymous stand-in; rendering an avatar and a name for it would describe a\n // user who does not exist, and imply an account there is no way to sign in or out of.\n if (!me || me.anonymous) return null;\n const initial = (me.name || me.id || '?')[0].toUpperCase();\n return div({ className: 'principal', title: me.email || me.name || me.id },\n me.picture ? dd.img({ src: me.picture, alt: '', className: 'avatar-img' }) : span({ className: 'avatar-txt' }, initial),\n );\n}\n\nexport function notificationBell(state, ui) {\n const n = state.so.notifications;\n return div({ className: 'bell-wrap' },\n button({ className: 'iconbtn bell', title: 'Notifications' },\n icon('bell', { size: 19 }),\n n.unread ? span({ className: 'bell-badge' }, String(n.unread > 9 ? '9+' : n.unread)) : null,\n ).on({ click: () => ui.engine.dispatch(new ToggleInboxAction()) }),\n state.so.inboxOpen ? inboxDropdown(state, ui) : null,\n );\n}\n\nfunction inboxDropdown(state, ui) {\n const items = state.so.notifications.items;\n return div({},\n div({ className: 'scrim', $styling: { background: 'transparent', 'z-index': '54' } }).on({ click: () => ui.engine.dispatch(new ToggleInboxAction(false)) }),\n div({ className: 'inbox' },\n div({ className: 'inbox-head' },\n span('Notifications'),\n state.so.pushSupported && !state.so.pushEnabled\n ? button({ className: 'link' }, 'Enable push').on({ click: () => ui.engine.dispatch(new EnablePushAction()) })\n : state.so.pushEnabled ? span({ className: 'muted' }, icon('check', { size: 13 })) : null,\n ),\n items.length\n ? div({ className: 'inbox-items' }, ...items.slice(0, 30).map((note) => inboxItem(note, ui)))\n : div({ className: 'inbox-empty' }, icon('info', { size: 24 }), span('You’re all caught up.')),\n ),\n );\n}\n\nfunction inboxItem(note, ui) {\n const first = note.items?.[0];\n return div({ className: `inbox-item ${note.read ? '' : 'unread'}` },\n div({ className: 'ii-title' }, note.title),\n first?.excerpt ? div({ className: 'ii-excerpt' }, '“' + first.excerpt + '”') : null,\n div({ className: 'ii-time' }, relativeDate(note.createdAt)),\n ).on({\n click: () => {\n // One intent, one action — including what to say when the item a notification\n // points at is gone. See OpenNotificationTargetAction.\n if (first?.nodeId) ui.engine.dispatch(new OpenNotificationTargetAction(first.nodeId));\n ui.engine.dispatch(new ToggleInboxAction(false));\n },\n });\n}\n\n// ---- info panel (tags + conversation) --------------------------------------\n\nexport function infoPanel(state, ui) {\n const nav = state.nav;\n const active = nav.activeFile ? { id: nav.activeTabId, node: nav.activeFile } : null;\n return div({ className: 'infopanel' },\n div({ className: 'ip-head' },\n icon('info', { size: 15 }),\n span('Details'),\n button({ className: 'iconbtn', title: 'Close' }, icon('close', { size: 14 })).on({ click: () => ui.engine.dispatch(new ToggleInfoPanelAction(false)) }),\n ),\n !active\n ? div({ className: 'ip-empty' }, span('Open a file to see its tags and conversation.'))\n // Watching `sidecarFor(id)` is what LOADS it: the query's bootAction fetches when the\n // first observer arrives and its killAction clears when the last one leaves. Nothing\n // watches the nav stack to notice a file changed — a different file is a different\n // query. See bl/queries.js.\n : ui.watch(watchQuery(ui.engine, sidecarFor(active.node.id)), (sc) => div({ className: 'ip-body' },\n fileHeader(active.node, state, ui),\n linkSection(active.node, state, ui),\n tagSection(sc, ui),\n conversationSection(state, sc, ui),\n )),\n );\n}\n\nfunction fileHeader(node, state, ui) {\n // From the offline view, which resolves the pin set — the component asks whether this\n // file is pinned without knowing that pins are a list to be scanned.\n const pinned = state.off?.pinnedIds?.has(node.id) ?? false;\n return div({ className: 'ip-file' },\n div({ className: 'ip-name' }, node.name),\n div({ className: 'ip-path' }, node.contentType || ''),\n // Secondary, not primary. Pinning a file for offline is a useful thing to be able\n // to do and not the thing you came to this panel for — as the brightest element on\n // screen it out-shouted the file's own links, tags and conversation.\n button({ className: `btn small ${pinned ? 'on' : ''}`, $styling: { 'margin-top': '10px' } },\n icon(pinned ? 'check' : 'download', { size: 14 }),\n pinned ? 'Available offline' : 'Make available offline',\n ).on({ click: () => (pinned ? ui.engine.dispatch(new ExecCommandAction('offline.unpin', node)) : ui.engine.dispatch(new ExecCommandAction('offline.pin', node))) }),\n );\n}\n\n/**\n * The item's own `trove:` link, and what links to it.\n *\n * With no folders, backlinks are the answer to \"where does this live?\" — the documents\n * that gather it up. A load failure says so rather than rendering as an empty list,\n * which would read as a fact about the drive instead of about the request.\n */\nfunction linkSection(node, state, ui) {\n const bl = state.so.backlinks;\n const uri = node.collectionId ? troveUri(node) : null;\n const mine = bl && bl.nodeId === node.id ? bl : null;\n return div({ className: 'ip-section' },\n div({ className: 'ip-label' }, 'Links'),\n uri\n ? button({ className: 'ip-uri', title: 'Copy this item’s link' }, icon('link', { size: 12 }), span(uri))\n .on({ click: () => copyLink(ui, uri) })\n : null,\n div({ className: 'ip-label', $styling: { 'margin-top': '10px' } }, 'Linked from'),\n mine?.loading\n ? div({ className: 'ip-muted' }, 'Loading…')\n : mine?.error\n ? div({ className: 'ip-muted error' }, `Couldn’t load links: ${mine.error}`)\n : mine?.items?.length\n ? div({ className: 'ip-backlinks' }, ...mine.items.map((n) =>\n button({ className: 'ip-backlink', title: n.name }, icon('file-text', { size: 12 }), span(n.name))\n .on({ click: () => ui.engine.dispatch(new OpenFileAction(n)) })))\n : div({ className: 'ip-muted' }, 'Nothing links here yet.'),\n );\n}\n\nfunction copyLink(ui, uri) {\n ui.engine.dispatch(new CopyTextAction(uri, `Copied ${uri}`));\n}\n\nfunction tagSection(sc, ui) {\n const tags = sc?.tags || [];\n return div({ className: 'ip-section' },\n div({ className: 'ip-label' }, 'Tags'),\n div({ className: 'tags' },\n ...tags.map((t) =>\n span({ className: 'tag' },\n t.value ? `${t.name}: ${t.value}` : t.name,\n button({ className: 'tag-x' }, icon('close', { size: 11 })).on({ click: () => ui.engine.dispatch(new RemoveTagAction(t.name)) }),\n ),\n ),\n input({ className: 'tag-input', placeholder: '+ tag', value: '' }).on({\n keydown: (e) => {\n if (e.key === 'Enter' && e.target.value.trim()) {\n const raw = e.target.value.trim();\n const [name, ...rest] = raw.split(':');\n ui.engine.dispatch(new AddTagAction(name.trim(), rest.join(':').trim() || undefined));\n e.target.value = '';\n }\n },\n }),\n ),\n );\n}\n\nfunction conversationSection(state, sc, ui) {\n if (sc?.loading) return div({ className: 'ip-section' }, div({ className: 'spinner' }));\n const comments = sc?.comments || [];\n // On a load failure, don't render a false \"No comments yet\" — say it couldn't load\n // and offer a retry, so the user doesn't post into what looks like an empty thread.\n const body = sc?.error\n ? div({ className: 'conv-empty' },\n span(`Couldn't load the conversation: ${sc.error}`),\n button({ className: 'btn', $styling: { 'margin-top': '8px' } }, 'Retry').on({ click: () => ui.engine.dispatch(new LoadSidecarAction(sc.nodeId)) }))\n : comments.length\n ? div({ className: 'thread' }, ...comments.map((c) => commentNode(c, state, ui, 0)))\n : div({ className: 'conv-empty' }, 'No comments yet. Start the discussion — use @ to mention someone.');\n return div({ className: 'ip-section conv' },\n div({ className: 'ip-label' }, `Conversation${sc?.commentCount ? ` · ${sc.commentCount}` : ''}`),\n body,\n sc?.error ? null : composer(state, ui),\n );\n}\n\nfunction commentNode(c, state, ui, depth) {\n const me = state.so.me;\n const mine = me && c.author?.id === me.id;\n return div({ className: 'comment', $styling: depth ? { marginLeft: '18px' } : {} },\n div({ className: 'c-head' },\n span({ className: 'c-avatar' }, (c.author?.name || '?')[0].toUpperCase()),\n span({ className: 'c-author' }, c.author?.name || c.author?.id || 'Someone'),\n span({ className: 'c-time' }, relativeDate(c.createdAt), c.edited ? ' · edited' : ''),\n ),\n c.deleted\n ? div({ className: 'c-body deleted' }, 'comment deleted')\n : div({ className: 'c-body' }, renderBody(c.body)),\n !c.deleted ? div({ className: 'c-actions' },\n ...REACTIONS.map((emoji) => {\n const users = c.reactions?.[emoji] || [];\n return button({ className: `react ${users.includes(me?.id) ? 'on' : ''}` }, emoji, users.length ? span({ className: 'rc' }, String(users.length)) : null)\n .on({ click: () => ui.engine.dispatch(new ReactToCommentAction(c.id, emoji)) });\n }),\n button({ className: 'c-link' }, 'Reply').on({ click: () => ui.engine.dispatch(new SetReplyToAction({ id: c.id, author: c.author })) }),\n mine ? button({ className: 'c-link danger' }, 'Delete').on({ click: () => ui.engine.dispatch(new DeleteCommentAction(c.id)) }) : null,\n ) : null,\n (c.replies || []).length ? div({ className: 'replies' }, ...c.replies.map((r) => commentNode(r, state, ui, depth + 1))) : null,\n ).key(c.id);\n}\n\nfunction composer(state, ui) {\n const me = state.so.me;\n const replyTo = state.so.replyTo;\n // `me` is null only when /api/me didn't answer — offline, or refused. It is NOT the\n // anonymous case (an anonymous deployment returns a real anonymous principal), so\n // \"Sign in to join the conversation\" was shown to people with nowhere to sign in,\n // and to people who were merely offline. Say which it is, and offer the one action\n // that helps: Trove ships no login of its own, so signing in means letting the\n // identity proxy in front of it redirect a fresh page load.\n if (!me) {\n if (!state.off?.online) {\n return div({ className: 'conv-signin' }, 'You’re offline. Conversations come back when you reconnect.');\n }\n return div({ className: 'conv-signin' },\n span('You’re signed out, so you can read this conversation but not add to it.'),\n button({ className: 'c-link' }, 'Reload to sign in').on({ click: () => window.location.reload() }),\n );\n }\n return div({ className: 'composer' },\n replyTo ? div({ className: 'replying' }, `Replying to ${replyTo.author?.name || 'comment'}`,\n button({ className: 'c-link' }, 'cancel').on({ click: () => ui.engine.dispatch(new SetReplyToAction(null)) })) : null,\n textarea({ className: 'composer-input', placeholder: 'Write a comment… @mention someone', rows: 2, value: '' }).on({\n keydown: (e) => {\n if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {\n ui.engine.dispatch(new PostCommentAction(e.target.value));\n e.target.value = '';\n }\n },\n }),\n div({ className: 'composer-actions' },\n span({ className: 'muted' }, '⌘/Ctrl + Enter'),\n button({ className: 'btn primary', disabled: state.so.posting }, 'Comment').on({\n click: (e) => {\n const box = e.target.closest('.composer').querySelector('.composer-input');\n ui.engine.dispatch(new PostCommentAction(box.value));\n box.value = '';\n },\n }),\n ),\n );\n}\n\n// WHERE the mentions are is parsed in bl/mentions.js, beside the `#tag` parser it is a\n// sibling of. All that is left here is the decision to draw one as a chip.\nfunction renderBody(text) {\n return parseMentions(text).map((part) =>\n (part.type === 'mention' ? span({ className: 'mention' }, `@${part.name}`) : part.value));\n}\n",
90
+ "// The left rail — the app's only global chrome now that the title bar is gone.\n// Brand mark at the top (→ home), the primary views below, then a bottom cluster\n// of notifications, settings, and the signed-in principal. Search is reached from\n// the Home view itself and via the double-shift modal, so there is no omni bar.\n\nimport { dd } from '../../runtime.js';\nimport { icon } from '../icon.js';\nimport { notificationBell, principalChip } from './social.js';\nimport { ExecCommandAction } from '../../bl/actions.js';\n\nconst { div, button, span, img } = dd;\n\nconst ITEMS = [\n { id: 'home', icon: 'search', title: 'Search & files', command: 'workbench.view.home' },\n { id: 'plugins', icon: 'plug', title: 'Plugins', command: 'workbench.view.plugins' },\n // Where an administrator goes. A destination rather than a route because this app does\n // not put its state in the address bar — see adminView.js.\n { id: 'admin', icon: 'book', title: 'Administration', command: 'workbench.view.admin' },\n];\n\nexport default function activityBar(state, ui) {\n const active = state.wb.activity;\n const pluginCount = state.plugins?.filter((p) => p.status === 'active').length || 0;\n return div({ className: 'activitybar' },\n button({ className: 'brand-mark', title: 'Trove — home' }, img({ src: '/icon.svg', alt: 'Trove' }))\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.view.home')) }),\n ...ITEMS.map((it) =>\n button({ className: `item ${active === it.id ? 'active' : ''}`, title: it.title },\n icon(it.icon, { size: 22 }),\n it.id === 'plugins' && pluginCount ? span({ className: 'badge' }, String(pluginCount)) : null,\n ).on({ click: () => ui.engine.dispatch(new ExecCommandAction(it.command)) }),\n ),\n div({ className: 'spacer' }),\n notificationBell(state, ui),\n button({ className: `item ${active === 'settings' ? 'active' : ''}`, title: 'Settings' }, icon('gear', { size: 21 }))\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.openSettings')) }),\n principalChip(state),\n );\n}\n",
91
+ "// A small, allowlist-only HTML sanitizer for content a PLUGIN produces (status bar\n// items today). Plugin code runs on an opaque origin with no reach into the host DOM;\n// anything it hands us to render is untrusted string data and must not be able to\n// become script, load a resource, or navigate.\n//\n// Allowlist, not denylist: parse into an inert document, then rebuild only the nodes\n// and attributes named below. Anything unrecognised — an element, an attribute, a\n// URL scheme — is dropped rather than \"cleaned\", so a novel injection has nothing to\n// slip through. `template` parsing is inert: no scripts execute and no images load\n// while we walk it.\n\nconst ALLOWED_TAGS = new Set(['SPAN', 'B', 'STRONG', 'I', 'EM', 'CODE', 'SMALL', 'BR', 'S', 'U']);\nconst ALLOWED_ATTRS = new Set(['class', 'title']);\n// Cap the output so a runaway plugin can't wedge the shell with a megabyte of markup.\nconst MAX_LENGTH = 4096;\nconst MAX_NODES = 200;\n\n/**\n * Sanitize `html` into a DocumentFragment safe to insert into the host DOM.\n * @param {string} html\n * @returns {DocumentFragment}\n */\nexport function sanitizeFragment(html) {\n const out = document.createDocumentFragment();\n if (typeof html !== 'string' || !html) return out;\n const tpl = document.createElement('template');\n tpl.innerHTML = html.slice(0, MAX_LENGTH);\n const budget = { nodes: MAX_NODES };\n for (const child of tpl.content.childNodes) {\n const clean = clone(child, budget);\n if (clean) out.appendChild(clean);\n }\n return out;\n}\n\n/** The plain-text content of `html`, for tooltips and other attribute contexts. */\nexport function htmlToText(html) {\n const frag = sanitizeFragment(html);\n return (frag.textContent || '').trim();\n}\n\n/**\n * Sanitize `html` into VDOM nodes, so plugin content reconciles like everything else\n * instead of being an opaque innerHTML island the renderer can't see into.\n * @param {string} html\n * @param {Record<string, Function>} dd the element factories (dodo's `dd`)\n */\nexport function sanitizedVNodes(html, dd) {\n return [...sanitizeFragment(html).childNodes].map((n) => toVNode(n, dd)).filter((n) => n != null);\n}\n\nfunction toVNode(node, dd) {\n if (node.nodeType === Node.TEXT_NODE) return node.nodeValue;\n const factory = dd[node.tagName.toLowerCase()];\n if (!factory) return node.textContent; // allowed tag the renderer doesn't model\n const props = {};\n if (node.className) props.className = node.className;\n if (node.title) props.title = node.title;\n return factory(props, ...[...node.childNodes].map((c) => toVNode(c, dd)).filter((n) => n != null));\n}\n\nfunction clone(node, budget) {\n if (budget.nodes-- <= 0) return null;\n if (node.nodeType === Node.TEXT_NODE) return document.createTextNode(node.nodeValue);\n if (node.nodeType !== Node.ELEMENT_NODE) return null; // comments, CDATA, …\n if (!ALLOWED_TAGS.has(node.tagName)) return null;\n\n const el = document.createElement(node.tagName.toLowerCase());\n for (const attr of node.attributes) {\n const name = attr.name.toLowerCase();\n // `on*` handlers never reach here (not in the allowlist), but be explicit: no\n // event handler, no `style` (CSS can exfiltrate via url()), no URL attributes.\n if (!ALLOWED_ATTRS.has(name)) continue;\n el.setAttribute(name, attr.value.slice(0, 200));\n }\n for (const child of node.childNodes) {\n const clean = clone(child, budget);\n if (clean) el.appendChild(clean);\n }\n return el;\n}\n",
92
+ "import { dd } from '../../runtime.js';\nimport { icon } from '../icon.js';\nimport { bytes } from '../format.js';\nimport { sanitizedVNodes, htmlToText } from '../sanitize.js';\nimport { CancelTransferAction, ExecCommandAction, ShowContextMenuAction, ToggleActivityPanelAction } from '../../bl/actions.js';\n\nconst { div, button, span } = dd;\n\n/**\n * A plugin's status slot. The manifest declares the slot (name + side); the plugin\n * pushes content into it at runtime over RPC. The content is untrusted HTML from a\n * sandboxed frame, so it goes through the allowlist sanitizer before it becomes nodes.\n * A slot with nothing in it, or one whose `when` doesn't hold, renders nothing at all\n * rather than an empty chip.\n */\n// The item arrives already decided — see the statusItems view query. Whether it should\n// show at all (`visible`, its `when` clause, whether the plugin behind it is responding) is\n// resolved on the query side now, which is what let this stop reaching into `platform`\n// mid-render. `html` is still untrusted plugin markup: a query emitting plain data says\n// nothing about that data being safe, so it is still sanitised here.\nfunction statusSlot(item, ui) {\n const content = sanitizedVNodes(item.html, dd);\n if (!content.length) return null;\n const title = item.tooltip ? htmlToText(item.tooltip) : '';\n return item.command\n ? button({ className: 'seg', title }, ...content).on({ click: () => ui.engine.dispatch(new ExecCommandAction(item.command)) })\n : span({ className: 'seg', title }, ...content);\n}\n\n/**\n * The two things that make background work and standing problems discoverable at all.\n *\n * Running work shows only while it is running — a status bar that always carries an\n * \"Activity\" button teaches people to ignore it. The attention badge is the opposite:\n * it stays until the problem is actually fixed, because that is the whole point of an\n * issue as against a toast that scrolls away.\n */\nexport function activityChips(state, ui) {\n const act = state.act || { tasks: [], issues: [] };\n const running = act.tasks.filter((t) => t.status === 'running');\n const open = () => ui.engine.dispatch(new ToggleActivityPanelAction(true));\n const chips = [];\n\n if (running.length) {\n const first = running[0];\n const determinate = first.total != null && first.total > 0;\n const pct = determinate ? Math.round(((first.done || 0) / first.total) * 100) : null;\n chips.push(button({\n className: 'seg sb-activity',\n title: running.map((t) => t.title).join('\\n'),\n },\n div({ className: 'spinner', $styling: { width: '11px', height: '11px' } }),\n span(running.length > 1\n ? `${running.length} running`\n : `${first.title}${pct == null ? '' : ` ${pct}%`}`)).on({ click: open }));\n }\n\n if (act.issues.length) {\n chips.push(button({\n className: 'seg sb-attention',\n title: act.issues.map((i) => i.title).join('\\n'),\n }, icon('info', { size: 12 }), span(`${act.issues.length} need${act.issues.length === 1 ? 's' : ''} attention`))\n .on({ click: open }));\n }\n return chips;\n}\n\n/**\n * How full the disk is — but only when the backend actually knows.\n *\n * A filesystem or NAS can answer exactly, and that is where it matters: a disk fills\n * up and every upload starts failing with no warning that anything was coming. An\n * object store has no equivalent number, so this renders nothing at all rather than a\n * meter that means nothing. The bar turns amber under 10% free and red under 5%, which\n * is early enough to act on.\n */\nexport function usageChip({ usage: u, usageLevel: level = '' }) {\n if (!u?.total) return null;\n const pct = Math.min(100, Math.round((u.used / u.total) * 100));\n return span({\n className: `seg sb-usage ${level}`,\n title: `${bytes(u.used)} used of ${bytes(u.total)} — ${bytes(u.available)} free on this volume`,\n },\n div({ className: 'usage-bar' }, div({ className: 'usage-fill', $styling: { width: `${pct}%` } })),\n span(`${bytes(u.available)} free`));\n}\n\nexport default function statusBar(state, ui) {\n const ex = state.ex;\n const items = ex.items || [];\n // Derived by the `statusFacts` query — see bl/status.js. These used to be worked out\n // here and imported INTO the phone chrome from this module, which is a business-layer\n // derivation living in a component and being shared out of it.\n const f = state.facts;\n const { totalItems, totalBytes } = f;\n const caps = state.caps;\n const active = f.uploading;\n\n // Plugin-contributed status slots. Already filtered and ordered by the query.\n const slots = state.statusItems || [];\n const left = slots.filter((s) => s.slot === 'left').map((s) => statusSlot(s, ui));\n const right = slots.filter((s) => s.slot !== 'left').map((s) => statusSlot(s, ui));\n\n const off = f.off;\n return div({ className: 'statusbar' },\n !off.online\n ? span({ className: 'seg offline-badge', title: 'You are offline — pinned files and cached data are available' }, icon('info', { size: 12 }), span('Offline'))\n : off.syncing\n ? span({ className: 'seg', title: 'Syncing offline changes' }, div({ className: 'spinner', $styling: { width: '11px', height: '11px' } }), span('Syncing…'))\n : null,\n off.queued ? span({ className: 'seg', title: 'Changes waiting to sync' }, `${off.queued} queued`) : null,\n // The pinned files themselves. There is no offline-files view anywhere, so a chip\n // counting them that only dropped you on the home screen was a label pretending to\n // be a control — and unpinning meant finding each file again through search.\n off.pins.length\n ? button({ className: 'seg', title: `${off.pins.length} file(s) available offline` },\n icon('download', { size: 12 }), span(`${off.pins.length} offline`), icon('chevron-down', { size: 11 }))\n .on({ click: (e) => {\n const items = off.pins.slice(0, 12).flatMap((p) => [\n { label: p.name, icon: 'file-text', actions: [new ExecCommandAction('explorer.open', p)] },\n { label: `Remove “${p.name}” from offline`, icon: 'close', actions: [new ExecCommandAction('offline.unpin', p)] },\n { sep: true },\n ]);\n if (off.pins.length > 12) items.push({ label: `…and ${off.pins.length - 12} more`, actions: [] });\n ui.engine.dispatch(new ShowContextMenuAction(items, {\n rect: e.currentTarget.getBoundingClientRect(), prefer: 'up',\n }));\n } })\n : null,\n button({ className: 'seg', title: 'Switch collection' },\n // The NAME, and nothing invented. `|| 'default'` used to sit here, which meant the\n // status bar cheerfully named a collection on a drive that had none.\n icon('files', { size: 13 }), span(f.collectionLabel),\n (ex.collections || []).length > 1 || ex.canCreateCollection ? icon('chevron-down', { size: 11 }) : null)\n .on({ click: (e) => {\n const items = ex.collectionMenu || [];\n // With nowhere else to go, the segment is a label, not a dead menu.\n if (items.length > 1 || ex.canCreateCollection) {\n ui.engine.dispatch(new ShowContextMenuAction(items, {\n rect: e.currentTarget.getBoundingClientRect(), prefer: 'up',\n }));\n } else ui.engine.dispatch(new ExecCommandAction('workbench.view.home'));\n } }),\n active.length\n ? button({ className: 'seg', title: 'Active uploads — click to cancel' }, div({ className: 'spinner', $styling: { width: '11px', height: '11px' } }), span(`${active.length} uploading`))\n .on({ click: (e) => ui.engine.dispatch(new ShowContextMenuAction(active.map((t) => ({\n label: `Cancel ${t.name} (${Math.round((t.ratio || 0) * 100)}%)`, icon: 'close', danger: true,\n actions: [new CancelTransferAction(t.id)],\n })), { x: e.clientX, y: e.clientY })) })\n : span({ className: 'seg', title: ex.nextCursor ? `Showing ${items.length} of ${f.totalKnown ? totalItems : 'more'}` : '' },\n `${totalItems.toLocaleString()}${f.totalKnown || !f.partial ? '' : '+'} item${totalItems === 1 ? '' : 's'}`),\n ...left,\n div({ className: 'spacer' }),\n ...activityChips(state, ui),\n ...right,\n // Same qualifier as the item count beside it. Without it the two numbers in one bar\n // disagreed about their own honesty: \"500+ items\" next to a byte figure that was\n // only the loaded page's, presented as the collection's.\n span({\n className: 'seg',\n title: f.totalKnown || !f.partial\n ? 'Total size of this collection'\n : `Size of the ${f.shown.toLocaleString()} items loaded so far — this server doesn’t report a collection total`,\n }, `${bytes(totalBytes)}${f.totalKnown || !f.partial ? '' : '+'}`),\n usageChip(f),\n caps ? span({ className: 'seg', title: 'Storage backend capabilities' },\n icon(caps.storage?.presignDownload ? 'download' : 'files', { size: 12 }),\n span(caps.storage?.presignDownload ? 'S3 direct' : 'proxied'),\n ) : null,\n caps?.features?.semanticSearch ? button({ className: 'seg', title: 'Semantic search enabled' }, icon('star', { size: 12 }), span('semantic'))\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.view.home')) }) : null,\n );\n}\n",
93
+ "// Running a menu item or a list row.\n//\n// These used to carry a `run` closure — `run: () => ui.engine.dispatch(new ExecCommandAction('explorer.open', node))` — which\n// made a menu item a piece of behaviour wearing a data shape. Nothing could inspect one,\n// nothing could contribute one from outside the module that built it, and the engine saw\n// only whatever the closure happened to do.\n//\n// They carry `actions` now: a list of Action instances, which is what an item IS — a label,\n// an icon, and what happens if you pick it. Almost all of them turned out to be exactly one\n// `ExecCommandAction`, which is the shape the statusItem view already used.\n//\n// A LIST rather than a single action because a few items genuinely do two things: opening a\n// file from the search modal opens it and then closes the modal. Sequencing them here keeps\n// that out of the item.\n\nimport { runAction } from '../dispatch.js';\n\n/**\n * Run an item's actions, one genuinely finished before the next begins.\n *\n * The loop used to be a bare `ui.engine.dispatch(action)` under a comment claiming it\n * sequenced them — `dispatch` returns a feed and schedules the body, so it fired them all\n * at once. Nothing was visibly broken, because the lists touched independent slices, but\n * bl/launcher.js already emits `[SetLaunchQueryAction, FilterAction]` and the comment was\n * telling the next reader that a read-after-write pair here would be safe.\n *\n * The same shape and the same stop-on-failure rule as CommandService.execute, which is the\n * other implementation of \"run this item's list of actions\".\n *\n * @param {object} ui\n * @param {{actions?: object[]}} item\n */\nexport async function activate(ui, item) {\n for (const action of item?.actions || []) {\n const settled = await runAction(ui.engine, action);\n if (settled?.type !== 'complete') break;\n }\n}\n",
94
+ "// The pieces every view draws the same way.\n//\n// A view decides how results are ARRANGED. It does not get to decide what a group\n// header says, or where the row menu opens, because those are the same promises\n// whichever way the drive is drawn: the header carries the group's action (Upload,\n// Empty trash, Retry) and the menu carries everything you can do to a file. A view that\n// dropped either would quietly take working features off the screen.\n\nimport { dd } from '../../../runtime.js';\nimport { icon } from '../../icon.js';\nimport { ShowContextMenuAction } from '../../../bl/actions.js';\nimport { activate } from '../../activate.js';\n\nconst { div, span, button } = dd;\n\n/**\n * A group's heading.\n *\n * `group.title` is uppercased by CSS, which is right for a label and wrong for anything\n * the user typed — it turns their `#draft` into `#DRAFT`, a tag that isn't what they\n * wrote. So a group can carry a verbatim half.\n */\nexport function groupHeader(group, ui) {\n const controls = group.controls || [];\n return div({ className: 'launch-h' },\n // Label and value together on the left; `.launch-h` is space-between, so an\n // ungrouped value gets flung to the far edge away from the label it belongs to.\n div({ className: 'lh-title' },\n span(group.title),\n group.verbatim ? span({ className: 'lh-verbatim' }, group.verbatim) : null),\n // Descriptions, not a pre-rendered button. A group used to carry a vnode in `action`,\n // which meant the thing deciding WHAT a header offers had to be able to draw one — the\n // same reason menu items stopped carrying `run` closures. See ui/activate.js.\n controls.length\n ? div({ className: 'lh-actions' }, ...controls.map((c) =>\n button({ className: 'launch-up', title: c.title || c.label },\n c.icon ? icon(c.icon, { size: 13 }) : null, c.label)\n .on({ click: () => activate(ui, c) })))\n : null,\n );\n}\n\n/** The \"…\" button, for items that have a menu. */\nexport function menuButton(it, ui, select) {\n if (!it.menu) return null;\n return button({\n className: 'launch-more',\n title: `Actions for ${it.title}`,\n $attrs: { 'aria-label': `Actions for ${it.title}` },\n }, icon('dots', { size: 14 }))\n .on({ click: (e) => { e.stopPropagation(); openRowMenu(e.currentTarget, it, ui, null, select); } });\n}\n\n/**\n * Open an item's menu, anchored to the thing it belongs to.\n *\n * Anchored to the row (or the pointer, when there was one) rather than to a remembered\n * click position, so the keyboard route lands somewhere sensible too.\n */\nexport function openRowMenu(anchor, it, ui, event, select) {\n const r = anchor?.getBoundingClientRect?.();\n const x = event?.clientX ?? (r ? r.right - 8 : 0);\n const y = event?.clientY ?? (r ? r.bottom : 0);\n // Read the coordinates BEFORE selecting: selecting re-renders, and `anchor` is then\n // a detached node whose rect is all zeroes.\n const items = it.menu();\n select?.();\n ui.engine.dispatch(new ShowContextMenuAction(items, { x, y }));\n}\n",
95
+ "// The list view: one row per item, which is what a drive looks like unless you ask\n// for something else.\n//\n// It is also the fallback for every other view: one that throws lands here, and views\n// are host code with no sandbox to catch them first. So it must not depend on anything\n// beyond the contract itself — no settings, no capabilities, no network.\n\nimport { dd } from '../../../runtime.js';\nimport { icon } from '../../icon.js';\nimport { groupHeader, menuButton, openRowMenu } from './parts.js';\nimport { activate } from '../../activate.js';\n\nconst { div, span } = dd;\n\nexport function listView({ groups, index, handlers, ui }) {\n let gi = -1;\n return div({ className: 'launch-view view-list' },\n ...groups.map((group) => div({ className: 'launch-group' },\n groupHeader(group, ui),\n group.items.length\n ? div({ className: 'launch-list' }, ...group.items.map((it) => {\n const at = ++gi;\n return itemRow(it, at === index, {\n hover: () => handlers.hover(at),\n select: () => handlers.select(at),\n }, ui);\n }))\n : div({ className: 'launch-empty' }, group.empty || 'Nothing here.'),\n )),\n );\n}\n\nfunction itemRow(it, active, { hover, select }, ui) {\n return div({ className: `launch-item ${active ? 'active' : ''}` },\n icon(it.icon, { size: 15 }),\n span({ className: 'name' }, it.title),\n it.detail ? span({ className: 'launch-detail' }, it.detail) : null,\n it.badge ? span({ className: 'launch-kind' }, it.badge) : null,\n // Everything you can do to a file, on the file. Rename, download, copy link and\n // delete were all commands with no way to reach them: the palette's versions act on\n // \"the selection\", and until the highlight became a selection there never was one.\n menuButton(it, ui, select),\n // One `.on()` call: a second replaces the handler map rather than merging into it,\n // which is how adding `contextmenu` silently removed `click` and stopped every file\n // in the drive from opening.\n ).on({\n click: () => activate(ui, it),\n mouseenter: hover,\n ...(it.menu ? { contextmenu: (e) => { e.preventDefault(); openRowMenu(e.currentTarget, it, ui, e, select); } } : {}),\n });\n}\n",
96
+ "// Keeping a media element pointed at a URL that still works.\n//\n// A minted URL expires (docs/design/signed-urls.md). Content URLs are long — longer than\n// almost any sitting — but \"almost\" is not \"always\": someone pauses a film, closes the\n// laptop, and comes back tomorrow. So the element has to be able to swap its own source,\n// and swapping the source under a playing video is not a matter of assigning `src`.\n//\n// Both refresh paths are needed and neither is sufficient alone:\n//\n// PROACTIVE a timer from `expiresAt`. Handles the common case invisibly.\n// REACTIVE the element's own `error`. A backgrounded tab has its timers throttled,\n// so the proactive refresh may simply never run — which is exactly the\n// paused-overnight case, the one the timer was supposed to cover.\n\nconst REFRESH_AT = 0.8; // of the URL's life, so the swap lands well before it matters.\nconst MAX_TIMER = 2 ** 31 - 1; // setTimeout overflows past this and fires immediately.\n\n/**\n * Point `el` at `node`'s bytes and keep it pointed there.\n *\n * @param {HTMLMediaElement|HTMLImageElement} el\n * @param {object} node\n * @param {object} ui\n * @param {{op?: string, onError?: (msg: string) => void}} [opts]\n * @returns {() => void} detach\n */\nexport function attachMedia(el, node, ui, { op = 'media', onError } = {}) {\n const urls = ui.platform.mediaUrls;\n let timer = null;\n let stopped = false;\n // One retry per URL. A file whose bytes are genuinely gone would otherwise re-mint\n // forever, hammering the server over a 404 that is never going to change.\n let retried = false;\n\n const clear = () => { clearTimeout(timer); timer = null; };\n\n const schedule = (expiresAt) => {\n clear();\n if (!Number.isFinite(expiresAt)) return; // nothing was minted; nothing expires\n const wait = Math.max(1000, (expiresAt - Date.now()) * REFRESH_AT);\n timer = setTimeout(() => apply({ resume: true }), Math.min(wait, MAX_TIMER));\n };\n\n /**\n * Fetch a URL and put it on the element, preserving where the user was.\n *\n * The order matters and every step earns its place: without `resume` the film restarts\n * from the beginning, without `load()` an element that has already errored may not pick\n * up the new source at all, and without the final `play()` it sits there paused looking\n * like a crash.\n */\n async function apply({ resume }) {\n if (stopped) return;\n const media = isMedia(el);\n const at = media && resume ? el.currentTime : 0;\n const wasPlaying = media && resume ? !el.paused && !el.ended : false;\n let got;\n try {\n got = await urls.url(node.id, { op });\n } catch (err) {\n if (!stopped) onError?.(err.message);\n return;\n }\n if (stopped) return;\n el.src = got.url;\n if (media) {\n el.load();\n if (at > 0 || wasPlaying) {\n const restore = () => {\n el.removeEventListener('loadedmetadata', restore);\n // Guard the seek: a live or zero-length source has nowhere to seek to, and\n // assigning currentTime there throws.\n if (at > 0 && Number.isFinite(el.duration) && el.duration > at) el.currentTime = at;\n if (wasPlaying) el.play().catch(() => { /* autoplay policy; the user can press play */ });\n };\n el.addEventListener('loadedmetadata', restore);\n }\n }\n schedule(got.expiresAt);\n }\n\n // The retry budget is spent by a failed LOAD and refunded by a successful one — not by\n // a successful mint. Refunding it in `apply` meant a file whose bytes are genuinely\n // gone re-minted forever: every retry got a perfectly good URL, reset the budget, and\n // failed again, so the fallback was never shown and the request never stopped.\n const onLoaded = () => { retried = false; };\n el.addEventListener('load', onLoaded); // <img>\n el.addEventListener('loadeddata', onLoaded); // <audio>/<video>\n\n // The reactive half. An expired URL and a missing file look identical from here — both\n // are just a failed load — so it re-mints once and, if that fails too, says so.\n const onElementError = () => {\n if (stopped) return;\n if (retried) { onError?.(null); return; }\n retried = true;\n urls.invalidate(node.id, op);\n apply({ resume: true });\n };\n el.addEventListener('error', onElementError);\n\n apply({ resume: false });\n\n return () => {\n stopped = true;\n clear();\n el.removeEventListener('error', onElementError);\n el.removeEventListener('load', onLoaded);\n el.removeEventListener('loadeddata', onLoaded);\n };\n}\n\nfunction isMedia(el) {\n return typeof el?.play === 'function' && typeof el?.load === 'function';\n}\n",
97
+ "// The grid view: tiles, with a picture on them where there is a picture to show.\n//\n// This is the second way to look at a drive, and it exists as much to prove the view\n// contract as to be useful — a contribution type with one implementation is a guess. It\n// draws the SAME groups the list does, headers and all, because the group header is\n// where Upload, Empty trash and Retry live: a view that dropped it would take those off\n// the screen the moment someone switched to tiles.\n//\n// On thumbnails, honestly: there is no thumbnail service yet, so a tile showing a\n// photograph is showing the photograph, scaled down by the browser. That is affordable\n// only because `loading=\"lazy\"` means the ones below the fold are never fetched — the\n// grid asks for what is on screen and nothing else. A hosted build that generates real\n// thumbnails should register its own view rather than patch this one; that is the whole\n// point of the contribution.\n\nimport { dd } from '../../../runtime.js';\nimport { icon } from '../../icon.js';\nimport { groupHeader, menuButton, openRowMenu } from './parts.js';\nimport { attachMedia } from '../../media.js';\nimport { activate } from '../../activate.js';\n\nconst { div, span, img } = dd;\n\nexport function gridView({ groups, index, handlers, ui }) {\n let gi = -1;\n return div({ className: 'launch-view view-grid' },\n ...groups.map((group) => div({ className: 'launch-group' },\n groupHeader(group, ui),\n group.items.length\n ? div({ className: 'grid-list' }, ...group.items.map((it) => {\n const at = ++gi;\n return tile(it, at === index, {\n hover: () => handlers.hover(at),\n select: () => handlers.select(at),\n }, ui);\n }))\n : div({ className: 'launch-empty' }, group.empty || 'Nothing here.'),\n )),\n );\n}\n\n/**\n * Which way to move for an arrow key.\n *\n * The launcher owns keyboard navigation and thinks in one flat list, which is right for\n * rows and wrong for tiles: down should mean the tile below, not the tile beside. The\n * view is asked, gets to answer in the launcher's own terms (a delta), and the launcher\n * keeps the wrapping, the selection and the scrolling.\n *\n * The column count is measured rather than assumed, because it comes from\n * `auto-fill` — it depends on the window width, the shell, and whether the sidebar\n * is open, none of which this file should be trying to predict.\n *\n * Left and right are only ours when the search box is empty. With a query typed in it,\n * those keys belong to the caret: someone fixing a typo must not find the highlight\n * walking across the grid instead.\n */\nexport function gridMove({ key, textual }) {\n if (key === 'ArrowLeft') return textual ? null : -1;\n if (key === 'ArrowRight') return textual ? null : 1;\n const cols = columns();\n if (key === 'ArrowUp') return -cols;\n if (key === 'ArrowDown') return cols;\n return null;\n}\n\nfunction columns() {\n // Tiles on the same row share an offsetTop. One row's worth is the answer; a grid with\n // a single row (or none on screen) falls back to 1, which is the list's behaviour and\n // never worse than a guess.\n const tiles = document.querySelectorAll('.grid-list .grid-tile');\n if (tiles.length < 2) return 1;\n const top = tiles[0].offsetTop;\n let n = 0;\n for (const el of tiles) {\n if (el.offsetTop !== top) break;\n n++;\n }\n return n || 1;\n}\n\nfunction tile(it, active, { hover, select }, ui) {\n const node = it.node;\n const pictorial = (node?.contentType || '').startsWith('image/');\n return div({ className: `grid-tile ${active ? 'active' : ''}`, title: it.detail ? `${it.title} — ${it.detail}` : it.title },\n div({ className: 'gt-media' },\n // The icon is drawn underneath, always. When the image loads it covers it; when\n // the image fails — a deleted object, a format the browser won't decode, a 401 —\n // hiding the <img> uncovers exactly what the list would have shown, rather than\n // leaving the browser's broken-image glyph in a gallery.\n icon(it.icon, { size: 26 }),\n // The `src` is minted rather than built — a tile fetches without our Authorization\n // header, so the URL has to carry its own grant. Minting is batched (see\n // platform/mediaUrls.js), so a wall of tiles costs one request, not one each.\n pictorial\n ? img({ className: 'gt-img', alt: '', loading: 'lazy', decoding: 'async' }).on({\n $attach: (dom) => {\n dom._detachMedia = attachMedia(dom, node, ui, {\n // Uncovering the icon underneath is exactly what the list would have shown,\n // and better than the browser's broken-image glyph in a gallery.\n onError: () => { dom.style.display = 'none'; },\n });\n },\n $detach: (dom) => { dom._detachMedia?.(); dom._detachMedia = null; },\n }).opaque()\n : null,\n it.badge ? span({ className: 'gt-badge' }, it.badge) : null,\n menuButton(it, ui, select),\n ),\n div({ className: 'gt-name' }, it.title),\n ).on({\n click: () => activate(ui, it),\n mouseenter: hover,\n ...(it.menu ? { contextmenu: (e) => { e.preventDefault(); openRowMenu(e.currentTarget, it, ui, e, select); } } : {}),\n });\n}\n",
98
+ "// How a list of items is DRAWN.\n//\n// An opener renders one file; a view renders the results. They register through the\n// same contribution system, so \"a gallery for a collection full of photographs\" is a\n// contribution rather than an edit to the launcher — which is the whole point: the\n// launcher should not have to know how many ways there are to look at a drive.\n//\n// A view is the workbench's own: the built-ins, plus whatever a build passes to\n// `createWorkbench({ views })`. It runs in the host, so the contract is a dodo vnode.\n//\n// The contract is one function:\n//\n// render({ groups, index, handlers, state, ui }) -> vnode\n//\n// `groups` is what the launcher assembled — `[{ title, verbatim?, action?, items,\n// empty? }]`, each item `{ icon, title, detail, badge, node?, run() }`. `index` is the\n// flat position of the highlighted item across every group, because keyboard\n// navigation is the launcher's job and not the view's: up and down must mean the same\n// thing whichever way the results happen to be drawn.\n\nimport { dd } from '../../../runtime.js';\nimport { icon } from '../../icon.js';\nimport { SetSettingAction } from '../../../bl/actions.js';\nimport { SETTING } from '../../../bl/views.js';\nimport { listView } from './list.js';\nimport { gridView, gridMove } from './grid.js';\n\nconst { div, button, span } = dd;\n\nconst BUILT_IN = {\n 'core.view.list': {\n title: 'List', icon: 'list', priority: 50,\n render: listView,\n },\n 'core.view.grid': {\n // Offered first where the results are pictures, and available everywhere.\n title: 'Grid', icon: 'grid', priority: 40,\n match: { mime: ['image/*', 'video/*'] },\n render: gridView, move: gridMove,\n },\n};\n\nexport function registerBuiltinViews(platform) {\n for (const [name, spec] of Object.entries(BUILT_IN)) {\n platform.contributions.register(name, { type: 'view', ...spec });\n }\n}\n\n\n\n/** The switcher, shown only when there is more than one way to look at this. */\nexport function viewSwitcher(slice, current, ui) {\n const views = slice?.views || [];\n if (views.length < 2) return null;\n return div({ className: 'view-switch' }, ...views.map((v) =>\n button({\n className: `vs-btn ${v.id === current?.id ? 'on' : ''}`,\n title: `${v.title} view`,\n 'aria-pressed': v.id === current?.id ? 'true' : 'false',\n }, icon(v.icon || 'list', { size: 14 }))\n .on({ click: () => ui.engine.dispatch(new SetSettingAction(SETTING, v.id)) })));\n}\n\n/**\n * Draw the results with `view`, falling back to the list if it throws.\n *\n * A view is the whole results area. One that fails takes the drive's contents off the\n * screen with it, so a broken third-party view degrades to the built-in list rather\n * than to nothing.\n */\n/**\n * The delta an arrow key should move the highlight by, or null for the default.\n *\n * Keyboard navigation stays the launcher's: it owns the index, the selection and the\n * wrapping. But \"down\" means the row below in a list and the tile below in a grid, so\n * the view is asked first and answers in the launcher's own terms.\n */\nexport function viewMove(view, key, ctx) {\n try {\n const d = view?.move?.({ key, ...ctx });\n return Number.isFinite(d) && d !== 0 ? d : null;\n } catch {\n return null; // a view that can't answer doesn't get to break the arrow keys\n }\n}\n\nexport function renderView(view, ctx) {\n try {\n if (typeof view?.render === 'function') return view.render(ctx);\n } catch (err) {\n console.error(`view \"${view?.id}\" failed`, err);\n return div({},\n div({ className: 'view-error' }, icon('warn', { size: 13 }),\n span(`The “${view?.title || view?.id}” view could not be drawn — showing the list instead.`)),\n listView(ctx));\n }\n return listView(ctx);\n}\n\nexport { listView, gridView };\n",
99
+ "// The main-panel launcher — search-first \"home\" that replaces the explorer\n// sidebar. Empty query shows recents + everything in the collection; typing\n// searches files; a leading `!` switches to command execution; a leading `#`\n// filters by tag/property (parsed in the search layer). One keyboard-navigable\n// list across whichever mode is active.\n\nimport { dd } from '../../runtime.js';\nimport { icon } from '../icon.js';\nimport { ExecCommandAction, FilterAction, MoveLaunchAction, SearchAction, SelectLaunchAction, SetLaunchIndexAction, SetLaunchQueryAction } from '../../bl/actions.js';\nimport { parseTagQuery, filterLabel } from '../../bl/tagQuery.js';\nimport { renderView, viewSwitcher, viewMove } from './views/index.js';\nimport { openRowMenu } from './views/parts.js';\nimport { activate } from '../activate.js';\n\nconst { div, span, input, button } = dd;\n\n// The keys a view may claim. Everything else the search box keeps.\nconst ARROWS = new Set(['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']);\n\n// What to put in the search box, and how much of it fits.\n//\n// The server tells us, because the search TRANSFORMER decides what the box accepts and\n// that is deployment configuration — swap in an LLM transformer and \"# filter by tag\"\n// stops being the right advice. The fallback covers the moment before capabilities\n// arrive and any server too old to say; `!` is ours either way, since running a command\n// from here is a client convention the server knows nothing about.\nfunction promptFor(caps, { compact = false, modal = false } = {}) {\n const p = caps?.searchPrompt;\n const base = (compact ? p?.short || p?.placeholder : p?.placeholder)\n || (compact ? 'Search files' : 'Search files · # filter by tag');\n // On a phone the box is ~300px wide; adding a second clause guarantees an ellipsis\n // in the middle of the instructions, which reads as broken rather than terse.\n return compact || modal ? base : `${base} · ! run a command`;\n}\n\n// Debounce timers, one PER SURFACE. workbench.js mounts the home launcher and the modal\n// one together, and a single module slot meant typing in the modal cancelled the home\n// box's pending search — one keystroke in one component silently discarding another's.\n// A timer is not application state (the engine has no use for a pending timeout), but it\n// does belong to the surface that armed it.\nconst timers = new Map();\nconst arm = (key, fn, ms) => {\n clearTimeout(timers.get(key));\n timers.set(key, setTimeout(fn, ms));\n};\n\nfunction runSearch(ui, key, query) {\n // SearchAction owns search state; the launcher only dispatches (no direct .set).\n arm(key, () => ui.engine.dispatch(new SearchAction(query)), 240);\n}\nfunction clearSearch(ui, key) {\n // The pending timer FIRST. Typing then pressing Escape inside 240ms let the search for\n // what was typed land after the clear — the results list stayed put (it reads the launch\n // query) while the resolved bar said \"Searching …\" over the home list, and `pickView`\n // could switch the view under it. SearchAction now also refuses a superseded answer, so\n // this is belt and braces on a race that produced a visibly wrong screen.\n clearTimeout(timers.get(key));\n ui.engine.dispatch(new SetLaunchQueryAction(''));\n ui.engine.dispatch(new SearchAction('')); // empty query resets results/ran/error\n}\nfunction runFilter(ui, key, filters, text) {\n arm(key, () => ui.engine.dispatch(new FilterAction(filters, text)), 200);\n}\n\nexport default function launcher(state, ui, opts = {}) {\n const modal = !!opts.modal; // rendered as the double-shift overlay → picks reset the stack\n const q = state.wb.launch.query;\n // What is on screen, which view draws it, and whether a search-help offer applies — all\n // decided by the `launcherContent` query. This used to be ~100 lines of derivation right\n // here: which nodes, what each heading says, whether \"All items\" is a claim the drive\n // cannot support. See bl/launcher.js.\n const content = modal ? state.modalContent : state.content;\n const { groups, mode, view } = content;\n const flat = groups.flatMap((g) => g.items);\n const idx = flat.length ? Math.min(state.wb.launch.index, flat.length - 1) : 0;\n\n // Which surface this is, so the two launchers do not share one debounce slot.\n const timerKey = modal ? 'modal' : 'home';\n const onInput = (e) => {\n const v = e.target.value;\n ui.engine.dispatch(new SetLaunchQueryAction(v));\n if (v.startsWith('!')) return; // command mode: no query dispatch\n const { text, filters } = parseTagQuery(v);\n if (filters.length) runFilter(ui, timerKey, filters, text); // drive-wide tag/property query\n else runSearch(ui, timerKey, text);\n };\n // Moving the highlight with the KEYBOARD is selecting, as far as the rest of the app\n // is concerned. Without this, `explorer.selectedNodes()` was permanently empty and\n // every command that works on \"the selected item\" — delete above all — silently did\n // nothing.\n //\n // Hovering deliberately does not select. It moves the highlight (so Enter opens what\n // the pointer is over) but leaves the selection alone: a second state push per mouse\n // move re-renders the list under the pointer, and a row replaced between mousedown and\n // mouseup never receives its click. A pointer user acts through the row's own menu,\n // which selects explicitly before it opens.\n const hoverAt = (at) => ui.engine.dispatch(new SetLaunchIndexAction(at));\n // Moving the highlight and selecting what it lands on are one action, not two. The index\n // wraps, so only the store can say where a move ends up — and reading that back out here\n // would read it before the dispatch had applied. See MoveLaunchAction.\n const selectAt = (at) => ui.engine.dispatch(new SelectLaunchAction(at, flat[at]?.node));\n const move = (delta) => ui.engine.dispatch(new MoveLaunchAction(delta, flat.map((i) => i.node)));\n // The view gets a say in what an arrow key means — one row down is one tile down in a\n // grid, not one tile across — but the index, the selection and the wrapping stay here, so\n // up and down mean the same thing whichever view is showing.\n const onKey = (e) => {\n // `textual`: there is text in the box, so left/right are the caret's and no view\n // may claim them. Fixing a typo must not move the highlight.\n const claimed = ARROWS.has(e.key)\n ? viewMove(view, e.key, { index: idx, count: flat.length, textual: q.length > 0 })\n : null;\n if (claimed !== null) { e.preventDefault(); move(claimed); }\n else if (e.key === 'ArrowDown') { e.preventDefault(); move(1); }\n else if (e.key === 'ArrowUp') { e.preventDefault(); move(-1); }\n else if (e.key === 'Enter') { e.preventDefault(); activate(ui, flat[idx]); }\n else if (e.key === 'Escape' && q) { e.preventDefault(); clearSearch(ui, timerKey); }\n // The row under the highlight is the subject of the row menu, so the key that opens\n // one on every other list opens this one too — without making the user leave the\n // search box to reach it.\n else if (e.key === 'ContextMenu' || (e.shiftKey && e.key === 'F10')) {\n const it = flat[idx];\n // Arrowing here already selected the row, so the menu acts on the right thing.\n if (it?.menu) { e.preventDefault(); openRowMenu(document.querySelector('.launch-item.active, .grid-tile.active'), it, ui); }\n }\n };\n\n // What the server actually searched (transformer output) — shown when it differs\n // from what the user typed, so an LLM-assisted transform stays honest.\n const resolved = mode === 'search' ? state.se.resolved : null;\n const showResolved = resolved && (resolved.source === 'llm'\n || (resolved.tagFilters && resolved.tagFilters.length)\n || (resolved.semanticText || '').trim() !== q.trim());\n\n const inner = div({ className: 'launcher' },\n div({ className: 'launch-box' },\n icon(mode === 'command' ? 'command' : mode === 'filter' ? 'tag' : 'search', { size: 18 }),\n // `false`, not `'false'`: this is set as a property, and the string is truthy —\n // so the search box had spellcheck ON, red-underlining every filename typed into it.\n input({ className: 'launch-input', value: q, autofocus: true, spellcheck: false,\n placeholder: promptFor(state.caps, { compact: state.vp?.mode === 'phone', modal }) })\n .on({ input: onInput, keydown: onKey }),\n q ? button({ className: 'launch-clear', title: 'Clear' }, icon('close', { size: 14 }))\n .on({ click: () => clearSearch(ui, timerKey) }) : null,\n // Only where the browser can transcribe WITHOUT sending audio anywhere. A remote's\n // own mic needs no button from us — it dictates into this field once it is focused,\n // which is what `search.voice` is really for.\n state.voice?.canListen\n ? button({\n className: `launch-mic ${state.voice?.listening ? 'on' : ''}`,\n title: state.voice?.listening ? 'Stop listening' : 'Search by voice',\n 'aria-pressed': state.voice?.listening ? 'true' : 'false',\n }, icon('mic', { size: 15 })).on({ click: () => ui.engine.dispatch(new ExecCommandAction('search.voice')) })\n : null,\n // Which way to look at the drive. Not in the modal search, where the answer is\n // always \"the one thing I am about to press Enter on\".\n modal ? null : viewSwitcher(state.views, view, ui),\n ),\n showResolved ? resolvedBar(resolved) : null,\n // The results belong to the active view — see ui/components/views. The launcher says\n // WHAT is on screen (these groups, this highlight); the view says how it looks. That\n // split is why a gallery is a contribution rather than another branch in here.\n div({ className: 'launch-body' },\n renderView(view, { groups, index: idx, handlers: { hover: hoverAt, select: selectAt }, state, ui }),\n searchHelp(content.help, ui),\n ),\n );\n return modal ? inner : div({ className: 'editor' }, inner);\n}\n\n// An \"under-bar\" reflecting what the search actually ran (the transformer's output):\n// the semantic text it searched for + any tag filters it applied. Read-only and\n// honest — we don't rewrite the user's input, we just show what was dispatched.\nfunction resolvedBar(r) {\n return div({ className: 'launch-resolved' },\n span({ className: 'rq-label' }, r.source === 'llm' ? 'Interpreted as' : 'Searching'),\n (r.semanticText || '').trim() ? span({ className: 'rq-text' }, `“${r.semanticText.trim()}”`) : null,\n ...(r.tagFilters || []).map((f) => span({ className: 'rq-chip' }, icon('tag', { size: 11 }), filterLabel(f))),\n );\n}\n\n// Keep the drive's idea of \"what is selected\" in step with the highlighted row.\n//\n// The NODE goes along with the id. A search result or a recent can be from a collection\n// that isn't loaded — or a page that isn't — so an id alone is something the explorer\n// cannot resolve, and the commands that act on \"the selection\" then do nothing at all.\n\n/**\n * How this search box works — shown when, and only when, a search came back empty.\n *\n * That is the one moment the syntax is worth explaining: the user asked for something\n * and got nothing, and \"you typed it wrong\" is a real possibility they can act on.\n * Showing it any earlier is a permanent instruction panel above an empty drive, and\n * showing it when there ARE results would be explaining a thing that just worked.\n *\n * The text comes from the server's transformer, so it describes the grammar this\n * deployment actually runs rather than the one this file was written against.\n */\n// Decided by the `launcherContent` query — whether an offer applies, and what the server\n// suggests. This only draws it.\nfunction searchHelp(help, ui) {\n if (!help) return null;\n return div({ className: 'launch-help' },\n help.hint ? div({ className: 'lh-hint' }, icon('info', { size: 13 }), span(help.hint)) : null,\n help.examples.length\n ? div({ className: 'lh-examples' }, ...help.examples.map((ex) =>\n button({ className: 'lh-example', title: ex.label || 'Try this search' },\n span({ className: 'lh-q' }, ex.query),\n ex.label ? span({ className: 'lh-label' }, ex.label) : null,\n ).on({ click: () => activate(ui, ex) })))\n : null,\n );\n}\n\n\n\n\n// The trash is the one place \"delete\" means destroy, so its two verbs live together:\n// put it back, or finish the job on this one item. Emptying the whole trash was\n// previously the only way to purge anything.\n\n\n// Substring-first, then subsequence fuzzy score (0 = no match).\n",
100
+ "import { dd } from '../../runtime.js';\nimport { eventToKey } from '../../platform/keybindings.js';\nimport { icon } from '../icon.js';\nimport { rotationFor } from '../../bl/queries.js';\nimport { watchQuery } from '../../bl/watchQuery.js';\nimport { BeginRotationAction, CancelRotationAction, CopyTextAction, ExecCommandAction, PatchApiKeyDraftAction, RebindKeyAction, RememberOpenerAction, SetSettingAction, SetViewStateAction, ToggleApiKeyCapAction } from '../../bl/actions.js';\n\nconst { div, h2, h3, p, span, select, option, input, label, button, ul, li, code } = dd;\n\nexport default function settingsView(state, ui, regions) {\n const groups = state.settingsGroups || new Map();\n return div({ className: 'editor' },\n div({ className: 'stage' },\n div({ className: 'settings' },\n h2('Settings'),\n p({ className: 'sub' }, 'Preferences are stored in this browser. Plugins contribute their own settings here too.'),\n ...groups.map((g) => group(g, ui)),\n mcpSection(ui, state.caps),\n encryptionSection(state, ui),\n apiKeysSection(state, ui),\n openersSection(state.assoc, ui),\n regions.keybindings(),\n ),\n ),\n );\n}\n\nfunction group(g, ui) {\n return div({ className: 'group' },\n h3(g.category),\n ...g.items.map((s) => setting(s, ui)),\n );\n}\n\nfunction setting(s, ui) {\n return div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, s.title || s.key),\n s.description ? div({ className: 'd' }, s.description) : null,\n ),\n div({ className: 'control' }, control(s, ui)),\n );\n}\n\nfunction control(s, ui) {\n const set = (v) => ui.engine.dispatch(new SetSettingAction(s.key, v));\n if (s.type === 'boolean') {\n return label({ className: 'switch' },\n input({ type: 'checkbox', checked: !!s.value }).on({ change: (e) => set(e.target.checked) }),\n span({ className: 'track' }),\n );\n }\n if (s.type === 'enum') {\n return select({ className: 'input' },\n ...s.enum.map((opt, i) =>\n option({ value: opt, selected: s.value === opt }, (s.enumLabels && s.enumLabels[i]) || opt),\n ),\n ).on({ change: (e) => set(e.target.value) });\n }\n if (s.type === 'number') {\n // Guard against a cleared field (Number('') === 0) or a paste yielding NaN, and\n // clamp to the declared range so downstream consumers never see an invalid value.\n const commit = (e) => {\n let n = Number(e.target.value);\n if (e.target.value === '' || Number.isNaN(n)) { e.target.value = s.value; return; }\n if (s.minimum != null) n = Math.max(s.minimum, n);\n if (s.maximum != null) n = Math.min(s.maximum, n);\n e.target.value = n;\n set(n);\n };\n return input({\n className: 'input', type: 'number', value: s.value,\n $attrs: { min: s.minimum ?? '', max: s.maximum ?? '' },\n }).on({ change: commit });\n }\n return input({ className: 'input', value: s.value ?? '' }).on({ change: (e) => set(e.target.value) });\n}\n// Connecting an AI agent to this drive.\n//\n// Read-only, and deliberately so. Everything here is DEPLOYMENT configuration — which\n// identity provider issues the tokens, where the endpoint lives — supplied by the\n// environment or by whoever constructed the server. Pointing the drive at a different\n// authorization server changes who can reach every file in it, which is a `docker run`\n// decision rather than a preference, and a settings field would make it look otherwise.\n//\n// What this section is FOR is the two questions a self-hoster has and currently cannot\n// answer: what URL do I paste into my assistant, and why does it say 401. The second is\n// why `needsAuthorizationServer` is called out as a problem — a drive with auth on and\n// no authorization server configured looks perfectly set up and cannot work.\n//\n// It reads straight off `capabilities`, which the app already fetched at startup, so\n// there is no loading state and nothing to go stale.\nfunction mcpSection(ui, caps) {\n if (!caps) return null; // capabilities never arrived; the shell has bigger problems\n const mcp = caps.mcp;\n const auth = caps.auth || { authorizationServers: [], source: 'none' };\n if (!mcp?.enabled) {\n return div({ className: 'group' }, h3('AI agents (MCP)'),\n p({ className: 'sub' }, 'MCP is switched off on this server. Set TROVE_MCP=on to enable it.'));\n }\n\n // The \"denied clipboard still has to hand the value over\" reasoning moved into\n // CopyTextAction, which is where the other three copies of it went too.\n const copy = (text) => () => ui.engine.dispatch(new CopyTextAction(text));\n\n const servers = auth.authorizationServers || [];\n // Where the value came from matters when it is wrong: \"we took this from your JWT\n // issuer\" points at a different file than \"you set this\".\n const provenance = auth.source === 'jwt-issuer' ? 'from TROVE_JWT_ISSUER'\n : auth.source === 'configured' ? 'from TROVE_AUTH_SERVER' : null;\n\n return div({ className: 'group' },\n h3('AI agents (MCP)'),\n p({ className: 'sub' }, 'Point an AI assistant at this drive. It signs in as you and sees exactly the collections you can see.'),\n\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'Server URL'),\n div({ className: 'd' }, 'Paste this into your assistant\\u2019s MCP settings.'),\n ),\n div({ className: 'control mcp-url' },\n span({ className: 'mono' }, mcp.endpoint),\n button({ className: 'btn small', title: 'Copy' }, icon('link', { size: 13 })).on({ click: copy(mcp.endpoint) }),\n ),\n ),\n\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'Sign-in required'),\n div({ className: 'd' }, mcp.requiresAuth\n ? 'Agents must present a token, the same one this browser uses.'\n : 'This drive is open, so agents connect without a token \\u2014 exactly like the web app does.'),\n ),\n div({ className: 'control' }, span({ className: 'mono' }, mcp.requiresAuth ? 'Yes' : 'No')),\n ),\n\n // The failure that looks like success. Before the value, because it is the answer\n // to \"I set this up and my agent just says 401\".\n mcp.needsAuthorizationServer\n ? div({ className: 'mcp-warn' }, icon('warn', { size: 15 }),\n span('This drive requires a token but no authorization server is set, so an agent has '\n + 'nowhere to sign in. Set TROVE_AUTH_SERVER (or TROVE_JWT_ISSUER) to the issuer URL '\n + 'of your identity provider and restart.'))\n : null,\n\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'Authorization server'),\n div({ className: 'd' }, 'Where clients are sent to sign in \\u2014 for the whole drive, not just for agents. '\n + 'Set with TROVE_AUTH_SERVER; defaults to TROVE_JWT_ISSUER when that is set.'),\n ),\n div({ className: 'control' },\n servers.length\n ? span({ className: 'mono' }, servers.join(', ') + (provenance ? ` (${provenance})` : ''))\n : span({ className: 'mono muted' }, 'not set'),\n ),\n ),\n\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'Discovery document'),\n div({ className: 'd' }, 'What a client reads to find out how to authenticate (RFC 9728).'),\n ),\n div({ className: 'control mcp-url' }, span({ className: 'mono small' }, auth.metadataUrl)),\n ),\n );\n}\n\n// Default openers per file type — the \"always use this\" choices from the opener\n// chooser. Each row shows the type → viewer; the × forgets it (so the next open of\n// that type asks again). Empty when the user hasn't set any defaults.\n// --- API keys -------------------------------------------------------------------\n\nconst CAPS = [\n { id: 'read', label: 'Read', hint: 'list and download' },\n { id: 'write', label: 'Write', hint: 'upload and rename' },\n { id: 'delete', label: 'Delete', hint: 'trash and purge' },\n { id: 'admin', label: 'Admin', hint: 'includes all of the above' },\n];\n\nconst ANY = '*';\n\nfunction apiKeysSection(state, ui) {\n const keys = state.keys || {};\n\n // Nothing to dispatch from here. The list is loaded by the query's `bootAction` — it\n // arrives because something is LOOKING at it, which is what makes it lazy without a\n // module-level flag and a render with a side effect. See bl/queries.js.\n //\n // A non-admin's 403 is the correct answer rather than an error: the section simply is\n // not part of their settings screen.\n if (keys.forbidden) return null;\n if (keys.error) {\n return div({ className: 'group' },\n h3('API keys'),\n // Said out loud. This used to render nothing at all on any failure, because the\n // catch set `loaded` as well as `error` — so one dropped request left a blank space\n // where the section belongs, with no message and no way to try again.\n p({ className: 'sub' }, `Couldn’t load the key list: ${keys.error}`),\n div({ className: 'keys-actions' },\n button({ className: 'btn' }, 'Try again')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('keys.load')) })),\n );\n }\n if (!keys.loaded) return null;\n\n const collections = state.ex?.collections || [];\n\n return div({ className: 'group' },\n h3('API keys'),\n p({ className: 'sub' },\n 'Give a script or a service access without giving it an account. A key carries '\n + 'capabilities and no identity, so anything it does is attributed to the key rather '\n + 'than to a person \\u2014 and it can only reach the collections you scope it to.'),\n\n keys.minted ? mintedBanner(keys.minted, ui) : null,\n keys.draft ? draftForm(keys, collections, ui) : null,\n\n !keys.draft && !keys.minted\n ? div({ className: 'keys-actions' },\n button({ className: 'btn' }, icon('plus', { size: 14 }), 'New key')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('keys.new')) }))\n : null,\n\n keys.keys?.length\n ? div({ className: 'keys-list' }, ...keys.keys.map((k) => keyRow(k, keys, collections, ui)))\n : div({ className: 'keys-empty' }, 'No keys yet.'),\n );\n}\n\n/**\n * The secret, shown once.\n *\n * Deliberately loud and deliberately blocking the rest of the section: the server stored\n * only a hash, so this is the only moment the value exists anywhere. A quiet row in a\n * table would be dismissed without being copied.\n */\nfunction mintedBanner(minted, ui) {\n const copy = () => ui.engine.dispatch(new CopyTextAction(minted.secret, 'Key copied'));\n return div({ className: 'key-minted' },\n div({ className: 'key-minted-head' },\n icon('warn', { size: 15 }),\n span(`\\u201c${minted.key.name}\\u201d is ready \\u2014 copy it now.`),\n ),\n p({ className: 'key-minted-note' },\n 'This is the only time it can be shown. It is stored as a hash, so it cannot be '\n + 'recovered \\u2014 if it is lost, revoke the key and make another.'),\n div({ className: 'key-secret' },\n code({ className: 'mono' }, minted.secret),\n button({ className: 'btn small', title: 'Copy' }, icon('link', { size: 13 })).on({ click: copy }),\n ),\n div({ className: 'keys-actions' },\n button({ className: 'btn' }, 'Done').on({ click: () => ui.engine.dispatch(new ExecCommandAction('keys.dismissMinted')) }),\n ),\n );\n}\n\nfunction draftForm(keys, collections, ui) {\n const draft = keys.draft;\n // Resolved by the apiKeys view: what this draft would actually grant, or null when it\n // would grant nothing.\n const scopes = keys.draftScopes;\n const ready = !!draft.name.trim() && !!scopes;\n\n return div({ className: 'key-form' },\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'Name'),\n div({ className: 'd' }, 'What it is for. This is what the list shows, so make it recognisable.'),\n ),\n div({ className: 'control' },\n input({ className: 'input', value: draft.name, $attrs: { placeholder: 'CI uploader' } })\n .on({ input: (e) => ui.engine.dispatch(new PatchApiKeyDraftAction({ name: e.target.value })) }),\n ),\n ),\n\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'Expires after'),\n div({ className: 'd' }, 'Days from now. Leave blank and it never expires.'),\n ),\n div({ className: 'control' },\n input({\n className: 'input', type: 'number', value: draft.expiresInDays,\n $attrs: { min: '1', max: '3650', placeholder: 'never' },\n }).on({ input: (e) => ui.engine.dispatch(new PatchApiKeyDraftAction({ expiresInDays: e.target.value })) }),\n ),\n ),\n\n div({ className: 'key-scopes' },\n div({ className: 'key-scopes-head' },\n div({ className: 't' }, 'What it may do'),\n div({ className: 'd' },\n 'Per collection. A key with nothing ticked grants nothing and cannot be created.'),\n ),\n scopeRow({ id: ANY, name: 'All collections', wildcard: true }, draft, ui),\n ...collections.map((c) => scopeRow(c, draft, ui)),\n ),\n\n div({ className: 'keys-actions' },\n button({ className: 'btn primary', $attrs: ready ? {} : { disabled: 'true' } },\n keys.busy === 'mint' ? 'Creating\\u2026' : 'Create key')\n .on({ click: () => ready && ui.engine.dispatch(new ExecCommandAction('keys.mint')) }),\n button({ className: 'btn' }, 'Cancel').on({ click: () => ui.engine.dispatch(new ExecCommandAction('keys.cancel')) }),\n ),\n );\n}\n\nfunction scopeRow(collection, draft, ui) {\n const held = new Set(draft.caps[collection.id] || []);\n return div({ className: `key-scope ${collection.wildcard ? 'wildcard' : ''}` },\n div({ className: 'key-scope-name' },\n icon(collection.wildcard ? 'grid' : 'files', { size: 14 }),\n span(collection.name || collection.id),\n ),\n div({ className: 'key-scope-caps' },\n ...CAPS.map((c) => label({ className: `cap ${held.has(c.id) ? 'on' : ''}`, title: c.hint },\n input({ type: 'checkbox', checked: held.has(c.id) })\n .on({ change: () => ui.engine.dispatch(new ToggleApiKeyCapAction(collection.id, c.id)) }),\n span(c.label),\n )),\n ),\n );\n}\n\nfunction keyRow(k, keys, collections, ui) {\n const revoked = !!k.revokedAt;\n const expired = k.expiresAt != null && k.expiresAt <= Date.now();\n const dead = revoked || expired;\n return div({ className: `key-row ${dead ? 'dead' : ''}` },\n div({ className: 'key-row-main' },\n div({ className: 'key-row-name' },\n span({ className: 't' }, k.name),\n revoked ? span({ className: 'key-tag' }, 'revoked')\n : expired ? span({ className: 'key-tag' }, 'expired') : null,\n ),\n div({ className: 'key-row-scopes' }, ...scopeSummary(k, collections)),\n div({ className: 'key-row-meta' }, metaLine(k)),\n ),\n !dead\n ? button({\n className: 'btn small danger',\n $attrs: keys.busy === k.id ? { disabled: 'true' } : {},\n }, keys.busy === k.id ? '\\u2026' : 'Revoke').on({ click: () => ui.engine.dispatch(new ExecCommandAction('keys.revoke', k.id)) })\n : null,\n );\n}\n\nfunction scopeSummary(k, collections) {\n // The name if we know it, the id if we do not. A key can outlive the collection it was\n // scoped to, and showing a bare id then is more honest than showing nothing — it is\n // also the thing you would search for to find out what happened to it.\n const nameOf = (id) => collections.find((c) => c.id === id)?.name || id;\n return (k.scopes || []).map((s) => span({ className: 'key-chip' },\n span({ className: 'where' }, s.collectionId === ANY ? 'all collections' : nameOf(s.collectionId)),\n span({ className: 'what' }, s.capabilities.join(' \\u00b7 ')),\n ));\n}\n\nfunction metaLine(k) {\n const when = (ms) => new Date(ms).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });\n const bits = [`created ${when(k.createdAt)}`];\n if (k.createdBy) bits.push(`by ${k.createdBy}`);\n // \"Never used\" is the more useful of the two facts: it is how you find the key nobody\n // needs and can safely revoke.\n bits.push(k.lastUsedAt ? `last used ${when(k.lastUsedAt)}` : 'never used');\n if (k.expiresAt) bits.push(`expires ${when(k.expiresAt)}`);\n return bits.join(' \\u00b7 ');\n}\n\n/**\n * The open collection's key: which one it is, and moving it to a new one.\n *\n * Only for an encrypted collection, and only for an admin — a non-admin gets a 403 reading\n * the rotation state, which is the correct answer rather than an error, so the section\n * simply is not drawn.\n */\nfunction encryptionSection(state, ui) {\n const collectionId = state.ex?.collectionId;\n const enc = state.ex?.collections?.find((c) => c.id === collectionId)?.encryption;\n if (!enc?.enabled) return null;\n // Watching the query is what LOADS it — its bootAction reads the rotation state and its\n // realization polls while one is running. Nothing fetches while this screen is closed.\n return ui.watch(watchQuery(ui.engine, rotationFor(collectionId)), (rot) => encryptionBody(enc, rot || {}, ui));\n}\n\nfunction encryptionBody(enc, rot, ui) {\n const running = rot.rotation?.status === 'running';\n const est = rot.estimate;\n\n return div({ className: 'group' },\n h3('Encryption'),\n p({ className: 'sub' }, 'Files in this collection are sealed before they leave your browser. The drive holds the key.'),\n\n // The only thing that identifies which key the collection is on, and what a sideloaded\n // object is matched against — so it has to be somewhere findable and copyable.\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'Key fingerprint'),\n div({ className: 'd' }, 'Identifies the key this collection is on.'),\n ),\n div({ className: 'control' },\n button({ className: 'btn small', title: 'Copy' }, dd.h('code', enc.fingerprint))\n .on({ click: () => ui.engine.dispatch(new CopyTextAction(enc.fingerprint, 'Fingerprint copied')) }),\n ),\n ),\n\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, running ? 'Rotating the key' : 'Rotate the key'),\n div({ className: 'd' }, running\n ? `${rot.rotation.moved} moved${rot.rotation.failed ? `, ${rot.rotation.failed} failed` : ''} — this continues in the background.`\n : rotationCost(est)),\n ),\n div({ className: 'control' },\n running\n ? button({ className: 'btn small', disabled: !!rot.busy }, 'Stop')\n .on({ click: () => ui.engine.dispatch(new CancelRotationAction()) })\n : button({ className: 'btn small', disabled: !!rot.busy }, 'Rotate')\n .on({ click: () => ui.engine.dispatch(new BeginRotationAction()) }),\n ),\n ),\n running\n ? null\n // Said before it is started rather than after: what has moved stays moved, so this\n // is not a job that can be undone by regretting it.\n : div({},\n rotationBill(est),\n p({ className: 'sub' }, 'Every file is re-sealed under a new key and the old one is retired once nothing is left on it. Files stay readable throughout.'),\n ),\n );\n}\n\n/**\n * What a rotation would cost, before anyone starts one.\n *\n * The server already composes this in words — it knows the provider and its pricing, and\n * whether anyone is billed at all — so this shows what it said rather than recomputing a\n * worse version from a file count. `applicable` is false for a store nobody charges for,\n * where the only cost is time.\n */\nfunction rotationCost(est) {\n if (!est) return 'Re-seals every file under a fresh key.';\n return est.summary || 'Re-seals every file under a fresh key.';\n}\n\n/** The itemised estimate, when the provider charges for the traffic. */\nfunction rotationBill(est) {\n if (!est?.applicable || !(est.lines || []).length) return null;\n return div({ className: 'rot-bill' },\n ...est.lines.map((l) => div({ className: 'rb-line' },\n span(l.label || l.name || ''), span({ className: 'mono' }, l.amount || l.value || ''))),\n est.total ? div({ className: 'rb-line total' }, span('Estimated total'), span({ className: 'mono' }, est.total)) : null,\n // Prices move and this is a guess against a snapshot of them; saying when stops it\n // reading as a quote.\n est.asOf ? div({ className: 'rb-asof' }, `Prices as of ${est.asOf}.`) : null,\n );\n}\n\nfunction openersSection(rows, ui) {\n return div({ className: 'group' },\n h3('Default Openers'),\n rows.length\n ? div({},\n ...rows.map((r) =>\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, r.typeKey),\n div({ className: 'd' }, r.missing ? `${r.openerTitle} (no longer installed)` : `Opens with ${r.openerTitle}`),\n ),\n div({ className: 'control' },\n button({ className: 'iconbtn', title: 'Forget this default' }, icon('close', { size: 14 }))\n .on({ click: () => ui.engine.dispatch(new RememberOpenerAction(r.typeKey, null)) }),\n ),\n ),\n ),\n )\n : p({ className: 'sub', $styling: { margin: 0 } }, 'No default openers set yet. When a file type has more than one viewer, you can pick one and check “Always use this”.'),\n );\n}\n\n// Which shortcut is listening for its new chord. Transient, and still engine state: it\n// decides whether a row renders a `<kbd>` or \"Press keys…\". See bl/viewState.js.\nexport const CAPTURE = 'keybindingCapture';\n\n// Its own region, over the keybindings view and the capture state.\n//\n// Everything a row needs is decided by the query — the command's title, whether the user\n// changed it, and whether another command answers to the same chord. That last one is not\n// something a row could work out for itself: it needs the whole list at once.\n//\n// Rebinding dispatches with the binding ID. The component has never held a binding object,\n// only a description of one, which is the point.\n// Built once and PASSED IN, beside the other regions in ui/compositions/workbench.js. It\n// was built at module scope with `kbRegion ??= region(ui.engine, …)` — right that a region\n// must be built once, wrong about where: at module scope it captures the FIRST `ui` and\n// engine it ever sees and pins them for the module's life, which is the shape `watchQuery`\n// deliberately avoids by keying its cache on the engine. Folding it into the parent\n// settingsView region would also work and costs granularity — a chord capture would\n// re-render the whole settings screen — so it is handed down instead.\n\nexport function keybindingRows(bindings, ui, capturing) {\n const setCapturing = (id) => ui.engine.dispatch(new SetViewStateAction(CAPTURE, id));\n const stop = () => setCapturing(null);\n const rebind = (bindingId, key) => ui.engine.dispatch(new RebindKeyAction(bindingId, key));\n return div({ className: 'group' },\n h3('Keyboard Shortcuts'),\n p({ className: 'sub' }, 'Click a shortcut to record a new one. Esc cancels; Backspace clears it.'),\n // Every binding, not the first 40. The cap was arbitrary and silent — with no \"N\n // more\" anywhere, the shortcuts past it simply did not exist as far as anyone could\n // tell, and one plugin keymap was enough to push real ones off the end.\n ...bindings.map((b) => {\n const listening = capturing === b.bindingId;\n return div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, b.title),\n div({ className: 'd' }, b.command),\n ),\n div({ className: 'control' },\n b.clash && !listening\n ? span({ className: 'kbd-clash', title: 'Another command answers to this shortcut too — the one registered last wins' },\n icon('warn', { size: 12 }))\n : null,\n button({ className: `kbd-edit ${listening ? 'listening' : ''} ${b.clash ? 'clash' : ''}`, title: listening ? 'Press the new shortcut' : 'Click to rebind' },\n listening ? span('Press keys…') : dd.h('kbd', b.label))\n .on({\n click: () => setCapturing(listening ? null : b.bindingId),\n blur: () => { if (listening) stop(); },\n keydown: (e) => {\n if (!listening) return;\n e.preventDefault();\n e.stopPropagation();\n if (e.key === 'Escape') return stop();\n if (e.key === 'Backspace') { rebind(b.bindingId, null); return stop(); }\n // A bare modifier isn't a chord yet — wait for the key it modifies.\n if (['Control', 'Meta', 'Alt', 'Shift'].includes(e.key)) return;\n rebind(b.bindingId, eventToKey(e));\n stop();\n },\n $attach: (el) => { if (listening) queueMicrotask(() => el.focus()); },\n }),\n b.custom\n ? button({ className: 'c-link', title: 'Back to the default' }, 'reset')\n .on({ click: () => { rebind(b.bindingId, null); setCapturing(null); } })\n : null,\n ),\n );\n }),\n );\n}\n",
101
+ "// The only thing on screen until a collection is chosen.\n//\n// Every collection-scoped request names its collection in the path, so before one is\n// known there is no file list to draw, nothing to search, and nowhere to upload to. The\n// old behaviour was to pick something — the remembered one, else `default`, else the\n// first in the list — and that is exactly the guess this replaces: on a shared drive it\n// opened a collection plenty of people could not read, and presented the permission error\n// as their drive.\n//\n// So there are two questions and no guesses. A drive with nothing in it asks for a\n// collection to be made; a drive with several asks which one. Once answered, the choice is\n// remembered in localStorage and this never appears again.\n\nimport { dd } from '../../runtime.js';\nimport { icon } from '../icon.js';\nimport { ExecCommandAction } from '../../bl/actions.js';\n\nconst { div, h2, p, button, span } = dd;\n\nexport default function collectionGate(state, ui) {\n const ex = state.ex || {};\n return div({ className: 'editor' },\n div({ className: 'stage' },\n div({ className: 'gate' },\n ex.gate === 'create' ? createPrompt(ui) : choosePrompt(ex, ui),\n ),\n ),\n );\n}\n\n/**\n * A drive with no collections at all.\n *\n * Only shown to someone who may actually create one — `OpenInitialCollectionAction`\n * sends everyone else to the \"ask an administrator\" message instead, because inviting\n * someone to do a thing they are not allowed to do is worse than saying nothing.\n */\nfunction createPrompt(ui) {\n return div({ className: 'gate-card' },\n div({ className: 'gate-icon' }, icon('files', { size: 26 })),\n h2('Make your first collection'),\n p({ className: 'gate-sub' },\n 'A collection is a backing store you own — a bucket, a directory, a mount. Files '\n + 'live in one, and permissions are granted on one. Nothing can be uploaded until '\n + 'there is somewhere to put it.'),\n div({ className: 'gate-actions' },\n button({ className: 'btn primary' }, icon('plus', { size: 14 }), 'New collection')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('collections.create')) }),\n ),\n );\n}\n\n/** Collections exist, but the user has not said which one they want. */\nfunction choosePrompt(ex, ui) {\n const collections = ex.collections || [];\n return div({ className: 'gate-card' },\n div({ className: 'gate-icon' }, icon('grid', { size: 26 })),\n h2(collections.length === 1 ? 'Open your collection' : 'Choose a collection'),\n p({ className: 'gate-sub' },\n collections.length === 1\n ? 'This is the one you have access to. Opening it will be remembered for next time.'\n : 'Files, search and uploads all belong to one collection. Your choice is remembered '\n + 'for next time, and you can switch from the status bar whenever you like.'),\n div({ className: 'gate-list' },\n ...collections.map((c) => button({ className: 'gate-choice' },\n div({ className: 'gate-choice-main' },\n span({ className: 'n' }, c.name || c.id),\n span({ className: 'd' }, c.driver ? `${c.driver}${c.description ? ` · ${c.description}` : ''}` : (c.description || '')),\n ),\n // What they may do, from the server's own answer — so a read-only collection says\n // so before they open it and find the Upload button missing.\n span({ className: 'gate-caps' }, (c.capabilities || []).join(' · ')),\n ).on({ click: () => ui.engine.dispatch(new ExecCommandAction('collections.switch', c.id)) })),\n ),\n ex.canCreateCollection\n ? div({ className: 'gate-actions' },\n button({ className: 'btn' }, icon('plus', { size: 14 }), 'New collection')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('collections.create')) }),\n )\n : null,\n );\n}\n",
102
+ "import { dd } from '../../runtime.js';\nimport { icon } from '../icon.js';\nimport { ExecCommandAction, OpenPluginPanelAction, RefreshPluginAction, SetPluginSecretAction, SetSettingAction, ShowDialogAction, UninstallPluginAction } from '../../bl/actions.js';\nimport { describeTrust } from '../../bl/trust.js';\n\nconst { div, span, p, button, h2, input, label } = dd;\n\nexport default function pluginsView(state, ui) {\n const plugins = state.plugins || [];\n return div({ className: 'editor' },\n div({ className: 'stage' },\n div({ className: 'plugins' },\n h2('Plugins'),\n p({ className: 'sub', $styling: { color: 'var(--text-dim)', margin: '0 0 8px' } },\n 'Plugins are sandboxed packages you install from a file or URL. They run in an isolated iframe and reach Trove only through a message channel, using the capabilities you granted.'),\n div({ className: 'plugin-install' },\n button({ className: 'btn primary' }, icon('upload', { size: 15 }), 'Install from file…')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('plugins.installFromFile')) }),\n button({ className: 'btn' }, icon('plug', { size: 15 }), 'Install from URL…')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('plugins.installFromUrl')) }),\n ),\n plugins.length\n ? div({ $styling: { display: 'flex', 'flex-direction': 'column', gap: '12px', 'margin-top': '14px' } }, ...plugins.map((pl) => installedCard(pl, state, ui)))\n : div({ className: 'empty', $styling: { padding: '48px' } }, icon('plug', { size: 30 }), span('No plugins installed yet.')),\n ),\n ),\n );\n}\n\nfunction installedCard(pl, state, ui) {\n const connectivity = !pl.responsive ? 'not responding' : pl.manifest?.online === false ? 'offline' : 'connected';\n const features = pl.features || [];\n return div({ className: 'plugin-card' },\n div({ className: 'top' },\n div({ className: 'avatar' }, (pl.name || '?')[0].toUpperCase()),\n div({ $styling: { flex: '1' } },\n div({ className: 'name' }, pl.name, pl.version ? span({ $styling: { color: 'var(--text-faint)', 'font-weight': '400', 'margin-left': '6px' } }, 'v' + pl.version) : null),\n div({ $styling: { 'font-size': '11px', color: 'var(--text-faint)' } }, pl.id),\n ),\n trustBadge(pl.trust),\n span({ className: `status ${pl.status}` }, pl.status),\n ),\n pl.error ? div({ className: 'desc', $styling: { color: 'var(--danger)' } }, pl.error) : null,\n div({ className: 'caps' }, ...(pl.capabilities || []).map((c) => span({ className: 'cap' }, c))),\n (pl.endpoints || []).length\n ? div({ className: 'plugin-endpoints', $styling: { 'font-size': '11px', color: 'var(--text-faint)', 'margin-top': '2px' } },\n icon('plug', { size: 11 }), ' Network: ', (pl.endpoints || []).map((e) => e.host).join(', '))\n : null,\n pl.status === 'active'\n ? div({ className: 'plugin-features' },\n div({ className: 'pf-head' }, span(`Features · ${connectivity}`), span({ className: 'muted' }, `${features.filter((f) => f.available).length}/${features.length} available`)),\n features.length\n ? div({ className: 'pf-list' }, ...features.map(featureRow))\n : div({ className: 'muted', $styling: { 'font-size': '12px' } }, pl.responsive ? 'No contributions announced.' : 'No manifest received — the plugin may not be running.'),\n )\n : null,\n (pl.settingsSchema || []).length ? settingsSection(pl, ui, state) : null,\n div({ className: 'actions' },\n pl.hasUi ? button({ className: 'btn' }, icon('command', { size: 14 }), 'Open panel').on({ click: () => ui.engine.dispatch(new OpenPluginPanelAction(pl.id)) }) : null,\n button({ className: 'btn' }, icon('refresh', { size: 14 }), 'Refresh').on({ click: () => ui.engine.dispatch(new RefreshPluginAction(pl.id)) }),\n button({ className: 'btn danger' }, 'Uninstall').on({\n click: () => ui.engine.dispatch(new ShowDialogAction({\n kind: 'confirm', title: `Uninstall ${pl.name}?`, danger: true, confirmLabel: 'Uninstall',\n body: 'The plugin and all data it stored will be removed.',\n confirmActions: [new UninstallPluginAction(pl.id)],\n })),\n }),\n ),\n );\n}\n\nfunction settingsSection(pl, ui, state) {\n return div({ className: 'plugin-features' },\n div({ className: 'pf-head' }, span('Settings')),\n div({ $styling: { display: 'flex', 'flex-direction': 'column', gap: '8px' } },\n ...pl.settingsSchema.map((s) => settingRow(pl, s, ui, state)),\n ),\n );\n}\n\nfunction settingRow(pl, s, ui, state) {\n const key = `${pl.id}.${s.key}`;\n const value = s.secret ? '' : (state.settings?.[key] ?? s.default ?? '');\n return div({ className: 'setting', $styling: { padding: '6px 0' } },\n div({ className: 'info' }, div({ className: 't' }, s.title || s.key), s.description ? div({ className: 'd' }, s.description) : null),\n div({ className: 'control' },\n s.secret\n ? input({ className: 'input', type: 'password', placeholder: 'Set secret…' }).on({\n change: (e) => { if (e.target.value) { ui.engine.dispatch(new SetPluginSecretAction(pl.id, s.key, e.target.value)); e.target.value = ''; e.target.placeholder = 'Saved ✓'; } },\n })\n : s.type === 'boolean'\n ? label({ className: 'switch' }, input({ type: 'checkbox', checked: !!value }).on({ change: (e) => ui.engine.dispatch(new SetSettingAction(key, e.target.checked)) }), span({ className: 'track' }))\n : input({ className: 'input', value }).on({ change: (e) => ui.engine.dispatch(new SetSettingAction(key, e.target.value)) }),\n ),\n );\n}\n\n// The compact badge. WHAT the signature means is decided in bl/trust.js — this only\n// chooses how few characters to say it in, which is the part that is genuinely a question\n// about a crowded row. The two badges used to be two `if` ladders maintained separately,\n// and this one was missing the branch that distinguishes a tampered package from an\n// unsigned one.\nfunction trustBadge(trust) {\n if (!trust) return null;\n const t = describeTrust(trust);\n const label = t.status === 'verified' ? t.domain\n : t.status === 'invalid' ? 'invalid signature'\n : t.status;\n return span({ className: `trust ${t.tone}`, title: t.explanation },\n icon(t.icon, { size: 12 }), label);\n}\n\nconst KIND_ICON = { command: 'command', opener: 'file', indexer: 'search', statusItem: 'info' };\nfunction featureRow(f) {\n return div({ className: `pf-row ${f.available ? '' : 'off'}` },\n icon(KIND_ICON[f.kind] || 'command', { size: 13 }),\n span({ className: 'pf-title' }, f.title),\n span({ className: 'pf-kind' }, f.kind),\n f.offline ? span({ className: 'pf-badge offline-ok', title: 'Works offline' }, 'offline ✓') : null,\n span({ className: `pf-dot ${f.available ? 'on' : 'no'}`, title: f.available ? 'Available now' : 'Unavailable now' }),\n );\n}\n",
103
+ "// The admin console.\n//\n// Drive-level administration had accumulated in three places and no place: API keys in\n// Settings, storage diagnostics behind a status-bar item, ACLs in a dialog, and the driver\n// registry, the indexers and the identity provider only through the API. Each landed where\n// it did for a local reason, and the result was that there was nowhere to send someone who\n// had just been made an administrator.\n//\n// A DESTINATION, not a route. 006 introduced share links, and what it actually established\n// is that this app does not reflect its state in the address bar — it consumes a share path\n// at boot and immediately replaces it with `/`, because a URL that goes stale the moment\n// you navigate is worse than one that says nothing. So there is no router to hang a route\n// on, and an activity-bar destination beside Plugins and Settings is the consistent answer.\n//\n// Almost nothing here is new capability. It is gathering: every value below already comes\n// from `/api/capabilities`, which the app fetches at startup, or from a query that already\n// exists. What was missing was somewhere to look.\n\nimport { dd } from '../../runtime.js';\nimport { watchQuery } from '../../bl/watchQuery.js';\nimport { grantsFor } from '../../bl/queries.js';\nimport { activate } from '../activate.js';\nimport { bytes } from '../format.js';\nimport { ExecCommandAction, SetGrantAction } from '../../bl/actions.js';\n\nconst { div, h2, h3, p, span, button, select, option, input } = dd;\n\nexport default function adminView(state, ui) {\n const caps = state.caps;\n return div({ className: 'editor' },\n div({ className: 'stage' },\n div({ className: 'settings admin' },\n h2('Administration'),\n p({ className: 'sub' }, 'How this drive is configured, and what it can do. Most of it is decided by the deployment rather than here.'),\n accessSection(caps, state, ui),\n collectionsSection(state, ui),\n storageSection(caps, state, ui),\n extensionsSection(caps, state),\n workSection(state, ui),\n ),\n ),\n );\n}\n\n/** A label/value row, matching the settings screen so the two read as one thing. */\nfunction row(title, detail, value) {\n return div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, title),\n detail ? div({ className: 'd' }, detail) : null,\n ),\n div({ className: 'control' }, typeof value === 'string' ? span({ className: 'mono' }, value) : value),\n );\n}\n\n/**\n * Who this drive thinks you are, and who it lets in.\n *\n * The identity driver and whether authentication is required are deployment decisions —\n * environment variables, not preferences — so they are reported rather than offered. Which\n * is the point: an admin needs to know what is in force, and previously could only find out\n * by reading the server's configuration or calling the API.\n */\nfunction accessSection(caps, state, ui) {\n const auth = caps?.auth || {};\n const me = caps?.principal || state.so?.me || {};\n const servers = auth.authorizationServers || [];\n return div({ className: 'group' },\n h3('Access'),\n p({ className: 'sub' }, 'Who can reach this drive. Set by the deployment, not here.'),\n row('Signed in as', me.anonymous ? 'This drive does not require a sign-in.' : (me.email || me.id),\n me.anonymous ? 'anonymous' : (me.name || me.id || '—')),\n row('Sign-in required', 'Whether a caller must present a token.',\n caps?.mcp?.requiresAuth ? 'Yes' : 'No'),\n row('Authorization server', 'Where clients are sent to sign in.',\n servers.length ? servers.join(', ') : 'not set'),\n // API keys stay in Settings for now and are LINKED rather than duplicated: two places\n // to revoke a credential is worse than one place in the wrong screen.\n row('API keys', 'Credentials for scripts and services, scoped per collection.',\n button({ className: 'btn small' }, 'In Settings')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.openSettings')) })),\n );\n}\n\n/**\n * Every collection, what it sits on, and whether it is sealed.\n *\n * The list an administrator actually wants: not \"which one am I looking at\" — the switcher\n * in the status bar answers that — but what exists, on what, under which key. Rows and their\n * actions come from the engine (`collectionAdmin`), so this only draws.\n */\nfunction collectionsSection(state, ui) {\n const admin = state.ex?.collectionAdmin;\n const rows = admin?.rows || [];\n // SEQUENCED, not fired together. `dispatch()` returns a feed rather than a promise, so\n // `forEach(dispatch)` starts everything at once — and these pairs are switch-then-do,\n // where the second only means anything after the first has landed. Fired concurrently,\n // \"Rotate key…\" opened Settings and was then thrown back to home by the switch that had\n // not finished yet. Same shape as platform/commands.js, which got this right first.\n // The same \"run this item's list of actions\" as every menu item and list row — one\n // implementation, in ui/activate.js, rather than a third spelling of the loop here.\n const run = (actions) => () => activate(ui, { actions });\n return div({ className: 'group' },\n h3('Collections'),\n p({ className: 'sub' }, 'What exists on this drive, where its bytes live, and which key seals it.'),\n ...(rows.length ? rows.map((c) => div({ className: 'setting stacked' },\n div({ className: 'info' },\n div({ className: 't' }, c.name, c.current ? span({ className: 'mono muted' }, ' · open') : null),\n div({ className: 'd' },\n c.encrypted\n // The fingerprint is the only way to tell two keys apart across a rotation, and\n // it is safe to show — it is not the key.\n ? `${c.driver} · sealed, key ${String(c.fingerprint).slice(0, 12)}…`\n : `${c.driver} · not encrypted`),\n div({ className: 'd' }, `You may: ${c.capabilities.join(', ') || 'nothing'}`),\n ),\n div({ className: 'control admin-actions' },\n c.current ? null : button({ className: 'btn small' }, 'Open').on({ click: run(c.actions.open) }),\n button({ className: 'btn small' }, 'Scan').on({ click: run(c.actions.scan) }),\n // Routed to Settings rather than started here: the estimate and the confirmation\n // live there, and a rotation begun without seeing its cost is the button nobody\n // should have.\n c.actions.rotate\n ? button({ className: 'btn small' }, 'Rotate key…').on({ click: run(c.actions.rotate) })\n : null,\n // Only offered where you could actually change it — `setGrant` asserts admin, so a\n // button that always showed would be one that sometimes only produces a 403.\n c.actions.access\n ? button({ className: `btn small ${state.wb?.aclFor === c.id ? 'on' : ''}` }, 'Access…')\n .on({ click: run(c.actions.access) })\n : null,\n ),\n // Leased only while open, by a query keyed on this collection — the same shape\n // settingsView uses for `rotationFor`.\n state.wb?.aclFor === c.id\n ? ui.watch(watchQuery(ui.engine, grantsFor(c.id)), (g) => accessEditor(g, ui, c.id))\n : null,\n )) : [row('Collections', 'Nothing has been created yet.', 'none')]),\n admin?.canCreate\n ? div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'New collection'),\n div({ className: 'd' }, 'A backing store you own — a bucket, a directory, a mount. Encryption is chosen here, at creation.'),\n ),\n div({ className: 'control' },\n button({ className: 'btn small' }, 'Create…').on({ click: run(admin.create) })),\n )\n : row('New collection', 'You do not have permission to create one on this drive.', 'not allowed'),\n );\n}\n\n/** The capabilities a grant can carry. `admin` expands to the rest, server-side. */\nconst CAPS = ['read', 'write', 'delete', 'admin'];\n\n/**\n * Who may do what on one collection.\n *\n * Rendered under the row an administrator opened, and reading `grantsFor(id)` — a query\n * keyed by collection with a `bootAction`, so it loads when this is shown and stops\n * mattering when it is not.\n *\n * Revoking is granting with nothing: one call, so the two cannot drift.\n */\nfunction accessEditor(g, ui, collectionId) {\n if (!g) return div({ className: 'acl' }, span({ className: 'mono muted' }, 'Loading access…'));\n if (g.error) return div({ className: 'acl' }, span({ className: 'mono muted' }, g.error));\n const grants = g.grants || [];\n const set = (grant) => ui.engine.dispatch(new SetGrantAction(collectionId, grant));\n\n const line = (grant) => {\n const held = new Set(grant.capabilities || []);\n const who = grant.type === 'anyone' ? 'Everyone' : `${grant.type}: ${grant.subject}`;\n return div({ className: 'acl-row' },\n span({ className: 'acl-who' }, who),\n ...CAPS.map((cap) => button({\n className: `btn small ${held.has(cap) ? 'on' : ''}`,\n title: cap === 'admin' ? 'admin implies every other capability' : `toggle ${cap}`,\n }, cap).on({\n click: () => set({\n type: grant.type,\n subject: grant.subject,\n capabilities: held.has(cap)\n ? (grant.capabilities || []).filter((c) => c !== cap)\n : [...(grant.capabilities || []), cap],\n }),\n })),\n // Revoke is the same call with an empty list.\n button({ className: 'btn small', title: 'remove this grant entirely' }, '\\u00d7')\n .on({ click: () => set({ type: grant.type, subject: grant.subject, capabilities: [] }) }),\n );\n };\n\n // Drive administrators, from the deployment's own configuration. Shown because leaving\n // them out makes the list a lie — they hold admin on every collection — and shown\n // WITHOUT controls because `setGrant` cannot touch them: a revoke button here would be\n // one that silently does nothing.\n const admins = (g.admins || []).map((who) => div({ className: 'acl-row acl-fixed' },\n span({ className: 'acl-who' }, who),\n span({ className: 'mono muted' }, 'admin · set by this deployment'),\n ));\n\n return div({ className: 'acl' },\n ...admins,\n ...(grants.length ? grants.map(line) : (admins.length ? [] : [span({ className: 'mono muted' }, 'Nobody yet.')])),\n div({ className: 'acl-row acl-add' },\n select({ className: 'acl-type' }, option({ value: 'user' }, 'user'), option({ value: 'role' }, 'role'), option({ value: 'anyone' }, 'anyone')),\n input({ className: 'acl-subject', placeholder: 'email, or a role name' }),\n button({ className: 'btn small' }, 'Grant read').on({\n click: (e) => {\n const rowEl = e.target.closest('.acl-add');\n const type = rowEl.querySelector('.acl-type').value;\n const subject = rowEl.querySelector('.acl-subject').value.trim();\n if (type !== 'anyone' && !subject) return;\n set({ type, subject: type === 'anyone' ? '' : subject, capabilities: ['read'] });\n },\n }),\n ),\n );\n}\n\n/**\n * What this deployment can actually do with bytes.\n *\n * The driver registry is the list a collection form offers, and it is deployment\n * configuration: `TROVE_STORAGE_DRIVERS` narrows it, and a driver missing from here is the\n * reason a collection cannot be made on it. The capability flags below explain behaviour\n * that otherwise looks arbitrary — why a download is proxied rather than direct, why a\n * usage figure is missing.\n */\nfunction storageSection(caps, state, ui) {\n const s = caps?.storage || {};\n const drivers = caps?.storageDrivers || [];\n const usage = state.ex?.usage;\n const can = (on) => span({ className: `mono ${on ? '' : 'muted'}` }, on ? 'yes' : 'no');\n return div({ className: 'group' },\n h3('Storage'),\n p({ className: 'sub' }, 'The backing stores this deployment offers, and what they support.'),\n row('Drivers offered', 'What a new collection may be created on.',\n drivers.length ? drivers.map((d) => d.label || d.key).join(', ') : 'none registered'),\n row('Direct downloads', 'A presigned URL sends bytes from the store, not through the drive.', can(s.presignDownload)),\n row('Direct uploads', 'A presigned PUT sends bytes to the store, not through the drive.', can(s.presignUpload)),\n row('Multipart', 'Large files go up in parts, resumably.', can(s.multipart)),\n row('Range requests', 'Seeking inside a file without fetching the whole thing.', can(s.range)),\n usage?.total\n ? row('Space', 'Reported by the backing store.', `${bytes(usage.available)} free of ${bytes(usage.total)}`)\n : row('Space', 'This store does not report a total, which object stores generally cannot.', 'not reported'),\n // The check and its remedy already exist as a command — this is where someone would\n // look for it, which is the whole complaint the ticket makes.\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'Check the backing stores'),\n div({ className: 'd' }, 'Asks whether each store can actually be reached from here — the failure that makes every file open to a spinner.'),\n ),\n div({ className: 'control' },\n button({ className: 'btn small' }, 'Run check')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.checkStorage')) })),\n ),\n );\n}\n\n/**\n * What extends this drive, and what each extension is permitted.\n *\n * Indexers matter here for a reason that is easy to miss: an indexer reads file CONTENTS,\n * including from an encrypted collection, because indexing happens on the drive's side of\n * the encryption. Anyone weighing what encryption protects needs to know which ones are\n * installed, so the same list appears on the collection form.\n */\nfunction extensionsSection(caps, state) {\n const indexers = caps?.indexers || [];\n const plugins = state.plugins || [];\n return div({ className: 'group' },\n h3('Extensions'),\n p({ className: 'sub' }, 'What reads and adds to this drive.'),\n div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, 'Indexers'),\n div({ className: 'd' }, 'They read file contents to make them searchable — including in an encrypted collection, since indexing happens on the drive’s side of the encryption.'),\n ),\n div({ className: 'control' },\n span({ className: 'mono' }, indexers.length ? indexers.map((i) => i.displayName || i.id).join(', ') : 'none')),\n ),\n plugins.length\n ? div({}, ...plugins.map((pl) => div({ className: 'setting' },\n div({ className: 'info' },\n div({ className: 't' }, pl.manifest?.displayName || pl.id),\n div({ className: 'd' }, (pl.grants || []).length\n ? `May: ${(pl.grants || []).join(', ')}`\n : 'Granted nothing — it runs in its sandbox and can only draw.'),\n ),\n div({ className: 'control' }, span({ className: `mono ${pl.status === 'active' ? '' : 'muted'}` }, pl.status || 'idle')),\n )))\n : row('Plugins', 'Installed by an administrator, from a signed package.', 'none installed'),\n );\n}\n\n/**\n * What the drive is doing, and what it has not finished.\n *\n * The panel that shows running work already exists and is reached from the status bar,\n * which is fine when something is running and undiscoverable when nothing is. The counts\n * here are the discoverable version; the panel is still where the detail lives.\n */\nfunction workSection(state, ui) {\n const act = state.act || { tasks: [], issues: [] };\n const running = (act.tasks || []).filter((t) => t.status === 'running');\n return div({ className: 'group' },\n h3('Work'),\n p({ className: 'sub' }, 'Background jobs and anything that needs attention.'),\n row('Running now', 'Scans, reindexes and rotations happening on the server.',\n running.length ? `${running.length}` : 'nothing running'),\n row('Needs attention', 'Standing problems — they persist until fixed, unlike a toast.',\n act.issues?.length ? `${act.issues.length}` : 'none'),\n // `stacked`: three buttons do not fit the 200px control column — see styles.css.\n div({ className: 'setting stacked' },\n div({ className: 'info' },\n div({ className: 't' }, 'Maintenance'),\n div({ className: 'd' }, 'A scan picks up files changed in the bucket by something other than Trove. A reindex rebuilds search from scratch.'),\n ),\n div({ className: 'control admin-actions' },\n button({ className: 'btn small' }, 'Activity panel')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.showActivity')) }),\n button({ className: 'btn small' }, 'Scan')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.scanCollection')) }),\n button({ className: 'btn small' }, 'Reindex')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.rebuildIndex')) }),\n ),\n ),\n );\n}\n",
104
+ "// Following a `trove:` link from a document.\n//\n// Resolution is deliberately lazy — at click time, not at render time. A document can\n// hold dozens of links; resolving them all on every render would be a request per link,\n// and the answer can change between renders anyway (the target may be created, renamed,\n// or deleted while the document is open). So a link is rendered from its text alone, and\n// only what the user actually follows costs a round trip.\n//\n// A broken link is a normal, expected state — names are the legible way to write a link,\n// and renaming breaks them. It has to say so clearly, and say WHY, because \"nothing\n// happened\" is the worst possible response to a click.\n\nimport { Action } from '@3sln/ngin';\nimport { parseTroveUri } from '@3sln/trove/core/links.js';\nimport { runAction } from '../dispatch.js';\nimport { OpenFileAction } from './actions.js';\n\n/**\n * Open what a `trove:` URI points at.\n *\n * An ACTION, because it is a network stat, a choice between three failure messages, and an\n * open. It was a plain function taking the UI bag — the only module in bl/ whose parameter\n * was a UI-layer shape, reaching `ui.platform.api` and `ui.engine` to do all of that with\n * no lease on anything and nothing of it on the feed. pluginHost.js states the rule for the\n * same kind of edge: \"Dispatched, not called: opening a file from a docked plugin frame is\n * the same intent as opening one from the drive, and the engine should see both.\"\n *\n * The laziness the module header argues for is untouched — this still runs at click time,\n * and where the work runs was never what that argument was about.\n */\nexport class OpenTroveLinkAction extends Action {\n static deps = ['api', 'engine', 'notifications'];\n\n /** @param {string} uri the link as written; @param {object} [from] the item it was in */\n constructor(uri, from = null) { super(); this.uri = uri; this.from = from; }\n\n async execute({ api, engine, notifications }) {\n const ref = parseTroveUri(this.uri);\n if (!ref) {\n notifications.warn(`\"${this.uri}\" isn’t a valid Trove link.`);\n return;\n }\n try {\n const res = await api.stat(this.uri);\n if (!res?.node) throw new Error('not found');\n await runAction(engine, new OpenFileAction(res.node));\n } catch (err) {\n notifications.warn(describeBrokenLink(ref, err, this.from));\n }\n }\n}\n\n/**\n * Why a link didn't open, in terms of the link the user is looking at. A 403 is a\n * different situation from a 404 and must not be reported as one: \"no such item\" when\n * the item exists but isn't yours is both wrong and a small information leak in reverse.\n */\nfunction describeBrokenLink(ref, err, from) {\n const where = from?.name ? ` (linked from \"${from.name}\")` : '';\n if (err?.status === 403 || err?.code === 'forbidden') {\n return `You don’t have access to that item in \"${ref.collection}\"${where}.`;\n }\n if (ref.by === 'name') {\n return `Nothing named \"${ref.value}\" in \"${ref.collection}\"${where} — it may have been renamed or deleted.`;\n }\n return `That item no longer exists in \"${ref.collection}\"${where}.`;\n}\n",
105
+ "// The markdown opener. Markdown is load-bearing now: with no folder hierarchy, a\n// document that links its sources IS the grouping, so these files have to render as\n// documents with working links rather than as a wall of `<pre>`.\n//\n// A `trove:` link navigates in-app (see ../../../bl/links.js for resolution); an http(s)\n// link opens in a new tab with `rel=\"noopener noreferrer\"`; anything else — `javascript:`,\n// `data:` — is rendered as inert text, because a document is untrusted content that any\n// user of the drive can write.\n//\n// The parser is deliberately small: headings, lists, block quotes, fenced code, inline\n// code/emphasis/links, and paragraphs. It builds VDOM nodes directly and never produces\n// an HTML string, so there is no innerHTML to get wrong.\n//\n// It is also BOUNDED. The input is a file someone uploaded, so its size and shape are\n// not ours to choose: a document with tens of thousands of emphasis spans used to\n// recurse once per span and overflow the stack mid-render, which left the viewer on a\n// spinner forever with nothing said. Inline scanning is now iterative, and both the\n// document length and the node count are capped — a truncated document with a visible\n// notice beats a hung one.\n\nimport { dd, mapCell } from '../../../runtime.js';\nimport { icon } from '../../icon.js';\nimport { parseTroveUri } from '@3sln/trove/core/links.js';\nimport { OpenTroveLinkAction } from '../../../bl/links.js';\nimport { FileText } from '../../../bl/queries.js';\nimport { watchQuery } from '../../../bl/watchQuery.js';\n\nconst { div, span, h1, h2, h3, p, ul, ol, li, pre, code, a, em, strong, blockquote, hr, br } = dd;\n\nexport function markdownOpener(node, ui) {\n // Bounded at the TRANSFER, not just the render: MAX_CHARS below stops us laying out a\n // huge document, but without this the whole file is still pulled into the tab first.\n const src = mapCell(watchQuery(ui.engine, FileText.of(node.id, MAX_CHARS, node.size)), (r) => r.text);\n return dd.alias(() =>\n ui.watch(\n src,\n // A throw in here is NOT covered by the `error:` handler below — that one is for\n // the observable failing, not for the mapper. Rendering untrusted content is\n // exactly where a throw is plausible, and an uncaught one leaves the placeholder\n // on screen forever, so it is caught where it happens.\n (text) => {\n try {\n return div({ className: 'viewer markdown' }, div({ className: 'md' }, ...renderMarkdown(text, node, ui)));\n } catch (err) {\n console.error('markdown render failed', err);\n return errorView(`This document couldn’t be displayed: ${err.message}`);\n }\n },\n {\n placeholder: () => div({ className: 'viewer' }, div({ className: 'loading' }, div({ className: 'spinner' }), span('Loading…'))),\n error: (e) => errorView(e.message),\n },\n ),\n )();\n}\n\nfunction errorView(message) {\n return div({ className: 'viewer' }, div({ className: 'fallback' }, icon('warn', { size: 40 }), span(message)));\n}\n\n// Bounds. A document past these renders as much as fits, with a notice — the parse is\n// linear, so these are about the size of the resulting DOM, not about parse time.\nconst MAX_CHARS = 512 * 1024;\nconst MAX_BLOCKS = 5_000;\nconst MAX_INLINE_NODES = 2_000; // per block\n\n// --- block level -------------------------------------------------------------\n\nexport function renderMarkdown(text, node, ui) {\n const raw = String(text ?? '');\n const truncated = raw.length > MAX_CHARS;\n const lines = (truncated ? raw.slice(0, MAX_CHARS) : raw).split(/\\r?\\n/);\n const out = [];\n let i = 0;\n\n while (i < lines.length) {\n if (out.length >= MAX_BLOCKS) return [...out, tooLarge()];\n const line = lines[i];\n\n // Fenced code — taken verbatim, including any markdown inside it.\n const fence = /^\\s*(```+|~~~+)(.*)$/.exec(line);\n if (fence) {\n const marker = fence[1][0].repeat(3);\n const body = [];\n i++;\n while (i < lines.length && !lines[i].trimStart().startsWith(marker)) body.push(lines[i++]);\n i++; // closing fence (or EOF — an unterminated fence still renders)\n out.push(pre({ className: 'md-code' }, code(body.join('\\n'))));\n continue;\n }\n\n if (!line.trim()) { i++; continue; }\n\n const heading = /^(#{1,6})\\s+(.*)$/.exec(line);\n if (heading) {\n const level = heading[1].length;\n const factory = level === 1 ? h1 : level === 2 ? h2 : h3;\n out.push(factory({ className: `md-h md-h${level}` }, ...inline(heading[2], node, ui)));\n i++;\n continue;\n }\n\n if (/^\\s*(-{3,}|\\*{3,}|_{3,})\\s*$/.test(line)) { out.push(hr({ className: 'md-hr' })); i++; continue; }\n\n if (/^\\s*>/.test(line)) {\n const body = [];\n while (i < lines.length && /^\\s*>/.test(lines[i])) body.push(lines[i++].replace(/^\\s*>\\s?/, ''));\n out.push(blockquote({ className: 'md-quote' }, ...renderMarkdown(body.join('\\n'), node, ui)));\n continue;\n }\n\n const bullet = /^\\s*([-*+]|\\d+[.)])\\s+/.exec(line);\n if (bullet) {\n const ordered = /\\d/.test(bullet[1]);\n const items = [];\n while (i < lines.length) {\n const m = /^\\s*([-*+]|\\d+[.)])\\s+(.*)$/.exec(lines[i]);\n if (!m || /\\d/.test(m[1]) !== ordered) break;\n items.push(li({ className: 'md-li' }, ...inline(m[2], node, ui)));\n i++;\n }\n out.push((ordered ? ol : ul)({ className: 'md-list' }, ...items));\n continue;\n }\n\n // Paragraph: consecutive non-blank lines that don't start another block.\n const para = [];\n while (i < lines.length && lines[i].trim() && !startsBlock(lines[i])) para.push(lines[i++]);\n const joined = para.join('\\n');\n const kids = [];\n joined.split('\\n').forEach((l, n) => {\n if (n) kids.push(br());\n kids.push(...inline(l, node, ui));\n });\n out.push(p({ className: 'md-p' }, ...kids));\n }\n return truncated ? [...out, tooLarge()] : out;\n}\n\n// Say what happened, rather than silently rendering a prefix as if it were the whole\n// document — a reader who can't tell it was cut off will believe the rest isn't there.\nfunction tooLarge() {\n return p({ className: 'md-truncated' },\n 'This document is too large to display in full. Download it to read the rest.');\n}\n\nfunction startsBlock(line) {\n return /^(#{1,6}\\s|\\s*>|\\s*([-*+]|\\d+[.)])\\s|\\s*(```|~~~))/.test(line)\n || /^\\s*(-{3,}|\\*{3,}|_{3,})\\s*$/.test(line);\n}\n\n// --- inline level ------------------------------------------------------------\n\n// Ordered by precedence: code spans win over emphasis (so `*` inside backticks is\n// literal), and explicit links win over bare autolinks.\nconst INLINE = [\n { re: /`([^`]+)`/, node: (m) => code({ className: 'md-inline-code' }, m[1]) },\n { re: /\\[([^\\]]*)\\]\\(([^)\\s]+)(?:\\s+\"[^\"]*\")?\\)/, node: (m, node, ui) => link(m[2], m[1] || m[2], node, ui) },\n { re: /(\\*\\*|__)(.+?)\\1/, node: (m, node, ui, d) => strong(...inline(m[2], node, ui, d + 1)) },\n { re: /(\\*|_)(.+?)\\1/, node: (m, node, ui, d) => em(...inline(m[2], node, ui, d + 1)) },\n // Bare URLs, so a pasted trove: reference is clickable without link syntax.\n { re: /(trove:[^\\s<>\"'`)\\]}]+|https?:\\/\\/[^\\s<>\"'`)\\]}]+)/, node: (m, node, ui) => link(trimTrailing(m[1]), trimTrailing(m[1]), node, ui) },\n];\n\n/**\n * Scan one line into inline nodes. Iterative on purpose: the obvious recursive form\n * (split on the first match, recurse on both sides) descends once per span, so a line\n * with thousands of them overflows the stack — and the input is a file someone\n * uploaded, so \"thousands of them\" is their choice, not ours.\n *\n * Emphasis still nests, via a bounded recursion on the span's *contents* only. That\n * depth is limited by how deeply markers are nested rather than by how many spans a\n * line contains, so it stays shallow for anything a person would write, and `depth`\n * stops a pathological document regardless.\n */\nfunction inline(text, node, ui, depth = 0) {\n if (!text) return [];\n if (depth > 12) return [text]; // deeper than any real markup; render it literally\n const out = [];\n let rest = text;\n while (rest) {\n if (out.length >= MAX_INLINE_NODES) { out.push(rest); break; }\n let best = null;\n for (const rule of INLINE) {\n const m = rule.re.exec(rest);\n if (m && (best === null || m.index < best.m.index)) best = { m, rule };\n }\n if (!best) { out.push(rest); break; }\n const { m, rule } = best;\n if (m.index) out.push(rest.slice(0, m.index));\n out.push(rule.node(m, node, ui, depth));\n rest = rest.slice(m.index + m[0].length);\n }\n return out;\n}\n\nfunction trimTrailing(url) {\n return url.replace(/[.,;:!?]+$/, '');\n}\n\n/**\n * One link. A `trove:` reference navigates inside the app and is resolved lazily on\n * click — resolving every link up front would mean a request per link on every render,\n * and a link's target can appear or disappear between renders anyway.\n *\n * Only trove: and http(s) are rendered as links at all. A `javascript:` or `data:` URL\n * is shown as plain text: markdown here is untrusted content written by whoever can\n * write to the drive, and an allowlist is the only way to be sure about a scheme.\n */\nfunction link(href, label, node, ui) {\n const trove = parseTroveUri(href);\n if (trove) {\n return a({ className: 'md-link md-trove', href: '#', title: href }, label).on({\n click: (e) => {\n e.preventDefault();\n ui.engine.dispatch(new OpenTroveLinkAction(href, node));\n },\n });\n }\n if (/^https?:\\/\\//i.test(href)) {\n return a({ className: 'md-link', href, target: '_blank', rel: 'noopener noreferrer', title: href }, label);\n }\n return span({ className: 'md-deadlink', title: `Unsupported link: ${href}` }, label);\n}\n",
106
+ "// Built-in openers, registered through the same contribution system plugins use.\n// Each declares a selector (extensions / mime) and a component(node, ui) → vnode.\n// The editor area picks the highest-priority opener whose selector matches.\n\nimport { cell, dd, watch } from '../../../runtime.js';\nimport { icon } from '../../icon.js';\nimport { bytes } from '../../format.js';\nimport { markdownOpener } from './markdown.js';\nimport { attachMedia } from '../../media.js';\nimport { FileText } from '../../../bl/queries.js';\nimport { watchQuery } from '../../../bl/watchQuery.js';\nimport { ExecCommandAction } from '../../../bl/actions.js';\n\nconst { div, pre, img, span, button, video, audio } = dd;\n\n// Built-ins register the same way a plugin's manifest declares an opener — same\n// registry, same `match` selector, same priority ordering. The only difference is\n// that a built-in supplies a `component` (it runs in the host) where a plugin\n// supplies an `entry` module (it runs in its own sandboxed frame).\nconst BUILT_IN = {\n 'core.audio': {\n title: 'Audio Player', priority: 20,\n match: { mime: ['audio/*'], ext: ['.mp3', '.flac', '.wav', '.opus', '.ogg', '.m4a', '.m4b'] },\n component: audioOpener,\n },\n 'core.video': {\n title: 'Video Player', priority: 20,\n match: { mime: ['video/*'], ext: ['.mp4', '.webm', '.mkv', '.mov'] },\n component: videoOpener,\n },\n 'core.image': {\n title: 'Image Viewer', priority: 20,\n match: { mime: ['image/*'], ext: ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.svg', '.avif'] },\n component: imageOpener,\n },\n // Markdown outranks the plain text viewer: a document that links its sources is how\n // things are grouped now, so those links have to be clickable by default.\n 'core.markdown': {\n title: 'Markdown', priority: 30,\n match: { ext: ['.md', '.markdown'], mime: ['text/markdown'] },\n component: markdownOpener,\n },\n 'core.text': {\n title: 'Text Viewer', priority: 10,\n match: {\n mime: ['text/*', 'application/json'],\n ext: ['.txt', '.md', '.json', '.js', '.mjs', '.ts', '.jsx', '.tsx', '.css', '.html', '.xml', '.yaml', '.yml', '.toml', '.ini', '.log', '.csv', '.py', '.rb', '.go', '.rs', '.sh', '.c', '.h', '.cpp', '.java'],\n },\n component: textOpener,\n },\n};\n\nexport function registerBuiltinOpeners(platform) {\n for (const [name, spec] of Object.entries(BUILT_IN)) {\n platform.contributions.register(name, { type: 'opener', ...spec });\n }\n}\n\n/** Render a node with a resolved opener; falls back gracefully. */\nexport function renderOpener(node, openerId, ui) {\n const opener = ui.platform.contributions.get(openerId);\n if (opener?.component) {\n try {\n return opener.component(node, ui);\n } catch (err) {\n return errorView(err.message);\n }\n }\n if (opener?.pluginId) return pluginOpenerView(opener, node, ui);\n return fallbackOpener(node, ui);\n}\n\n// ---- component openers -----------------------------------------------------\n\n// How much of a text file the viewer will pull and draw. A drive holds logs, CSV\n// exports and database dumps in the hundreds of megabytes; reading one whole just to\n// show its beginning buffers the entire file in the tab and then asks the browser to\n// lay out ten million characters. Both halves are bounded here — the Range request\n// means the bytes never arrive, not merely that they aren't drawn.\nconst TEXT_VIEW_BYTES = 512 * 1024;\n\nfunction textOpener(node, ui) {\n const src = watchQuery(ui.engine, FileText.of(node.id, TEXT_VIEW_BYTES, node.size));\n return dd.alias(() =>\n ui.watch(\n src,\n ({ text, truncated, total }) => div({ className: 'viewer text' },\n pre(text),\n // Say what is missing rather than trailing off. A viewer that silently shows\n // the first slice of a file is worse than one that refuses: the reader believes\n // they have seen the end of it.\n truncated\n ? div({ className: 'md-truncated' },\n `Showing the first ${Math.round(text.length / 1024)} KB${total ? ` of ${(total / 1048576).toFixed(1)} MB` : ''}. `,\n span('Download the file to read all of it.'))\n : null,\n ),\n {\n placeholder: () => div({ className: 'viewer' }, div({ className: 'loading' }, div({ className: 'spinner' }), span('Loading…'))),\n error: (e) => errorView(e.message),\n },\n ),\n )();\n}\n\n// A media element (img/audio/video) sets its `src` to a download URL that can 404 or\n// hold undecodable bytes. Those failures surface only as an async `error` event on the\n// element itself (media error events don't bubble), which would otherwise leave a\n// broken glyph / black box with no message. `mediaWithError` passes an `onError` the\n// caller MUST wire onto the actual media element, and swaps in the download fallback\n// (with a reason) the moment it fires.\nconst MEDIA_ERR = \"This file couldn't be loaded — it may be missing or in an unsupported format.\";\nfunction mediaWithError(node, ui, makeEl) {\n const state = cell({ error: null });\n const onError = (msg) => state.setValue({ error: msg || MEDIA_ERR });\n const el = makeEl(onError);\n return dd.alias(() =>\n watch(state, (s) => (s.error ? fallbackOpener(node, ui, s.error) : el)),\n )();\n}\n\n/**\n * The `src` is not set here.\n *\n * It is minted — a URL that carries its own grant, because a media element fetches\n * without our Authorization header — and then KEPT current: it expires, and a paused\n * film resumed the next morning has to swap its source without losing its place. All of\n * that is `attachMedia`; see ui/media.js.\n */\nconst sourced = (el, node, ui, onError) => el.on({\n $attach: (dom) => { dom._detachMedia = attachMedia(dom, node, ui, { onError }); },\n $detach: (dom) => { dom._detachMedia?.(); dom._detachMedia = null; },\n}).opaque();\n\nfunction imageOpener(node, ui) {\n return mediaWithError(node, ui, (onError) =>\n div({ className: 'viewer image' }, sourced(img({ alt: node.name }), node, ui, onError)),\n );\n}\n\nfunction audioOpener(node, ui) {\n return mediaWithError(node, ui, (onError) =>\n div({ className: 'viewer', $styling: { display: 'grid', 'place-items': 'center', gap: '16px', padding: '40px' } },\n icon('file-audio', { size: 48 }),\n span({ $styling: { color: 'var(--text-dim)' } }, node.name),\n sourced(audio({ controls: true, $styling: { width: 'min(520px, 90%)' } }), node, ui, onError),\n ),\n );\n}\n\nfunction videoOpener(node, ui) {\n return mediaWithError(node, ui, (onError) =>\n div({ className: 'viewer', $styling: { display: 'grid', 'place-items': 'center', background: '#000' } },\n sourced(video({ controls: true, $styling: { 'max-width': '100%', 'max-height': '100%' } }), node, ui, onError),\n ),\n );\n}\n\nfunction fallbackOpener(node, ui, reason) {\n return div({ className: 'viewer' },\n div({ className: 'fallback' },\n icon(reason ? 'warn' : 'file', { size: 44 }),\n span({ $styling: { 'font-weight': 600 } }, node.name),\n span(`${node.contentType || 'Unknown type'} · ${bytes(node.size)}`),\n span({ $styling: { color: 'var(--text-faint)', 'max-width': '340px' } },\n reason || 'No preview available for this file type. Install a plugin that handles it, or download the file.'),\n button({ className: 'btn primary' }, icon('download', { size: 15 }), 'Download')\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('explorer.download', node)) }),\n ),\n );\n}\n\nfunction pluginOpenerView(opener, node, ui) {\n // A plugin opener renders in its OWN sandboxed iframe (spawned by mountViewer with\n // the plugin's capabilities). That iframe is not a child here — it's a host-owned\n // position:fixed overlay whose box tracks this .pv-host element (moving an <iframe>\n // in the DOM would reload it). $attach hands .pv-host to mountViewer as the tracking\n // target; $detach lets it dock or tear down. `.opaque()` keeps dodo from reconciling\n // these (host-managed) nodes so their lifecycle hooks stay stable across re-renders.\n // The status overlay shows a spinner until the plugin opens the file (the iframe is\n // transparent while loading) and an error if it never does. It is a CELL and a `watch`,\n // the same shape `mediaWithError` above uses — it used to be functions stamped onto the\n // status element (`el._ready`, `el._error`) and fetched back by the sibling with\n // `el.parentElement?.querySelector('.pv-status')`. Every `?.` in that chain silently\n // no-ops, so reordering or wrapping these two divs left the spinner up forever with\n // nothing reporting it. `.pv-host` stays opaque and imperative because it genuinely is:\n // re-parenting the iframe would reload it.\n const status = cell({ ready: false, error: null });\n return div({ className: 'viewer plugin-viewer' },\n watch(status, (st) => {\n if (st.ready) return null;\n return div({ className: 'pv-status' }, st.error\n ? div({ className: 'fallback' }, icon('warn', { size: 40 }), span(st.error))\n : div({ className: 'loading' }, div({ className: 'spinner' }), span('Opening…')));\n }),\n div({ className: 'pv-host' }).on({\n $attach: (el) => {\n el._detach = ui.platform.plugins.mountViewer(opener.pluginId, el, node, opener.id, {\n onReady: () => status.setValue({ ready: true, error: null }),\n onError: (msg) => status.setValue({ ready: false, error: msg || 'This viewer failed to load' }),\n });\n },\n $detach: (el) => { el._detach?.(); el._detach = null; },\n }).opaque(),\n );\n}\n\nfunction errorView(message) {\n return div({ className: 'viewer' }, div({ className: 'fallback' }, icon('warn', { size: 40 }), span(message || 'Failed to open')));\n}\n",
107
+ "// The viewer — the top of the panel stack (a file's opener), full-width, with a\n// nav bar: a Back button, a trail of the stacked panels (Search › A › B),\n// and details/close actions. The opener host returns a *stable* keyed alias per\n// panel so dodo reuses its DOM across unrelated workbench re-renders — critical for\n// any media opener, whose <audio>/<video> must keep playing while state churns; the\n// DOM persists as long as the panel stays in the stack.\n\nimport { dd } from '../../runtime.js';\nimport { icon, iconForNode } from '../icon.js';\nimport { renderOpener } from './openers/index.js';\nimport { openersFor } from '../../bl/openers.js';\nimport { NavigateBackAction, OpenInPanelAction, ShowDialogAction, ShowHomeAction, ToggleInfoPanelAction } from '../../bl/actions.js';\n\nconst { div, span, button } = dd;\n\n/**\n * `${panelId}:${openerId}` -> stable render fn.\n *\n * dodo identifies an alias by the FUNCTION, so a fresh one per render would rebuild it\n * every pass and take the <audio> with it. Module scope is safe here in a way it was not\n * for the keybindings region, and the difference is the key: a panel id is minted by\n * `newId()` and is unique across every workbench on the page, so two shells cannot collide\n * and hand each other's `ui` to a render. `pruneOpeners` bounds it to the live stack.\n */\nconst openerFns = new Map();\n\nexport default function editorArea(state, ui) {\n const wb = state.wb;\n const files = state.nav.stack.filter((p) => p.kind === 'file');\n pruneOpeners(files);\n const active = files[files.length - 1];\n if (!active) return div({ className: 'editor' });\n return div({ className: 'editor' },\n navBar(files, active, state, ui),\n div({ className: 'stage' }, openerHost(active, ui)),\n );\n}\n\nfunction navBar(files, active, state, ui) {\n return div({ className: 'viewer-nav' },\n button({ className: 'vn-back', title: 'Back (Esc)' }, icon('chevron-left', { size: 16 }))\n .on({ click: () => ui.engine.dispatch(new NavigateBackAction()) }),\n div({ className: 'vn-trail' },\n button({ className: 'vn-crumb' }, icon('search', { size: 13 }), span('Search'))\n .on({ click: () => ui.engine.dispatch(new ShowHomeAction()) }),\n ...files.map((p) =>\n button({ className: `vn-crumb ${p.id === active.id ? 'active' : ''}`, title: p.node.name },\n icon(iconForNode(p.node), { size: 13 }), span({ className: 'label' }, p.node.name))\n .on({ click: () => ui.engine.dispatch(new OpenInPanelAction(p.node, p.openerId)) })),\n ),\n div({ className: 'vn-actions' },\n openerSwitch(active, state, ui),\n button({ className: 'iconbtn', title: 'Details & comments' }, icon('info', { size: 15 }))\n .on({ click: () => ui.engine.dispatch(new ToggleInfoPanelAction()) }),\n button({ className: 'iconbtn', title: 'Close (Esc)' }, icon('close', { size: 15 }))\n .on({ click: () => ui.engine.dispatch(new ShowHomeAction()) }),\n ),\n );\n}\n\n// \"Open with…\" — shown only when more than one opener can handle this file. Opens\n// the chooser (pre-selected to the current opener) so the user can switch viewers,\n// and optionally make the choice their default for this file type.\nfunction openerSwitch(active, state, ui) {\n // `state.openers` has already had its when-clauses and plugin health resolved by the\n // query; matching them against THIS file is pure. That split is why this no longer\n // reaches for the contribution registry mid-render.\n const openers = openersFor(state.openers, active.node);\n if (openers.length <= 1) return null;\n return button({ className: 'iconbtn', title: 'Open with…' }, icon('dots', { size: 15 }))\n .on({ click: () => ui.engine.dispatch(new ShowDialogAction({ kind: 'opener-chooser', node: active.node, openers, current: active.openerId })) });\n}\n\nfunction openerHost(panel, ui) {\n const key = `${panel.id}:${panel.openerId}`;\n let fn = openerFns.get(key);\n if (!fn) {\n fn = () => renderOpener(panel.node, panel.openerId, ui);\n openerFns.set(key, fn);\n }\n return dd.alias(fn)().key(panel.id);\n}\n\nfunction pruneOpeners(files) {\n const live = new Set(files.map((p) => `${p.id}:${p.openerId}`));\n for (const k of openerFns.keys()) if (!live.has(k)) openerFns.delete(k);\n}\n",
108
+ "// Command palette + quick-open. Mode 'commands' fuzzy-filters registered\n// commands (respecting when-clauses); mode 'files' searches the drive by name\n// and opens the chosen file. Arrow keys move, Enter runs, Esc closes.\n\nimport { dd } from '../../runtime.js';\nimport { icon, iconForNode } from '../icon.js';\nimport { ClosePaletteAction, ExecCommandAction, MovePaletteAction, OpenFileAction, QuickOpenAction, SetPaletteIndexAction, SetPaletteQueryAction } from '../../bl/actions.js';\n\nconst { div, input, span } = dd;\n\nexport default function commandPalette(state, ui) {\n const pal = state.overlay.palette;\n if (!pal) return null;\n // With no query there is nothing to show — and showing the PREVIOUS session's hits\n // would be worse than nothing, since they don't match what the field now says.\n // Already ranked — see the `paletteMatches` query. The palette used to score and sort\n // here, with its own fuzzy algorithm that disagreed with the launcher's.\n const items = pal.mode === 'files'\n ? (pal.query.trim() ? state.se.paletteFiles || [] : [])\n : state.matches || [];\n const index = Math.min(pal.index, Math.max(0, items.length - 1));\n\n const run = (item) => {\n if (!item) return;\n ui.engine.dispatch(new ClosePaletteAction());\n if (pal.mode === 'files') ui.engine.dispatch(new OpenFileAction(item.node));\n else ui.engine.dispatch(new ExecCommandAction(item.id));\n };\n\n return div({},\n div({ className: 'scrim' }).on({ click: () => ui.engine.dispatch(new ClosePaletteAction()) }),\n div({ className: 'palette' },\n div({ className: 'search' },\n icon(pal.mode === 'files' ? 'search' : 'command', { size: 18 }),\n input({\n type: 'text', value: pal.query, autofocus: true,\n placeholder: pal.mode === 'files' ? 'Search files by name…' : 'Type a command…',\n }).on({\n // NOTE: the mode is read from live state inside onQuery, NOT captured here.\n // A listener belongs to the render that created it, and rendering is async —\n // a keystroke landing between `openPalette('files')` and the re-render would\n // otherwise be handled as a COMMANDS keystroke and silently do nothing.\n input: (e) => onQuery(ui, e.target.value),\n keydown: (e) => onKey(e, ui, items, index, run),\n $attach: (el) => {\n queueMicrotask(() => el.focus());\n // Same reason in reverse: dodo only patches `value` when the vnode prop\n // changed, so a reopened palette whose query is '' both times would keep\n // whatever text the previous session left in the live DOM node.\n if (el.value !== pal.query) el.value = pal.query;\n },\n }),\n ),\n div({ className: 'results' },\n items.length\n ? items.map((item, i) => {\n const hover = () => ui.engine.dispatch(new SetPaletteIndexAction(i));\n return pal.mode === 'files' ? fileOpt(item, i === index, run, hover) : cmdOpt(item, i === index, ui, run, hover);\n })\n : emptyResults(pal, state),\n ),\n ),\n );\n}\n\n// Nothing to show is three different situations, and saying \"No files found\" for all\n// three tells the user something false in two of them.\nfunction emptyResults(pal, state) {\n if (pal.mode !== 'files') return div({ className: 'none' }, 'No matching commands');\n if (state.se.paletteError) return div({ className: 'none error' }, icon('warn', { size: 14 }), ` ${state.se.paletteError}`);\n if (state.se.paletteLoading) return div({ className: 'none' }, div({ className: 'spinner' }), ' Searching…');\n return div({ className: 'none' }, pal.query.trim() ? 'No files found' : 'Type to search files by name');\n}\n\n// Everything here arrives decided — see the paletteCommands view query. This used to ask\n// the keybinding service for a label, then throw the label away and re-resolve the raw key\n// to prettify it again, which was two lookups to render one `<kbd>`.\nfunction cmdOpt(cmd, active, ui, run, hover) {\n return div({ className: `opt ${active ? 'active' : ''} ${cmd.available ? '' : 'unavailable'}` },\n span({ className: 'ico' }, icon(cmd.icon || 'command', { size: 16 })),\n cmd.category ? span({ className: 'cat' }, cmd.category + ' ›') : null,\n span({ className: 'title' }, cmd.title),\n !cmd.available ? span({ className: 'offline-tag' }, 'offline') : null,\n cmd.keybinding ? span({ className: 'kbd' }, dd.h('kbd', cmd.keybinding)) : null,\n ).on({ click: () => run(cmd), mouseenter: hover });\n}\n\nfunction fileOpt(item, active, run, hover) {\n return div({ className: `opt ${active ? 'active' : ''}` },\n span({ className: 'ico' }, icon(iconForNode(item.node), { size: 16 })),\n span({ className: 'title' }, item.node.name),\n span({ className: 'sub' }, item.node.contentType || ''),\n ).on({ click: () => run(item), mouseenter: hover });\n}\n\n\n\nfunction onKey(e, ui, items, index, run) {\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n ui.engine.dispatch(new MovePaletteAction(1, items.length));\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n ui.engine.dispatch(new MovePaletteAction(-1, items.length));\n } else if (e.key === 'Enter') {\n e.preventDefault();\n run(items[index]);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n ui.engine.dispatch(new ClosePaletteAction());\n }\n}\n\nlet fileTimer = null;\nfunction onQuery(ui, value) {\n ui.engine.dispatch(new SetPaletteQueryAction(value));\n clearTimeout(fileTimer);\n // The mode guard moved into QuickOpenAction, where \"current\" means current: the timer\n // below outlives the render that set it, so checking here would test a stale mode.\n // Results land in the search service (state.se.paletteFiles), so the palette re-renders\n // without ad-hoc state.\n fileTimer = setTimeout(() => ui.engine.dispatch(new QuickOpenAction(value)), 200);\n}\n",
109
+ "// The pre-install review — everything a user needs to decide whether to trust\n// and install a plugin: its identity + signature/domain-verified status, the\n// capabilities it wants (each explained, admin-only ones flagged), what it\n// contributes, and its settings. Capabilities are opt-in checkboxes; admin-only\n// ones are disabled for non-admins. No plugin code has run at this point.\n\nimport { dd } from '../../runtime.js';\nimport { icon } from '../icon.js';\nimport { bytes as fmtBytes } from '../format.js';\nimport { draftFor, PLUGIN_REVIEW as KEY } from '../../bl/viewState.js';\nimport { CloseDialogAction, SetViewStateAction } from '../../bl/actions.js';\nimport { activate } from '../activate.js';\nimport { describeTrust } from '../../bl/trust.js';\n\nconst { div, span, button, h3, p, label, input } = dd;\n\n// The ticked capabilities, keyed to the dialog instance. Engine state — it decides which\n// boxes render checked, and it is where InstallReviewedPluginAction reads the grants from.\n// See bl/viewState.js.\n\nexport function pluginReview(d, ui, view) {\n const s = d.summary;\n // Derived, not written: the default used to be installed during the render that noticed\n // the dialog had changed, which made rendering a side-effecting operation.\n const sel = draftFor(view, KEY, d, {\n // Default: request everything the user is allowed to grant.\n grants: s.capabilities.filter((c) => !c.adminOnly || d.isAdmin).map((c) => c.id),\n // Never defaulted true. An acknowledgement that arrives pre-ticked is not one.\n acknowledged: false,\n });\n const policy = d.policy || { requiresAcknowledgement: false };\n // Install stays out of reach until the risk has actually been acknowledged. A package\n // this applies to is unsigned — see installPolicyFor.\n const blocked = policy.requiresAcknowledgement && !sel.acknowledged;\n // A new array rather than a mutated Set: the write has to be a different value for the\n // cell to see it as a change at all.\n const patch = (fields) => ui.engine.dispatch(new SetViewStateAction(KEY, { ...sel, ...fields }));\n const toggle = (cap) => patch({\n grants: sel.grants.includes(cap) ? sel.grants.filter((c) => c !== cap) : [...sel.grants, cap],\n });\n\n return div({},\n div({ className: 'scrim' }).on({ click: () => ui.engine.dispatch(new CloseDialogAction()) }),\n div({ className: 'dialog review', $styling: { width: 'min(560px, 96vw)' } },\n header(s),\n div({ className: 'review-body' },\n s.description ? p({ className: 'review-desc' }, s.description) : null,\n section('Capabilities it requests', s.capabilities.length\n ? div({ className: 'cap-list' }, ...s.capabilities.map((c) => capRow(c, d.isAdmin, sel.grants.includes(c.id), () => toggle(c.id))))\n : muted('None — this plugin only runs in its sandbox.')),\n (s.network || []).length ? section('Network access', div({ className: 'contrib-list' }, ...s.network.map(endpointRow))) : null,\n (s.commands || []).length\n ? section('Commands it can run', div({ className: 'contrib-list' }, ...s.commands.map((id) => commandRow(id, ui))))\n : null,\n s.storage ? section('Storage', storageRows(s.storage)) : null,\n s.contributions.length ? section('What it adds', div({ className: 'contrib-list' }, ...s.contributions.map(contribRow))) : null,\n s.settings.length ? section('Settings', div({ className: 'contrib-list' }, ...s.settings.map(settingRow))) : null,\n div({ className: 'review-meta' }, `${s.fileCount} files · ${fmtBytes(s.sizeBytes)} · id ${s.id}`),\n ),\n policy.headline ? trustWarning(policy, sel, patch) : null,\n div({ className: 'row-actions' },\n button({ className: 'btn' }, 'Cancel').on({ click: () => ui.engine.dispatch(new CloseDialogAction()) }),\n button({ className: `btn primary ${blocked ? 'disabled' : ''}`, disabled: blocked },\n icon('plug', { size: 15 }), 'Install')\n // The spec's own actions, run the way every other item's are. The install used\n // to be a closure ON THE SPEC, which put an effect inside engine state.\n .on({ click: () => !blocked && activate(ui, { actions: d.installActions }) }),\n ),\n ),\n );\n}\n\n/**\n * What is wrong with this package's provenance, said before the Install button rather than\n * as a badge beside the name.\n *\n * A badge is something you can read past. This sits between the review and the action, and\n * where an acknowledgement is required it holds the button until the box is ticked — which\n * is the difference between telling someone and asking them.\n */\nfunction trustWarning(policy, sel, patch) {\n return div({ className: `review-warning ${policy.status}` },\n div({ className: 'rw-head' }, icon('warn', { size: 15 }), span(policy.headline)),\n div({ className: 'rw-detail' }, policy.detail),\n policy.requiresAcknowledgement\n ? label({ className: 'rw-ack' },\n input({ type: 'checkbox', checked: !!sel.acknowledged })\n .on({ change: (e) => patch({ acknowledged: !!e.target.checked }) }),\n span('I know this package is unsigned and I trust where it came from'))\n : null,\n );\n}\n\nfunction header(s) {\n const t = s.trust || { status: 'unverified' };\n return div({ className: 'review-head' },\n div({ className: 'avatar' }, (s.name || '?')[0].toUpperCase()),\n div({ className: 'rh-main' },\n div({ className: 'rh-name' }, s.name, span({ className: 'rh-ver' }, 'v' + s.version)),\n div({ className: 'rh-author' }, 'by ' + s.author),\n ),\n trustBadge(t),\n );\n}\n\n// The full badge, for the dialog that asks whether to install at all. Same classification\n// as the list's — see bl/trust.js — with room to spell it out.\nfunction trustBadge(trust) {\n const t = describeTrust(trust);\n const label = t.status === 'verified' && t.domain ? `Verified · ${t.domain}`\n : t.status === 'invalid' ? 'Invalid signature'\n : t.status === 'signed' ? 'Signed'\n : 'Unverified';\n return span({ className: `trust ${t.tone}`, title: t.explanation },\n icon(t.icon, { size: 13 }), label);\n}\n\nfunction capRow(cap, isAdmin, checked, onToggle) {\n const blocked = cap.adminOnly && !isAdmin;\n return label({ className: `cap-row ${blocked ? 'blocked' : ''}` },\n input({ type: 'checkbox', checked: checked && !blocked, disabled: blocked }).on({ change: () => !blocked && onToggle() }),\n div({ className: 'cap-info' },\n div({ className: 'cap-name' }, cap.id, cap.adminOnly ? span({ className: 'pf-badge', $styling: { color: 'var(--warn)', 'margin-left': '6px' } }, 'admin only') : null),\n div({ className: 'cap-desc' }, cap.description + (blocked ? ' — requires an administrator' : '')),\n ),\n );\n}\n\nfunction contribRow(c) {\n const kindIcon = { command: 'command', opener: 'file', indexer: 'search', statusItem: 'info', register: 'info', keymap: 'command' }[c.kind] || 'command';\n return div({ className: 'contrib-row' },\n icon(kindIcon, { size: 13 }),\n span({ className: 'cr-title' }, c.title),\n c.detail ? span({ className: 'cr-detail' }, c.detail) : null,\n c.offline ? span({ className: 'pf-badge offline-ok' }, 'offline') : null,\n span({ className: 'pf-kind' }, c.kind),\n );\n}\n\n// One command the plugin may ask the host to run. Resolved against the live registry\n// so the user sees the human title and where it comes from (built-in vs another\n// plugin) — an id like \"explorer.delete\" alone doesn't convey what it does.\nfunction commandRow(id, ui) {\n const cmd = ui?.platform?.contributions?.get?.(id);\n const source = cmd?.pluginId ? 'plugin' : cmd ? 'built-in' : 'not installed';\n return div({ className: `contrib-row ${cmd ? '' : 'blocked'}` },\n icon('command', { size: 13 }),\n span({ className: 'cr-title' }, cmd?.title || id),\n span({ className: 'cr-detail' }, id),\n span({ className: 'pf-kind' }, source),\n );\n}\n\nfunction endpointRow(ep) {\n return div({ className: 'contrib-row' },\n icon('plug', { size: 13 }),\n span({ className: 'cr-title' }, ep.host),\n ep.path ? span({ className: 'cr-detail' }, ep.path) : null,\n span({ className: 'pf-kind' }, ep.scheme),\n );\n}\n\nfunction storageRows(st) {\n const rows = [];\n if (st.plugin) rows.push(storageRow('Private database', 'A SQLite store just for this plugin (server + this device).', false));\n if (st.domain) rows.push(storageRow('Shared database', `Shared with other plugins from ${'its domain'} (SQLite).`, st.domainBlocked));\n return div({ className: 'contrib-list' }, ...rows);\n}\nfunction storageRow(title, detail, blocked) {\n return div({ className: `contrib-row ${blocked ? 'blocked' : ''}` },\n icon('plug', { size: 13 }),\n span({ className: 'cr-title' }, title),\n span({ className: 'cr-detail' }, blocked ? detail + ' — needs a verified domain' : detail),\n blocked ? span({ className: 'pf-badge', $styling: { color: 'var(--warn)' } }, 'unavailable') : null,\n );\n}\n\nfunction settingRow(st) {\n return div({ className: 'contrib-row' },\n icon('gear', { size: 13 }),\n span({ className: 'cr-title' }, st.title),\n st.secret\n ? span({ className: 'pf-badge', $styling: { color: 'var(--warn)' } }, 'secret')\n : span({ className: 'pf-kind' }, st.type),\n );\n}\n\nfunction section(title, content) {\n return div({ className: 'review-section' }, div({ className: 'rs-title' }, title), content);\n}\nfunction muted(t) {\n return div({ className: 'muted', $styling: { 'font-size': '12.5px' } }, t);\n}\n",
110
+ "// Small transient overlays: modal dialog (prompt/confirm), right-click context\n// menu, toast notifications, the upload/transfer tray, and the plugin popup\n// panel (which hosts a plugin's own iframe, Chrome-extension style).\n\nimport { dd } from '../../runtime.js';\nimport { icon, iconForNode } from '../icon.js';\nimport { bytes } from '../format.js';\nimport { pluginReview } from './pluginReview.js';\nimport { typeKeyFor, typeLabelFor } from '../../bl/openers.js';\nimport { draftFor, promptValueOf, PROMPT } from '../../bl/viewState.js';\nimport { CancelTransferAction, ClearFinishedTransfersAction, CloseContextMenuAction, CloseDialogAction, ClosePluginPanelAction, CreateCollectionFromFormAction, DismissNotificationAction, DismissTransferAction, OpenInPanelAction, PatchDraftAction, RememberOpenerAction, RetryTransferAction, SetViewStateAction, UpdateDialogAction } from '../../bl/actions.js';\nimport { activate } from '../activate.js';\n\nconst { div, span, button, input, h3, p, select, option, label, textarea } = dd;\n\n// ---- Dialog ----------------------------------------------------------------\nexport function dialog(state, ui) {\n const d = state.overlay.dialog;\n if (!d) return null;\n if (d.kind === 'collection') return collectionDialog(d, ui, state.caps, state.view);\n if (d.kind === 'plugin-review') return pluginReview(d, ui, state.view);\n if (d.kind === 'opener-chooser') return openerChooserDialog(d, ui);\n // Both kinds carry ACTIONS — what happens if you say yes — rather than a callback. A\n // prompt's typed value is engine state (see bl/viewState.js), so its actions read what\n // was typed instead of being handed it, and the dialog spec holds no functions.\n //\n // A confirm closes itself here; a prompt's action closes first and then acts, because it\n // has to read the value before the dialog goes.\n const value = promptValueOf(state.view, d);\n const submit = () => {\n if (d.kind === 'confirm') ui.engine.dispatch(new CloseDialogAction());\n activate(ui, { actions: d.confirmActions });\n };\n return div({},\n div({ className: 'scrim' }).on({ click: () => ui.engine.dispatch(new CloseDialogAction()) }),\n div({ className: 'dialog' },\n h3(d.title),\n d.body ? div({ className: 'body' }, d.body) : null,\n d.kind === 'prompt'\n ? div({ className: 'field' },\n d.label ? span({ $styling: { 'font-size': '12px', color: 'var(--text-dim)' } }, d.label) : null,\n input({ className: 'input', value, placeholder: d.placeholder || '', autofocus: true })\n .on({\n input: (e) => ui.engine.dispatch(new SetViewStateAction(PROMPT, { ref: d, value: e.target.value })),\n keydown: (e) => { if (e.key === 'Enter') submit(); if (e.key === 'Escape') ui.engine.dispatch(new CloseDialogAction()); },\n $attach: (el) => queueMicrotask(() => { el.focus(); el.select(); }),\n }),\n )\n : null,\n div({ className: 'row-actions' },\n button({ className: 'btn' }, 'Cancel').on({ click: () => ui.engine.dispatch(new CloseDialogAction()) }),\n button({ className: `btn ${d.danger ? 'danger' : 'primary'}` }, d.confirmLabel || 'OK').on({ click: submit }),\n ),\n ),\n );\n}\n\n// Choose which viewer opens a file when several openers match. Reactive via the\n// workbench dialog state (updateDialog), so radio/checkbox selection survives\n// re-renders. \"Remember\" persists a per-file-type association in settings.\nfunction openerChooserDialog(d, ui) {\n const selected = d.openerId || d.current || d.openers[0]?.id;\n const remember = !!d.remember;\n const confirm = () => {\n if (remember && selected) {\n ui.engine.dispatch(new RememberOpenerAction(typeKeyFor(d.node), selected));\n }\n ui.engine.dispatch(new CloseDialogAction());\n ui.engine.dispatch(new OpenInPanelAction(d.node, selected, { reset: !!d.reset }));\n };\n return div({},\n div({ className: 'scrim' }).on({ click: () => ui.engine.dispatch(new CloseDialogAction()) }),\n div({ className: 'dialog opener-chooser' },\n h3(`Open “${d.node.name}” with…`),\n div({ className: 'opener-list' },\n ...d.openers.map((o) =>\n label({ className: `opener-opt ${o.id === selected ? 'sel' : ''}` },\n input({ type: 'radio', name: 'opener-choice', checked: o.id === selected })\n .on({ change: () => ui.engine.dispatch(new UpdateDialogAction({ openerId: o.id })) }),\n icon(o.icon || iconForNode(d.node), { size: 18 }),\n div({ className: 'oo-main' },\n span({ className: 'oo-title' }, o.title || o.id),\n // Resolved by whoever assembled the list — see describeOpener. Asking the\n // plugin host for a display name mid-render was the last thing keeping\n // `platform` in this dialog.\n span({ className: 'oo-src' }, o.source),\n ),\n ).on({ click: () => ui.engine.dispatch(new UpdateDialogAction({ openerId: o.id })) }),\n ),\n ),\n label({ className: 'opener-remember' },\n input({ type: 'checkbox', checked: remember }).on({ change: (e) => ui.engine.dispatch(new UpdateDialogAction({ remember: e.target.checked })) }),\n span(`Always use this for ${typeLabelFor(d.node)}`),\n ),\n div({ className: 'row-actions' },\n button({ className: 'btn' }, 'Cancel').on({ click: () => ui.engine.dispatch(new CloseDialogAction()) }),\n button({ className: 'btn primary' }, 'Open').on({ click: confirm }),\n ),\n ),\n );\n}\n\n// A collection is a backing-store config, and which stores exist is the SERVER's answer.\n//\n// This form used to hardcode its own list — Filesystem / NAS, S3, Memory — and the fields\n// for each. On Cloudflare Workers that offered a filesystem the runtime cannot provide, so\n// the form could produce a collection the server would refuse to build. Now the drivers and\n// their fields come from /api/capabilities, which reports what was actually registered.\n//\n// The form persists across re-renders (keyed to the dialog instance) so switching driver\n// keeps what has been typed.\n// The collection dialog's unsubmitted form. Engine state, because changing the storage\n// driver changes which fields are on screen — see bl/viewState.js.\nconst COL_FORM = 'collectionDialog';\nfunction collectionDialog(d, ui, caps, view) {\n const drivers = caps?.storageDrivers || [];\n\n // Derived, not written. This used to install the empty form during the render that\n // noticed the dialog had changed — a render with a side effect. `draftFor` answers with\n // the default when the held draft belongs to a different dialog instance, so nothing is\n // written until the user types something.\n const blankForm = {\n name: '', description: '', driver: drivers[0]?.key || '',\n // Off by default and deliberately so: encryption changes what the drive can do for you\n // (see the exposure notes below) and should be a decision, not a default someone\n // discovers later.\n encrypt: false, encryptWhat: 'all', encryptList: '',\n };\n const colState = draftFor(view, COL_FORM, d, { form: blankForm });\n const form = colState.form;\n const driver = drivers.find((x) => x.key === form.driver) || drivers[0];\n // Every field writes through the cell. Only the driver changes which fields are on\n // screen, but writing them all the same way means there is no second rule to remember —\n // and a text field that only mattered on submit was the reason `form` could be mutated\n // in place at all.\n // Merged against STORED state, not against the `form` this render closed over — see\n // PatchDraftAction. Changing two fields before the next render used to lose one.\n const set = (k) => (e) => {\n const value = e.target.type === 'checkbox' ? e.target.checked : e.target.value;\n ui.engine.dispatch(new PatchDraftAction(COL_FORM, colState.ref, { [k]: value }, blankForm));\n };\n\n const submit = () => {\n // Only the fields this driver declared, so a leftover value from a driver the user\n // switched away from is not smuggled into the store config.\n const store = { driver: form.driver };\n for (const f of driver?.fields || []) {\n const v = form[f.name];\n if (v !== undefined && v !== '') store[f.name] = f.type === 'number' ? Number(v) : v;\n }\n ui.engine.dispatch(new CreateCollectionFromFormAction({\n name: form.name, description: form.description, store,\n encryption: encryptionOf(form),\n }));\n };\n\n const field = (lbl, k, ph = '') => div({ className: 'field', $styling: { 'margin-bottom': '10px' } },\n label(lbl), input({ className: 'input', placeholder: ph }).on({ input: set(k) }));\n\n // The server refuses a configuration that would match nothing, and saying so here is the\n // difference between a form that explains itself and an API error after the fact.\n const encryptionProblem = form.encrypt && form.encryptWhat !== 'all' && !parseList(form.encryptList).length\n ? (form.encryptWhat === 'extensions'\n ? 'Name at least one extension, or choose every file.'\n : 'Name at least one media type, or choose every file.')\n : null;\n\n const ready = !!form.name.trim() && !!form.driver && !encryptionProblem\n && (driver?.fields || []).every((f) => !f.required || String(form[f.name] ?? '').trim());\n\n return div({},\n div({ className: 'scrim' }).on({ click: () => ui.engine.dispatch(new CloseDialogAction()) }),\n div({ className: 'dialog', $styling: { width: 'min(480px, 94vw)' } },\n h3('New collection'),\n div({ className: 'body' }, 'A collection is a backing store you own. Configure where its files live.'),\n field('Name', 'name', 'Team Vault'),\n drivers.length\n ? div({ className: 'field', $styling: { 'margin-bottom': '10px' } },\n label('Backing store'),\n select({ className: 'input' },\n ...drivers.map((x) => option({ value: x.key, selected: form.driver === x.key }, x.label)),\n ).on({ change: set('driver') }))\n // No drivers at all means the deployment registered none, which is a server\n // misconfiguration — saying so beats an empty dropdown.\n : div({ className: 'body' }, 'This server has no storage drivers registered, so a collection cannot be created.'),\n driver ? storeFields(driver, form, set) : null,\n encryptionSection(form, set, caps, encryptionProblem),\n div({ className: 'row-actions' },\n button({ className: 'btn' }, 'Cancel').on({ click: () => ui.engine.dispatch(new CloseDialogAction()) }),\n button({ className: 'btn primary', $attrs: ready ? {} : { disabled: 'true' } }, 'Create collection')\n .on({ click: () => ready && submit() }),\n ),\n ),\n );\n}\n\n/** The rules as the API wants them, or null when encryption is off. */\nfunction encryptionOf(form) {\n if (!form.encrypt) return null;\n const list = parseList(form.encryptList);\n return {\n enabled: true,\n rules: form.encryptWhat === 'all'\n ? { all: true }\n : form.encryptWhat === 'extensions'\n ? { extensions: list }\n : { mimeTypes: list },\n };\n}\n\n/** A comma or space separated list, emptied of blanks. */\nfunction parseList(text) {\n return String(text || '').split(/[\\s,]+/).map((x) => x.trim()).filter(Boolean);\n}\n\n/**\n * Turning encryption on, and saying what it does.\n *\n * The scope notes sit HERE rather than in a help page, because the moment someone enables\n * this is the moment the scope matters. What it protects is the storage provider seeing\n * file contents; what it does not protect against is anything that reads through the drive,\n * which includes every indexer. Someone who believes they have just made their files\n * unreadable to the server has been misled by omission.\n */\nfunction encryptionSection(form, set, caps, problem) {\n const indexers = (caps?.indexers || []).filter((i) => i.readsContent !== false);\n return div({ className: 'field enc-section', $styling: { 'margin-bottom': '10px' } },\n label({ className: 'enc-toggle' },\n input({ type: 'checkbox', checked: !!form.encrypt }).on({ change: set('encrypt') }),\n span('Encrypt files in this collection'),\n ),\n !form.encrypt\n ? div({ className: 'enc-hint' }, 'Files are stored exactly as uploaded.')\n : div({ className: 'enc-body' },\n div({ className: 'field' },\n label('What to encrypt'),\n select({ className: 'input' },\n option({ value: 'all', selected: form.encryptWhat === 'all' }, 'Every file'),\n option({ value: 'extensions', selected: form.encryptWhat === 'extensions' }, 'Only these extensions'),\n option({ value: 'mimeTypes', selected: form.encryptWhat === 'mimeTypes' }, 'Only these media types'),\n ).on({ change: set('encryptWhat') })),\n form.encryptWhat !== 'all'\n ? div({ className: 'field' },\n input({\n className: 'input', value: form.encryptList,\n placeholder: form.encryptWhat === 'extensions' ? '.pdf, .docx, .key' : 'image, application/pdf',\n }).on({ input: set('encryptList') }),\n // A media type matches by its leading part too, which is how someone actually\n // thinks about \"encrypt my photos\".\n div({ className: 'enc-hint' }, form.encryptWhat === 'extensions'\n ? 'Separated by commas. The leading dot is optional.'\n : 'Separated by commas. “image” covers every image type.'))\n : null,\n problem ? div({ className: 'enc-problem' }, icon('warn', { size: 13 }), span(problem)) : null,\n div({ className: 'enc-scope' },\n div({ className: 'es-title' }, 'What this does'),\n div({ className: 'es-line' }, 'Files are sealed in your browser before they are uploaded, so the storage provider only ever holds ciphertext.'),\n div({ className: 'es-title' }, 'What it does not do'),\n div({ className: 'es-line' }, 'It is not end-to-end. The drive holds the key and decrypts for anything that reads through it — previews, downloads, and search indexing.'),\n indexers.length\n ? div({ className: 'es-line' }, `These read file contents in the clear: ${indexers.map((i) => i.title || i.id).join(', ')}.`)\n : null,\n div({ className: 'es-line note' }, 'This applies to files uploaded from now on. Turning it off later does not decrypt anything already sealed.'),\n ),\n ),\n );\n}\n\n/** The chosen driver's declared fields, rendered from its descriptor. */\nfunction storeFields(driver, form, set) {\n if (!driver.fields.length) {\n return div({ className: 'body', $styling: { 'font-size': '12px' } },\n driver.description || 'This store needs no configuration.');\n }\n return div({},\n driver.description\n ? div({ className: 'body', $styling: { 'font-size': '12px', 'margin-bottom': '10px' } }, driver.description)\n : null,\n ...driver.fields.map((f) => (f.type === 'boolean'\n ? div({ className: 'field', $styling: { 'margin-bottom': '10px' } },\n label({}, input({ type: 'checkbox' }).on({ change: set(f.name) }), ` ${f.label}`),\n f.help ? div({ className: 'body', $styling: { 'font-size': '11.5px' } }, f.help) : null)\n : div({ className: 'field', $styling: { 'margin-bottom': '10px' } },\n label(f.label + (f.required ? '' : ' (optional)')),\n input({\n className: 'input', placeholder: f.placeholder, autocomplete: 'off',\n // A field the driver marked secret is a password field, so a shoulder or a\n // screen share does not read an access key out of the form.\n type: f.type === 'password' || f.secret ? 'password' : (f.type === 'number' ? 'number' : 'text'),\n }).on({ input: set(f.name) }),\n f.help ? div({ className: 'body', $styling: { 'font-size': '11.5px' } }, f.help) : null))),\n );\n}\n\n// ---- Context menu ----------------------------------------------------------\n// The menu's own geometry, in the one place that can measure it. `MENU_ROW` must match the\n// `.mi` height in the stylesheet; it used to be spelled out at the call sites too, so\n// changing the CSS made status-bar menus overlap their trigger while the clamp below\n// compensated by a different amount.\nconst MENU_WIDTH = 220;\nconst MENU_ROW = 34;\nconst MENU_PAD = 20;\n\n/**\n * Where a menu of `height` should sit, given a point, a rect to hang off, or nothing.\n *\n * Flipping and clamping are the same decision and belong together: anchoring ABOVE a\n * trigger produces a negative top, which is exactly what the clamp is for.\n */\nfunction placeMenu(at, height) {\n const w = window.innerWidth;\n const h = window.innerHeight;\n // No anchor — a keyboard-invoked menu has no geometry to hang off, so it is centred.\n if (!at) return { x: Math.round(w / 2 - MENU_WIDTH / 2), y: Math.round(h / 3) };\n const wantX = at.rect ? at.rect.left : at.x;\n const wantY = at.rect\n ? (at.prefer === 'up' ? at.rect.top - 8 - height : at.rect.bottom + 8)\n : at.y;\n return {\n x: Math.max(8, Math.min(wantX, w - MENU_WIDTH)),\n y: Math.max(8, Math.min(wantY, h - height)),\n };\n}\n\nexport function contextMenu(state, ui) {\n const m = state.overlay.contextMenu;\n if (!m || !m.items?.length) return null;\n // The height is whatever the menu needs OR whatever the window allows, whichever is\n // smaller — past that the menu scrolls (see `.menu`), so pushing it further up buys\n // nothing and would just leave a gap at the bottom.\n const wanted = Math.min(m.items.length * MENU_ROW + MENU_PAD, window.innerHeight - 24);\n const { x, y } = placeMenu(m.at, wanted);\n return div({},\n div({ className: 'scrim', $styling: { background: 'transparent' } }).on({ click: () => ui.engine.dispatch(new CloseContextMenuAction()), contextmenu: (e) => { e.preventDefault(); ui.engine.dispatch(new CloseContextMenuAction()); } }),\n div({ className: 'menu', $styling: { left: x + 'px', top: y + 'px' } },\n ...m.items.map((it, i) =>\n it.sep\n ? div({ className: 'sep' })\n // A real <button>, not a click-handling div: menu entries were unreachable by\n // keyboard and invisible to the TV shell's spatial navigation, which only\n // considers focusable elements.\n : button({ className: `mi ${it.danger ? 'danger' : ''}`, autofocus: i === 0 },\n it.icon ? icon(it.icon, { size: 15 }) : null,\n span(it.label),\n it.kbd ? span({ className: 'kbd' }, it.kbd) : null,\n ).on({\n click: () => { ui.engine.dispatch(new CloseContextMenuAction()); activate(ui, it); },\n // The first item is focused on open, so Escape has to get you back out.\n keydown: (e) => { if (e.key === 'Escape') { e.preventDefault(); ui.engine.dispatch(new CloseContextMenuAction()); } },\n $attach: (el) => { if (i === 0) queueMicrotask(() => el.focus()); },\n }),\n ),\n ),\n );\n}\n\n// ---- Toasts ----------------------------------------------------------------\nexport function toasts(state, ui) {\n const list = state.notif || [];\n if (!list.length) return null;\n return div({ className: 'toasts' },\n ...list.slice(-5).map((n) =>\n div({ className: `toast ${n.level}` },\n div({ className: 'bar' }),\n div({ className: 'msg' }, n.message),\n button({ className: 'x' }, icon('close', { size: 14 })).on({ click: () => ui.engine.dispatch(new DismissNotificationAction(n.id)) }),\n ).key(n.id),\n ),\n );\n}\n\n// ---- Transfer tray ---------------------------------------------------------\nexport function transferTray(state, ui) {\n const items = state.tr.items;\n if (!items.length) return null;\n return div({ className: 'tray' },\n div({ className: 'head' },\n icon('upload', { size: 14 }),\n span({ $styling: { 'margin-left': '6px' } }, 'Transfers'),\n div({ className: 'actions' },\n button({ className: 'iconbtn', title: 'Clear finished' }, icon('check', { size: 14 }))\n .on({ click: () => ui.engine.dispatch(new ClearFinishedTransfersAction()) }),\n ),\n ),\n div({ className: 'items' },\n ...items.map((t) =>\n div({ className: `xfer ${t.status}` },\n div({ className: 'top' },\n icon(t.status === 'error' ? 'warn' : t.status === 'done' ? 'check' : 'upload', { size: 14 }),\n span({ className: 'name' }, t.name),\n t.status === 'active'\n ? button({ className: 'iconbtn', title: 'Cancel' }, icon('close', { size: 13 })).on({ click: () => ui.engine.dispatch(new CancelTransferAction(t.id)) })\n : span({ className: 'pct' }, t.status === 'done' ? bytes(t.total) : t.status),\n ),\n t.status === 'active'\n ? div({ className: 'progress' }, div({ $styling: { width: `${Math.round(t.ratio * 100)}%` } }))\n : t.error ? div({ $styling: { 'font-size': '11px', color: 'var(--danger)', 'margin-top': '4px' } }, t.error) : null,\n t.status === 'active' ? div({ className: 'pct', $styling: { 'margin-top': '4px' } }, `${bytes(t.loaded)} / ${bytes(t.total)}`) : null,\n // Offered on anything that stopped short, cancelled included — the transport\n // already retries what is worth retrying on its own, so a row that reached this\n // state failed for a reason another automatic attempt would not fix. A lost\n // upload session is the case in point: correctly non-retryable, and correctly\n // something the user can choose to start over.\n (t.status === 'error' || t.status === 'cancelled') && t.retryable\n ? div({ className: 'xfer-actions' },\n button({ className: 'btn small' }, icon('refresh', { size: 12 }), span('Retry'))\n .on({ click: () => ui.engine.dispatch(new RetryTransferAction(t.id)) }),\n button({ className: 'btn small ghost' }, 'Dismiss')\n .on({ click: () => ui.engine.dispatch(new DismissTransferAction(t.id)) }),\n )\n : null,\n ).key(t.id),\n ),\n ),\n );\n}\n\n// ---- Plugin popup panel ----------------------------------------------------\nexport function pluginPanel(state, ui) {\n const pid = state.overlay.pluginPanel;\n if (!pid) return null;\n const plugin = (state.plugins || []).find((p) => p.id === pid);\n return div({ className: 'plugin-panel', $styling: { width: '380px' } },\n div({ className: 'head' },\n icon('plug', { size: 14 }),\n span(plugin?.name || pid),\n button({ className: 'iconbtn x' }, icon('close', { size: 14 })).on({ click: () => ui.engine.dispatch(new ClosePluginPanelAction()) }),\n ),\n // The host mounts the plugin's iframe into this element on attach.\n div({ className: 'host' }).on({\n $attach: (el) => {\n el._detach = ui.platform.plugins.mountPanel(pid, el, { width: 380, height: 460 });\n },\n $detach: (el) => el._detach?.(),\n }),\n );\n}\n",
111
+ "// The Activity panel — what is running, and what is stuck.\n//\n// Two sections, because they are two different kinds of fact and the user acts on them\n// differently. Running work is watched and possibly cancelled; a standing problem is\n// retried or dismissed. Merging them into one \"notifications\" list would lose that:\n// a task that finished is over, while an issue that is listed is still true right now.\n//\n// A task that doesn't know its total renders as an indeterminate bar rather than a\n// guess. Nothing here fabricates a percentage.\n\nimport { dd } from '../../runtime.js';\nimport { icon } from '../icon.js';\nimport { bytes } from '../format.js';\nimport { CancelTaskAction, CopyTextAction, DismissIssueAction, DismissTaskAction, ExecCommandAction, RetryIssueAction, ToggleActivityPanelAction } from '../../bl/actions.js';\n\nconst { div, button, span, h3, p, pre } = dd;\n\nconst STATUS_ICON = { running: 'refresh', done: 'check', failed: 'close', cancelled: 'close' };\n\n/**\n * Clipboard, with the value shown if the write is refused.\n *\n * Clipboard permission is denied often enough that a button which silently does nothing\n * reads as broken — and the remedy is the one thing on this panel the user has to get out\n * of the app and into a terminal.\n */\nfunction copyText(text, ui) {\n ui.engine.dispatch(new CopyTextAction(text));\n}\n\nfunction amount(task) {\n if (task.total == null) return null;\n return task.unit === 'bytes'\n ? `${bytes(task.done || 0)} of ${bytes(task.total)}`\n : `${task.done || 0} of ${task.total}${task.unit ? ` ${task.unit}` : ''}`;\n}\n\nfunction taskRow(task, ui) {\n const running = task.status === 'running';\n const determinate = running && task.total != null && task.total > 0;\n const pct = determinate ? Math.min(100, Math.round(((task.done || 0) / task.total) * 100)) : 0;\n return div({ className: `act-task act-${task.status}`, 'data-task-id': task.id },\n div({ className: 'act-row' },\n running\n ? div({ className: 'spinner', $styling: { width: '12px', height: '12px' } })\n : icon(STATUS_ICON[task.status] || 'info', { size: 13 }),\n div({ className: 'act-body' },\n div({ className: 'act-title' }, task.title),\n task.detail ? div({ className: 'act-detail' }, task.detail) : null,\n task.error ? div({ className: 'act-error' }, task.error) : null,\n ),\n running && task.cancellable\n ? button({ className: 'act-action', title: 'Cancel' }, icon('close', { size: 12 })).on({ click: () => ui.engine.dispatch(new CancelTaskAction(task.id)) })\n : !running\n ? button({ className: 'act-action', title: 'Dismiss' }, icon('close', { size: 12 })).on({ click: () => ui.engine.dispatch(new DismissTaskAction(task.id)) })\n : null,\n ),\n running\n // An indeterminate bar animates without claiming a position. The alternative —\n // picking a number — would be a lie dressed as information.\n ? div({ className: `act-bar ${determinate ? '' : 'indeterminate'}` },\n div({ className: 'act-fill', $styling: determinate ? { width: `${pct}%` } : {} }))\n : null,\n running && amount(task) ? div({ className: 'act-amount' }, amount(task)) : null,\n );\n}\n\nfunction issueRow(issue, ui) {\n const since = new Date(issue.firstAt || issue.lastAt).toLocaleString();\n return div({ className: `act-issue act-sev-${issue.severity || 'error'}`, 'data-issue-id': issue.id },\n div({ className: 'act-row' },\n icon(issue.severity === 'warning' ? 'info' : 'close', { size: 13 }),\n div({ className: 'act-body' },\n div({ className: 'act-title' }, issue.title),\n issue.detail ? div({ className: 'act-detail' }, issue.detail) : null,\n // The fix, kept apart from the description and rendered as-is. A remedy is often\n // a policy document or a shell command, and a problem report that describes the\n // fix in prose leaves the reader to retype it.\n issue.remedy ? pre({ className: 'act-remedy' }, issue.remedy) : null,\n div({ className: 'act-meta' }, issue.count > 1 ? `${issue.count} times, since ${since}` : `since ${since}`),\n ),\n ),\n div({ className: 'act-actions' },\n issue.remedy\n ? button({ className: 'btn small ghost' }, 'Copy fix')\n .on({ click: () => copyText(issue.remedy, ui) })\n : null,\n // Retry only when the server said pressing it will actually do something.\n issue.retryable\n ? button({ className: 'btn small act-retry' }, icon('refresh', { size: 12 }), span('Retry'))\n .on({ click: () => ui.engine.dispatch(new RetryIssueAction(issue.id)) })\n : null,\n button({ className: 'btn small ghost act-dismiss' }, 'Dismiss')\n .on({ click: () => ui.engine.dispatch(new DismissIssueAction(issue.id)) }),\n ),\n );\n}\n\nexport default function activityPanel(state, ui) {\n const act = state.act || { tasks: [], issues: [] };\n if (!state.overlay.activityPanel) return null;\n const running = act.tasks.filter((t) => t.status === 'running');\n const recent = act.tasks.filter((t) => t.status !== 'running');\n\n return div({ className: 'activity-panel' },\n div({ className: 'act-head' },\n h3('Activity'),\n button({ className: 'act-action', title: 'Close' }, icon('close', { size: 13 }))\n .on({ click: () => ui.engine.dispatch(new ToggleActivityPanelAction(false)) }),\n ),\n\n // \"Nothing is wrong\" and \"we couldn't ask\" look identical unless one says so. Both\n // loads are reported, because either can fail alone.\n act.tasksError || act.issuesError\n ? div({ className: 'act-offline' }, icon('info', { size: 12 }),\n span(`Couldn't reach the server — this list may be out of date (${act.issuesError || act.tasksError})`))\n : null,\n\n div({ className: 'act-section' },\n div({ className: 'act-section-title' }, 'Running'),\n running.length\n ? div(...running.map((t) => taskRow(t, ui)))\n : p({ className: 'act-empty' }, 'Nothing running.'),\n ),\n\n act.issues.length\n ? div({ className: 'act-section' },\n div({ className: 'act-section-title' }, `Needs attention (${act.issues.length})`),\n div(...act.issues.map((i) => issueRow(i, ui))),\n )\n : div({ className: 'act-section' },\n div({ className: 'act-section-title' }, 'Needs attention'),\n // An unreadable list is not an empty one, and must never render as \"all clear\".\n p({ className: 'act-empty' },\n act.issuesError ? 'Could not load the list of problems.' : act.issuesLoading ? 'Checking…' : 'No standing problems.'),\n ),\n\n recent.length\n ? div({ className: 'act-section' },\n div({ className: 'act-section-title' }, 'Recently finished'),\n div(...recent.map((t) => taskRow(t, ui))),\n )\n : null,\n\n div({ className: 'act-foot act-actions' },\n button({ className: 'btn small ghost act-rebuild' }, icon('refresh', { size: 12 }), span('Rebuild search index'))\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.rebuildIndex')) }),\n button({ className: 'btn small ghost act-scan' }, icon('refresh', { size: 12 }), span('Scan for outside changes'))\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.scanCollection')) }),\n // On demand as well as on a schedule, because the moment an admin wants to know\n // whether they fixed the bucket is right after they changed it — not up to five\n // minutes later. It also checks against THIS browser's origin, which the scheduled\n // run can only do if the deployment configured one.\n button({ className: 'btn small ghost act-storage' }, icon('plug', { size: 12 }), span('Check storage'))\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.checkStorage')) }),\n ),\n );\n}\n",
112
+ "// The phone shell: a thin top bar, a bottom tab bar, and two sheets.\n//\n// A left rail costs 52px of a 390px-wide screen and a status bar costs a row of chrome\n// that is unreadable at that size anyway — on a phone both are worse than useless. So\n// the rail's destinations become bottom tabs (thumb-reachable, which the top of the\n// screen is not), everything past the first few becomes one \"More\" sheet, and the whole\n// status bar folds behind a single icon in the top bar.\n//\n// The icon is not decoration: it changes to say what is happening. Work running shows a\n// spinner, a standing problem shows a badge, and neither is something the user has to go\n// looking for. Everything else — item counts, free space, backend — is a tap away rather\n// than permanently on screen, because on a phone it is reference material, not status.\n\nimport { dd } from '../../runtime.js';\nimport { icon } from '../icon.js';\nimport { bytes } from '../format.js';\nimport { usageChip } from './statusBar.js';\nimport { CloseSheetAction, ExecCommandAction, OpenSheetAction, ToggleActivityPanelAction, ToggleInboxAction } from '../../bl/actions.js';\n\nconst { div, button, span, img } = dd;\n\n// The tabs that earn a permanent slot. Everything else lives in More — a bottom bar with\n// six items is a bottom bar nobody can hit.\nconst TABS = [\n { id: 'home', icon: 'search', label: 'Files', command: 'workbench.view.home' },\n { id: 'upload', icon: 'upload', label: 'Upload', command: 'explorer.upload' },\n { id: 'plugins', icon: 'plug', label: 'Plugins', command: 'workbench.view.plugins' },\n];\n\n// How to DRAW each condition. Which condition is the one worth showing — offline over a\n// standing problem, a standing problem over work in progress — is decided by the\n// `statusFacts` query, because that ordering is a claim about what a person most needs to\n// know rather than a question about glyphs. See bl/status.js.\nconst GLYPHS = {\n offline: { icon: 'info', tone: 'warn' },\n issues: { icon: 'warn', tone: 'danger' },\n working: { spinner: true, tone: '' },\n lowSpace: { icon: 'info', tone: 'warn' },\n idle: { icon: 'info', tone: '' },\n};\n\nexport function phoneTopBar(state, ui) {\n const f = state.facts;\n const c = f.condition;\n const g = { ...(GLYPHS[c.kind] || GLYPHS.idle), label: c.label, badge: c.kind === 'issues' ? c.count : 0 };\n // Where you are, at the coarsest level. Deliberately NOT the open file's name: the\n // viewer's own breadcrumb sits directly beneath this bar and already says that, and two\n // rows of chrome repeating \"notes.txt\" costs a fifth of the screen to say it twice.\n const title = state.wb.activity === 'settings' ? 'Settings'\n : state.wb.activity === 'plugins' ? 'Plugins'\n : f.collectionLabel;\n return div({ className: 'phonebar top' },\n button({ className: 'pb-brand', title: 'Trove — home' }, img({ src: '/icon.svg', alt: 'Trove' }))\n .on({ click: () => ui.engine.dispatch(new ExecCommandAction('workbench.view.home')) }),\n div({ className: 'pb-title' }, title),\n button({ className: `pb-status ${g.tone}`, title: g.label, $attrs: { 'aria-label': g.label } },\n g.spinner\n ? div({ className: 'spinner', $styling: { width: '15px', height: '15px' } })\n : icon(g.icon, { size: 18 }),\n g.badge ? span({ className: 'pb-badge' }, String(g.badge > 9 ? '9+' : g.badge)) : null,\n ).on({ click: () => ui.engine.dispatch(new OpenSheetAction('status')) }),\n );\n}\n\nexport function phoneBottomBar(state, ui) {\n const active = state.wb.activity;\n const sheet = state.wb.sheet;\n const unread = state.so.notifications.unread;\n return div({ className: 'phonebar bottom' },\n ...TABS.map((t) => button({\n className: `pb-tab ${!sheet && active === t.id ? 'active' : ''}`,\n $attrs: { 'aria-label': t.label },\n }, icon(t.icon, { size: 21 }), span({ className: 'pb-label' }, t.label))\n .on({ click: () => { ui.engine.dispatch(new CloseSheetAction()); ui.engine.dispatch(new ExecCommandAction(t.command)); } })),\n // Settings is reached FROM the More sheet, so while you are in it \"More\" is where\n // you are — otherwise all four tabs read as inactive and the bar claims you are\n // nowhere.\n button({\n className: `pb-tab ${sheet === 'more' || (!sheet && !TABS.some((t) => t.id === active)) ? 'active' : ''}`,\n $attrs: { 'aria-label': 'More' },\n },\n icon('dots', { size: 21 }),\n unread ? span({ className: 'pb-badge' }, String(unread > 9 ? '9+' : unread)) : null,\n span({ className: 'pb-label' }, 'More'),\n ).on({ click: () => ui.engine.dispatch(new OpenSheetAction('more')) }),\n );\n}\n\n/** A row in a sheet: an icon, a label, and either a value or a chevron. */\nfunction sheetRow({ icon: name, label, value, danger, onClick }) {\n const body = [\n icon(name, { size: 18 }),\n span({ className: 'sr-label' }, label),\n value != null ? span({ className: 'sr-value' }, value) : null,\n onClick ? icon('chevron-right', { size: 16, className: 'sr-go' }) : null,\n ];\n return onClick\n ? button({ className: `sheet-row ${danger ? 'danger' : ''}` }, ...body).on({ click: onClick })\n : div({ className: 'sheet-row static' }, ...body);\n}\n\nexport function phoneSheet(state, ui) {\n const which = state.wb.sheet;\n if (!which) return null;\n return div({ className: 'sheet-wrap' },\n div({ className: 'scrim' }).on({ click: () => ui.engine.dispatch(new CloseSheetAction()) }),\n div({ className: 'sheet' },\n div({ className: 'sheet-grip' }).on({ click: () => ui.engine.dispatch(new CloseSheetAction()) }),\n which === 'status' ? statusSheet(state, ui) : moreSheet(state, ui),\n ),\n );\n}\n\nfunction statusSheet(state, ui) {\n const f = state.facts;\n const go = (cmd) => () => { ui.engine.dispatch(new CloseSheetAction()); ui.engine.dispatch(new ExecCommandAction(cmd)); };\n return div({ className: 'sheet-body' },\n div({ className: 'sheet-title' }, f.collectionLabel),\n\n // Problems and running work first: they are the reason someone opened this.\n f.issues.length\n ? sheetRow({\n icon: 'warn', danger: true,\n label: `${f.issues.length} need${f.issues.length === 1 ? 's' : ''} attention`,\n onClick: () => { ui.engine.dispatch(new CloseSheetAction()); ui.engine.dispatch(new ToggleActivityPanelAction(true)); },\n })\n : null,\n f.running.length || f.uploading.length\n ? sheetRow({\n icon: 'refresh',\n label: `${f.running.length + f.uploading.length} running`,\n onClick: () => { ui.engine.dispatch(new CloseSheetAction()); ui.engine.dispatch(new ToggleActivityPanelAction(true)); },\n })\n : null,\n !f.off.online ? sheetRow({ icon: 'info', label: 'Offline', value: `${f.off.pins.length} pinned` }) : null,\n f.off.queued ? sheetRow({ icon: 'upload', label: 'Waiting to sync', value: String(f.off.queued) }) : null,\n\n sheetRow({\n icon: 'files',\n label: 'Items',\n value: f.partial\n ? `${f.shown.toLocaleString()} of ${f.totalKnown ? f.totalItems.toLocaleString() : 'more'}`\n : f.totalItems.toLocaleString(),\n }),\n // `+` where the figure covers only what has loaded, matching the desktop bar.\n sheetRow({ icon: 'file', label: 'Size', value: `${bytes(f.totalBytes)}${f.totalKnown || !f.partial ? '' : '+'}` }),\n // Only where the backend can actually answer — see usageChip.\n f.usage?.total\n ? div({ className: 'sheet-row static usage' },\n icon('download', { size: 18 }),\n span({ className: 'sr-label' }, 'Free space'),\n usageChip(f))\n : null,\n state.caps ? sheetRow({\n icon: state.caps.storage?.presignDownload ? 'download' : 'files',\n label: 'Transfers',\n value: state.caps.storage?.presignDownload ? 'Direct to storage' : 'Through the server',\n }) : null,\n state.caps?.features?.semanticSearch ? sheetRow({ icon: 'star', label: 'Search', value: 'Semantic + keyword' }) : null,\n\n div({ className: 'sheet-actions' },\n button({ className: 'btn small ghost' }, icon('refresh', { size: 13 }), span('Scan for changes')).on({ click: go('workbench.scanCollection') }),\n button({ className: 'btn small ghost' }, icon('refresh', { size: 13 }), span('Activity'))\n .on({ click: () => { ui.engine.dispatch(new CloseSheetAction()); ui.engine.dispatch(new ToggleActivityPanelAction(true)); } }),\n ),\n );\n}\n\nfunction moreSheet(state, ui) {\n const go = (cmd) => () => { ui.engine.dispatch(new CloseSheetAction()); ui.engine.dispatch(new ExecCommandAction(cmd)); };\n const me = state.so.me;\n const unread = state.so.notifications.unread;\n return div({ className: 'sheet-body' },\n // No identity, no profile row — the same rule the desktop rail follows. An anonymous\n // deployment has no account to show and nothing to sign into.\n me && !me.anonymous\n ? div({ className: 'sheet-me' },\n me.picture ? img({ src: me.picture, alt: '', className: 'avatar-img' }) : span({ className: 'avatar-txt' }, (me.name || me.id || '?')[0].toUpperCase()),\n div({}, div({ className: 'sm-name' }, me.name || me.id), me.email ? div({ className: 'sm-sub' }, me.email) : null))\n : null,\n\n sheetRow({ icon: 'bell', label: unread ? `Notifications (${unread})` : 'Notifications', onClick: () => { ui.engine.dispatch(new CloseSheetAction()); ui.engine.dispatch(new ToggleInboxAction(true)); } }),\n sheetRow({ icon: 'refresh', label: 'Activity & problems', onClick: () => { ui.engine.dispatch(new CloseSheetAction()); ui.engine.dispatch(new ToggleActivityPanelAction(true)); } }),\n sheetRow({ icon: 'info', label: 'Details & conversation', onClick: go('workbench.toggleInfoPanel') }),\n sheetRow({ icon: 'trash', label: 'Trash', onClick: go('explorer.showTrash') }),\n sheetRow({ icon: 'refresh', label: 'Refresh', onClick: go('explorer.refresh') }),\n sheetRow({ icon: 'command', label: 'All commands', onClick: go('workbench.showCommandPalette') }),\n sheetRow({ icon: 'gear', label: 'Settings', onClick: go('workbench.openSettings') }),\n );\n}\n",
113
+ "// Root composition. Assembles the `ui` helper (stable for the app's life), zips every\n// query the shell reads into one snapshot, and renders the workbench from it.\n//\n// Components are pure: they receive (state, ui) and dispatch. This module knows about\n// every QUERY at once — which is a different thing from what it used to know, when it\n// held the bag of services every component reached through.\n\nimport { dd, derive, watch } from '../../runtime.js';\nimport { region } from '../region.js';\nimport { watchQuery } from '../../bl/watchQuery.js';\nimport * as q from '../../bl/queries.js';\nimport { CloseSearchModalAction, NavigateAction } from '../../bl/actions.js';\nimport activityBar from '../components/activityBar.js';\nimport statusBar from '../components/statusBar.js';\nimport launcher from '../components/launcher.js';\nimport settingsView, { keybindingRows, CAPTURE } from '../components/settingsView.js';\nimport collectionGate from '../components/collectionGate.js';\nimport pluginsView from '../components/pluginsView.js';\nimport adminView from '../components/adminView.js';\nimport editorArea from '../components/editorArea.js';\nimport commandPalette from '../components/commandPalette.js';\nimport { dialog, contextMenu, toasts, transferTray, pluginPanel } from '../components/overlays.js';\nimport activityPanel from '../components/activityPanel.js';\nimport { infoPanel } from '../components/social.js';\nimport { phoneTopBar, phoneBottomBar, phoneSheet } from '../components/phoneChrome.js';\n\nconst { alias, div } = dd;\n\nexport default function workbench({ engine, platform }) {\n // What a component is handed, and it is nearly nothing now.\n //\n // `engine` is the thing components talk to: `dispatch` for an action, `query` for a\n // question. It was removed once for being unreferenced, which was true and backwards —\n // nothing referenced it precisely BECAUSE `go` and `exec` stood in for it, and `exec`\n // called the command service directly, so every menu item, keybinding and palette entry\n // a person triggered was invisible to the engine.\n //\n // Both are gone. `go(action)` was `engine.dispatch(action)` with a shorter name, and a\n // shorter name for the one door is how the door stops being obvious. Call sites say\n // `ui.engine.dispatch(new SomeAction(...))` now: longer, and it names what happens.\n //\n // `platform` is still passed, for four uses that are genuinely imperative: two plugin\n // iframe mounts, the media URL machinery, and the opener lookup in openers/index.js —\n // which stays because an opener may resolve to a plugin iframe rather than to a render\n // function, and mounting one is an effect, not a view.\n //\n // Note what is NOT a reason: carrying a function. A query hands over the view renderers\n // (see the `views` query) because a renderer is pure — it builds a vnode from what it is\n // given. The rule is about SIDE EFFECTS escaping through a callable, not about callables.\n //\n // See docs/tickets/009. `app` used to be here too — the whole bag of services — and is\n // gone: nothing in `ui/` reads a service directly any more.\n const ui = {\n engine, platform,\n // Rendering a cell is a UI concern, not a platform subsystem to reach through.\n watch,\n };\n\n // One derived snapshot of every slice the shell reads. `derive` invalidates when any\n // of them does and recomputes once on the next read, so fifteen changes in a frame\n // still cost one render.\n const combined = derive(\n // EVERY input is a query. Half of these used to read the service cell directly, which\n // looked equivalent and was not: a query may PROJECT, and the projection is where\n // `offline.pinnedIds` and `voice.canListen` come from. Reading the raw cell got the\n // service's state without them, so a pinned file's menu still offered to pin it and the\n // microphone button never appeared — silently, because an undefined field just reads as\n // false. Going through the engine uniformly is what makes \"the same slice\" mean the\n // same thing everywhere.\n [\n watchQuery(engine, q.workbench),\n watchQuery(engine, q.overlay),\n watchQuery(engine, q.navigation),\n watchQuery(engine, q.explorer),\n watchQuery(engine, q.search),\n watchQuery(engine, q.context),\n watchQuery(engine, q.settings),\n watchQuery(engine, q.offline),\n watchQuery(engine, q.viewport),\n watchQuery(engine, q.voice),\n // What the UI is in the middle of doing — see bl/viewState.js.\n watchQuery(engine, q.viewState),\n // What the server can do. Its resource hands out a cell that starts null and fills\n // in, so this is a normal value while the request is in flight rather than turning\n // the whole snapshot PENDING and blanking the shell.\n watchQuery(engine, q.capabilities),\n // Command id -> its shortcut label, for anything that shows one next to an action.\n watchQuery(engine, q.commandKeys),\n // What the launcher shows, twice: the home screen and the double-shift overlay are\n // both mounted when the overlay is up, and they differ in what picking a row does —\n // the overlay resets the viewer stack and then dismisses itself. That is the only\n // input that is about which INSTANCE is rendering, so it is the query's one\n // parameter, and interning means at most two live realizations.\n watchQuery(engine, q.launcherContent(false)),\n watchQuery(engine, q.launcherContent(true)),\n // How results can be drawn, and every opener that could run. Both used to be worked\n // out mid-render from `platform` — three registry reads that nothing invalidated on,\n // so the launcher and the viewer nav only kept up because this snapshot is coarse\n // enough to redraw them anyway. As a query the dependency is declared, which is what\n // makes it safe to give either of them a region later.\n watchQuery(engine, q.views),\n watchQuery(engine, q.openers),\n ],\n // No `_bump` any more. It existed to defeat `watch`'s shallow-equality check for a\n // forced re-render that left no trace in the snapshot — a counter smuggled into the\n // state to get past an optimisation designed to skip pointless renders. With the state\n // that needed it in a cell, every render has a reason again.\n (wb, overlay, nav, ex, se, ctx, settings, off, vp, voice, view, caps, commandKeys,\n content, modalContent, views, openers) =>\n ({ wb, overlay, nav, ex, se, ctx, settings, off, vp, voice, view, caps, commandKeys,\n content, modalContent, views, openers }),\n );\n\n // The chrome, subscribed to what it reads instead of to everything.\n //\n // These four render the same facts in different shapes — `statusFacts` is shared between\n // them — so they share a query set. Splitting them out is what takes `tr` off the main\n // snapshot: an upload progress tick used to invalidate the one watch that builds the whole\n // shell, so moving one number in the transfer tray reconstructed every row of the file\n // list beneath it. Now it reaches the chrome and the tray, and nothing else.\n const chrome = {\n ex: q.explorer, tr: q.transfers, act: q.activity, off: q.offline,\n so: q.social, wb: q.workbench, statusItems: q.statusItems, caps: q.capabilities,\n // The numbers and the one-line verdict both shells report. Derived by the query rather\n // than by the status bar and imported from there by the phone chrome, which is what it\n // was — a business-layer derivation living in a component. See bl/status.js.\n facts: q.statusFacts,\n };\n // A query boots asynchronously — it awaits a container lease first — so a region is\n // PENDING for the first frame or two and `watch` renders its placeholder. For a bar with\n // a fixed height that has to be an empty bar rather than nothing, or the layout jumps\n // once on load and settles.\n const regions = {\n statusBar: region(engine, chrome, (s) => statusBar(s, ui), { placeholder: () => div({ className: 'statusbar' }) }),\n phoneTopBar: region(engine, chrome, (s) => phoneTopBar(s, ui), { placeholder: () => div({ className: 'phonebar top' }) }),\n phoneBottomBar: region(engine, chrome, (s) => phoneBottomBar(s, ui), { placeholder: () => div({ className: 'phonebar bottom' }) }),\n // Both render nothing when there is nothing to show, so an absent first frame is what\n // they would have drawn anyway.\n phoneSheet: region(engine, chrome, (s) => phoneSheet(s, ui)),\n transferTray: region(engine, { tr: q.transfers }, (s) => transferTray(s, ui)),\n // Both read one slice each, and both change often enough to matter: a toast arriving\n // or auto-dismissing used to rebuild the entire shell — including every row of the\n // file list — to add a line in the corner.\n toasts: region(engine, { notif: q.notifications }, (s) => toasts(s, ui)),\n // `overlay` as well as `act`: the panel's open flag is overlay state like every other\n // transient surface, and its contents are the poller's.\n activityPanel: region(engine, { act: q.activity, overlay: q.overlay }, (s) => activityPanel(s, ui)),\n // A region like its neighbours, and it has to be: it reads `plugins`, which the main\n // snapshot does not contain — so `state.plugins` was permanently undefined, `|| []`\n // swallowed it, and the panel header showed the raw plugin id where the display name\n // belongs. It was the one component the region split left reading a key nobody\n // supplies. Being a region also takes it off the main snapshot, which is the point.\n pluginPanel: region(engine, { overlay: q.overlay, plugins: q.plugins },\n (s) => pluginPanel(s, ui)),\n // Screens that are usually NOT on screen. Their state still invalidated the shell from\n // wherever they were: minting an API key or a plugin reporting in rebuilt the file\n // list. Each reads a couple of slices, so each is a cheap region.\n settingsView: region(engine, {\n settings: q.settings, settingsGroups: q.settingsGroups, keys: q.apiKeys,\n caps: q.capabilities, ex: q.explorer, assoc: q.openerAssociations,\n }, (s) => settingsView(s, ui, regions)),\n // The keybinding table is its own region so a chord capture does not re-render the\n // whole settings screen. Built HERE, with every other region — at module scope it\n // pinned the first engine it ever saw.\n keybindings: region(engine, { bindings: q.keybindings, view: q.viewState },\n (s) => keybindingRows(s.bindings || [], ui, s.view?.[CAPTURE] ?? null)),\n pluginsView: region(engine, { plugins: q.plugins, settings: q.settings },\n (s) => pluginsView(s, ui)),\n // Gathers what already exists rather than fetching anything new — see adminView.js.\n adminView: region(engine, {\n caps: q.capabilities, ex: q.explorer, plugins: q.plugins, act: q.activity, so: q.social,\n wb: q.workbench,\n }, (s) => adminView(s, ui)),\n infoPanel: region(engine, { so: q.social, off: q.offline, nav: q.navigation },\n (s) => infoPanel(s, ui)),\n // The rail. It renders the notification bell and the identity chip, both of which read\n // the social slice — which is how `so` was still reaching the shell after infoPanel\n // moved out. Missed by looking at infoPanel alone; the bell is imported INTO the bar\n // from social.js, so a grep for the component name does not find it.\n activityBar: region(engine, { wb: q.workbench, plugins: q.plugins, so: q.social },\n (s) => activityBar(s, ui)),\n // The palette is the first thing to read a composed view rather than a service's state:\n // `commands` arrives with keybinding labels resolved and availability decided, so the\n // component stopped asking the keybinding and command services anything mid-render.\n // `matches` is the list already ranked against what has been typed — the palette does\n // no scoring of its own any more. See bl/match.js for why there was more than one.\n commandPalette: region(engine, { overlay: q.overlay, se: q.search, matches: q.paletteMatches },\n (s) => commandPalette(s, ui)),\n };\n\n return alias(() => watch(combined, (state) => view(state, ui, regions)));\n}\n\nfunction view(state, ui, regions) {\n const mode = state.vp?.mode || 'desktop';\n const phone = mode === 'phone';\n return div({ className: `shell ${mode} ${state.settings['workbench.density'] === 'compact' ? 'compact' : ''}` },\n // On a phone the rail becomes a bottom bar and the status bar folds behind one icon\n // in a top bar — see phoneChrome. Everything between them is identical, which is the\n // point: only the chrome changes shape, not the app.\n phone ? regions.phoneTopBar() : null,\n div({ className: 'body' },\n phone ? null : regions.activityBar(),\n mainArea(state, ui, regions),\n ),\n phone ? regions.phoneBottomBar() : regions.statusBar(),\n phone ? regions.phoneSheet() : null,\n // Overlays.\n searchModal(state, ui),\n regions.commandPalette(),\n dialog(state, ui),\n contextMenu(state, ui),\n regions.pluginPanel(),\n regions.toasts(),\n regions.transferTray(),\n regions.activityPanel(),\n );\n}\n\nfunction mainArea(state, ui, regions) {\n // Before a collection is known there is nothing to draw: every scoped request names one\n // in its path, so a file list, a search box and an Upload button would all be lying.\n // Settings stays reachable — an admin with no collections still needs to get at it.\n if (state.ex?.gate && state.wb.activity !== 'settings') return collectionGate(state, ui);\n\n switch (state.wb.activity) {\n case 'settings': return regions.settingsView();\n case 'plugins': return regions.pluginsView();\n case 'admin': return regions.adminView();\n default: {\n // Home: the top of the panel stack — the launcher (base search) or, once a\n // file is open, its opener full-width (optionally split with the info panel).\n if (!state.nav.activeTabId) return launcher(state, ui);\n if (!state.wb.infoPanel) return editorArea(state, ui);\n // A 340px rail beside a 390px screen leaves nothing on either side. On a phone the\n // details panel takes the whole panel instead — it has its own close button, so\n // there is still a way back to the file.\n return state.vp?.mode === 'phone'\n ? regions.infoPanel()\n : div({ className: 'editor-split' }, editorArea(state, ui), regions.infoPanel());\n }\n }\n}\n\n// Double-shift search: the launcher as a modal overlay. Picking an item resets the\n// viewer stack (starts over) — the launcher reads state.wb.searchModal to know.\nfunction searchModal(state, ui) {\n if (!state.wb.searchModal) return div();\n return div({ className: 'search-modal' },\n div({ className: 'scrim' }).on({ click: () => ui.engine.dispatch(new CloseSearchModalAction()) }),\n div({ className: 'search-modal-panel' }, launcher(state, ui, { modal: true })),\n );\n}\n\nexport { NavigateAction };\n",
114
+ "// Booting a workbench — the whole client, as a function you call with what you want\n// added to it.\n//\n// This used to be `main.js`: a fixed sequence that registered a fixed set of openers\n// and mounted. Which is fine until someone wants to SHIP a different drive — a hosted\n// build with a rich media player, an image-caption indexer and a gallery view — and\n// finds the only way in is to fork the package. Every contribution the built-ins use\n// goes through the same registry a plugin's does, so there was never a technical reason\n// for that; there was only a hard-coded list.\n//\n// import { createWorkbench } from '@3sln/trove/web/workbench.js';\n//\n// createWorkbench({\n// openers: [{ id: 'acme.player', title: 'Player', priority: 60,\n// match: { mime: ['video/*'] }, component: player }],\n// views: [{ id: 'acme.gallery', title: 'Gallery', icon: 'grid', priority: 70,\n// match: { mime: ['image/*'] }, render: gallery }],\n// });\n//\n// Two ways to displace a built-in, both falling out of how the registry already works:\n// register a HIGHER PRIORITY (selection sorts by it, and the user can still pick the\n// plain one from the chooser), or register the SAME ID (the registry is a map, so it is\n// replaced outright). Prefer the first — it leaves the original reachable.\n//\n// These openers and views run IN PROCESS. That is the difference between a build of the\n// app and a plugin, and it cuts both ways: full access to the platform, and no sandbox\n// to catch a mistake. Anything a user installs is a plugin and stays in its frame.\n\nimport { dd, effect } from './runtime.js';\nimport { createPlatform } from './platform/index.js';\nimport { createApp } from './bl/index.js';\nimport {\n NavigateAction, UploadFilesAction, OpenInitialCollectionAction, OpenSearchModalAction,\n OpenInPanelAction, ShowContextMenuAction,\n} from './bl/actions.js';\nimport { parsePackage } from './platform/pluginPackage.js';\nimport workbenchComposition from './ui/compositions/workbench.js';\nimport { registerBuiltinOpeners } from './ui/components/openers/index.js';\nimport { registerBuiltinViews } from './ui/components/views/index.js';\nimport { attachMedia } from './ui/media.js';\n\n/**\n * Build the platform, mount the workbench, and wire the cross-cutting behaviours that\n * belong to no single component — theme, global keybindings, OS drag-and-drop upload,\n * capability probing, the plugin catalog.\n *\n * @param {object} [options]\n * @param {Element} [options.root] where to mount (default `.workbench`)\n * @param {string} [options.baseUrl] API origin (default same-origin)\n * @param {Array} [options.openers] extra openers: `{ id, title, match, priority?, component }`\n * @param {Array} [options.views] extra views: `{ id, title, icon?, match?, priority?, render, move? }`\n * @param {Array} [options.settings] extra setting schemas, for whatever those contribute\n * @param {boolean} [options.serviceWorker] register /sw.js (default true)\n * @param {boolean} [options.debug] install `window.__trove` (default off — see below)\n * @returns {{platform: object, engine: object, app: object}}\n */\nexport function createWorkbench({\n root = document.querySelector('.workbench'),\n baseUrl = '',\n openers = [],\n views = [],\n settings = [],\n serviceWorker = true,\n // OFF unless someone asks. `window.__trove` is the one place the entire resource graph —\n // engine, platform, app, plus a direct `plugins.install` from raw bytes that goes around\n // the review dialog — is reachable without a dispatch, and it shipped unconditionally in\n // the production bundle. The global is how automation asks: Playwright's `addInitScript`\n // sets it before any page script runs, and a developer can set it and reload. Nothing an\n // attacker controls can set a global in this origin, and a person with our console open\n // can already do all of it.\n debug = globalThis.__troveDebug === true,\n} = {}) {\n const platform = createPlatform({ baseUrl });\n const { engine, app } = createApp(platform);\n\n // Built-in openers and views are UI, so they register from the composition layer\n // (which is allowed to know both platform and ui) rather than from bl/.\n registerBuiltinOpeners(platform);\n registerBuiltinViews(platform);\n // Then whatever this build adds, so a same-id registration replaces the built-in\n // rather than being replaced by it.\n register(platform, 'opener', openers);\n register(platform, 'view', views);\n if (settings.length) platform.settings.register(settings);\n\n // Plugins are installed by the user (from a .zip or a URL) and persisted locally;\n // restore any that were installed on this device, then run.\n platform.plugins.restore();\n\n // --- mount ----------------------------------------------------------------\n const App = workbenchComposition({ engine, platform });\n dd.reconcile(root, [App()]);\n\n // --- theme ----------------------------------------------------------------\n const applyTheme = () => {\n document.documentElement.dataset.theme = platform.settings.get('workbench.theme') || 'dark';\n };\n applyTheme();\n effect(platform.settings.observe(), () => applyTheme());\n\n // --- form factor ----------------------------------------------------------\n // Watch the window so rotating a phone, or dragging a desktop window narrow, re-picks\n // the shell. Also stamps data-layout on <html> for the CSS half of the same decision.\n platform.viewport.install();\n // Ask once whether this browser can transcribe on-device, so the launcher knows\n // whether to offer a microphone. Nothing is downloaded and no permission is requested\n // — see platform/voice.js.\n platform.voice.refresh().catch(() => {});\n // Remote-control navigation, which switches itself on and off with the TV layout.\n platform.spatialNav.install();\n\n // --- keybindings ----------------------------------------------------------\n platform.keybindings.install(window);\n\n // --- viewer stack ↔ browser history ---------------------------------------\n // Browser back/forward. The panel stack is the only thing that mirrors itself into\n // history, so this reaches it directly rather than through a shell object.\n window.addEventListener('popstate', (e) => app.navigation.onPopState(e));\n installDoubleShift(engine);\n\n // --- service worker (offline shell + pinned files + push) -----------------\n if (serviceWorker && 'serviceWorker' in navigator) {\n window.addEventListener('load', () => navigator.serviceWorker.register('/sw.js').catch(() => {}));\n }\n\n installDragAndDrop(engine);\n\n // --- initial load ---------------------------------------------------------\n // Land on a collection the user can actually read — see OpenInitialCollectionAction.\n //\n // This was an async IIFE whose `try` block held only a comment, so its `catch` was not\n // merely dead but a CLAIM: a reader looking for where boot verifies the server is\n // reachable found \"Cannot reach the Trove server\" and it could never fire. The capability\n // fetch it once guarded belongs to the `capabilities` provider now, whose rejection arm\n // deliberately swallows — whether boot should report an unreachable server is that\n // provider's decision to make, not a wrapper's around one synchronous call.\n engine.dispatch(new OpenInitialCollectionAction());\n\n if (debug) installDebugHandle({ platform, engine, app });\n\n return { platform, engine, app };\n}\n\n/** The automation handle. See the `debug` option — this is not installed by default. */\nfunction installDebugHandle({ platform, engine, app }) {\n window.__trove = {\n platform, engine, app,\n // Test/automation hook: install a package from raw zip bytes.\n test: {\n parsePackage,\n assessTrust: (pkg) => platform.plugins.assessTrust(pkg),\n install: (pkg, opts) => platform.plugins.install(pkg, opts),\n NavigateAction,\n // The intents that take a SUBJECT, and so have no command to execute. Everything\n // else a probe wants is `platform.commands.execute(id)` — the same path a click\n // takes. These dispatch rather than writing state, so the engine sees a probe's\n // actions exactly as it sees a person's.\n open: (node, openerId) => platform.dispatch(new OpenInPanelAction(node, openerId)),\n contextMenu: (items, at) => platform.dispatch(new ShowContextMenuAction(items, at)),\n // Keeping a media element pointed at a URL that still works is the half of signed\n // URLs that only shows up over time, so it is drivable from a probe.\n attachMedia,\n },\n };\n}\n\n/**\n * Register a build's own contributions.\n *\n * `id` is required and it is not a formality: an unaddressed contribution cannot be\n * remembered as someone's default opener, cannot be pinned as their view, and cannot be\n * named in a keymap. Failing here is far better than shipping a build whose media\n * player silently forgets which one the user chose.\n */\nfunction register(platform, type, list) {\n for (const c of list) {\n if (!c?.id) throw new Error(`A ${type} passed to createWorkbench needs an \"id\"`);\n const { id, ...spec } = c;\n platform.contributions.register(id, { type, ...spec });\n }\n}\n\n// Double-shift → modal search overlay (Raycast-style). Two Shift presses within 400ms,\n// with no other key between, open it.\nfunction installDoubleShift(engine) {\n let lastShift = 0;\n window.addEventListener('keydown', (e) => {\n if (e.key === 'Shift' && !e.repeat) {\n const now = Date.now();\n if (now - lastShift < 400) { engine.dispatch(new OpenSearchModalAction()); lastShift = 0; }\n else lastShift = now;\n } else if (e.key !== 'Shift') {\n lastShift = 0;\n }\n });\n}\n\n// Dropping files anywhere on the window uploads them to the open collection.\nfunction installDragAndDrop(engine) {\n let dragDepth = 0;\n window.addEventListener('dragenter', (e) => {\n if (!e.dataTransfer?.types.includes('Files')) return;\n dragDepth++;\n document.body.classList.add('dragging-file');\n });\n window.addEventListener('dragover', (e) => {\n if (e.dataTransfer?.types.includes('Files')) e.preventDefault();\n });\n window.addEventListener('dragleave', () => {\n if (--dragDepth <= 0) {\n dragDepth = 0;\n document.body.classList.remove('dragging-file');\n }\n });\n window.addEventListener('drop', (e) => {\n if (!e.dataTransfer?.files?.length) return;\n e.preventDefault();\n dragDepth = 0;\n document.body.classList.remove('dragging-file');\n // No collection named: UploadFilesAction resolves the open one itself and refuses\n // visibly when there isn't one. Reading it here only to hand it straight back was the\n // drop target knowing where files go, which is the action's business.\n engine.dispatch(new UploadFilesAction(e.dataTransfer.files));\n });\n}\n",
115
+ "// The open-source build's entry point: a workbench with nothing added to it.\n//\n// Everything that used to live here is `createWorkbench` (./workbench.js), which takes\n// the openers and views a build wants to ship. A hosted or bespoke build imports that\n// instead of this file and passes its own — no fork, and the same registry the plugins\n// use.\n\nimport { createWorkbench } from './workbench.js';\n\ncreateWorkbench();\n"
116
+ ],
117
+ "mappings": "89CAAA,IAAM,GAAe,OAAO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GAAI,CAAC,EAAO,QACV,EAAE,GAOR,GAFA,EAAM,KAAK,CAAI,EAEX,CAAC,EACH,EAAY,GACZ,EAAU,EAAa,CAAQ,EAKnC,SAAS,CAAK,EAAG,CACf,GAAI,EACF,EAAY,CAAO,EACnB,EAAU,EAKZ,EAAY,GACZ,MAAO,EAAM,OAAS,EAAG,CACvB,IAAM,EAAQ,EACd,EAAQ,CAAC,EACT,EAAU,CAAK,EAEjB,EAAY,GAId,SAAS,CAAK,EAAG,CACf,GAAI,EACF,EAAY,CAAO,EAErB,EAAQ,CAAC,EACT,EAAY,GACZ,EAAU,EAGZ,MAAO,CAAC,WAAU,QAAO,OAAK,EC9GhC,SAAS,EAAW,CAAC,EAAc,CACjC,IAAM,EAAe,GAAY,CAAY,EACvC,EAAe,GAAY,CAAY,EAIvC,EAAoB,GAAc,WAAa,GAAiB,CAAY,EAClF,MAAO,IACF,KACA,KACA,CACL,EAGF,IAAM,GAAc,GAAY,EAIzB,IACL,KACA,SACA,WACA,aACA,YACA,SACA,QACA,QACA,SACA,UACA,YACA,WACA,WACA,SACA,UACA,UACA,MACA,MACA,MACA,MACA,MACA,MACA,QACA,OACA,WACA,cACA,MACA,OACA,MACA,MACA,cACA,UACA,MACA,MACA,MACA,KACA,OACA,MACA,KACA,QACA,KACA,MACA,QACA,QACA,QACA,OACA,OACA,MACA,KACA,OACA,OACA,QACA,KACA,KACA,QACA,SACA,QACA,UACA,OACA,OACA,QACA,KACA,OACA,QACA,SACA,OACA,OACA,SACA,SACA,SACA,UACA,UACA,SACA,WACA,UACA,UACA,OACA,QACA,UACA,WACA,OACA,YACA,SACA,SACA,MACA,SACA,MACA,SACA,MACA,UACA,YACA,YACA,QACA,SACA,SACA,UACA,SACA,YACA,UACA,UACA,YACA,UACA,YACA,WACA,UACA,WACA,QACA,YACA,YACA,SACA,UACE,GC/GJ,SAAS,EAAiB,CAAC,GAAK,UAAU,CAAC,EAAG,CAC5C,eAAe,IAAM,CACnB,GAAI,CAAC,GA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