@longzai-intelligence-electron/core 0.0.5 → 0.0.7

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/preload.d.ts CHANGED
@@ -600,4 +600,18 @@ type ExposeSafeAPIOptions = {
600
600
  */
601
601
  declare function exposeSafeAPI(options: ExposeSafeAPIOptions): void;
602
602
  //#endregion
603
- export { type ExtractMethodName, type IPCAPIToFunctions, type IPCAPIToShortAPI, type IPCAPIWithMapping, type IPCError, IPCErrorCodeSchema, IPCErrorSchema, type IPCError$1 as IPCErrorZod, type IPCEventListener, type IPCMethodDefinition, type IPCMethodDefinition$1 as IPCMethodDefinitionZod, type IPCParams, type IPCParamsArray, type IPCResult, IPCResultSchema, type IPCResult$1 as IPCResultZod, type IPCReturn, type IPCSerializable, type OutputValidatorFn, type StrictIPCAPI, type TypedAPI, type TypedAPIFunction, type TypedAPIObject, type UnsubscribeFunction, type ValidatedZodIPCSchemaResult, type ValidationResult, type ZodAPIFunction, type ZodAPIObject, type ZodAPISchema, type ZodIPCSchemaAPIObject, createErrorResult, createIPCAPISchema, createIPCMethodDefinitionSchema, createIPCResultSchema, createSuccessResult, createTypedAPI, createValidatedAPI, createZodAPI, exposeSafeAPI, invoke, invokeZod, isErrorResult, isSuccessResult, safeInvokeZod, subscribeChannel, subscribeZodChannel, unwrapIPCResult };
603
+ //#region src/preload/drop-path.utils.d.ts
604
+ /**
605
+ * 拖放路径解析桥
606
+ *
607
+ * 封装 Electron `webUtils.getPathForFile` 即拖入文件与目录的真实本地路径解析,仅 preload 环境可用,渲染层经各产品壳薄 preload 转发获得,浏览器形态无路径语义由内容态承接,正本见 architecture 仓 ADR 0173 决策 6
608
+ */
609
+ /**
610
+ * 解析拖拽 File 对象的本地路径
611
+ *
612
+ * @param file - 拖放事件携带的 `File` 对象,目录拖入在 Electron 中同样以 `File` 呈现
613
+ * @returns 真实本地路径,非本地来源返回空串
614
+ */
615
+ declare function resolveDropPath(file: File): string;
616
+ //#endregion
617
+ export { type ExtractMethodName, type IPCAPIToFunctions, type IPCAPIToShortAPI, type IPCAPIWithMapping, type IPCError, IPCErrorCodeSchema, IPCErrorSchema, type IPCError$1 as IPCErrorZod, type IPCEventListener, type IPCMethodDefinition, type IPCMethodDefinition$1 as IPCMethodDefinitionZod, type IPCParams, type IPCParamsArray, type IPCResult, IPCResultSchema, type IPCResult$1 as IPCResultZod, type IPCReturn, type IPCSerializable, type OutputValidatorFn, type StrictIPCAPI, type TypedAPI, type TypedAPIFunction, type TypedAPIObject, type UnsubscribeFunction, type ValidatedZodIPCSchemaResult, type ValidationResult, type ZodAPIFunction, type ZodAPIObject, type ZodAPISchema, type ZodIPCSchemaAPIObject, createErrorResult, createIPCAPISchema, createIPCMethodDefinitionSchema, createIPCResultSchema, createSuccessResult, createTypedAPI, createValidatedAPI, createZodAPI, exposeSafeAPI, invoke, invokeZod, isErrorResult, isSuccessResult, resolveDropPath, safeInvokeZod, subscribeChannel, subscribeZodChannel, unwrapIPCResult };
package/dist/preload.js CHANGED
@@ -1 +1 @@
1
- import"./rolldown-runtime-BqT_7tdF.js";import{t as e}from"./ipc.schema-CRktvhDm.js";import{ipcRenderer as t}from"electron";import*as n from"zod";import{createBrowserLogger as r}from"@longzai-intelligence-logger/browser";const i=n.object({code:e,message:n.string(),details:n.record(n.string(),n.unknown()).optional()});function a(e){return n.object({success:n.boolean(),data:e.optional(),error:i.optional()})}const o=a(n.void());function s(e){return{success:!0,data:e}}function c(e,t,n){return{success:!1,error:{code:e,message:t,details:n}}}function l(e){return e.success}function u(e){return!e.success}function d(e,t){return n.object({params:e,return:t})}function f(e){return e}function p(e,...n){let r=String(e);return t.invoke(r,...n)}function m(e){let n=Object.keys(e),r={};for(let i of n){let n=e[i],a=String(n);r[i]=(...e)=>t.invoke(a,...e)}return r}function h(e,n){let r=(e,t)=>{n(t)};return t.on(e,r),()=>{t.removeListener(e,r)}}function g(e){return e instanceof n.ZodFunction}function _(e){return e instanceof n.ZodPromise}function v(e){let t=e._zod.def.output;return _(t)&&(t=t._zod.def.innerType),async e=>{let r=await n.core.safeParseAsync(t,e);return r.success?{success:!0,data:r.data}:{success:!1,error:JSON.stringify(r.error.issues)}}}const y=r(`src/ipc/zod/preload/api.utils`);async function b(e,n,...r){let i=await t.invoke(e,...r),a=await v(n)(i);if(a.success)return a.data;throw Error(`Output validation failed: ${a.error}`)}function x(e){let n=e.schema.shape,r=e.channels,i={};for(let e of Object.keys(n)){let a=n[e];if(a&&g(a)){let n=r[e];n&&(i[e]=(...e)=>t.invoke(n,...e))}}return i}function S(e){let t=e.schema.shape,n=e.channels,r={};for(let e of Object.keys(t)){let i=t[e];if(i&&g(i)){let t=n[e];t&&(r[e]=(...e)=>b(t,i,...e))}}return{api:r,validate:async(e,n)=>{let r=t[String(e)];return r&&g(r)?v(r)(n):{success:!1,error:`Invalid schema`}}}}function C(e,r,i){let a=(t,a)=>{let o=n.core.safeParse(r,a);o.success?i(o.data):y.error(`Invalid payload for channel ${e}: ${JSON.stringify(a)}`)};return t.on(e,a),()=>{t.removeListener(e,a)}}function w(e,r,...i){return t.invoke(e,...i).then(e=>n.core.parse(r,e))}async function T(e,r,...i){try{let a=await t.invoke(e,...i),o=n.core.safeParse(r,a);return o.success?{success:!0,data:o.data}:{success:!1,error:JSON.stringify(o.error.issues)}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Unknown error`}}}function E(e){return e.success}function D(e,t){if(E(e))return e.data;let n=e.error?.code?`[${e.error.code}] `:``,r=e.error?.message??t;throw Error(`${n}${r}`)}const O=new Set([`ipcRenderer`]),k=new Set([`on`,`send`,`invoke`]);function A(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function j(e,t=`root`){for(let[n,r]of Object.entries(e)){if(O.has(n))throw Error(`禁止暴露危险键:${t}.${n}`);if(n===`ipc`&&A(r)){for(let e of Object.keys(r))if(k.has(e))throw Error(`禁止暴露通用 IPC 方法:${t}.${n}.${e}`)}A(r)&&j(r,`${t}.${n}`)}}function M(e){j(e.api),e.expose(e.globalKey,e.api)}export{e as IPCErrorCodeSchema,i as IPCErrorSchema,o as IPCResultSchema,c as createErrorResult,f as createIPCAPISchema,d as createIPCMethodDefinitionSchema,a as createIPCResultSchema,s as createSuccessResult,m as createTypedAPI,S as createValidatedAPI,x as createZodAPI,M as exposeSafeAPI,p as invoke,w as invokeZod,u as isErrorResult,l as isSuccessResult,T as safeInvokeZod,h as subscribeChannel,C as subscribeZodChannel,D as unwrapIPCResult};
1
+ import"./rolldown-runtime-BqT_7tdF.js";import{t as e}from"./ipc.schema-CRktvhDm.js";import{ipcRenderer as t,webUtils as n}from"electron";import*as r from"zod";import{createBrowserLogger as i}from"@longzai-intelligence-logger/browser";const a=r.object({code:e,message:r.string(),details:r.record(r.string(),r.unknown()).optional()});function o(e){return r.object({success:r.boolean(),data:e.optional(),error:a.optional()})}const s=o(r.void());function c(e){return{success:!0,data:e}}function l(e,t,n){return{success:!1,error:{code:e,message:t,details:n}}}function u(e){return e.success}function d(e){return!e.success}function f(e,t){return r.object({params:e,return:t})}function p(e){return e}function m(e,...n){let r=String(e);return t.invoke(r,...n)}function h(e){let n=Object.keys(e),r={};for(let i of n){let n=e[i],a=String(n);r[i]=(...e)=>t.invoke(a,...e)}return r}function g(e,n){let r=(e,t)=>{n(t)};return t.on(e,r),()=>{t.removeListener(e,r)}}function _(e){return e instanceof r.ZodFunction}function v(e){return e instanceof r.ZodPromise}function y(e){let t=e._zod.def.output;return v(t)&&(t=t._zod.def.innerType),async e=>{let n=await r.core.safeParseAsync(t,e);return n.success?{success:!0,data:n.data}:{success:!1,error:JSON.stringify(n.error.issues)}}}const b=i(`src/ipc/zod/preload/api.utils`);async function x(e,n,...r){let i=await t.invoke(e,...r),a=await y(n)(i);if(a.success)return a.data;throw Error(`Output validation failed: ${a.error}`)}function S(e){let n=e.schema.shape,r=e.channels,i={};for(let e of Object.keys(n)){let a=n[e];if(a&&_(a)){let n=r[e];n&&(i[e]=(...e)=>t.invoke(n,...e))}}return i}function C(e){let t=e.schema.shape,n=e.channels,r={};for(let e of Object.keys(t)){let i=t[e];if(i&&_(i)){let t=n[e];t&&(r[e]=(...e)=>x(t,i,...e))}}return{api:r,validate:async(e,n)=>{let r=t[String(e)];return r&&_(r)?y(r)(n):{success:!1,error:`Invalid schema`}}}}function w(e,n,i){let a=(t,a)=>{let o=r.core.safeParse(n,a);o.success?i(o.data):b.error(`Invalid payload for channel ${e}: ${JSON.stringify(a)}`)};return t.on(e,a),()=>{t.removeListener(e,a)}}function T(e,n,...i){return t.invoke(e,...i).then(e=>r.core.parse(n,e))}async function E(e,n,...i){try{let a=await t.invoke(e,...i),o=r.core.safeParse(n,a);return o.success?{success:!0,data:o.data}:{success:!1,error:JSON.stringify(o.error.issues)}}catch(e){return{success:!1,error:e instanceof Error?e.message:`Unknown error`}}}function D(e){return e.success}function O(e,t){if(D(e))return e.data;let n=e.error?.code?`[${e.error.code}] `:``,r=e.error?.message??t;throw Error(`${n}${r}`)}const k=new Set([`ipcRenderer`]),A=new Set([`on`,`send`,`invoke`]);function j(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function M(e,t=`root`){for(let[n,r]of Object.entries(e)){if(k.has(n))throw Error(`禁止暴露危险键:${t}.${n}`);if(n===`ipc`&&j(r)){for(let e of Object.keys(r))if(A.has(e))throw Error(`禁止暴露通用 IPC 方法:${t}.${n}.${e}`)}j(r)&&M(r,`${t}.${n}`)}}function N(e){M(e.api),e.expose(e.globalKey,e.api)}function P(e){return n.getPathForFile(e)}export{e as IPCErrorCodeSchema,a as IPCErrorSchema,s as IPCResultSchema,l as createErrorResult,p as createIPCAPISchema,f as createIPCMethodDefinitionSchema,o as createIPCResultSchema,c as createSuccessResult,h as createTypedAPI,C as createValidatedAPI,S as createZodAPI,N as exposeSafeAPI,m as invoke,T as invokeZod,d as isErrorResult,u as isSuccessResult,P as resolveDropPath,E as safeInvokeZod,g as subscribeChannel,w as subscribeZodChannel,O as unwrapIPCResult};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-electron/core",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Longzai Intelligence Electron 桌面端运行时基础设施包",
5
5
  "keywords": [
6
6
  "longzai-intelligence",