PageSourceSearch

https://phasoric.com/assets/desktop-vault-Cj0Xjt1b.js

js phasoric.com collected 2026-09-24 14:52:25 UTC 19,035 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/desktop-note-index-worker-CEqdaeex.js","assets/semantic-note-DyLW_AZF.js","assets/task-utils-NfCAvgr9.js","assets/safe-frontmatter-BdZqnLng.js","assets/note-metadata-B1U6L68W.js","assets/note-header-Dl68MLXE.js","assets/shared-vault-artifact-C5nEgsr5.js","assets/intelligence-content-hash-CEhOl9kW.js","assets/source-lineage-sX0-NSIe.js","assets/context-scope-CsYkf_jD.js","assets/note-header-fingerprint-DVT7jIKZ.js","assets/note-trust-Y3C29qxz.js","assets/rolldown-runtime-BNNRdYrd.js","assets/storage-vendor-HZzIgsIR.js","assets/semantic-links-BmhOhVmH.js","assets/source-manifest-Du9PY7Qn.js","assets/db-Dgd9zlNH.js","assets/react-vendor-BqQF_9sx.js","assets/index-BQuIkJiK.js","assets/platform-capabilities-Bjt71t6g.js","assets/comparison-positioning-DbkxE00R.js","assets/context-sales-routes-BmilJBIO.js","assets/domain-plugin-catalog-lNnBMB9_.js","assets/plan-entitlements-D-LMrELD.js","assets/index-DNsQKlv_.css","assets/desktop-vault-binding-CVzuZYam.js","assets/desktop-mcp-D_M5TizZ.js","assets/local-tools-BJvoPiiK.js","assets/vaultPaths-DDAbbuS7.js","assets/trash-C3hwSUy1.js","assets/permanent-memory-BEUfT4yj.js","assets/attachments-0D7dZ0Hd.js","assets/dexie-batching-DceqOBeq.js","assets/cloud-sources-0yR8nunz.js","assets/metadata-sync-BmUSMven.js","assets/onboarding-C3SgsVj9.js","assets/workspace-bootstrap-BlZDnksD.js","assets/client-BHTBpyJq.js","assets/knowledge-model-DWJuoUAe.js","assets/resource-model-DDr_1WO_.js","assets/settings-T1AcS8Fx.js"])))=>i.map(i=>d[i]);
2import{r as R}from"./rolldown-runtime-BNNRdYrd.js";import{_ as u}from"./react-vendor-BqQF_9sx.js";import{n as T}from"./platform-capabilities-Bjt71t6g.js";import{U as L,at as A,d as x}from"./index-BQuIkJiK.js";import{a as j,i as U,o as l,r as N,s as k,t as _}from"./desktop-vault-binding-CVzuZYam.js";import{t as w}from"./desktop-update-preparation-AB-eezLX.js";function F(){let t,e,i=0,s=!1;const r=a=>{const n=e;e=null,n?.reject(a)};return{async derive(a){if(s)throw new Error("The vault indexer is closed.");if(e)throw new Error("A vault index job is already running.");if(typeof Worker>"u"){if(typeof window<"u"&&!"production".includes("test"))throw new Error("Background note indexing is unavailable. Reload Phasoric.");return(await u(async()=>{const{deriveDesktopNote:n}=await import("./desktop-note-index-worker-CEqdaeex.js");return{deriveDesktopNote:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).deriveDesktopNote(a)}return t||(t=new Worker(new URL("/assets/desktop-note-index-worker-BiMIbOGI.js",""+import.meta.url),{type:"module"}),t.onmessage=({data:n})=>{if(!e||e.id!==n.id)return;const o=e;e=null,n.error?o.reject(Object.assign(new Error(n.error.message),{code:n.error.code})):o.resolve(n.result)},t.onerror=()=>{t?.terminate(),t=null,r(new Error("Background note indexing stopped. Reload Phasoric to resume."))},t.onmessageerror=()=>r(new Error("The background index result could not be read."))),new Promise((n,o)=>{e={id:++i,resolve:n,reject:o};try{t.postMessage({id:i,note:a})}catch(p){r(p)}})},close(){s=!0,t?.terminate(),t=null,r(new Error("The vault indexer is closed."))}}}var st=R({DesktopVaultSession:()=>V,chooseDesktopVault:()=>B,desktopAssetResource:()=>$,desktopSessionForDatabase:()=>M,desktopVaultStatus:()=>G,forgetDesktopVault:()=>K,listDesktopVaults:()=>H,openDesktopVault:()=>z,pauseDesktopVaultForUpdate:()=>q,refreshDesktopNote:()=>Q,startDesktopVault:()=>W}),f=x("PhasoricVault"),v=new WeakMap,m=new WeakMap,h,D=Promise.resolve();function S(t,e){typeof window<"u"&&window.dispatchEvent(new CustomEvent(t,{detail:e}))}function O(t){return Object.assign(new Error(`This note changed outside Phasoric. Reload the disk version or save your draft as a new note: ${t}`),{code:"REVISION_CONFLICT"})}function C(t){return[/\]\(\s*(?:<([^>\n]+)>|([^\s)]+))/g,/^\s{0,3}\[[^\]\n]+\]:\s*(?:<([^>\n]+)>|([^\s]+))/gm].some(e=>[...String(t||"").matchAll(e)].some(i=>{const s=i[1]||i[2];return s&&!/^(?:[a-z][a-z\d+.-]*:|\/|#)/i.test(s)}))}var V=class{constructor({database:t,grant:e,plugin:i=f}){this.database=t,this.grant=e,this.plugin=i,this.tail=Promise.resolve(),this.closed=!1,this.closing=!1,this.status="opening",this.pendingEvents=[],this.assetPaths=new Set,this.indexer=F(),this.issues=new Map,this.progress={phase:"opening",scanned:0,indexed:0,skipped:0},v.set(t,this)}serial(t){if(this.closed||this.closing)return Promise.reject(new Error("The desktop vault is closed. Reopen it before saving."));const e=this.tail.then(t);return this.tail=e.catch(()=>{}),e}emit(t,e={}){!this.closed&&!this.closing&&k()?.grantId===this.grant.id&&S(t,{...e,grantId:this.grant.id})}async project(t,{external:e=!1,changes:i={}}={}){const s=this.database,r=_+t.path,a=await s.notes.get(r);if(a?.nativeRevision===t.revision&&!Object.keys(i).length)return this.issues.delete(t.path)&&this.publishProgress(),a;const n={...a,...i,path:r,content:t.content,id:i.id??a?.id??crypto.randomUUID(),createdAt:i.createdAt??a?.createdAt??t.modifiedAt??Date.now(),updatedAt:Math.max(Number(t.modifiedAt)||0,Number(a?.updatedAt||0)+1),nativeRevision:t.revision,desktopGrantId:this.grant.id,synced:!0,provenance:a?.provenance||{kind:"local",sourceId:r,capturedAt:Date.now()}},{note:o,header:p,semanticEntities:E}=await this.indexer.derive(n);await s.transaction("rw",s.notes,s.noteHeaders,s.syncQueue,async d=>{N(d),await s.notes.put(o),await s.noteHeaders.put(p),await s.syncQueue.
2where("path").equals(r).delete()});const[{reconcileTrustAfterNoteWrite:g},{indexSemanticNote:P}]=await Promise.all([u(()=>import("./note-trust-Y3C29qxz.js").then(d=>d.r),__vite__mapDeps([11,12,13])),u(()=>import("./semantic-links-BmhOhVmH.js").then(d=>d.i),__vite__mapDeps([14,12,1,2,3]))]);return await g(o,{previousNote:a,database:s}),await P(o,{database:s,preparedEntities:E}).catch(d=>this.emit("semantic-index-error",{path:r,message:d.message})),this.issues.delete(t.path)&&this.publishProgress(),e&&this.emit("desktop-vault-change",{path:r,type:a?"change":"create",revision:t.revision,note:o,origin:"external"}),o}async removeProjection(t,{external:e=!1}={}){this.issues.delete(t)&&this.publishProgress();const i=_+t,s=this.database,r=await s.notes.get(i),{markSourceDeleted:a}=await u(async()=>{const{markSourceDeleted:n}=await import("./source-manifest-Du9PY7Qn.js").then(o=>o.a);return{markSourceDeleted:n}},__vite__mapDeps([15,12,16,17,18,19,20,21,22,23,24,13,11,14,1,2,3,25,7]));await a(i,{database:s}),await s.transaction("rw",s.notes,s.noteHeaders,s.syncQueue,s.semanticEntities,async n=>{N(n),await s.notes.delete(i),await s.noteHeaders.delete(i),await s.syncQueue.where("path").equals(i).delete(),await s.semanticEntities.where("sourcePath").equals(i).delete(),r?.id&&await s.semanticEntities.where("sourceNoteId").equals(r.id).delete()}),e&&this.emit("desktop-vault-change",{path:i,type:"delete",origin:"external"})}async refreshPath(t){if(!/\.md$/i.test(t.path)){t.type==="delete"?this.assetPaths.delete(t.path):this.assetPaths.add(t.path),this.emit("desktop-vault-assets-changed",{path:t.path});return}try{const e=await this.plugin.readFile({grantId:this.grant.id,path:t.path});await this.project(e,{external:!0})}catch(e){if(["ENOENT","FILE_NOT_FOUND","NOT_FOUND"].includes(e.code))await this.removeProjection(t.path,{external:!0});else if(!this.skipFile(t.path,e))throw e}}snapshot(){const t=[];for(const e of this.issues.values())if(t.push(e),t.length===100)break;return{status:this.status,grant:this.grant,grantId:this.grant.id,...this.progress,skipped:this.issues.size,issues:t,message:this.errorMessage}}publishProgress(t={}){Object.assign(this.progress,t),this.emit("desktop-vault-status",this.snapshot())}skipFile(t,e){return["UNSUPPORTED_ENCODING","FILE_TOO_LARGE","FILE_BUSY","EACCES","EPERM"].includes(e.code)?(this.issues.set(t,{path:t,code:e.code,message:e.code==="UNSUPPORTED_ENCODING"?"Not valid UTF-8. Original bytes preserved.":e.message}),this.publishProgress(),!0):!1}start({background:t=!1}={}){return this.startPromise?this.startPromise:(this.startPromise=this.initialize({background:t}),this.startPromise)}async initialize({background:t}){return this.setupPromise=this.installListeners(),await this.setupPromise,this.closing?this:(this.indexing=!0,this.status="indexing",this.indexPromise=this.hydrate().catch(async e=>{if(this.closing||e.code==="SCAN_CANCELED")return this;for(this.reportError(e),["ACCESS_REVOKED","VAULT_UNAVAILABLE","VAULT_WORKER_UNAVAILABLE"].includes(e.code)&&(this.pendingEvents.length=0);this.pendingEvents.length;)for(const i of this.pendingEvents.splice(0))for(const s of i.changes){if(this.closing)return this;try{await this.serial(()=>this.refreshPath(s))}catch{}}
2if(this.emit("notes-updated"),!t)throw e;return this}).finally(()=>{this.indexing=!1}),t||await this.indexPromise,this)}async installListeners(){this.listener=await this.plugin.addListener("vaultChanged",t=>{if(!(t.grantId!==this.grant.id||this.closed||this.closing)){if(this.indexing&&this.progress.phase!=="scanning"){this.pendingEvents.push(t);return}this.serial(async()=>{for(const e of t.changes)await this.refreshPath(e);this.emit("notes-updated")}).catch(e=>this.reportError(e))}}),this.errorListener=await this.plugin.addListener("vaultWatchError",t=>{t.grantId!==this.grant.id||this.closed||this.closing||(this.watchError=Object.assign(new Error(t.message||"Vault monitoring stopped. Reconnect the vault."),{code:t.code||"WATCH_UNAVAILABLE"}),this.reportError(this.watchError))}),this.progressListener=await this.plugin.addListener("vaultScanProgress",t=>{t.grantId!==this.grant.id||this.closed||this.closing||t.phase==="scanning"&&this.publishProgress({phase:"scanning",scanned:t.scanned})}),this.issueListener=await this.plugin.addListener("vaultScanIssue",t=>{t.grantId!==this.grant.id||this.closed||this.closing||this.skipFile(t.path,t)})}async hydrate(){if(this.publishProgress({phase:"scanning",indexed:0}),await this.plugin.startWatch({grantId:this.grant.id}),this.closing)return this;this.publishProgress({phase:"indexing"});const t=new Set;let e;do{const i=await this.plugin.listEntries({grantId:this.grant.id,...e?{cursor:e}:{},limit:250});for(const s of i.entries){if(this.closing)return this;if(s.kind==="asset"&&this.assetPaths.add(s.path),s.kind!=="note")continue;const r=_+s.path;t.add(r);try{await this.serial(async()=>{(await this.database.notes.get(r))?.nativeRevision!==s.revision&&await this.project(await this.plugin.readFile({grantId:this.grant.id,path:s.path}))})}catch(a){if(["ENOENT","FILE_NOT_FOUND","NOT_FOUND"].includes(a.code))t.delete(r),this.closing||await this.serial(()=>this.refreshPath({path:s.path,type:"change"}));else if(!this.skipFile(s.path,a))throw a}await this.drainPendingChanges(),this.progress.indexed+=1,this.progress.indexed%25===0&&(this.publishProgress({phase:"indexing"}),this.emit("notes-updated"),await new Promise(a=>setTimeout(a,0)))}this.publishProgress({phase:"indexing"}),e=i.nextCursor}while(e);for(const i of await this.database.notes.toCollection().primaryKeys()){if(this.closing)return this;t.has(i)||await this.serial(async()=>{(await this.database.notes.get(i))?.desktopGrantId===this.grant.id&&await this.refreshPath({path:l(i),type:"change"})})}if(this.watchError)throw this.watchError;return await this.drainPendingChanges(),this.indexing=!1,this.status="watching",this.emit("notes-updated"),this.publishProgress({phase:"ready"}),this}async drainPendingChanges(){for(;this.pendingEvents.length;){for(const t of this.pendingEvents.splice(0))for(const e of t.changes){if(this.closing)return;await this.serial(()=>this.refreshPath(e))}this.emit("notes-updated")}}reportError(t){this.status="error",this.errorMessage=t.message,this.publishProgress()}async write(t,{expectedRevision:e,expectedUpdatedAt:i}={}){if(t.desktopGrantId&&t.desktopGrantId!==this.grant.id)throw new Error("This note belongs to another desktop vault. Reopen its original workspace before saving.");return this.serial(async()=>{const s=await this.database.notes.get(t.path);if(i!=null&&Number(s?.updatedAt||0)!==Number(i))throw O(t.path);const r=e!==void 0?e:t.nativeRevision??s?.nativeRevision??null,a=t.content??s?.content;if(typeof a!="string")throw new Error("Markdown content is required.");const n=await this.plugin.writeNote({grantId:this.grant.id,path:l(t.path),content:a,expectedRevision:r});return this.project({...n,content:a},{changes:t})})}close(){return this.closePromise?this.closePromise:(this.closing=!0,this.closePromise=(async()=>{const t=[];try{try{const{stopDesktopMcp:e}=await u(async()=>{const{stopDesktopMcp:i}=await import("./desktop-mcp-D_M5TizZ.js");return{stopDesktopMcp:i}},__vite__mapDeps([26,17,12,18,19,20,21,22,23,24,16,13,11,14,1,2,3,25,27,28,29,30,31,32,33,34,35,36,37,38,39,15,7,40]));await e()}catch(e){t.push(e)}await this.setupPromise?.catch(()=>{}),this.indexing&&await this.plugin.stopWatch({grantId:this.grant.id}).catch(e=>t.push(e)),await this.indexPromise?.catch(()=>{}),await this.tail,this.indexer.close();for(const e of[()=>this.listener?.remove(),()=>this.errorListener?.remove(),()=>this.progressListener?.remove(),()=>this.issueListener?.remove(),()=>this.plugin.stopWatch({grantId:this.grant.id})])try{await e()}catch(i){t.push(i)}if(t.length)throw t[0]}finally{this.closed=!0,this.status="closed",this.pendingEvents.length=0,v.get(this.database)===this&&v.delete(this.database),h===this&&(h=null)}})(),this.closePromise)}async move({fromPath:t,note:e,expectedUpdatedAt:i}){if(e.desktopGrantId&&e.desktopGrantId!==this.grant.id)throw new Error("This note belongs to another desktop vault. Reopen its original workspace before moving it.");return this.serial(async()=>
2{const s=await this.database.notes.get(t);if(!s||i!=null&&s.updatedAt!==i)throw O(t);if(e.content!==void 0&&e.content!==s.content)throw new Error("Save the note before moving it.");if(t.split("/").slice(0,-1).join("/")!==e.path.split("/").slice(0,-1).join("/")&&C(s.content))throw Object.assign(new Error("This note contains relative Markdown links. Move it with Obsidian so those links are updated, or use vault-root paths or WikiLinks before moving it between folders."),{code:"RELATIVE_LINK_MOVE_UNSUPPORTED"});const r=await this.plugin.moveNote({grantId:this.grant.id,path:l(t),destination:l(e.path),expectedRevision:e.nativeRevision??s.nativeRevision});return await this.database.transaction("rw",this.database.noteVersions,this.database.attachments,async()=>{await this.database.noteVersions.where("path").equals(t).modify({path:e.path}),await this.database.attachments.where("notePath").equals(t).modify({notePath:e.path})}),await this.removeProjection(l(t)),this.project({...r,path:l(e.path),content:s.content},{changes:{...s,...e}})})}async delete(t){if(t.desktopGrantId&&t.desktopGrantId!==this.grant.id)throw new Error("This note belongs to another desktop vault. Reopen its original workspace before deleting it.");return this.serial(async()=>{await this.plugin.deleteNote({grantId:this.grant.id,path:l(t.path),expectedRevision:t.nativeRevision}),await this.removeProjection(l(t.path))})}};function M(t){const e=v.get(t);if(!e||e.closed||e.closing)throw new Error("The desktop vault is unavailable. Reopen its folder before saving.");return e}function W(t){if(w(),m.has(t))return m.get(t);const e=D.catch(()=>{}).then(async()=>{w();const i=j(t);if(!i)return await h?.close(),null;if(!T().vaultDirectoryPicker)throw new Error("Open this vault in Phasoric Desktop.");if(k()?.grantId!==i.grantId)throw new Error("The active vault changed before it finished opening.");const s=v.get(t);if(s&&!s.closed&&!s.closing)return s.start({background:!0});await h?.close();const{grant:r}=await f.restoreVault({grantId:i.grantId});if(w(),k()?.grantId!==i.grantId)throw new Error("The active vault changed while restoring folder access.");const a=new V({database:t,grant:r});h=a;try{return await a.start({background:!0})}catch(n){throw await a.close(),n}});return m.set(t,e),D=e.catch(()=>{}),e.finally(()=>{m.get(t)===e&&m.delete(t)}).catch(()=>{}),e}function G(){return h?.snapshot()||{status:"ready",issues:[]}}async function q(){await D,h&&await h.close();const{stopDesktopMcp:t}=await u(async()=>{const{stopDesktopMcp:e}=await import("./desktop-mcp-D_M5TizZ.js");return{stopDesktopMcp:e}},__vite__mapDeps([26,17,12,18,19,20,21,22,23,24,16,13,11,14,1,2,3,25,27,28,29,30,31,32,33,34,35,36,37,38,39,15,7,40]));await t()}async function B(){if(w(),!T().vaultDirectoryPicker)throw new Error("Folder access requires Phasoric Desktop.");return(await f.selectVault({mode:"companion"})).grant}async function z(t,{reload:e=!0}={}){w(),await h?.close(),w();const i=`desktop-${t.id}`;return A(i,{label:t.name,defaultVault:"Vault",vaults:["Vault"],logicalVaults:[],deviceOnly:!0,purpose:"desktop-companion",linkedAccountIds:[]}),U(i,t),L(i,{reload:!1,preserveWorkspaceProfile:!0}),e&&window.location.assign("/app/dashboard"),i}async function H(){return(await f.listGrants()).grants}async function K(t){if(h?.grant.id===t)await h.close();else{const{stopDesktopMcp:e}=await u(async()=>{const{stopDesktopMcp:i}=await import("./desktop-mcp-D_M5TizZ.js");return{stopDesktopMcp:i}},__vite__mapDeps([26,17,12,18,19,20,21,22,23,24,16,13,11,14,1,2,3,25,27,28,29,30,31,32,33,34,35,36,37,38,39,15,7,40]));await e()}await f.revokeVault({grantId:t})}async function Q(t){if(!h||h.closed)throw new Error("Reopen this desktop vault to read the disk version.");return await h.serial(()=>h.refreshPath({type:"change",path:l(t)})),h.database.notes.get(t)}async function $(t,e,{wiki:i=!1}={}){const s=k();if(!s||!t||/^[a-z][a-z\d+.-]*:|^\/\/|^#/i.test(t))return null;const r=l(e).split("/").slice(0,-1);let a;try{a=decodeURIComponent(t.split("#")[0])}catch{return null}const n=[...a.startsWith("/")?[]:r,...a.replace(/^\//,"").split("/")],o=[];for(const c of n)if(c===".."){if(!o.length)return null;o.pop()}else c&&c!=="."&&o.push(c);const p=h?.grant.id===s.grantId?h:null,E=c=>f.readFile({grantId:s.grantId,path:c});let g;
2try{g=await E(o.join("/"))}catch(c){if(!i||!p||!["ENOENT","FILE_NOT_FOUND","NOT_FOUND"].includes(c.code)||a.split("/").some(y=>y==="."||y===".."))throw c;const b=a.replace(/^\//,""),I=p.assetPaths.has(b)?[b]:[...p.assetPaths].filter(y=>y.endsWith(`/${b}`));if(I.length!==1)throw new Error(I.length?"This asset name is ambiguous. Include its folder in the WikiLink.":"This local asset is unavailable.");g=await E(I[0])}if(k()?.grantId!==s.grantId)throw new Error("The active vault changed while this asset was loading.");if(g.kind!=="asset")return null;const P=Uint8Array.from(atob(g.content),c=>c.charCodeAt(0)),d={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",avif:"image/avif",bmp:"image/bmp",ico:"image/x-icon",pdf:"application/pdf",mp3:"audio/mpeg",mp4:"video/mp4",wav:"audio/wav",ogg:"audio/ogg",m4a:"audio/mp4",webm:"video/webm",mov:"video/quicktime",flac:"audio/flac"}[o.at(-1).split(".").at(-1).toLowerCase()]||"application/octet-stream";return{url:URL.createObjectURL(new Blob([P],{type:d})),mimeType:d}}export{st as a,z as c,G as i,$ as n,K as o,M as r,H as s,B as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.