@nyte-ai/plugin 0.0.25-beta.1 → 0.0.25-nightly.20261101.40
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/THIRD-PARTY-NOTICES.md +49 -32
- package/dist/chunks/bash-description-0ah30s12.js +33 -0
- package/dist/chunks/bash-description-4h0hnsv4.js +68 -0
- package/dist/chunks/{bash-description-dnvgk30y.js → bash-description-4rfavmha.js} +32 -1
- package/dist/chunks/bash-description-5dpf5hpt.js +724 -0
- package/dist/chunks/{bash-description-yyd9jznf.js → bash-description-94km1hm2.js} +1 -1
- package/dist/chunks/{bash-description-svrhh5a5.js → bash-description-99k8z2r7.js} +3 -2
- package/dist/chunks/bash-description-9gw9ets8.js +162 -0
- package/dist/chunks/{bash-description-h13r0byk.js → bash-description-axnga0jz.js} +3 -3
- package/dist/chunks/bash-description-b78pre8c.js +147 -0
- package/dist/chunks/{bash-description-ye3wk5r3.js → bash-description-bas41ptb.js} +6 -24
- package/dist/chunks/{bash-description-2v3g7rd9.js → bash-description-bj5yh7tr.js} +26 -64
- package/dist/chunks/{bash-description-6z2kgtyt.js → bash-description-bkhr9zrz.js} +4 -4
- package/dist/chunks/{bash-description-hg64tqf1.js → bash-description-f754ge33.js} +49 -3
- package/dist/chunks/{bash-description-zz15raxk.js → bash-description-ff18794t.js} +1 -1
- package/dist/chunks/{bash-description-wmcbg6fw.js → bash-description-g7gfy7nw.js} +1 -1
- package/dist/chunks/{bash-description-1neewp76.js → bash-description-hp4rb8k4.js} +4 -3
- package/dist/chunks/bash-description-myvnmtt2.js +125 -0
- package/dist/chunks/{bash-description-9nn3yp18.js → bash-description-q2v8wbn8.js} +9 -1
- package/dist/chunks/bash-description-qwyy182r.js +452 -0
- package/dist/chunks/bash-description-rxpx004v.js +295 -0
- package/dist/chunks/{bash-description-eqp7ap2w.js → bash-description-z1581a29.js} +23 -9
- package/dist/src/acp/connection.d.ts +3 -1
- package/dist/src/acp/connection.js +3 -3
- package/dist/src/acp/index.d.ts +7 -4
- package/dist/src/acp/index.js +41 -8
- package/dist/src/acp/registry.d.ts +9 -0
- package/dist/src/acp/registry.js +5 -3
- package/dist/src/acp/thread.js +2 -2
- package/dist/src/acp/transcript.js +2 -2
- package/dist/src/acp/translate.d.ts +10 -2
- package/dist/src/acp/translate.js +3 -1
- package/dist/src/approvals/approvals.d.ts +1 -1
- package/dist/src/approvals/approvals.js +2 -2
- package/dist/src/approvals/schema.d.ts +3 -3
- package/dist/src/approvals/schema.js +1 -1
- package/dist/src/browser-tools.js +8 -2
- package/dist/src/canvas/canvas-compile.js +2 -2
- package/dist/src/canvas/canvas-preview.js +2 -2
- package/dist/src/canvas/canvas-protocol.d.ts +46 -0
- package/dist/src/canvas/canvas-protocol.js +11 -1
- package/dist/src/canvas/canvas.d.ts +17 -3
- package/dist/src/canvas/canvas.js +75 -31
- package/dist/src/canvas/schema.d.ts +28 -7
- package/dist/src/canvas/schema.js +2 -2
- package/dist/src/claude-code-sdk/index.d.ts +0 -10
- package/dist/src/claude-code-sdk/index.js +19 -179
- package/dist/src/claude-code-sdk/session.d.ts +22 -23
- package/dist/src/claude-code-sdk/session.js +6 -3
- package/dist/src/claude-code-sdk/transcript.d.ts +0 -6
- package/dist/src/claude-code-sdk/transcript.js +2 -4
- package/dist/src/claude-code-sdk/translate.d.ts +1 -5
- package/dist/src/claude-code-sdk/translate.js +2 -8
- package/dist/src/client/mount.d.ts +4 -2
- package/dist/src/client/mount.js +3 -0
- package/dist/src/client/notifications.d.ts +12 -4
- package/dist/src/client/notifications.js +25 -10
- package/dist/src/client/presentation.d.ts +138 -8
- package/dist/src/client/presentation.js +86 -371
- package/dist/src/codemode.js +151 -46
- package/dist/src/core.d.ts +1 -1
- package/dist/src/question/client/questions-tui.js +3 -3
- package/dist/src/question/client/questions.js +3 -3
- package/dist/src/question/question.js +84 -5
- package/dist/src/question/schema.js +3 -3
- package/dist/src/rename.d.ts +7 -35
- package/dist/src/rename.js +115 -48
- package/dist/src/subagents.d.ts +30 -0
- package/dist/src/subagents.js +323 -0
- package/dist/src/tool-search.d.ts +49 -0
- package/dist/src/tool-search.js +14 -0
- package/dist/src/web/body.d.ts +3 -0
- package/dist/src/web/body.js +6 -0
- package/dist/src/web/fetch.d.ts +16 -0
- package/dist/src/web/fetch.js +8 -0
- package/dist/src/web/html-markdown.d.ts +9 -0
- package/dist/src/web/html-markdown.js +10 -0
- package/dist/src/web/index.d.ts +24 -0
- package/dist/src/web/index.js +93 -0
- package/dist/src/web/providers.d.ts +60 -0
- package/dist/src/web/providers.js +11 -0
- package/dist/src/web/search.d.ts +21 -0
- package/dist/src/web/search.js +6 -0
- package/package.json +16 -7
- package/dist/chunks/bash-description-3j77ss7y.js +0 -86
- package/dist/chunks/bash-description-wbe8w0te.js +0 -530
- package/dist/src/web-search.d.ts +0 -78
- package/dist/src/web-search.js +0 -219
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -55,6 +55,11 @@ SOFTWARE.
|
|
|
55
55
|
`@earendil-works/pi-codemode` 1.0.0 supply the MCP client and QuickJS
|
|
56
56
|
executor. Tool discovery and code-mode integration are adapted from commit
|
|
57
57
|
`86dfceec402ad77e563bf4feab5f26c42d5f5db6`.
|
|
58
|
+
- BM25 tool search (`tool_search`, `searchTools()`), tool namespaces with
|
|
59
|
+
`describeNamespace()`, the budgeted codemode listing and the one-line MCP
|
|
60
|
+
server summary (`packages/plugin/src/tool-search.ts`,
|
|
61
|
+
`packages/plugin/src/codemode.ts`, `packages/core/src/builtins/mcp.ts`) are
|
|
62
|
+
ported from commit `d5b3de22d0e24a3e9c38a9410d3329b099717283`.
|
|
58
63
|
- Transcript reconciliation, checkpoint instruction snapshots, provider system
|
|
59
64
|
updates, and cache warming are ported from the 1.0.0 release commit
|
|
60
65
|
`a13d35a742c6ef8462812a28fbe1d8c8b7431c32`.
|
|
@@ -271,10 +276,9 @@ SOFTWARE.
|
|
|
271
276
|
https://github.com/agentclientprotocol/registry
|
|
272
277
|
- Package: `@agentclientprotocol/sdk` 1.9.0
|
|
273
278
|
- What: the ACP model API in `packages/plugin/src/acp/` talks to agents through
|
|
274
|
-
the SDK's client connection and schema types
|
|
275
|
-
`packages/plugin/src/acp/registry-seed.json`
|
|
276
|
-
registry's agent list
|
|
277
|
-
registry fetch.
|
|
279
|
+
the SDK's client connection and schema types, and
|
|
280
|
+
`packages/plugin/src/acp/registry-seed.json` copies entries from the
|
|
281
|
+
registry's agent list.
|
|
278
282
|
|
|
279
283
|
License: Apache License 2.0, reproduced in the appendix below. Copyright 2025
|
|
280
284
|
Zed Industries, Inc. and contributors. Neither project ships a `NOTICE` file, so
|
|
@@ -312,11 +316,14 @@ Copyright 2025 OpenAI
|
|
|
312
316
|
front of the queue (`packages/tui/src/model/interactions.ts`) is its
|
|
313
317
|
`onEmptySubmit`. The rename
|
|
314
318
|
plugin's context construction, prompt, model fallback, and output cleanup
|
|
315
|
-
(`packages/plugin/src/rename.ts`) port OpenCode v2. The web
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
319
|
+
(`packages/plugin/src/rename.ts`) port OpenCode v2. The web plugin
|
|
320
|
+
(`packages/plugin/src/web/`) ports OpenCode v2's web search and fetch tools:
|
|
321
|
+
the search provider registry any plugin can add to (`searchProviders` in
|
|
322
|
+
`packages/core/src/contract/plugin.ts`), its Exa, Firecrawl, Parallel, and
|
|
323
|
+
Tavily adapters, their stateless MCP `tools/call` transport and response
|
|
324
|
+
bounds, the result and error vocabulary, `web_fetch`'s Accept headers,
|
|
325
|
+
Cloudflare-challenge retry and size limits, and the streaming HTML-to-Markdown
|
|
326
|
+
and HTML-to-text converters (`packages/plugin/src/web/html-markdown.ts`).
|
|
320
327
|
- Core's ripgrep resolver and search adapter (`packages/core/src/ripgrep.ts`,
|
|
321
328
|
`packages/core/src/ripgrep/binary.ts`) and filename search
|
|
322
329
|
(`packages/core/src/file-search.ts`) adapt OpenCode v2's core implementation.
|
|
@@ -477,6 +484,39 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
477
484
|
SOFTWARE.
|
|
478
485
|
```
|
|
479
486
|
|
|
487
|
+
## Visual Studio Code (`microsoft/vscode`)
|
|
488
|
+
|
|
489
|
+
- Repository: https://github.com/microsoft/vscode
|
|
490
|
+
- What: the zsh and bash startup scripts in `packages/host/src/local/shell-integration`
|
|
491
|
+
adapt portions of VS Code's shell integration scripts at tag `1.105.1`; the
|
|
492
|
+
folder's `UPSTREAM.md` lists them.
|
|
493
|
+
|
|
494
|
+
License: MIT, with the following notice:
|
|
495
|
+
|
|
496
|
+
```text
|
|
497
|
+
MIT License
|
|
498
|
+
|
|
499
|
+
Copyright (c) 2015 - present Microsoft Corporation
|
|
500
|
+
|
|
501
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
502
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
503
|
+
in the Software without restriction, including without limitation the rights
|
|
504
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
505
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
506
|
+
furnished to do so, subject to the following conditions:
|
|
507
|
+
|
|
508
|
+
The above copyright notice and this permission notice shall be included in all
|
|
509
|
+
copies or substantial portions of the Software.
|
|
510
|
+
|
|
511
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
512
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
513
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
514
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
515
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
516
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
517
|
+
SOFTWARE.
|
|
518
|
+
```
|
|
519
|
+
|
|
480
520
|
## EasyList and EasyPrivacy
|
|
481
521
|
|
|
482
522
|
- Homepage: https://easylist.to
|
|
@@ -591,29 +631,6 @@ wherever the gameplay is used: "Gameplay – youtube.com/@Naybr".
|
|
|
591
631
|
|
|
592
632
|
License: every one is public domain or CC0. None requires attribution.
|
|
593
633
|
|
|
594
|
-
## Design references
|
|
595
|
-
|
|
596
|
-
These credits record design sources. They do not grant a license to the
|
|
597
|
-
referenced products or imply endorsement.
|
|
598
|
-
|
|
599
|
-
### Cursor
|
|
600
|
-
|
|
601
|
-
- Product: https://cursor.com
|
|
602
|
-
- Desktop design references include mention-preview folder rows, native
|
|
603
|
-
context menus and file-manager labels, transcript overscroll and edge
|
|
604
|
-
fades, collapsed-message previews, shell command and output presentation,
|
|
605
|
-
and Changes-panel shortcuts and default commit behavior in `packages/app`.
|
|
606
|
-
- The mention-preview reference is the file and folder path presentation in
|
|
607
|
-
`/Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.glass.main.js`.
|
|
608
|
-
Scroll and fade references include `--composer-messages-bottom-overscroll`,
|
|
609
|
-
`--cursor-spacing-8`, `.composer-fade-overlay`, and `UMs`.
|
|
610
|
-
- Composer and read-only message behavior was studied in the workbench
|
|
611
|
-
modules `ComposerLexicalRenderer.js`, `ComposerRichTextInline.js`,
|
|
612
|
-
`promptInputRichText.js`, and `draftAgentRepositoryService.js`. Nyte uses
|
|
613
|
-
its own message model and workspace and draft visibility rules.
|
|
614
|
-
- A Cursor iOS study informed the mobile interaction order and visual
|
|
615
|
-
hierarchy. Its iPad layouts were adapted to iPhone rather than copied.
|
|
616
|
-
|
|
617
634
|
## Appendix: Apache License 2.0
|
|
618
635
|
|
|
619
636
|
This is the license for Pierre, Grok Build, and OpenAI Codex above. Section 4
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/web/body.ts
|
|
2
|
+
async function readCapped2(response, limit) {
|
|
3
|
+
const declared = Number(response.headers.get("content-length") ?? Number.NaN);
|
|
4
|
+
if (Number.isSafeInteger(declared) && declared > limit) {
|
|
5
|
+
await response.body?.cancel();
|
|
6
|
+
throw tooLarge(limit);
|
|
7
|
+
}
|
|
8
|
+
if (response.body === null)
|
|
9
|
+
return new Uint8Array;
|
|
10
|
+
const reader = response.body.getReader();
|
|
11
|
+
const chunks = [];
|
|
12
|
+
let size = 0;
|
|
13
|
+
for (let next = await reader.read();!next.done; next = await reader.read()) {
|
|
14
|
+
size += next.value.byteLength;
|
|
15
|
+
if (size > limit) {
|
|
16
|
+
await reader.cancel();
|
|
17
|
+
throw tooLarge(limit);
|
|
18
|
+
}
|
|
19
|
+
chunks.push(next.value);
|
|
20
|
+
}
|
|
21
|
+
const body = new Uint8Array(size);
|
|
22
|
+
let offset = 0;
|
|
23
|
+
for (const chunk of chunks) {
|
|
24
|
+
body.set(chunk, offset);
|
|
25
|
+
offset += chunk.byteLength;
|
|
26
|
+
}
|
|
27
|
+
return body;
|
|
28
|
+
}
|
|
29
|
+
function tooLarge(limit) {
|
|
30
|
+
return new Error(`The response is larger than ${limit >= 1024 * 1024 ? `${limit / 1024 / 1024} MiB` : `${limit / 1024} KiB`}.`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { readCapped2 };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// src/web/search.ts
|
|
2
|
+
import { dev } from "@nyte-ai/core";
|
|
3
|
+
import { standard } from "@nyte-ai/schema";
|
|
4
|
+
import { Type } from "typebox";
|
|
5
|
+
var TIMEOUT_MS = 25000;
|
|
6
|
+
var parameters = standard(Type.Object({ query: Type.String({ minLength: 1, description: "What to search the web for." }) }));
|
|
7
|
+
var searchOutput = Type.Object({
|
|
8
|
+
provider: Type.String(),
|
|
9
|
+
results: Type.Array(Type.Object({
|
|
10
|
+
url: Type.String(),
|
|
11
|
+
title: Type.Optional(Type.String()),
|
|
12
|
+
content: Type.Optional(Type.String()),
|
|
13
|
+
published: Type.Optional(Type.Number({ description: "Milliseconds since the Unix epoch." }))
|
|
14
|
+
}))
|
|
15
|
+
});
|
|
16
|
+
function webSearch2(api, setting) {
|
|
17
|
+
return {
|
|
18
|
+
name: "web_search",
|
|
19
|
+
description: `Search the web using the user's selected search provider. Use this for current information beyond your knowledge cutoff. The current year is ${new Date().getFullYear()}.`,
|
|
20
|
+
parameters,
|
|
21
|
+
output: standard(searchOutput),
|
|
22
|
+
class: (args) => ({ kind: "custom", label: `Searching ${args.query}` }),
|
|
23
|
+
effects: "none",
|
|
24
|
+
approval: "never",
|
|
25
|
+
replay: "safe",
|
|
26
|
+
async execute(args, invocation) {
|
|
27
|
+
const output = await invocation.memo("results", async () => {
|
|
28
|
+
const chosen = await api.contribute.settings.value(setting);
|
|
29
|
+
const providers = api.contribute.searchProviders.list();
|
|
30
|
+
const provider = providers.find((candidate) => candidate.id === chosen) ?? providers.find((candidate) => candidate.id === "exa") ?? providers[0];
|
|
31
|
+
if (provider === undefined)
|
|
32
|
+
throw new Error("No web search provider is installed.");
|
|
33
|
+
dev("web", "search", { call: invocation.call, provider: provider.id });
|
|
34
|
+
const deadline = AbortSignal.timeout(TIMEOUT_MS);
|
|
35
|
+
const hits = await provider.search({ query: args.query, signal: AbortSignal.any([invocation.signal, deadline]) }).catch((error) => {
|
|
36
|
+
if (deadline.aborted && !invocation.signal.aborted)
|
|
37
|
+
throw new Error(`${provider.name} didn't answer within ${TIMEOUT_MS / 1000} s.`, {
|
|
38
|
+
cause: error
|
|
39
|
+
});
|
|
40
|
+
throw error;
|
|
41
|
+
});
|
|
42
|
+
return { provider: provider.id, results: hits.map(clean) };
|
|
43
|
+
});
|
|
44
|
+
const text = output.results.length === 0 ? "No search results found. Try a different query." : output.results.map((hit) => {
|
|
45
|
+
const published = hit.published === undefined ? "" : `
|
|
46
|
+
Published: ${new Date(hit.published).toISOString()}`;
|
|
47
|
+
return `## [${hit.title ?? hit.url}](${hit.url})${published}${hit.content === undefined ? "" : `
|
|
48
|
+
|
|
49
|
+
${hit.content}`}`;
|
|
50
|
+
}).join(`
|
|
51
|
+
|
|
52
|
+
`);
|
|
53
|
+
return { content: [{ kind: "text", text }], output };
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function clean(hit) {
|
|
58
|
+
const kept = { url: hit.url };
|
|
59
|
+
if (hit.title !== undefined && hit.title !== "")
|
|
60
|
+
kept.title = hit.title;
|
|
61
|
+
if (hit.content !== undefined && hit.content !== "")
|
|
62
|
+
kept.content = hit.content;
|
|
63
|
+
if (hit.published !== undefined && Number.isFinite(hit.published))
|
|
64
|
+
kept.published = hit.published;
|
|
65
|
+
return kept;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { webSearch2 };
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
// src/canvas/canvas-protocol.ts
|
|
6
6
|
var CANVAS_RUNTIME2 = 2;
|
|
7
7
|
var CANVAS_GLOBAL2 = "__nyteCanvas";
|
|
8
|
+
var CANVAS_STARTUP_CONTEXT2 = "__nyteCanvasContext";
|
|
8
9
|
var KIT_SPECIFIER2 = "nyte/canvas";
|
|
9
10
|
var CANVAS_ENTRY2 = "main.tsx";
|
|
10
11
|
var CANVAS_SOURCE_LIMIT2 = 65536;
|
|
@@ -57,6 +58,10 @@ var REACT_EXPORTS2 = [
|
|
|
57
58
|
var JSX_RUNTIME_EXPORTS2 = ["Fragment", "jsx", "jsxs"];
|
|
58
59
|
var REACT_DOM_EXPORTS2 = ["createPortal", "flushSync"];
|
|
59
60
|
var LIBRARY_EXPORTS2 = Object.fromEntries(Object.entries(CANVAS_LIBRARIES2).map(([name, library]) => [name, library.exports.split(" ")]));
|
|
61
|
+
var CANVAS_LIBRARY_NAMES = Object.keys(CANVAS_LIBRARIES2).filter((name) => Object.hasOwn(CANVAS_LIBRARIES2, name));
|
|
62
|
+
function readCanvasLibrary2(value) {
|
|
63
|
+
return CANVAS_LIBRARY_NAMES.find((name) => name === value);
|
|
64
|
+
}
|
|
60
65
|
var LIBRARY_VERSIONS2 = Object.fromEntries(Object.entries(CANVAS_LIBRARIES2).map(([name, library]) => [name, library.version]));
|
|
61
66
|
var FILES_COMMENT = /^\/\*nyte-canvas-files:(\[[^\n]*?\])\*\//u;
|
|
62
67
|
function canvasFilesComment2(spans) {
|
|
@@ -151,6 +156,7 @@ var INITIALIZE = "ui/initialize";
|
|
|
151
156
|
var INITIALIZED = "ui/notifications/initialized";
|
|
152
157
|
var SIZE_CHANGED = "ui/notifications/size-changed";
|
|
153
158
|
var OPEN_LINK = "ui/open-link";
|
|
159
|
+
var LIBRARY = "nyte/library";
|
|
154
160
|
var LOG_MESSAGE = "notifications/message";
|
|
155
161
|
var HOST_CONTEXT_CHANGED = "ui/notifications/host-context-changed";
|
|
156
162
|
var RENDER = "nyte/notifications/render";
|
|
@@ -215,6 +221,12 @@ function hostContextChangedNotification2(context) {
|
|
|
215
221
|
function openLinkResult2(id, isError = false) {
|
|
216
222
|
return { jsonrpc: "2.0", id, result: isError ? { isError: true } : {} };
|
|
217
223
|
}
|
|
224
|
+
function libraryRequest2(name) {
|
|
225
|
+
return { jsonrpc: "2.0", id: name, method: LIBRARY, params: { name } };
|
|
226
|
+
}
|
|
227
|
+
function libraryResult2(name, source) {
|
|
228
|
+
return { jsonrpc: "2.0", id: name, result: { source } };
|
|
229
|
+
}
|
|
218
230
|
function readShellMessage2(data) {
|
|
219
231
|
const message = envelope(data);
|
|
220
232
|
if (message === undefined)
|
|
@@ -235,6 +247,10 @@ function readShellMessage2(data) {
|
|
|
235
247
|
const url = linkHref(params?.["url"]);
|
|
236
248
|
return url === undefined ? undefined : { kind: "open-link", id, url };
|
|
237
249
|
}
|
|
250
|
+
if (method === LIBRARY) {
|
|
251
|
+
const name = readCanvasLibrary2(params?.["name"]);
|
|
252
|
+
return name !== undefined && id === name ? { kind: "library", name } : undefined;
|
|
253
|
+
}
|
|
238
254
|
if (method === LOG_MESSAGE) {
|
|
239
255
|
const payload = record(params?.["data"]);
|
|
240
256
|
const phase = payload?.["phase"];
|
|
@@ -252,6 +268,11 @@ function readHostMessage2(data) {
|
|
|
252
268
|
return;
|
|
253
269
|
const { id, method, params, result } = message;
|
|
254
270
|
if (method === undefined && id !== undefined && result !== undefined) {
|
|
271
|
+
if ("source" in result) {
|
|
272
|
+
const source = result["source"];
|
|
273
|
+
const name = readCanvasLibrary2(id);
|
|
274
|
+
return typeof source === "string" && name !== undefined ? { kind: "library-result", name, source } : undefined;
|
|
275
|
+
}
|
|
255
276
|
if (result["hostContext"] === undefined)
|
|
256
277
|
return { kind: "open-link-result", id, isError: result["isError"] === true };
|
|
257
278
|
const info = record(result["hostInfo"]);
|
|
@@ -277,6 +298,16 @@ function readHostMessage2(data) {
|
|
|
277
298
|
function clampCanvasHeight2(height) {
|
|
278
299
|
return Math.min(CANVAS_MAX_HEIGHT2, Math.max(CANVAS_MIN_HEIGHT2, Math.round(height)));
|
|
279
300
|
}
|
|
301
|
+
function canvasStartHeight2(canvas, width) {
|
|
302
|
+
const fallback = clampCanvasHeight2(canvas.height ?? CANVAS_DEFAULT_HEIGHT2);
|
|
303
|
+
if (width === undefined || canvas.heights === undefined)
|
|
304
|
+
return fallback;
|
|
305
|
+
const measured = canvas.heights.toSorted((left, right) => left.width - right.width);
|
|
306
|
+
const narrower = measured.findLast((point) => point.width <= width);
|
|
307
|
+
const wider = measured.find((point) => point.width >= width);
|
|
308
|
+
const height = Math.max(narrower?.height ?? 0, wider?.height ?? 0);
|
|
309
|
+
return height > 0 ? clampCanvasHeight2(height) : fallback;
|
|
310
|
+
}
|
|
280
311
|
function sanitizeCanvasVariables2(variables) {
|
|
281
312
|
const allowed = CANVAS_VARIABLES2;
|
|
282
313
|
return Object.fromEntries(Object.entries(variables).filter(([name]) => allowed.includes(name)).map(([name, value]) => [name, value.replace(/[;{}<>]/g, "")]));
|
|
@@ -366,4 +397,4 @@ function linkHref(value) {
|
|
|
366
397
|
return URL.parse(value)?.href;
|
|
367
398
|
}
|
|
368
399
|
|
|
369
|
-
export { CANVAS_RUNTIME2, CANVAS_GLOBAL2, KIT_SPECIFIER2, CANVAS_ENTRY2, CANVAS_SOURCE_LIMIT2, CANVAS_CODE_LIMIT2, CANVAS_MIN_HEIGHT2, CANVAS_MAX_HEIGHT2, CANVAS_MIN_HEIGHT_HINT2, CANVAS_DEFAULT_HEIGHT2, REACT_EXPORTS2, JSX_RUNTIME_EXPORTS2, REACT_DOM_EXPORTS2, LIBRARY_EXPORTS2, LIBRARY_VERSIONS2, canvasFilesComment2, locateCanvasStack2, TINTS2, KIT2, KIT_EXPORTS2, CANVAS_VARIABLES2, CANVAS_PROTOCOL_VERSION2, initializeRequest2, initializedNotification2, sizeChangedNotification2, openLinkRequest2, errorNotification2, initializeResult2, renderNotification2, hostContextChangedNotification2, openLinkResult2, readShellMessage2, readHostMessage2, clampCanvasHeight2, sanitizeCanvasVariables2 };
|
|
400
|
+
export { CANVAS_RUNTIME2, CANVAS_GLOBAL2, CANVAS_STARTUP_CONTEXT2, KIT_SPECIFIER2, CANVAS_ENTRY2, CANVAS_SOURCE_LIMIT2, CANVAS_CODE_LIMIT2, CANVAS_MIN_HEIGHT2, CANVAS_MAX_HEIGHT2, CANVAS_MIN_HEIGHT_HINT2, CANVAS_DEFAULT_HEIGHT2, REACT_EXPORTS2, JSX_RUNTIME_EXPORTS2, REACT_DOM_EXPORTS2, LIBRARY_EXPORTS2, readCanvasLibrary2, LIBRARY_VERSIONS2, canvasFilesComment2, locateCanvasStack2, TINTS2, KIT2, KIT_EXPORTS2, CANVAS_VARIABLES2, CANVAS_PROTOCOL_VERSION2, initializeRequest2, initializedNotification2, sizeChangedNotification2, openLinkRequest2, errorNotification2, initializeResult2, renderNotification2, hostContextChangedNotification2, openLinkResult2, libraryRequest2, libraryResult2, readShellMessage2, readHostMessage2, clampCanvasHeight2, canvasStartHeight2, sanitizeCanvasVariables2 };
|