@tempo-ai/mcp 0.0.113-staging.3 → 0.0.113
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 +8 -5
- package/dist/bin.js +2 -2
- package/dist/{call-ZENVEMBV.js → call-WAGXDIIR.js} +3 -3
- package/dist/{chunk-3J3V3CVG.js → chunk-2P3T5CJG.js} +251 -132
- package/dist/chunk-2P3T5CJG.js.map +1 -0
- package/dist/{chunk-IC3SRTRB.js → chunk-GWZ4IVKA.js} +31 -62
- package/dist/chunk-GWZ4IVKA.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2 -2
- package/dist/{serve-B3XMDJMJ.js → serve-YVFHBEFM.js} +753 -317
- package/dist/serve-YVFHBEFM.js.map +1 -0
- package/dist/{token-BH4Z4COI.js → token-QSGSKGO3.js} +3 -3
- package/dist/token-QSGSKGO3.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-3J3V3CVG.js.map +0 -1
- package/dist/chunk-IC3SRTRB.js.map +0 -1
- package/dist/serve-B3XMDJMJ.js.map +0 -1
- package/dist/token-BH4Z4COI.js.map +0 -1
- /package/dist/{call-ZENVEMBV.js.map → call-WAGXDIIR.js.map} +0 -0
|
@@ -2,17 +2,23 @@ import { createRequire as __tempoCreateRequire } from 'node:module'; const requi
|
|
|
2
2
|
import {
|
|
3
3
|
AuthedConvexClient,
|
|
4
4
|
McpToolError,
|
|
5
|
+
TokenExchangeError,
|
|
5
6
|
createAggregateServer,
|
|
6
7
|
createAuthProvider,
|
|
7
8
|
createRefreshLoop,
|
|
9
|
+
createSignInPrompt,
|
|
8
10
|
discoverWorkspace,
|
|
9
|
-
|
|
11
|
+
envAccessToken,
|
|
10
12
|
envTokenReauth,
|
|
13
|
+
exchangeAccessToken,
|
|
11
14
|
installProcessSafety,
|
|
15
|
+
readAuth,
|
|
12
16
|
readAuthSync,
|
|
13
17
|
resolveConvexSiteUrl,
|
|
14
|
-
resolveConvexUrl
|
|
15
|
-
|
|
18
|
+
resolveConvexUrl,
|
|
19
|
+
resolveSignInWaitMs,
|
|
20
|
+
storedAuthMatchesAccessToken
|
|
21
|
+
} from "./chunk-2P3T5CJG.js";
|
|
16
22
|
import {
|
|
17
23
|
__commonJS,
|
|
18
24
|
__require,
|
|
@@ -5825,6 +5831,78 @@ var require_png = __commonJS({
|
|
|
5825
5831
|
// src/serve.ts
|
|
5826
5832
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5827
5833
|
|
|
5834
|
+
// src/auth-gate.ts
|
|
5835
|
+
var FRESHNESS_FLOOR_MS = 6e4;
|
|
5836
|
+
function createAuthGate(options) {
|
|
5837
|
+
const { waitMs } = options;
|
|
5838
|
+
return {
|
|
5839
|
+
async ensure() {
|
|
5840
|
+
const accessToken = envAccessToken();
|
|
5841
|
+
if (accessToken) {
|
|
5842
|
+
const existing2 = await readAuth();
|
|
5843
|
+
if (existing2 && storedAuthMatchesAccessToken(existing2, accessToken) && existing2.expiresAt - Date.now() > FRESHNESS_FLOOR_MS) {
|
|
5844
|
+
return null;
|
|
5845
|
+
}
|
|
5846
|
+
try {
|
|
5847
|
+
await exchangeAccessToken({
|
|
5848
|
+
convexSiteUrl: options.convexSiteUrl,
|
|
5849
|
+
accessToken
|
|
5850
|
+
});
|
|
5851
|
+
return null;
|
|
5852
|
+
} catch (err) {
|
|
5853
|
+
if (err instanceof TokenExchangeError && err.kind === "invalid_token") {
|
|
5854
|
+
return toolError(
|
|
5855
|
+
"auth_token_invalid",
|
|
5856
|
+
"TEMPO_AUTH_TOKEN was rejected (revoked or not a Tempo token). Mint a new one with `npx -y @tempo-ai/mcp token create` on a machine that can sign in, then set it in this environment."
|
|
5857
|
+
);
|
|
5858
|
+
}
|
|
5859
|
+
return toolError(
|
|
5860
|
+
"network_unavailable",
|
|
5861
|
+
`Couldn't reach Tempo to sign in with TEMPO_AUTH_TOKEN: ${err instanceof Error ? err.message : String(err)}. Check the network and retry.`
|
|
5862
|
+
);
|
|
5863
|
+
}
|
|
5864
|
+
}
|
|
5865
|
+
const existing = await readAuth();
|
|
5866
|
+
if (existing) {
|
|
5867
|
+
if (existing.expiresAt - Date.now() > FRESHNESS_FLOOR_MS) return null;
|
|
5868
|
+
if (await options.refreshLoop.refreshNow()) return null;
|
|
5869
|
+
if (await readAuth()) {
|
|
5870
|
+
return toolError(
|
|
5871
|
+
"network_unavailable",
|
|
5872
|
+
"Couldn't reach Tempo to refresh the signed-in session. Check the network and retry."
|
|
5873
|
+
);
|
|
5874
|
+
}
|
|
5875
|
+
}
|
|
5876
|
+
const prompt = await options.signInPrompt.ensure(waitMs);
|
|
5877
|
+
if (prompt === "signed_in") return null;
|
|
5878
|
+
return {
|
|
5879
|
+
isError: true,
|
|
5880
|
+
content: [
|
|
5881
|
+
{
|
|
5882
|
+
type: "text",
|
|
5883
|
+
text: JSON.stringify({
|
|
5884
|
+
error: {
|
|
5885
|
+
code: "auth_required",
|
|
5886
|
+
message: `Tempo needs the user to connect their Tempo account before this tool can run. ${prompt.browserOpened ? "A browser window was opened to the Tempo sign-in page; if it didn't appear, the user can open this link:" : "Ask the user to open this link in a browser:"} ${prompt.signInUrl} \u2014 they can sign in or create an account there (a new account is walked through creating its organization). Once they've finished, call this tool again; no login command or restart is needed.`,
|
|
5887
|
+
signInUrl: prompt.signInUrl,
|
|
5888
|
+
browserOpened: prompt.browserOpened
|
|
5889
|
+
}
|
|
5890
|
+
})
|
|
5891
|
+
}
|
|
5892
|
+
]
|
|
5893
|
+
};
|
|
5894
|
+
}
|
|
5895
|
+
};
|
|
5896
|
+
}
|
|
5897
|
+
function toolError(code, message) {
|
|
5898
|
+
return {
|
|
5899
|
+
isError: true,
|
|
5900
|
+
content: [
|
|
5901
|
+
{ type: "text", text: JSON.stringify({ error: { code, message } }) }
|
|
5902
|
+
]
|
|
5903
|
+
};
|
|
5904
|
+
}
|
|
5905
|
+
|
|
5828
5906
|
// ../slack-mcp/document-pages.ts
|
|
5829
5907
|
import { createRequire } from "module";
|
|
5830
5908
|
|
|
@@ -6102,6 +6180,7 @@ async function extractDocumentText(bytes, format) {
|
|
|
6102
6180
|
if (pdf.numPages > 200) {
|
|
6103
6181
|
return {
|
|
6104
6182
|
ok: false,
|
|
6183
|
+
reason: "too_many_pages",
|
|
6105
6184
|
message: "This PDF exceeds the 200-page bulk text-extraction limit. Use slack_read_pdf_page to inspect individual pages with a vision-capable model, or ask for smaller documents before treating its requirements as fully read."
|
|
6106
6185
|
};
|
|
6107
6186
|
}
|
|
@@ -6109,6 +6188,7 @@ async function extractDocumentText(bytes, format) {
|
|
|
6109
6188
|
if (!extracted.text.some((page) => page.trim())) {
|
|
6110
6189
|
return {
|
|
6111
6190
|
ok: false,
|
|
6191
|
+
reason: "no_text",
|
|
6112
6192
|
message: "This PDF has no extractable text. Use slack_read_pdf_page to read scanned pages with a vision-capable model, or ask for a searchable PDF or Markdown copy before triaging its requirements."
|
|
6113
6193
|
};
|
|
6114
6194
|
}
|
|
@@ -6124,6 +6204,7 @@ ${page}`).join("\n\n"),
|
|
|
6124
6204
|
} catch {
|
|
6125
6205
|
return {
|
|
6126
6206
|
ok: false,
|
|
6207
|
+
reason: "invalid_pdf",
|
|
6127
6208
|
message: "Could not extract the PDF's text. It may be corrupt or password-protected; ask for an unlocked, searchable PDF or Markdown copy."
|
|
6128
6209
|
};
|
|
6129
6210
|
} finally {
|
|
@@ -16818,7 +16899,7 @@ function createHostToolsServer(options) {
|
|
|
16818
16899
|
text: JSON.stringify(
|
|
16819
16900
|
rows.length === 0 ? {
|
|
16820
16901
|
orgs: rows,
|
|
16821
|
-
hint: "This account belongs to no organization yet. Ask the user to
|
|
16902
|
+
hint: "This account belongs to no organization yet. Ask the user to run `npx -y @tempo-ai/mcp logout`, then call this tool again \u2014 the fresh sign-in link walks the account through creating its organization in the browser."
|
|
16822
16903
|
} : { orgs: rows }
|
|
16823
16904
|
)
|
|
16824
16905
|
}
|
|
@@ -16879,7 +16960,7 @@ function createHostToolsServer(options) {
|
|
|
16879
16960
|
content: [
|
|
16880
16961
|
{
|
|
16881
16962
|
type: "text",
|
|
16882
|
-
text: "registration_failed: the session
|
|
16963
|
+
text: "registration_failed: the Tempo session has expired. Call this tool again to get a fresh sign-in link for the user."
|
|
16883
16964
|
}
|
|
16884
16965
|
]
|
|
16885
16966
|
};
|
|
@@ -16946,7 +17027,7 @@ import { z as z22 } from "zod";
|
|
|
16946
17027
|
// ../canvas-mcp/docs/assets.ts
|
|
16947
17028
|
var ASSET_DOCS = `# Asset Libraries
|
|
16948
17029
|
|
|
16949
|
-
Assets are the user's design-building-block inventory: components and canvases tagged with \`defineAsset\` so Tempo can list them in the Assets tab, group them into libraries, and let you query and organize them with the \`asset_*\` tools.
|
|
17030
|
+
Assets are the user's design-building-block inventory: components and canvases tagged with \`defineAsset\` so Tempo can list them in the Assets tab, group them into libraries, and let you query and organize them with the \`asset_*\` tools. The index discovers declarations from source without executing user code. Local constants can be read statically; the editor reads explicit controls and example values from the running component when needed. Component prop types still come from TypeScript.
|
|
16950
17031
|
|
|
16951
17032
|
**You only need this guide to WRITE declarations.** Browsing is self-serve: \`asset_list_libraries\` / \`asset_list\` / \`asset_library_get\` / \`asset_get\` are cheap read-only scans \u2014 call them freely, before building any UI, without reading further.
|
|
16952
17033
|
|
|
@@ -16954,17 +17035,34 @@ Assets are the user's design-building-block inventory: components and canvases t
|
|
|
16954
17035
|
|
|
16955
17036
|
## 1. What an asset is
|
|
16956
17037
|
|
|
16957
|
-
|
|
17038
|
+
Controls describe editors for real component props; assets register library membership, usage instructions, and reusable variants. New components declare \`defineControls(Component, controls)\` in their own file. Existing components can instead use \`tempo/controls.ts\` to leave app source untouched; see the placement policy below. Both are available across canvases without an asset or library. Keep \`defineAsset(Component, config)\` on library canvases.
|
|
16958
17039
|
|
|
16959
17040
|
\`\`\`tsx
|
|
16960
|
-
//
|
|
17041
|
+
// src/components/Button.tsx \u2014 controls beside a newly created component
|
|
17042
|
+
import { defineControls } from "tempo-sdk/assets";
|
|
17043
|
+
|
|
17044
|
+
export function Button({ label, variant = "primary" }: {
|
|
17045
|
+
label: string;
|
|
17046
|
+
variant?: "primary" | "destructive";
|
|
17047
|
+
}) {
|
|
17048
|
+
return <button data-variant={variant}>{label}</button>;
|
|
17049
|
+
}
|
|
17050
|
+
|
|
17051
|
+
defineControls(Button, {
|
|
17052
|
+
label: { type: "text" },
|
|
17053
|
+
variant: { type: "select" },
|
|
17054
|
+
});
|
|
17055
|
+
\`\`\`
|
|
17056
|
+
|
|
17057
|
+
\`\`\`tsx
|
|
17058
|
+
// tempo/designs/design-system/buttons/index.canvas.tsx \u2014 optional library entry
|
|
16961
17059
|
import { defineAsset } from "tempo-sdk/assets";
|
|
16962
17060
|
import { Button } from "../../../../src/components/Button";
|
|
16963
17061
|
|
|
16964
17062
|
export default function ButtonsCanvas() { /* storyboards showing Button */ }
|
|
16965
17063
|
|
|
16966
17064
|
defineAsset(Button, {
|
|
16967
|
-
libraries: ["
|
|
17065
|
+
libraries: ["Design System"],
|
|
16968
17066
|
usageInstructions: "Primary action button \u2014 for form submits, CTAs, not navigation (use Link)",
|
|
16969
17067
|
variants: {
|
|
16970
17068
|
Primary: { props: { label: "Buy now", variant: "primary" } },
|
|
@@ -16983,13 +17081,28 @@ Config keys (all optional at the value level; see variants rule below):
|
|
|
16983
17081
|
|
|
16984
17082
|
## 2. The two authoring shapes
|
|
16985
17083
|
|
|
16986
|
-
**
|
|
17084
|
+
**Choose controls placement before adding a declaration.** New components always keep \`defineControls\` in the same file as the component, even during non-developer work. For existing components, maintain an existing declaration where it is unless the user asks to move it. When adding controls, honor the user\u2019s stated preference and the repo\u2019s established convention: fully integrated projects prefer the component file; for non-developers working on existing code, prefer \`tempo/controls.ts\` so app source stays untouched. This shared file is the usual default for \`generate-design-system\` on an existing codebase. If a developer\u2019s preference is not already known, ask once whether they want component-file controls or the shared file, then follow that answer throughout the work. Use conversation/repo context; do not ask everyone to identify their role or re-ask an answered preference. If context gives no preference or role, use the shared file for existing components. For component-file controls, make sure the app or component package declares its dependency on \`tempo-sdk\`; the Tempo host\u2019s dependency alone is not enough. Both locations work across every canvas without an asset or library. Keep exactly one declaration per component; move it rather than copying it.
|
|
16987
17085
|
|
|
16988
|
-
|
|
17086
|
+
For shared controls, put top-level \`defineControls\` calls in \`tempo/controls.ts\` (or \`controls.ts\` inside a custom Tempo host root). Import the real exported components and pass them directly. The file is shared across canvases and never needs to be imported by them or by your app. Tempo's workspace scan discovers the calls and its metadata reader loads their modules. Once the canvas host is ready, controls-only components warm in the same bounded, thumbnail-aware queue as asset props. Definitions are cached across canvases and app sessions; changes to the declaration, imported constants, or prop types invalidate affected entries. No library registration or component-source edit is required. Component-file, canvas, and sibling-module declarations are also discovered; maintain existing calls in place rather than migrating them automatically. Keys must be real props and values/options must fit their types; imported constants work. For components without an importable runtime export, use an existing local wrapper where appropriate; do not create wrappers solely to satisfy metadata coverage.
|
|
16989
17087
|
|
|
16990
|
-
|
|
17088
|
+
For an existing Button whose source should stay untouched, the alternative is:
|
|
16991
17089
|
|
|
16992
|
-
|
|
17090
|
+
\`\`\`tsx
|
|
17091
|
+
// tempo/controls.ts \u2014 use INSTEAD OF a component-file declaration, never both
|
|
17092
|
+
import { defineControls } from "tempo-sdk/assets";
|
|
17093
|
+
import { Button } from "../src/components/Button";
|
|
17094
|
+
|
|
17095
|
+
defineControls(Button, {
|
|
17096
|
+
label: { type: "text" },
|
|
17097
|
+
variant: { type: "select" },
|
|
17098
|
+
});
|
|
17099
|
+
\`\`\`
|
|
17100
|
+
|
|
17101
|
+
**Curated assets.** Prefer \`defineAsset\` in a library canvas that imports the component. Existing same-file declarations still work. Do not put controls in this declaration: Assets resolves the component\u2019s own controls. Each variant is an independent, insertable set of props, including JSX children, or a JSX-only render template. Controls do not depend on asset metadata being loaded.
|
|
17102
|
+
|
|
17103
|
+
**One declaration per component, workspace-wide.** Tempo resolves re-exports and project aliases to identify the component. Duplicate asset definitions block insertion. They do not block selected-component editing, which uses defineControls independently. Multiple defineControls calls on the same runtime component are a separate controls conflict. A deterministic display row is not an authoritative winner.
|
|
17104
|
+
|
|
17105
|
+
**For a canvas-owned asset declaration, keep its source pointer.** Someone reading ONLY the component's source must be able to see that a canvas exists for it. Whenever you write a canvas reference declaration for a component, also add the canvas-pointer note to the docstring (any comment works) in the component's DEFINING file, naming the canvas's workspace-relative path and reminding future editors to keep the two in sync:
|
|
16993
17106
|
|
|
16994
17107
|
\`\`\`tsx
|
|
16995
17108
|
/**
|
|
@@ -17012,15 +17125,17 @@ The defining file is resolved best-effort: a relative import resolves directly t
|
|
|
17012
17125
|
## 3. The exact authoring rules \u2014 get these right
|
|
17013
17126
|
|
|
17014
17127
|
- **The import specifier must be exactly \`"tempo-sdk/assets"\`.** Importing \`defineAsset\` from \`"tempo-sdk"\` (root) or \`"tempo-sdk/canvas"\` does not work at runtime and is flagged as a structural \`misimported_define_asset\` error \u2014 the declaration is ignored entirely.
|
|
17015
|
-
- The call is a **top-level expression statement** \u2014 never inside a function or block. The first argument is a plain identifier: a component defined in the same file, or
|
|
17128
|
+
- The call is a **top-level expression statement** \u2014 never inside a function or block. The first argument is a plain identifier: a component defined in the same file, or a named/default import. Namespace imports (\`import * as X\`) cannot be declared.
|
|
17016
17129
|
- **Never wrap the export**: \`export default defineAsset(App, {\u2026})\` is a type error (the function returns \`void\`) and would break React Fast Refresh. The statement form is the only supported shape.
|
|
17017
17130
|
- The config must be an **inline object literal**. Passing a variable, spread, or call result is a structural error \u2014 Tempo edits configs by source span and needs the literal there.
|
|
17018
|
-
- One \`defineAsset\` per
|
|
17019
|
-
-
|
|
17131
|
+
- One \`defineAsset\` per component. Duplicates are structural errors and block asset insertion, not selected-component controls.
|
|
17132
|
+
- Controls and example props may use constants. Local literal constants are resolved statically; imported constants are read from the running component when its editor opens. Source expressions that cannot be represented faithfully remain \`{"$unresolved": true}\` in tool output and block insertion until replaced. Non-literal \`libraries\` entries are dropped with a warning \u2014 a library name must be statically knowable to exist.
|
|
17133
|
+
|
|
17134
|
+
## 4. Variants and nested content
|
|
17020
17135
|
|
|
17021
|
-
|
|
17136
|
+
\`defineAsset\`'s TypeScript types make the user's own typecheck the validator: every declared variant must fully satisfy the component's prop types. Variants are optional, including for components with required props; insertion waits until those required values are filled. When you add variants, use real, renderable prop values taken from how the app actually uses the component \u2014 never invented placeholders. The static parser does no prop validation of its own; \`variants: {}\` (present but empty) is only a degraded warning.
|
|
17022
17137
|
|
|
17023
|
-
|
|
17138
|
+
Portable JSX children may include fragments, HTML elements, imported named/default components, literal attributes, and nested children. Tempo copies their code and imports on insertion. A text control never replaces nested content. Callbacks, local non-exported child components, and expressions that cannot be transferred are blocked with an explanation. Slots and variant switching on existing components are deferred.
|
|
17024
17139
|
|
|
17025
17140
|
## 5. Every canvas declares its top-level component(s); self-registration is strictly for component-less foundations pages
|
|
17026
17141
|
|
|
@@ -17040,9 +17155,9 @@ defineAsset(IconsCanvas, {
|
|
|
17040
17155
|
\`\`\`
|
|
17041
17156
|
|
|
17042
17157
|
- Canvases live under the canvases root \`{{canvasesDirRel}}/\` \u2014 design-system canvases at \`design-system/<slug>/index.canvas.tsx\`, library canvases at \`libraries/<libname>/<slug>/index.canvas.tsx\`, freeform canvases at \`canvases/<slug>/index.canvas.tsx\`. A canvas with a \`defineAsset\` call appears in the Assets tab (kind \`"canvas"\`), and clicking it there opens the canvas. Canvases WITHOUT one stay in the Canvases tab only.
|
|
17043
|
-
- **STRICT zones require a declaration.** Every canvas under \`design-system/**\` or \`libraries/**\` MUST
|
|
17158
|
+
- **STRICT zones require a declaration.** Every canvas under \`design-system/**\` or \`libraries/**\` MUST showcase an already-declared component or contribute a declaration. Componentless foundations pages can self-register. A strict-zone canvas with zero declarations fails \`canvas_validate\` with \`missing_asset_declaration\`. Freeform canvases carry no requirement.
|
|
17044
17159
|
- **Component-less foundations pages are first-class design-system entries**: a canvas asset with \`usageInstructions\` and no component (an Icons page, Color foundations, spacing scales) is a complete asset \u2014 no component tag needed. This is the ONLY case where a canvas self-registers.
|
|
17045
|
-
- **
|
|
17160
|
+
- **Component canvases showcase declared components.** An existing canvas whose folder declares component references is already linked by every one of those components (their \`canvasPath\`) \u2014 the canvas is "for" them, one asset row per declared component. Adding a canvas-level \`defineAsset\` on top is redundant and flagged with a degraded \`redundant_canvas_declaration\` warning on the canvas asset (visible via \`asset_get\`, and surfaced by \`canvas_validate\`) \u2014 remove the self-registration instead.
|
|
17046
17161
|
- **Declaration errors fail \`canvas_validate\`.** A \`duplicate_asset_declaration\` or \`component_declaration_outside_canvas\` involving the canvas (or any file in its folder), and a \`missing_asset_declaration\` on a strict-zone canvas, fail validation like a type error \u2014 fix the declaration, don't work around it.
|
|
17047
17162
|
- Canvas components take no props, so \`variants\` never applies (ignored with a warning if present).
|
|
17048
17163
|
- A canvas file with an anonymous default export can't be referenced by a statement \u2014 \`asset_define\` repairs that automatically (see below).
|
|
@@ -17053,27 +17168,40 @@ Read (fresh static scan per call, cheap, safe to spam):
|
|
|
17053
17168
|
|
|
17054
17169
|
- \`asset_list_libraries\` \u2014 all libraries with component/canvas member counts, plus library-less counts.
|
|
17055
17170
|
- \`asset_library_get({ name })\` \u2014 one library's members with summaries.
|
|
17056
|
-
- \`asset_list({ library?, query? })\` \u2014 all assets; \`library: ""\` selects library-less assets; \`query\` is a name substring. Records carry \`usageInstructions\`, and for canvas-declared components \`canvasPath\` (the linked canvas folder \u2014 the declaring file is its \`index.canvas.tsx\`) + \`componentFilePath\` (the component's resolved defining file, when resolvable). A \`fileErrors\` field (present when non-empty) reports structural declaration errors per file, including \`duplicate_asset_declaration
|
|
17171
|
+
- \`asset_list({ library?, query? })\` \u2014 all assets; \`library: ""\` selects library-less assets; \`query\` is a name substring. Records carry \`usageInstructions\`, and for canvas-declared components \`canvasPath\` (the linked canvas folder \u2014 the declaring file is its \`index.canvas.tsx\`) + \`componentFilePath\` (the component's resolved defining file, when resolvable). A \`fileErrors\` field (present when non-empty) reports structural declaration errors per file, including \`duplicate_asset_declaration\`.
|
|
17057
17172
|
- \`asset_get({ assetKey })\` \u2014 full detail: config, variants (dynamic values as \`{"$unresolved": true}\`), warnings (including the canvas-pointer checks above), canvas linkage.
|
|
17058
17173
|
|
|
17059
17174
|
Write (surgical span edits through the assets editor \u2014 never regenerate a file by hand when these apply):
|
|
17060
17175
|
|
|
17061
|
-
- \`asset_define({ filePath, exportName?, libraries?, usageInstructions? })\` \u2014 attach a **
|
|
17176
|
+
- \`asset_define({ filePath, exportName?, libraries?, usageInstructions? })\` \u2014 attach a **same-file** \`defineAsset\` to an existing component/canvas. Hand-edit the asset definition to add variants. Hand-write defineControls in the location chosen by the placement policy above for prop editors. Omit \`exportName\` to target the default export; anonymous default exports are automatically renamed to a proper binding (\`repairedDefaultExport: true\` in the result). Errors \`already_defined\` if the binding already has a declaration.
|
|
17062
17177
|
- \`asset_add_to_libraries({ assetKey, libraries })\` / \`asset_remove_from_libraries({ assetKey, libraries })\` \u2014 mutate membership; both return the resulting full membership. Removing the last library removes the \`libraries\` property entirely. These edit same-file declarations only \u2014 hand-edit a canvas reference declaration's config directly.
|
|
17063
17178
|
|
|
17064
17179
|
Asset keys come in three shapes \u2014 \`"src/components/Button.tsx#Button"\` (legacy), \`"src/components/Button#Button"\` (canvas-declared, relative import), \`"pkg:@scope/pkg#Button"\` (canvas-declared, package import) \u2014 always take them from tool output rather than constructing them by hand.
|
|
17065
17180
|
|
|
17066
|
-
## 7.
|
|
17181
|
+
## 7. Everyday component work
|
|
17182
|
+
|
|
17183
|
+
When creating a reusable component or changing its public props, find its existing defineControls declaration (component file, tempo/controls.ts, or legacy canvas) and its owning asset canvas. New components always declare controls in their own file; for existing components follow the placement policy above. Add or update useful controls for the edited props; preserve curated controls and hide callbacks or internal props with \`false\` when appropriate. Basic editors can be inferred from TypeScript, so focus explicit controls on intentional choices, ranges, labels, and safe editing. Do not invent props or expose every DOM/event prop. Update the affected saved examples when props change. Register a new asset when the component is an approved reusable building block, not for every one-off page or prototype.
|
|
17184
|
+
|
|
17185
|
+
For design-system generation, use \`libraries: ["Design System"]\`, retaining other memberships. Every component asset gets at least one usable named variant, even if all props are optional; put the representative example first for its grid thumbnail. Use a few real call-site examples rather than a Cartesian product. Componentless foundations canvases need no controls or component variants.
|
|
17186
|
+
|
|
17187
|
+
## 8. Recipes
|
|
17067
17188
|
|
|
17068
17189
|
**Browse what exists** \u2014 \`asset_list_libraries\` \u2192 \`asset_library_get({ name })\` \u2192 \`asset_get({ assetKey })\` for the one you care about. Use \`asset_list({ library: "" })\` to find untagged assets worth organizing.
|
|
17069
17190
|
|
|
17070
|
-
**
|
|
17191
|
+
**Add controls** \u2014 find and update the existing definition in place. For a new declaration, choose the component file or tempo/controls.ts using the placement policy above; do not duplicate or automatically migrate existing definitions. No asset registration is required. **Curate an asset** \u2014 check asset_list, then add variants and usage instructions on its library canvas. Keep the component\u2019s canvas-pointer comment up to date; avoid duplicate declarations.
|
|
17192
|
+
|
|
17193
|
+
**Controls (defineControls, not defineAsset)** \u2014 use \`defineControls(Component, { propName: { type: "\u2026" } })\`. Supported types: text, boolean, number, range, color, select, radio, inline-radio, check, inline-check, multi-select, object, date, file. Use \`false\` to hide a prop. Range requires min/max and optionally step. Choice controls infer finite options from the prop type or accept a type-compatible options array. Date writes a numeric timestamp; file writes durable URL strings to a string[] prop. Controls cannot invent props or convert incompatible values.
|
|
17071
17194
|
|
|
17072
|
-
**
|
|
17195
|
+
**Variants** \u2014 \`variants: { Default: { props: { children: "Save", size: "medium" } }, Small: { props: { children: "Save", size: "small" } } }\`. Every example is independent and includes all required props. Default is an ordinary name, not a fallback. No extends, args, argTypes, or top-level props/defaults. Components with required props may omit variants; insertion waits until required values are supplied. Existing-instance editors read the usage's values, not a saved example; optional reset removes that prop and restores the component default. Applying saved examples to existing instances is deferred.
|
|
17073
17196
|
|
|
17074
|
-
**
|
|
17197
|
+
**Hand-editing** is fine for anything the write tools don't cover (canvas reference declarations, \`usageInstructions\`, variants) \u2014 edit the \`defineAsset\` config object directly, keep library names and example names statically discoverable; prop values may use constants, and keep the statement top-level.
|
|
17075
17198
|
|
|
17076
|
-
|
|
17199
|
+
### JSX-only render templates
|
|
17200
|
+
|
|
17201
|
+
A variant may use \`render: () => <Button><Icon />Add</Button>\` instead of \`props\`. The parameterless arrow must return JSX directly: fragments, imported named/default components, literal attributes, and static source-local constants work. No statements, hooks, callbacks, calls, conditions, spreads, or unresolved values inside the template. Put behavior in an imported component instead. Do not combine render and props.
|
|
17202
|
+
|
|
17203
|
+
Tempo previews and inserts the validated JSX with its imports, resolving naming collisions. It never enters AI mode for these templates. There are no composition-wide controls before insertion; select the inserted components to edit their own controls. Props-only variants keep their existing controls and remain compatible.
|
|
17204
|
+
`;
|
|
17077
17205
|
|
|
17078
17206
|
// ../canvas-mcp/docs/canvas.ts
|
|
17079
17207
|
var CANVAS_DOCS = `# Canvas System
|
|
@@ -17153,11 +17281,11 @@ The Tempo devserver runs from \`<projectRoot>/tempo/\` (the tempo root). The \`t
|
|
|
17153
17281
|
|
|
17154
17282
|
\`canvas_project_init\` scaffolds the tempo root, and must be run before any canvas exists. It writes:
|
|
17155
17283
|
- \`tempo/index.html\`
|
|
17284
|
+
- \`tempo/controls.ts\` \u2014 optional prop editors for existing components whose source should stay untouched; auto-discovered across canvases, never imported into app entry points
|
|
17156
17285
|
- \`tempo/main.tsx\` \u2014 entry point that renders the TempoHost projection only (no app UI)
|
|
17157
17286
|
- \`tempo/vite.config.ts\` \u2014 includes \`server.fs.allow\` so the canvas can resolve user-side imports from the project root
|
|
17158
17287
|
- \`tempo/package.json\` \u2014 Tempo's own dev dependencies, distinct from any user-side \`<projectRoot>/package.json\`
|
|
17159
17288
|
- \`tempo/designs/{design-system,libraries,canvases}/\` \u2014 the canvases root and its zone folders
|
|
17160
|
-
- \`tempo/designs/canvases/template-canvas/\` \u2014 a commented example canvas (a canvas-local storyboard plus a commented real-app import) to learn the model from
|
|
17161
17289
|
|
|
17162
17290
|
**UI framework selection is explicit.** If \`apps[0].uiFramework\` is absent, Tempo creates React storyboards. For a Svelte 5 application, run \`canvas_project_init\`, set \`apps[0].uiFramework\` to \`"svelte"\` in the generated \`tempo.config.json\`, then rerun \`canvas_project_init\` before creating any storyboards. Do not infer this from dependencies; inspect the application and make the choice.
|
|
17163
17291
|
|
|
@@ -17477,6 +17605,7 @@ Before creating, modifying, restyling, or reviewing UI, read the existing app to
|
|
|
17477
17605
|
- State patterns (Redux slice? Context? Local state? RTK Query? Supabase?)
|
|
17478
17606
|
- Styling approach (Tailwind classes? CSS modules? tokens from a theme file?)
|
|
17479
17607
|
3. **Asset libraries** \u2014 query the project's reusable collections before reaching for a raw \`<div>\` or \`<button>\`: \`asset_list\` returns every blessed component with \`usageInstructions\` saying when to use it, and \`asset_get\` gives variants with real prop values. These libraries include the design system and may include other approved collections. If the index is empty or has no suitable asset, fall back to checking \`components/ui/\`, \`components/common/\`, or equivalent for an existing primitive. Prefer the app's components over hand-rolled ones every time.
|
|
17608
|
+
When creating a reusable component or changing its public props, maintain its \`defineControls\` and affected \`defineAsset\` variants. New components always keep controls in their own file. For existing components, preserve existing definitions and known user/repo preferences; prefer \`tempo/controls.ts\` for non-dev work, and ask developers once if their placement preference is unknown. Fully integrated projects prefer component-file controls. Keep assets on library canvases and never duplicate controls. Controls can exist without an asset. Read \`get_guide({ topic: "tempo-assets-instructions" })\` before editing either declaration; it covers placement, supported controls, and insertable variants.
|
|
17480
17609
|
4. **Providers** \u2014 confirm the app's entry point wires every provider the new component needs. If you add a provider to make the new UI work, add it to the app's entry, not to CanvasProviders.
|
|
17481
17610
|
5. **Mock data** \u2014 if backing data isn't available yet, hardcode realistic fixtures inline in the component as a "UI-only prototype". Do not build API clients or data-fetching scaffolding for a prototype.
|
|
17482
17611
|
|
|
@@ -17716,7 +17845,7 @@ commands.
|
|
|
17716
17845
|
|
|
17717
17846
|
**Pre-existing canvases with blank route iframes** on a project without an app dev command are a config gap, not a bug \u2014 call \`set_app_dev_command\` and the iframes light up.
|
|
17718
17847
|
|
|
17719
|
-
**Home canvas.** A project's home canvas (single \`route: "/"\` storyboard) backs the header Run (play) button and the turn-summary "Run app" card \u2014 both open it next to the app's dev-server output. When setting a project up for canvases or route storyboards, ensure one exists: \`canvas_project_init\` seeds it
|
|
17848
|
+
**Home canvas.** A project's home canvas (single \`route: "/"\` storyboard) backs the header Run (play) button and the turn-summary "Run app" card \u2014 both open it next to the app's dev-server output. When setting a project up for canvases or route storyboards, ensure one exists: \`canvas_project_init\` seeds it; if a \`route: "/"\` canvas already exists, mark it with \`canvas_set_home\` instead of duplicating; otherwise create one with \`canvas_create({ canvas_name: "Home", home: true, storyboards: [{ export_name: "Home", route: "/" }] })\`.
|
|
17720
17849
|
|
|
17721
17850
|
Use the \`set_app_dev_command\` MCP tool to write this \u2014 don't hand-edit \`tempo.config.json\` for it. The tool validates the fields and clears any cached supervisor so the next route storyboard load picks up the new config. \`create-canvas\` issues a soft-gate warning in its result when route storyboards are requested but app start is missing \u2014 confirm the command with the user, then call \`set_app_dev_command\`. When you set it, you should also check the app's bundler plugin + \`tempo-sdk\` dep are in place (above), unless you already did.
|
|
17722
17851
|
|
|
@@ -17729,6 +17858,7 @@ Once set, app \`start\` also appears automatically in the workspace header's Run
|
|
|
17729
17858
|
| \`tempo-sdk/canvas\` | Canvas primitives | \`import { Canvas, Storyboard } from 'tempo-sdk/canvas'\` |
|
|
17730
17859
|
| Root alias \`@/\` | Project components | \`import { Button } from '@/components/ui/button'\` |
|
|
17731
17860
|
| Relative \`./\` | Canvas-local files | \`import { ThemeShowcase } from './ThemeShowcase'\` |
|
|
17861
|
+
| Relative out of \`tempo/\` | Project components when the app has no root alias | \`import { Button } from '../../../../src/components/Button'\` (from \`tempo/designs/canvases/<slug>/\`) |
|
|
17732
17862
|
|
|
17733
17863
|
- Prefer direct source paths over barrel re-exports.
|
|
17734
17864
|
- For nested repo imports, use the root alias path (e.g., \`@/my-app/components/Header\`).
|
|
@@ -18148,9 +18278,13 @@ A canvas can only be linked once its branch is committed and pushed to a remote
|
|
|
18148
18278
|
|
|
18149
18279
|
// ../canvas-mcp/docs/design-system-example.ts
|
|
18150
18280
|
var EXAMPLE_FILES = [
|
|
18281
|
+
{
|
|
18282
|
+
path: "tempo-modules/tempo-design-system/components/primitives/button.tsx",
|
|
18283
|
+
source: 'import { defineControls } from "tempo-sdk/assets";\nimport { Button as ButtonPrimitive } from "@base-ui/react/button";\nimport { cva, type VariantProps } from "class-variance-authority";\nimport { Loader2 } from "lucide-react";\nimport * as React from "react";\nimport { type ReactNode } from "react";\n\nimport { cn } from "../../lib/utils.js";\n\nconst buttonVariants = cva(\n "inline-flex shrink-0 cursor-pointer select-none items-center justify-center whitespace-nowrap ring-1 ring-inset ring-transparent text-[13px] font-medium outline-none transition-[colors,transform] duration-150 ease-out active:scale-[0.97] focus-visible:ring-2 focus-visible:ring-focus/60 disabled:cursor-default disabled:pointer-events-none disabled:bg-[var(--button-disabled-surface)] disabled:text-[var(--button-disabled-text)] disabled:ring-transparent disabled:active:scale-100 [&_svg]:pointer-events-none [&_svg]:shrink-0",\n {\n variants: {\n variant: {\n primary:\n "bg-accent text-on-accent hover:bg-accent/85 active:bg-accent/75",\n secondary: "bg-accent-subtle text-accent hover:bg-accent-subtle-hover",\n outline: "ring-accent/40 bg-surface text-accent hover:bg-accent/10",\n // `ghost` and `link` opt out of BOTH halves of the base disabled pair\n // (`--button-disabled-surface` fill + `--button-disabled-text` ink).\n // They are transparent by design, so filling them on disable makes the\n // control LOUDER than its enabled state \u2014 and the paired ink is tuned\n // for that fill (white-on-base-200 in light), so keeping it on a\n // transparent button renders a white glyph on the light app chrome\n // (the invisible disabled nav chevron). Disabled ghost/link stay\n // transparent and signal purely through dimmed `text-text-tertiary`.\n ghost:\n "text-accent hover:bg-accent/10 disabled:bg-transparent disabled:text-text-tertiary",\n link: "bg-transparent text-accent underline-offset-4 hover:text-accent/85 hover:underline disabled:bg-transparent disabled:text-text-tertiary",\n },\n tone: {\n default: "",\n critical: "",\n success: "",\n warning: "",\n info: "",\n },\n isIconOnly: {\n true: "",\n false: "",\n },\n size: {\n xs: "h-6 gap-1 rounded px-2 text-xs",\n sm: "h-7 gap-1 rounded-md px-2.5",\n default: "h-8 gap-1.5 rounded-md px-3",\n lg: "h-9 gap-1.5 rounded-lg px-3.5",\n },\n },\n compoundVariants: [\n { isIconOnly: true, size: "xs", class: "w-6 px-0" },\n { isIconOnly: true, size: "sm", class: "w-7 px-0" },\n { isIconOnly: true, size: "default", class: "w-8 px-0" },\n { isIconOnly: true, size: "lg", class: "w-9 px-0" },\n\n { variant: "link", size: "xs", class: "h-auto w-auto p-0 text-xs" },\n { variant: "link", size: "sm", class: "h-auto w-auto p-0" },\n { variant: "link", size: "default", class: "h-auto w-auto p-0" },\n { variant: "link", size: "lg", class: "h-auto w-auto p-0" },\n\n {\n variant: "primary",\n tone: "critical",\n class:\n "bg-critical text-on-critical hover:bg-critical/85 active:bg-critical/75",\n },\n {\n variant: "primary",\n tone: "success",\n class:\n "bg-success text-on-success hover:bg-success/85 active:bg-success/75",\n },\n {\n variant: "primary",\n tone: "warning",\n class:\n "bg-warning text-on-warning hover:bg-warning/85 active:bg-warning/75",\n },\n {\n variant: "primary",\n tone: "info",\n class: "bg-info text-on-info hover:bg-info/85 active:bg-info/75",\n },\n\n {\n variant: "secondary",\n tone: "critical",\n class:\n "bg-critical-subtle text-critical hover:bg-critical-subtle-hover",\n },\n {\n variant: "secondary",\n tone: "success",\n class: "bg-success-subtle text-success hover:bg-success-subtle-hover",\n },\n {\n variant: "secondary",\n tone: "warning",\n class: "bg-warning-subtle text-warning hover:bg-warning-subtle-hover",\n },\n {\n variant: "secondary",\n tone: "info",\n class: "bg-info-subtle text-info hover:bg-info-subtle-hover",\n },\n\n // An outline button\'s identity IS its ring, so it keeps one when\n // disabled \u2014 the base rule (filled disabled surface, `ring-transparent`)\n // would otherwise render it as a filled disabled pill, indistinguishable\n // from a disabled `primary`/`secondary`. The ring drops to a neutral\n // border token: still an outline, no longer an accent inviting a click.\n {\n variant: "outline",\n class:\n // Same transparent-background reasoning as ghost/link: without the\n // fill, the base\'s `--button-disabled-text` (white in light) has\n // nothing behind it, so the ink dims to text-tertiary instead.\n "disabled:bg-transparent disabled:ring-1 disabled:ring-border-secondary disabled:text-text-tertiary",\n },\n\n {\n variant: "outline",\n tone: "critical",\n class: "ring-critical/50 text-critical hover:bg-critical/10",\n },\n {\n variant: "outline",\n tone: "success",\n class: "ring-success/50 text-success hover:bg-success/10",\n },\n {\n variant: "outline",\n tone: "warning",\n class: "ring-warning/50 text-warning hover:bg-warning/10",\n },\n {\n variant: "outline",\n tone: "info",\n class: "ring-info/50 text-info hover:bg-info/10",\n },\n\n {\n variant: "ghost",\n tone: "critical",\n class: "text-critical hover:bg-critical/10",\n },\n {\n variant: "ghost",\n tone: "success",\n class: "text-success hover:bg-success/10",\n },\n {\n variant: "ghost",\n tone: "warning",\n class: "text-warning hover:bg-warning/10",\n },\n { variant: "ghost", tone: "info", class: "text-info hover:bg-info/10" },\n\n {\n variant: "link",\n tone: "critical",\n class: "text-critical hover:text-critical/85",\n },\n {\n variant: "link",\n tone: "success",\n class: "text-success hover:text-success/85",\n },\n {\n variant: "link",\n tone: "warning",\n class: "text-warning hover:text-warning/85",\n },\n { variant: "link", tone: "info", class: "text-info hover:text-info/85" },\n ],\n defaultVariants: {\n variant: "primary",\n tone: "default",\n size: "xs",\n },\n },\n);\n\ntype ButtonBaseProps = ButtonPrimitive.Props &\n VariantProps<typeof buttonVariants>;\nconst BUTTON_ACCENTS = [\n "base",\n "graphite",\n "lavender",\n "salmon",\n "mustard",\n "blueberry",\n "kiwi",\n] as const;\ntype ButtonAccent = (typeof BUTTON_ACCENTS)[number];\n\ninterface ButtonProps extends ButtonBaseProps {\n icon?: ReactNode;\n leading?: boolean;\n isLoading?: boolean;\n accent?: ButtonAccent;\n}\n\nfunction toRenderableNode(node: ReactNode): ReactNode | null {\n if (node == null || typeof node === "boolean") return null;\n if (typeof node === "string" || typeof node === "number") return node;\n if (Array.isArray(node)) {\n const normalized = node\n .map((child) => toRenderableNode(child))\n .filter((child) => child != null);\n return normalized.length ? normalized : null;\n }\n return React.isValidElement(node) ? node : null;\n}\n\n/**\n * The canvas for this component is at tempo/designs/design-system/buttons/index.canvas.tsx.\n * If you adjust this component in any way, ensure the canvas and its asset\n * declaration stay consistent.\n */\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n className,\n variant = "primary",\n tone = "default",\n size = "xs",\n icon,\n leading = true,\n isLoading = false,\n accent,\n disabled,\n children,\n "aria-label": ariaLabel,\n "aria-labelledby": ariaLabelledBy,\n ...props\n },\n ref,\n) {\n const safeChildren = toRenderableNode(children);\n const safeIcon = toRenderableNode(icon);\n const hasVisualIcon = !!(safeIcon || isLoading);\n const isIconOnly = hasVisualIcon && safeChildren == null;\n const resolvedIcon = isLoading ? (\n <Loader2 className="size-3.5 animate-spin" aria-hidden="true" />\n ) : (\n safeIcon\n );\n const accentClass =\n tone === "default" && accent ? `button-accent-${accent}` : undefined;\n\n if (process.env.NODE_ENV !== "production") {\n if (!hasVisualIcon && safeChildren == null) {\n console.warn(\n "[Button] Provide either `children`, `icon`, or `isLoading`.",\n );\n }\n\n if (isIconOnly && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n "[Button] Icon-only buttons must have `aria-label` or `aria-labelledby`.",\n );\n }\n\n if (accent && tone !== "default") {\n console.warn(\'[Button] `accent` is ignored unless `tone` is "default".\');\n }\n }\n\n return (\n <ButtonPrimitive\n ref={ref}\n data-slot="button"\n className={cn(\n buttonVariants({\n variant,\n tone,\n size,\n isIconOnly: isIconOnly || undefined,\n }),\n accentClass,\n className,\n "[--tw-outline-style:none]",\n )}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-busy={isLoading || undefined}\n disabled={disabled || isLoading}\n {...props}\n >\n {!isIconOnly && resolvedIcon && leading && resolvedIcon}\n {safeChildren}\n {!isIconOnly && resolvedIcon && !leading && resolvedIcon}\n {isIconOnly && resolvedIcon}\n </ButtonPrimitive>\n );\n});\n\nButton.displayName = "Button";\n\nexport { Button, buttonVariants, type ButtonProps };\n\ndefineControls(Button, {\n children: { type: "text" },\n variant: { type: "select" },\n tone: { type: "select" },\n size: { type: "select" },\n disabled: { type: "boolean" },\n isLoading: { type: "boolean" },\n onClick: false,\n});\n'
|
|
18284
|
+
},
|
|
18151
18285
|
{
|
|
18152
18286
|
path: "index.canvas.tsx",
|
|
18153
|
-
source: 'import { Canvas, Storyboard } from "tempo-sdk/canvas";\nimport { defineAsset } from "tempo-sdk/assets";\nimport { Button } from "@tempo-modules/tempo-design-system";\nimport { BoardIntro } from "./BoardIntro";\nimport { BoardVariantsTones } from "./BoardVariantsTones";\nimport { BoardSizes } from "./BoardSizes";\nimport { BoardDesignSystemDebt } from "./BoardDesignSystemDebt";\n\nexport default function DesignSystemButtonsCanvas() {\n return (\n <Canvas name="Design System Buttons">\n <Storyboard\n id="Intro"\n name="Intro"\n component={BoardIntro}\n layout={{ x: 0, y: 0, width: 900, height: 860 }}\n />\n <Storyboard\n id="VariantsTones"\n name={"Variants & Tones"}\n component={BoardVariantsTones}\n layout={{ x: 950, y: 0, width: 1050, height: 1150 }}\n />\n <Storyboard\n id="Sizes"\n name="Sizes"\n component={BoardSizes}\n layout={{ x: 2050, y: 0, width: 900, height: 700 }}\n />\n <Storyboard\n id="DesignSystemDebt"\n name="Design System Debt"\n component={BoardDesignSystemDebt}\n layout={{ x: 3000, y: 0, width:
|
|
18287
|
+
source: 'import { Canvas, Storyboard } from "tempo-sdk/canvas";\nimport { defineAsset } from "tempo-sdk/assets";\nimport { Button } from "@tempo-modules/tempo-design-system";\nimport { BoardIntro } from "./BoardIntro";\nimport { BoardVariantsTones } from "./BoardVariantsTones";\nimport { BoardSizes } from "./BoardSizes";\nimport { BoardDesignSystemDebt } from "./BoardDesignSystemDebt";\n\nexport default function DesignSystemButtonsCanvas() {\n return (\n <Canvas name="Design System Buttons">\n <Storyboard\n id="Intro"\n vrt\n name="Intro"\n component={BoardIntro}\n layout={{ x: 0, y: 0, width: 900, height: 860 }}\n />\n <Storyboard\n id="VariantsTones"\n name={"Variants & Tones"}\n component={BoardVariantsTones}\n layout={{ x: 950, y: 0, width: 1050, height: 1150 }}\n />\n <Storyboard\n id="Sizes"\n name="Sizes"\n component={BoardSizes}\n layout={{ x: 2050, y: 0, width: 900, height: 700 }}\n />\n <Storyboard\n id="DesignSystemDebt"\n name="Design System Debt"\n component={BoardDesignSystemDebt}\n layout={{ x: 3000, y: 0, width: 3770, height: 4220 }}\n />\n </Canvas>\n );\n}\n\ndefineAsset(Button, {\n libraries: ["Design System"],\n usageInstructions:\n "actions, CTAs, form submits \u2014 not navigation (use a link)",\n variants: {\n Primary: { props: { children: "Save changes" } },\n "Secondary sm": {\n props: { variant: "secondary", size: "sm", children: "Duplicate" },\n },\n "Ghost cancel": {\n props: { variant: "ghost", size: "sm", children: "Cancel" },\n },\n "Critical outline": {\n props: {\n variant: "outline",\n tone: "critical",\n size: "sm",\n children: "Delete stage",\n },\n },\n },\n});\n'
|
|
18154
18288
|
},
|
|
18155
18289
|
{
|
|
18156
18290
|
path: "Chrome.tsx",
|
|
@@ -18850,8 +18984,18 @@ canvases root (create them with \`canvas_create({ canvas_name:
|
|
|
18850
18984
|
\`defineAsset\` declaration or \`canvas_validate\` fails with
|
|
18851
18985
|
\`missing_asset_declaration\`.
|
|
18852
18986
|
|
|
18987
|
+
This is Tempo's actual production Button, not a separate example project.
|
|
18988
|
+
Tempo is fully integrated, so defineControls(Button, ...) lives in Button's own
|
|
18989
|
+
component file; reusable variants live on the Buttons canvas. New components
|
|
18990
|
+
always keep controls in their own file. For existing components, follow the
|
|
18991
|
+
placement policy in tempo-assets-instructions: preserve existing definitions
|
|
18992
|
+
and known preferences, prefer tempo/controls.ts for non-dev design-system
|
|
18993
|
+
work, and ask developers once when their preference is unknown. Both locations
|
|
18994
|
+
work across canvases without library membership; never duplicate declarations.
|
|
18995
|
+
|
|
18853
18996
|
File anatomy:
|
|
18854
18997
|
|
|
18998
|
+
- The production Button file \u2014 real props, implementation, and colocated controls.
|
|
18855
18999
|
- \`index.canvas.tsx\` \u2014 the canvas entry: \`<Storyboard>\` list with explicit
|
|
18856
19000
|
\`layout\` coordinates, and the bottom-of-file \`defineAsset(...)\` statements:
|
|
18857
19001
|
one **reference declaration per top-level component the canvas showcases** \u2014
|
|
@@ -19034,11 +19178,9 @@ function registerDocs(server, context) {
|
|
|
19034
19178
|
);
|
|
19035
19179
|
server.tool(
|
|
19036
19180
|
"get_guide",
|
|
19037
|
-
assetsEnabled ? "Returns canvas documentation by topic. Pick by INTENT, not by name similarity: 'tempo-canvas-instructions' \u2014 the full canvas authoring guide; MUST be called before your first canvas operation in a session. 'tempo-assets-instructions' \u2014 the design-system conventions: defineAsset authoring rules
|
|
19181
|
+
assetsEnabled ? "Returns canvas documentation by topic. Pick by INTENT, not by name similarity: 'tempo-canvas-instructions' \u2014 the full canvas authoring guide; MUST be called before your first canvas operation in a session. 'tempo-assets-instructions' \u2014 the design-system conventions: defineControls + defineAsset authoring rules, placement, and asset_* write recipes; MUST be read before ADDING or EDITING controls or asset declarations, but NOT needed to browse (browse directly with asset_list / asset_list_libraries \u2014 never via a guide). 'tempo-design-system-example' \u2014 the full source of the reference design-system canvas; read ONLY when authoring a design-system canvas, to mirror its anatomy and formatting \u2014 it is not a way to look up what's in the design system. 'tempo-visual-review-setup' \u2014 the protocol for turning on visual review (VRT) for a repo: how to read visual_review_doctor's rows, what visual_review_init writes, picking + verifying the first tracked set, other-CI limits, and the debugging ladder; MUST be read before running visual_review_doctor / visual_review_init." : "Returns canvas documentation by topic. Topics: 'tempo-canvas-instructions' (full canvas authoring guide \u2014 MUST be called before your first canvas operation in a session), 'tempo-design-system-example' (full source of the reference design-system canvas \u2014 read before authoring design-system canvases to mirror its anatomy and formatting), 'tempo-visual-review-setup' (the visual review setup protocol \u2014 MUST be read before visual_review_doctor / visual_review_init).",
|
|
19038
19182
|
{
|
|
19039
|
-
topic: z22.enum(topicNames).describe(
|
|
19040
|
-
`Guide topic. Currently supported: ${topicNames.join(", ")}`
|
|
19041
|
-
)
|
|
19183
|
+
topic: z22.enum(topicNames).describe(`Guide topic. Currently supported: ${topicNames.join(", ")}`)
|
|
19042
19184
|
},
|
|
19043
19185
|
async ({ topic }) => {
|
|
19044
19186
|
const payload = GUIDE_TOPICS[topic];
|
|
@@ -19099,19 +19241,15 @@ function registerDocs(server, context) {
|
|
|
19099
19241
|
})
|
|
19100
19242
|
);
|
|
19101
19243
|
if (assetsEnabled) {
|
|
19102
|
-
server.resource(
|
|
19103
|
-
|
|
19104
|
-
|
|
19105
|
-
|
|
19106
|
-
|
|
19107
|
-
|
|
19108
|
-
|
|
19109
|
-
|
|
19110
|
-
|
|
19111
|
-
}
|
|
19112
|
-
]
|
|
19113
|
-
})
|
|
19114
|
-
);
|
|
19244
|
+
server.resource("tempo://docs/assets", "tempo://docs/assets", async () => ({
|
|
19245
|
+
contents: [
|
|
19246
|
+
{
|
|
19247
|
+
uri: "tempo://docs/assets",
|
|
19248
|
+
text: resolveTemplate(ASSET_DOCS, context),
|
|
19249
|
+
mimeType: "text/markdown"
|
|
19250
|
+
}
|
|
19251
|
+
]
|
|
19252
|
+
}));
|
|
19115
19253
|
}
|
|
19116
19254
|
}
|
|
19117
19255
|
|
|
@@ -19119,7 +19257,7 @@ function registerDocs(server, context) {
|
|
|
19119
19257
|
function buildCanvasInstructions(canvasesDir, options) {
|
|
19120
19258
|
const assetLibrarySection = options?.assetsEnabled === false ? "" : `## Asset libraries
|
|
19121
19259
|
|
|
19122
|
-
Before creating, modifying, restyling, or reviewing ANY UI, call \`asset_list\` FIRST and reuse results per \`usageInstructions\`. Do the same for design system, component library, or UI kit requests; use \`asset_list_libraries\` for a collection overview.
|
|
19260
|
+
Before creating, modifying, restyling, or reviewing ANY UI, call \`asset_list\` FIRST and reuse results per \`usageInstructions\`. Do the same for design system, component library, or UI kit requests; use \`asset_list_libraries\` for a collection overview. Before editing \`defineControls\` or \`defineAsset\`, read get_guide({ topic: "tempo-assets-instructions" }). Follow its controls-placement policy. Assets declare top-level components.
|
|
19123
19261
|
|
|
19124
19262
|
`;
|
|
19125
19263
|
return `Tempo canvases are code-first. Canvases live under the canvases root ${canvasesDir}/, whose storyboards render PRODUCTION components and routes \u2014 never mocks of existing UI.
|
|
@@ -19174,6 +19312,118 @@ function parseAssetFile(filePath, source) {
|
|
|
19174
19312
|
span: misimport.span
|
|
19175
19313
|
});
|
|
19176
19314
|
}
|
|
19315
|
+
const constants = /* @__PURE__ */ new Map();
|
|
19316
|
+
for (const statement of program.body) {
|
|
19317
|
+
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
19318
|
+
if (declaration?.type !== "VariableDeclaration" || declaration.kind !== "const")
|
|
19319
|
+
continue;
|
|
19320
|
+
for (const binding of declaration.declarations)
|
|
19321
|
+
if (binding.id.type === "Identifier" && binding.init)
|
|
19322
|
+
constants.set(binding.id.name, binding.init);
|
|
19323
|
+
}
|
|
19324
|
+
const resolveConstants = (node, seen = /* @__PURE__ */ new Set(), depth = 0) => {
|
|
19325
|
+
if (!node || depth > 16) return node;
|
|
19326
|
+
if (node.type === "Identifier" && constants.has(node.name) && !seen.has(node.name))
|
|
19327
|
+
return resolveConstants(
|
|
19328
|
+
constants.get(node.name),
|
|
19329
|
+
new Set(seen).add(node.name),
|
|
19330
|
+
depth + 1
|
|
19331
|
+
);
|
|
19332
|
+
if (node.type === "JSXElement" || node.type === "JSXFragment") {
|
|
19333
|
+
const element = node.openingElement;
|
|
19334
|
+
const tag = element?.name?.type === "JSXIdentifier" ? element.name.name : "";
|
|
19335
|
+
if (element && !tag) return node;
|
|
19336
|
+
const reference = tag && /^[A-Z]/.test(tag) ? imports.referenceableImports.get(tag) : void 0;
|
|
19337
|
+
if (tag && /^[A-Z]/.test(tag) && !reference) return node;
|
|
19338
|
+
const props = {};
|
|
19339
|
+
for (const attribute of element?.attributes ?? []) {
|
|
19340
|
+
if (attribute.type !== "JSXAttribute" || attribute.name.type !== "JSXIdentifier")
|
|
19341
|
+
return node;
|
|
19342
|
+
props[attribute.name.name] = !attribute.value ? true : readStaticValue(
|
|
19343
|
+
resolveConstants(
|
|
19344
|
+
attribute.value.type === "JSXExpressionContainer" ? attribute.value.expression : attribute.value,
|
|
19345
|
+
seen,
|
|
19346
|
+
depth + 1
|
|
19347
|
+
)
|
|
19348
|
+
);
|
|
19349
|
+
}
|
|
19350
|
+
const children = [];
|
|
19351
|
+
for (const child of node.children) {
|
|
19352
|
+
if (child.type === "JSXText") {
|
|
19353
|
+
const lines = child.value.replace(/\t/g, " ").split(/\r\n|\n|\r/);
|
|
19354
|
+
const text = lines.map(
|
|
19355
|
+
(line, i) => (i ? line.trimStart() : line).replace(
|
|
19356
|
+
i < lines.length - 1 ? / +$/ : /$^/,
|
|
19357
|
+
""
|
|
19358
|
+
)
|
|
19359
|
+
).filter(Boolean).join(" ");
|
|
19360
|
+
if (text) children.push(text);
|
|
19361
|
+
} else if (child.type === "JSXExpressionContainer" && child.expression.type === "JSXEmptyExpression")
|
|
19362
|
+
continue;
|
|
19363
|
+
else
|
|
19364
|
+
children.push(
|
|
19365
|
+
readStaticValue(
|
|
19366
|
+
resolveConstants(
|
|
19367
|
+
child.type === "JSXExpressionContainer" ? child.expression : child,
|
|
19368
|
+
seen,
|
|
19369
|
+
depth + 1
|
|
19370
|
+
)
|
|
19371
|
+
)
|
|
19372
|
+
);
|
|
19373
|
+
}
|
|
19374
|
+
if (children.length)
|
|
19375
|
+
props.children = children.length === 1 ? children[0] : children;
|
|
19376
|
+
let source2 = reference?.importSpecifier;
|
|
19377
|
+
if (source2?.startsWith(".")) {
|
|
19378
|
+
const parts = filePath.replace(/\\/g, "/").split("/").slice(0, -1);
|
|
19379
|
+
for (const part of source2.split("/")) {
|
|
19380
|
+
if (part === "..") parts.pop();
|
|
19381
|
+
else if (part !== ".") parts.push(part);
|
|
19382
|
+
}
|
|
19383
|
+
source2 = parts.join("/");
|
|
19384
|
+
} else if (source2) source2 = `pkg:${source2}`;
|
|
19385
|
+
return {
|
|
19386
|
+
type: "TempoJsxValue",
|
|
19387
|
+
value: {
|
|
19388
|
+
$jsx: {
|
|
19389
|
+
tag,
|
|
19390
|
+
...reference ? { reference: { source: source2, importedName: reference.importedName } } : {},
|
|
19391
|
+
props
|
|
19392
|
+
}
|
|
19393
|
+
}
|
|
19394
|
+
};
|
|
19395
|
+
}
|
|
19396
|
+
if (node.type === "ArrowFunctionExpression" && !node.async && node.params.length === 0)
|
|
19397
|
+
return { ...node, body: resolveConstants(node.body, seen, depth + 1) };
|
|
19398
|
+
if (node.type === "ObjectExpression")
|
|
19399
|
+
return {
|
|
19400
|
+
...node,
|
|
19401
|
+
properties: node.properties.map(
|
|
19402
|
+
(property) => property.type === "Property" ? {
|
|
19403
|
+
...property,
|
|
19404
|
+
value: resolveConstants(property.value, seen, depth + 1),
|
|
19405
|
+
shorthand: false
|
|
19406
|
+
} : property
|
|
19407
|
+
)
|
|
19408
|
+
};
|
|
19409
|
+
if (node.type === "ArrayExpression")
|
|
19410
|
+
return {
|
|
19411
|
+
...node,
|
|
19412
|
+
elements: node.elements.map(
|
|
19413
|
+
(item) => resolveConstants(item, seen, depth + 1)
|
|
19414
|
+
)
|
|
19415
|
+
};
|
|
19416
|
+
if ([
|
|
19417
|
+
"TSAsExpression",
|
|
19418
|
+
"TSSatisfiesExpression",
|
|
19419
|
+
"ParenthesizedExpression"
|
|
19420
|
+
].includes(node.type))
|
|
19421
|
+
return {
|
|
19422
|
+
...node,
|
|
19423
|
+
expression: resolveConstants(node.expression, seen, depth + 1)
|
|
19424
|
+
};
|
|
19425
|
+
return node;
|
|
19426
|
+
};
|
|
19177
19427
|
const scope = collectTopLevelScope(program);
|
|
19178
19428
|
const declarations = [];
|
|
19179
19429
|
const declaredBindings = /* @__PURE__ */ new Set();
|
|
@@ -19187,7 +19437,19 @@ function parseAssetFile(filePath, source) {
|
|
|
19187
19437
|
topLevelCalls.add(call);
|
|
19188
19438
|
const declaration = readAssetDeclaration({
|
|
19189
19439
|
statement,
|
|
19190
|
-
call
|
|
19440
|
+
call: {
|
|
19441
|
+
...call,
|
|
19442
|
+
arguments: call.arguments.map(
|
|
19443
|
+
(argument, index) => index === 1 && argument.type === "ObjectExpression" ? {
|
|
19444
|
+
...argument,
|
|
19445
|
+
properties: argument.properties.map(
|
|
19446
|
+
(property) => property.type === "Property" && ["controls", "variants"].includes(
|
|
19447
|
+
property.key.name ?? property.key.value
|
|
19448
|
+
) ? { ...property, value: resolveConstants(property.value) } : property
|
|
19449
|
+
)
|
|
19450
|
+
} : argument
|
|
19451
|
+
)
|
|
19452
|
+
},
|
|
19191
19453
|
scope,
|
|
19192
19454
|
imports,
|
|
19193
19455
|
program,
|
|
@@ -19207,6 +19469,16 @@ function parseAssetFile(filePath, source) {
|
|
|
19207
19469
|
});
|
|
19208
19470
|
}
|
|
19209
19471
|
});
|
|
19472
|
+
for (const declaration of declarations) {
|
|
19473
|
+
const duplicate = errors.find(
|
|
19474
|
+
(error) => error.code === "duplicate_declaration" && error.message.includes(`"${declaration.bindingName}"`)
|
|
19475
|
+
);
|
|
19476
|
+
if (duplicate)
|
|
19477
|
+
declaration.warnings.push({
|
|
19478
|
+
...duplicate,
|
|
19479
|
+
code: "duplicate_asset_declaration"
|
|
19480
|
+
});
|
|
19481
|
+
}
|
|
19210
19482
|
return { filePath, declarations, errors };
|
|
19211
19483
|
}
|
|
19212
19484
|
function parseAssetProgram(filePath, source) {
|
|
@@ -19253,6 +19525,7 @@ function readSourceComments(filePath, source) {
|
|
|
19253
19525
|
}
|
|
19254
19526
|
function readAssetImports(program) {
|
|
19255
19527
|
const info = {
|
|
19528
|
+
trustedDefineControlsNames: /* @__PURE__ */ new Set(),
|
|
19256
19529
|
trustedDefineAssetNames: /* @__PURE__ */ new Set(),
|
|
19257
19530
|
importedBindings: /* @__PURE__ */ new Map(),
|
|
19258
19531
|
referenceableImports: /* @__PURE__ */ new Map(),
|
|
@@ -19286,6 +19559,8 @@ function readAssetImports(program) {
|
|
|
19286
19559
|
importSpecifier: source,
|
|
19287
19560
|
importedName
|
|
19288
19561
|
});
|
|
19562
|
+
if (trusted && importedName === "defineControls")
|
|
19563
|
+
info.trustedDefineControlsNames.add(localName);
|
|
19289
19564
|
if (importedName !== "defineAsset") continue;
|
|
19290
19565
|
if (trusted) {
|
|
19291
19566
|
info.trustedDefineAssetNames.add(localName);
|
|
@@ -19299,6 +19574,29 @@ function readAssetImports(program) {
|
|
|
19299
19574
|
}
|
|
19300
19575
|
return info;
|
|
19301
19576
|
}
|
|
19577
|
+
function parseControlsFile(filePath, source) {
|
|
19578
|
+
const { program } = parseAssetProgram(filePath, source);
|
|
19579
|
+
const imports = readAssetImports(program);
|
|
19580
|
+
const scope = program ? collectTopLevelScope(program) : null;
|
|
19581
|
+
return (program?.body ?? []).flatMap((statement) => {
|
|
19582
|
+
const call = statement.type === "ExpressionStatement" ? statement.expression : null;
|
|
19583
|
+
if (call?.type !== "CallExpression" || call.callee.type !== "Identifier" || !imports.trustedDefineControlsNames?.has(call.callee.name) || call.arguments.length !== 2 || call.arguments[0]?.type !== "Identifier")
|
|
19584
|
+
return [];
|
|
19585
|
+
const bindingName = call.arguments[0].name;
|
|
19586
|
+
const reference = imports.referenceableImports.get(bindingName);
|
|
19587
|
+
const binding = scope?.bindings.get(bindingName);
|
|
19588
|
+
if (!reference && !binding) return [];
|
|
19589
|
+
return [
|
|
19590
|
+
{
|
|
19591
|
+
bindingName,
|
|
19592
|
+
reference,
|
|
19593
|
+
exportKind: reference?.importedName === "default" ? "default" : binding?.exportKind ?? "named",
|
|
19594
|
+
start: call.start,
|
|
19595
|
+
end: call.end
|
|
19596
|
+
}
|
|
19597
|
+
];
|
|
19598
|
+
});
|
|
19599
|
+
}
|
|
19302
19600
|
function isTrustedAssetImportSource(source) {
|
|
19303
19601
|
return source === ASSET_SDK_IMPORT_SOURCE || source.endsWith(`/${ASSET_SDK_IMPORT_SOURCE}`);
|
|
19304
19602
|
}
|
|
@@ -19483,7 +19781,7 @@ function readAssetDeclaration(input) {
|
|
|
19483
19781
|
errors.push({
|
|
19484
19782
|
code: "duplicate_declaration",
|
|
19485
19783
|
severity: "structural",
|
|
19486
|
-
message: `duplicate defineAsset call for "${bindingName}" \u2014
|
|
19784
|
+
message: `duplicate defineAsset call for "${bindingName}" \u2014 keep one asset declaration`,
|
|
19487
19785
|
span: callSpan
|
|
19488
19786
|
});
|
|
19489
19787
|
return null;
|
|
@@ -19498,6 +19796,21 @@ function readAssetDeclaration(input) {
|
|
|
19498
19796
|
const usageInstructions = readUsageInstructions(configArg);
|
|
19499
19797
|
const libraries = readLibraries(configArg, spans, warnings);
|
|
19500
19798
|
const variants = readVariants(configArg, warnings);
|
|
19799
|
+
if (getObjectProperty(configArg, "controls")) {
|
|
19800
|
+
errors.push({
|
|
19801
|
+
code: "invalid_control",
|
|
19802
|
+
severity: "structural",
|
|
19803
|
+
message: "Move controls to defineControls(Component, controls) in the component file or tempo/controls.ts."
|
|
19804
|
+
});
|
|
19805
|
+
return null;
|
|
19806
|
+
}
|
|
19807
|
+
const structural = warnings.filter(
|
|
19808
|
+
(warning) => warning.severity === "structural"
|
|
19809
|
+
);
|
|
19810
|
+
if (structural.length) {
|
|
19811
|
+
errors.push(...structural);
|
|
19812
|
+
return null;
|
|
19813
|
+
}
|
|
19501
19814
|
if (binding && binding.exportKind === "none") {
|
|
19502
19815
|
warnings.push({
|
|
19503
19816
|
code: "not_exported",
|
|
@@ -19664,8 +19977,31 @@ function readVariants(configNode, warnings) {
|
|
|
19664
19977
|
}
|
|
19665
19978
|
function readVariant(name, entry, warnings) {
|
|
19666
19979
|
const value = unwrapTsExpression(entry.value);
|
|
19980
|
+
for (const property of value?.type === "ObjectExpression" ? value.properties : []) {
|
|
19981
|
+
if (property.type !== "Property" || property.computed || !["props", "render"].includes(readPropertyKeyName(property.key) ?? "")) {
|
|
19982
|
+
warnings.push({
|
|
19983
|
+
code: "invalid_variant_config",
|
|
19984
|
+
severity: "structural",
|
|
19985
|
+
message: `Variant "${name}" accepts either props or render, with explicit keys and no spreads or inheritance`,
|
|
19986
|
+
span: toSourceSpan(property)
|
|
19987
|
+
});
|
|
19988
|
+
}
|
|
19989
|
+
}
|
|
19990
|
+
const renderProperty = value?.type === "ObjectExpression" ? getObjectProperty(value, "render") : null;
|
|
19667
19991
|
const propsProperty = value?.type === "ObjectExpression" ? getObjectProperty(value, "props") : null;
|
|
19668
|
-
const
|
|
19992
|
+
const fn = unwrapTsExpression(renderProperty?.value);
|
|
19993
|
+
const body = unwrapTsExpression(fn?.body);
|
|
19994
|
+
const jsx = body?.type === "TempoJsxValue" ? readStaticValue(body) : UNRESOLVED_VALUE;
|
|
19995
|
+
const validRender = fn?.type === "ArrowFunctionExpression" && !fn.async && fn.params.length === 0 && !propsProperty && !containsUnresolvedValue(jsx);
|
|
19996
|
+
if (renderProperty && !validRender)
|
|
19997
|
+
warnings.push({
|
|
19998
|
+
code: "invalid_variant_config",
|
|
19999
|
+
severity: "structural",
|
|
20000
|
+
message: `Variant "${name}" render must be a parameterless arrow returning static JSX, without props, statements, hooks, callbacks, or computed expressions. Move logic into an imported component.`,
|
|
20001
|
+
span: toSourceSpan(renderProperty)
|
|
20002
|
+
});
|
|
20003
|
+
const render = renderProperty && validRender ? { jsx } : void 0;
|
|
20004
|
+
const propsValue = propsProperty ? readStaticValue(propsProperty.value) : render ? {} : UNRESOLVED_VALUE;
|
|
19669
20005
|
const props = isPlainRecord(propsValue) ? propsValue : {};
|
|
19670
20006
|
const hasUnresolvedValues = !isPlainRecord(propsValue) || containsUnresolvedValue(propsValue);
|
|
19671
20007
|
if (hasUnresolvedValues) {
|
|
@@ -19676,12 +20012,14 @@ function readVariant(name, entry, warnings) {
|
|
|
19676
20012
|
span: toSourceSpan(entry)
|
|
19677
20013
|
});
|
|
19678
20014
|
}
|
|
19679
|
-
return { name, props, hasUnresolvedValues };
|
|
20015
|
+
return { name, props, hasUnresolvedValues, ...render ? { render } : {} };
|
|
19680
20016
|
}
|
|
19681
20017
|
function readStaticValue(node) {
|
|
19682
20018
|
const expression = unwrapTsExpression(node);
|
|
19683
20019
|
if (!expression) return UNRESOLVED_VALUE;
|
|
19684
20020
|
switch (expression.type) {
|
|
20021
|
+
case "TempoJsxValue":
|
|
20022
|
+
return expression.value;
|
|
19685
20023
|
case "Literal": {
|
|
19686
20024
|
if (expression.regex || expression.bigint) return UNRESOLVED_VALUE;
|
|
19687
20025
|
const { value } = expression;
|
|
@@ -19709,7 +20047,11 @@ function readStaticValue(node) {
|
|
|
19709
20047
|
}
|
|
19710
20048
|
const key = readPropertyKeyName(property.key);
|
|
19711
20049
|
if (key === null) return UNRESOLVED_VALUE;
|
|
19712
|
-
record
|
|
20050
|
+
Object.defineProperty(record, key, {
|
|
20051
|
+
value: readStaticValue(property.value),
|
|
20052
|
+
enumerable: true,
|
|
20053
|
+
configurable: true
|
|
20054
|
+
});
|
|
19713
20055
|
}
|
|
19714
20056
|
return record;
|
|
19715
20057
|
}
|
|
@@ -20353,6 +20695,7 @@ import path5 from "path";
|
|
|
20353
20695
|
// ../asset-libraries/component-resolution.ts
|
|
20354
20696
|
import { readdir as readdir2, readFile as readFile3 } from "fs/promises";
|
|
20355
20697
|
import path3 from "path";
|
|
20698
|
+
import ts from "typescript";
|
|
20356
20699
|
|
|
20357
20700
|
// ../asset-libraries/discovery.ts
|
|
20358
20701
|
import { readdir, readFile as readFile2 } from "fs/promises";
|
|
@@ -20365,7 +20708,7 @@ function hasAssetSourceExtension(filePath) {
|
|
|
20365
20708
|
);
|
|
20366
20709
|
}
|
|
20367
20710
|
function sourceMayDeclareAssets(source) {
|
|
20368
|
-
return source.includes(DEFINE_ASSET_PREFILTER);
|
|
20711
|
+
return source.includes(DEFINE_ASSET_PREFILTER) || source.includes("defineControls");
|
|
20369
20712
|
}
|
|
20370
20713
|
var IGNORED_DIRECTORY_NAMES = /* @__PURE__ */ new Set(["node_modules", "dist", "build"]);
|
|
20371
20714
|
function isIgnoredSegment(segment) {
|
|
@@ -20411,6 +20754,42 @@ async function scanRepo(repoRoot) {
|
|
|
20411
20754
|
}
|
|
20412
20755
|
|
|
20413
20756
|
// ../asset-libraries/component-resolution.ts
|
|
20757
|
+
function resolveProjectModule(resolution, specifier, fromFile = "index.ts") {
|
|
20758
|
+
const root = "/__tempo_workspace__/";
|
|
20759
|
+
const read2 = (file) => file.startsWith(root) ? resolution.readFile(file.slice(root.length)) ?? void 0 : void 0;
|
|
20760
|
+
const host = {
|
|
20761
|
+
fileExists: (file) => read2(file) !== void 0,
|
|
20762
|
+
readFile: read2
|
|
20763
|
+
};
|
|
20764
|
+
const configPath = ts.findConfigFile(
|
|
20765
|
+
path3.posix.dirname(root + fromFile),
|
|
20766
|
+
host.fileExists,
|
|
20767
|
+
"tsconfig.json"
|
|
20768
|
+
);
|
|
20769
|
+
let options = {
|
|
20770
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
20771
|
+
allowJs: true
|
|
20772
|
+
};
|
|
20773
|
+
if (configPath) {
|
|
20774
|
+
const config = ts.readConfigFile(configPath, read2);
|
|
20775
|
+
if (!config.error)
|
|
20776
|
+
options = {
|
|
20777
|
+
...options,
|
|
20778
|
+
...ts.parseJsonConfigFileContent(
|
|
20779
|
+
config.config,
|
|
20780
|
+
{ ...host, useCaseSensitiveFileNames: true, readDirectory: () => [] },
|
|
20781
|
+
path3.posix.dirname(configPath)
|
|
20782
|
+
).options
|
|
20783
|
+
};
|
|
20784
|
+
}
|
|
20785
|
+
const resolved = ts.resolveModuleName(
|
|
20786
|
+
specifier,
|
|
20787
|
+
root + fromFile,
|
|
20788
|
+
options,
|
|
20789
|
+
host
|
|
20790
|
+
).resolvedModule?.resolvedFileName;
|
|
20791
|
+
return resolved?.startsWith(root) ? resolved.slice(root.length) : null;
|
|
20792
|
+
}
|
|
20414
20793
|
var MAX_REEXPORT_DEPTH = 4;
|
|
20415
20794
|
function posixDirname(filePath) {
|
|
20416
20795
|
const separator = filePath.lastIndexOf("/");
|
|
@@ -20579,9 +20958,13 @@ function collectExportTargets(value, depth = 0) {
|
|
|
20579
20958
|
function resolvePackageEntryFile(resolution, specifier) {
|
|
20580
20959
|
const { packageName, subpath } = parsePackageSpecifier(specifier);
|
|
20581
20960
|
const packageDir = resolution.workspacePackages?.[packageName];
|
|
20582
|
-
if (packageDir === void 0)
|
|
20961
|
+
if (packageDir === void 0)
|
|
20962
|
+
return resolveProjectModule(resolution, specifier);
|
|
20583
20963
|
if (subpath !== void 0) {
|
|
20584
|
-
return resolveModuleFilePath(
|
|
20964
|
+
return resolveModuleFilePath(
|
|
20965
|
+
resolution.readFile,
|
|
20966
|
+
`${packageDir}/${subpath}`
|
|
20967
|
+
);
|
|
20585
20968
|
}
|
|
20586
20969
|
const manifestSource = resolution.readFile(`${packageDir}/package.json`);
|
|
20587
20970
|
if (manifestSource != null) {
|
|
@@ -20657,11 +21040,20 @@ function findExportInProgram(program, exportedName) {
|
|
|
20657
21040
|
starSources
|
|
20658
21041
|
};
|
|
20659
21042
|
}
|
|
20660
|
-
return {
|
|
21043
|
+
return {
|
|
21044
|
+
finding: {
|
|
21045
|
+
type: "defined",
|
|
21046
|
+
localName: expression?.id?.name ?? exportedName
|
|
21047
|
+
},
|
|
21048
|
+
starSources
|
|
21049
|
+
};
|
|
20661
21050
|
}
|
|
20662
21051
|
if (statement?.type === "ExportNamedDeclaration") {
|
|
20663
21052
|
if (statement.declaration && declarationDeclaresName(statement.declaration, exportedName)) {
|
|
20664
|
-
return {
|
|
21053
|
+
return {
|
|
21054
|
+
finding: { type: "defined", localName: exportedName },
|
|
21055
|
+
starSources
|
|
21056
|
+
};
|
|
20665
21057
|
}
|
|
20666
21058
|
for (const specifier of statement.specifiers ?? []) {
|
|
20667
21059
|
if (specifier?.type !== "ExportSpecifier") continue;
|
|
@@ -20678,7 +21070,10 @@ function findExportInProgram(program, exportedName) {
|
|
|
20678
21070
|
starSources
|
|
20679
21071
|
};
|
|
20680
21072
|
}
|
|
20681
|
-
return {
|
|
21073
|
+
return {
|
|
21074
|
+
finding: { type: "local", localName: sourceName },
|
|
21075
|
+
starSources
|
|
21076
|
+
};
|
|
20682
21077
|
}
|
|
20683
21078
|
continue;
|
|
20684
21079
|
}
|
|
@@ -20688,15 +21083,6 @@ function findExportInProgram(program, exportedName) {
|
|
|
20688
21083
|
}
|
|
20689
21084
|
return { finding: null, starSources };
|
|
20690
21085
|
}
|
|
20691
|
-
function resolveReExportedDefiningFile(resolution, entryFilePath, exportedName) {
|
|
20692
|
-
return followExportChain(
|
|
20693
|
-
resolution,
|
|
20694
|
-
entryFilePath,
|
|
20695
|
-
exportedName,
|
|
20696
|
-
MAX_REEXPORT_DEPTH,
|
|
20697
|
-
/* @__PURE__ */ new Set()
|
|
20698
|
-
);
|
|
20699
|
-
}
|
|
20700
21086
|
function followExportChain(resolution, filePath, exportedName, hopsRemaining, seen) {
|
|
20701
21087
|
const visitKey = `${filePath}#${exportedName}`;
|
|
20702
21088
|
if (seen.has(visitKey)) return null;
|
|
@@ -20718,7 +21104,8 @@ function followExportChain(resolution, filePath, exportedName, hopsRemaining, se
|
|
|
20718
21104
|
seen
|
|
20719
21105
|
);
|
|
20720
21106
|
};
|
|
20721
|
-
if (finding?.type === "defined")
|
|
21107
|
+
if (finding?.type === "defined")
|
|
21108
|
+
return { filePath, name: finding.localName ?? exportedName };
|
|
20722
21109
|
if (finding?.type === "reexport") {
|
|
20723
21110
|
return hop(finding.specifier, finding.sourceName);
|
|
20724
21111
|
}
|
|
@@ -20726,7 +21113,7 @@ function followExportChain(resolution, filePath, exportedName, hopsRemaining, se
|
|
|
20726
21113
|
const imported = readAssetImports(program).referenceableImports.get(
|
|
20727
21114
|
finding.localName
|
|
20728
21115
|
);
|
|
20729
|
-
if (!imported) return filePath;
|
|
21116
|
+
if (!imported) return { filePath, name: finding.localName };
|
|
20730
21117
|
return hop(imported.importSpecifier, imported.importedName);
|
|
20731
21118
|
}
|
|
20732
21119
|
for (const starSource of starSources) {
|
|
@@ -20744,14 +21131,19 @@ function resolveChainSpecifier(resolution, fromFilePath, specifier) {
|
|
|
20744
21131
|
}
|
|
20745
21132
|
return resolvePackageEntryFile(resolution, specifier);
|
|
20746
21133
|
}
|
|
21134
|
+
function resolveComponentIdentity(resolution, identityPath, importedName, declaringFile) {
|
|
21135
|
+
const entryFile = identityPath.startsWith("pkg:") ? resolvePackageEntryFile(resolution, identityPath.slice(4)) ?? resolveProjectModule(resolution, identityPath.slice(4), declaringFile) : resolveModuleFilePath(resolution.readFile, identityPath);
|
|
21136
|
+
if (!entryFile) return null;
|
|
21137
|
+
return followExportChain(
|
|
21138
|
+
resolution,
|
|
21139
|
+
entryFile,
|
|
21140
|
+
importedName,
|
|
21141
|
+
MAX_REEXPORT_DEPTH,
|
|
21142
|
+
/* @__PURE__ */ new Set()
|
|
21143
|
+
);
|
|
21144
|
+
}
|
|
20747
21145
|
function resolveComponentFilePath(resolution, identityPath, importedName) {
|
|
20748
|
-
|
|
20749
|
-
const specifier = identityPath.slice("pkg:".length);
|
|
20750
|
-
const entryFile = resolvePackageEntryFile(resolution, specifier);
|
|
20751
|
-
if (entryFile === null) return null;
|
|
20752
|
-
return resolveReExportedDefiningFile(resolution, entryFile, importedName);
|
|
20753
|
-
}
|
|
20754
|
-
return resolveModuleFilePath(resolution.readFile, identityPath);
|
|
21146
|
+
return resolveComponentIdentity(resolution, identityPath, importedName)?.filePath ?? (!identityPath.startsWith("pkg:") ? resolveModuleFilePath(resolution.readFile, identityPath) : null);
|
|
20755
21147
|
}
|
|
20756
21148
|
function canvasPointerDocLine(canvasPath) {
|
|
20757
21149
|
return `The canvas for this component is at ${canvasPath}/index.canvas.tsx. If you adjust this component in any way, ensure the canvas and its asset declaration stay consistent.`;
|
|
@@ -20788,9 +21180,7 @@ function verifyCanvasPointer(resolution, canvasesDir, entry) {
|
|
|
20788
21180
|
if (comments === null) {
|
|
20789
21181
|
return {
|
|
20790
21182
|
componentFilePath,
|
|
20791
|
-
warnings: unverified2(
|
|
20792
|
-
`could not read comments in "${componentFilePath}"`
|
|
20793
|
-
).warnings
|
|
21183
|
+
warnings: unverified2(`could not read comments in "${componentFilePath}"`).warnings
|
|
20794
21184
|
};
|
|
20795
21185
|
}
|
|
20796
21186
|
const mentionPattern = new RegExp(
|
|
@@ -22412,7 +22802,7 @@ function parsedPageName(file) {
|
|
|
22412
22802
|
return void 0;
|
|
22413
22803
|
}
|
|
22414
22804
|
}
|
|
22415
|
-
function referenceDeclarationToEntry(declaration, reference, file, canvasName) {
|
|
22805
|
+
function referenceDeclarationToEntry(declaration, reference, file, canvasName, inCanvasesTree) {
|
|
22416
22806
|
const identityPath = referenceIdentityPath(
|
|
22417
22807
|
file.filePath,
|
|
22418
22808
|
reference.importSpecifier
|
|
@@ -22429,9 +22819,10 @@ function referenceDeclarationToEntry(declaration, reference, file, canvasName) {
|
|
|
22429
22819
|
...declaration.usageInstructions !== void 0 ? { usageInstructions: declaration.usageInstructions } : {},
|
|
22430
22820
|
variants: declaration.variants,
|
|
22431
22821
|
warnings: [...declaration.warnings],
|
|
22432
|
-
canvasPath: posixDirname(file.filePath),
|
|
22822
|
+
...inCanvasesTree ? { canvasPath: posixDirname(file.filePath) } : {},
|
|
22433
22823
|
...canvasName !== void 0 ? { canvasName } : {},
|
|
22434
|
-
declaredIn: file.filePath
|
|
22824
|
+
declaredIn: file.filePath,
|
|
22825
|
+
declaredBindingName: declaration.bindingName
|
|
22435
22826
|
};
|
|
22436
22827
|
}
|
|
22437
22828
|
function declarationToEntry(declaration, file, canvasesDir) {
|
|
@@ -22483,25 +22874,28 @@ function fileToIndexedParts(file, canvasesDir) {
|
|
|
22483
22874
|
entries.push(declarationToEntry(declaration, file, canvasesDir));
|
|
22484
22875
|
continue;
|
|
22485
22876
|
}
|
|
22486
|
-
if (!inCanvasesTree) {
|
|
22487
|
-
structuralErrors.push({
|
|
22488
|
-
code: "component_declaration_outside_canvas",
|
|
22489
|
-
severity: "structural",
|
|
22490
|
-
message: `defineAsset for imported "${declaration.bindingName}" must live in a canvas folder (under "${canvasesDir}/") \u2014 component declarations belong on the canvas that curates them`,
|
|
22491
|
-
span: declaration.spans.call
|
|
22492
|
-
});
|
|
22493
|
-
continue;
|
|
22494
|
-
}
|
|
22495
22877
|
entries.push(
|
|
22496
22878
|
referenceDeclarationToEntry(
|
|
22497
22879
|
declaration,
|
|
22498
22880
|
declaration.reference,
|
|
22499
22881
|
file,
|
|
22500
|
-
curatingCanvasName
|
|
22882
|
+
curatingCanvasName,
|
|
22883
|
+
inCanvasesTree
|
|
22501
22884
|
)
|
|
22502
22885
|
);
|
|
22503
22886
|
}
|
|
22504
|
-
|
|
22887
|
+
const controls = parseControlsFile(file.filePath, file.source).map(
|
|
22888
|
+
(call) => ({
|
|
22889
|
+
filePath: call.reference ? referenceIdentityPath(file.filePath, call.reference.importSpecifier) : file.filePath,
|
|
22890
|
+
name: call.reference?.importedName ?? (call.exportKind === "default" ? "default" : call.bindingName),
|
|
22891
|
+
declaredIn: file.filePath
|
|
22892
|
+
})
|
|
22893
|
+
);
|
|
22894
|
+
return {
|
|
22895
|
+
entries,
|
|
22896
|
+
structuralErrors,
|
|
22897
|
+
...controls.length ? { controls } : {}
|
|
22898
|
+
};
|
|
22505
22899
|
}
|
|
22506
22900
|
function deriveLibraries(assets) {
|
|
22507
22901
|
const members = /* @__PURE__ */ new Map();
|
|
@@ -22533,7 +22927,9 @@ function normalizedIdentity(key) {
|
|
|
22533
22927
|
function resolveDuplicateDeclarations(entries) {
|
|
22534
22928
|
const groups = /* @__PURE__ */ new Map();
|
|
22535
22929
|
for (const entry of entries) {
|
|
22536
|
-
const identity = normalizedIdentity(
|
|
22930
|
+
const identity = normalizedIdentity(
|
|
22931
|
+
entry.componentFilePath ? `${entry.componentFilePath}#${entry.componentName ?? entry.name}` : entry.key
|
|
22932
|
+
);
|
|
22537
22933
|
const group = groups.get(identity);
|
|
22538
22934
|
if (group) group.push(entry);
|
|
22539
22935
|
else groups.set(identity, [entry]);
|
|
@@ -22541,28 +22937,27 @@ function resolveDuplicateDeclarations(entries) {
|
|
|
22541
22937
|
const winners = [];
|
|
22542
22938
|
const errorsByFile = /* @__PURE__ */ new Map();
|
|
22543
22939
|
for (const group of groups.values()) {
|
|
22544
|
-
|
|
22545
|
-
|
|
22546
|
-
winners.push(...group);
|
|
22940
|
+
if (group.length === 1) {
|
|
22941
|
+
winners.push(group[0]);
|
|
22547
22942
|
continue;
|
|
22548
22943
|
}
|
|
22549
|
-
const
|
|
22550
|
-
|
|
22944
|
+
const declarations = group.map((entry) => entry.declaredIn ?? entry.filePath).sort();
|
|
22945
|
+
const error = {
|
|
22946
|
+
code: "duplicate_asset_declaration",
|
|
22947
|
+
severity: "structural",
|
|
22948
|
+
message: `This component has multiple defineAsset declarations: ${declarations.join(", ")}. Keep one definition before editing or inserting it.`
|
|
22949
|
+
};
|
|
22950
|
+
const representative = [...group].sort(
|
|
22951
|
+
(a, b2) => a.key.localeCompare(b2.key) || (a.declaredIn ?? a.filePath).localeCompare(b2.declaredIn ?? b2.filePath)
|
|
22551
22952
|
)[0];
|
|
22552
|
-
winners.push(
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22560
|
-
message: `duplicate asset declaration for "${winner.key}" \u2014 declared in both "${winnerFile}" and "${loserFile}"; the canvas declaration in "${winnerFile}" wins`
|
|
22561
|
-
};
|
|
22562
|
-
const existing = errorsByFile.get(loserFile);
|
|
22563
|
-
if (existing) existing.push(error);
|
|
22564
|
-
else errorsByFile.set(loserFile, [error]);
|
|
22565
|
-
}
|
|
22953
|
+
winners.push({
|
|
22954
|
+
...representative,
|
|
22955
|
+
controls: void 0,
|
|
22956
|
+
variants: [],
|
|
22957
|
+
warnings: [...representative.warnings, error]
|
|
22958
|
+
});
|
|
22959
|
+
for (const file of declarations)
|
|
22960
|
+
errorsByFile.set(file, [...errorsByFile.get(file) ?? [], error]);
|
|
22566
22961
|
}
|
|
22567
22962
|
return { winners, errorsByFile };
|
|
22568
22963
|
}
|
|
@@ -22598,9 +22993,20 @@ function decorateWithRedundancyWarning(entry, componentCanvasPaths) {
|
|
|
22598
22993
|
}
|
|
22599
22994
|
function assembleIndex(contributions, canvasesDir, fileResolution) {
|
|
22600
22995
|
const { winners, errorsByFile } = resolveDuplicateDeclarations(
|
|
22601
|
-
Object.values(contributions).flatMap(
|
|
22602
|
-
(
|
|
22603
|
-
|
|
22996
|
+
Object.values(contributions).flatMap((contribution) => contribution.entries).map((entry) => {
|
|
22997
|
+
if (!fileResolution || entry.kind !== "component") return entry;
|
|
22998
|
+
const identity = resolveComponentIdentity(
|
|
22999
|
+
fileResolution,
|
|
23000
|
+
entry.filePath,
|
|
23001
|
+
entry.exportKind === "default" ? "default" : parseAssetKey(entry.key)?.bindingName ?? entry.name,
|
|
23002
|
+
entry.declaredIn ?? entry.filePath
|
|
23003
|
+
);
|
|
23004
|
+
return identity ? {
|
|
23005
|
+
...entry,
|
|
23006
|
+
componentFilePath: identity.filePath,
|
|
23007
|
+
componentName: identity.name
|
|
23008
|
+
} : entry;
|
|
23009
|
+
})
|
|
22604
23010
|
);
|
|
22605
23011
|
const componentCanvasPaths = /* @__PURE__ */ new Set();
|
|
22606
23012
|
for (const entry of winners) {
|
|
@@ -22629,7 +23035,28 @@ function assembleIndex(contributions, canvasesDir, fileResolution) {
|
|
|
22629
23035
|
];
|
|
22630
23036
|
if (fileErrorList.length > 0) errors[filePath] = fileErrorList;
|
|
22631
23037
|
}
|
|
22632
|
-
|
|
23038
|
+
const controls = {};
|
|
23039
|
+
for (const file of Object.keys(contributions).sort()) {
|
|
23040
|
+
for (const declaration of contributions[file].controls ?? []) {
|
|
23041
|
+
const identity = fileResolution ? resolveComponentIdentity(
|
|
23042
|
+
fileResolution,
|
|
23043
|
+
declaration.filePath,
|
|
23044
|
+
declaration.name,
|
|
23045
|
+
file
|
|
23046
|
+
) : null;
|
|
23047
|
+
const key = makeAssetKey(
|
|
23048
|
+
identity?.filePath ?? declaration.filePath,
|
|
23049
|
+
identity?.name ?? declaration.name
|
|
23050
|
+
);
|
|
23051
|
+
(controls[key] ??= []).push(declaration.declaredIn);
|
|
23052
|
+
}
|
|
23053
|
+
}
|
|
23054
|
+
return {
|
|
23055
|
+
assets,
|
|
23056
|
+
libraries: deriveLibraries(assets),
|
|
23057
|
+
fileErrors: errors,
|
|
23058
|
+
...Object.keys(controls).length ? { controls } : {}
|
|
23059
|
+
};
|
|
22633
23060
|
}
|
|
22634
23061
|
function buildIndexFromParsedFiles(files, options = {}) {
|
|
22635
23062
|
const canvasesDir = options.canvasesDir ?? DEFAULT_CANVASES_DIR;
|
|
@@ -25286,7 +25713,7 @@ async function ensureCanvasPageFileMigrated(pageFilePath) {
|
|
|
25286
25713
|
// ../canvas-pages/delete-storyboard.ts
|
|
25287
25714
|
import fs5 from "fs/promises";
|
|
25288
25715
|
import path33 from "path";
|
|
25289
|
-
import
|
|
25716
|
+
import ts2 from "typescript";
|
|
25290
25717
|
|
|
25291
25718
|
// ../canvas-pages/discovery.ts
|
|
25292
25719
|
import { readdir as readdir9, stat as stat7 } from "fs/promises";
|
|
@@ -28052,6 +28479,16 @@ import os from "os";
|
|
|
28052
28479
|
import path14 from "path";
|
|
28053
28480
|
var PRE_BOOT_CLOCK_SLACK_MS = 5 * 60 * 1e3;
|
|
28054
28481
|
|
|
28482
|
+
// ../tempo-devserver/install-environment-fallback.ts
|
|
28483
|
+
function missingInstallEnvironment(error) {
|
|
28484
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
28485
|
+
return /(?:^|[\s/"'])(?:docker|pnpm|yarn|bun)(?:["'])?: (?:command )?not found\b/im.test(
|
|
28486
|
+
message
|
|
28487
|
+
) || /['"](?:docker|pnpm|yarn|bun)['"] is not recognized as an internal or external command/i.test(
|
|
28488
|
+
message
|
|
28489
|
+
) || /cannot connect to the docker daemon/i.test(message) || /is the docker daemon running\?/i.test(message);
|
|
28490
|
+
}
|
|
28491
|
+
|
|
28055
28492
|
// ../tempo-devserver/tempo-devserver.ts
|
|
28056
28493
|
import { spawn as spawn4 } from "child_process";
|
|
28057
28494
|
import { createHash as createHash3, randomUUID as randomUUID3 } from "crypto";
|
|
@@ -28675,7 +29112,7 @@ async function parcelEventToFileEvent(event, rootInfo) {
|
|
|
28675
29112
|
// ../tempo-sdk/package.json
|
|
28676
29113
|
var package_default = {
|
|
28677
29114
|
name: "tempo-sdk",
|
|
28678
|
-
version: "0.0.
|
|
29115
|
+
version: "0.0.51",
|
|
28679
29116
|
type: "module",
|
|
28680
29117
|
description: "Tempo SDK \u2014 Vite, Next.js, and Expo plugins for JSX annotation and shared page/storyboard types",
|
|
28681
29118
|
repository: {
|
|
@@ -28756,7 +29193,7 @@ var package_default = {
|
|
|
28756
29193
|
demo: "TEMPO=true pnpm --filter @tempo-modules/vite-annotate-plugin-demo dev",
|
|
28757
29194
|
"demo:nextjs": "TEMPO=true pnpm --filter @tempo-modules/tempo-sdk-nextjs-demo dev",
|
|
28758
29195
|
test: "vitest run",
|
|
28759
|
-
"test:browser": "vitest run canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts",
|
|
29196
|
+
"test:browser": "vitest run asset-live-preview-browser.test.ts asset-popover-lifecycle-browser.test.ts component-controls-browser.test.ts canvas-controls-browser.test.ts canvas-capture-determinism-browser.test.ts canvas-host-vite-e2e.test.ts canvas-host-packed-sdk-e2e.test.ts error-tracking-e2e.test.ts",
|
|
28760
29197
|
"test:watch": "vitest",
|
|
28761
29198
|
"test:nextjs:unit": "vitest run nextjs-loader.test.ts nextjs-wrapper.test.ts nextjs-fixtures.test.ts nextjs-published.test.ts",
|
|
28762
29199
|
"test:nextjs:integration": "vitest run nextjs-e2e-correctness.test.ts",
|
|
@@ -29621,6 +30058,7 @@ async function walkPagesDir(directory, collector) {
|
|
|
29621
30058
|
var CanvasRegistry = class {
|
|
29622
30059
|
constructor(projectRoot, tempoRoot, _pagesDir, options) {
|
|
29623
30060
|
this.pendingRequestedCanvasPaths = null;
|
|
30061
|
+
this.requestedThisSession = /* @__PURE__ */ new Set();
|
|
29624
30062
|
this.requestedCanvasesQueue = Promise.resolve();
|
|
29625
30063
|
this.projectRoot = projectRoot;
|
|
29626
30064
|
this.tempoRoot = tempoRoot;
|
|
@@ -29658,9 +30096,31 @@ var CanvasRegistry = class {
|
|
|
29658
30096
|
async resetRequestedCanvases() {
|
|
29659
30097
|
await this.runRequestedCanvasesExclusive(async () => {
|
|
29660
30098
|
this.pendingRequestedCanvasPaths = null;
|
|
30099
|
+
this.requestedThisSession.clear();
|
|
29661
30100
|
await rm3(this.requestedCanvasesPath, { force: true });
|
|
29662
30101
|
});
|
|
29663
30102
|
}
|
|
30103
|
+
/**
|
|
30104
|
+
* Drop demand registrations inherited from an older host session without
|
|
30105
|
+
* erasing canvases already requested through this registry instance.
|
|
30106
|
+
*
|
|
30107
|
+
* Canvas admission may run while first-time initialization is queued. The
|
|
30108
|
+
* registry queue makes both orderings safe: a reset that wins clears the old
|
|
30109
|
+
* file before admission writes it, while a reset that follows admission
|
|
30110
|
+
* observes the current-session request and preserves the file.
|
|
30111
|
+
*/
|
|
30112
|
+
async resetStaleRequestedCanvases() {
|
|
30113
|
+
await this.runRequestedCanvasesExclusive(async () => {
|
|
30114
|
+
const requestedPaths = [...this.requestedThisSession];
|
|
30115
|
+
this.pendingRequestedCanvasPaths = requestedPaths;
|
|
30116
|
+
if (requestedPaths.length === 0) {
|
|
30117
|
+
await rm3(this.requestedCanvasesPath, { force: true });
|
|
30118
|
+
} else {
|
|
30119
|
+
await this.writeRequestedCanvasPaths(requestedPaths);
|
|
30120
|
+
}
|
|
30121
|
+
this.pendingRequestedCanvasPaths = null;
|
|
30122
|
+
});
|
|
30123
|
+
}
|
|
29664
30124
|
requestedPathToAbsolutePath(relativePath) {
|
|
29665
30125
|
if (typeof relativePath !== "string" || relativePath.length === 0) {
|
|
29666
30126
|
return null;
|
|
@@ -29785,6 +30245,7 @@ var CanvasRegistry = class {
|
|
|
29785
30245
|
}
|
|
29786
30246
|
return this.runRequestedCanvasesExclusive(async () => {
|
|
29787
30247
|
const requestedPath = this.toRequestedPath(absolutePath);
|
|
30248
|
+
this.requestedThisSession.add(requestedPath);
|
|
29788
30249
|
const pruned = await this.pruneDeletedRequestedPaths(
|
|
29789
30250
|
await this.readRequestedCanvasPaths()
|
|
29790
30251
|
);
|
|
@@ -31874,9 +32335,24 @@ var TempoDevServer = class _TempoDevServer {
|
|
|
31874
32335
|
}
|
|
31875
32336
|
this.state.dependenciesInstalled = false;
|
|
31876
32337
|
await this.persistStatus();
|
|
31877
|
-
|
|
32338
|
+
try {
|
|
32339
|
+
for (const step of steps) {
|
|
32340
|
+
throwIfLaunchAborted(signal);
|
|
32341
|
+
await runInstallStep(step, signal);
|
|
32342
|
+
}
|
|
32343
|
+
} catch (error) {
|
|
31878
32344
|
throwIfLaunchAborted(signal);
|
|
31879
|
-
|
|
32345
|
+
if (!steps.some((step) => step.label === "custom tempo install") || !missingInstallEnvironment(error))
|
|
32346
|
+
throw error;
|
|
32347
|
+
const localSteps = await this.buildInstallSteps(false, false);
|
|
32348
|
+
if (!localSteps.length) throw error;
|
|
32349
|
+
console.warn(
|
|
32350
|
+
"[tempo-devserver] The configured installer needs unavailable local tooling; trying a local dependency install for this launch."
|
|
32351
|
+
);
|
|
32352
|
+
for (const step of localSteps) {
|
|
32353
|
+
throwIfLaunchAborted(signal);
|
|
32354
|
+
await runInstallStep(step, signal);
|
|
32355
|
+
}
|
|
31880
32356
|
}
|
|
31881
32357
|
};
|
|
31882
32358
|
while (_TempoDevServer.installBarriers.has(this.projectRoot)) {
|
|
@@ -31906,9 +32382,9 @@ var TempoDevServer = class _TempoDevServer {
|
|
|
31906
32382
|
throw error;
|
|
31907
32383
|
}
|
|
31908
32384
|
}
|
|
31909
|
-
async buildInstallSteps(forceInstall) {
|
|
32385
|
+
async buildInstallSteps(forceInstall, useConfiguredScript = true) {
|
|
31910
32386
|
const configuredInstall = this.config.scripts.install.trim();
|
|
31911
|
-
if (!looksLikeGeneratedInstallScript(configuredInstall)) {
|
|
32387
|
+
if (useConfiguredScript && !looksLikeGeneratedInstallScript(configuredInstall)) {
|
|
31912
32388
|
if (!forceInstall && await this.projectRootInstallReady() && await installCompletedForCurrentDeps(this.tempoRoot) && await this.tempoInstallReady()) {
|
|
31913
32389
|
devLog("supervisor:custom_install_skipped_premat", {
|
|
31914
32390
|
projectRoot: this.projectRoot,
|
|
@@ -31968,7 +32444,7 @@ var TempoDevServer = class _TempoDevServer {
|
|
|
31968
32444
|
markerRoots: [this.tempoRoot]
|
|
31969
32445
|
});
|
|
31970
32446
|
}
|
|
31971
|
-
if (!rootManager && !tempoManager) {
|
|
32447
|
+
if (useConfiguredScript && !rootManager && !tempoManager) {
|
|
31972
32448
|
steps.push({
|
|
31973
32449
|
cwd: this.commandCwd,
|
|
31974
32450
|
command: configuredInstall,
|
|
@@ -32562,7 +33038,7 @@ var TempoDevServer = class _TempoDevServer {
|
|
|
32562
33038
|
const firstInitialize = !this.state.initialized;
|
|
32563
33039
|
const hostAlive = this.activeHostHasLivenessAuthority();
|
|
32564
33040
|
if (firstInitialize && !hostAlive) {
|
|
32565
|
-
await this.registry.
|
|
33041
|
+
await this.registry.resetStaleRequestedCanvases();
|
|
32566
33042
|
}
|
|
32567
33043
|
const reconcileResult = await this.enqueueReconcile(
|
|
32568
33044
|
"initialize",
|
|
@@ -40557,87 +41033,6 @@ import TempoHost from "./.tempo/tempo-host";
|
|
|
40557
41033
|
// (outside tempo/) keeps whatever StrictMode setup it already had.
|
|
40558
41034
|
createRoot(document.getElementById("root")!).render(<TempoHost />);
|
|
40559
41035
|
`;
|
|
40560
|
-
var TEMPLATE_STORYBOARD1_TSX = `// Storyboard1 \u2014 an example of CANVAS-LOCAL, isolated UI.
|
|
40561
|
-
//
|
|
40562
|
-
// Code in a storyboard file like this is UI-only work that is NOT used by your
|
|
40563
|
-
// real app. It lives ONLY on this canvas, as a sketch / playground. When you
|
|
40564
|
-
// want a component to actually ship in your app, build it in your app's source
|
|
40565
|
-
// (OUTSIDE the tempo/ folder, e.g. <projectRoot>/src/...) and import it onto a
|
|
40566
|
-
// canvas instead \u2014 see the commented example in index.canvas.tsx.
|
|
40567
|
-
|
|
40568
|
-
export default function Storyboard1() {
|
|
40569
|
-
return (
|
|
40570
|
-
<div className="min-h-[200px] flex items-center justify-center rounded-xl border border-black/10 bg-white p-8">
|
|
40571
|
-
<div className="text-center">
|
|
40572
|
-
<div className="text-xs font-semibold uppercase tracking-wide text-black/40 mb-2">
|
|
40573
|
-
Canvas-local example
|
|
40574
|
-
</div>
|
|
40575
|
-
<div className="text-lg font-semibold text-black/80">
|
|
40576
|
-
Edit Storyboard1.tsx to sketch isolated UI here
|
|
40577
|
-
</div>
|
|
40578
|
-
</div>
|
|
40579
|
-
</div>
|
|
40580
|
-
);
|
|
40581
|
-
}
|
|
40582
|
-
`;
|
|
40583
|
-
var TEMPLATE_CANVAS_INDEX_TSX = `// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
40584
|
-
// Template canvas
|
|
40585
|
-
//
|
|
40586
|
-
// A canvas is a design surface that renders REAL React components from your app
|
|
40587
|
-
// as "storyboards". The tempo/ folder this file lives in is an auto-generated
|
|
40588
|
-
// dev server that POWERS the canvas \u2014 it is NOT your app. Your real app code
|
|
40589
|
-
// lives OUTSIDE tempo/, at the project root (e.g. <projectRoot>/src/...).
|
|
40590
|
-
//
|
|
40591
|
-
// Two ways to put something on a canvas:
|
|
40592
|
-
// 1. A canvas-local storyboard \u2014 isolated UI that only exists here, never
|
|
40593
|
-
// shipped in your app. See ./Storyboard1 below.
|
|
40594
|
-
// 2. A REAL component imported from your app (the main, intended use): build
|
|
40595
|
-
// it in your app outside tempo/, then import it here to preview it. See
|
|
40596
|
-
// the commented example below.
|
|
40597
|
-
//
|
|
40598
|
-
// Note: canvas_project_init must be run before any canvas exists (it created this one).
|
|
40599
|
-
// Create further canvases with the create-canvas tool \u2014 don't hand-write
|
|
40600
|
-
// *.canvas.tsx files.
|
|
40601
|
-
// \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
40602
|
-
|
|
40603
|
-
import { Canvas, Storyboard } from "tempo-sdk/canvas";
|
|
40604
|
-
import Storyboard1 from "./Storyboard1";
|
|
40605
|
-
|
|
40606
|
-
// Example \u2014 import a REAL component from your app, which lives OUTSIDE tempo/.
|
|
40607
|
-
// Your app is at the project root, so climb out of tempo/ to reach it. From
|
|
40608
|
-
// tempo/designs/canvases/template-canvas/ that is four levels up:
|
|
40609
|
-
// import { Button } from "../../../../src/components/Button";
|
|
40610
|
-
|
|
40611
|
-
export default function TemplateCanvas() {
|
|
40612
|
-
return (
|
|
40613
|
-
<Canvas name="Template">
|
|
40614
|
-
{/* A canvas-local storyboard: isolated, UI-only, not used by your app. */}
|
|
40615
|
-
<Storyboard
|
|
40616
|
-
id="Example"
|
|
40617
|
-
name="Storyboard 1 (canvas-local example)"
|
|
40618
|
-
component={Storyboard1}
|
|
40619
|
-
layout={{
|
|
40620
|
-
x: 0,
|
|
40621
|
-
y: 0,
|
|
40622
|
-
width: 480,
|
|
40623
|
-
height: 320,
|
|
40624
|
-
intrinsicSizing: "root-element",
|
|
40625
|
-
}}
|
|
40626
|
-
/>
|
|
40627
|
-
{/* Example of projecting a REAL component from your app onto the canvas.
|
|
40628
|
-
Uncomment after adding the import above and having that component in
|
|
40629
|
-
your app:
|
|
40630
|
-
<Storyboard
|
|
40631
|
-
id="RealButton"
|
|
40632
|
-
name="Button (from your app)"
|
|
40633
|
-
component={Button}
|
|
40634
|
-
layout={{ x: 0, y: 380, width: 240, height: 120 }}
|
|
40635
|
-
/>
|
|
40636
|
-
*/}
|
|
40637
|
-
</Canvas>
|
|
40638
|
-
);
|
|
40639
|
-
}
|
|
40640
|
-
`;
|
|
40641
41036
|
var TEMPLATE_HOME_CANVAS_INDEX_TSX = `// @tempo-home \u2014 Tempo home canvas (the workspace Run button opens this). Managed marker; do not remove.
|
|
40642
41037
|
//
|
|
40643
41038
|
// One storyboard rendering your app's home route ("/"). Run (workspace header)
|
|
@@ -42215,16 +42610,26 @@ async function seedZoneDirectories(config) {
|
|
|
42215
42610
|
recursive: true
|
|
42216
42611
|
});
|
|
42217
42612
|
}
|
|
42218
|
-
async function
|
|
42219
|
-
const freeformDir = await resolveFreeformCanvasesDir(config.pagesDir);
|
|
42220
|
-
await writeFileIfMissing(
|
|
42221
|
-
path27.join(freeformDir, "template-canvas", "Storyboard1.tsx"),
|
|
42222
|
-
TEMPLATE_STORYBOARD1_TSX
|
|
42223
|
-
);
|
|
42613
|
+
async function seedSharedControls(config) {
|
|
42224
42614
|
await writeFileIfMissing(
|
|
42225
|
-
path27.join(
|
|
42226
|
-
|
|
42615
|
+
path27.join(config.tempoRoot, "controls.ts"),
|
|
42616
|
+
`// Optional controls for existing components whose source should stay untouched.
|
|
42617
|
+
// New components always keep defineControls in their own file.
|
|
42618
|
+
// For existing components, honor the user/repo preference; fully integrated apps
|
|
42619
|
+
// prefer component files. Non-dev work can use this file; ask developers if unsure.
|
|
42620
|
+
// Both locations work across canvases without asset registration.
|
|
42621
|
+
// Import app components here, and import defineControls from "tempo-sdk/assets".
|
|
42622
|
+
// Example (adjust the import to your app):
|
|
42623
|
+
// import { defineControls } from "tempo-sdk/assets";
|
|
42624
|
+
// import { Button } from "../src/components/Button";
|
|
42625
|
+
// defineControls(Button, { disabled: { type: "boolean" } });
|
|
42626
|
+
// Keep one declaration per component; move existing declarations rather than copying them.
|
|
42627
|
+
// Tempo discovers this file automatically. Do not import it into app or canvas entry points.
|
|
42628
|
+
export {};
|
|
42629
|
+
`
|
|
42227
42630
|
);
|
|
42631
|
+
}
|
|
42632
|
+
async function ensureProjectScaffold(config, framework = "vite") {
|
|
42228
42633
|
if (framework === "expo") {
|
|
42229
42634
|
const { aliasPaths } = await collectHostAliasPaths(config);
|
|
42230
42635
|
const metroAliases = convertAliasPathsToMetroEntries(aliasPaths);
|
|
@@ -42304,13 +42709,7 @@ async function ensureProjectScaffold(config, framework = "vite") {
|
|
|
42304
42709
|
NEXT_TEMPO_HOST_PAGE_TSX
|
|
42305
42710
|
);
|
|
42306
42711
|
await writeFileIfMissing(
|
|
42307
|
-
path27.join(
|
|
42308
|
-
config.tempoRoot,
|
|
42309
|
-
"app",
|
|
42310
|
-
"%5F%5Ftempo",
|
|
42311
|
-
"identity",
|
|
42312
|
-
"route.ts"
|
|
42313
|
-
),
|
|
42712
|
+
path27.join(config.tempoRoot, "app", "%5F%5Ftempo", "identity", "route.ts"),
|
|
42314
42713
|
NEXT_TEMPO_IDENTITY_ROUTE_TS
|
|
42315
42714
|
);
|
|
42316
42715
|
const legacyIdentityRoutePath = path27.join(
|
|
@@ -42522,7 +42921,10 @@ export default {
|
|
|
42522
42921
|
],
|
|
42523
42922
|
};
|
|
42524
42923
|
`;
|
|
42525
|
-
await atomicWriteText(
|
|
42924
|
+
await atomicWriteText(
|
|
42925
|
+
path27.join(config.tempoRoot, "svelte.config.mjs"),
|
|
42926
|
+
desired
|
|
42927
|
+
);
|
|
42526
42928
|
}
|
|
42527
42929
|
var TAILWIND_V3_HOST_CONFIG_BASENAMES = [
|
|
42528
42930
|
"tailwind.config.ts",
|
|
@@ -42589,10 +42991,7 @@ async function ensureViteConfigFile(config, styleContext, uiFramework) {
|
|
|
42589
42991
|
);
|
|
42590
42992
|
return;
|
|
42591
42993
|
}
|
|
42592
|
-
const deduped = addHostRuntimeDedupeToViteConfig(
|
|
42593
|
-
sourceRooted,
|
|
42594
|
-
uiFramework
|
|
42595
|
-
);
|
|
42994
|
+
const deduped = addHostRuntimeDedupeToViteConfig(sourceRooted, uiFramework);
|
|
42596
42995
|
if (deduped === null) {
|
|
42597
42996
|
await atomicWriteText(
|
|
42598
42997
|
config.viteConfigPath,
|
|
@@ -42894,8 +43293,8 @@ async function healFrameworkMismatch(config, detectedFramework, options = {}) {
|
|
|
42894
43293
|
if (previousFramework === null || previousFramework === detectedFramework) {
|
|
42895
43294
|
return { healed: false, previousFramework, backupPath: null };
|
|
42896
43295
|
}
|
|
42897
|
-
const
|
|
42898
|
-
const backupDirName = `.tempo-backup-${previousFramework}-${
|
|
43296
|
+
const ts7 = options.now ?? Date.now();
|
|
43297
|
+
const backupDirName = `.tempo-backup-${previousFramework}-${ts7}`;
|
|
42899
43298
|
const backupPath = path27.join(config.tempoRoot, backupDirName);
|
|
42900
43299
|
const filesToMove = [
|
|
42901
43300
|
...FRAMEWORK_DISTINCTIVE_FILES[previousFramework],
|
|
@@ -43036,9 +43435,7 @@ async function upsertPackageJson(config, framework, styleContext, options) {
|
|
|
43036
43435
|
throw new Error(`Missing style context for ${framework} project setup`);
|
|
43037
43436
|
}
|
|
43038
43437
|
const userReactVersions = await readUserReactVersions(config.projectRoot);
|
|
43039
|
-
const uiFramework = resolveAppUiFramework(
|
|
43040
|
-
config.apps[0]?.uiFramework
|
|
43041
|
-
);
|
|
43438
|
+
const uiFramework = resolveAppUiFramework(config.apps[0]?.uiFramework);
|
|
43042
43439
|
const userSvelteVersions = uiFramework === "svelte" ? await readUserSvelteVersions(config.projectRoot) : {};
|
|
43043
43440
|
next = buildTempoOwnedPackage(
|
|
43044
43441
|
current,
|
|
@@ -44749,14 +45146,18 @@ var TempoProject = class _TempoProject {
|
|
|
44749
45146
|
return await this.ensureInitialized(options);
|
|
44750
45147
|
}
|
|
44751
45148
|
async initializeNewProject() {
|
|
44752
|
-
|
|
45149
|
+
const result = await this.runSingleInitialize(async () => {
|
|
44753
45150
|
return await this.performInitializeNewProject();
|
|
44754
45151
|
});
|
|
45152
|
+
await seedSharedControls(result.config);
|
|
45153
|
+
return result;
|
|
44755
45154
|
}
|
|
44756
45155
|
async initializeExistingProject(options = {}) {
|
|
44757
|
-
|
|
45156
|
+
const result = await this.runSingleInitialize(async () => {
|
|
44758
45157
|
return await this.performInitializeExistingProject(options);
|
|
44759
45158
|
});
|
|
45159
|
+
await seedSharedControls(result.config);
|
|
45160
|
+
return result;
|
|
44760
45161
|
}
|
|
44761
45162
|
async ensureInitialized(options = {}) {
|
|
44762
45163
|
return await this.runSingleInitialize(async () => {
|
|
@@ -45363,7 +45764,7 @@ import path41 from "path";
|
|
|
45363
45764
|
// ../../modules/typescript/workspace-service.ts
|
|
45364
45765
|
import { realpathSync as realpathSync2, statSync as statSync3 } from "fs";
|
|
45365
45766
|
import path36 from "path";
|
|
45366
|
-
import
|
|
45767
|
+
import ts3 from "typescript";
|
|
45367
45768
|
function canonicalPath(input) {
|
|
45368
45769
|
const resolved = path36.resolve(input);
|
|
45369
45770
|
try {
|
|
@@ -45393,23 +45794,23 @@ function loadProject(descriptor) {
|
|
|
45393
45794
|
}
|
|
45394
45795
|
const tsconfigPath = canonicalPath(descriptor.tsconfigPath);
|
|
45395
45796
|
const rootDir = canonicalPath(descriptor.rootDir);
|
|
45396
|
-
const readResult =
|
|
45797
|
+
const readResult = ts3.readConfigFile(tsconfigPath, ts3.sys.readFile);
|
|
45397
45798
|
if (readResult.error) {
|
|
45398
45799
|
throw new Error(
|
|
45399
|
-
`Failed to read tsconfig at ${tsconfigPath}: ${
|
|
45800
|
+
`Failed to read tsconfig at ${tsconfigPath}: ${ts3.flattenDiagnosticMessageText(
|
|
45400
45801
|
readResult.error.messageText,
|
|
45401
45802
|
"\n"
|
|
45402
45803
|
)}`
|
|
45403
45804
|
);
|
|
45404
45805
|
}
|
|
45405
|
-
const parsed =
|
|
45806
|
+
const parsed = ts3.parseJsonConfigFileContent(
|
|
45406
45807
|
readResult.config,
|
|
45407
|
-
|
|
45808
|
+
ts3.sys,
|
|
45408
45809
|
path36.dirname(tsconfigPath)
|
|
45409
45810
|
);
|
|
45410
45811
|
if (parsed.errors.length > 0) {
|
|
45411
45812
|
const message = parsed.errors.map(
|
|
45412
|
-
(diagnostic) =>
|
|
45813
|
+
(diagnostic) => ts3.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
|
|
45413
45814
|
).join("; ");
|
|
45414
45815
|
throw new Error(`Failed to parse tsconfig at ${tsconfigPath}: ${message}`);
|
|
45415
45816
|
}
|
|
@@ -45423,7 +45824,7 @@ function loadProject(descriptor) {
|
|
|
45423
45824
|
priority: descriptor.priority ?? 0,
|
|
45424
45825
|
options: parsed.options,
|
|
45425
45826
|
fileNames: normalizedFiles,
|
|
45426
|
-
moduleResolutionCache:
|
|
45827
|
+
moduleResolutionCache: ts3.createModuleResolutionCache(
|
|
45427
45828
|
rootDir,
|
|
45428
45829
|
(value) => value,
|
|
45429
45830
|
parsed.options
|
|
@@ -45481,12 +45882,12 @@ function createTsWorkspaceService(descriptor) {
|
|
|
45481
45882
|
return primaryProject;
|
|
45482
45883
|
}
|
|
45483
45884
|
const moduleResolutionHost = {
|
|
45484
|
-
fileExists:
|
|
45485
|
-
readFile:
|
|
45486
|
-
realpath:
|
|
45487
|
-
directoryExists:
|
|
45885
|
+
fileExists: ts3.sys.fileExists,
|
|
45886
|
+
readFile: ts3.sys.readFile,
|
|
45887
|
+
realpath: ts3.sys.realpath,
|
|
45888
|
+
directoryExists: ts3.sys.directoryExists,
|
|
45488
45889
|
getCurrentDirectory: () => workspaceRoot,
|
|
45489
|
-
getDirectories:
|
|
45890
|
+
getDirectories: ts3.sys.getDirectories
|
|
45490
45891
|
};
|
|
45491
45892
|
const host = {
|
|
45492
45893
|
getScriptFileNames: () => Array.from(rootFileNames),
|
|
@@ -45502,28 +45903,28 @@ function createTsWorkspaceService(descriptor) {
|
|
|
45502
45903
|
const canonicalFilePath = canonicalPath(filePath);
|
|
45503
45904
|
const inMemory = inMemoryFiles.get(canonicalFilePath);
|
|
45504
45905
|
if (inMemory) {
|
|
45505
|
-
return
|
|
45906
|
+
return ts3.ScriptSnapshot.fromString(inMemory.content);
|
|
45506
45907
|
}
|
|
45507
|
-
const diskContent =
|
|
45908
|
+
const diskContent = ts3.sys.readFile(canonicalFilePath);
|
|
45508
45909
|
if (diskContent === void 0) {
|
|
45509
45910
|
return void 0;
|
|
45510
45911
|
}
|
|
45511
|
-
return
|
|
45912
|
+
return ts3.ScriptSnapshot.fromString(diskContent);
|
|
45512
45913
|
},
|
|
45513
45914
|
getCurrentDirectory: () => workspaceRoot,
|
|
45514
45915
|
getCompilationSettings: () => primaryProject.options,
|
|
45515
|
-
getDefaultLibFileName: (options) =>
|
|
45516
|
-
fileExists:
|
|
45517
|
-
readFile:
|
|
45518
|
-
readDirectory:
|
|
45519
|
-
directoryExists:
|
|
45520
|
-
getDirectories:
|
|
45521
|
-
useCaseSensitiveFileNames: () =>
|
|
45916
|
+
getDefaultLibFileName: (options) => ts3.getDefaultLibFilePath(options),
|
|
45917
|
+
fileExists: ts3.sys.fileExists,
|
|
45918
|
+
readFile: ts3.sys.readFile,
|
|
45919
|
+
readDirectory: ts3.sys.readDirectory,
|
|
45920
|
+
directoryExists: ts3.sys.directoryExists,
|
|
45921
|
+
getDirectories: ts3.sys.getDirectories,
|
|
45922
|
+
useCaseSensitiveFileNames: () => ts3.sys.useCaseSensitiveFileNames,
|
|
45522
45923
|
getProjectVersion: () => String(projectVersion),
|
|
45523
45924
|
resolveModuleNames: (moduleNames, containingFile) => {
|
|
45524
45925
|
const owningProject = getOwningProject(containingFile);
|
|
45525
45926
|
return moduleNames.map((moduleName) => {
|
|
45526
|
-
const ownerResolution =
|
|
45927
|
+
const ownerResolution = ts3.resolveModuleName(
|
|
45527
45928
|
moduleName,
|
|
45528
45929
|
containingFile,
|
|
45529
45930
|
owningProject.options,
|
|
@@ -45536,7 +45937,7 @@ function createTsWorkspaceService(descriptor) {
|
|
|
45536
45937
|
if (owningProject.id === primaryProject.id) {
|
|
45537
45938
|
return void 0;
|
|
45538
45939
|
}
|
|
45539
|
-
return
|
|
45940
|
+
return ts3.resolveModuleName(
|
|
45540
45941
|
moduleName,
|
|
45541
45942
|
containingFile,
|
|
45542
45943
|
primaryProject.options,
|
|
@@ -45546,9 +45947,9 @@ function createTsWorkspaceService(descriptor) {
|
|
|
45546
45947
|
});
|
|
45547
45948
|
}
|
|
45548
45949
|
};
|
|
45549
|
-
const languageService =
|
|
45950
|
+
const languageService = ts3.createLanguageService(
|
|
45550
45951
|
host,
|
|
45551
|
-
|
|
45952
|
+
ts3.createDocumentRegistry()
|
|
45552
45953
|
);
|
|
45553
45954
|
return {
|
|
45554
45955
|
updateFile(filePath, content) {
|
|
@@ -45596,7 +45997,7 @@ function createTsWorkspaceService(descriptor) {
|
|
|
45596
45997
|
}
|
|
45597
45998
|
|
|
45598
45999
|
// ../canvas-pages/pages/validate-page.ts
|
|
45599
|
-
import
|
|
46000
|
+
import ts6 from "typescript";
|
|
45600
46001
|
|
|
45601
46002
|
// ../canvas-pages/pages/validate-service-cache.ts
|
|
45602
46003
|
import { statSync as statSync4 } from "fs";
|
|
@@ -45770,12 +46171,12 @@ async function checkDependencies(npmPackages, projectRoot, _tempoPackageDir) {
|
|
|
45770
46171
|
}
|
|
45771
46172
|
|
|
45772
46173
|
// ../canvas-pages/pages/diagnostics.ts
|
|
45773
|
-
import
|
|
46174
|
+
import ts5 from "typescript";
|
|
45774
46175
|
|
|
45775
46176
|
// ../canvas-pages/pages/import-walker.ts
|
|
45776
46177
|
import { isBuiltin } from "module";
|
|
45777
46178
|
import path40 from "path";
|
|
45778
|
-
import
|
|
46179
|
+
import ts4 from "typescript";
|
|
45779
46180
|
function isServerComponentOnlySpecifier(specifier) {
|
|
45780
46181
|
const cleaned = specifier.split("?")[0].split("#")[0];
|
|
45781
46182
|
return cleaned === "server-only" || cleaned === "client-only" || cleaned === "next/headers" || cleaned.startsWith("next/headers/");
|
|
@@ -45829,42 +46230,42 @@ function extractViteAliasKeys(source) {
|
|
|
45829
46230
|
return keys;
|
|
45830
46231
|
}
|
|
45831
46232
|
function runtimeImportSpecifiers(file, content, verbatimModuleSyntax) {
|
|
45832
|
-
const source =
|
|
46233
|
+
const source = ts4.createSourceFile(file, content, ts4.ScriptTarget.Latest);
|
|
45833
46234
|
const specifiers = [];
|
|
45834
46235
|
function addSpecifier(node) {
|
|
45835
|
-
if (node &&
|
|
46236
|
+
if (node && ts4.isStringLiteralLike(node)) specifiers.push(node.text);
|
|
45836
46237
|
}
|
|
45837
46238
|
function visit(node) {
|
|
45838
|
-
if (
|
|
45839
|
-
if (
|
|
46239
|
+
if (ts4.isTypeNode(node)) return;
|
|
46240
|
+
if (ts4.isImportDeclaration(node)) {
|
|
45840
46241
|
const clause = node.importClause;
|
|
45841
46242
|
if (clause?.isTypeOnly) return;
|
|
45842
46243
|
const bindings = clause?.namedBindings;
|
|
45843
|
-
if (!verbatimModuleSyntax && !clause?.name && bindings &&
|
|
46244
|
+
if (!verbatimModuleSyntax && !clause?.name && bindings && ts4.isNamedImports(bindings) && bindings.elements.length > 0 && bindings.elements.every((binding) => binding.isTypeOnly)) {
|
|
45844
46245
|
return;
|
|
45845
46246
|
}
|
|
45846
46247
|
addSpecifier(node.moduleSpecifier);
|
|
45847
46248
|
return;
|
|
45848
46249
|
}
|
|
45849
|
-
if (
|
|
46250
|
+
if (ts4.isExportDeclaration(node)) {
|
|
45850
46251
|
if (node.isTypeOnly) return;
|
|
45851
46252
|
const clause = node.exportClause;
|
|
45852
|
-
if (!verbatimModuleSyntax && clause &&
|
|
46253
|
+
if (!verbatimModuleSyntax && clause && ts4.isNamedExports(clause) && clause.elements.length > 0 && clause.elements.every((binding) => binding.isTypeOnly)) {
|
|
45853
46254
|
return;
|
|
45854
46255
|
}
|
|
45855
46256
|
addSpecifier(node.moduleSpecifier);
|
|
45856
46257
|
return;
|
|
45857
46258
|
}
|
|
45858
|
-
if (
|
|
45859
|
-
if (!node.isTypeOnly &&
|
|
46259
|
+
if (ts4.isImportEqualsDeclaration(node)) {
|
|
46260
|
+
if (!node.isTypeOnly && ts4.isExternalModuleReference(node.moduleReference)) {
|
|
45860
46261
|
addSpecifier(node.moduleReference.expression);
|
|
45861
46262
|
}
|
|
45862
46263
|
return;
|
|
45863
46264
|
}
|
|
45864
|
-
if (
|
|
46265
|
+
if (ts4.isCallExpression(node) && (node.expression.kind === ts4.SyntaxKind.ImportKeyword || ts4.isIdentifier(node.expression) && node.expression.text === "require")) {
|
|
45865
46266
|
addSpecifier(node.arguments[0]);
|
|
45866
46267
|
}
|
|
45867
|
-
|
|
46268
|
+
ts4.forEachChild(node, visit);
|
|
45868
46269
|
}
|
|
45869
46270
|
visit(source);
|
|
45870
46271
|
return specifiers;
|
|
@@ -45873,7 +46274,7 @@ function walkImports(entryFile, compilerOptions, moduleResolutionHost, projectRo
|
|
|
45873
46274
|
const visited = /* @__PURE__ */ new Set();
|
|
45874
46275
|
const npmPackages = /* @__PURE__ */ new Map();
|
|
45875
46276
|
const serverOnlyImports = /* @__PURE__ */ new Map();
|
|
45876
|
-
const canonicalProjectRoot =
|
|
46277
|
+
const canonicalProjectRoot = ts4.sys.realpath?.(projectRoot) ?? projectRoot;
|
|
45877
46278
|
const repoRoot = repoRootForCanvasWalk(canonicalProjectRoot);
|
|
45878
46279
|
const primaryConfigPath = primaryTsconfigPath ? path40.resolve(primaryTsconfigPath) : null;
|
|
45879
46280
|
const queue = [entryFile];
|
|
@@ -45900,11 +46301,11 @@ function walkImports(entryFile, compilerOptions, moduleResolutionHost, projectRo
|
|
|
45900
46301
|
const normalized = path40.resolve(configPath);
|
|
45901
46302
|
if (seen.has(normalized)) return null;
|
|
45902
46303
|
seen.add(normalized);
|
|
45903
|
-
const read2 =
|
|
46304
|
+
const read2 = ts4.readConfigFile(normalized, ts4.sys.readFile);
|
|
45904
46305
|
if (read2.error) return null;
|
|
45905
|
-
const parsed =
|
|
46306
|
+
const parsed = ts4.parseJsonConfigFileContent(
|
|
45906
46307
|
read2.config,
|
|
45907
|
-
|
|
46308
|
+
ts4.sys,
|
|
45908
46309
|
path40.dirname(normalized),
|
|
45909
46310
|
void 0,
|
|
45910
46311
|
normalized
|
|
@@ -45955,7 +46356,7 @@ function walkImports(entryFile, compilerOptions, moduleResolutionHost, projectRo
|
|
|
45955
46356
|
]) {
|
|
45956
46357
|
const candidate = path40.join(candidateDir, name);
|
|
45957
46358
|
if (!moduleResolutionHost.fileExists(candidate)) continue;
|
|
45958
|
-
const source =
|
|
46359
|
+
const source = ts4.sys.readFile(candidate);
|
|
45959
46360
|
if (source !== void 0) keys = extractViteAliasKeys(source);
|
|
45960
46361
|
break outer;
|
|
45961
46362
|
}
|
|
@@ -45972,10 +46373,10 @@ function walkImports(entryFile, compilerOptions, moduleResolutionHost, projectRo
|
|
|
45972
46373
|
}
|
|
45973
46374
|
while (queue.length > 0) {
|
|
45974
46375
|
const file = queue.pop();
|
|
45975
|
-
const canonical =
|
|
46376
|
+
const canonical = ts4.sys.realpath?.(file) ?? file;
|
|
45976
46377
|
if (visited.has(canonical)) continue;
|
|
45977
46378
|
visited.add(canonical);
|
|
45978
|
-
const content =
|
|
46379
|
+
const content = ts4.sys.readFile(canonical);
|
|
45979
46380
|
if (content === void 0) continue;
|
|
45980
46381
|
const importer = importerConfig(canonical);
|
|
45981
46382
|
const importOptions = importer?.options ?? compilerOptions;
|
|
@@ -45991,14 +46392,14 @@ function walkImports(entryFile, compilerOptions, moduleResolutionHost, projectRo
|
|
|
45991
46392
|
path40.relative(canonicalProjectRoot, canonical)
|
|
45992
46393
|
);
|
|
45993
46394
|
}
|
|
45994
|
-
let resolvedModule2 = importer && importer.configPath !== primaryConfigPath ?
|
|
46395
|
+
let resolvedModule2 = importer && importer.configPath !== primaryConfigPath ? ts4.resolveModuleName(
|
|
45995
46396
|
specifier,
|
|
45996
46397
|
canonical,
|
|
45997
46398
|
importer.options,
|
|
45998
46399
|
moduleResolutionHost
|
|
45999
46400
|
).resolvedModule : void 0;
|
|
46000
46401
|
if (!resolvedModule2) {
|
|
46001
|
-
resolvedModule2 =
|
|
46402
|
+
resolvedModule2 = ts4.resolveModuleName(
|
|
46002
46403
|
specifier,
|
|
46003
46404
|
canonical,
|
|
46004
46405
|
compilerOptions,
|
|
@@ -46078,7 +46479,7 @@ function formatDiagnostics(diagnostics, missingPackageNames) {
|
|
|
46078
46479
|
const typeErrors = [];
|
|
46079
46480
|
const unresolvedImports = [];
|
|
46080
46481
|
for (const diagnostic of diagnostics) {
|
|
46081
|
-
const message =
|
|
46482
|
+
const message = ts5.flattenDiagnosticMessageText(
|
|
46082
46483
|
diagnostic.messageText,
|
|
46083
46484
|
" "
|
|
46084
46485
|
);
|
|
@@ -46178,20 +46579,20 @@ async function validatePage(pageFile, projectRoot, config) {
|
|
|
46178
46579
|
const resolvedPageFile = path41.resolve(pageFile);
|
|
46179
46580
|
const resolvedProjectRoot = path41.resolve(projectRoot);
|
|
46180
46581
|
const tsconfigPath = config?.tsconfigPath ?? path41.join(resolvedProjectRoot, "tsconfig.json");
|
|
46181
|
-
const readResult =
|
|
46582
|
+
const readResult = ts6.readConfigFile(tsconfigPath, ts6.sys.readFile);
|
|
46182
46583
|
if (readResult.error) {
|
|
46183
|
-
const errorText =
|
|
46584
|
+
const errorText = ts6.flattenDiagnosticMessageText(
|
|
46184
46585
|
readResult.error.messageText,
|
|
46185
46586
|
"\n"
|
|
46186
46587
|
);
|
|
46187
46588
|
throw new Error(`Failed to read tsconfig at ${tsconfigPath}: ${errorText}`);
|
|
46188
46589
|
}
|
|
46189
|
-
const parsed =
|
|
46590
|
+
const parsed = ts6.parseJsonConfigFileContent(
|
|
46190
46591
|
readResult.config,
|
|
46191
|
-
|
|
46592
|
+
ts6.sys,
|
|
46192
46593
|
resolvedProjectRoot
|
|
46193
46594
|
);
|
|
46194
|
-
const pageContent =
|
|
46595
|
+
const pageContent = ts6.sys.readFile(resolvedPageFile);
|
|
46195
46596
|
if (pageContent === void 0) {
|
|
46196
46597
|
throw new Error(`Canvas file not found: ${resolvedPageFile}`);
|
|
46197
46598
|
}
|
|
@@ -46227,12 +46628,12 @@ async function validatePage(pageFile, projectRoot, config) {
|
|
|
46227
46628
|
}
|
|
46228
46629
|
}
|
|
46229
46630
|
const moduleResolutionHost = {
|
|
46230
|
-
fileExists:
|
|
46231
|
-
readFile:
|
|
46232
|
-
realpath:
|
|
46233
|
-
directoryExists:
|
|
46631
|
+
fileExists: ts6.sys.fileExists,
|
|
46632
|
+
readFile: ts6.sys.readFile,
|
|
46633
|
+
realpath: ts6.sys.realpath,
|
|
46634
|
+
directoryExists: ts6.sys.directoryExists,
|
|
46234
46635
|
getCurrentDirectory: () => resolvedProjectRoot,
|
|
46235
|
-
getDirectories:
|
|
46636
|
+
getDirectories: ts6.sys.getDirectories
|
|
46236
46637
|
};
|
|
46237
46638
|
const walkResult = walkImports(
|
|
46238
46639
|
resolvedPageFile,
|
|
@@ -46721,8 +47122,9 @@ import path53 from "path";
|
|
|
46721
47122
|
|
|
46722
47123
|
// ../canvas-mcp/asset-validation.ts
|
|
46723
47124
|
import path52 from "path";
|
|
47125
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
46724
47126
|
var FIXES = {
|
|
46725
|
-
duplicate_asset_declaration: "
|
|
47127
|
+
duplicate_asset_declaration: "Keep one defineAsset beside the component. Existing canvas-owned declarations are also supported, but must not duplicate it.",
|
|
46726
47128
|
component_declaration_outside_canvas: "Move the defineAsset reference declaration into the folder of the canvas that showcases this component (its index.canvas.tsx or a sibling file in the same folder).",
|
|
46727
47129
|
redundant_canvas_declaration: "Remove the canvas-level defineAsset self-registration \u2014 the canvas's component declarations already link it; canvas self-registration is strictly for pages with truly no component to declare (foundations like color or icons).",
|
|
46728
47130
|
missing_asset_declaration: "a design-system/library canvas must declare the top-level component(s) it showcases, or self-register with usageInstructions if it is a componentless foundations page"
|
|
@@ -46742,6 +47144,37 @@ async function collectAssetDeclarationIssues(options) {
|
|
|
46742
47144
|
workspaceRoot: options.workspaceRoot,
|
|
46743
47145
|
canvasesDir: options.canvasesDir
|
|
46744
47146
|
});
|
|
47147
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
47148
|
+
const readFile28 = (file) => {
|
|
47149
|
+
try {
|
|
47150
|
+
return readFileSync3(path52.join(options.workspaceRoot, file), "utf8");
|
|
47151
|
+
} catch {
|
|
47152
|
+
return null;
|
|
47153
|
+
}
|
|
47154
|
+
};
|
|
47155
|
+
const canvasSource = readFile28(`${canvasFolderRel}/index.canvas.tsx`);
|
|
47156
|
+
if (canvasSource) {
|
|
47157
|
+
const { program } = parseAssetProgram(
|
|
47158
|
+
`${canvasFolderRel}/index.canvas.tsx`,
|
|
47159
|
+
canvasSource
|
|
47160
|
+
);
|
|
47161
|
+
if (program)
|
|
47162
|
+
for (const imported of readAssetImports(
|
|
47163
|
+
program
|
|
47164
|
+
).referenceableImports.values()) {
|
|
47165
|
+
const identityPath = imported.importSpecifier.startsWith(".") ? resolveRelativeImport(canvasFolderRel, imported.importSpecifier) : `pkg:${imported.importSpecifier}`;
|
|
47166
|
+
const identity = resolveComponentIdentity(
|
|
47167
|
+
{ readFile: readFile28 },
|
|
47168
|
+
identityPath,
|
|
47169
|
+
imported.importedName,
|
|
47170
|
+
`${canvasFolderRel}/index.canvas.tsx`
|
|
47171
|
+
);
|
|
47172
|
+
if (!identity) continue;
|
|
47173
|
+
for (const entry of Object.values(index.assets))
|
|
47174
|
+
if ((entry.componentFilePath ?? entry.filePath) === identity.filePath && (entry.componentName ?? entry.name) === identity.name)
|
|
47175
|
+
referenced.add(entry.key);
|
|
47176
|
+
}
|
|
47177
|
+
}
|
|
46745
47178
|
const issues = [];
|
|
46746
47179
|
for (const [file, errors] of Object.entries(index.fileErrors)) {
|
|
46747
47180
|
for (const error of errors) {
|
|
@@ -46780,11 +47213,9 @@ async function collectAssetDeclarationIssues(options) {
|
|
|
46780
47213
|
const zone = underCanvasesRoot ? classifyCanvasZone(canvasFolderRel.slice(canvasesDirRel.length + 1)) : null;
|
|
46781
47214
|
if (zone && isStrictZone(zone)) {
|
|
46782
47215
|
const contributesDeclaration = Object.values(index.assets).some(
|
|
46783
|
-
(entry) => inCanvasFolder(entry.declaredIn ?? entry.filePath)
|
|
47216
|
+
(entry) => inCanvasFolder(entry.declaredIn ?? entry.filePath) || referenced.has(entry.key)
|
|
46784
47217
|
) || Object.entries(index.fileErrors).some(
|
|
46785
|
-
([file, errors]) => inCanvasFolder(file) && errors.some(
|
|
46786
|
-
(error) => error.code === "duplicate_asset_declaration"
|
|
46787
|
-
)
|
|
47218
|
+
([file, errors]) => inCanvasFolder(file) && errors.some((error) => error.code === "duplicate_asset_declaration")
|
|
46788
47219
|
);
|
|
46789
47220
|
if (!contributesDeclaration) {
|
|
46790
47221
|
const zoneLabel = zone.kind === "design-system" ? "design-system zone" : `library zone${zone.libraryName ? ` ("${zone.libraryName}")` : ""}`;
|
|
@@ -51300,7 +51731,7 @@ function registerTools(server, context) {
|
|
|
51300
51731
|
);
|
|
51301
51732
|
server.tool(
|
|
51302
51733
|
"canvas_project_init",
|
|
51303
|
-
"Initialize the PROJECT for canvas support (NOT an individual canvas \u2014 use canvas_create for that). Scaffolds `tempo/tempo.config.json`, the host entry, `vite.config.ts`, and `.tempo/` runtime files, plus the
|
|
51734
|
+
"Initialize the PROJECT for canvas support (NOT an individual canvas \u2014 use canvas_create for that). Scaffolds `tempo/tempo.config.json`, the host entry, `vite.config.ts`, and `.tempo/` runtime files, plus the project's **home canvas** (a `route: \"/\"` storyboard backing the Run button). framework=vite scaffolds a Vite host; framework=nextjs scaffolds a Next.js sidecar host; framework=expo scaffolds an Expo web sidecar host. UI source framework is not auto-detected: omission means React. For a Svelte 5 app, set `apps[0].uiFramework` to `\"svelte\"` in the generated config and rerun this tool before `canvas_create`; that rerun fills missing sidecar Svelte compiler and official Vite-plugin dependencies without overwriting existing specs. Svelte route storyboards also require the APP package to depend on `tempo-sdk` and, for standalone Svelte/Vite, directly dev-depend on `@sveltejs/vite-plugin-svelte`; add missing packages at versions compatible with the app's existing toolchain and preserve configured versions. The APP'S OWN Vite/Svelte config (outside `tempo/`) must use `tempoVitePlugin()` and prepend `tempoSveltePreprocess(...)`; the generated sidecar cannot annotate the separately running app. Preserve existing preprocessors after Tempo's. Idempotent \u2014 safe to re-run; only creates files that don't already exist. Run this once per project before `canvas_create`, or in response to a `canvas_validate` result that contains a `host_setup_issue`. The result includes `initial_tempo_config` (the scaffolded install/start scripts) and `review_notes`. On a FIRST-time init, review the scripts against the repo per `review_notes` (monorepos, postinstall codegen, and private registries need a custom `scripts.install`); getting this right up front is the difference between the canvas rendering on first open and a broken-install debugging session.",
|
|
51304
51735
|
{
|
|
51305
51736
|
repo_root: z25.string().optional().describe(
|
|
51306
51737
|
"Project root. Defaults to the workspace bound to this MCP session."
|
|
@@ -52164,7 +52595,7 @@ function buildBackends(runtime, toolsets, workspace) {
|
|
|
52164
52595
|
}
|
|
52165
52596
|
|
|
52166
52597
|
// src/version.ts
|
|
52167
|
-
var CLI_VERSION = "0.0.113
|
|
52598
|
+
var CLI_VERSION = "0.0.113";
|
|
52168
52599
|
|
|
52169
52600
|
// src/canvas-hooks.ts
|
|
52170
52601
|
var import_pngjs4 = __toESM(require_png(), 1);
|
|
@@ -53000,8 +53431,12 @@ function buildBranchNotPushedMessage2(canvasPath, state) {
|
|
|
53000
53431
|
|
|
53001
53432
|
// src/serve.ts
|
|
53002
53433
|
var INSTRUCTIONS = `Tempo workspace tools. SCOPING: every issues_*/docs_*/comments_*/agents_*/slack_*/linear_*/script tool requires an explicit orgId \u2014 call tempo_list_orgs once to discover it; project-scoped agents/scripts tools (and canvas_share) also require projectId \u2014 call tempo_list_projects; if the org has no project for the current repo yet, register it with tempo_register_project. Toolsets: issues, cloud docs, canvas comments, custom agents, run scripts, Slack (acts as the org's Tempo bot), Linear. In a Tempo repo, canvas tools (canvas_*, asset_*) design against production components \u2014 call get_guide({ topic: "tempo-canvas-instructions" }) before canvas work. Cross-link artifacts with link_items.`;
|
|
53434
|
+
function toolRequiresAuth(toolset, toolName) {
|
|
53435
|
+
return toolset !== "canvas" || toolName === "canvas_share";
|
|
53436
|
+
}
|
|
53003
53437
|
async function createTempoAggregate(options, overrides = {}) {
|
|
53004
|
-
const
|
|
53438
|
+
const { signInPrompt: signInPromptOverride, authWaitMs, ...runtimeOverrides } = overrides;
|
|
53439
|
+
const convexUrl = runtimeOverrides.convexUrl ?? resolveConvexUrl();
|
|
53005
53440
|
const convexSiteUrl = resolveConvexSiteUrl(convexUrl);
|
|
53006
53441
|
const refreshLoop = createRefreshLoop({
|
|
53007
53442
|
convexSiteUrl,
|
|
@@ -53010,17 +53445,24 @@ async function createTempoAggregate(options, overrides = {}) {
|
|
|
53010
53445
|
attemptReauth: envTokenReauth(convexSiteUrl),
|
|
53011
53446
|
onReauthRequired: () => {
|
|
53012
53447
|
console.error(
|
|
53013
|
-
"[tempo-mcp] Tempo session expired
|
|
53448
|
+
"[tempo-mcp] Tempo session expired \u2014 the next Tempo tool call will prompt for sign-in."
|
|
53014
53449
|
);
|
|
53015
53450
|
}
|
|
53016
53451
|
});
|
|
53017
53452
|
refreshLoop.start();
|
|
53453
|
+
const signInPrompt = signInPromptOverride ?? createSignInPrompt({ authUrl: process.env.TEMPO_AUTH_URL });
|
|
53454
|
+
const authGate = createAuthGate({
|
|
53455
|
+
convexSiteUrl,
|
|
53456
|
+
refreshLoop,
|
|
53457
|
+
signInPrompt,
|
|
53458
|
+
waitMs: authWaitMs ?? resolveSignInWaitMs()
|
|
53459
|
+
});
|
|
53018
53460
|
let scopedOrgId = null;
|
|
53019
53461
|
let scopedProjectId = null;
|
|
53020
53462
|
let orgGeneration = 0;
|
|
53021
53463
|
const orgListeners = /* @__PURE__ */ new Set();
|
|
53022
53464
|
const workspace = options.toolsets.includes("canvas") ? discoverWorkspace() : null;
|
|
53023
|
-
const authProvider =
|
|
53465
|
+
const authProvider = runtimeOverrides.authProvider ?? createAuthProvider(refreshLoop);
|
|
53024
53466
|
const runtime = {
|
|
53025
53467
|
authProvider,
|
|
53026
53468
|
convexUrl,
|
|
@@ -53040,7 +53482,7 @@ async function createTempoAggregate(options, overrides = {}) {
|
|
|
53040
53482
|
getOrgId: () => scopedOrgId,
|
|
53041
53483
|
getOrgProjectId: () => scopedProjectId
|
|
53042
53484
|
}) : void 0,
|
|
53043
|
-
...
|
|
53485
|
+
...runtimeOverrides
|
|
53044
53486
|
};
|
|
53045
53487
|
const backends = buildBackends(runtime, options.toolsets, workspace);
|
|
53046
53488
|
backends.push({
|
|
@@ -53057,6 +53499,7 @@ async function createTempoAggregate(options, overrides = {}) {
|
|
|
53057
53499
|
backends,
|
|
53058
53500
|
filterTool: (_toolset, toolName) => isExternallyExposed(toolName, { readonly: options.readonly }),
|
|
53059
53501
|
injectParams: scopeParamsFor,
|
|
53502
|
+
gateCall: (toolset, toolName) => toolRequiresAuth(toolset, toolName) ? authGate.ensure() : Promise.resolve(null),
|
|
53060
53503
|
onScopedCall: (values) => {
|
|
53061
53504
|
const nextOrg = values.orgId ?? null;
|
|
53062
53505
|
if (nextOrg !== scopedOrgId) {
|
|
@@ -53071,21 +53514,13 @@ async function createTempoAggregate(options, overrides = {}) {
|
|
|
53071
53514
|
aggregate,
|
|
53072
53515
|
dispose: async () => {
|
|
53073
53516
|
refreshLoop.stop();
|
|
53517
|
+
signInPrompt.dispose();
|
|
53074
53518
|
await aggregate.dispose();
|
|
53075
53519
|
}
|
|
53076
53520
|
};
|
|
53077
53521
|
}
|
|
53078
53522
|
async function runServe(options) {
|
|
53079
53523
|
installProcessSafety({ binaryName: "tempo" });
|
|
53080
|
-
try {
|
|
53081
|
-
await ensureCliAuth();
|
|
53082
|
-
} catch (err) {
|
|
53083
|
-
console.error(
|
|
53084
|
-
"[tempo-mcp] sign-in failed:",
|
|
53085
|
-
err instanceof Error ? err.message : String(err)
|
|
53086
|
-
);
|
|
53087
|
-
return 1;
|
|
53088
|
-
}
|
|
53089
53524
|
const handle = await createTempoAggregate(options);
|
|
53090
53525
|
const transport = new StdioServerTransport();
|
|
53091
53526
|
await handle.aggregate.connect(transport);
|
|
@@ -53099,7 +53534,8 @@ async function runServe(options) {
|
|
|
53099
53534
|
export {
|
|
53100
53535
|
createTempoAggregate,
|
|
53101
53536
|
runServe,
|
|
53102
|
-
scopeParamsFor
|
|
53537
|
+
scopeParamsFor,
|
|
53538
|
+
toolRequiresAuth
|
|
53103
53539
|
};
|
|
53104
53540
|
/*! Bundled license information:
|
|
53105
53541
|
|
|
@@ -53110,4 +53546,4 @@ unpdf/dist/index.mjs:
|
|
|
53110
53546
|
* @license Apache-2.0
|
|
53111
53547
|
*)
|
|
53112
53548
|
*/
|
|
53113
|
-
//# sourceMappingURL=serve-
|
|
53549
|
+
//# sourceMappingURL=serve-YVFHBEFM.js.map
|