@amalgm/live 0.2.81-preview.46154071576 → 0.2.81-preview.46345292204

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,28 @@
1
+ # Amalgm proprietary licence
2
+
3
+ Copyright © 2026 Amalgm. All rights reserved.
4
+
5
+ This package and every file in it ("the Software") belong to Amalgm. It is
6
+ not open source.
7
+
8
+ You may install and run the Software only as part of using Amalgm, and only as
9
+ the Amalgm Terms of Service allow. Those terms govern your use of the
10
+ Software; if you do not accept them, do not install or run it.
11
+
12
+ Unless Amalgm agrees otherwise in writing, you may not:
13
+
14
+ - copy, modify, translate or make works based on the Software;
15
+ - reverse engineer, decompile or disassemble it, or try to recover its source
16
+ code, except where the law allows this despite this restriction;
17
+ - sell, rent, lend, publish, redistribute or sublicense it, or bundle it into
18
+ another product or service;
19
+ - use it, or any part of it, to build a product or service that competes with
20
+ Amalgm;
21
+ - remove or change this notice or any other proprietary notice.
22
+
23
+ Open-source components the Software uses keep their own licences, which this
24
+ notice does not change. Their notices ship with them.
25
+
26
+ The Software is provided "as is", without any warranty, express or implied, to
27
+ the extent the law allows. Amalgm is not liable for any damage arising from it,
28
+ except where the law does not allow that liability to be excluded.
@@ -21,6 +21,7 @@ export interface MapPort {
21
21
  children(parentUUID: string): readonly MapEntity[];
22
22
  holders(parentUUID: string, name: string): readonly MapEntity[];
23
23
  placed(uuid: string): boolean;
24
+ homed(holderUUID: string): Promise<readonly string[]>;
24
25
  }
