@amalgm/live 0.2.81-preview.46147035832 → 0.2.81-preview.46155260343
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/git/plan.js +1 -1
- package/dist/git/play.js +4 -4
- package/dist/git/restore.js +2 -2
- package/dist/git/state.d.ts +1 -0
- package/dist/git/state.js +3 -3
- package/dist-cjs/git/plan.js +1 -1
- package/dist-cjs/git/play.js +4 -4
- package/dist-cjs/git/restore.js +2 -2
- package/dist-cjs/git/state.js +3 -3
- package/package.json +5 -5
package/dist/git/plan.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var O=Object.defineProperty;var n=(s,e)=>O(s,"name",{value:e,configurable:!0});import{fail as g,pass as $}from"../contracts/validate.js";import{gitBytesForm as F,gitOwnPath as M,isGitStoragePath as k}from"./state.js";import{compareGitText as B}from"./text.js";const r=n(s=>s.mode==="040000","isFolder"),P=n((s,e)=>s!==void 0&&s.mode===e.mode&&s.oid===e.oid,"same"),h=n((s,e)=>B(e.path,s.path),"deepestFirst");function T(s,e){if(s.format!==e.format)return g(`a ${s.format} repository cannot hold a ${e.format} state`);const m=F(e);if(m&&!F(s))return g("a state in byte form is reached from the state here read in byte form");const d=n(t=>!m&&k(t.path,e.home),"storage"),S=s.files.filter(t=>d(t)&&!r(t)).sort(h),i={...s,files:s.files.filter(t=>!d(t))},f=new Map(e.files.map(t=>[t.path,t])),v=new Set(i.files.filter(t=>f.has(t.path)&&r(f.get(t.path))!==r(t)).map(t=>t.path)),A=n(t=>{for(let a=t.length;a>0;a=t.lastIndexOf("/",a-1))if(v.has(t.slice(0,a)))return!0;return!1},"clashed"),u=[],p=[],x=new Map;for(const t of i.files)A(t.path)?u.push(t):f.has(t.path)?x.set(t.path,t):p.push(t);const l=e.files.filter(t=>!P(x.get(t.path),t)),w=n(t=>M(t.path)==="HEAD","isHead"),G=[...l.filter(r),...l.filter(t=>!r(t)&&!w(t)),...l.filter(w)],y=n(t=>t.index?.meaning??null,"meaning"),c=[];if(y(i)!==y(e)){const t=new Map(i.index?.files.map(o=>[o.path,o])),a=new Set(e.index?.files.map(o=>o.path));for(const o of e.index?.files??[])P(t.get(o.path),o)||c.push(o);const b=n(o=>+(M(o.path)==="index"),"last");c.sort((o,H)=>b(o)-b(H)),p.push(...i.index?.files.filter(o=>!a.has(o.path))??[])}return $({drop:S,clear:u.sort(h),writes:G,index:c,removals:p.sort(h)})}n(T,"gitApplyPlan");export{T as gitApplyPlan};
|
|
1
|
+
var O=Object.defineProperty;var n=(s,e)=>O(s,"name",{value:e,configurable:!0});import{fail as g,pass as $}from"../contracts/validate.js";import{gitBytesForm as F,gitOwnPath as M,isGitStoragePath as k}from"./state.js";import{compareGitText as B}from"./text.js";const r=n(s=>s.mode==="040000","isFolder"),P=n((s,e)=>s!==void 0&&s.mode===e.mode&&s.oid===e.oid,"same"),h=n((s,e)=>B(e.path,s.path),"deepestFirst");function T(s,e){if(s.format!==e.format)return g(`a ${s.format} repository cannot hold a ${e.format} state`);const m=F(e);if(m&&!F(s))return g("a state in byte form is reached only from the state here read in byte form");const d=n(t=>!m&&k(t.path,e.home),"storage"),S=s.files.filter(t=>d(t)&&!r(t)).sort(h),i={...s,files:s.files.filter(t=>!d(t))},f=new Map(e.files.map(t=>[t.path,t])),v=new Set(i.files.filter(t=>f.has(t.path)&&r(f.get(t.path))!==r(t)).map(t=>t.path)),A=n(t=>{for(let a=t.length;a>0;a=t.lastIndexOf("/",a-1))if(v.has(t.slice(0,a)))return!0;return!1},"clashed"),u=[],p=[],x=new Map;for(const t of i.files)A(t.path)?u.push(t):f.has(t.path)?x.set(t.path,t):p.push(t);const l=e.files.filter(t=>!P(x.get(t.path),t)),w=n(t=>M(t.path)==="HEAD","isHead"),G=[...l.filter(r),...l.filter(t=>!r(t)&&!w(t)),...l.filter(w)],y=n(t=>t.index?.meaning??null,"meaning"),c=[];if(y(i)!==y(e)){const t=new Map(i.index?.files.map(o=>[o.path,o])),a=new Set(e.index?.files.map(o=>o.path));for(const o of e.index?.files??[])P(t.get(o.path),o)||c.push(o);const b=n(o=>+(M(o.path)==="index"),"last");c.sort((o,H)=>b(o)-b(H)),p.push(...i.index?.files.filter(o=>!a.has(o.path))??[])}return $({drop:S,clear:u.sort(h),writes:G,index:c,removals:p.sort(h)})}n(T,"gitApplyPlan");export{T as gitApplyPlan};
|
package/dist/git/play.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var se=Object.defineProperty;var
|
|
2
|
-
`)):(
|
|
3
|
-
`).at(-1);s+=`${
|
|
4
|
-
`}s===""?
|
|
1
|
+
var se=Object.defineProperty;var f=(t,i)=>se(t,"name",{value:i,configurable:!0});import{utf8Decode as ie,utf8Encode as ae}from"../entities/bytes.js";import{GIT_ALTERNATES_PATH as re}from"./alternates.js";import{gitBlobId as Y}from"./artifact.js";import{gitChainReflog as fe,gitDropPackedRefs as ce,gitLooseRef as le,gitPackedRefs as de,gitReflogPlay as me,gitReflogTop as Z}from"./refs.js";import{gitBytesForm as ue,gitSelfHeld as he,gitSharesGitDir as ge,gitSharesObjects as pe,gitTreeOf as we,isGitOid as ee}from"./state.js";import{compareGitText as _}from"./text.js";function ye(t){return t.facets.some(c=>c==="create"||c==="retype"||c==="content")&&t.result.status==="active"?t.result.transportVersion:null}f(ye,"gitOwnChange");function Pe(t){let i=[],c=!1;for(const u of t){if(u.result.type!=="repo.git"){i=[],c=!0;continue}const p=ye(u);p!==null&&i.push(p)}return{reached:i,ended:c}}f(Pe,"gitLineChanges");function Te({line:t,basis:i,record:c}){const u=f(l=>l.files.find(a=>a.path===re)?.oid??null,"borrowed"),p=f(l=>l.files.some(a=>a.path==="reftable"),"reftable");return t.format===c.format&&(i===null||i.format===c.format)&&!pe(t)&&!he(t.home)&&!ge(t.home)&&t.home?.entity===c.home?.entity&&t.home?.path===c.home?.path&&u(t)===u(c)&&![t,c,...i?[i]:[]].some(l=>p(l)||ue(l))}f(Te,"gitPlayable");const z="040000",B=f(t=>new Map(t.map(i=>[i.path,i])),"byPath"),F=f((t,i)=>t===void 0?i===void 0:i!==void 0&&t.mode===i.mode&&t.oid===i.oid,"same"),te=f(t=>{const i=[];for(let c=t.indexOf("/");c>0;c=t.indexOf("/",c+1))i.push(t.slice(0,c));return i},"parents");function ke(t,i,c){const u=new Set;for(const l of t.keys()){const a=te(l).find(b=>t.has(b)&&t.get(b).mode!==z);a!==void 0&&u.add(a)}const p=f(l=>u.has(l)||te(l).some(a=>u.has(a)),"clashed");if(u.size>0){for(const l of[...t.keys()])p(l)&&t.delete(l);for(const[l,a]of i)p(l)&&t.set(l,a)}return we(t.values(),c)}f(ke,"asTree");const E=["line","basis","record"],R=f(t=>t.mode!==z&&(t.path==="HEAD"||t.path.startsWith("refs/")),"isLooseRef"),ne=f(t=>R(t)||t.path==="packed-refs","isRefFile"),be=f(t=>t.startsWith("logs/"),"isReflogPath"),N="refs/stash",j="refs/heads/",V=`${j}amalgm`,xe=7,Ee=/^[0-9a-f]{7,}$/,q=f((t,i)=>t.startsWith(`${i}/`),"beneath");async function Ie(t,i,c,u){const p={format:t.record.format,home:t.record.home,files:[],index:null},l={line:t.line,basis:t.basis??p,record:t.record},a={line:B(l.line.files),basis:B(l.basis.files),record:B(l.record.files)},b=new Map,A=f((e,n)=>{const o=ae(n),r=Y(o,u);return b.set(r,o),{path:e,mode:"100644",oid:r}},"make"),w=f(async e=>e?.oid?ie(b.get(e.oid)??await i(e.oid)):"","read"),H=new Map,$=f(e=>(H.has(e)||H.set(e,w(a[e].get("packed-refs")).then(de)),H.get(e)),"packedOf"),y=f(async(e,n)=>{const o=a[e].get(n);return o!==void 0&&R(o)?le(await w(o)):n==="HEAD"?null:(await $(e)).get(n)??null},"value"),P=f(e=>!F(a.basis.get(e),a.record.get(e)),"recordChanged"),m=new Map;for(const e of new Set([...a.line.keys(),...a.basis.keys(),...a.record.keys()])){const n=P(e)?a.record.get(e):a.line.get(e);n!==void 0&&m.set(e,n)}const T=new Set;for(const e of new Set(E.flatMap(n=>[...a[n].keys()]))){const[n,o,r]=E.map(s=>a[s].get(e));if(!(F(n,o)&&F(o,r)))if(e==="packed-refs")for(const s of E)for(const d of(await $(s)).keys())T.add(d);else[n,o,r].some(s=>s!==void 0&&R(s))&&T.add(e)}const J=f(async e=>{const[n,o,r]=E.map(s=>a[s].get(e));return[n,o,r].some(s=>s?.mode===z)?w(n):me(await w(o),await w(r),await w(n))},"playLog"),x=`logs/${N}`;let S=null;P(x)&&(S=fe(await J(x)),S===""?m.delete(x):m.set(x,A(x,S)));const g=new Map,I=[];for(const e of[...T].sort(_)){const[n,o,r]=await Promise.all(E.map(d=>y(d,e)));let s=o!==r?r:n;if(e===N){if(S===null)continue;s=Z(S)}else e.startsWith(j)&&n!==null&&n!==o&&s!==n&&[n,r].every(d=>d===null||ee(t.record.format,d))&&(r===null||!await c.builtOn(r,n))&&(s=n,r!==null&&!await c.builtOn(n,r)&&I.push({name:e,basis:o,record:r}));s!==n&&g.set(e,s)}const K=[];if(I.length>0){const e=new Map;for(const o of new Set([...a.line.keys(),...(await $("line")).keys(),...g.keys()])){if(o!==V&&!q(o,V))continue;const r=g.has(o)?g.get(o):await y("line",o);r!==null&&e.set(o,r)}const n=f((o,r)=>(e.get(o)??r)===r&&![...e.keys()].some(s=>q(o,s)||q(s,o)),"free");for(const{name:o,basis:r,record:s}of I){const d=`${V}/${o.slice(j.length)}-`;let h=[...e.keys()].sort(_).find(k=>e.get(k)===r&&k.startsWith(d)&&Ee.test(k.slice(d.length)));for(let k=xe;h===void 0&&k<=s.length;k+=1)n(d+s.slice(0,k),s)&&(h=d+s.slice(0,k));h!==void 0&&(await y("line",h)!==s&&g.set(h,s),e.set(h,s),K.push({branch:h,from:o,commit:s}))}}for(const[e,n]of[...m])ne(n)&&m.delete(e);for(const e of l.line.files)ne(e)&&m.set(e.path,e);const M=new Set;for(const[e,n]of g)n!==null?m.set(e,A(e,`${n}
|
|
2
|
+
`)):(m.has(e)&&R(m.get(e))&&m.delete(e),M.add(e));const Q=a.line.get("packed-refs");if(M.size>0&&Q!==void 0){const e=await w(Q),n=ce(e,M);n!==e&&m.set("packed-refs",A("packed-refs",n))}const L=f(e=>g.has(e)?Promise.resolve(g.get(e)):y("line",e),"final"),v=f(async(e,n)=>e?.startsWith("ref: ")?n(e.slice(5)):e,"commitOf"),D=await v(await L("HEAD"),L),O=new Set;for(const e of E)for(const n of a[e].keys())be(n)&&n!==x&&O.add(n);for(const e of g.keys())e!==N&&O.add(`logs/${e}`);D!==await v(await y("line","HEAD"),e=>y("line",e))&&O.add("logs/HEAD");for(const e of[...O].sort(_)){const n=e.slice(5),o=n==="HEAD"?D:await L(n),r=P(e);if(!r&&(o===null||n!=="HEAD"&&!g.has(n)||!a.line.has(e)))continue;let s=r?await J(e):await w(a.line.get(e));const d=Z(s);if(o!==null&&d!==null&&d!==o&&ee(t.record.format,o)){const h=s.trimEnd().split(`
|
|
3
|
+
`).at(-1);s+=`${d} ${o}${h.slice(h.indexOf(" ",h.indexOf(" ")+1))}
|
|
4
|
+
`}s===""?m.delete(e):m.set(e,A(e,s))}const C=f(e=>y(e,"HEAD").then(n=>v(n,o=>y(e,o))),"headOf"),U=await C("record"),oe=t.record.index?.meaning!==t.basis?.index?.meaning||U!==(t.basis===null?null:await C("basis")),[W,G]=oe?[t.record.index,U]:[t.line.index,await C("line")];let X=W;if(W?.files.length===1&&G!==null&&D!==null&&G!==D){const e=await c.carryIndex(await i(W.files[0].oid),G,D);if(e!==null){const n=e.bytes,o=Y(n,u);b.set(o,n),X={meaning:e.meaning,files:[{path:"index",mode:"100644",oid:o}]}}}return{state:{format:t.record.format,home:t.record.home,files:ke(m,a.record,t.record.home),index:X},made:b,aside:K}}f(Ie,"gitPlayRecord");export{Pe as gitLineChanges,ye as gitOwnChange,Ie as gitPlayRecord,Te as gitPlayable};
|
package/dist/git/restore.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var I=Object.defineProperty;var
|
|
2
|
-
`)));for(const t of n.files)(p(t)?
|
|
1
|
+
var I=Object.defineProperty;var s=(o,n)=>I(o,"name",{value:n,configurable:!0});import{fail as f,pass as A}from"../contracts/validate.js";import{utf8Decode as B,utf8Encode as S}from"../entities/bytes.js";import{gitBlobId as W}from"./artifact.js";import{GIT_PACKED_REFS as l,gitOwnFile as j,gitOwnRef as c}from"./parts.js";import{gitDropPackedRefs as q,gitPackedRefs as m}from"./refs.js";import{checkGitState as C,gitBytesForm as H,gitSelfHeld as K,gitTreeOf as L}from"./state.js";const E=/^(rebase-merge|rebase-apply|sequencer)(\/|$)/,p=s(o=>o.mode==="040000","isFolder"),T=s(o=>c(o)||j(o),"restored");function Y(o,n,$,v){for(const t of[o,n]){if(H(t))return f("a repository in byte form cannot be restored");if(t.files.some(e=>e.path.startsWith("reftable/")))return f("a reftable repository cannot be restored");if(K(t.home))return f("a worktree of storage outside every folder cannot be restored")}if(o.format!==n.format)return f(`a ${o.format} repository cannot take a ${n.format} version`);const d=new Map,u=s((t,e)=>{const a=W(e,v);return d.set(a,e),{path:t,mode:"100644",oid:a}},"blob"),h=s(t=>t.files.find(e=>e.path===l),"packed"),k=s(t=>{const e=h(t);return e===void 0?null:B($(e.oid))},"packedText"),i=k(o),g=k(n),b=g===null?new Map:m(g),w=s((t,e)=>new Set([...t.files.filter(a=>!p(a)&&c(a.path)).map(a=>a.path),...[...e.keys()].filter(c)]),"ownRefs"),O=w(n,b),x=new Set([...w(o,i===null?new Map:m(i))].filter(t=>!O.has(t)).map(t=>`logs/${t}`)),r=new Map;for(const[t,e]of b)c(t)&&r.set(t,u(t,S(`${e}
|
|
2
|
+
`)));for(const t of n.files)(p(t)?E.test(t.path):T(t.path))&&r.set(t.path,t);if(i!==null){const t=q(i,new Set([...m(i).keys()].filter(c)));r.set(l,t===i?h(o):u(l,S(t)))}const y=s(t=>{const e=t.split("/");return e.slice(1).map((a,G)=>e.slice(0,G+1).join("/"))},"ancestors"),F=new Set([...r.keys()].flatMap(y)),_=s(t=>r.has(t.path)||!p(t)&&F.has(t.path)||y(t.path).some(e=>r.has(e)&&!p(r.get(e))),"inTheWay");for(const t of o.files)(p(t)?!E.test(t.path):t.path!==l&&!T(t.path)&&!x.has(t.path))&&!_(t)&&r.set(t.path,t);const R=L(r.values(),o.home),M={...o,files:R,index:n.index},P=C(M);if(!P.ok)return f(`the version cannot stand over this repository: ${P.error}`);const D=new Map(R.flatMap(t=>d.has(t.oid)?[[t.oid,d.get(t.oid)]]:[]));return A({state:M,blobs:D})}s(Y,"gitRestoreGoal");export{Y as gitRestoreGoal};
|
package/dist/git/state.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare const isGitIndexPath: (path: string) => boolean;
|
|
|
30
30
|
export declare const isGitConfigurationPath: (path: string) => boolean;
|
|
31
31
|
export declare function isGitStatePath(path: string, home: GitHome | null, bytes?: boolean): boolean;
|
|
32
32
|
export declare const gitBytesForm: (state: GitState) => boolean;
|
|
33
|
+
export declare function gitTreeOf(files: Iterable<GitFile>, home: GitHome | null): GitFile[];
|
|
33
34
|
export declare const isGitStoragePath: (path: string, home: GitHome | null) => boolean;
|
|
34
35
|
export declare const gitSharesObjects: (state: GitState) => boolean;
|
|
35
36
|
export declare const isGitNamingPath: (path: string) => boolean;
|
package/dist/git/state.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`).map(
|
|
3
|
-
${JSON.stringify({format:t.format,home:t.home&&[t.home.entity,t.home.path],files:t.files.map(
|
|
1
|
+
var _=Object.defineProperty;var i=(t,e)=>_(t,"name",{value:e,configurable:!0});import{isLocalOnlyPath as P}from"@amalgm/core/identity";import{failShape as $,isRecord as c,pass as u}from"../contracts/validate.js";import{utf8Decode as j,utf8Encode as D}from"../entities/bytes.js";import{UUID_PATTERN as H}from"../entities/types.js";import{GIT_ALTERNATES_PATH as I}from"./alternates.js";import{compareGitText as E}from"./text.js";const L=["040000","100644","100755","120000"],M={sha1:40,sha256:64},O=i((t,e)=>typeof e=="string"&&e.length===M[t]&&/^[0-9a-f]+$/.test(e),"isGitOid"),S=i(t=>O("sha256",t),"isDigest"),m=i(t=>t!==null&&t.entity===null,"gitSelfHeld"),k=i(t=>t!==null&&t.entity!==null&&t.path==="","gitSharesGitDir"),p=i(t=>t.replace(/^worktrees\/[^/]+\//,""),"gitOwnPath"),w=i(t=>t.split("/").some(e=>e.endsWith(".lock")),"isGitLockPath"),g=i(t=>(e=>e==="index"||/^sharedindex\.[0-9a-f]+$/.test(e))(p(t)),"isGitIndexPath"),z=i(t=>["config","config.worktree"].includes(p(t)),"isGitConfigurationPath"),G=["worktrees","modules"],N=["objects",...G],x=i((t,e)=>t===I||t!=="gitdir"&&!(e?G:N).some(n=>t===n||t.startsWith(`${n}/`)),"isOwnStatePath");function d(t,e,n=!1){if(k(e)||P(t)||w(t))return!1;if(!m(e))return x(t,n);const o=e.path;return t==="worktrees"||t===o?!0:t.startsWith(`${o}/`)?x(t.slice(o.length+1),n):x(t,n)&&!g(t)}i(d,"isGitStatePath");const T=i(t=>t.some(e=>c(e)&&e.path==="objects"&&e.mode==="040000"),"listsObjects"),K=i(t=>T(t.files),"gitBytesForm");function Q(t,e){const n=new Map;for(const o of t)n.set(o.path,o);for(const o of[...n.keys()])for(let r=o.indexOf("/");r>0;r=o.indexOf("/",r+1)){const a=o.slice(0,r);!n.has(a)&&d(a,e)&&n.set(a,{path:a,mode:"040000",oid:null})}return[...n.values()].sort((o,r)=>E(o.path,r.path))}i(Q,"gitTreeOf");const Y=i((t,e)=>d(t,e,!0)&&!d(t,e),"isGitStoragePath"),v=i(t=>!m(t.home)&&(t.home?.path.startsWith("worktrees/")??!1),"gitSharesObjects"),W=new Set(["AUTO_MERGE","BISECT_EXPECTED_REV","MERGE_AUTOSTASH","NOTES_MERGE_PARTIAL","NOTES_MERGE_REF"]),tt=i(t=>(e=>/^[A-Z_-]+_HEAD$/.test(e)||W.has(e)||/^rebase-(apply|merge)\/(autostash|orig-head)$/.test(e))(p(t)),"isGitNamingPath"),et=i((t,e)=>j(e).split(`
|
|
2
|
+
`).map(n=>n.split(/[\t ]/,1)[0]).filter(n=>O(t,n)),"gitNamedObjects"),y=i(t=>typeof t=="string"&&t.length>0&&!t.includes("\0")&&t.split("/").every(e=>e!==""&&e!=="."&&e!==".."),"isPath");function nt(t){const e=new Set;for(const n of[...t.files,...t.index?.files??[]])n.oid!==null&&e.add(n.oid);return e}i(nt,"gitBlobs");const F='{ format: "sha1", home: { entity: <uuid>, path: "worktrees/<name>" | "modules/<name>" | "" } | { entity: null, path: "worktrees/<name>" } | null, files: [{ path: "HEAD", mode: "100644", oid: <sha256> }], index: { meaning: <sha256>, files: [...] } | null }',A=i(t=>typeof t=="string"&&/^worktrees\/[^/]+$/.test(t),"isWorktreeHome"),U=i(t=>c(t)&&Object.keys(t).length===2&&(t.entity===null?y(t.path)&&A(t.path):typeof t.entity=="string"&&H.test(t.entity)&&t.entity===t.entity.toLowerCase()&&(t.path===""||y(t.path)&&(A(t.path)||t.path.startsWith("modules/")))),"isGitHome");function R(t,e,n,o,r){if(!Array.isArray(t))return"not a list";for(const[a,s]of t.entries()){if(c(s)&&typeof s.path=="string"&&w(s.path))return`${s.path} is a lock, a write in progress, never state`;if(!c(s)||Object.keys(s).length!==3||!y(s.path)||!o(s.path))return`entry ${a} is not one { path, mode, oid } this list owns`;if(a>0&&E(t[a-1].path,s.path)>=0)return"paths are not sorted and unique";if(!L.includes(s.mode)||(s.mode==="040000"?s.oid!==null:!S(s.oid)))return`${s.path} is not a folder without a blob or a file, executable or link naming one`;const h=s.path.slice(0,Math.max(0,s.path.lastIndexOf("/")));if(h!==""&&d(h,e,n)&&!r.has(h))return`${s.path} stands in no listed folder`;s.mode==="040000"&&r.add(s.path)}return t}i(R,"checkFiles");function it(t){const e=i(f=>$(F,f),"bad");if(!c(t)||Object.keys(t).length!==4)return e("the state is not { format, home, files, index }");const{format:n,index:o}=t;if(n!=="sha1"&&n!=="sha256")return e("format is not sha1 or sha256");if(t.home!==null&&!U(t.home))return e("home is not null or { entity, path } naming worktrees/, modules/ or, with an entity, nothing, with no entity only for worktrees/");const r=t.home&&{entity:t.home.entity,path:t.home.path},a=new Set,s=Array.isArray(t.files)&&T(t.files),h=R(t.files,r,s,f=>d(f,r,s)&&!g(f),a);if(typeof h=="string")return e(`files: ${h}`);if(o===null)return u({format:n,home:r,files:h,index:null});if(k(r))return e("a state that shares its owner's Git directory has an index");if(!c(o)||Object.keys(o).length!==2||!S(o.meaning))return e("index is not null or { meaning, files }");const l=R(o.files,r,s,f=>d(f,r)&&g(f),a);if(typeof l=="string")return e(`index files: ${l}`);const b=m(r)?`${r.path}/index`:"index";return!l.some(f=>f.path===b)||l.some(f=>f.mode!=="100644")?e("index files are not plain files including index"):u({format:n,home:r,files:h,index:{meaning:o.meaning,files:l}})}i(it,"checkGitState");function ot(t){const e=i(n=>n.map(o=>({path:o.path,mode:o.mode,oid:o.oid})),"files");return{format:t.format,home:t.home&&{entity:t.home.entity,path:t.home.path},files:e(t.files),index:t.index&&{meaning:t.index.meaning,files:e(t.index.files)}}}i(ot,"gitStateJson");const st=i((t,e)=>e(D(`amalgm.git-state.v3
|
|
3
|
+
${JSON.stringify({format:t.format,home:t.home&&[t.home.entity,t.home.path],files:t.files.map(n=>[n.path,n.mode,n.oid]),index:t.index?.meaning??null})}`)),"gitStateId");export{it as checkGitState,nt as gitBlobs,K as gitBytesForm,et as gitNamedObjects,p as gitOwnPath,m as gitSelfHeld,k as gitSharesGitDir,v as gitSharesObjects,st as gitStateId,ot as gitStateJson,Q as gitTreeOf,z as isGitConfigurationPath,U as isGitHome,g as isGitIndexPath,w as isGitLockPath,tt as isGitNamingPath,O as isGitOid,d as isGitStatePath,Y as isGitStoragePath};
|
package/dist-cjs/git/plan.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var q=Object.defineProperty;var
|
|
1
|
+
"use strict";var q=Object.defineProperty;var o=(e,s)=>q(e,"name",{value:s,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.gitApplyPlan=S;const h=require("../contracts/validate.js"),r=require("./state.js"),A=require("./text.js"),l=o(e=>e.mode==="040000","isFolder"),b=o((e,s)=>e!==void 0&&e.mode===s.mode&&e.oid===s.oid,"same"),m=o((e,s)=>(0,A.compareGitText)(s.path,e.path),"deepestFirst");function S(e,s){if(e.format!==s.format)return(0,h.fail)(`a ${e.format} repository cannot hold a ${s.format} state`);const u=(0,r.gitBytesForm)(s);if(u&&!(0,r.gitBytesForm)(e))return(0,h.fail)("a state in byte form is reached only from the state here read in byte form");const x=o(t=>!u&&(0,r.isGitStoragePath)(t.path,s.home),"storage"),j=e.files.filter(t=>x(t)&&!l(t)).sort(m),i={...e,files:e.files.filter(t=>!x(t))},c=new Map(s.files.map(t=>[t.path,t])),v=new Set(i.files.filter(t=>c.has(t.path)&&l(c.get(t.path))!==l(t)).map(t=>t.path)),F=o(t=>{for(let a=t.length;a>0;a=t.lastIndexOf("/",a-1))if(v.has(t.slice(0,a)))return!0;return!1},"clashed"),y=[],f=[],w=new Map;for(const t of i.files)F(t.path)?y.push(t):c.has(t.path)?w.set(t.path,t):f.push(t);const p=s.files.filter(t=>!b(w.get(t.path),t)),_=o(t=>(0,r.gitOwnPath)(t.path)==="HEAD","isHead"),M=[...p.filter(l),...p.filter(t=>!l(t)&&!_(t)),...p.filter(_)],g=o(t=>t.index?.meaning??null,"meaning"),d=[];if(g(i)!==g(s)){const t=new Map(i.index?.files.map(n=>[n.path,n])),a=new Set(s.index?.files.map(n=>n.path));for(const n of s.index?.files??[])b(t.get(n.path),n)||d.push(n);const P=o(n=>+((0,r.gitOwnPath)(n.path)==="index"),"last");d.sort((n,O)=>P(n)-P(O)),f.push(...i.index?.files.filter(n=>!a.has(n.path))??[])}return(0,h.pass)({drop:j,clear:y.sort(m),writes:M,index:d,removals:f.sort(m)})}o(S,"gitApplyPlan");
|
package/dist-cjs/git/play.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ae=Object.defineProperty;var r=(t,i)=>ae(t,"name",{value:i,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.gitOwnChange=
|
|
2
|
-
`)):(
|
|
3
|
-
`).at(-1);o+=`${
|
|
4
|
-
`}o===""?
|
|
1
|
+
"use strict";var ae=Object.defineProperty;var r=(t,i)=>ae(t,"name",{value:i,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.gitOwnChange=ne,exports.gitLineChanges=re,exports.gitPlayable=fe,exports.gitPlayRecord=he;const ee=require("../entities/bytes.js"),ce=require("./alternates.js"),te=require("./artifact.js"),E=require("./refs.js"),S=require("./state.js"),W=require("./text.js");function ne(t){return t.facets.some(f=>f==="create"||f==="retype"||f==="content")&&t.result.status==="active"?t.result.transportVersion:null}r(ne,"gitOwnChange");function re(t){let i=[],f=!1;for(const g of t){if(g.result.type!=="repo.git"){i=[],f=!0;continue}const p=ne(g);p!==null&&i.push(p)}return{reached:i,ended:f}}r(re,"gitLineChanges");function fe({line:t,basis:i,record:f}){const g=r(l=>l.files.find(a=>a.path===ce.GIT_ALTERNATES_PATH)?.oid??null,"borrowed"),p=r(l=>l.files.some(a=>a.path==="reftable"),"reftable");return t.format===f.format&&(i===null||i.format===f.format)&&!(0,S.gitSharesObjects)(t)&&!(0,S.gitSelfHeld)(t.home)&&!(0,S.gitSharesGitDir)(t.home)&&t.home?.entity===f.home?.entity&&t.home?.path===f.home?.path&&g(t)===g(f)&&![t,f,...i?[i]:[]].some(l=>p(l)||(0,S.gitBytesForm)(l))}r(fe,"gitPlayable");const B="040000",z=r(t=>new Map(t.map(i=>[i.path,i])),"byPath"),F=r((t,i)=>t===void 0?i===void 0:i!==void 0&&t.mode===i.mode&&t.oid===i.oid,"same"),se=r(t=>{const i=[];for(let f=t.indexOf("/");f>0;f=t.indexOf("/",f+1))i.push(t.slice(0,f));return i},"parents");function le(t,i,f){const g=new Set;for(const l of t.keys()){const a=se(l).find(k=>t.has(k)&&t.get(k).mode!==B);a!==void 0&&g.add(a)}const p=r(l=>g.has(l)||se(l).some(a=>g.has(a)),"clashed");if(g.size>0){for(const l of[...t.keys()])p(l)&&t.delete(l);for(const[l,a]of i)p(l)&&t.set(l,a)}return(0,S.gitTreeOf)(t.values(),f)}r(le,"asTree");const D=["line","basis","record"],H=r(t=>t.mode!==B&&(t.path==="HEAD"||t.path.startsWith("refs/")),"isLooseRef"),oe=r(t=>H(t)||t.path==="packed-refs","isRefFile"),de=r(t=>t.startsWith("logs/"),"isReflogPath"),N="refs/stash",V="refs/heads/",J=`${V}amalgm`,ue=7,ge=/^[0-9a-f]{7,}$/,K=r((t,i)=>t.startsWith(`${i}/`),"beneath");async function he(t,i,f,g){const p={format:t.record.format,home:t.record.home,files:[],index:null},l={line:t.line,basis:t.basis??p,record:t.record},a={line:z(l.line.files),basis:z(l.basis.files),record:z(l.record.files)},k=new Map,O=r((e,n)=>{const s=(0,ee.utf8Encode)(n),c=(0,te.gitBlobId)(s,g);return k.set(c,s),{path:e,mode:"100644",oid:c}},"make"),w=r(async e=>e?.oid?(0,ee.utf8Decode)(k.get(e.oid)??await i(e.oid)):"","read"),P=new Map,T=r(e=>(P.has(e)||P.set(e,w(a[e].get("packed-refs")).then(E.gitPackedRefs)),P.get(e)),"packedOf"),y=r(async(e,n)=>{const s=a[e].get(n);return s!==void 0&&H(s)?(0,E.gitLooseRef)(await w(s)):n==="HEAD"?null:(await T(e)).get(n)??null},"value"),$=r(e=>!F(a.basis.get(e),a.record.get(e)),"recordChanged"),u=new Map;for(const e of new Set([...a.line.keys(),...a.basis.keys(),...a.record.keys()])){const n=$(e)?a.record.get(e):a.line.get(e);n!==void 0&&u.set(e,n)}const I=new Set;for(const e of new Set(D.flatMap(n=>[...a[n].keys()]))){const[n,s,c]=D.map(o=>a[o].get(e));if(!(F(n,s)&&F(s,c)))if(e==="packed-refs")for(const o of D)for(const d of(await T(o)).keys())I.add(d);else[n,s,c].some(o=>o!==void 0&&H(o))&&I.add(e)}const Q=r(async e=>{const[n,s,c]=D.map(o=>a[o].get(e));return[n,s,c].some(o=>o?.mode===B)?w(n):(0,E.gitReflogPlay)(await w(s),await w(c),await w(n))},"playLog"),x=`logs/${N}`;let _=null;$(x)&&(_=(0,E.gitChainReflog)(await Q(x)),_===""?u.delete(x):u.set(x,O(x,_)));const m=new Map,M=[];for(const e of[...I].sort(W.compareGitText)){const[n,s,c]=await Promise.all(D.map(d=>y(d,e)));let o=s!==c?c:n;if(e===N){if(_===null)continue;o=(0,E.gitReflogTop)(_)}else e.startsWith(V)&&n!==null&&n!==s&&o!==n&&[n,c].every(d=>d===null||(0,S.isGitOid)(t.record.format,d))&&(c===null||!await f.builtOn(c,n))&&(o=n,c!==null&&!await f.builtOn(n,c)&&M.push({name:e,basis:s,record:c}));o!==n&&m.set(e,o)}const U=[];if(M.length>0){const e=new Map;for(const s of new Set([...a.line.keys(),...(await T("line")).keys(),...m.keys()])){if(s!==J&&!K(s,J))continue;const c=m.has(s)?m.get(s):await y("line",s);c!==null&&e.set(s,c)}const n=r((s,c)=>(e.get(s)??c)===c&&![...e.keys()].some(o=>K(s,o)||K(o,s)),"free");for(const{name:s,basis:c,record:o}of M){const d=`${J}/${s.slice(V.length)}-`;let h=[...e.keys()].sort(W.compareGitText).find(b=>e.get(b)===c&&b.startsWith(d)&&ge.test(b.slice(d.length)));for(let b=ue;h===void 0&&b<=o.length;b+=1)n(d+o.slice(0,b),o)&&(h=d+o.slice(0,b));h!==void 0&&(await y("line",h)!==o&&m.set(h,o),e.set(h,o),U.push({branch:h,from:s,commit:o}))}}for(const[e,n]of[...u])oe(n)&&u.delete(e);for(const e of l.line.files)oe(e)&&u.set(e.path,e);const j=new Set;for(const[e,n]of m)n!==null?u.set(e,O(e,`${n}
|
|
2
|
+
`)):(u.has(e)&&H(u.get(e))&&u.delete(e),j.add(e));const X=a.line.get("packed-refs");if(j.size>0&&X!==void 0){const e=await w(X),n=(0,E.gitDropPackedRefs)(e,j);n!==e&&u.set("packed-refs",O("packed-refs",n))}const C=r(e=>m.has(e)?Promise.resolve(m.get(e)):y("line",e),"final"),L=r(async(e,n)=>e?.startsWith("ref: ")?n(e.slice(5)):e,"commitOf"),A=await L(await C("HEAD"),C),R=new Set;for(const e of D)for(const n of a[e].keys())de(n)&&n!==x&&R.add(n);for(const e of m.keys())e!==N&&R.add(`logs/${e}`);A!==await L(await y("line","HEAD"),e=>y("line",e))&&R.add("logs/HEAD");for(const e of[...R].sort(W.compareGitText)){const n=e.slice(5),s=n==="HEAD"?A:await C(n),c=$(e);if(!c&&(s===null||n!=="HEAD"&&!m.has(n)||!a.line.has(e)))continue;let o=c?await Q(e):await w(a.line.get(e));const d=(0,E.gitReflogTop)(o);if(s!==null&&d!==null&&d!==s&&(0,S.isGitOid)(t.record.format,s)){const h=o.trimEnd().split(`
|
|
3
|
+
`).at(-1);o+=`${d} ${s}${h.slice(h.indexOf(" ",h.indexOf(" ")+1))}
|
|
4
|
+
`}o===""?u.delete(e):u.set(e,O(e,o))}const v=r(e=>y(e,"HEAD").then(n=>L(n,s=>y(e,s))),"headOf"),Y=await v("record"),ie=t.record.index?.meaning!==t.basis?.index?.meaning||Y!==(t.basis===null?null:await v("basis")),[G,q]=ie?[t.record.index,Y]:[t.line.index,await v("line")];let Z=G;if(G?.files.length===1&&q!==null&&A!==null&&q!==A){const e=await f.carryIndex(await i(G.files[0].oid),q,A);if(e!==null){const n=e.bytes,s=(0,te.gitBlobId)(n,g);k.set(s,n),Z={meaning:e.meaning,files:[{path:"index",mode:"100644",oid:s}]}}}return{state:{format:t.record.format,home:t.record.home,files:le(u,a.record,t.record.home),index:Z},made:k,aside:U}}r(he,"gitPlayRecord");
|
package/dist-cjs/git/restore.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var
|
|
2
|
-
`)));for(const e of
|
|
1
|
+
"use strict";var I=Object.defineProperty;var o=(s,a)=>I(s,"name",{value:a,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.gitRestoreGoal=A;const f=require("../contracts/validate.js"),g=require("../entities/bytes.js"),$=require("./artifact.js"),n=require("./parts.js"),d=require("./refs.js"),p=require("./state.js"),O=/^(rebase-merge|rebase-apply|sequencer)(\/|$)/,l=o(s=>s.mode==="040000","isFolder"),S=o(s=>(0,n.gitOwnRef)(s)||(0,n.gitOwnFile)(s),"restored");function A(s,a,T,j){for(const e of[s,a]){if((0,p.gitBytesForm)(e))return(0,f.fail)("a repository in byte form cannot be restored");if(e.files.some(t=>t.path.startsWith("reftable/")))return(0,f.fail)("a reftable repository cannot be restored");if((0,p.gitSelfHeld)(e.home))return(0,f.fail)("a worktree of storage outside every folder cannot be restored")}if(s.format!==a.format)return(0,f.fail)(`a ${s.format} repository cannot take a ${a.format} version`);const u=new Map,_=o((e,t)=>{const i=(0,$.gitBlobId)(t,j);return u.set(i,t),{path:e,mode:"100644",oid:i}},"blob"),k=o(e=>e.files.find(t=>t.path===n.GIT_PACKED_REFS),"packed"),R=o(e=>{const t=k(e);return t===void 0?null:(0,g.utf8Decode)(T(t.oid))},"packedText"),c=R(s),h=R(a),m=h===null?new Map:(0,d.gitPackedRefs)(h),w=o((e,t)=>new Set([...e.files.filter(i=>!l(i)&&(0,n.gitOwnRef)(i.path)).map(i=>i.path),...[...t.keys()].filter(n.gitOwnRef)]),"ownRefs"),M=w(a,m),q=new Set([...w(s,c===null?new Map:(0,d.gitPackedRefs)(c))].filter(e=>!M.has(e)).map(e=>`logs/${e}`)),r=new Map;for(const[e,t]of m)(0,n.gitOwnRef)(e)&&r.set(e,_(e,(0,g.utf8Encode)(`${t}
|
|
2
|
+
`)));for(const e of a.files)(l(e)?O.test(e.path):S(e.path))&&r.set(e.path,e);if(c!==null){const e=(0,d.gitDropPackedRefs)(c,new Set([...(0,d.gitPackedRefs)(c).keys()].filter(n.gitOwnRef)));r.set(n.GIT_PACKED_REFS,e===c?k(s):_(n.GIT_PACKED_REFS,(0,g.utf8Encode)(e)))}const b=o(e=>{const t=e.split("/");return t.slice(1).map((i,D)=>t.slice(0,D+1).join("/"))},"ancestors"),v=new Set([...r.keys()].flatMap(b)),F=o(e=>r.has(e.path)||!l(e)&&v.has(e.path)||b(e.path).some(t=>r.has(t)&&!l(r.get(t))),"inTheWay");for(const e of s.files)(l(e)?!O.test(e.path):e.path!==n.GIT_PACKED_REFS&&!S(e.path)&&!q.has(e.path))&&!F(e)&&r.set(e.path,e);const y=(0,p.gitTreeOf)(r.values(),s.home),E={...s,files:y,index:a.index},P=(0,p.checkGitState)(E);if(!P.ok)return(0,f.fail)(`the version cannot stand over this repository: ${P.error}`);const G=new Map(y.flatMap(e=>u.has(e.oid)?[[e.oid,u.get(e.oid)]]:[]));return(0,f.pass)({state:E,blobs:G})}o(A,"gitRestoreGoal");
|
package/dist-cjs/git/state.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`).map(
|
|
3
|
-
${JSON.stringify({format:t.format,home:t.home&&[t.home.entity,t.home.path],files:t.files.map(
|
|
1
|
+
"use strict";var E=Object.defineProperty;var s=(t,i)=>E(t,"name",{value:i,configurable:!0});Object.defineProperty(exports,"__esModule",{value:!0}),exports.gitStateId=exports.isGitHome=exports.gitNamedObjects=exports.isGitNamingPath=exports.gitSharesObjects=exports.isGitStoragePath=exports.gitBytesForm=exports.isGitConfigurationPath=exports.isGitIndexPath=exports.isGitLockPath=exports.gitOwnPath=exports.gitSharesGitDir=exports.gitSelfHeld=exports.isGitOid=void 0,exports.isGitStatePath=f,exports.gitTreeOf=M,exports.gitBlobs=U,exports.checkGitState=V,exports.gitStateJson=Z;const _=require("@amalgm/core/identity"),d=require("../contracts/validate.js"),p=require("../entities/bytes.js"),k=require("../entities/types.js"),w=require("./alternates.js"),u=require("./text.js"),b=["040000","100644","100755","120000"],R={sha1:40,sha256:64},T=s((t,i)=>typeof i=="string"&&i.length===R[t]&&/^[0-9a-f]+$/.test(i),"isGitOid");exports.isGitOid=T;const G=s(t=>(0,exports.isGitOid)("sha256",t),"isDigest"),j=s(t=>t!==null&&t.entity===null,"gitSelfHeld");exports.gitSelfHeld=j;const A=s(t=>t!==null&&t.entity!==null&&t.path==="","gitSharesGitDir");exports.gitSharesGitDir=A;const H=s(t=>t.replace(/^worktrees\/[^/]+\//,""),"gitOwnPath");exports.gitOwnPath=H;const I=s(t=>t.split("/").some(i=>i.endsWith(".lock")),"isGitLockPath");exports.isGitLockPath=I;const $=s(t=>(i=>i==="index"||/^sharedindex\.[0-9a-f]+$/.test(i))((0,exports.gitOwnPath)(t)),"isGitIndexPath");exports.isGitIndexPath=$;const D=s(t=>["config","config.worktree"].includes((0,exports.gitOwnPath)(t)),"isGitConfigurationPath");exports.isGitConfigurationPath=D;const y=["worktrees","modules"],L=["objects",...y],g=s((t,i)=>t===w.GIT_ALTERNATES_PATH||t!=="gitdir"&&!(i?y:L).some(e=>t===e||t.startsWith(`${e}/`)),"isOwnStatePath");function f(t,i,e=!1){if((0,exports.gitSharesGitDir)(i)||(0,_.isLocalOnlyPath)(t)||(0,exports.isGitLockPath)(t))return!1;if(!(0,exports.gitSelfHeld)(i))return g(t,e);const n=i.path;return t==="worktrees"||t===n?!0:t.startsWith(`${n}/`)?g(t.slice(n.length+1),e):g(t,e)&&!(0,exports.isGitIndexPath)(t)}s(f,"isGitStatePath");const S=s(t=>t.some(i=>(0,d.isRecord)(i)&&i.path==="objects"&&i.mode==="040000"),"listsObjects"),N=s(t=>S(t.files),"gitBytesForm");exports.gitBytesForm=N;function M(t,i){const e=new Map;for(const n of t)e.set(n.path,n);for(const n of[...e.keys()])for(let r=n.indexOf("/");r>0;r=n.indexOf("/",r+1)){const a=n.slice(0,r);!e.has(a)&&f(a,i)&&e.set(a,{path:a,mode:"040000",oid:null})}return[...e.values()].sort((n,r)=>(0,u.compareGitText)(n.path,r.path))}s(M,"gitTreeOf");const q=s((t,i)=>f(t,i,!0)&&!f(t,i),"isGitStoragePath");exports.isGitStoragePath=q;const F=s(t=>!(0,exports.gitSelfHeld)(t.home)&&(t.home?.path.startsWith("worktrees/")??!1),"gitSharesObjects");exports.gitSharesObjects=F;const B=new Set(["AUTO_MERGE","BISECT_EXPECTED_REV","MERGE_AUTOSTASH","NOTES_MERGE_PARTIAL","NOTES_MERGE_REF"]),C=s(t=>(i=>/^[A-Z_-]+_HEAD$/.test(i)||B.has(i)||/^rebase-(apply|merge)\/(autostash|orig-head)$/.test(i))((0,exports.gitOwnPath)(t)),"isGitNamingPath");exports.isGitNamingPath=C;const W=s((t,i)=>(0,p.utf8Decode)(i).split(`
|
|
2
|
+
`).map(e=>e.split(/[\t ]/,1)[0]).filter(e=>(0,exports.isGitOid)(t,e)),"gitNamedObjects");exports.gitNamedObjects=W;const m=s(t=>typeof t=="string"&&t.length>0&&!t.includes("\0")&&t.split("/").every(i=>i!==""&&i!=="."&&i!==".."),"isPath");function U(t){const i=new Set;for(const e of[...t.files,...t.index?.files??[]])e.oid!==null&&i.add(e.oid);return i}s(U,"gitBlobs");const J='{ format: "sha1", home: { entity: <uuid>, path: "worktrees/<name>" | "modules/<name>" | "" } | { entity: null, path: "worktrees/<name>" } | null, files: [{ path: "HEAD", mode: "100644", oid: <sha256> }], index: { meaning: <sha256>, files: [...] } | null }',O=s(t=>typeof t=="string"&&/^worktrees\/[^/]+$/.test(t),"isWorktreeHome"),X=s(t=>(0,d.isRecord)(t)&&Object.keys(t).length===2&&(t.entity===null?m(t.path)&&O(t.path):typeof t.entity=="string"&&k.UUID_PATTERN.test(t.entity)&&t.entity===t.entity.toLowerCase()&&(t.path===""||m(t.path)&&(O(t.path)||t.path.startsWith("modules/")))),"isGitHome");exports.isGitHome=X;function P(t,i,e,n,r){if(!Array.isArray(t))return"not a list";for(const[a,o]of t.entries()){if((0,d.isRecord)(o)&&typeof o.path=="string"&&(0,exports.isGitLockPath)(o.path))return`${o.path} is a lock, a write in progress, never state`;if(!(0,d.isRecord)(o)||Object.keys(o).length!==3||!m(o.path)||!n(o.path))return`entry ${a} is not one { path, mode, oid } this list owns`;if(a>0&&(0,u.compareGitText)(t[a-1].path,o.path)>=0)return"paths are not sorted and unique";if(!b.includes(o.mode)||(o.mode==="040000"?o.oid!==null:!G(o.oid)))return`${o.path} is not a folder without a blob or a file, executable or link naming one`;const c=o.path.slice(0,Math.max(0,o.path.lastIndexOf("/")));if(c!==""&&f(c,i,e)&&!r.has(c))return`${o.path} stands in no listed folder`;o.mode==="040000"&&r.add(o.path)}return t}s(P,"checkFiles");function V(t){const i=s(h=>(0,d.failShape)(J,h),"bad");if(!(0,d.isRecord)(t)||Object.keys(t).length!==4)return i("the state is not { format, home, files, index }");const{format:e,index:n}=t;if(e!=="sha1"&&e!=="sha256")return i("format is not sha1 or sha256");if(t.home!==null&&!(0,exports.isGitHome)(t.home))return i("home is not null or { entity, path } naming worktrees/, modules/ or, with an entity, nothing, with no entity only for worktrees/");const r=t.home&&{entity:t.home.entity,path:t.home.path},a=new Set,o=Array.isArray(t.files)&&S(t.files),c=P(t.files,r,o,h=>f(h,r,o)&&!(0,exports.isGitIndexPath)(h),a);if(typeof c=="string")return i(`files: ${c}`);if(n===null)return(0,d.pass)({format:e,home:r,files:c,index:null});if((0,exports.gitSharesGitDir)(r))return i("a state that shares its owner's Git directory has an index");if(!(0,d.isRecord)(n)||Object.keys(n).length!==2||!G(n.meaning))return i("index is not null or { meaning, files }");const l=P(n.files,r,o,h=>f(h,r)&&(0,exports.isGitIndexPath)(h),a);if(typeof l=="string")return i(`index files: ${l}`);const x=(0,exports.gitSelfHeld)(r)?`${r.path}/index`:"index";return!l.some(h=>h.path===x)||l.some(h=>h.mode!=="100644")?i("index files are not plain files including index"):(0,d.pass)({format:e,home:r,files:c,index:{meaning:n.meaning,files:l}})}s(V,"checkGitState");function Z(t){const i=s(e=>e.map(n=>({path:n.path,mode:n.mode,oid:n.oid})),"files");return{format:t.format,home:t.home&&{entity:t.home.entity,path:t.home.path},files:i(t.files),index:t.index&&{meaning:t.index.meaning,files:i(t.index.files)}}}s(Z,"gitStateJson");const z=s((t,i)=>i((0,p.utf8Encode)(`amalgm.git-state.v3
|
|
3
|
+
${JSON.stringify({format:t.format,home:t.home&&[t.home.entity,t.home.path],files:t.files.map(e=>[e.path,e.mode,e.oid]),index:t.index?.meaning??null})}`)),"gitStateId");exports.gitStateId=z;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amalgm/live",
|
|
3
|
-
"version": "0.2.81-preview.
|
|
3
|
+
"version": "0.2.81-preview.46155260343",
|
|
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",
|
|
@@ -131,13 +131,13 @@
|
|
|
131
131
|
"esbuild@0.28.2": true
|
|
132
132
|
},
|
|
133
133
|
"dependencies": {
|
|
134
|
-
"@amalgm/core": "0.5.1-preview.
|
|
134
|
+
"@amalgm/core": "0.5.1-preview.46154682692"
|
|
135
135
|
},
|
|
136
|
-
"gitHead": "
|
|
136
|
+
"gitHead": "4463595667422a27dec873c2ff32f1e71c704f8a",
|
|
137
137
|
"amalgmSource": {
|
|
138
138
|
"repository": "amalgm-inc/amalgm-live",
|
|
139
139
|
"branch": "preview",
|
|
140
|
-
"commit": "
|
|
141
|
-
"occurrence": "
|
|
140
|
+
"commit": "4463595667422a27dec873c2ff32f1e71c704f8a",
|
|
141
|
+
"occurrence": "46155260343"
|
|
142
142
|
}
|
|
143
143
|
}
|