@amalgm/live 0.2.81-main.47362174613 → 0.2.81-main.47425704837
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/dist/drive/drive.d.ts +38 -12
- package/dist/drive/drive.js +1 -1
- package/dist-cjs/drive/drive.js +1 -1
- package/package.json +4 -4
package/dist/drive/drive.d.ts
CHANGED
|
@@ -14,11 +14,40 @@ export interface Recorded {
|
|
|
14
14
|
readonly recorded: Unit;
|
|
15
15
|
readonly placed: readonly Receipt[];
|
|
16
16
|
}
|
|
17
|
-
export type DriveRefusal = 'nowhere' | 'not-directory' | 'directory' | 'not-empty';
|
|
17
|
+
export type DriveRefusal = 'nowhere' | 'not-directory' | 'directory' | 'not-empty' | 'exists' | 'cross-device';
|
|
18
18
|
export interface Refused {
|
|
19
19
|
readonly refused: DriveRefusal;
|
|
20
20
|
readonly placed: readonly Receipt[];
|
|
21
21
|
}
|
|
22
|
+
export type DriveOp = {
|
|
23
|
+
readonly op: 'read';
|
|
24
|
+
} | {
|
|
25
|
+
readonly op: 'create';
|
|
26
|
+
} | {
|
|
27
|
+
readonly op: 'overwrite';
|
|
28
|
+
} | {
|
|
29
|
+
readonly op: 'replace';
|
|
30
|
+
readonly by: 'file' | 'directory';
|
|
31
|
+
readonly within: string;
|
|
32
|
+
} | {
|
|
33
|
+
readonly op: 'remove';
|
|
34
|
+
readonly as: 'file' | 'directory';
|
|
35
|
+
} | {
|
|
36
|
+
readonly op: 'move';
|
|
37
|
+
readonly to: readonly string[];
|
|
38
|
+
} | {
|
|
39
|
+
readonly op: 'mode';
|
|
40
|
+
readonly mode: number;
|
|
41
|
+
} | {
|
|
42
|
+
readonly op: 'times';
|
|
43
|
+
readonly times: Times;
|
|
44
|
+
} | {
|
|
45
|
+
readonly op: 'owner';
|
|
46
|
+
readonly owner: KeptOwner;
|
|
47
|
+
};
|
|
48
|
+
declare const READ: {
|
|
49
|
+
readonly op: "read";
|
|
50
|
+
};
|
|
22
51
|
export declare class Drive {
|
|
23
52
|
private readonly ports;
|
|
24
53
|
private readonly placements;
|
|
@@ -27,19 +56,15 @@ export declare class Drive {
|
|
|
27
56
|
pathOf(file: DriveFile): Promise<readonly string[] | null>;
|
|
28
57
|
list(path: readonly string[]): Promise<Listing>;
|
|
29
58
|
look(path: readonly string[]): Promise<Looked>;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
59
|
+
act(path: readonly string[], op: typeof READ, file?: DriveFile | null): Promise<Touched>;
|
|
60
|
+
act(path: readonly string[], op: Extract<DriveOp, {
|
|
61
|
+
readonly op: 'create' | 'overwrite' | 'replace';
|
|
62
|
+
}>, file?: DriveFile | null): Promise<Touched | Refused | null>;
|
|
63
|
+
act(path: readonly string[], op: DriveOp, file?: DriveFile | null): Promise<Touched | Recorded | Refused | null>;
|
|
33
64
|
removable(path: readonly string[]): Promise<boolean>;
|
|
34
|
-
|
|
35
|
-
private refuses;
|
|
36
|
-
move(from: readonly string[], to: readonly string[]): Promise<Touched | Recorded | Refused | null>;
|
|
37
|
-
mode(path: readonly string[], mode: number): Promise<Touched | Recorded | Refused | null>;
|
|
38
|
-
times(path: readonly string[], times: Times): Promise<Touched | Recorded | Refused | null>;
|
|
39
|
-
keep(path: readonly string[], kept: KeptOwner): Promise<Touched | Recorded | Refused | null>;
|
|
40
|
-
empty(path: readonly string[], file?: DriveFile): Promise<Touched | Refused | null>;
|
|
65
|
+
private replaced;
|
|
41
66
|
private meets;
|
|
42
|
-
private
|
|
67
|
+
private unread;
|
|
43
68
|
private again;
|
|
44
69
|
private freed;
|
|
45
70
|
private own;
|
|
@@ -53,3 +78,4 @@ export declare class Drive {
|
|
|
53
78
|
private judged;
|
|
54
79
|
placing(): number;
|
|
55
80
|
}
|
|
81
|
+
export {};
|
package/dist/drive/drive.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var S=Object.defineProperty;var c=(o,t)=>S(o,"name",{value:t,configurable:!0});import{isRepositoryMetadataEntry as E}from"../detection/classify.js";import{isName as A,portableFileMode as D,portableMtime as I}from"../entities/rules.js";import{CONTAINERS as b}from"../entities/types.js";import{placedAtHome as x}from"../registration/home-layout.js";import{listing as C}from"./listing.js";import{Placements as T}from"./placements.js";import{CROSSES_ROOTS as U}from"./records.js";import{addressOnly as f,aloneInSlot as H,childAt as K,freeName as P,glance as O,outsideRepositories as j,pathOfFile as V,rootOf as F,where as _}from"./where.js";const q={op:"read"};class Z{static{c(this,"Drive")}ports;placements;constructor(t){this.ports=t,this.placements=new T(t)}where(t){return _(this.ports.roots,t)}pathOf(t){return V(this.ports.roots,t)}list(t){return C(this.ports.roots,t)}async look(t){const n=await this.judged(t),r=O(n.at);if(r!==null)return{look:r,placed:[]};const{where:s,placed:a}=await this.settle(t,n),i=O(s);if(i!==null)return{look:i,placed:a};throw new Error("placed, yet the shelf does not stand here")}async act(t,n,r){const s=await this.judgedFile(t,r);if(n.op==="read")return this.settle(t,s,void 0,r);const{roots:a,recorder:i,keeper:l}=this.ports;if(f(a,t,s.at)||n.op==="move"&&f(a,n.to,await this.where(n.to)))return null;switch(n.op){case"create":return this.replaced(t,s,async e=>p(e)??(y(e)===null?null:"exists"),r);case"overwrite":return this.replaced(t,s,async e=>w(e)??await this.meets(t,e,"file"),r);case"replace":return this.replaced(t,s,async e=>await this.meets(t,e,n.by)??(e.kind==="listed"&&e.root!==n.within?"cross-device":null),r);case"remove":return this.unread(t,s,r,async e=>w(e)??await this.meets(t,e,n.as),e=>this.leavable(e),async e=>(n.as==="file"||!M(await this.list(t)))&&i.remove(e.unit),!0);case"move":return this.unread(t,s,r,async e=>w(e)??await this.meets(n.to,await this.where(n.to),y(e),e.kind==="listed"?e.entity.uuid:null),e=>this.movable(e,n.to),async e=>(await i.free({root:e.destination.root,address:e.destination.address}),i.move(e.unit,e.destination)),!0);case"mode":return this.unread(t,s,r,async e=>w(e),e=>this.modable(e,n.mode),async e=>e.fileMode!==e.listed.mode&&!await i.mode(e.unit,e.fileMode)?!1:(await l.keep(e.unit,{mode:n.mode&4095},{...e.listed,mode:e.fileMode}),!0),!1);case"times":return this.unread(t,s,r,async e=>w(e),e=>this.keepable(e),async e=>{const{mtimeNs:u,atimeNs:d}=n.times,h=u===null?e.listed.mtime:I(e.listed.type,u);return h!==e.listed.mtime&&!await i.time(e.unit,h)?!1:(await l.keep(e.unit,{atimeNs:d},{...e.listed,mtime:h}),!0)},!1);case"owner":return this.unread(t,s,r,async e=>w(e),e=>this.keepable(e),async e=>(await l.keep(e.unit,n.owner,e.listed),!0),!1)}}async removable(t){return!f(this.ports.roots,t,await this.where(t))}async replaced(t,n,r,s){const a=await r(n.at);if(a!==null)return{refused:a,placed:[]};if(await this.freed(n.at),n.at.kind!=="absent")return this.settle(t,n,async u=>(await this.keepable(u))?.unit.uuid??null,s);const{root:i,address:l}=n.at,e=await this.act(t.slice(0,-1),q);return e.where.kind!=="shelf"?e:e.where.root!==i||e.where.address.length+1!==l.length||!e.where.address.every((u,d)=>u===l[d])?{where:{kind:"nowhere"},placed:e.placed}:{where:{kind:"shelf",root:i,address:l,entity:null},placed:e.placed}}async meets(t,n,r,s=null){const a=p(n);if(a!==null||r===null||n.kind==="listed"&&n.entity.uuid===s)return a;const i=y(n);return i!==null&&i!==r?r==="directory"?"not-directory":"directory":r==="directory"&&M(await this.list(t))?"not-empty":null}async unread(t,n,r,s,a,i,l){const e=[];let u=!1;for(let d=n,h=!1;;d=await this.judgedFile(t,r)){const k=await s(d.at);if(k!==null)return{refused:k,placed:e};const g="placing"in d.at?d.at.placing:[];if(h||g.length===0)return{where:d.at,placed:e};const m=u?null:await a(d.at);if(m!==null){const v=await this.placements.record(m.unit,()=>this.again(t,r,m,a,i),l);if(v===!0)return{recorded:m.unit,placed:e};u=v===!1;continue}const{receipts:N,complete:R}=await this.placements.place(g,d.seen);e.push(...N),h=R}}async again(t,n,r,s,a){const i=await s((await this.judgedFile(t,n)).at);return i!==null&&i.unit.uuid===r.unit.uuid&&a(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 n=t.placing.at(-1);if(n?.uuid!==t.entity.uuid)return null;const r=await F(this.ports.roots,t.root);return r===null||!await j(r.map,t.address)?null:{unit:n,root:r,entity:t.entity}}async leavable(t){const n=await this.own(t);return n!==null&&await H(n.root.map,n.entity)?n:null}async keepable(t){const n=await this.own(t);if(n===null)return null;const{type:r,fileMode:s,mtime:a,payloadVersion:i,version:l}=n.entity;return s===null||a===null||i===null?null:{...n,listed:{type:r,mode:s,mtime:a,payloadVersion:i,version:l}}}async modable(t,n){const r=await this.keepable(t),s=r===null?null:D(r.entity.type,n);return r===null||s===null?null:{...r,fileMode:s}}async movable(t,n){const r=await this.leavable(t);if(r===null||b.has(r.unit.type))return null;const s=await this.destination(r,n);return s===null?null:{...r,destination:s}}async destination({unit:t,root:n},r){const s=r.at(-1);if(s===void 0||!A(s)||E(s))return null;const a=await this.where(r.slice(0,-1));if(a.kind!=="shelf"&&a.kind!=="listed"||a.root!==n.uuid&&!U.has(t.type))return null;const i=await F(this.ports.roots,a.root),l=a.entity;if(i===null||l===null||!b.has(l.type)||a.kind==="shelf"&&i.shelf.names(a.address)===null)return null;const e=[...a.address,s],u=a.address.length===0?s:(await K(i.map,i.map.root().uuid,a.address[0]))?.name;return u===void 0||!await P(i.map,l.uuid,s,t.uuid)||i.shelf.has(e)||!await j(i.map,a.address)||i.uuid===this.ports.roots.home.uuid&&x(u,e.length>1)||f(this.ports.roots,r,{root:i.uuid,address:e})?null:{root:i.uuid,parentUUID:l.uuid,name:s,address:e}}async settle(t,n,r=async()=>null,s){const a=[];for(let i=n;;){const l="placing"in i.at?i.at.placing:[];if(l.length===0)return{where:i.at,placed:a};const{receipts:e,complete:u}=await this.placements.place(l,i.seen,await r(i.at));if(a.push(...e),i=await this.judgedFile(t,s),u)return{where:i.at,placed:a}}}async judgedFile(t,n){const r=await this.judged(t);if(!n)return r;const s=c(i=>(i.kind==="listed"||i.kind==="shelf")&&i.root===n.root&&i.entity?.uuid===n.uuid,"matches");if(s(r.at))return r;const a=await this.pathOf(n);if(a){const i=await this.judged(a);if(s(i.at))return i}return{seen:r.seen,at:{kind:"nowhere"}}}async judged(t){const n=this.placements.recorded();return{at:await this.where(t),seen:n}}placing(){return this.placements.count()}}function w(o){return o.kind==="absent"?"nowhere":p(o)}c(w,"unnamed");function p(o){return o.kind==="nowhere"?"nowhere":o.kind==="notdir"?"not-directory":null}c(p,"noFolder");function y(o){const t=o.kind==="listed"||o.kind==="door"?o.entry:null;return t===null?null:t.kind==="directory"?"directory":"file"}c(y,"listedKind");function M(o){return o.kind==="entries"&&o.entries.length>0}c(M,"shows");export{Z as Drive};
|
package/dist-cjs/drive/drive.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var q=Object.defineProperty;var h=(o,t)=>q(o,"name",{value:t,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.Drive=void 0;const F=require("../detection/classify.js"),f=require("../entities/rules.js"),j=require("../entities/types.js"),N=require("../registration/home-layout.js"),R=require("./listing.js"),S=require("./placements.js"),E=require("./records.js"),u=require("./where.js"),A={op:"read"};class D{static{h(this,"Drive")}ports;placements;constructor(t){this.ports=t,this.placements=new S.Placements(t)}where(t){return(0,u.where)(this.ports.roots,t)}pathOf(t){return(0,u.pathOfFile)(this.ports.roots,t)}list(t){return(0,R.listing)(this.ports.roots,t)}async look(t){const n=await this.judged(t),s=(0,u.glance)(n.at);if(s!==null)return{look:s,placed:[]};const{where:i,placed:a}=await this.settle(t,n),r=(0,u.glance)(i);if(r!==null)return{look:r,placed:a};throw new Error("placed, yet the shelf does not stand here")}async act(t,n,s){const i=await this.judgedFile(t,s);if(n.op==="read")return this.settle(t,i,void 0,s);const{roots:a,recorder:r,keeper:l}=this.ports;if((0,u.addressOnly)(a,t,i.at)||n.op==="move"&&(0,u.addressOnly)(a,n.to,await this.where(n.to)))return null;switch(n.op){case"create":return this.replaced(t,i,async e=>p(e)??(k(e)===null?null:"exists"),s);case"overwrite":return this.replaced(t,i,async e=>y(e)??await this.meets(t,e,"file"),s);case"replace":return this.replaced(t,i,async e=>await this.meets(t,e,n.by)??(e.kind==="listed"&&e.root!==n.within?"cross-device":null),s);case"remove":return this.unread(t,i,s,async e=>y(e)??await this.meets(t,e,n.as),e=>this.leavable(e),async e=>(n.as==="file"||!O(await this.list(t)))&&r.remove(e.unit),!0);case"move":return this.unread(t,i,s,async e=>y(e)??await this.meets(n.to,await this.where(n.to),k(e),e.kind==="listed"?e.entity.uuid:null),e=>this.movable(e,n.to),async e=>(await r.free({root:e.destination.root,address:e.destination.address}),r.move(e.unit,e.destination)),!0);case"mode":return this.unread(t,i,s,async e=>y(e),e=>this.modable(e,n.mode),async e=>e.fileMode!==e.listed.mode&&!await r.mode(e.unit,e.fileMode)?!1:(await l.keep(e.unit,{mode:n.mode&4095},{...e.listed,mode:e.fileMode}),!0),!1);case"times":return this.unread(t,i,s,async e=>y(e),e=>this.keepable(e),async e=>{const{mtimeNs:d,atimeNs:c}=n.times,w=d===null?e.listed.mtime:(0,f.portableMtime)(e.listed.type,d);return w!==e.listed.mtime&&!await r.time(e.unit,w)?!1:(await l.keep(e.unit,{atimeNs:c},{...e.listed,mtime:w}),!0)},!1);case"owner":return this.unread(t,i,s,async e=>y(e),e=>this.keepable(e),async e=>(await l.keep(e.unit,n.owner,e.listed),!0),!1)}}async removable(t){return!(0,u.addressOnly)(this.ports.roots,t,await this.where(t))}async replaced(t,n,s,i){const a=await s(n.at);if(a!==null)return{refused:a,placed:[]};if(await this.freed(n.at),n.at.kind!=="absent")return this.settle(t,n,async d=>(await this.keepable(d))?.unit.uuid??null,i);const{root:r,address:l}=n.at,e=await this.act(t.slice(0,-1),A);return e.where.kind!=="shelf"?e:e.where.root!==r||e.where.address.length+1!==l.length||!e.where.address.every((d,c)=>d===l[c])?{where:{kind:"nowhere"},placed:e.placed}:{where:{kind:"shelf",root:r,address:l,entity:null},placed:e.placed}}async meets(t,n,s,i=null){const a=p(n);if(a!==null||s===null||n.kind==="listed"&&n.entity.uuid===i)return a;const r=k(n);return r!==null&&r!==s?s==="directory"?"not-directory":"directory":s==="directory"&&O(await this.list(t))?"not-empty":null}async unread(t,n,s,i,a,r,l){const e=[];let d=!1;for(let c=n,w=!1;;c=await this.judgedFile(t,s)){const g=await i(c.at);if(g!==null)return{refused:g,placed:e};const v="placing"in c.at?c.at.placing:[];if(w||v.length===0)return{where:c.at,placed:e};const m=d?null:await a(c.at);if(m!==null){const _=await this.placements.record(m.unit,()=>this.again(t,s,m,a,r),l);if(_===!0)return{recorded:m.unit,placed:e};d=_===!1;continue}const{receipts:b,complete:M}=await this.placements.place(v,c.seen);e.push(...b),w=M}}async again(t,n,s,i,a){const r=await i((await this.judgedFile(t,n)).at);return r!==null&&r.unit.uuid===s.unit.uuid&&a(r)}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 n=t.placing.at(-1);if(n?.uuid!==t.entity.uuid)return null;const s=await(0,u.rootOf)(this.ports.roots,t.root);return s===null||!await(0,u.outsideRepositories)(s.map,t.address)?null:{unit:n,root:s,entity:t.entity}}async leavable(t){const n=await this.own(t);return n!==null&&await(0,u.aloneInSlot)(n.root.map,n.entity)?n:null}async keepable(t){const n=await this.own(t);if(n===null)return null;const{type:s,fileMode:i,mtime:a,payloadVersion:r,version:l}=n.entity;return i===null||a===null||r===null?null:{...n,listed:{type:s,mode:i,mtime:a,payloadVersion:r,version:l}}}async modable(t,n){const s=await this.keepable(t),i=s===null?null:(0,f.portableFileMode)(s.entity.type,n);return s===null||i===null?null:{...s,fileMode:i}}async movable(t,n){const s=await this.leavable(t);if(s===null||j.CONTAINERS.has(s.unit.type))return null;const i=await this.destination(s,n);return i===null?null:{...s,destination:i}}async destination({unit:t,root:n},s){const i=s.at(-1);if(i===void 0||!(0,f.isName)(i)||(0,F.isRepositoryMetadataEntry)(i))return null;const a=await this.where(s.slice(0,-1));if(a.kind!=="shelf"&&a.kind!=="listed"||a.root!==n.uuid&&!E.CROSSES_ROOTS.has(t.type))return null;const r=await(0,u.rootOf)(this.ports.roots,a.root),l=a.entity;if(r===null||l===null||!j.CONTAINERS.has(l.type)||a.kind==="shelf"&&r.shelf.names(a.address)===null)return null;const e=[...a.address,i],d=a.address.length===0?i:(await(0,u.childAt)(r.map,r.map.root().uuid,a.address[0]))?.name;return d===void 0||!await(0,u.freeName)(r.map,l.uuid,i,t.uuid)||r.shelf.has(e)||!await(0,u.outsideRepositories)(r.map,a.address)||r.uuid===this.ports.roots.home.uuid&&(0,N.placedAtHome)(d,e.length>1)||(0,u.addressOnly)(this.ports.roots,s,{root:r.uuid,address:e})?null:{root:r.uuid,parentUUID:l.uuid,name:i,address:e}}async settle(t,n,s=async()=>null,i){const a=[];for(let r=n;;){const l="placing"in r.at?r.at.placing:[];if(l.length===0)return{where:r.at,placed:a};const{receipts:e,complete:d}=await this.placements.place(l,r.seen,await s(r.at));if(a.push(...e),r=await this.judgedFile(t,i),d)return{where:r.at,placed:a}}}async judgedFile(t,n){const s=await this.judged(t);if(!n)return s;const i=h(r=>(r.kind==="listed"||r.kind==="shelf")&&r.root===n.root&&r.entity?.uuid===n.uuid,"matches");if(i(s.at))return s;const a=await this.pathOf(n);if(a){const r=await this.judged(a);if(i(r.at))return r}return{seen:s.seen,at:{kind:"nowhere"}}}async judged(t){const n=this.placements.recorded();return{at:await this.where(t),seen:n}}placing(){return this.placements.count()}}exports.Drive=D;function y(o){return o.kind==="absent"?"nowhere":p(o)}h(y,"unnamed");function p(o){return o.kind==="nowhere"?"nowhere":o.kind==="notdir"?"not-directory":null}h(p,"noFolder");function k(o){const t=o.kind==="listed"||o.kind==="door"?o.entry:null;return t===null?null:t.kind==="directory"?"directory":"file"}h(k,"listedKind");function O(o){return o.kind==="entries"&&o.entries.length>0}h(O,"shows");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amalgm/live",
|
|
3
|
-
"version": "0.2.81-main.
|
|
3
|
+
"version": "0.2.81-main.47425704837",
|
|
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",
|
|
@@ -133,11 +133,11 @@
|
|
|
133
133
|
"dependencies": {
|
|
134
134
|
"@amalgm/core": "0.5.1-main.46384328664"
|
|
135
135
|
},
|
|
136
|
-
"gitHead": "
|
|
136
|
+
"gitHead": "e9cebfe8539639252ffd5de2b05563a298ce0feb",
|
|
137
137
|
"amalgmSource": {
|
|
138
138
|
"repository": "amalgm-inc/amalgm-live",
|
|
139
139
|
"branch": "main",
|
|
140
|
-
"commit": "
|
|
141
|
-
"occurrence": "
|
|
140
|
+
"commit": "e9cebfe8539639252ffd5de2b05563a298ce0feb",
|
|
141
|
+
"occurrence": "47425704837"
|
|
142
142
|
}
|
|
143
143
|
}
|