25
26
  export interface ShelfPort {
26
27
  has(address: readonly string[]): boolean;
@@ -1,7 +1,11 @@
1
1
  import type { DrivePorts, KeptOwner, Times, Unit } from './contracts.js';
2
2
  import { type Listing } from './listing.js';
3
3
  import { type Receipt } from './placements.js';
4
- import { type Where } from './where.js';
4
+ import { type Look, type Where } from './where.js';
5
+ export interface Looked {
6
+ readonly look: Look;
7
+ readonly placed: readonly Receipt[];
8
+ }
5
9
  export interface Touched {
6
10
  readonly where: Where;
7
11
  readonly placed: readonly Receipt[];
@@ -21,6 +25,7 @@ export declare class Drive {
21
25
  constructor(ports: DrivePorts);
22
26
  where(path: readonly string[]): Promise<Where>;
23
27
  list(path: readonly string[]): Promise<Listing>;
28
+ look(path: readonly string[]): Promise<Looked>;
24
29
  touch(path: readonly string[]): Promise<Touched>;
25
30
  change(path: readonly string[]): Promise<Touched | null>;
26
31
  vacate(path: readonly string[]): Promise<Touched | 'not-empty' | null>;
@@ -1 +1 @@
1
- var O=Object.defineProperty;var c=(o,t)=>O(o,"name",{value:t,configurable:!0});import{isRepositoryMetadataEntry as S}from"../detection/classify.js";import{isName as R,portableFileMode as A,portableMtime as E}from"../entities/rules.js";import{CONTAINERS as k}from"../entities/types.js";import{placedAtHome as I}from"../registration/home-layout.js";import{listing as C}from"./listing.js";import{Placements as D}from"./placements.js";import{CROSSES_ROOTS as F}from"./records.js";import{addressOnly as l,aloneInSlot as T,childAt as U,freeName as x,outsideRepositories as b,rootOf as v,where as H}from"./where.js";class L{static{c(this,"Drive")}ports;placements;constructor(t){this.ports=t,this.placements=new D(t)}where(t){return H(this.ports.roots,t)}list(t){return C(this.ports.roots,t)}async touch(t){return this.settle(t,await this.judged(t))}async change(t){const r=await this.judged(t);return l(this.ports.roots,t,r.at)?null:(await this.freed(r.at),this.settle(t,r))}async vacate(t){const r=await this.judged(t);return l(this.ports.roots,t,r.at)?null:f(await this.list(t))?"not-empty":(await this.freed(r.at),this.settle(t,r))}async removable(t){return!l(this.ports.roots,t,await this.where(t))}async remove(t,r){const i=await this.judged(t);if(l(this.ports.roots,t,i.at))return null;const e=c(async()=>r==="file"||!f(await this.list(t)),"empty");return this.act(t,i,n=>this.refuses(t,r,n),n=>this.leavable(n),async n=>await e()&&this.ports.recorder.remove(n.unit),!0)}async refuses(t,r,i){const e=h(i);return e!==null?e:i.kind==="listed"&&i.entry.kind==="directory"!=(r==="directory")?r==="directory"?"not-directory":"directory":r==="directory"&&f(await this.list(t))?"not-empty":null}async move(t,r){const i=await this.judged(t);return l(this.ports.roots,t,i.at)||l(this.ports.roots,r,await this.where(r))?null:this.act(t,i,async e=>this.meets(e,r,await this.where(r)),e=>this.movable(e,r),async e=>(await this.ports.recorder.free({root:e.destination.root,address:e.destination.address}),this.ports.recorder.move(e.unit,e.destination)),!0)}async mode(t,r){const i=await this.judged(t);return l(this.ports.roots,t,i.at)?null:this.act(t,i,async e=>h(e),e=>this.modable(e,r),async e=>e.fileMode!==e.listed.mode&&!await this.ports.recorder.mode(e.unit,e.fileMode)?!1:(await this.ports.keeper.keep(e.unit,{mode:r&4095},{...e.listed,mode:e.fileMode}),!0),!1)}async times(t,r){const i=await this.judged(t);return l(this.ports.roots,t,i.at)?null:this.act(t,i,async e=>h(e),e=>this.keepable(e),async e=>{const n=r.mtimeNs===null?e.listed.mtime:E(e.listed.type,r.mtimeNs);return n!==e.listed.mtime&&!await this.ports.recorder.time(e.unit,n)?!1:(await this.ports.keeper.keep(e.unit,{atimeNs:r.atimeNs},{...e.listed,mtime:n}),!0)},!1)}async keep(t,r){const i=await this.judged(t);return l(this.ports.roots,t,i.at)?null:this.act(t,i,async e=>h(e),e=>this.keepable(e),async e=>(await this.ports.keeper.keep(e.unit,r,e.listed),!0),!1)}async empty(t){const r=await this.judged(t);if(l(this.ports.roots,t,r.at))return null;const i=h(r.at);return i!==null?{refused:i,placed:[]}:this.settle(t,r,async e=>(await this.keepable(e))?.unit.uuid??null)}async meets(t,r,i){const e=h(t)??j(i);if(e!==null)return e;if(t.kind!=="listed"||i.kind!=="listed"||t.entity.uuid===i.entity.uuid)return null;const n=t.entry.kind==="directory";return n!==(i.entry.kind==="directory")?n?"not-directory":"directory":n&&f(await this.list(r))?"not-empty":null}async act(t,r,i,e,n,s){const a=[];let d=!1;for(let u=r,w=!1;;u=await this.judged(t)){const y=await i(u.at);if(y!==null)return{refused:y,placed:a};const m="placing"in u.at?u.at.placing:[];if(w||m.length===0)return{where:u.at,placed:a};const p=d?null:await e(u.at);if(p!==null){const g=await this.placements.record(p.unit,()=>this.again(t,p,e,n),s);if(g===!0)return{recorded:p.unit,placed:a};d=g===!1;continue}const{receipts:M,complete:N}=await this.placements.place(m,u.seen);a.push(...M),w=N}}async again(t,r,i,e){const n=await i(await this.where(t));return n!==null&&n.unit.uuid===r.unit.uuid&&e(n)}async freed(t){"root"in t&&await this.ports.recorder.free({root:t.root,address:t.address})}async own(t){if(t.kind!=="listed")return null;const r=t.placing.at(-1);if(r?.uuid!==t.entity.uuid)return null;const i=await v(this.ports.roots,t.root);return i===null||!await b(i.map,t.address)?null:{unit:r,root:i,entity:t.entity}}async leavable(t){const r=await this.own(t);return r!==null&&await T(r.root.map,r.entity)?r:null}async keepable(t){const r=await this.own(t);if(r===null)return null;const{type:i,fileMode:e,mtime:n,payloadVersion:s,version:a}=r.entity;return e===null||n===null||s===null?null:{...r,listed:{type:i,mode:e,mtime:n,payloadVersion:s,version:a}}}async modable(t,r){const i=await this.keepable(t),e=i===null?null:A(i.entity.type,r);return i===null||e===null?null:{...i,fileMode:e}}async movable(t,r){const i=await this.leavable(t);if(i===null||k.has(i.unit.type))return null;const e=await this.destination(i,r);return e===null?null:{...i,destination:e}}async destination({unit:t,root:r},i){const e=i.at(-1);if(e===void 0||!R(e)||S(e))return null;const n=await this.where(i.slice(0,-1));if(n.kind!=="shelf"&&n.kind!=="listed"||n.root!==r.uuid&&!F.has(t.type))return null;const s=await v(this.ports.roots,n.root),a=n.entity;if(s===null||a===null||!k.has(a.type)||n.kind==="shelf"&&s.shelf.names(n.address)===null)return null;const d=[...n.address,e],u=n.address.length===0?e:(await U(s.map,s.map.root().uuid,n.address[0]))?.name;return u===void 0||!await x(s.map,a.uuid,e,t.uuid)||s.shelf.has(d)||!await b(s.map,n.address)||s.uuid===this.ports.roots.home.uuid&&I(u,d.length>1)||l(this.ports.roots,i,{root:s.uuid,address:d})?null:{root:s.uuid,parentUUID:a.uuid,name:e,address:d}}async settle(t,r,i=async()=>null){const e=[];for(let n=r;;){const s="placing"in n.at?n.at.placing:[];if(s.length===0)return{where:n.at,placed:e};const{receipts:a,complete:d}=await this.placements.place(s,n.seen,await i(n.at));if(e.push(...a),n=await this.judged(t),d)return{where:n.at,placed:e}}}async judged(t){const r=this.placements.recorded();return{at:await this.where(t),seen:r}}placing(){return this.placements.count()}}function h(o){return o.kind==="absent"?"nowhere":j(o)}c(h,"unnamed");function j(o){return o.kind==="nowhere"?"nowhere":o.kind==="notdir"?"not-directory":null}c(j,"noFolder");function f(o){return o.kind==="entries"&&o.entries.length>0}c(f,"shows");export{L as Drive};
1
+ var S=Object.defineProperty;var c=(o,t)=>S(o,"name",{value:t,configurable:!0});import{isRepositoryMetadataEntry as R}from"../detection/classify.js";import{isName as E,portableFileMode as A,portableMtime as I}from"../entities/rules.js";import{CONTAINERS as k}from"../entities/types.js";import{placedAtHome as C}from"../registration/home-layout.js";import{listing as D}from"./listing.js";import{Placements as F}from"./placements.js";import{CROSSES_ROOTS as T}from"./records.js";import{addressOnly as l,aloneInSlot as U,childAt as x,freeName as H,glance as b,outsideRepositories as v,rootOf as j,where as P}from"./where.js";class Q{static{c(this,"Drive")}ports;placements;constructor(t){this.ports=t,this.placements=new F(t)}where(t){return P(this.ports.roots,t)}list(t){return D(this.ports.roots,t)}async look(t){const r=await this.judged(t),n=b(r.at);if(n!==null)return{look:n,placed:[]};const{where:e,placed:i}=await this.settle(t,r),s=b(e);if(s!==null)return{look:s,placed:i};throw new Error("placed, yet the shelf does not stand here")}async touch(t){return this.settle(t,await this.judged(t))}async change(t){const r=await this.judged(t);return l(this.ports.roots,t,r.at)?null:(await this.freed(r.at),this.settle(t,r))}async vacate(t){const r=await this.judged(t);return l(this.ports.roots,t,r.at)?null:f(await this.list(t))?"not-empty":(await this.freed(r.at),this.settle(t,r))}async removable(t){return!l(this.ports.roots,t,await this.where(t))}async remove(t,r){const n=await this.judged(t);if(l(this.ports.roots,t,n.at))return null;const e=c(async()=>r==="file"||!f(await this.list(t)),"empty");return this.act(t,n,i=>this.refuses(t,r,i),i=>this.leavable(i),async i=>await e()&&this.ports.recorder.remove(i.unit),!0)}async refuses(t,r,n){const e=h(n);return e!==null?e:n.kind==="listed"&&n.entry.kind==="directory"!=(r==="directory")?r==="directory"?"not-directory":"directory":r==="directory"&&f(await this.list(t))?"not-empty":null}async move(t,r){const n=await this.judged(t);return l(this.ports.roots,t,n.at)||l(this.ports.roots,r,await this.where(r))?null:this.act(t,n,async e=>this.meets(e,r,await this.where(r)),e=>this.movable(e,r),async e=>(await this.ports.recorder.free({root:e.destination.root,address:e.destination.address}),this.ports.recorder.move(e.unit,e.destination)),!0)}async mode(t,r){const n=await this.judged(t);return l(this.ports.roots,t,n.at)?null:this.act(t,n,async e=>h(e),e=>this.modable(e,r),async e=>e.fileMode!==e.listed.mode&&!await this.ports.recorder.mode(e.unit,e.fileMode)?!1:(await this.ports.keeper.keep(e.unit,{mode:r&4095},{...e.listed,mode:e.fileMode}),!0),!1)}async times(t,r){const n=await this.judged(t);return l(this.ports.roots,t,n.at)?null:this.act(t,n,async e=>h(e),e=>this.keepable(e),async e=>{const i=r.mtimeNs===null?e.listed.mtime:I(e.listed.type,r.mtimeNs);return i!==e.listed.mtime&&!await this.ports.recorder.time(e.unit,i)?!1:(await this.ports.keeper.keep(e.unit,{atimeNs:r.atimeNs},{...e.listed,mtime:i}),!0)},!1)}async keep(t,r){const n=await this.judged(t);return l(this.ports.roots,t,n.at)?null:this.act(t,n,async e=>h(e),e=>this.keepable(e),async e=>(await this.ports.keeper.keep(e.unit,r,e.listed),!0),!1)}async empty(t){const r=await this.judged(t);if(l(this.ports.roots,t,r.at))return null;const n=h(r.at);return n!==null?{refused:n,placed:[]}:this.settle(t,r,async e=>(await this.keepable(e))?.unit.uuid??null)}async meets(t,r,n){const e=h(t)??M(n);if(e!==null)return e;if(t.kind!=="listed"||n.kind!=="listed"||t.entity.uuid===n.entity.uuid)return null;const i=t.entry.kind==="directory";return i!==(n.entry.kind==="directory")?i?"not-directory":"directory":i&&f(await this.list(r))?"not-empty":null}async act(t,r,n,e,i,s){const a=[];let d=!1;for(let u=r,w=!1;;u=await this.judged(t)){const y=await n(u.at);if(y!==null)return{refused:y,placed:a};const m="placing"in u.at?u.at.placing:[];if(w||m.length===0)return{where:u.at,placed:a};const p=d?null:await e(u.at);if(p!==null){const g=await this.placements.record(p.unit,()=>this.again(t,p,e,i),s);if(g===!0)return{recorded:p.unit,placed:a};d=g===!1;continue}const{receipts:N,complete:O}=await this.placements.place(m,u.seen);a.push(...N),w=O}}async again(t,r,n,e){const i=await n(await this.where(t));return i!==null&&i.unit.uuid===r.unit.uuid&&e(i)}async freed(t){"root"in t&&await this.ports.recorder.free({root:t.root,address:t.address})}async own(t){if(t.kind!=="listed")return null;const r=t.placing.at(-1);if(r?.uuid!==t.entity.uuid)return null;const n=await j(this.ports.roots,t.root);return n===null||!await v(n.map,t.address)?null:{unit:r,root:n,entity:t.entity}}async leavable(t){const r=await this.own(t);return r!==null&&await U(r.root.map,r.entity)?r:null}async keepable(t){const r=await this.own(t);if(r===null)return null;const{type:n,fileMode:e,mtime:i,payloadVersion:s,version:a}=r.entity;return e===null||i===null||s===null?null:{...r,listed:{type:n,mode:e,mtime:i,payloadVersion:s,version:a}}}async modable(t,r){const n=await this.keepable(t),e=n===null?null:A(n.entity.type,r);return n===null||e===null?null:{...n,fileMode:e}}async movable(t,r){const n=await this.leavable(t);if(n===null||k.has(n.unit.type))return null;const e=await this.destination(n,r);return e===null?null:{...n,destination:e}}async destination({unit:t,root:r},n){const e=n.at(-1);if(e===void 0||!E(e)||R(e))return null;const i=await this.where(n.slice(0,-1));if(i.kind!=="shelf"&&i.kind!=="listed"||i.root!==r.uuid&&!T.has(t.type))return null;const s=await j(this.ports.roots,i.root),a=i.entity;if(s===null||a===null||!k.has(a.type)||i.kind==="shelf"&&s.shelf.names(i.address)===null)return null;const d=[...i.address,e],u=i.address.length===0?e:(await x(s.map,s.map.root().uuid,i.address[0]))?.name;return u===void 0||!await H(s.map,a.uuid,e,t.uuid)||s.shelf.has(d)||!await v(s.map,i.address)||s.uuid===this.ports.roots.home.uuid&&C(u,d.length>1)||l(this.ports.roots,n,{root:s.uuid,address:d})?null:{root:s.uuid,parentUUID:a.uuid,name:e,address:d}}async settle(t,r,n=async()=>null){const e=[];for(let i=r;;){const s="placing"in i.at?i.at.placing:[];if(s.length===0)return{where:i.at,placed:e};const{receipts:a,complete:d}=await this.placements.place(s,i.seen,await n(i.at));if(e.push(...a),i=await this.judged(t),d)return{where:i.at,placed:e}}}async judged(t){const r=this.placements.recorded();return{at:await this.where(t),seen:r}}placing(){return this.placements.count()}}function h(o){return o.kind==="absent"?"nowhere":M(o)}c(h,"unnamed");function M(o){return o.kind==="nowhere"?"nowhere":o.kind==="notdir"?"not-directory":null}c(M,"noFolder");function f(o){return o.kind==="entries"&&o.entries.length>0}c(f,"shows");export{Q as Drive};
@@ -0,0 +1,3 @@
1
+ import type { MapEntity, MapPort, ShelfPort } from './contracts.js';
2
+ import { type Where } from './where.js';
3
+ export declare function inGitDirectory(map: MapPort, shelf: ShelfPort, root: string, holder: MapEntity, git: readonly string[], rest: readonly string[]): Promise<Where | null>;
@@ -0,0 +1 @@
1
+ var v=Object.defineProperty;var h=(e,r)=>v(e,"name",{value:r,configurable:!0});import{addressIn as H,entryOf as p}from"./where.js";async function D(e,r,o,a,u,i){const d=await b(e,o,a),s=[...u,...i],n=d.filter(t=>k(i,t.parts)).sort((t,l)=>l.parts.length-t.parts.length)[0];if(n!==void 0){if(r.has([...u,...n.parts]))return null;const t=n.parts.length===i.length?p(n.entity,i.at(-1),"directory"):null;return{kind:"door",root:o,address:s,entry:t,placing:[n.unit]}}for(let t=i.length;t>=0;t-=1){const l=i.slice(0,t),f=d.filter(c=>c.parts.length>t&&k(c.parts,l));if(f.length===0)continue;const y=r.has([...u,...l]),g=f.map(c=>c.unit);if(t===i.length){const c=new Map;for(const w of f)c.set(w.parts[t],p(a,w.parts[t],"directory"));const m=[...c.values()];return y?{kind:"shelf",root:o,address:s,entity:null,homes:m}:{kind:"door",root:o,address:s,entry:p(a,i.at(-1),"directory"),placing:g,homes:m}}return y?null:t+1===i.length?{kind:"absent",root:o,address:s,placing:g}:{kind:"nowhere"}}return null}h(D,"inGitDirectory");async function b(e,r,o){const a=[];let u=[{entity:o,parts:[]}];for(;u.length>0;){const i=[];for(const d of u)for(const s of await e.homed(d.entity.uuid)){const n=e.get(s)??(await e.enter(s)?e.get(s):void 0);if(n?.type!=="repo.git"||n.status!=="active"||n.gitHome?.entity!==d.entity.uuid||n.gitHome.path==="")continue;const t=H(e,n);if(t===null)continue;const l=[...d.parts,...n.gitHome.path.split("/")];e.placed(s)||a.push({unit:{root:r,uuid:s,type:n.type,address:t},entity:n,parts:l}),i.push({entity:n,parts:l})}u=i}return a}h(b,"homedIn");function k(e,r){return r.length<=e.length&&r.every((o,a)=>e[a]===o)}h(k,"startsWith");export{D as inGitDirectory};
@@ -1 +1 @@
1
- var O=Object.defineProperty;var f=(t,s)=>O(t,"name",{value:s,configurable:!0});import{CONTAINERS as v}from"../entities/types.js";import{active as h,derivedNames as p,entryOf as w,gitEntry as E,rootOf as y,shows as k,unshown as S,where as b}from"./where.js";async function I(t,s){const a=f(e=>!S(t,[...s,e]),"shown"),n=await b(t,s);switch(n.kind){case"shelf":{const e=await y(t,n.root);if(e===null)return{kind:"nowhere"};const i=e.shelf.names(n.address);if(i===null)return e.shelf.has(n.address)?{kind:"notdir"}:{kind:"nowhere"};const o=i.filter(a),l={kind:"entries",root:n.root,address:n.address,shelf:o,entries:[],standing:[]};if(n.entity===null||!v.has(n.entity.type))return l;if(!await e.map.enter(n.entity.uuid))return{kind:"nowhere"};const u=new Set(i),c=p(h(e.map.children(n.entity.uuid))).filter(([r,d])=>k(r)!==null&&a(d)),g=c.filter(([r,d])=>!e.map.placed(r.uuid)&&!u.has(d)),N=c.filter(([r,d])=>e.map.placed(r.uuid)&&u.has(d)).map(([r,d])=>({name:d,uuid:r.uuid}));return{...l,entries:await m(t,g),standing:N}}case"listed":{if(n.entry.kind!=="directory")return{kind:"notdir"};const e=await y(t,n.root);if(e===null)return{kind:"nowhere"};if(!await e.map.enter(n.entry.uuid))return{kind:"nowhere"};const i=p(h(e.map.children(n.entry.uuid))).filter(([u,c])=>k(u)!==null&&a(c)),o=n.entry.type==="repo.git"?await E(e.map,n.entity):void 0;if(o===null)return{kind:"place-first",placing:n.placing};const l=[...await m(t,i),...o===void 0?[]:[o]];return{kind:"entries",root:n.root,address:n.address,shelf:[],entries:l,standing:[]}}case"door":return n.entry?.kind==="file"?{kind:"notdir"}:{kind:"place-first",placing:n.placing};case"absent":return{kind:"nowhere"};default:return n}}f(I,"listing");async function m(t,s){const a=[];for(const[n,e]of s){const i=n.type==="reference"&&n.target!==null&&await t.top(n.target)!==null;a.push(i?w(n,e,"directory"):w(n,e))}return a}f(m,"entries");export{I as listing};
1
+ var v=Object.defineProperty;var c=(t,a)=>v(t,"name",{value:a,configurable:!0});import{CONTAINERS as E}from"../entities/types.js";import{active as p,derivedNames as m,entryOf as w,gitEntry as S,rootOf as y,shows as k,unshown as b,where as x}from"./where.js";async function R(t,a){const r=c(n=>!b(t,[...a,n]),"shown"),e=await x(t,a);switch(e.kind){case"shelf":{const n=await y(t,e.root);if(n===null)return{kind:"nowhere"};const s=n.shelf.names(e.address);if(s===null)return n.shelf.has(e.address)?{kind:"notdir"}:{kind:"nowhere"};const o=s.filter(r),l=new Set(s),f=(e.homes??[]).filter(i=>!l.has(i.name)&&r(i.name)),u={kind:"entries",root:e.root,address:e.address,shelf:o,entries:f,standing:[]};if(e.entity===null||!E.has(e.entity.type))return u;if(!await n.map.enter(e.entity.uuid))return{kind:"nowhere"};const h=m(p(n.map.children(e.entity.uuid))).filter(([i,d])=>k(i)!==null&&r(d)),N=h.filter(([i,d])=>!n.map.placed(i.uuid)&&!l.has(d)),O=h.filter(([i,d])=>n.map.placed(i.uuid)&&l.has(d)).map(([i,d])=>({name:d,uuid:i.uuid}));return{...u,entries:await g(t,N),standing:O}}case"listed":{if(e.entry.kind!=="directory")return{kind:"notdir"};const n=await y(t,e.root);if(n===null)return{kind:"nowhere"};if(!await n.map.enter(e.entry.uuid))return{kind:"nowhere"};const s=m(p(n.map.children(e.entry.uuid))).filter(([f,u])=>k(f)!==null&&r(u)),o=e.entry.type==="repo.git"?await S(n.map,e.entity):void 0;if(o===null)return{kind:"place-first",placing:e.placing};const l=[...await g(t,s),...o===void 0?[]:[o]];return{kind:"entries",root:e.root,address:e.address,shelf:[],entries:l,standing:[]}}case"door":return e.entry?.kind==="file"?{kind:"notdir"}:e.homes===void 0?{kind:"place-first",placing:e.placing}:{kind:"entries",root:e.root,address:e.address,shelf:[],entries:e.homes.filter(n=>r(n.name)),standing:[]};case"absent":return{kind:"nowhere"};default:return e}}c(R,"listing");async function g(t,a){const r=[];for(const[e,n]of a){const s=e.type==="reference"&&e.target!==null&&await t.top(e.target)!==null;r.push(s?w(e,n,"directory"):w(e,n))}return r}c(g,"entries");export{R as listing};
@@ -13,11 +13,19 @@ export interface Entry {
13
13
  readonly payloadVersion: string | null;
14
14
  }
15
15
  export type EntryKind = 'directory' | 'file' | 'link';
16
+ export type Described = Entry & ({
17
+ readonly kind: 'directory';
18
+ } | {
19
+ readonly kind: 'file' | 'link';
20
+ readonly size: number;
21
+ });
22
+ export declare function described(entry: Entry): entry is Described;
16
23
  export type Where = {
17
24
  readonly kind: 'shelf';
18
25
  readonly root: string;
19
26
  readonly address: readonly string[];
20
27
  readonly entity: MapEntity | null;
28
+ readonly homes?: readonly Entry[];
21
29
  } | {
22
30
  readonly kind: 'listed';
23
31
  readonly root: string;
@@ -36,12 +44,21 @@ export type Where = {
36
44
  readonly address: readonly string[];
37
45
  readonly entry: Entry | null;
38
46
  readonly placing: readonly Unit[];
47
+ readonly homes?: readonly Entry[];
39
48
  } | {
40
49
  readonly kind: 'nowhere';
41
50
  } | {
42
51
  readonly kind: 'notdir';
43
52
  };
44
53
  export declare function where(roots: RootsPort, path: readonly string[]): Promise<Where>;
54
+ export type Look = Extract<Where, {
55
+ kind: 'shelf' | 'absent' | 'nowhere' | 'notdir';
56
+ }> | (Extract<Where, {
57
+ kind: 'listed' | 'door';
58
+ }> & {
59
+ readonly entry: Described;
60
+ });
61
+ export declare function glance(at: Where): Look | null;
45
62
  export declare function rootOf(roots: RootsPort, uuid: string): Promise<Root | null>;
46
63
  export declare function unshown(roots: RootsPort, path: readonly string[]): boolean;
47
64
  export declare function addressOnly(roots: RootsPort, path: readonly string[], at: Where | Place): boolean;
@@ -54,5 +71,6 @@ export declare function derivedNames(children: readonly MapEntity[]): [MapEntity
54
71
  export declare function entryOf(entity: MapEntity, name: string, kind?: EntryKind): Entry;
55
72
  export declare function gitEntry(map: MapPort, repository: MapEntity): Promise<Entry | null>;
56
73
  export declare function gitPointer(checkout: readonly string[], gitDirectory: readonly string[]): string;
74
+ export declare function addressIn(map: MapPort, entity: MapEntity): string[] | null;
57
75
  export declare function kindOf(type: MapEntity['type']): EntryKind;
58
76
  export declare function active(entities: readonly MapEntity[]): MapEntity[];
@@ -1,2 +1,2 @@
1
- var F=Object.defineProperty;var l=(e,n)=>F(e,"name",{value:n,configurable:!0});import{LOCAL_DIR_NAME as V}from"@amalgm/core/identity";import{isRepositoryMetadataEntry as D,REPOSITORY_METADATA as x}from"../detection/classify.js";import{utf8Length as N}from"../entities/bytes.js";import{collisionBases as I,fileAbsent as P,materializedSlotNames as $}from"../entities/rules.js";import{CONTAINERS as L}from"../entities/types.js";import{FILES_FOLDER as R}from"../registration/home-layout.js";async function ne(e,n){if(M(e,n))return{kind:"nowhere"};const t=[];let r=!1,i=e.home.uuid,s=e.home.shelf,o=e.home.map,u=o.root(),f=[],v=u.name,w=!1;const O=l(()=>w?!1:s.has(f)?!0:(w=!0,!1),"standing");for(let a=0;;a+=1){const E=a===n.length,h=l(d=>[...f,...n.slice(d)],"whole");let p=o.placed(u.uuid),m=O();if(u.type==="reference"&&u.target!==null&&p===m){const d=await e.top(u.target);d!==null&&(!p&&!r&&t.push(S(i,u,f)),i=d.uuid,s=d.shelf,o=null,u=d.entity,f=[],w=!1,p=d.placed,m=O())}if(p){if(E)return{kind:"shelf",root:i,address:f,entity:u};if(!m)return{kind:"shelf",root:i,address:h(a),entity:null}}else{if(m)return{kind:"shelf",root:i,address:h(a),entity:null};{const d=u.type==="repo.git";if((d||!r)&&t.push(S(i,u,f)),d&&(r=!0),E)return{kind:"listed",root:i,address:f,entity:u,entry:y(u,v),placing:t};if(!L.has(u.type))return{kind:"notdir"}}}if(o??=(await e.enter(i))?.map??null,o===null||!await o.enter(u.uuid))return{kind:"nowhere"};const g=n[a],A=await b(o,u.uuid,g);if(f=[...f,g],v=g,A===null){if(r&&u.type==="repo.git"&&D(g)){const d=await j(o,u);return a+1===n.length?{kind:"door",root:i,address:h(a+1),entry:d,placing:t}:d?.kind==="file"?{kind:"notdir"}:{kind:"door",root:i,address:h(a+1),entry:null,placing:t}}return t.length===0?{kind:"shelf",root:i,address:h(a+1),entity:null}:a+1===n.length?{kind:"absent",root:i,address:f,placing:t}:{kind:"nowhere"}}u=A}}l(ne,"where");async function te(e,n){return n===e.home.uuid?e.home:await e.enter(n)}l(te,"rootOf");function S(e,n,t){return{root:e,uuid:n.uuid,type:n.type,address:t}}l(S,"unitOf");function M(e,n){return n.some(t=>t.toLowerCase()===V)?!0:e.computer!==null&&n.length>=2&&n[0]===R&&n[1]===e.computer}l(M,"unshown");function re(e,n,t){return M(e,n)?!0:"root"in t?t.root===e.home.uuid?t.address[0]===R:t.address.length===0:!1}l(re,"addressOnly");async function b(e,n,t){if(!await e.enter(n))return null;const r=c(e.holders(n,t));if(r.length===1)return z(r[0]);if(r.length===0&&!H(e,n,t))return null;for(const[i,s]of T(c(e.children(n))))if(s===t)return z(i);return null}l(b,"childAt");function z(e){return P(e)?null:e}l(z,"shows");async function ie(e,n){const t=n.parentUUID;return t!==null&&await e.enter(t)&&C(e,t,n)}l(ie,"aloneInSlot");function C(e,n,t){const r=c(e.holders(n,t.name));return r.length===1&&r[0]?.uuid===t.uuid&&!H(e,n,t.name)}l(C,"soleHolder");async function ue(e,n,t,r){if(!await e.enter(n))return!1;const i=k(t),s=new Map(I(t).map(o=>[k(o),0]));for(const o of c(e.children(n))){if(o.uuid===r)continue;const u=k(o.name);if(u===i)return!1;const f=s.get(u);f!==void 0&&s.set(u,f+1)}return[...s.values()].every(o=>o<2)}l(ue,"freeName");function k(e){return e.normalize("NFC").toLowerCase()}l(k,"folded");function H(e,n,t){return I(t).some(r=>c(e.holders(n,r)).length>1)}l(H,"derivable");async function le(e,n){let t=e.root();for(const r of n){if(t.type==="repo.git")return!1;const i=await b(e,t.uuid,r);if(i===null)return!1;t=i}return t.type!=="repo.git"}l(le,"outsideRepositories");function T(e){const n=$(e);return e.map(t=>[t,n.get(t.uuid)??t.name])}l(T,"derivedNames");function y(e,n,t=J(e.type)){const r=e.type==="link"?e.target:null;return{name:n,uuid:e.uuid,type:e.type,kind:t,mode:e.fileMode,mtime:e.mtime,size:r!==null?N(r):e.size,target:r,version:e.version,payloadVersion:e.payloadVersion}}l(y,"entryOf");async function j(e,n){if(n.gitHome===null)return y(n,x,"directory");const t=await q(e,n),r=_(e,n);if(r===null||t===null)return null;const i=N(B(r,t));return{...y(n,x,"file"),size:i,payloadVersion:null}}l(j,"gitEntry");function B(e,n){let t=0;for(;t<e.length&&t<n.length&&e[t]===n[t];)t+=1;return`gitdir: ${[...e.slice(t).map(()=>".."),...n.slice(t)].join("/")}
2
- `}l(B,"gitPointer");const Y=8;async function q(e,n){const t=[];let r=n;for(let s=0;r.gitHome!==null;s+=1){const{entity:o,path:u}=r.gitHome;if(s===Y||o===null)return null;t.push(u===""?[]:u.split("/"));const f=e.get(o)??(await e.enter(o)?e.get(o):void 0);if(f===void 0||f.type!=="repo.git"||f.status!=="active")return null;r=f}const i=_(e,r);return i===null?null:[...i,x,...t.reverse().flat()]}l(q,"gitDirectoryIn");function _(e,n){const t=e.root().uuid,r=[],i=new Set;for(let s=n;s.uuid!==t;){const o=s.parentUUID===null?void 0:e.get(s.parentUUID);if(o===void 0||i.has(s.uuid)||s.status!=="active")return null;i.add(s.uuid);const u=G(e,s);if(u===null)return null;r.push(u),s=o}return r.reverse()}l(_,"addressIn");function G(e,n){const t=n.parentUUID;if(C(e,t,n))return n.name;for(const[r,i]of T(c(e.children(t))))if(r.uuid===n.uuid)return i;return null}l(G,"shownName");function J(e){if(L.has(e))return"directory";if(e==="file.text"||e==="file.binary")return"file";if(e==="link"||e==="reference")return"link";throw new Error(`a ${e} cannot stand in a folder`)}l(J,"kindOf");function c(e){return e.filter(n=>n.status==="active")}l(c,"active");export{c as active,re as addressOnly,ie as aloneInSlot,b as childAt,T as derivedNames,y as entryOf,ue as freeName,j as gitEntry,B as gitPointer,J as kindOf,le as outsideRepositories,te as rootOf,z as shows,M as unshown,ne as where};
1
+ var F=Object.defineProperty;var l=(e,n)=>F(e,"name",{value:n,configurable:!0});import{LOCAL_DIR_NAME as V}from"@amalgm/core/identity";import{isRepositoryMetadataEntry as N,REPOSITORY_METADATA as y}from"../detection/classify.js";import{inGitDirectory as P}from"./homes.js";import{utf8Length as I}from"../entities/bytes.js";import{collisionBases as L,fileAbsent as $,materializedSlotNames as j}from"../entities/rules.js";import{CONTAINERS as R}from"../entities/types.js";import{FILES_FOLDER as S}from"../registration/home-layout.js";function B(e){return e.kind==="directory"||e.size!==null}l(B,"described");async function re(e,n){if(z(e,n))return{kind:"nowhere"};const t=[];let r=!1,i=e.home.uuid,s=e.home.shelf,o=e.home.map,u=o.root(),d=[],v=u.name,w=!1;const O=l(()=>w?!1:s.has(d)?!0:(w=!0,!1),"standing");for(let a=0;;a+=1){const E=a===n.length,h=l(f=>[...d,...n.slice(f)],"whole");let m=o.placed(u.uuid),g=O();if(u.type==="reference"&&u.target!==null&&m===g){const f=await e.top(u.target);f!==null&&(!m&&!r&&t.push(b(i,u,d)),i=f.uuid,s=f.shelf,o=null,u=f.entity,d=[],w=!1,m=f.placed,g=O())}if(m){if(E)return{kind:"shelf",root:i,address:d,entity:u};if(!g)return{kind:"shelf",root:i,address:h(a),entity:null}}else{if(g)return{kind:"shelf",root:i,address:h(a),entity:null};{const f=u.type==="repo.git";if((f||!r)&&t.push(b(i,u,d)),f&&(r=!0),E)return{kind:"listed",root:i,address:d,entity:u,entry:k(u,v),placing:t};if(!R.has(u.type))return{kind:"notdir"}}}if(o??=(await e.enter(i))?.map??null,o===null||!await o.enter(u.uuid))return{kind:"nowhere"};const p=n[a],A=await C(o,u.uuid,p);if(d=[...d,p],v=p,A===null){if(r&&u.type==="repo.git"&&N(p)){const f=await G(o,u);return a+1===n.length?{kind:"door",root:i,address:h(a+1),entry:f,placing:t}:f?.kind==="file"?{kind:"notdir"}:{kind:"door",root:i,address:h(a+1),entry:null,placing:t}}return t.length===0?(u.type==="repo.git"&&u.gitHome===null&&N(p)&&s.has(d)?await P(o,s,i,u,d,n.slice(a+1)):null)??{kind:"shelf",root:i,address:h(a+1),entity:null}:a+1===n.length?{kind:"absent",root:i,address:d,placing:t}:{kind:"nowhere"}}u=A}}l(re,"where");function ie(e){return e.kind!=="listed"&&e.kind!=="door"?e:e.entry!==null&&B(e.entry)?{...e,entry:e.entry}:null}l(ie,"glance");async function ue(e,n){return n===e.home.uuid?e.home:await e.enter(n)}l(ue,"rootOf");function b(e,n,t){return{root:e,uuid:n.uuid,type:n.type,address:t}}l(b,"unitOf");function z(e,n){return n.some(t=>t.toLowerCase()===V)?!0:e.computer!==null&&n.length>=2&&n[0]===S&&n[1]===e.computer}l(z,"unshown");function le(e,n,t){return z(e,n)?!0:"root"in t?t.root===e.home.uuid?t.address[0]===S:t.address.length===0:!1}l(le,"addressOnly");async function C(e,n,t){if(!await e.enter(n))return null;const r=c(e.holders(n,t));if(r.length===1)return H(r[0]);if(r.length===0&&!T(e,n,t))return null;for(const[i,s]of _(c(e.children(n))))if(s===t)return H(i);return null}l(C,"childAt");function H(e){return $(e)?null:e}l(H,"shows");async function oe(e,n){const t=n.parentUUID;return t!==null&&await e.enter(t)&&M(e,t,n)}l(oe,"aloneInSlot");function M(e,n,t){const r=c(e.holders(n,t.name));return r.length===1&&r[0]?.uuid===t.uuid&&!T(e,n,t.name)}l(M,"soleHolder");async function se(e,n,t,r){if(!await e.enter(n))return!1;const i=x(t),s=new Map(L(t).map(o=>[x(o),0]));for(const o of c(e.children(n))){if(o.uuid===r)continue;const u=x(o.name);if(u===i)return!1;const d=s.get(u);d!==void 0&&s.set(u,d+1)}return[...s.values()].every(o=>o<2)}l(se,"freeName");function x(e){return e.normalize("NFC").toLowerCase()}l(x,"folded");function T(e,n,t){return L(t).some(r=>c(e.holders(n,r)).length>1)}l(T,"derivable");async function de(e,n){let t=e.root();for(const r of n){if(t.type==="repo.git")return!1;const i=await C(e,t.uuid,r);if(i===null)return!1;t=i}return t.type!=="repo.git"}l(de,"outsideRepositories");function _(e){const n=j(e);return e.map(t=>[t,n.get(t.uuid)??t.name])}l(_,"derivedNames");function k(e,n,t=K(e.type)){const r=e.type==="link"?e.target:null;return{name:n,uuid:e.uuid,type:e.type,kind:t,mode:e.fileMode,mtime:e.mtime,size:r!==null?I(r):e.size,target:r,version:e.version,payloadVersion:e.payloadVersion}}l(k,"entryOf");async function G(e,n){if(n.gitHome===null)return k(n,y,"directory");const t=await q(e,n),r=D(e,n);if(r===null||t===null)return null;const i=I(Y(r,t));return{...k(n,y,"file"),size:i,payloadVersion:null}}l(G,"gitEntry");function Y(e,n){let t=0;for(;t<e.length&&t<n.length&&e[t]===n[t];)t+=1;return`gitdir: ${[...e.slice(t).map(()=>".."),...n.slice(t)].join("/")}
2
+ `}l(Y,"gitPointer");async function q(e,n){const t=[],r=new Set([n.uuid]);let i=n;for(;i.gitHome!==null;){const{entity:o,path:u}=i.gitHome;if(o===null||r.has(o))return null;r.add(o),t.push(u===""?[]:u.split("/"));const d=e.get(o)??(await e.enter(o)?e.get(o):void 0);if(d===void 0||d.type!=="repo.git"||d.status!=="active")return null;i=d}const s=D(e,i);return s===null?null:[...s,y,...t.reverse().flat()]}l(q,"gitDirectoryIn");function D(e,n){const t=e.root().uuid,r=[],i=new Set;for(let s=n;s.uuid!==t;){const o=s.parentUUID===null?void 0:e.get(s.parentUUID);if(o===void 0||i.has(s.uuid)||s.status!=="active")return null;i.add(s.uuid);const u=J(e,s);if(u===null)return null;r.push(u),s=o}return r.reverse()}l(D,"addressIn");function J(e,n){const t=n.parentUUID;if(M(e,t,n))return n.name;for(const[r,i]of _(c(e.children(t))))if(r.uuid===n.uuid)return i;return null}l(J,"shownName");function K(e){if(R.has(e))return"directory";if(e==="file.text"||e==="file.binary")return"file";if(e==="link"||e==="reference")return"link";throw new Error(`a ${e} cannot stand in a folder`)}l(K,"kindOf");function c(e){return e.filter(n=>n.status==="active")}l(c,"active");export{c as active,D as addressIn,le as addressOnly,oe as aloneInSlot,C as childAt,_ as derivedNames,B as described,k as entryOf,se as freeName,G as gitEntry,Y as gitPointer,ie as glance,K as kindOf,de as outsideRepositories,ue as rootOf,H as shows,z as unshown,re as where};
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var c=(l,t)=>v(l,"name",{value:t,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.Drive=void 0;const N=require("../detection/classify.js"),w=require("../entities/rules.js"),b=require("../entities/types.js"),M=require("../registration/home-layout.js"),q=require("./listing.js"),R=require("./placements.js"),S=require("./records.js"),i=require("./where.js");class A{static{c(this,"Drive")}ports;placements;constructor(t){this.ports=t,this.placements=new R.Placements(t)}where(t){return(0,i.where)(this.ports.roots,t)}list(t){return(0,q.listing)(this.ports.roots,t)}async touch(t){return this.settle(t,await this.judged(t))}async change(t){const s=await this.judged(t);return(0,i.addressOnly)(this.ports.roots,t,s.at)?null:(await this.freed(s.at),this.settle(t,s))}async vacate(t){const s=await this.judged(t);return(0,i.addressOnly)(this.ports.roots,t,s.at)?null:p(await this.list(t))?"not-empty":(await this.freed(s.at),this.settle(t,s))}async removable(t){return!(0,i.addressOnly)(this.ports.roots,t,await this.where(t))}async remove(t,s){const r=await this.judged(t);if((0,i.addressOnly)(this.ports.roots,t,r.at))return null;const e=c(async()=>s==="file"||!p(await this.list(t)),"empty");return this.act(t,r,n=>this.refuses(t,s,n),n=>this.leavable(n),async n=>await e()&&this.ports.recorder.remove(n.unit),!0)}async refuses(t,s,r){const e=h(r);return e!==null?e:r.kind==="listed"&&r.entry.kind==="directory"!=(s==="directory")?s==="directory"?"not-directory":"directory":s==="directory"&&p(await this.list(t))?"not-empty":null}async move(t,s){const r=await this.judged(t);return(0,i.addressOnly)(this.ports.roots,t,r.at)||(0,i.addressOnly)(this.ports.roots,s,await this.where(s))?null:this.act(t,r,async e=>this.meets(e,s,await this.where(s)),e=>this.movable(e,s),async e=>(await this.ports.recorder.free({root:e.destination.root,address:e.destination.address}),this.ports.recorder.move(e.unit,e.destination)),!0)}async mode(t,s){const r=await this.judged(t);return(0,i.addressOnly)(this.ports.roots,t,r.at)?null:this.act(t,r,async e=>h(e),e=>this.modable(e,s),async e=>e.fileMode!==e.listed.mode&&!await this.ports.recorder.mode(e.unit,e.fileMode)?!1:(await this.ports.keeper.keep(e.unit,{mode:s&4095},{...e.listed,mode:e.fileMode}),!0),!1)}async times(t,s){const r=await this.judged(t);return(0,i.addressOnly)(this.ports.roots,t,r.at)?null:this.act(t,r,async e=>h(e),e=>this.keepable(e),async e=>{const n=s.mtimeNs===null?e.listed.mtime:(0,w.portableMtime)(e.listed.type,s.mtimeNs);return n!==e.listed.mtime&&!await this.ports.recorder.time(e.unit,n)?!1:(await this.ports.keeper.keep(e.unit,{atimeNs:s.atimeNs},{...e.listed,mtime:n}),!0)},!1)}async keep(t,s){const r=await this.judged(t);return(0,i.addressOnly)(this.ports.roots,t,r.at)?null:this.act(t,r,async e=>h(e),e=>this.keepable(e),async e=>(await this.ports.keeper.keep(e.unit,s,e.listed),!0),!1)}async empty(t){const s=await this.judged(t);if((0,i.addressOnly)(this.ports.roots,t,s.at))return null;const r=h(s.at);return r!==null?{refused:r,placed:[]}:this.settle(t,s,async e=>(await this.keepable(e))?.unit.uuid??null)}async meets(t,s,r){const e=h(t)??j(r);if(e!==null)return e;if(t.kind!=="listed"||r.kind!=="listed"||t.entity.uuid===r.entity.uuid)return null;const n=t.entry.kind==="directory";return n!==(r.entry.kind==="directory")?n?"not-directory":"directory":n&&p(await this.list(s))?"not-empty":null}async act(t,s,r,e,n,a){const o=[];let d=!1;for(let u=s,f=!1;;u=await this.judged(t)){const m=await r(u.at);if(m!==null)return{refused:m,placed:o};const g="placing"in u.at?u.at.placing:[];if(f||g.length===0)return{where:u.at,placed:o};const y=d?null:await e(u.at);if(y!==null){const k=await this.placements.record(y.unit,()=>this.again(t,y,e,n),a);if(k===!0)return{recorded:y.unit,placed:o};d=k===!1;continue}const{receipts:_,complete:O}=await this.placements.place(g,u.seen);o.push(..._),f=O}}async again(t,s,r,e){const n=await r(await this.where(t));return n!==null&&n.unit.uuid===s.unit.uuid&&e(n)}async freed(t){"root"in t&&await this.ports.recorder.free({root:t.root,address:t.address})}async own(t){if(t.kind!=="listed")return null;const s=t.placing.at(-1);if(s?.uuid!==t.entity.uuid)return null;const r=await(0,i.rootOf)(this.ports.roots,t.root);return r===null||!await(0,i.outsideRepositories)(r.map,t.address)?null:{unit:s,root:r,entity:t.entity}}async leavable(t){const s=await this.own(t);return s!==null&&await(0,i.aloneInSlot)(s.root.map,s.entity)?s:null}async keepable(t){const s=await this.own(t);if(s===null)return null;const{type:r,fileMode:e,mtime:n,payloadVersion:a,version:o}=s.entity;return e===null||n===null||a===null?null:{...s,listed:{type:r,mode:e,mtime:n,payloadVersion:a,version:o}}}async modable(t,s){const r=await this.keepable(t),e=r===null?null:(0,w.portableFileMode)(r.entity.type,s);return r===null||e===null?null:{...r,fileMode:e}}async movable(t,s){const r=await this.leavable(t);if(r===null||b.CONTAINERS.has(r.unit.type))return null;const e=await this.destination(r,s);return e===null?null:{...r,destination:e}}async destination({unit:t,root:s},r){const e=r.at(-1);if(e===void 0||!(0,w.isName)(e)||(0,N.isRepositoryMetadataEntry)(e))return null;const n=await this.where(r.slice(0,-1));if(n.kind!=="shelf"&&n.kind!=="listed"||n.root!==s.uuid&&!S.CROSSES_ROOTS.has(t.type))return null;const a=await(0,i.rootOf)(this.ports.roots,n.root),o=n.entity;if(a===null||o===null||!b.CONTAINERS.has(o.type)||n.kind==="shelf"&&a.shelf.names(n.address)===null)return null;const d=[...n.address,e],u=n.address.length===0?e:(await(0,i.childAt)(a.map,a.map.root().uuid,n.address[0]))?.name;return u===void 0||!await(0,i.freeName)(a.map,o.uuid,e,t.uuid)||a.shelf.has(d)||!await(0,i.outsideRepositories)(a.map,n.address)||a.uuid===this.ports.roots.home.uuid&&(0,M.placedAtHome)(u,d.length>1)||(0,i.addressOnly)(this.ports.roots,r,{root:a.uuid,address:d})?null:{root:a.uuid,parentUUID:o.uuid,name:e,address:d}}async settle(t,s,r=async()=>null){const e=[];for(let n=s;;){const a="placing"in n.at?n.at.placing:[];if(a.length===0)return{where:n.at,placed:e};const{receipts:o,complete:d}=await this.placements.place(a,n.seen,await r(n.at));if(e.push(...o),n=await this.judged(t),d)return{where:n.at,placed:e}}}async judged(t){const s=this.placements.recorded();return{at:await this.where(t),seen:s}}placing(){return this.placements.count()}}exports.Drive=A;function h(l){return l.kind==="absent"?"nowhere":j(l)}c(h,"unnamed");function j(l){return l.kind==="nowhere"?"nowhere":l.kind==="notdir"?"not-directory":null}c(j,"noFolder");function p(l){return l.kind==="entries"&&l.entries.length>0}c(p,"shows");
1
+ "use strict";var v=Object.defineProperty;var c=(l,t)=>v(l,"name",{value:t,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.Drive=void 0;const N=require("../detection/classify.js"),p=require("../entities/rules.js"),b=require("../entities/types.js"),M=require("../registration/home-layout.js"),q=require("./listing.js"),R=require("./placements.js"),S=require("./records.js"),a=require("./where.js");class E{static{c(this,"Drive")}ports;placements;constructor(t){this.ports=t,this.placements=new R.Placements(t)}where(t){return(0,a.where)(this.ports.roots,t)}list(t){return(0,q.listing)(this.ports.roots,t)}async look(t){const s=await this.judged(t),r=(0,a.glance)(s.at);if(r!==null)return{look:r,placed:[]};const{where:e,placed:n}=await this.settle(t,s),i=(0,a.glance)(e);if(i!==null)return{look:i,placed:n};throw new Error("placed, yet the shelf does not stand here")}async touch(t){return this.settle(t,await this.judged(t))}async change(t){const s=await this.judged(t);return(0,a.addressOnly)(this.ports.roots,t,s.at)?null:(await this.freed(s.at),this.settle(t,s))}async vacate(t){const s=await this.judged(t);return(0,a.addressOnly)(this.ports.roots,t,s.at)?null:w(await this.list(t))?"not-empty":(await this.freed(s.at),this.settle(t,s))}async removable(t){return!(0,a.addressOnly)(this.ports.roots,t,await this.where(t))}async remove(t,s){const r=await this.judged(t);if((0,a.addressOnly)(this.ports.roots,t,r.at))return null;const e=c(async()=>s==="file"||!w(await this.list(t)),"empty");return this.act(t,r,n=>this.refuses(t,s,n),n=>this.leavable(n),async n=>await e()&&this.ports.recorder.remove(n.unit),!0)}async refuses(t,s,r){const e=h(r);return e!==null?e:r.kind==="listed"&&r.entry.kind==="directory"!=(s==="directory")?s==="directory"?"not-directory":"directory":s==="directory"&&w(await this.list(t))?"not-empty":null}async move(t,s){const r=await this.judged(t);return(0,a.addressOnly)(this.ports.roots,t,r.at)||(0,a.addressOnly)(this.ports.roots,s,await this.where(s))?null:this.act(t,r,async e=>this.meets(e,s,await this.where(s)),e=>this.movable(e,s),async e=>(await this.ports.recorder.free({root:e.destination.root,address:e.destination.address}),this.ports.recorder.move(e.unit,e.destination)),!0)}async mode(t,s){const r=await this.judged(t);return(0,a.addressOnly)(this.ports.roots,t,r.at)?null:this.act(t,r,async e=>h(e),e=>this.modable(e,s),async e=>e.fileMode!==e.listed.mode&&!await this.ports.recorder.mode(e.unit,e.fileMode)?!1:(await this.ports.keeper.keep(e.unit,{mode:s&4095},{...e.listed,mode:e.fileMode}),!0),!1)}async times(t,s){const r=await this.judged(t);return(0,a.addressOnly)(this.ports.roots,t,r.at)?null:this.act(t,r,async e=>h(e),e=>this.keepable(e),async e=>{const n=s.mtimeNs===null?e.listed.mtime:(0,p.portableMtime)(e.listed.type,s.mtimeNs);return n!==e.listed.mtime&&!await this.ports.recorder.time(e.unit,n)?!1:(await this.ports.keeper.keep(e.unit,{atimeNs:s.atimeNs},{...e.listed,mtime:n}),!0)},!1)}async keep(t,s){const r=await this.judged(t);return(0,a.addressOnly)(this.ports.roots,t,r.at)?null:this.act(t,r,async e=>h(e),e=>this.keepable(e),async e=>(await this.ports.keeper.keep(e.unit,s,e.listed),!0),!1)}async empty(t){const s=await this.judged(t);if((0,a.addressOnly)(this.ports.roots,t,s.at))return null;const r=h(s.at);return r!==null?{refused:r,placed:[]}:this.settle(t,s,async e=>(await this.keepable(e))?.unit.uuid??null)}async meets(t,s,r){const e=h(t)??j(r);if(e!==null)return e;if(t.kind!=="listed"||r.kind!=="listed"||t.entity.uuid===r.entity.uuid)return null;const n=t.entry.kind==="directory";return n!==(r.entry.kind==="directory")?n?"not-directory":"directory":n&&w(await this.list(s))?"not-empty":null}async act(t,s,r,e,n,i){const o=[];let d=!1;for(let u=s,f=!1;;u=await this.judged(t)){const m=await r(u.at);if(m!==null)return{refused:m,placed:o};const g="placing"in u.at?u.at.placing:[];if(f||g.length===0)return{where:u.at,placed:o};const y=d?null:await e(u.at);if(y!==null){const k=await this.placements.record(y.unit,()=>this.again(t,y,e,n),i);if(k===!0)return{recorded:y.unit,placed:o};d=k===!1;continue}const{receipts:_,complete:O}=await this.placements.place(g,u.seen);o.push(..._),f=O}}async again(t,s,r,e){const n=await r(await this.where(t));return n!==null&&n.unit.uuid===s.unit.uuid&&e(n)}async freed(t){"root"in t&&await this.ports.recorder.free({root:t.root,address:t.address})}async own(t){if(t.kind!=="listed")return null;const s=t.placing.at(-1);if(s?.uuid!==t.entity.uuid)return null;const r=await(0,a.rootOf)(this.ports.roots,t.root);return r===null||!await(0,a.outsideRepositories)(r.map,t.address)?null:{unit:s,root:r,entity:t.entity}}async leavable(t){const s=await this.own(t);return s!==null&&await(0,a.aloneInSlot)(s.root.map,s.entity)?s:null}async keepable(t){const s=await this.own(t);if(s===null)return null;const{type:r,fileMode:e,mtime:n,payloadVersion:i,version:o}=s.entity;return e===null||n===null||i===null?null:{...s,listed:{type:r,mode:e,mtime:n,payloadVersion:i,version:o}}}async modable(t,s){const r=await this.keepable(t),e=r===null?null:(0,p.portableFileMode)(r.entity.type,s);return r===null||e===null?null:{...r,fileMode:e}}async movable(t,s){const r=await this.leavable(t);if(r===null||b.CONTAINERS.has(r.unit.type))return null;const e=await this.destination(r,s);return e===null?null:{...r,destination:e}}async destination({unit:t,root:s},r){const e=r.at(-1);if(e===void 0||!(0,p.isName)(e)||(0,N.isRepositoryMetadataEntry)(e))return null;const n=await this.where(r.slice(0,-1));if(n.kind!=="shelf"&&n.kind!=="listed"||n.root!==s.uuid&&!S.CROSSES_ROOTS.has(t.type))return null;const i=await(0,a.rootOf)(this.ports.roots,n.root),o=n.entity;if(i===null||o===null||!b.CONTAINERS.has(o.type)||n.kind==="shelf"&&i.shelf.names(n.address)===null)return null;const d=[...n.address,e],u=n.address.length===0?e:(await(0,a.childAt)(i.map,i.map.root().uuid,n.address[0]))?.name;return u===void 0||!await(0,a.freeName)(i.map,o.uuid,e,t.uuid)||i.shelf.has(d)||!await(0,a.outsideRepositories)(i.map,n.address)||i.uuid===this.ports.roots.home.uuid&&(0,M.placedAtHome)(u,d.length>1)||(0,a.addressOnly)(this.ports.roots,r,{root:i.uuid,address:d})?null:{root:i.uuid,parentUUID:o.uuid,name:e,address:d}}async settle(t,s,r=async()=>null){const e=[];for(let n=s;;){const i="placing"in n.at?n.at.placing:[];if(i.length===0)return{where:n.at,placed:e};const{receipts:o,complete:d}=await this.placements.place(i,n.seen,await r(n.at));if(e.push(...o),n=await this.judged(t),d)return{where:n.at,placed:e}}}async judged(t){const s=this.placements.recorded();return{at:await this.where(t),seen:s}}placing(){return this.placements.count()}}exports.Drive=E;function h(l){return l.kind==="absent"?"nowhere":j(l)}c(h,"unnamed");function j(l){return l.kind==="nowhere"?"nowhere":l.kind==="notdir"?"not-directory":null}c(j,"noFolder");function w(l){return l.kind==="entries"&&l.entries.length>0}c(w,"shows");
@@ -0,0 +1 @@
1
+ "use strict";var v=Object.defineProperty;var h=(e,r)=>v(e,"name",{value:r,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.inGitDirectory=O;const f=require("./where.js");async function O(e,r,o,u,c,i){const d=await _(e,o,u),s=[...c,...i],n=d.filter(t=>m(i,t.parts)).sort((t,a)=>a.parts.length-t.parts.length)[0];if(n!==void 0){if(r.has([...c,...n.parts]))return null;const t=n.parts.length===i.length?(0,f.entryOf)(n.entity,i.at(-1),"directory"):null;return{kind:"door",root:o,address:s,entry:t,placing:[n.unit]}}for(let t=i.length;t>=0;t-=1){const a=i.slice(0,t),y=d.filter(l=>l.parts.length>t&&m(l.parts,a));if(y.length===0)continue;const p=r.has([...c,...a]),g=y.map(l=>l.unit);if(t===i.length){const l=new Map;for(const k of y)l.set(k.parts[t],(0,f.entryOf)(u,k.parts[t],"directory"));const w=[...l.values()];return p?{kind:"shelf",root:o,address:s,entity:null,homes:w}:{kind:"door",root:o,address:s,entry:(0,f.entryOf)(u,i.at(-1),"directory"),placing:g,homes:w}}return p?null:t+1===i.length?{kind:"absent",root:o,address:s,placing:g}:{kind:"nowhere"}}return null}h(O,"inGitDirectory");async function _(e,r,o){const u=[];let c=[{entity:o,parts:[]}];for(;c.length>0;){const i=[];for(const d of c)for(const s of await e.homed(d.entity.uuid)){const n=e.get(s)??(await e.enter(s)?e.get(s):void 0);if(n?.type!=="repo.git"||n.status!=="active"||n.gitHome?.entity!==d.entity.uuid||n.gitHome.path==="")continue;const t=(0,f.addressIn)(e,n);if(t===null)continue;const a=[...d.parts,...n.gitHome.path.split("/")];e.placed(s)||u.push({unit:{root:r,uuid:s,type:n.type,address:t},entity:n,parts:a}),i.push({entity:n,parts:a})}c=i}return u}h(_,"homedIn");function m(e,r){return r.length<=e.length&&r.every((o,u)=>e[u]===o)}h(m,"startsWith");
@@ -1 +1 @@
1
- "use strict";var k=Object.defineProperty;var h=(i,a)=>k(i,"name",{value:a,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.listing=m;const g=require("../entities/types.js"),t=require("./where.js");async function m(i,a){const l=h(n=>!(0,t.unshown)(i,[...a,n]),"shown"),e=await(0,t.where)(i,a);switch(e.kind){case"shelf":{const n=await(0,t.rootOf)(i,e.root);if(n===null)return{kind:"nowhere"};const r=n.shelf.names(e.address);if(r===null)return n.shelf.has(e.address)?{kind:"notdir"}:{kind:"nowhere"};const o=r.filter(l),u={kind:"entries",root:e.root,address:e.address,shelf:o,entries:[],standing:[]};if(e.entity===null||!g.CONTAINERS.has(e.entity.type))return u;if(!await n.map.enter(e.entity.uuid))return{kind:"nowhere"};const c=new Set(r),f=(0,t.derivedNames)((0,t.active)(n.map.children(e.entity.uuid))).filter(([s,d])=>(0,t.shows)(s)!==null&&l(d)),w=f.filter(([s,d])=>!n.map.placed(s.uuid)&&!c.has(d)),y=f.filter(([s,d])=>n.map.placed(s.uuid)&&c.has(d)).map(([s,d])=>({name:d,uuid:s.uuid}));return{...u,entries:await p(i,w),standing:y}}case"listed":{if(e.entry.kind!=="directory")return{kind:"notdir"};const n=await(0,t.rootOf)(i,e.root);if(n===null)return{kind:"nowhere"};if(!await n.map.enter(e.entry.uuid))return{kind:"nowhere"};const r=(0,t.derivedNames)((0,t.active)(n.map.children(e.entry.uuid))).filter(([c,f])=>(0,t.shows)(c)!==null&&l(f)),o=e.entry.type==="repo.git"?await(0,t.gitEntry)(n.map,e.entity):void 0;if(o===null)return{kind:"place-first",placing:e.placing};const u=[...await p(i,r),...o===void 0?[]:[o]];return{kind:"entries",root:e.root,address:e.address,shelf:[],entries:u,standing:[]}}case"door":return e.entry?.kind==="file"?{kind:"notdir"}:{kind:"place-first",placing:e.placing};case"absent":return{kind:"nowhere"};default:return e}}h(m,"listing");async function p(i,a){const l=[];for(const[e,n]of a){const r=e.type==="reference"&&e.target!==null&&await i.top(e.target)!==null;l.push(r?(0,t.entryOf)(e,n,"directory"):(0,t.entryOf)(e,n))}return l}h(p,"entries");
1
+ "use strict";var k=Object.defineProperty;var f=(i,o)=>k(i,"name",{value:o,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.listing=O;const g=require("../entities/types.js"),t=require("./where.js");async function O(i,o){const s=f(n=>!(0,t.unshown)(i,[...o,n]),"shown"),e=await(0,t.where)(i,o);switch(e.kind){case"shelf":{const n=await(0,t.rootOf)(i,e.root);if(n===null)return{kind:"nowhere"};const d=n.shelf.names(e.address);if(d===null)return n.shelf.has(e.address)?{kind:"notdir"}:{kind:"nowhere"};const l=d.filter(s),u=new Set(d),h=(e.homes??[]).filter(r=>!u.has(r.name)&&s(r.name)),c={kind:"entries",root:e.root,address:e.address,shelf:l,entries:h,standing:[]};if(e.entity===null||!g.CONTAINERS.has(e.entity.type))return c;if(!await n.map.enter(e.entity.uuid))return{kind:"nowhere"};const p=(0,t.derivedNames)((0,t.active)(n.map.children(e.entity.uuid))).filter(([r,a])=>(0,t.shows)(r)!==null&&s(a)),y=p.filter(([r,a])=>!n.map.placed(r.uuid)&&!u.has(a)),m=p.filter(([r,a])=>n.map.placed(r.uuid)&&u.has(a)).map(([r,a])=>({name:a,uuid:r.uuid}));return{...c,entries:await w(i,y),standing:m}}case"listed":{if(e.entry.kind!=="directory")return{kind:"notdir"};const n=await(0,t.rootOf)(i,e.root);if(n===null)return{kind:"nowhere"};if(!await n.map.enter(e.entry.uuid))return{kind:"nowhere"};const d=(0,t.derivedNames)((0,t.active)(n.map.children(e.entry.uuid))).filter(([h,c])=>(0,t.shows)(h)!==null&&s(c)),l=e.entry.type==="repo.git"?await(0,t.gitEntry)(n.map,e.entity):void 0;if(l===null)return{kind:"place-first",placing:e.placing};const u=[...await w(i,d),...l===void 0?[]:[l]];return{kind:"entries",root:e.root,address:e.address,shelf:[],entries:u,standing:[]}}case"door":return e.entry?.kind==="file"?{kind:"notdir"}:e.homes===void 0?{kind:"place-first",placing:e.placing}:{kind:"entries",root:e.root,address:e.address,shelf:[],entries:e.homes.filter(n=>s(n.name)),standing:[]};case"absent":return{kind:"nowhere"};default:return e}}f(O,"listing");async function w(i,o){const s=[];for(const[e,n]of o){const d=e.type==="reference"&&e.target!==null&&await i.top(e.target)!==null;s.push(d?(0,t.entryOf)(e,n,"directory"):(0,t.entryOf)(e,n))}return s}f(w,"entries");
@@ -1,2 +1,2 @@
1
- "use strict";var H=Object.defineProperty;var l=(e,n)=>H(e,"name",{value:n,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.where=V,exports.rootOf=Y,exports.unshown=v,exports.addressOnly=B,exports.childAt=k,exports.shows=E,exports.aloneInSlot=$,exports.freeName=G,exports.outsideRepositories=J,exports.derivedNames=R,exports.entryOf=O,exports.gitEntry=P,exports.gitPointer=z,exports.kindOf=F,exports.active=c;const x=require("@amalgm/core/identity"),p=require("../detection/classify.js"),L=require("../entities/bytes.js"),y=require("../entities/rules.js"),M=require("../entities/types.js"),b=require("../registration/home-layout.js");async function V(e,n){if(v(e,n))return{kind:"nowhere"};const t=[];let r=!1,i=e.home.uuid,o=e.home.shelf,s=e.home.map,u=s.root(),d=[],I=u.name,_=!1;const N=l(()=>_?!1:o.has(d)?!0:(_=!0,!1),"standing");for(let a=0;;a+=1){const S=a===n.length,h=l(f=>[...d,...n.slice(f)],"whole");let g=s.placed(u.uuid),w=N();if(u.type==="reference"&&u.target!==null&&g===w){const f=await e.top(u.target);f!==null&&(!g&&!r&&t.push(j(i,u,d)),i=f.uuid,o=f.shelf,s=null,u=f.entity,d=[],_=!1,g=f.placed,w=N())}if(g){if(S)return{kind:"shelf",root:i,address:d,entity:u};if(!w)return{kind:"shelf",root:i,address:h(a),entity:null}}else{if(w)return{kind:"shelf",root:i,address:h(a),entity:null};{const f=u.type==="repo.git";if((f||!r)&&t.push(j(i,u,d)),f&&(r=!0),S)return{kind:"listed",root:i,address:d,entity:u,entry:O(u,I),placing:t};if(!M.CONTAINERS.has(u.type))return{kind:"notdir"}}}if(s??=(await e.enter(i))?.map??null,s===null||!await s.enter(u.uuid))return{kind:"nowhere"};const m=n[a],T=await k(s,u.uuid,m);if(d=[...d,m],I=m,T===null){if(r&&u.type==="repo.git"&&(0,p.isRepositoryMetadataEntry)(m)){const f=await P(s,u);return a+1===n.length?{kind:"door",root:i,address:h(a+1),entry:f,placing:t}:f?.kind==="file"?{kind:"notdir"}:{kind:"door",root:i,address:h(a+1),entry:null,placing:t}}return t.length===0?{kind:"shelf",root:i,address:h(a+1),entity:null}:a+1===n.length?{kind:"absent",root:i,address:d,placing:t}:{kind:"nowhere"}}u=T}}l(V,"where");async function Y(e,n){return n===e.home.uuid?e.home:await e.enter(n)}l(Y,"rootOf");function j(e,n,t){return{root:e,uuid:n.uuid,type:n.type,address:t}}l(j,"unitOf");function v(e,n){return n.some(t=>t.toLowerCase()===x.LOCAL_DIR_NAME)?!0:e.computer!==null&&n.length>=2&&n[0]===b.FILES_FOLDER&&n[1]===e.computer}l(v,"unshown");function B(e,n,t){return v(e,n)?!0:"root"in t?t.root===e.home.uuid?t.address[0]===b.FILES_FOLDER:t.address.length===0:!1}l(B,"addressOnly");async function k(e,n,t){if(!await e.enter(n))return null;const r=c(e.holders(n,t));if(r.length===1)return E(r[0]);if(r.length===0&&!C(e,n,t))return null;for(const[i,o]of R(c(e.children(n))))if(o===t)return E(i);return null}l(k,"childAt");function E(e){return(0,y.fileAbsent)(e)?null:e}l(E,"shows");async function $(e,n){const t=n.parentUUID;return t!==null&&await e.enter(t)&&q(e,t,n)}l($,"aloneInSlot");function q(e,n,t){const r=c(e.holders(n,t.name));return r.length===1&&r[0]?.uuid===t.uuid&&!C(e,n,t.name)}l(q,"soleHolder");async function G(e,n,t,r){if(!await e.enter(n))return!1;const i=A(t),o=new Map((0,y.collisionBases)(t).map(s=>[A(s),0]));for(const s of c(e.children(n))){if(s.uuid===r)continue;const u=A(s.name);if(u===i)return!1;const d=o.get(u);d!==void 0&&o.set(u,d+1)}return[...o.values()].every(s=>s<2)}l(G,"freeName");function A(e){return e.normalize("NFC").toLowerCase()}l(A,"folded");function C(e,n,t){return(0,y.collisionBases)(t).some(r=>c(e.holders(n,r)).length>1)}l(C,"derivable");async function J(e,n){let t=e.root();for(const r of n){if(t.type==="repo.git")return!1;const i=await k(e,t.uuid,r);if(i===null)return!1;t=i}return t.type!=="repo.git"}l(J,"outsideRepositories");function R(e){const n=(0,y.materializedSlotNames)(e);return e.map(t=>[t,n.get(t.uuid)??t.name])}l(R,"derivedNames");function O(e,n,t=F(e.type)){const r=e.type==="link"?e.target:null;return{name:n,uuid:e.uuid,type:e.type,kind:t,mode:e.fileMode,mtime:e.mtime,size:r!==null?(0,L.utf8Length)(r):e.size,target:r,version:e.version,payloadVersion:e.payloadVersion}}l(O,"entryOf");async function P(e,n){if(n.gitHome===null)return O(n,p.REPOSITORY_METADATA,"directory");const t=await Q(e,n),r=D(e,n);if(r===null||t===null)return null;const i=(0,L.utf8Length)(z(r,t));return{...O(n,p.REPOSITORY_METADATA,"file"),size:i,payloadVersion:null}}l(P,"gitEntry");function z(e,n){let t=0;for(;t<e.length&&t<n.length&&e[t]===n[t];)t+=1;return`gitdir: ${[...e.slice(t).map(()=>".."),...n.slice(t)].join("/")}
2
- `}l(z,"gitPointer");const K=8;async function Q(e,n){const t=[];let r=n;for(let o=0;r.gitHome!==null;o+=1){const{entity:s,path:u}=r.gitHome;if(o===K||s===null)return null;t.push(u===""?[]:u.split("/"));const d=e.get(s)??(await e.enter(s)?e.get(s):void 0);if(d===void 0||d.type!=="repo.git"||d.status!=="active")return null;r=d}const i=D(e,r);return i===null?null:[...i,p.REPOSITORY_METADATA,...t.reverse().flat()]}l(Q,"gitDirectoryIn");function D(e,n){const t=e.root().uuid,r=[],i=new Set;for(let o=n;o.uuid!==t;){const s=o.parentUUID===null?void 0:e.get(o.parentUUID);if(s===void 0||i.has(o.uuid)||o.status!=="active")return null;i.add(o.uuid);const u=U(e,o);if(u===null)return null;r.push(u),o=s}return r.reverse()}l(D,"addressIn");function U(e,n){const t=n.parentUUID;if(q(e,t,n))return n.name;for(const[r,i]of R(c(e.children(t))))if(r.uuid===n.uuid)return i;return null}l(U,"shownName");function F(e){if(M.CONTAINERS.has(e))return"directory";if(e==="file.text"||e==="file.binary")return"file";if(e==="link"||e==="reference")return"link";throw new Error(`a ${e} cannot stand in a folder`)}l(F,"kindOf");function c(e){return e.filter(n=>n.status==="active")}l(c,"active");
1
+ "use strict";var x=Object.defineProperty;var l=(e,n)=>x(e,"name",{value:n,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.described=q,exports.where=B,exports.glance=$,exports.rootOf=G,exports.unshown=O,exports.addressOnly=J,exports.childAt=v,exports.shows=E,exports.aloneInSlot=K,exports.freeName=Q,exports.outsideRepositories=U,exports.derivedNames=R,exports.entryOf=_,exports.gitEntry=P,exports.gitPointer=F,exports.addressIn=I,exports.kindOf=H,exports.active=a;const V=require("@amalgm/core/identity"),m=require("../detection/classify.js"),Y=require("./homes.js"),b=require("../entities/bytes.js"),p=require("../entities/rules.js"),M=require("../entities/types.js"),j=require("../registration/home-layout.js");function q(e){return e.kind==="directory"||e.size!==null}l(q,"described");async function B(e,n){if(O(e,n))return{kind:"nowhere"};const t=[];let r=!1,i=e.home.uuid,o=e.home.shelf,s=e.home.map,u=s.root(),d=[],N=u.name,k=!1;const S=l(()=>k?!1:o.has(d)?!0:(k=!0,!1),"standing");for(let c=0;;c+=1){const T=c===n.length,h=l(f=>[...d,...n.slice(f)],"whole");let w=s.placed(u.uuid),y=S();if(u.type==="reference"&&u.target!==null&&w===y){const f=await e.top(u.target);f!==null&&(!w&&!r&&t.push(z(i,u,d)),i=f.uuid,o=f.shelf,s=null,u=f.entity,d=[],k=!1,w=f.placed,y=S())}if(w){if(T)return{kind:"shelf",root:i,address:d,entity:u};if(!y)return{kind:"shelf",root:i,address:h(c),entity:null}}else{if(y)return{kind:"shelf",root:i,address:h(c),entity:null};{const f=u.type==="repo.git";if((f||!r)&&t.push(z(i,u,d)),f&&(r=!0),T)return{kind:"listed",root:i,address:d,entity:u,entry:_(u,N),placing:t};if(!M.CONTAINERS.has(u.type))return{kind:"notdir"}}}if(s??=(await e.enter(i))?.map??null,s===null||!await s.enter(u.uuid))return{kind:"nowhere"};const g=n[c],L=await v(s,u.uuid,g);if(d=[...d,g],N=g,L===null){if(r&&u.type==="repo.git"&&(0,m.isRepositoryMetadataEntry)(g)){const f=await P(s,u);return c+1===n.length?{kind:"door",root:i,address:h(c+1),entry:f,placing:t}:f?.kind==="file"?{kind:"notdir"}:{kind:"door",root:i,address:h(c+1),entry:null,placing:t}}return t.length===0?(u.type==="repo.git"&&u.gitHome===null&&(0,m.isRepositoryMetadataEntry)(g)&&o.has(d)?await(0,Y.inGitDirectory)(s,o,i,u,d,n.slice(c+1)):null)??{kind:"shelf",root:i,address:h(c+1),entity:null}:c+1===n.length?{kind:"absent",root:i,address:d,placing:t}:{kind:"nowhere"}}u=L}}l(B,"where");function $(e){return e.kind!=="listed"&&e.kind!=="door"?e:e.entry!==null&&q(e.entry)?{...e,entry:e.entry}:null}l($,"glance");async function G(e,n){return n===e.home.uuid?e.home:await e.enter(n)}l(G,"rootOf");function z(e,n,t){return{root:e,uuid:n.uuid,type:n.type,address:t}}l(z,"unitOf");function O(e,n){return n.some(t=>t.toLowerCase()===V.LOCAL_DIR_NAME)?!0:e.computer!==null&&n.length>=2&&n[0]===j.FILES_FOLDER&&n[1]===e.computer}l(O,"unshown");function J(e,n,t){return O(e,n)?!0:"root"in t?t.root===e.home.uuid?t.address[0]===j.FILES_FOLDER:t.address.length===0:!1}l(J,"addressOnly");async function v(e,n,t){if(!await e.enter(n))return null;const r=a(e.holders(n,t));if(r.length===1)return E(r[0]);if(r.length===0&&!D(e,n,t))return null;for(const[i,o]of R(a(e.children(n))))if(o===t)return E(i);return null}l(v,"childAt");function E(e){return(0,p.fileAbsent)(e)?null:e}l(E,"shows");async function K(e,n){const t=n.parentUUID;return t!==null&&await e.enter(t)&&C(e,t,n)}l(K,"aloneInSlot");function C(e,n,t){const r=a(e.holders(n,t.name));return r.length===1&&r[0]?.uuid===t.uuid&&!D(e,n,t.name)}l(C,"soleHolder");async function Q(e,n,t,r){if(!await e.enter(n))return!1;const i=A(t),o=new Map((0,p.collisionBases)(t).map(s=>[A(s),0]));for(const s of a(e.children(n))){if(s.uuid===r)continue;const u=A(s.name);if(u===i)return!1;const d=o.get(u);d!==void 0&&o.set(u,d+1)}return[...o.values()].every(s=>s<2)}l(Q,"freeName");function A(e){return e.normalize("NFC").toLowerCase()}l(A,"folded");function D(e,n,t){return(0,p.collisionBases)(t).some(r=>a(e.holders(n,r)).length>1)}l(D,"derivable");async function U(e,n){let t=e.root();for(const r of n){if(t.type==="repo.git")return!1;const i=await v(e,t.uuid,r);if(i===null)return!1;t=i}return t.type!=="repo.git"}l(U,"outsideRepositories");function R(e){const n=(0,p.materializedSlotNames)(e);return e.map(t=>[t,n.get(t.uuid)??t.name])}l(R,"derivedNames");function _(e,n,t=H(e.type)){const r=e.type==="link"?e.target:null;return{name:n,uuid:e.uuid,type:e.type,kind:t,mode:e.fileMode,mtime:e.mtime,size:r!==null?(0,b.utf8Length)(r):e.size,target:r,version:e.version,payloadVersion:e.payloadVersion}}l(_,"entryOf");async function P(e,n){if(n.gitHome===null)return _(n,m.REPOSITORY_METADATA,"directory");const t=await W(e,n),r=I(e,n);if(r===null||t===null)return null;const i=(0,b.utf8Length)(F(r,t));return{..._(n,m.REPOSITORY_METADATA,"file"),size:i,payloadVersion:null}}l(P,"gitEntry");function F(e,n){let t=0;for(;t<e.length&&t<n.length&&e[t]===n[t];)t+=1;return`gitdir: ${[...e.slice(t).map(()=>".."),...n.slice(t)].join("/")}
2
+ `}l(F,"gitPointer");async function W(e,n){const t=[],r=new Set([n.uuid]);let i=n;for(;i.gitHome!==null;){const{entity:s,path:u}=i.gitHome;if(s===null||r.has(s))return null;r.add(s),t.push(u===""?[]:u.split("/"));const d=e.get(s)??(await e.enter(s)?e.get(s):void 0);if(d===void 0||d.type!=="repo.git"||d.status!=="active")return null;i=d}const o=I(e,i);return o===null?null:[...o,m.REPOSITORY_METADATA,...t.reverse().flat()]}l(W,"gitDirectoryIn");function I(e,n){const t=e.root().uuid,r=[],i=new Set;for(let o=n;o.uuid!==t;){const s=o.parentUUID===null?void 0:e.get(o.parentUUID);if(s===void 0||i.has(o.uuid)||o.status!=="active")return null;i.add(o.uuid);const u=X(e,o);if(u===null)return null;r.push(u),o=s}return r.reverse()}l(I,"addressIn");function X(e,n){const t=n.parentUUID;if(C(e,t,n))return n.name;for(const[r,i]of R(a(e.children(t))))if(r.uuid===n.uuid)return i;return null}l(X,"shownName");function H(e){if(M.CONTAINERS.has(e))return"directory";if(e==="file.text"||e==="file.binary")return"file";if(e==="link"||e==="reference")return"link";throw new Error(`a ${e} cannot stand in a folder`)}l(H,"kindOf");function a(e){return e.filter(n=>n.status==="active")}l(a,"active");
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@amalgm/live",
3
- "version": "0.2.81-preview.46154071576",
3
+ "version": "0.2.81-preview.46345292204",
4
4
  "description": "Portable realtime SDK for Amalgm — wire contracts, mutation discipline, and delivery state machines behind host-injected adapters.",
5
5
  "type": "module",
6
6
  "main": "./dist-cjs/index.js",
7
7
  "types": "./dist/index.d.ts",
8
- "license": "UNLICENSED",
8
+ "license": "SEE LICENSE IN LICENSE.md",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https://github.com/amalgm-inc/amalgm-live.git"
@@ -131,13 +131,13 @@
131
131
  "esbuild@0.28.2": true
132
132
  },
133
133
  "dependencies": {
134
- "@amalgm/core": "0.5.1-preview.46146790288"
134
+ "@amalgm/core": "0.5.1-preview.46154682692"
135
135
  },
136
- "gitHead": "4463595667422a27dec873c2ff32f1e71c704f8a",
136
+ "gitHead": "4b222c7a6c352ef1a0a7a62bcd0f58f8ab248464",
137
137
  "amalgmSource": {
138
138
  "repository": "amalgm-inc/amalgm-live",
139
139
  "branch": "preview",
140
- "commit": "4463595667422a27dec873c2ff32f1e71c704f8a",
141
- "occurrence": "46154071576"
140
+ "commit": "4b222c7a6c352ef1a0a7a62bcd0f58f8ab248464",
141
+ "occurrence": "46345292204"
142
142
  }
143
143
  }