@pen.dev/cli 0.3.10 → 0.3.11
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/README.md +6 -4
- package/dist/browserAll-BVNfpTCH.mjs +15 -0
- package/dist/chunk-V2S4ZYJR-B9IPlZGx.mjs +7 -0
- package/dist/esm-N6I77Ols.mjs +63 -0
- package/dist/esm-Rg36NIlb.mjs +2 -0
- package/dist/html-BzmDMzcE.mjs +26 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +3 -2
- package/dist/init-79Ivv_Iw.mjs +555 -0
- package/dist/limit-io-DqzENcBM.mjs +3 -0
- package/dist/module-ES6BEMUI-nLDaJUtp.mjs +2 -0
- package/dist/module-asyncify-2EFITU5U-B-l6gXmU.mjs +2 -0
- package/dist/node_modules/@highagency/pencil-wasm/package.json +1 -1
- package/dist/node_modules/@highagency/pencil-wasm/pencil.wasm +0 -0
- package/dist/out/mcp-server-darwin-arm64 +0 -0
- package/dist/out/mcp-server-darwin-x64 +0 -0
- package/dist/out/mcp-server-linux-arm64 +0 -0
- package/dist/out/mcp-server-linux-x64 +0 -0
- package/dist/out/mcp-server-windows-arm64.exe +0 -0
- package/dist/out/mcp-server-windows-x64.exe +0 -0
- package/dist/out/skills/pen-dev/SKILL.md +1 -0
- package/dist/out/skills/pen-dev/execute.md +1 -0
- package/dist/out/skills/pen-dev/pen-schema.md +5 -11
- package/dist/out/skills/pen-dev/scripts-and-shaders.md +35 -3
- package/dist/rolldown-runtime-DUc_qoCt.mjs +2 -0
- package/dist/standalone-DmZDPu3b.mjs +30 -0
- package/dist/validate-response-Cd_RKmhH.mjs +3 -0
- package/dist/webworkerAll-tGgDIbvf.mjs +2 -0
- package/package.json +31 -31
- package/dist/browserAll-DN_YxOXQ.mjs +0 -2
- package/dist/dist-CbU0Evuc.mjs +0 -4
- package/dist/esm-BHQtsEyo.mjs +0 -2
- package/dist/esm-BYcFG9-N.mjs +0 -25
- package/dist/html-C5EUiP3B.mjs +0 -26
- package/dist/init-C4ANyG-9.mjs +0 -2
- package/dist/module-ES6BEMUI-fiUywq2c.mjs +0 -2
- package/dist/module-asyncify-2EFITU5U-Ck30SKgw.mjs +0 -2
- package/dist/standalone-D4MlQZsr.mjs +0 -30
- package/dist/validate-response-DHB60j_7.mjs +0 -3
- package/dist/webworkerAll-FVvp_NgY.mjs +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pen.dev/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "CLI tool for running the pen.dev AI agent manipulating .pen design files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -8,22 +8,6 @@
|
|
|
8
8
|
"pen": "dist/index.mjs",
|
|
9
9
|
"pencil": "dist/index.mjs"
|
|
10
10
|
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsdown && npm run bundle:chmod && npm run bundle:mcp && npm run bundle:wasm && npm run bundle:pen-libs && npm run bundle:skill",
|
|
13
|
-
"bundle:skill": "cp ../../SKILL.md ./SKILL.md && rm -rf dist/out/skills && mkdir -p dist/out/skills && cp -Rp ../../skills/pen-dev dist/out/skills/",
|
|
14
|
-
"build:prod": "npm run build && node scripts/obfuscate.js",
|
|
15
|
-
"bundle:mcp": "mkdir -p dist/out && cp ../../servers/mcp/mcp-server-* dist/out/ && chmod +x dist/out/mcp-server-*",
|
|
16
|
-
"bundle:wasm": "node scripts/copy-pencil-wasm.mjs",
|
|
17
|
-
"bundle:pen-libs": "mkdir -p dist/out/data && cp ../../lib/pencil-editor/data/*.lib.pen dist/out/data/",
|
|
18
|
-
"bundle:chmod": "node scripts/chmod-dist-entry.mjs",
|
|
19
|
-
"dev": "npm run build && cross-env NODE_ENV=development npm run start --",
|
|
20
|
-
"start": "node dist/index.mjs",
|
|
21
|
-
"lint": "biome check",
|
|
22
|
-
"lint:ci": "biome ci",
|
|
23
|
-
"test:package": "bash scripts/test-package-docker.sh",
|
|
24
|
-
"test:interactive": "bash scripts/test-interactive.sh",
|
|
25
|
-
"typecheck": "tsc --noEmit"
|
|
26
|
-
},
|
|
27
11
|
"keywords": [
|
|
28
12
|
"pen.dev",
|
|
29
13
|
"pencil",
|
|
@@ -35,8 +19,8 @@
|
|
|
35
19
|
"author": "High Agency, Inc.",
|
|
36
20
|
"license": "UNLICENSED",
|
|
37
21
|
"dependencies": {
|
|
38
|
-
"@anthropic-ai/claude-agent-sdk": "^0.3.
|
|
39
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
22
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.293",
|
|
23
|
+
"@earendil-works/pi-coding-agent": "^1.0.1",
|
|
40
24
|
"@inquirer/prompts": "^8.3.0",
|
|
41
25
|
"@jitl/quickjs-wasmfile-release-asyncify": "^0.32.0",
|
|
42
26
|
"@jitl/quickjs-wasmfile-release-sync": "^0.32.0",
|
|
@@ -48,21 +32,21 @@
|
|
|
48
32
|
"svgo": "^4.0.0"
|
|
49
33
|
},
|
|
50
34
|
"devDependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"@ha/
|
|
53
|
-
"@ha/
|
|
54
|
-
"@ha/
|
|
55
|
-
"@ha/mcp": "
|
|
56
|
-
"@ha/pencil-editor": "
|
|
57
|
-
"@ha/schema": "
|
|
58
|
-
"@ha/shared": "
|
|
35
|
+
"@ha/agent": "0.1.0",
|
|
36
|
+
"@ha/device-auth": "0.1.0",
|
|
37
|
+
"@ha/ipc": "0.1.0",
|
|
38
|
+
"@ha/mcp": "0.1.0",
|
|
39
|
+
"@ha/mcp-server": "0.1.0",
|
|
40
|
+
"@ha/pencil-editor": "0.0.1",
|
|
41
|
+
"@ha/schema": "0.1.0",
|
|
42
|
+
"@ha/shared": "0.1.0",
|
|
59
43
|
"@types/node": "^20.0.0",
|
|
60
44
|
"@types/node-ipc": "^9.2.3",
|
|
61
45
|
"@types/semver": "^7.7.1",
|
|
62
46
|
"cross-env": "^10.1.0",
|
|
63
47
|
"javascript-obfuscator": "^4.2.2",
|
|
64
|
-
"tsdown": "^0.
|
|
65
|
-
"typescript": "
|
|
48
|
+
"tsdown": "^0.23.0",
|
|
49
|
+
"typescript": "7.0.2"
|
|
66
50
|
},
|
|
67
51
|
"engines": {
|
|
68
52
|
"node": ">=22.19.0"
|
|
@@ -70,5 +54,21 @@
|
|
|
70
54
|
"files": [
|
|
71
55
|
"dist",
|
|
72
56
|
"SKILL.md"
|
|
73
|
-
]
|
|
74
|
-
|
|
57
|
+
],
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsdown && pnpm run bundle:chmod && pnpm run bundle:mcp && pnpm run bundle:wasm && pnpm run bundle:pen-libs && pnpm run bundle:skill",
|
|
60
|
+
"bundle:skill": "cp ../../SKILL.md ./SKILL.md && rm -rf dist/out/skills && mkdir -p dist/out/skills && cp -Rp ../../skills/pen-dev dist/out/skills/",
|
|
61
|
+
"build:prod": "pnpm run build && node scripts/obfuscate.js",
|
|
62
|
+
"bundle:mcp": "mkdir -p dist/out && cp ../../servers/mcp/mcp-server-* dist/out/ && chmod +x dist/out/mcp-server-*",
|
|
63
|
+
"bundle:wasm": "node scripts/copy-pencil-wasm.mjs",
|
|
64
|
+
"bundle:pen-libs": "mkdir -p dist/out/data && cp ../../lib/pencil-editor/data/*.lib.pen dist/out/data/",
|
|
65
|
+
"bundle:chmod": "node scripts/chmod-dist-entry.mjs",
|
|
66
|
+
"dev": "pnpm run build && cross-env NODE_ENV=development pnpm run start",
|
|
67
|
+
"start": "node dist/index.mjs",
|
|
68
|
+
"lint": "biome check",
|
|
69
|
+
"lint:ci": "biome ci",
|
|
70
|
+
"test:package": "bash scripts/test-package-docker.sh",
|
|
71
|
+
"test:interactive": "bash scripts/test-interactive.sh",
|
|
72
|
+
"typecheck": "tsc --noEmit"
|
|
73
|
+
}
|
|
74
|
+
}
|
package/dist/dist-CbU0Evuc.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{promises as e,statSync as t}from"fs";import n from"path";import{createRequire as r}from"module";import i from"os";import{spawn as a}from"child_process";import o from"readline";async function s(t){if(t===void 0)return{cleanup:async()=>{}};if(!c(t))throw Error(`outputSchema must be a plain JSON object`);let r=await e.mkdtemp(n.join(i.tmpdir(),`codex-output-schema-`)),a=n.join(r,`schema.json`),o=async()=>{try{await e.rm(r,{recursive:!0,force:!0})}catch{}};try{return await e.writeFile(a,JSON.stringify(t),`utf8`),{schemaPath:a,cleanup:o}}catch(e){throw await o(),e}}function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var l=class{_exec;_options;_id;_threadOptions;get id(){return this._id}constructor(e,t,n,r=null){this._exec=e,this._options=t,this._id=r,this._threadOptions=n}async runStreamed(e,t={}){return{events:this.runStreamedInternal(e,t)}}async*runStreamedInternal(e,t={}){let{schemaPath:n,cleanup:r}=await s(t.outputSchema),i=this._threadOptions,{prompt:a,images:o}=u(e),c=this._exec.run({input:a,baseUrl:this._options.baseUrl,apiKey:this._options.apiKey,threadId:this._id,images:o,model:i?.model,threadSource:i?.threadSource,sandboxMode:i?.sandboxMode,workingDirectory:i?.workingDirectory,skipGitRepoCheck:i?.skipGitRepoCheck,outputSchemaFile:n,modelReasoningEffort:i?.modelReasoningEffort,signal:t.signal,networkAccessEnabled:i?.networkAccessEnabled,webSearchMode:i?.webSearchMode,webSearchEnabled:i?.webSearchEnabled,approvalPolicy:i?.approvalPolicy,additionalDirectories:i?.additionalDirectories});try{for await(let e of c){let t;try{t=JSON.parse(e)}catch(t){throw Error(`Failed to parse item: ${e}`,{cause:t})}t.type===`thread.started`?this._id=t.thread_id:t.type===`turn.completed`&&(t.usage.cache_write_input_tokens??=0),yield t}}finally{await r()}}async run(e,t={}){let n=this.runStreamedInternal(e,t),r=[],i=``,a=null,o=null;for await(let e of n)if(e.type===`item.completed`)e.item.type===`agent_message`&&(i=e.item.text),r.push(e.item);else if(e.type===`turn.completed`)a=e.usage;else if(e.type===`turn.failed`){o=e.error;break}if(o)throw Error(o.message);return{items:r,finalResponse:i,usage:a}}};function u(e){if(typeof e==`string`)return{prompt:e,images:[]};let t=[],n=[];for(let r of e)r.type===`text`?t.push(r.text):r.type===`local_image`&&n.push(r.path);return{prompt:t.join(`
|
|
3
|
-
|
|
4
|
-
`),images:n}}var d=`CODEX_INTERNAL_ORIGINATOR_OVERRIDE`,f=`codex_sdk_ts`,p=`@openai/codex`,m={"x86_64-unknown-linux-musl":`@openai/codex-linux-x64`,"aarch64-unknown-linux-musl":`@openai/codex-linux-arm64`,"x86_64-apple-darwin":`@openai/codex-darwin-x64`,"aarch64-apple-darwin":`@openai/codex-darwin-arm64`,"x86_64-pc-windows-msvc":`@openai/codex-win32-x64`,"aarch64-pc-windows-msvc":`@openai/codex-win32-arm64`},h=r(import.meta.url),g=class{executablePath;pathDirs;envOverride;configOverrides;rawConfigOverrides;constructor(e=null,t,n,r){if(e)this.executablePath=e,this.pathDirs=[];else{let e=C();this.executablePath=e.executablePath,this.pathDirs=e.pathDirs}this.envOverride=t,this.configOverrides=n,this.rawConfigOverrides=r}async*run(e){let t=[`exec`,`--experimental-json`];if(this.configOverrides)for(let e of _(this.configOverrides))t.push(`--config`,e);if(this.rawConfigOverrides)for(let e of this.rawConfigOverrides)t.push(`--config`,e);if(e.baseUrl&&t.push(`--config`,`openai_base_url=${y(e.baseUrl,`openai_base_url`)}`),e.model&&t.push(`--model`,e.model),e.threadSource!==void 0&&!e.threadId&&t.push(`--thread-source`,e.threadSource),e.sandboxMode&&t.push(`--sandbox`,e.sandboxMode),e.workingDirectory&&t.push(`--cd`,e.workingDirectory),e.additionalDirectories?.length)for(let n of e.additionalDirectories)t.push(`--add-dir`,n);if(e.skipGitRepoCheck&&t.push(`--skip-git-repo-check`),e.outputSchemaFile&&t.push(`--output-schema`,e.outputSchemaFile),e.modelReasoningEffort&&t.push(`--config`,`model_reasoning_effort="${e.modelReasoningEffort}"`),e.networkAccessEnabled!==void 0&&t.push(`--config`,`sandbox_workspace_write.network_access=${e.networkAccessEnabled}`),e.webSearchMode?t.push(`--config`,`web_search="${e.webSearchMode}"`):e.webSearchEnabled===!0?t.push(`--config`,`web_search="live"`):e.webSearchEnabled===!1&&t.push(`--config`,`web_search="disabled"`),e.approvalPolicy&&t.push(`--config`,`approval_policy="${e.approvalPolicy}"`),e.threadId&&t.push(`resume`,e.threadId),e.images?.length)for(let n of e.images)t.push(`--image`,n);let n={};if(this.envOverride)Object.assign(n,this.envOverride);else for(let[e,t]of Object.entries(process.env))t!==void 0&&(n[e]=t);n[d]||(n[d]=f),e.apiKey&&(n.CODEX_API_KEY=e.apiKey),this.pathDirs.length>0&&E(n,this.pathDirs);let r=a(this.executablePath,t,{env:n,signal:e.signal}),i=null;if(r.once(`error`,e=>i=e),!r.stdin)throw r.kill(),Error(`Child process has no stdin`);if(r.stdin.write(e.input),r.stdin.end(),!r.stdout)throw r.kill(),Error(`Child process has no stdout`);let s=[];r.stderr&&r.stderr.on(`data`,e=>{s.push(e)});let c=new Promise(e=>{r.once(`exit`,(t,n)=>{e({code:t,signal:n})})}),l=o.createInterface({input:r.stdout,crlfDelay:1/0});try{for await(let e of l)yield e;if(i)throw i;let{code:e,signal:t}=await c;if(e!==0||t){let n=Buffer.concat(s),r=t?`signal ${t}`:`code ${e??1}`;throw Error(`Codex Exec exited with ${r}: ${n.toString(`utf8`)}`)}}finally{l.close(),r.removeAllListeners();try{r.killed||r.kill()}catch{}}}};function _(e){let t=[];return v(e,``,t),t}function v(e,t,n){if(!S(e))if(t){n.push(`${t}=${y(e,t)}`);return}else throw Error(`Codex config overrides must be a plain object`);let r=Object.entries(e);if(!(!t&&r.length===0)){if(t&&r.length===0){n.push(`${t}={}`);return}for(let[e,i]of r){if(!e)throw Error(`Codex config override keys must be non-empty strings`);if(i===void 0)continue;let r=t?`${t}.${e}`:e;S(i)?v(i,r,n):n.push(`${r}=${y(i,r)}`)}}}function y(e,t){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`Codex config override at ${t} must be a finite number`);return`${e}`}else if(typeof e==`boolean`)return e?`true`:`false`;else if(Array.isArray(e))return`[${e.map((e,n)=>y(e,`${t}[${n}]`)).join(`, `)}]`;else if(S(e)){let n=[];for(let[r,i]of Object.entries(e)){if(!r)throw Error(`Codex config override keys must be non-empty strings`);i!==void 0&&n.push(`${x(r)} = ${y(i,`${t}.${r}`)}`)}return`{${n.join(`, `)}}`}else if(e===null)throw Error(`Codex config override at ${t} cannot be null`);else{let n=typeof e;throw Error(`Unsupported Codex config override value at ${t}: ${n}`)}}var b=/^[A-Za-z0-9_-]+$/;function x(e){return b.test(e)?e:JSON.stringify(e)}function S(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function C(){let{platform:e,arch:t}=process,i=null;switch(e){case`linux`:case`android`:switch(t){case`x64`:i=`x86_64-unknown-linux-musl`;break;case`arm64`:i=`aarch64-unknown-linux-musl`;break;default:break}break;case`darwin`:switch(t){case`x64`:i=`x86_64-apple-darwin`;break;case`arm64`:i=`aarch64-apple-darwin`;break;default:break}break;case`win32`:switch(t){case`x64`:i=`x86_64-pc-windows-msvc`;break;case`arm64`:i=`aarch64-pc-windows-msvc`;break;default:break}break;default:break}if(!i)throw Error(`Unsupported platform: ${e} (${t})`);let a=m[i];if(!a)throw Error(`Unsupported target triple: ${i}`);let o;try{let e=r(h.resolve(`${p}/package.json`)).resolve(`${a}/package.json`);o=n.join(n.dirname(e),`vendor`)}catch{throw Error(`Unable to locate Codex CLI binaries. Ensure ${p} is installed with optional dependencies.`)}let s=process.platform===`win32`?`codex.exe`:`codex`,c=w(o,i,s);if(!c)throw Error(`Unable to locate Codex CLI binaries for ${i}. Ensure ${p} is installed with optional dependencies.`);return c}function w(e,t,r){let i=n.join(e,t),a=n.join(i,`bin`,r);if(O(a)&&O(n.join(i,`codex-package.json`)))return{executablePath:a,pathDirs:T(n.join(i,`codex-path`))};let o=n.join(i,`codex`,r);return O(o)?{executablePath:o,pathDirs:T(n.join(i,`path`))}:null}function T(...e){return e.filter(k)}function E(e,t,r=process.platform){let i=D(e,r);if(r===`win32`)for(let t of Object.keys(e))t.toLowerCase()===`path`&&t!==i&&delete e[t];let a=(e[i]??``).split(n.delimiter).filter(e=>e.length>0&&!t.includes(e));e[i]=[...t,...a].join(n.delimiter)}function D(e,t){if(t!==`win32`)return`PATH`;let n=Object.keys(e).filter(e=>e.toLowerCase()===`path`);return n.includes(`Path`)?`Path`:n.at(-1)??`PATH`}function O(e){try{return t(e).isFile()}catch{return!1}}function k(e){try{return t(e).isDirectory()}catch{return!1}}var A=class{exec;options;constructor(e={}){let{codexPathOverride:t,env:n,config:r,configOverrides:i}=e;this.exec=new g(t,n,r,i),this.options=e}startThread(e={}){return new l(this.exec,this.options,e)}resumeThread(e,t={}){return new l(this.exec,this.options,t,e)}};export{A as Codex};
|
package/dist/esm-BHQtsEyo.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{K as e,M as t,N as n,W as r,X as i,_t as a,c as o,dt as s,f as c,ft as l,g as u,i as d,j as f,l as p,o as m,pt as h,s as g,st as _,t as v,u as y}from"./validate-response-DHB60j_7.mjs";import{$ as b,J as x,K as S,X as C,et as w,q as T,tt as E}from"./index.mjs";function D(){try{new Headers}catch{throw Error(`connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.`)}}var O=function(e){return this instanceof O?(this.v=e,this):new O(e)},k=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i={},s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof O?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function A(s){D();let l=s.useBinaryFormat??!1;return{async unary(t,d,f,m,g,_,v){let{serialize:b,parse:x}=r(d,l,s.jsonOptions,s.binaryOptions);return m=m===void 0?s.defaultTimeoutMs:m<=0?void 0:m,await o({interceptors:s.interceptors,signal:f,timeoutMs:m,req:{stream:!1,service:t,method:d,url:i(s.baseUrl,t,d),init:{method:`POST`,credentials:s.credentials??`same-origin`,redirect:`error`,mode:`cors`},header:c(d.kind,l,m,g,!1),contextValues:v??h(),message:_},next:async r=>{let i=s.useHttpGet===!0&&d.idempotency===w.NoSideEffects,o=null;i?r=p(r,b(r.message),l):o=b(r.message);let c=await(s.fetch??globalThis.fetch)(r.url,Object.assign(Object.assign({},r.init),{headers:r.header,signal:r.signal,body:o})),{isUnaryError:f,unaryError:m}=y(d.kind,l,c.status,c.headers);if(f)throw n(await c.json(),a(...u(c.headers)),m);let[h,g]=u(c.headers);return{stream:!1,service:t,method:d,header:h,message:l?x(new Uint8Array(await c.arrayBuffer())):d.O.fromJson(await c.json(),e(s.jsonOptions)),trailer:g}}})},async stream(e,n,a,o,u,d,p){let{serialize:m,parse:_}=r(n,l,s.jsonOptions,s.binaryOptions);function v(e,n,r,i){return k(this,arguments,function*(){let a=S(e).getReader(),o=!1;for(;;){let e=yield O(a.read());if(e.done)break;let{flags:i,data:s}=e.value;if((i&x)===x)throw new C(`protocol error: received unsupported compressed output`,b.Internal);if((i&f)===f){o=!0;let e=t(s);if(e.error){let t=e.error;throw r.forEach((e,n)=>{t.metadata.append(n,e)}),t}e.metadata.forEach((e,t)=>n.set(t,e));continue}yield yield O(_(s))}if(`throwIfAborted`in i&&i.throwIfAborted(),!o)throw`missing EndStreamResponse`})}async function w(e){if(n.kind!=E.ServerStreaming)throw`The fetch API does not support streaming request bodies`;let t=await e[Symbol.asyncIterator]().next();if(t.done==1)throw`missing request message`;return T(0,m(t.value))}return o=o===void 0?s.defaultTimeoutMs:o<=0?void 0:o,await g({interceptors:s.interceptors,timeoutMs:o,signal:a,req:{stream:!0,service:e,method:n,url:i(s.baseUrl,e,n),init:{method:`POST`,credentials:s.credentials??`same-origin`,redirect:`error`,mode:`cors`},header:c(n.kind,l,o,u,!1),contextValues:p??h(),message:d},next:async e=>{let t=await(s.fetch??globalThis.fetch)(e.url,Object.assign(Object.assign({},e.init),{headers:e.header,signal:e.signal,body:await w(e.message)}));if(y(n.kind,l,t.status,t.headers),t.body===null)throw`missing response body`;let r=new Headers;return Object.assign(Object.assign({},e),{header:t.headers,trailer:r,message:v(t.body,r,t.headers,e.signal)})}})}}}var j=function(e){return this instanceof j?(this.v=e,this):new j(e)},M=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i={},s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof j?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function N(e){D();let t=e.useBinaryFormat??!0;return{async unary(n,a,c,u,f,p,g){let{serialize:y,parse:w}=r(a,t,e.jsonOptions,e.binaryOptions);return u=u===void 0?e.defaultTimeoutMs:u<=0?void 0:u,await o({interceptors:e.interceptors,signal:c,timeoutMs:u,req:{stream:!1,service:n,method:a,url:i(e.baseUrl,n,a),init:{method:`POST`,credentials:e.credentials??`same-origin`,redirect:`error`,mode:`cors`},header:d(t,u,f,!1),contextValues:g??h(),message:p},next:async t=>{let r=await(e.fetch??globalThis.fetch)(t.url,Object.assign(Object.assign({},t.init),{headers:t.header,signal:t.signal,body:T(0,y(t.message))})),{headerError:i}=v(r.status,r.headers);if(!r.body)throw i===void 0?`missing response body`:i;let o=S(r.body).getReader(),c,u;for(;;){let e=await o.read();if(e.done)break;let{flags:t,data:n}=e.value;if((t&x)===x)throw new C(`protocol error: received unsupported compressed output`,b.Internal);if(t===s){if(c!==void 0)throw`extra trailer`;c=l(n);continue}if(u!==void 0)throw new C(`extra message`,b.Unimplemented);u=w(n)}if(c===void 0)throw i===void 0?new C(`missing trailer`,r.headers.has(_)?b.Unimplemented:b.Unknown):i;if(m(c,r.headers),u===void 0)throw new C(`missing message`,c.has(_)?b.Unimplemented:b.Unknown);return{stream:!1,service:n,method:a,header:r.headers,message:u,trailer:c}}})},async stream(n,a,o,c,u,f,p){let{serialize:_,parse:y}=r(a,t,e.jsonOptions,e.binaryOptions);function b(e,t,n,r,i){return M(this,arguments,function*(){let a=S(e).getReader();if(t){if(!(yield j(a.read())).done)throw`extra data for trailers-only`;return yield j(void 0)}let o=!1;for(;;){let e=yield j(a.read());if(e.done)break;let{flags:t,data:i}=e.value;if((t&s)===s){if(o)throw`extra trailer`;o=!0;let e=l(i);m(e,r),e.forEach((e,t)=>n.set(t,e));continue}if(o)throw`extra message`;yield yield j(y(i))}if(`throwIfAborted`in i&&i.throwIfAborted(),!o)throw`missing trailer`})}async function x(e){if(a.kind!=E.ServerStreaming)throw`The fetch API does not support streaming request bodies`;let t=await e[Symbol.asyncIterator]().next();if(t.done==1)throw`missing request message`;return T(0,_(t.value))}return c=c===void 0?e.defaultTimeoutMs:c<=0?void 0:c,g({interceptors:e.interceptors,signal:o,timeoutMs:c,req:{stream:!0,service:n,method:a,url:i(e.baseUrl,n,a),init:{method:`POST`,credentials:e.credentials??`same-origin`,redirect:`error`,mode:`cors`},header:d(t,c,u,!1),contextValues:p??h(),message:f},next:async t=>{let n=await(e.fetch??globalThis.fetch)(t.url,Object.assign(Object.assign({},t.init),{headers:t.header,signal:t.signal,body:await x(t.message)})),{foundStatus:r,headerError:i}=v(n.status,n.headers);if(i!=null)throw i;if(!n.body)throw`missing response body`;let a=new Headers;return Object.assign(Object.assign({},t),{header:n.headers,trailer:a,message:b(n.body,r,a,n.headers,t.signal)})}})}}}export{A as createConnectTransport,N as createGrpcWebTransport};
|