Sign In

@github/copilot-linux-arm64

Package Overview
Dependencies
Maintainers
24
Versions
346
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@github/copilot-linux-arm64 - npm Package Compare versions

Comparing version
1.0.81-1
to
1.0.81-2
+1
-1
index.js

@@ -11,3 +11,3 @@ #!/usr/bin/env node

`);throw new Error(`Native addon "${e}" not found for ${t}. Tried:
${c}`)}function Gn(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}}function Ie(e){try{return{ok:!0,value:Kn(e)}}catch(n){return{ok:!1,err:n}}}function Kn(e){return Un($n(import.meta.url))(e)}function De(e){if(!(e instanceof Error))return e;let n=q.sharedApiSqliteNativeErrorPayload(e.message);if(!n)return e;let t=new Error(n.message);return t.code="ERR_SQLITE_ERROR",t.errcode=n.errcode,t.errstr=n.errstr,t}var V="COPILOT_RUNTIME_OOP",Yn=new Set(["NativeRunnerLogger"]),Ve=new Set(["log","debug","info","notice","warning","error","startGroup","endGroup","write"]),O,Xn=new Set(["flush","dispose"]),Zn=new Set(["writeLog"]),He=5e3,et="dispose";function nt(e){let n,t=new Promise(r=>{n=setTimeout(()=>{A.debug(`[nativeRuntime] pipeline drain gave up after ${He}ms; trailing log lines were dropped`),r(void 0)},He),n.unref?.()});return Promise.race([e,t]).finally(()=>{n&&clearTimeout(n)})}function tt(){return typeof __napiOopRequire<"u"&&__napiOopRequire||Qn(import.meta.url)}function rt(){return process.env[V]==="1"||process.env[V]==="true"}var ot;function st(e,n,t){let r=new Set((e.classes??[]).map(s=>s.name)),o={};for(let s of e.classes??[]){let c=s.methods.find(i=>i.js_name==="constructor"),p=c?c.rust_name:`${s.name}.constructor`,h=Yn.has(s.name),f=class{__provider;__handle;constructor(...i){let m=i[i.length-1],u=i.slice(0,i.length-1);this.__provider=m,this.__handle=m.call(p,u),m.trackExternal(this.__handle)}};Object.defineProperty(f,"name",{value:s.name}),f.__fromHandle=function(i,m){let u=Object.create(f.prototype);return u.__provider=i,u.__handle=m,i.trackExternal(m),u};for(let i of s.methods){if(i.js_name==="constructor")continue;let m=r.has(i.ret),u=i.rust_name,x=(d,l)=>m?n[i.ret].__fromHandle(d.__provider,l):l;if(i.is_static){let d=l=>m?n[i.ret].__fromHandle(t,l):l;f[i.js_name]=i.is_async?async(...l)=>d(await t.callAsync(u,l)):(...l)=>d(t.call(u,l));continue}if(i.is_getter){Object.defineProperty(f.prototype,i.js_name,{configurable:!0,get(){return i.is_async?(async()=>x(this,await this.__provider.callAsync(u,[this.__handle])))():x(this,this.__provider.call(u,[this.__handle]))}});continue}if(h&&!i.is_async&&i.ret==="void"&&Ve.has(i.js_name)){f.prototype[i.js_name]=function(...d){let l=this.__provider,y=this.__handle;O=(O??Promise.resolve()).then(async()=>{try{await l.callAsync(u,[y,...d])}catch{}})};continue}if(h&&i.is_async&&Zn.has(i.js_name)){f.prototype[i.js_name]=function(...d){let l=this.__provider,y=this.__handle,a=(O??Promise.resolve()).then(()=>l.callAsync(u,[y,...d]));return O=a.then(()=>{},()=>{}),a.then(()=>{})};continue}if(h&&i.is_async&&Xn.has(i.js_name)){let d=i.js_name===et;f.prototype[i.js_name]=async function(...l){let y=a=>d?nt(a):a;return await y(O??Promise.resolve()),x(this,await y(this.__provider.callAsync(u,[this.__handle,...l])))};continue}f.prototype[i.js_name]=i.is_async?async function(...d){return x(this,await this.__provider.callAsync(u,[this.__handle,...d]))}:function(...d){return x(this,this.__provider.call(u,[this.__handle,...d]))}}o[s.name]=f,n[s.name]=f}return o}function it(){let{bindClasses:e,connectFromEnvSync:n,createSyncBinding:t,SOCKET_ENV:r}=tt()("napi-oop-runtime");if(!process.env[r])throw new Error(`${V} is set but ${r} is not; the out-of-process runtime must be launched by the Rust provider parent, which exports the connect-back socket.`);let o=n();if(ot=o,delete process.env[V],!o.manifest)throw new Error("out-of-process provider did not advertise a surface manifest in its handshake");let s=JSON.parse(o.manifest),c=new Set((s.classes??[]).map(a=>a.name)),p=s.functions.filter(a=>a.is_async).map(a=>a.js_name),h=s.functions.filter(a=>a.ret==="ExternalObject").map(a=>a.js_name),f={};for(let a of s.functions)f[a.js_name]=a.rust_name;let i=Object.fromEntries((s.host_functions??[]).map(a=>[a.js_name,{intrinsic:a.intrinsic,target:a.target}])),m=t(o,p,h,f,i),u={},x=st(s,u,o),d={};for(let a of s.functions)c.has(a.ret)&&(d[a.js_name]={cls:u[a.ret],isAsync:a.is_async,rustName:a.rust_name});let l=e(m,o,x,d),y=new Map((s.constants??[]).map(a=>[a.js_name,a.value]));return y.size===0?l:new Proxy(l,{get(a,S,gn){return typeof S=="string"&&y.has(S)?y.get(S):Reflect.get(a,S,gn)},has(a,S){return typeof S=="string"&&y.has(S)?!0:Reflect.has(a,S)}})}var Fe="__copilotRuntimeAddon__";function at(){let e=globalThis,n=e[Fe];return n||(n={addon:null},e[Fe]=n),n}function ct(){let e=at();if(e.addon)return e.addon;if(rt()){A.debug("[nativeRuntime] out-of-process mode: skipping the in-process runtime .node; all native calls are remoted to the Rust provider");let r=it();return e.addon=r,r}A.debug("[nativeRuntime] in-process mode: loading the native runtime .node addon into this process");let n=Y.dirname(zn(import.meta.url)),t=U("runtime",[n,Y.resolve(n,".."),Y.resolve(n,"..","..","native","runtime")]);return e.addon=t,t}var M;function ut(e,n,t){e.authInitializeProcessUserAgent?.(t);let r=n.COPILOT_DEBUG_ENTRA_BROKER_URL?.trim()||void 0;delete n.COPILOT_DEBUG_ENTRA_BROKER_URL,e.authInitializeDebugEntraBrokerUrl?.(r)}function L(){return M||(M=ct(),ut(M,process.env,process.version)),M}var Be="\0__copilot_git_structured_error__\0",je="__copilot_session_fs_error:";function lt(e){if(!(e instanceof Error)||!e.message.startsWith(Be))return e;let n;try{n=JSON.parse(e.message.slice(Be.length))}catch{return e}let t=new Error(typeof n.message=="string"?n.message:"");typeof n.name=="string"&&(t.name=n.name);for(let[r,o]of Object.entries(n))r!=="message"&&r!=="name"&&(t[r]=o);return t}function $e(e){if(!(e instanceof Error)||!e.message.startsWith(je))return e;let n;try{n=JSON.parse(e.message.slice(je.length))}catch{return e}let t=typeof n.code=="string"?n.code:"UNKNOWN",r=typeof n.path=="string"?n.path:"sqliteQuery",o=typeof n.message=="string"&&n.message?`: ${n.message}`:"",s=new Error(`${t}: ${r}${o}`);return s.code=t,s.path=r,s}function P(e){let n=De(e);return n!==e?n:$e(e)}function Ue(e){return e??void 0}function ft(e){class n{inner;constructor(...r){this.inner=new e(...r)}async execute(r,o,s){try{return Ue(await this.inner.execute(r,o,s))}catch(c){throw P(c)}}async batch(r){try{return(await this.inner.batch(r)).map(Ue)}catch(o){throw P(o)}}async transaction(r){try{return await this.inner.transaction(r)}catch(o){throw P(o)}}async getTableNames(){try{return await this.inner.getTableNames()}catch(r){throw P(r)}}async getTableNamesIfExists(){try{return await this.inner.getTableNamesIfExists()}catch(r){throw P(r)}}async getTodoStatus(){try{return await this.inner.getTodoStatus()}catch(r){throw P(r)}}async getCurrentIntent(){try{return await this.inner.getCurrentIntent()}catch(r){throw P(r)}}async closeAll(){try{await this.inner.closeAll()}catch(r){throw P(r)}}}return Object.defineProperty(n,"name",{value:"SessionDatabaseHandle"}),n}function qe(e){return JSON.stringify(e,(n,t)=>typeof t=="number"&&!Number.isFinite(t)?{__copilot_forge_number:String(t)}:t)??"null"}var dt=new Set(["runnerCreateNoopLogger","runnerCreateNoopExec"]);function pt(e){if(typeof e!="object"||e===null||!("__handle"in e)||!("__provider"in e))return e;let n=e,t=Object.create(n);t.__provider=n.__provider,t.__handle=n.__handle;for(let r of Ve)typeof n[r]=="function"&&(t[r]=()=>{});return t}var Me=new WeakMap;function mt(e,n,t){let r=Me.get(e);return r||(r=new Map,Me.set(e,r)),r.has(n)||r.set(n,t()),r.get(n)}function gt(e,n){let t=Reflect.get(e,n);if(typeof t=="function"&&n==="SessionDatabaseHandle")return ft(t);if(typeof t=="function"&&typeof n=="string"&&dt.has(n)){let r=t;return()=>mt(e,n,()=>{let o=r.call(e);return n==="runnerCreateNoopLogger"?pt(o):o})}if(typeof t=="function"&&n==="sessionStoreTrackingPostToolUsePlan"){let r=t;return(o,s,c)=>r.call(e,qe(o),qe(s),c)}if(typeof t=="function"&&typeof n=="string"&&/^git[A-Z]/.test(n)){let r=t;return(...o)=>{let s=r.apply(e,o);return s instanceof Promise?s.catch(c=>{throw lt(c)}):s}}if(typeof t=="function"&&typeof n=="string"&&/^sessionFs[A-Z]/.test(n)){let r=t;return(...o)=>{let s=r.apply(e,o);return s instanceof Promise?s.catch(c=>{throw $e(c)}):s}}return t}var q=new Proxy({},{get:(e,n)=>gt(L(),n),has:(e,n)=>Reflect.has(L(),n),set:(e,n,t)=>Reflect.set(L(),n,t),ownKeys:()=>Reflect.ownKeys(L()),getOwnPropertyDescriptor:(e,n)=>Reflect.getOwnPropertyDescriptor(L(),n),defineProperty:(e,n,t)=>Reflect.defineProperty(L(),n,t)});function $(e){return q.errorFormattingFormatUnknown(e)}import{basename as vt,join as X}from"node:path";var We="0.0.1";import{readdir as ht,access as _t,constants as yt}from"node:fs/promises";import{join as g,basename as Je}from"node:path";import{homedir as W}from"node:os";function Ke(){return process.env.XDG_CACHE_HOME||g(W(),".cache")}function Qe(){if(process.argv.includes("--no-auto-update")||process.argv.includes("--prefer-version"))return!1;let e=process.env.COPILOT_AUTO_UPDATE;return!(e&&e.toLowerCase()==="false")}function ze(){let e=process.argv.indexOf("--prefer-version");if(!(e===-1||e+1>=process.argv.length))return process.argv[e+1]}function bt(){if(process.platform==="darwin")return g(W(),"Library","Caches","copilot");if(process.platform==="win32"){let e=process.env.LOCALAPPDATA||g(W(),".cache");return g(e,"copilot")}return g(Ke(),"copilot")}function Ye(){let e=[];return process.env.COPILOT_PKG_CACHE_HOME&&e.push(g(process.env.COPILOT_PKG_CACHE_HOME,"pkg")),process.env.COPILOT_CACHE_HOME&&e.push(g(process.env.COPILOT_CACHE_HOME,"pkg")),e.push(g(bt(),"pkg")),e.push(g(Ke(),"copilot","pkg")),process.env.COPILOT_HOME&&e.push(g(process.env.COPILOT_HOME,"pkg")),e.push(g(W(),".copilot","pkg")),[...new Set(e)]}function Ge(e){let n=e.match(/^(\d+)\.(\d+)\.(\d+)/);if(n)return[Number(n[1]),Number(n[2]),Number(n[3])]}function wt(e,n){let t=Ge(e),r=Ge(n);if(!t&&!r)return 0;if(!t)return-1;if(!r)return 1;for(let c=0;c<3;c++)if(t[c]!==r[c])return t[c]-r[c];let o=e.includes("-"),s=n.includes("-");return o!==s?o?-1:1:e.localeCompare(n)}async function Xe(e,...n){let t=[];for(let r of n){let o;try{o=await ht(r)}catch{continue}for(let s of o){let c=g(r,s);try{await _t(g(c,e),yt.R_OK),t.push(c)}catch{continue}}}return t.sort((r,o)=>{let s=wt(Je(o),Je(r));return s!==0?s:r.localeCompare(o)}),t}import{join as Ze}from"node:path";function en(){let e=Ce();return Ye().flatMap(n=>[Ze(n,"universal"),Ze(n,e)])}function Rt(){return process.env.COPILOT_CLI_VERSION?process.env.COPILOT_CLI_VERSION:"1.0.81-1"}async function nn(e,n){let t=X(e,"app.js"),r=Rt()===We,o=ze();if(n&&(o||Qe()&&!r)){let s=en(),c=await Xe("app.js",...s);if(o){let p=c.find(h=>vt(h)===o);p?t=X(p,"app.js"):process.stderr.write(`Warning: preferred version ${o} not found in package cache, using built-in version
${c}`)}function Gn(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}}function Ie(e){try{return{ok:!0,value:Kn(e)}}catch(n){return{ok:!1,err:n}}}function Kn(e){return Un($n(import.meta.url))(e)}function De(e){if(!(e instanceof Error))return e;let n=q.sharedApiSqliteNativeErrorPayload(e.message);if(!n)return e;let t=new Error(n.message);return t.code="ERR_SQLITE_ERROR",t.errcode=n.errcode,t.errstr=n.errstr,t}var V="COPILOT_RUNTIME_OOP",Yn=new Set(["NativeRunnerLogger"]),Ve=new Set(["log","debug","info","notice","warning","error","startGroup","endGroup","write"]),O,Xn=new Set(["flush","dispose"]),Zn=new Set(["writeLog"]),He=5e3,et="dispose";function nt(e){let n,t=new Promise(r=>{n=setTimeout(()=>{A.debug(`[nativeRuntime] pipeline drain gave up after ${He}ms; trailing log lines were dropped`),r(void 0)},He),n.unref?.()});return Promise.race([e,t]).finally(()=>{n&&clearTimeout(n)})}function tt(){return typeof __napiOopRequire<"u"&&__napiOopRequire||Qn(import.meta.url)}function rt(){return process.env[V]==="1"||process.env[V]==="true"}var ot;function st(e,n,t){let r=new Set((e.classes??[]).map(s=>s.name)),o={};for(let s of e.classes??[]){let c=s.methods.find(i=>i.js_name==="constructor"),p=c?c.rust_name:`${s.name}.constructor`,h=Yn.has(s.name),f=class{__provider;__handle;constructor(...i){let m=i[i.length-1],u=i.slice(0,i.length-1);this.__provider=m,this.__handle=m.call(p,u),m.trackExternal(this.__handle)}};Object.defineProperty(f,"name",{value:s.name}),f.__fromHandle=function(i,m){let u=Object.create(f.prototype);return u.__provider=i,u.__handle=m,i.trackExternal(m),u};for(let i of s.methods){if(i.js_name==="constructor")continue;let m=r.has(i.ret),u=i.rust_name,x=(d,l)=>m?n[i.ret].__fromHandle(d.__provider,l):l;if(i.is_static){let d=l=>m?n[i.ret].__fromHandle(t,l):l;f[i.js_name]=i.is_async?async(...l)=>d(await t.callAsync(u,l)):(...l)=>d(t.call(u,l));continue}if(i.is_getter){Object.defineProperty(f.prototype,i.js_name,{configurable:!0,get(){return i.is_async?(async()=>x(this,await this.__provider.callAsync(u,[this.__handle])))():x(this,this.__provider.call(u,[this.__handle]))}});continue}if(h&&!i.is_async&&i.ret==="void"&&Ve.has(i.js_name)){f.prototype[i.js_name]=function(...d){let l=this.__provider,y=this.__handle;O=(O??Promise.resolve()).then(async()=>{try{await l.callAsync(u,[y,...d])}catch{}})};continue}if(h&&i.is_async&&Zn.has(i.js_name)){f.prototype[i.js_name]=function(...d){let l=this.__provider,y=this.__handle,a=(O??Promise.resolve()).then(()=>l.callAsync(u,[y,...d]));return O=a.then(()=>{},()=>{}),a.then(()=>{})};continue}if(h&&i.is_async&&Xn.has(i.js_name)){let d=i.js_name===et;f.prototype[i.js_name]=async function(...l){let y=a=>d?nt(a):a;return await y(O??Promise.resolve()),x(this,await y(this.__provider.callAsync(u,[this.__handle,...l])))};continue}f.prototype[i.js_name]=i.is_async?async function(...d){return x(this,await this.__provider.callAsync(u,[this.__handle,...d]))}:function(...d){return x(this,this.__provider.call(u,[this.__handle,...d]))}}o[s.name]=f,n[s.name]=f}return o}function it(){let{bindClasses:e,connectFromEnvSync:n,createSyncBinding:t,SOCKET_ENV:r}=tt()("napi-oop-runtime");if(!process.env[r])throw new Error(`${V} is set but ${r} is not; the out-of-process runtime must be launched by the Rust provider parent, which exports the connect-back socket.`);let o=n();if(ot=o,delete process.env[V],!o.manifest)throw new Error("out-of-process provider did not advertise a surface manifest in its handshake");let s=JSON.parse(o.manifest),c=new Set((s.classes??[]).map(a=>a.name)),p=s.functions.filter(a=>a.is_async).map(a=>a.js_name),h=s.functions.filter(a=>a.ret==="ExternalObject").map(a=>a.js_name),f={};for(let a of s.functions)f[a.js_name]=a.rust_name;let i=Object.fromEntries((s.host_functions??[]).map(a=>[a.js_name,{intrinsic:a.intrinsic,target:a.target}])),m=t(o,p,h,f,i),u={},x=st(s,u,o),d={};for(let a of s.functions)c.has(a.ret)&&(d[a.js_name]={cls:u[a.ret],isAsync:a.is_async,rustName:a.rust_name});let l=e(m,o,x,d),y=new Map((s.constants??[]).map(a=>[a.js_name,a.value]));return y.size===0?l:new Proxy(l,{get(a,S,gn){return typeof S=="string"&&y.has(S)?y.get(S):Reflect.get(a,S,gn)},has(a,S){return typeof S=="string"&&y.has(S)?!0:Reflect.has(a,S)}})}var Fe="__copilotRuntimeAddon__";function at(){let e=globalThis,n=e[Fe];return n||(n={addon:null},e[Fe]=n),n}function ct(){let e=at();if(e.addon)return e.addon;if(rt()){A.debug("[nativeRuntime] out-of-process mode: skipping the in-process runtime .node; all native calls are remoted to the Rust provider");let r=it();return e.addon=r,r}A.debug("[nativeRuntime] in-process mode: loading the native runtime .node addon into this process");let n=Y.dirname(zn(import.meta.url)),t=U("runtime",[n,Y.resolve(n,".."),Y.resolve(n,"..","..","native","runtime")]);return e.addon=t,t}var M;function ut(e,n,t){e.authInitializeProcessUserAgent?.(t);let r=n.COPILOT_DEBUG_ENTRA_BROKER_URL?.trim()||void 0;delete n.COPILOT_DEBUG_ENTRA_BROKER_URL,e.authInitializeDebugEntraBrokerUrl?.(r)}function L(){return M||(M=ct(),ut(M,process.env,process.version)),M}var Be="\0__copilot_git_structured_error__\0",je="__copilot_session_fs_error:";function lt(e){if(!(e instanceof Error)||!e.message.startsWith(Be))return e;let n;try{n=JSON.parse(e.message.slice(Be.length))}catch{return e}let t=new Error(typeof n.message=="string"?n.message:"");typeof n.name=="string"&&(t.name=n.name);for(let[r,o]of Object.entries(n))r!=="message"&&r!=="name"&&(t[r]=o);return t}function $e(e){if(!(e instanceof Error)||!e.message.startsWith(je))return e;let n;try{n=JSON.parse(e.message.slice(je.length))}catch{return e}let t=typeof n.code=="string"?n.code:"UNKNOWN",r=typeof n.path=="string"?n.path:"sqliteQuery",o=typeof n.message=="string"&&n.message?`: ${n.message}`:"",s=new Error(`${t}: ${r}${o}`);return s.code=t,s.path=r,s}function P(e){let n=De(e);return n!==e?n:$e(e)}function Ue(e){return e??void 0}function ft(e){class n{inner;constructor(...r){this.inner=new e(...r)}async execute(r,o,s){try{return Ue(await this.inner.execute(r,o,s))}catch(c){throw P(c)}}async batch(r){try{return(await this.inner.batch(r)).map(Ue)}catch(o){throw P(o)}}async transaction(r){try{return await this.inner.transaction(r)}catch(o){throw P(o)}}async getTableNames(){try{return await this.inner.getTableNames()}catch(r){throw P(r)}}async getTableNamesIfExists(){try{return await this.inner.getTableNamesIfExists()}catch(r){throw P(r)}}async getTodoStatus(){try{return await this.inner.getTodoStatus()}catch(r){throw P(r)}}async getCurrentIntent(){try{return await this.inner.getCurrentIntent()}catch(r){throw P(r)}}async closeAll(){try{await this.inner.closeAll()}catch(r){throw P(r)}}}return Object.defineProperty(n,"name",{value:"SessionDatabaseHandle"}),n}function qe(e){return JSON.stringify(e,(n,t)=>typeof t=="number"&&!Number.isFinite(t)?{__copilot_forge_number:String(t)}:t)??"null"}var dt=new Set(["runnerCreateNoopLogger","runnerCreateNoopExec"]);function pt(e){if(typeof e!="object"||e===null||!("__handle"in e)||!("__provider"in e))return e;let n=e,t=Object.create(n);t.__provider=n.__provider,t.__handle=n.__handle;for(let r of Ve)typeof n[r]=="function"&&(t[r]=()=>{});return t}var Me=new WeakMap;function mt(e,n,t){let r=Me.get(e);return r||(r=new Map,Me.set(e,r)),r.has(n)||r.set(n,t()),r.get(n)}function gt(e,n){let t=Reflect.get(e,n);if(typeof t=="function"&&n==="SessionDatabaseHandle")return ft(t);if(typeof t=="function"&&typeof n=="string"&&dt.has(n)){let r=t;return()=>mt(e,n,()=>{let o=r.call(e);return n==="runnerCreateNoopLogger"?pt(o):o})}if(typeof t=="function"&&n==="sessionStoreTrackingPostToolUsePlan"){let r=t;return(o,s,c)=>r.call(e,qe(o),qe(s),c)}if(typeof t=="function"&&typeof n=="string"&&/^git[A-Z]/.test(n)){let r=t;return(...o)=>{let s=r.apply(e,o);return s instanceof Promise?s.catch(c=>{throw lt(c)}):s}}if(typeof t=="function"&&typeof n=="string"&&/^sessionFs[A-Z]/.test(n)){let r=t;return(...o)=>{let s=r.apply(e,o);return s instanceof Promise?s.catch(c=>{throw $e(c)}):s}}return t}var q=new Proxy({},{get:(e,n)=>gt(L(),n),has:(e,n)=>Reflect.has(L(),n),set:(e,n,t)=>Reflect.set(L(),n,t),ownKeys:()=>Reflect.ownKeys(L()),getOwnPropertyDescriptor:(e,n)=>Reflect.getOwnPropertyDescriptor(L(),n),defineProperty:(e,n,t)=>Reflect.defineProperty(L(),n,t)});function $(e){return q.errorFormattingFormatUnknown(e)}import{basename as vt,join as X}from"node:path";var We="0.0.1";import{readdir as ht,access as _t,constants as yt}from"node:fs/promises";import{join as g,basename as Je}from"node:path";import{homedir as W}from"node:os";function Ke(){return process.env.XDG_CACHE_HOME||g(W(),".cache")}function Qe(){if(process.argv.includes("--no-auto-update")||process.argv.includes("--prefer-version"))return!1;let e=process.env.COPILOT_AUTO_UPDATE;return!(e&&e.toLowerCase()==="false")}function ze(){let e=process.argv.indexOf("--prefer-version");if(!(e===-1||e+1>=process.argv.length))return process.argv[e+1]}function bt(){if(process.platform==="darwin")return g(W(),"Library","Caches","copilot");if(process.platform==="win32"){let e=process.env.LOCALAPPDATA||g(W(),".cache");return g(e,"copilot")}return g(Ke(),"copilot")}function Ye(){let e=[];return process.env.COPILOT_PKG_CACHE_HOME&&e.push(g(process.env.COPILOT_PKG_CACHE_HOME,"pkg")),process.env.COPILOT_CACHE_HOME&&e.push(g(process.env.COPILOT_CACHE_HOME,"pkg")),e.push(g(bt(),"pkg")),e.push(g(Ke(),"copilot","pkg")),process.env.COPILOT_HOME&&e.push(g(process.env.COPILOT_HOME,"pkg")),e.push(g(W(),".copilot","pkg")),[...new Set(e)]}function Ge(e){let n=e.match(/^(\d+)\.(\d+)\.(\d+)/);if(n)return[Number(n[1]),Number(n[2]),Number(n[3])]}function wt(e,n){let t=Ge(e),r=Ge(n);if(!t&&!r)return 0;if(!t)return-1;if(!r)return 1;for(let c=0;c<3;c++)if(t[c]!==r[c])return t[c]-r[c];let o=e.includes("-"),s=n.includes("-");return o!==s?o?-1:1:e.localeCompare(n)}async function Xe(e,...n){let t=[];for(let r of n){let o;try{o=await ht(r)}catch{continue}for(let s of o){let c=g(r,s);try{await _t(g(c,e),yt.R_OK),t.push(c)}catch{continue}}}return t.sort((r,o)=>{let s=wt(Je(o),Je(r));return s!==0?s:r.localeCompare(o)}),t}import{join as Ze}from"node:path";function en(){let e=Ce();return Ye().flatMap(n=>[Ze(n,"universal"),Ze(n,e)])}function Rt(){return process.env.COPILOT_CLI_VERSION?process.env.COPILOT_CLI_VERSION:"1.0.81-2"}async function nn(e,n){let t=X(e,"app.js"),r=Rt()===We,o=ze();if(n&&(o||Qe()&&!r)){let s=en(),c=await Xe("app.js",...s);if(o){let p=c.find(h=>vt(h)===o);p?t=X(p,"app.js"):process.stderr.write(`Warning: preferred version ${o} not found in package cache, using built-in version
`)}else c.length>0&&(t=X(c[0],"app.js"))}return t}import rn from"node:path";import{fileURLToPath as St}from"node:url";var C,tn=rn.dirname(St(import.meta.url));function on(){if(C){if(C.kind==="ok")return C.addon;throw C.error}try{let e=U("cli-native",[tn,rn.resolve(tn,"..","native","cli")]);return C={kind:"ok",addon:e},e}catch(e){let n=e instanceof Error?e:new Error(`Failed to load cli-native addon: ${$(e)}`);throw C={kind:"error",error:n},n}}function J(){if(process.platform==="win32")return on()}var sn=Symbol.for("github.copilot.cli.cleanExit");function Et(){let e=Reflect.get(process,"exit");if(typeof e!="function")return;let n=Reflect.get(e,sn);return typeof n=="function"?n:void 0}function Pt(){let e;if(process.platform==="win32")try{e=J()}catch{e=void 0}let n=!1;return()=>{if(!n){n=!0;try{process.report.reportOnFatalError=!1}catch{}if(e){try{e.uninstallExceptionFilter()}catch{}try{e.disableCrashReporting()}catch{}}}}}function an(){let e=Et();if(e)return e;let n=process.exit.bind(process),t=Pt(),r=(...c)=>(t(),n(...c));process.once("exit",t);let o=!0,s=()=>{o&&(o=!1,process.exit===r&&(process.exit=n),process.removeListener("exit",t))};return Reflect.defineProperty(r,sn,{value:s}),process.exit=r,s}import{existsSync as xt}from"node:fs";import{basename as kt,resolve as Nt}from"node:path";var cn="extension_bootstrap.mjs";function un(e,n,t=xt){let r=e.find(c=>kt(c)===cn);if(!r)return;process.stderr.write(`[extension-fork] resolveBootstrapPath: __dir=${n}, argv-bootstrap=${r}

@@ -14,0 +14,0 @@ `);let o=Nt(n,"preloads",cn),s=t(o);if(process.stderr.write(`[extension-fork] resolveBootstrapPath: localBootstrap=${o}, localExists=${s}

{
"name": "@github/copilot-linux-arm64",
"version": "1.0.81-1",
"version": "1.0.81-2",
"description": "GitHub Copilot CLI for linux-arm64",

@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE.md",

@@ -1,2 +0,2 @@

(()=>{const stack=new Error().stack;stack&&(globalThis._sentryDebugIds=globalThis._sentryDebugIds||{},globalThis._sentryDebugIds[stack]="c047a240-6749-5a04-b7c9-a538e79ba0db",globalThis._sentryDebugIdIdentifier="sentry-dbid-c047a240-6749-5a04-b7c9-a538e79ba0db");})();
(()=>{const stack=new Error().stack;stack&&(globalThis._sentryDebugIds=globalThis._sentryDebugIds||{},globalThis._sentryDebugIds[stack]="88f35ad5-de43-51c5-a097-f4ce5cdd4cb8",globalThis._sentryDebugIdIdentifier="sentry-dbid-88f35ad5-de43-51c5-a097-f4ce5cdd4cb8");})();

@@ -11,9 +11,5 @@ /*---------------------------------------------------------------------------------------------

const __appPath = __fs.realpathSync(import.meta.dirname);
const __clipboardEntrypoint = __path.join(__appPath, "clipboard", "index.js");
const __foundryEntrypoint = __path.join(__appPath, "foundry-local-sdk", "index.js");
const __pvRecorderEntrypoint = __path.join(__appPath, "pvrecorder", "index.js");
const __napiOopEntrypoint = __path.join(__appPath, "napi-oop-runtime", "index.js");
const __clipboardRequire = __fs.existsSync(__clipboardEntrypoint)
? __module.createRequire(__clipboardEntrypoint)
: __rootRequire;
const __foundryRequire = __fs.existsSync(__foundryEntrypoint)

@@ -30,8 +26,5 @@ ? __module.createRequire(__foundryEntrypoint)

typeof module === "string" &&
(module.startsWith("@teddyzhu/") || module === "foundry-local-sdk" || module === "@picovoice/pvrecorder-node" || module === "napi-oop-runtime");
(module === "foundry-local-sdk" || module === "@picovoice/pvrecorder-node" || module === "napi-oop-runtime");
const require = (module) => {
let req = __rootRequire;
if (typeof module === "string" && module.startsWith("@teddyzhu/")) {
req = __clipboardRequire;
}
if (module === "foundry-local-sdk") {

@@ -38,0 +31,0 @@ req = __foundryRequire;

Sorry, the diff of this file is not supported yet

/* auto-generated by NAPI-RS */
/* eslint-disable */
/**
* 剪贴板监听器实例,用于监听剪贴板变化并支持停止
* 支持自动检测环境:在 Wayland 环境下使用 Wayland 专用监听器,否则使用通用监听器
* 使用方法:
* ```javascript
* const { ClipboardListener } = require('./index.node');
* const listener = new ClipboardListener();
* listener.watch((data) => {
* console.log('剪贴板数据变化:', data);
* console.log('可用格式:', data.available_formats);
* if (data.text) console.log('文本:', data.text);
* if (data.html) console.log('HTML:', data.html);
* if (data.rtf) console.log('RTF:', data.rtf);
* if (data.image) console.log('图片 (base64):', data.image.substring(0, 50) + '...');
* if (data.files) console.log('文件:', data.files);
* if (data.other) console.log('其他格式:', data.other);
* });
* // 停止监听
* listener.stop();
* ```
*/
export declare class ClipboardListener {
/**
* 创建新的剪贴板监听器实例
* 自动检测当前环境类型(Wayland 或其他)
*/
constructor()
/**
* 开始监听剪贴板变化
* callback: 当剪贴板变化时调用的回调函数,参数为包含所有格式数据的复杂对象
* 自动根据当前环境选择合适的监听方式(Wayland 或通用)
*/
watch(callback: (arg: ClipboardData) => void): void
/** 停止监听剪贴板变化 */
stop(): void
/** 检查是否正在监听 */
isWatching(): boolean
/** 获取当前使用的监听器类型 */
getListenerType(): string
}
/** 剪贴板管理器,提供跨平台的剪贴板操作功能 */
export declare class ClipboardManager {
/** 创建新的剪贴板管理器实例 */
constructor()
/** 获取剪贴板中的纯文本内容 */
getText(): string
/** 设置剪贴板中的纯文本内容 */
setText(text: string): void
/** 获取剪贴板中的 HTML 内容 */
getHtml(): string
/** 设置剪贴板中的 HTML 内容 */
setHtml(html: string): void
/** 获取剪贴板中的富文本内容 */
getRichText(): string
/** 设置剪贴板中的富文本内容 */
setRichText(text: string): void
/** 获取剪贴板中的图片数据(以 base64 编码返回) */
getImageBase64(): string
/** 获取剪贴板中的图片详细信息(包含宽度、高度、大小和原始数据) */
getImageData(): ImageData
/** 从 base64 编码的图片数据设置剪贴板图片 */
setImageBase64(base64Data: string): void
/** 从原始字节数据设置剪贴板图片 */
setImageRaw(imageData: Buffer): void
/** 获取剪贴板中的图片原始数据(Buffer) */
getImageRaw(): Buffer
/** 获取剪贴板中的文件列表 */
getFiles(): Array<string>
/** 设置剪贴板中的文件列表 */
setFiles(files: Array<string>): void
/** 设置剪贴板中的自定义格式数据 */
setBuffer(format: string, buffer: Buffer): void
/** 获取剪贴板中的自定义格式数据 */
getBuffer(format: string): Buffer
/** 设置剪贴板中的复合内容(可同时设置多种格式) */
setContents(contents: ClipboardData): void
/** 检查剪贴板是否包含指定格式的内容 */
hasFormat(format: string): boolean
/** 获取剪贴板中所有可用的格式 */
getAvailableFormats(): Array<string>
/** 清空剪贴板 */
clear(): void
/** 异步获取剪贴板文本内容 */
getTextAsync(): Promise<string>
/** 异步设置剪贴板文本内容 */
setTextAsync(text: string): Promise<void>
/** 异步获取剪贴板图片数据(以 base64 编码返回) */
getImageBase64Async(): Promise<string>
/** 异步获取剪贴板图片详细信息(包含宽度、高度、大小和原始数据) */
getImageDataAsync(): Promise<ImageData>
}
/** 快速清空剪贴板 */
export declare function clearClipboard(): void
/** 剪贴板数据结构,包含所有可用格式的数据 */
export interface ClipboardData {
/** 可用的格式列表 */
availableFormats: Array<string>
/** 纯文本内容 */
text?: string
/** RTF 富文本内容 */
rtf?: string
/** HTML 内容 */
html?: string
/** 图片数据 */
image?: ImageData
/** 文件列表 */
files?: Array<string>
}
/** 快速获取剪贴板自定义格式数据 */
export declare function getClipboardBuffer(format: string): Buffer
/** 快速获取剪贴板文件列表 */
export declare function getClipboardFiles(): Array<string>
/** 快速获取剪贴板 HTML 内容 */
export declare function getClipboardHtml(): string
/** 快速获取剪贴板图片(base64 编码) */
export declare function getClipboardImage(): string
/** 快速获取剪贴板图片详细信息(包含宽度、高度、大小和原始数据) */
export declare function getClipboardImageData(): ImageData
/** 快速获取剪贴板图片原始数据(Buffer) */
export declare function getClipboardImageRaw(): Buffer
/** 快速获取剪贴板文本内容 */
export declare function getClipboardText(): string
/** 快速获取完整的剪贴板数据 */
export declare function getFullClipboardData(): ClipboardData
/** 图片数据结构,包含图片的详细信息 */
export interface ImageData {
/** 图片宽度(像素) */
width: number
/** 图片高度(像素) */
height: number
/** 图片数据大小(字节) */
size: number
/** 图片原始数据(Buffer) */
data: Buffer
}
/**
* 检测 Wayland 剪贴板监听是否可用
*
* 返回 true 表示当前环境支持 Wayland 剪贴板监听
*/
export declare function isWaylandClipboardAvailable(): boolean
/** 快速设置剪贴板自定义格式数据 */
export declare function setClipboardBuffer(format: string, buffer: Buffer): void
/** 快速设置剪贴板复合内容(可同时设置多种格式) */
export declare function setClipboardContents(contents: ClipboardData): void
/** 快速设置剪贴板文件列表 */
export declare function setClipboardFiles(files: Array<string>): void
/** 快速设置剪贴板 HTML 内容 */
export declare function setClipboardHtml(html: string): void
/** 快速设置剪贴板图片(从 base64 编码) */
export declare function setClipboardImage(base64Data: string): void
/** 快速设置剪贴板图片(从原始字节数据) */
export declare function setClipboardImageRaw(imageData: Buffer): void
/** 快速设置剪贴板文本内容 */
export declare function setClipboardText(text: string): void
// prettier-ignore
/* eslint-disable */
// @ts-nocheck
/* auto-generated by NAPI-RS */
const { readFileSync } = require('node:fs')
let nativeBinding = null
const loadErrors = []
const isMusl = () => {
let musl = false
if (process.platform === 'linux') {
musl = isMuslFromFilesystem()
if (musl === null) {
musl = isMuslFromReport()
}
if (musl === null) {
musl = isMuslFromChildProcess()
}
}
return musl
}
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
}
}
const isMuslFromReport = () => {
let report = null
if (typeof process.report?.getReport === 'function') {
process.report.excludeNetwork = true
report = process.report.getReport()
}
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
}
return false
}
const isMuslFromChildProcess = () => {
try {
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
} catch (e) {
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
}
}
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
try {
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
} catch (err) {
loadErrors.push(err)
}
} else if (process.platform === 'android') {
if (process.arch === 'arm64') {
try {
return require('./clipboard.android-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-android-arm64')
const bindingPackageVersion = require('@teddyzhu/clipboard-android-arm64/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./clipboard.android-arm-eabi.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-android-arm-eabi')
const bindingPackageVersion = require('@teddyzhu/clipboard-android-arm-eabi/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
}
} else if (process.platform === 'win32') {
if (process.arch === 'x64') {
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
try {
return require('./clipboard.win32-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-win32-x64-gnu')
const bindingPackageVersion = require('@teddyzhu/clipboard-win32-x64-gnu/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./clipboard.win32-x64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-win32-x64-msvc')
const bindingPackageVersion = require('@teddyzhu/clipboard-win32-x64-msvc/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ia32') {
try {
return require('./clipboard.win32-ia32-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-win32-ia32-msvc')
const bindingPackageVersion = require('@teddyzhu/clipboard-win32-ia32-msvc/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./clipboard.win32-arm64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-win32-arm64-msvc')
const bindingPackageVersion = require('@teddyzhu/clipboard-win32-arm64-msvc/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
}
} else if (process.platform === 'darwin') {
try {
return require('./clipboard.darwin-universal.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-darwin-universal')
const bindingPackageVersion = require('@teddyzhu/clipboard-darwin-universal/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
if (process.arch === 'x64') {
try {
return require('./clipboard.darwin-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-darwin-x64')
const bindingPackageVersion = require('@teddyzhu/clipboard-darwin-x64/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./clipboard.darwin-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-darwin-arm64')
const bindingPackageVersion = require('@teddyzhu/clipboard-darwin-arm64/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
}
} else if (process.platform === 'freebsd') {
if (process.arch === 'x64') {
try {
return require('./clipboard.freebsd-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-freebsd-x64')
const bindingPackageVersion = require('@teddyzhu/clipboard-freebsd-x64/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./clipboard.freebsd-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-freebsd-arm64')
const bindingPackageVersion = require('@teddyzhu/clipboard-freebsd-arm64/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
}
} else if (process.platform === 'linux') {
if (process.arch === 'x64') {
if (isMusl()) {
try {
return require('./clipboard.linux-x64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-x64-musl')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-x64-musl/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./clipboard.linux-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-x64-gnu')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-x64-gnu/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm64') {
if (isMusl()) {
try {
return require('./clipboard.linux-arm64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-arm64-musl')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-arm64-musl/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./clipboard.linux-arm64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-arm64-gnu')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-arm64-gnu/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm') {
if (isMusl()) {
try {
return require('./clipboard.linux-arm-musleabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-arm-musleabihf')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-arm-musleabihf/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./clipboard.linux-arm-gnueabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-arm-gnueabihf')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-arm-gnueabihf/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'loong64') {
if (isMusl()) {
try {
return require('./clipboard.linux-loong64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-loong64-musl')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-loong64-musl/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./clipboard.linux-loong64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-loong64-gnu')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-loong64-gnu/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'riscv64') {
if (isMusl()) {
try {
return require('./clipboard.linux-riscv64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-riscv64-musl')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-riscv64-musl/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./clipboard.linux-riscv64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-riscv64-gnu')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-riscv64-gnu/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ppc64') {
try {
return require('./clipboard.linux-ppc64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-ppc64-gnu')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-ppc64-gnu/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 's390x') {
try {
return require('./clipboard.linux-s390x-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-linux-s390x-gnu')
const bindingPackageVersion = require('@teddyzhu/clipboard-linux-s390x-gnu/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
}
} else if (process.platform === 'openharmony') {
if (process.arch === 'arm64') {
try {
return require('./clipboard.openharmony-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-openharmony-arm64')
const bindingPackageVersion = require('@teddyzhu/clipboard-openharmony-arm64/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'x64') {
try {
return require('./clipboard.openharmony-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-openharmony-x64')
const bindingPackageVersion = require('@teddyzhu/clipboard-openharmony-x64/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./clipboard.openharmony-arm.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@teddyzhu/clipboard-openharmony-arm')
const bindingPackageVersion = require('@teddyzhu/clipboard-openharmony-arm/package.json').version
if (bindingPackageVersion !== '0.0.9' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.0.9 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
}
} else {
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
}
}
nativeBinding = requireNative()
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
let wasiBinding = null
let wasiBindingError = null
try {
wasiBinding = require('./clipboard.wasi.cjs')
nativeBinding = wasiBinding
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
wasiBindingError = err
}
}
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
try {
wasiBinding = require('@teddyzhu/clipboard-wasm32-wasi')
nativeBinding = wasiBinding
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
if (!wasiBindingError) {
wasiBindingError = err
} else {
wasiBindingError.cause = err
}
loadErrors.push(err)
}
}
}
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
error.cause = wasiBindingError
throw error
}
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
throw new Error(
`Cannot find native binding. ` +
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
{
cause: loadErrors.reduce((err, cur) => {
cur.cause = err
return cur
}),
},
)
}
throw new Error(`Failed to load native binding`)
}
module.exports = nativeBinding
module.exports.ClipboardListener = nativeBinding.ClipboardListener
module.exports.ClipboardManager = nativeBinding.ClipboardManager
module.exports.clearClipboard = nativeBinding.clearClipboard
module.exports.getClipboardBuffer = nativeBinding.getClipboardBuffer
module.exports.getClipboardFiles = nativeBinding.getClipboardFiles
module.exports.getClipboardHtml = nativeBinding.getClipboardHtml
module.exports.getClipboardImage = nativeBinding.getClipboardImage
module.exports.getClipboardImageData = nativeBinding.getClipboardImageData
module.exports.getClipboardImageRaw = nativeBinding.getClipboardImageRaw
module.exports.getClipboardText = nativeBinding.getClipboardText
module.exports.getFullClipboardData = nativeBinding.getFullClipboardData
module.exports.isWaylandClipboardAvailable = nativeBinding.isWaylandClipboardAvailable
module.exports.setClipboardBuffer = nativeBinding.setClipboardBuffer
module.exports.setClipboardContents = nativeBinding.setClipboardContents
module.exports.setClipboardFiles = nativeBinding.setClipboardFiles
module.exports.setClipboardHtml = nativeBinding.setClipboardHtml
module.exports.setClipboardImage = nativeBinding.setClipboardImage
module.exports.setClipboardImageRaw = nativeBinding.setClipboardImageRaw
module.exports.setClipboardText = nativeBinding.setClipboardText
MIT License
Copyright (c) 2020 N-API for Rust
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{
"name": "@teddyzhu/clipboard",
"version": "0.0.10",
"description": "it's a node package with napi-rs wrapper clipboard-rs",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/Teddy-Zhu/node-clipboard-rs.git"
},
"license": "MIT",
"keywords": [
"napi-rs",
"NAPI",
"N-API",
"Rust",
"node-addon",
"node-addon-api"
],
"files": [
"index.d.ts",
"index.js",
"*.node"
],
"napi": {
"binaryName": "clipboard",
"targets": [
"x86_64-pc-windows-msvc",
"x86_64-apple-darwin",
"x86_64-unknown-linux-gnu",
"aarch64-unknown-linux-gnu",
"aarch64-apple-darwin",
"aarch64-pc-windows-msvc"
]
},
"engines": {
"node": ">= 10.16.0 < 11 || >= 11.8.0 < 12 || >= 12.0.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"scripts": {
"artifacts": "napi artifacts",
"bench": "node --import @oxc-node/core/register benchmark/bench.ts",
"build": "napi build --platform --release",
"build:debug": "napi build --platform",
"format": "run-p format:prettier format:rs format:toml",
"format:prettier": "prettier . -w",
"format:toml": "taplo format",
"format:rs": "cargo fmt",
"lint": "oxlint .",
"prepublishOnly": "napi pre-publish -t npm",
"test": "ava",
"version": "napi version",
"prepare": "husky"
},
"devDependencies": {
"@emnapi/core": "^1.4.3",
"@emnapi/runtime": "^1.4.3",
"@napi-rs/cli": "^3.0.0",
"@oxc-node/core": "^0.0.29",
"@taplo/cli": "^0.7.0",
"@tybys/wasm-util": "^0.10.0",
"@types/node": "^24.1.0",
"ava": "^6.4.0",
"chalk": "^5.4.1",
"husky": "^9.1.7",
"lint-staged": "^16.1.2",
"npm-run-all2": "^8.0.4",
"oxlint": "^1.3.0",
"prettier": "^3.6.0",
"tinybench": "^4.0.1",
"typescript": "^5.8.3"
},
"lint-staged": {
"*.@(js|ts|tsx)": [
"oxlint --fix"
],
"*.@(js|ts|tsx|yml|yaml|md|json)": [
"prettier --write"
],
"*.toml": [
"taplo format"
]
},
"ava": {
"extensions": {
"ts": "module"
},
"timeout": "2m",
"workerThreads": false,
"environmentVariables": {
"OXC_TSCONFIG_PATH": "./__test__/tsconfig.json"
},
"nodeArguments": [
"--import",
"@oxc-node/core/register"
]
},
"prettier": {
"printWidth": 120,
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"arrowParens": "always"
},
"optionalDependencies": {
"@teddyzhu/clipboard-win32-x64-msvc": "0.0.10",
"@teddyzhu/clipboard-darwin-x64": "0.0.10",
"@teddyzhu/clipboard-linux-x64-gnu": "0.0.10",
"@teddyzhu/clipboard-linux-arm64-gnu": "0.0.10",
"@teddyzhu/clipboard-darwin-arm64": "0.0.10",
"@teddyzhu/clipboard-win32-arm64-msvc": "0.0.10"
},
"packageManager": "pnpm@10.28.2+sha512.41872f037ad22f7348e3b1debbaf7e867cfd448f2726d9cf74c08f19507c31d2c8e7a11525b983febc2df640b5438dee6023ebb1f84ed43cc2d654d2bc326264"
}
# `@teddyzhu/clipboard`
![https://github.com/Teddy-Zhu/node-clipboard-rs/actions](https://github.com/Teddy-Zhu/node-clipboard-rs/workflows/CI/badge.svg)
> 基于 napi-rs 包装 clipboard-rs/wl-clipboard-rs 的 Node.js 剪贴板库,提供跨平台剪贴板操作功能
## 特性
- 🚀 跨平台支持(Windows、macOS、Linux)
- 📝 支持多种数据格式:文本、HTML、 RTF、图片、文件列表
- 🖼️ 完整的图片处理支持(PNG、JPEG、GIF、BMP)
- 👂 剪贴板实时监听功能
- 🐧 Linux Wayland 环境原生支持
- ⚡ 同步和异步 API
- 🎯 TypeScript 类型定义
## 安装
```bash
npm install @teddyzhu/clipboard
```
## 基本使用
### 剪贴板管理器
```javascript
const { ClipboardManager } = require('@teddyzhu/clipboard')
const clipboard = new ClipboardManager()
// 文本操作
clipboard.setText('Hello World!')
console.log(clipboard.getText()) // "Hello World!"
// HTML 操作
clipboard.setHtml('<h1>Hello HTML</h1>')
console.log(clipboard.getHtml())
// 富文本(RTF)操作
clipboard.setRichText('Hello RTF')
console.log(clipboard.getRichText())
// 检查格式支持
console.log(clipboard.hasFormat('text')) // true
console.log(clipboard.getAvailableFormats()) // ['text', 'html', ...]
// 清空剪贴板
clipboard.clear()
```
### 快速操作函数
```javascript
const {
getClipboardText,
setClipboardText,
getClipboardHtml,
setClipboardHtml,
clearClipboard,
getFullClipboardData,
} = require('@teddyzhu/clipboard')
// 快速文本操作
setClipboardText('Hello World!')
console.log(getClipboardText())
// 快速 HTML 操作
setClipboardHtml('<p>Hello HTML</p>')
console.log(getClipboardHtml())
// 获取完整剪贴板数据
const data = getFullClipboardData()
console.log('可用格式:', data.availableFormats)
console.log('文本内容:', data.text)
console.log('HTML内容:', data.html)
// 清空剪贴板
clearClipboard()
```
## 图片操作
### 基本图片操作
```javascript
const { ClipboardManager, getClipboardImageData } = require('@teddyzhu/clipboard')
const fs = require('fs')
const clipboard = new ClipboardManager()
// 检查是否有图片
if (clipboard.hasFormat('image')) {
// 获取图片详细信息
const imageData = clipboard.getImageData()
console.log('图片宽度:', imageData.width + 'px')
console.log('图片高度:', imageData.height + 'px')
console.log('图片大小:', imageData.size + ' bytes')
// 保存图片到文件
fs.writeFileSync('clipboard_image.png', imageData.data)
// 获取 base64 编码
const base64 = clipboard.getImageBase64()
console.log('Base64 长度:', base64.length)
}
// 从文件设置图片
const imageBuffer = fs.readFileSync('image.png')
clipboard.setImageRaw(imageBuffer)
// 从 base64 设置图片
const base64Data = fs.readFileSync('image.png', 'base64')
clipboard.setImageBase64(base64Data)
// 快速图片操作
const quickImageData = getClipboardImageData()
```
### 异步图片操作
```javascript
const clipboard = new ClipboardManager()
// 异步获取图片
try {
const imageData = await clipboard.getImageDataAsync()
console.log('异步获取图片:', imageData.width + 'x' + imageData.height)
const base64 = await clipboard.getImageBase64Async()
console.log('异步获取 Base64 长度:', base64.length)
} catch (error) {
console.error('获取图片失败:', error.message)
}
// 异步文本操作
await clipboard.setTextAsync('Hello Async!')
const text = await clipboard.getTextAsync()
console.log('异步文本:', text)
```
## 文件操作
```javascript
const { ClipboardManager, getClipboardFiles, setClipboardFiles } = require('@teddyzhu/clipboard')
const clipboard = new ClipboardManager()
// 设置文件列表
const files = ['/path/to/file1.txt', '/path/to/file2.pdf']
clipboard.setFiles(files)
// 获取文件列表
if (clipboard.hasFormat('files')) {
const clipboardFiles = clipboard.getFiles()
console.log('剪贴板中的文件:', clipboardFiles)
}
// 快速文件操作
setClipboardFiles(['/path/to/document.pdf'])
const quickFiles = getClipboardFiles()
console.log('快速获取文件:', quickFiles)
```
## 自定义格式数据
```javascript
const clipboard = new ClipboardManager()
// 设置自定义格式数据
const customData = Buffer.from('custom binary data')
clipboard.setBuffer('application/custom', customData)
// 获取自定义格式数据
try {
const data = clipboard.getBuffer('application/custom')
console.log('自定义数据:', data.toString())
} catch (error) {
console.error('自定义格式不存在')
}
```
## 复合内容操作
```javascript
const { ClipboardManager, setClipboardContents } = require('@teddyzhu/clipboard')
const clipboard = new ClipboardManager()
// 同时设置多种格式
const contents = {
text: 'Hello World!',
html: '<h1>Hello HTML</h1>',
rtf: 'Hello RTF',
// 可选:图片数据
// image: { width: 100, height: 100, size: 1000, data: imageBuffer },
// 可选:文件列表
// files: ['/path/to/file.txt']
}
clipboard.setContents(contents)
// 快速设置复合内容
setClipboardContents({
text: 'Multi-format content',
html: '<p>Multi-format <strong>content</strong></p>',
})
```
## 剪贴板监听
### 基本监听
```javascript
const { ClipboardListener } = require('@teddyzhu/clipboard')
const listener = new ClipboardListener()
listener.watch((data) => {
console.log('剪贴板数据变化:', data)
console.log('可用格式:', data.availableFormats)
if (data.text) {
console.log('文本:', data.text)
}
if (data.html) {
console.log('HTML:', data.html)
}
if (data.rtf) {
console.log('RTF:', data.rtf)
}
if (data.image) {
console.log('图片信息:')
console.log(' 尺寸:', data.image.width + 'x' + data.image.height + 'px')
console.log(' 大小:', data.image.size + ' bytes')
// 注意:图片数据在 data.image.data (Buffer) 中,不是 base64Data
console.log(' 数据类型:', Buffer.isBuffer(data.image.data) ? 'Buffer' : typeof data.image.data)
}
if (data.files) {
console.log('文件:', data.files)
}
})
// 检查监听状态
console.log('是否正在监听:', listener.isWatching())
console.log('监听器类型:', listener.getListenerType()) // 'wayland' 或 'generic'
// 停止监听
setTimeout(() => {
listener.stop()
console.log('已停止监听')
}, 10000)
```
## Wayland 支持
本库对 Linux Wayland 环境提供原生支持:
```javascript
const { isWaylandClipboardAvailable, ClipboardListener } = require('@teddyzhu/clipboard')
// 检查 Wayland 剪贴板是否可用
if (isWaylandClipboardAvailable()) {
console.log('Wayland 剪贴板监听可用')
const listener = new ClipboardListener()
console.log('当前监听器类型:', listener.getListenerType()) // 在 Wayland 下会显示 'wayland'
// Wayland 监听器会自动处理不同的 MIME 类型
listener.watch((data) => {
console.log('Wayland 剪贴板变化:', data)
})
} else {
console.log('使用通用剪贴板监听器')
}
```
## API 参考
### ClipboardManager 类
| 方法 | 描述 |
| ---------------------------- | -------------------------------------- |
| `getText()` | 获取纯文本内容 |
| `setText(text)` | 设置纯文本内容 |
| `getHtml()` | 获取 HTML 内容 |
| `setHtml(html)` | 设置 HTML 内容 |
| `getRichText()` | 获取 RTF 富文本内容 |
| `setRichText(text)` | 设置 RTF 富文本内容 |
| `getImageBase64()` | 获取图片的 base64 编码 |
| `getImageData()` | 获取图片详细信息(包含尺寸和原始数据) |
| `setImageBase64(base64Data)` | 从 base64 设置图片 |
| `setImageRaw(buffer)` | 从 Buffer 设置图片 |
| `getImageRaw()` | 获取图片原始数据(Buffer) |
| `getFiles()` | 获取文件列表 |
| `setFiles(files)` | 设置文件列表 |
| `setBuffer(format, buffer)` | 设置自定义格式数据 |
| `getBuffer(format)` | 获取自定义格式数据 |
| `setContents(contents)` | 设置复合内容 |
| `hasFormat(format)` | 检查是否包含指定格式 |
| `getAvailableFormats()` | 获取所有可用格式 |
| `clear()` | 清空剪贴板 |
### 异步方法
| 方法 | 描述 |
| ----------------------- | -------------------- |
| `getTextAsync()` | 异步获取文本内容 |
| `setTextAsync(text)` | 异步设置文本内容 |
| `getImageBase64Async()` | 异步获取图片 base64 |
| `getImageDataAsync()` | 异步获取图片详细信息 |
### ClipboardListener 类
| 方法 | 描述 |
| ------------------- | ---------------------------------------- |
| `watch(callback)` | 开始监听剪贴板变化 |
| `stop()` | 停止监听 |
| `isWatching()` | 检查是否正在监听 |
| `getListenerType()` | 获取监听器类型('wayland' 或 'generic') |
### 快速操作函数
| 函数 | 描述 |
| ------------------------------------ | --------------------------- |
| `getClipboardText()` | 快速获取文本 |
| `setClipboardText(text)` | 快速设置文本 |
| `getClipboardHtml()` | 快速获取 HTML |
| `setClipboardHtml(html)` | 快速设置 HTML |
| `getClipboardImage()` | 快速获取图片(base64) |
| `getClipboardImageData()` | 快速获取图片详细信息 |
| `setClipboardImage(base64Data)` | 快速设置图片(base64) |
| `setClipboardImageRaw(buffer)` | 快速设置图片(Buffer) |
| `getClipboardImageRaw()` | 快速获取图片原始数据 |
| `getClipboardFiles()` | 快速获取文件列表 |
| `setClipboardFiles(files)` | 快速设置文件列表 |
| `getClipboardBuffer(format)` | 快速获取自定义格式数据 |
| `setClipboardBuffer(format, buffer)` | 快速设置自定义格式数据 |
| `setClipboardContents(contents)` | 快速设置复合内容 |
| `getFullClipboardData()` | 快速获取完整剪贴板数据 |
| `clearClipboard()` | 快速清空剪贴板 |
| `isWaylandClipboardAvailable()` | 检查 Wayland 剪贴板是否可用 |
## 数据结构
### ClipboardData
```typescript
interface ClipboardData {
availableFormats: string[] // 可用的格式列表
text?: string // 纯文本内容
rtf?: string // RTF 富文本内容
html?: string // HTML 内容
image?: ImageData // 图片数据
files?: string[] // 文件列表
}
```
### ImageData
```typescript
interface ImageData {
width: number // 图片宽度(像素)
height: number // 图片高度(像素)
size: number // 图片数据大小(字节)
data: Buffer // 图片原始数据(Buffer)
}
```
## 注意事项
1. **图片格式**:所有图片都会转换为 PNG 格式存储
2. **文件路径**:文件路径需要是绝对路径
3. **自定义格式**:自定义格式的 MIME 类型需要遵循标准
4. **Wayland 支持**:在 Wayland 环境下会自动使用专用监听器以获得更好的性能
5. **异步操作**:对于可能耗时的操作,推荐使用异步版本
6. **错误处理**:所有方法都可能抛出异常,请适当处理错误
## 许可证
MIT

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display