@reqvire-org/ads 0.3.43 → 0.3.44
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 +5 -1
- package/dist/assets.mjs +48 -2
- package/dist/bootstrap-ds/ADS.md +2 -2
- package/dist/bootstrap-ds/README.md +6 -4
- package/dist/bootstrap-ds/design-system/assets/brand/README.md +26 -19
- package/dist/bootstrap-ds/design-system/assets/brand/app-icon.svg +4 -0
- package/dist/bootstrap-ds/design-system/assets/brand/logo.dark.svg +6 -0
- package/dist/bootstrap-ds/design-system/assets/brand/logo.svg +6 -0
- package/dist/bootstrap-ds/design-system/components/Content/Logo/Logo.ads.fixture.ts +1 -0
- package/dist/bootstrap-ds/design-system/components/Content/Logo/Logo.ads.scenario.tsx +12 -0
- package/dist/bootstrap-ds/design-system/components/Content/Logo/Logo.tsx +41 -0
- package/dist/bootstrap-ds/design-system/components/Content/Logo/README.md +10 -0
- package/dist/bootstrap-ds/design-system/index.ts +1 -0
- package/dist/bootstrap-ds/design-system/review/brand-preview/BrandPreview.tsx +115 -0
- package/dist/bootstrap-ds/design-system/review/index.ts +1 -0
- package/dist/bootstrap-ds/design-system/tokens/Brand.ads.fixture.ts +12 -0
- package/dist/bootstrap-ds/design-system/tokens/Brand.ads.scenario.tsx +4 -0
- package/dist/bootstrap-ds/ds.config.json +2 -1
- package/dist/bootstrap-ds-preact/ds.config.json +2 -1
- package/dist/brand-assets.mjs +136 -3
- package/dist/check.mjs +4 -2
- package/dist/config.mjs +49 -1
- package/dist/init.mjs +3 -2
- package/dist/mcp/preview-widget.bundle.js +1 -1
- package/dist/mcp/project-widget.bundle.js +1 -1
- package/dist/mcp/server.mjs +5 -2
- package/dist/preview-bun.mjs +4 -2
- package/dist/preview-resources.mjs +1 -1
- package/dist/scenarios.mjs +11 -4
- package/dist/skills/ads-designer/SKILL.md +9 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/ADS.md +2 -2
- package/dist/skills/ads-designer/assets/bootstrap-ds/README.md +6 -4
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/README.md +26 -19
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/app-icon.svg +4 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/logo.dark.svg +6 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/assets/brand/logo.svg +6 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/Logo.ads.fixture.ts +1 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/Logo.ads.scenario.tsx +12 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/Logo.tsx +41 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/README.md +10 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/index.ts +1 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/brand-preview/BrandPreview.tsx +115 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/review/index.ts +1 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Brand.ads.fixture.ts +12 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/tokens/Brand.ads.scenario.tsx +4 -0
- package/dist/skills/ads-designer/assets/bootstrap-ds/ds.config.json +2 -1
- package/dist/skills/ads-designer/assets/bootstrap-ds-preact/ds.config.json +2 -1
- package/dist/skills/ads-designer/references/branding.md +89 -0
- package/dist/skills/ads-import/references/branding.md +10 -3
- package/dist/token-fixtures.mjs +2 -2
- package/docs/ADS.md +5 -2
- package/docs/CHANGELOG.md +35 -12
- package/docs/GUIDE.md +41 -1
- package/package.json +1 -1
package/dist/config.mjs
CHANGED
|
@@ -20,7 +20,7 @@ export const defaultConfig = {
|
|
|
20
20
|
tokenDir: "tokens",
|
|
21
21
|
inlineStyleFiles: [],
|
|
22
22
|
boundaries: { styleWrites: [], componentVariables: [] },
|
|
23
|
-
assets: { publicDirs: ["public/assets"], generatedPaths: ["dist", "dist-showcase", ".vite", ".ds"], generatedFiles: [], iconSource: null },
|
|
23
|
+
assets: { publicDirs: ["public/assets"], generatedPaths: ["dist", "dist-showcase", ".vite", ".ds"], generatedFiles: [], iconSource: null, targets: [], glyphs: null },
|
|
24
24
|
oxlint: { plugins: [], rules: {}, overrides: [] },
|
|
25
25
|
acceptance: { checks: [], behaviorChecks: false },
|
|
26
26
|
validation: { checks: [], behaviorChecks: true, inputs: [] },
|
|
@@ -33,6 +33,50 @@ export function isInside(parent, file) {
|
|
|
33
33
|
return relative === "" || (!relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
const iconSizes = [16, 32, 64, 128, 256, 512, 1024];
|
|
37
|
+
/** Committed brand outputs: each renders one SVG master in assets/brand/ to a project path. */
|
|
38
|
+
function validateBrandTargets(targets, { root, dsRoot }) {
|
|
39
|
+
if (!Array.isArray(targets)) throw new Error("assets.targets must be an array.");
|
|
40
|
+
const outputs = new Set();
|
|
41
|
+
for (const [index, target] of targets.entries()) {
|
|
42
|
+
const field = `assets.targets[${index}]`;
|
|
43
|
+
if (!target || typeof target !== "object" || Array.isArray(target)) throw new Error(`${field} must be an object.`);
|
|
44
|
+
const unknown = Object.keys(target).filter(key => !["from", "to", "size", "width", "height", "sizes", "background"].includes(key));
|
|
45
|
+
if (unknown.length) throw new Error(`${field} has unknown keys: ${unknown.join(", ")}.`);
|
|
46
|
+
const source = projectPath(dsRoot, target.from, `${field}.from`);
|
|
47
|
+
if (!isInside(path.join(dsRoot, "assets/brand"), source) || path.extname(source).toLowerCase() !== ".svg") throw new Error(`${field}.from must name an SVG inside the ADS's assets/brand/ folder.`);
|
|
48
|
+
const output = projectPath(root, target.to, `${field}.to`);
|
|
49
|
+
if (isInside(path.join(dsRoot, "assets"), output) || isInside(path.join(root, ".ds"), output)) throw new Error(`${field}.to must be outside the ADS assets/ folder and .ds/.`);
|
|
50
|
+
if (outputs.has(output)) throw new Error(`${field}.to repeats an earlier target's output.`);
|
|
51
|
+
outputs.add(output);
|
|
52
|
+
const format = path.extname(output).toLowerCase();
|
|
53
|
+
const pixels = value => Number.isInteger(value) && value >= 1 && value <= 4096;
|
|
54
|
+
if (target.background !== undefined && (format === ".svg" || typeof target.background !== "string" || !/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(target.background))) throw new Error(`${field}.background must be a #RGB, #RRGGBB or #RRGGBBAA colour on a PNG, ICO or ICNS target.`);
|
|
55
|
+
if (format === ".svg") {
|
|
56
|
+
if (["size", "width", "height", "sizes"].some(key => key in target)) throw new Error(`${field} copies its SVG; it takes no sizes.`);
|
|
57
|
+
} else if (format === ".png") {
|
|
58
|
+
const square = target.size !== undefined, rectangle = target.width !== undefined || target.height !== undefined;
|
|
59
|
+
if (square === rectangle || target.sizes !== undefined || (square ? !pixels(target.size) : !pixels(target.width) || !pixels(target.height))) throw new Error(`${field} renders a PNG at one size (1–4096) or one width and height.`);
|
|
60
|
+
} else if (format === ".ico" || format === ".icns") {
|
|
61
|
+
const allowed = format === ".ico" ? [16, 24, 32, 48, 64, 128, 256] : iconSizes;
|
|
62
|
+
if (["size", "width", "height"].some(key => key in target) || !Array.isArray(target.sizes) || !target.sizes.length || new Set(target.sizes).size !== target.sizes.length || target.sizes.some(size => !allowed.includes(size))) throw new Error(`${field}.sizes must list distinct ${format.slice(1).toUpperCase()} sizes from ${allowed.join(", ")}.`);
|
|
63
|
+
} else throw new Error(`${field}.to must end in .svg, .png, .ico or .icns.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** A glyph set: SVGs in one assets/ folder become one generated TypeScript map. */
|
|
67
|
+
function validateGlyphs(glyphs, { dsRoot }) {
|
|
68
|
+
if (glyphs === null) return;
|
|
69
|
+
if (!glyphs || typeof glyphs !== "object" || Array.isArray(glyphs)) throw new Error("assets.glyphs must be an object or null.");
|
|
70
|
+
const unknown = Object.keys(glyphs).filter(key => !["source", "output", "attributes"].includes(key));
|
|
71
|
+
if (unknown.length) throw new Error(`assets.glyphs has unknown keys: ${unknown.join(", ")}.`);
|
|
72
|
+
const source = projectPath(dsRoot, glyphs.source, "assets.glyphs.source");
|
|
73
|
+
if (!isInside(path.join(dsRoot, "assets"), source) || source === path.join(dsRoot, "assets")) throw new Error("assets.glyphs.source must be a folder inside the ADS's assets/ folder.");
|
|
74
|
+
const output = projectPath(dsRoot, glyphs.output, "assets.glyphs.output");
|
|
75
|
+
if (isInside(path.join(dsRoot, "assets"), output) || path.extname(output) !== ".ts") throw new Error("assets.glyphs.output must be a .ts module in the ADS, outside assets/.");
|
|
76
|
+
const attributes = glyphs.attributes ?? {};
|
|
77
|
+
if (!attributes || typeof attributes !== "object" || Array.isArray(attributes) || Object.entries(attributes).some(([name, value]) => !/^[a-z][a-z0-9-]*$/.test(name) || typeof value !== "string" || /["<>]/.test(value))) throw new Error("assets.glyphs.attributes maps SVG attribute names to plain string values.");
|
|
78
|
+
}
|
|
79
|
+
|
|
36
80
|
export function projectPath(root, value, field) {
|
|
37
81
|
if (typeof value !== "string" || !value.trim() || path.isAbsolute(value)) {
|
|
38
82
|
throw new Error(`${field} must be a non-empty relative path.`);
|
|
@@ -124,6 +168,8 @@ export function loadConfig(directory = process.cwd()) {
|
|
|
124
168
|
const source = projectPath(dsRoot, config.assets.iconSource, "assets.iconSource");
|
|
125
169
|
if (!isInside(path.join(dsRoot, "assets/brand"), source) || path.extname(source).toLowerCase() !== ".svg") throw new Error("assets.iconSource must name an SVG inside the ADS's assets/brand/ folder.");
|
|
126
170
|
}
|
|
171
|
+
validateBrandTargets(config.assets.targets, { root, dsRoot });
|
|
172
|
+
validateGlyphs(config.assets.glyphs, { dsRoot });
|
|
127
173
|
for (const plugin of config.oxlint.plugins) {
|
|
128
174
|
if (!plugin || Object.keys(plugin).some((key) => !["name", "path"].includes(key)) || typeof plugin.name !== "string" || !plugin.name || typeof plugin.path !== "string") {
|
|
129
175
|
throw new Error("Each project Oxlint plugin needs a name and a relative path.");
|
|
@@ -259,6 +305,8 @@ export function importViolation(specifier, filename, options, resolve) {
|
|
|
259
305
|
: specifier.startsWith(`${config.dsDir}/`) ? [path.resolve(root, specifier)] : [];
|
|
260
306
|
return imported.some((file) => {
|
|
261
307
|
if (!isInside(dsRoot, file)) return false;
|
|
308
|
+
// Previews may show the ADS's own artwork and fonts: asset files are data, not implementation.
|
|
309
|
+
if (isDevelopmentFile(filename, options) && isInside(path.join(dsRoot, "assets"), file.replace(/\?[^/\\]*$/, ""))) return false;
|
|
262
310
|
// Review implementations can reuse local foundation helpers. Resolved public
|
|
263
311
|
// UI/controller contracts are enforced by the layer inspector, as for patterns.
|
|
264
312
|
if (isReviewFile(filename, options)) return false;
|
package/dist/init.mjs
CHANGED
|
@@ -156,8 +156,9 @@ export function initProject(directory = process.cwd(), { toolPackage, packageMan
|
|
|
156
156
|
return file;
|
|
157
157
|
});
|
|
158
158
|
if (!existingTokens.length) {
|
|
159
|
-
// The starter's token groups, each a scenario with its fixture.
|
|
160
|
-
|
|
159
|
+
// The starter's token groups, each a scenario with its fixture. Its Brand preview needs
|
|
160
|
+
// the starter's artwork and review renderer, which an existing app brings itself.
|
|
161
|
+
for (const name of readdirSync(path.join(starter, "design-system/tokens")).filter(name => /\.ads\.(?:scenario\.tsx|fixture\.ts)$/.test(name) && !name.startsWith("Brand.")).sort()) {
|
|
161
162
|
const content = readFileSync(path.join(starter, "design-system/tokens", name), "utf8").replaceAll('"@ds/review"', JSON.stringify(`${config.publicAlias}/review`)).replaceAll('"@ds"', JSON.stringify(config.publicAlias));
|
|
162
163
|
addMissing(path.join(tokenRoot, name), content);
|
|
163
164
|
}
|
|
@@ -105,7 +105,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
105
105
|
- "app": Tool callable by the app from this server only`),csp:Oc().optional(),permissions:Oc().optional()}),Rz=l({mimeTypes:h(s()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),xz=l({method:u("ui/download-file"),params:l({contents:h(v([Zt,Dt])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Pz=l({method:u("ui/message"),params:l({role:u("user").describe('Message role, currently only "user" is supported.'),content:h(Ce).describe("Message content blocks (text, image, etc.).")})}),Tz=l({method:u("ui/notifications/sandbox-resource-ready"),params:l({html:s().describe("HTML content to load into the inner iframe."),sandbox:s().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:rl.optional().describe("CSP configuration from resource metadata."),permissions:nl.optional().describe("Sandbox permissions from resource metadata.")})}),__=l({method:u("ui/notifications/tool-result"),params:at.describe("Standard MCP tool execution result.")}),zm=l({toolInfo:l({id:Re.optional().describe("JSON-RPC id of the tools/call request."),tool:it.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:t_.optional().describe("Current color theme preference."),styles:d_.optional().describe("Style configuration for theming the app."),displayMode:Ks.optional().describe("How the UI is currently displayed."),availableDisplayModes:h(Ks).optional().describe("Display modes the host supports."),containerDimensions:v([l({height:_().describe("Fixed container height in pixels.")}),l({maxHeight:v([_(),Ic()]).optional().describe("Maximum container height in pixels.")})]).and(v([l({width:_().describe("Fixed container width in pixels.")}),l({maxWidth:v([_(),Ic()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
106
106
|
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:s().optional().describe("User's language and region preference in BCP 47 format."),timeZone:s().optional().describe("User's timezone in IANA format."),userAgent:s().optional().describe("Host application identifier."),platform:v([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:l({touch:z().optional().describe("Whether the device supports touch input."),hover:z().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:l({top:_().describe("Top safe area inset in pixels."),right:_().describe("Right safe area inset in pixels."),bottom:_().describe("Bottom safe area inset in pixels."),left:_().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),y_=l({method:u("ui/notifications/host-context-changed"),params:zm.describe("Partial context update containing only changed fields.")}),Ez=l({method:u("ui/update-model-context"),params:l({content:h(Ce).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:b(s(),P().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),kz=l({method:u("ui/initialize"),params:l({appInfo:ke.describe("App identification (name and version)."),appCapabilities:f_.describe("Features and capabilities this app provides."),protocolVersion:s().describe("Protocol version this app supports.")})}),b_=l({protocolVersion:s().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:ke.describe("Host application identification and version."),hostCapabilities:m_.describe("Features and capabilities provided by the host."),hostContext:zm.describe("Rich context about the host environment.")}).passthrough(),v_={target:"draft-2020-12"};async function Sm(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](v_);throw Error(`Schema (vendor: ${o.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function _m(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((i)=>{let a=i.path?.map((c)=>typeof c==="object"?c.key:c).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(o+n)}return r.value}function z_(e,t){let o={...e,...t};if(t.experimental!==void 0)o.experimental={...e.experimental,...t.experimental};if(t.tools!==void 0)o.tools={...e.tools,...t.tools};return o}class va extends ol{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new ym;_methods=new bm;setRequestHandler=(...e)=>{let[t,...o]=fm("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=fm("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:a_,toolinputpartial:c_,toolresult:__,toolcancelled:l_,hostcontextchanged:y_};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!va.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e))return;if(this._everHadListener.add(e),!this._initializedSent)return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){if(t)this._assertHandlerTiming(e);this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(o)=>{let r=o;if(e==="hostcontextchanged")this._hostContext={...this._hostContext,...r};this._events.dispatch(e,r)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},o={autoResize:!0}){super(o);if(this._appInfo=e,this._appCapabilities=t,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval)le({jitless:!0});this.replaceRequestHandler("ping",(r)=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=z_(this._appCapabilities,e)}registerTool(e,t,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,n=()=>{if(r._initializedSent&&r._appCapabilities.tools?.listChanged)r.sendToolListChanged()},i=t.inputSchema!==void 0,a={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(c){Object.assign(this,c),n()},remove(){if(r._registeredTools[e]!==a)return;delete r._registeredTools[e],n()},handler:async(c,d)=>{if(!a.enabled)throw Error(`Tool ${e} is disabled`);let p;if(i){let m=a.inputSchema,f=m?await _m(m,c??{},`Invalid input for tool ${e}: `):c??{};p=await o(f,d)}else p=await o(d);if(a.outputSchema&&!p.isError)p.structuredContent=await _m(a.outputSchema,p.structuredContent,`Invalid output for tool ${e}: `);return p}};if(this._registeredTools[e]=a,!this._appCapabilities.tools&&!this.transport)this.registerAppCapabilities({tools:{listChanged:!0}});return this.ensureToolHandlersInitialized(),n(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){if(this._toolHandlersInitialized)return;this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let n={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await Sm(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await Sm(r.outputSchema,"output");if(r.annotations)n.annotations=r.annotations;if(r._meta)n._meta=r._meta;return n}))})}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:p_.shape.params,result:h_},(t,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(t,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,o)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e==="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},i_,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},st,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},n_,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},s_,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},g_,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,o=0,r=()=>{if(e)return;e=!0,requestAnimationFrame(()=>{e=!1;let i=document.documentElement,a=i.style.height;i.style.height="max-content";let c=Math.ceil(i.getBoundingClientRect().height);i.style.height=a;let d=Math.ceil(window.innerWidth);if(d!==t||c!==o)t=d,o=c,this.sendSizeChanged({width:d,height:c})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new vm(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:XS}},b_,t);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);if(this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize)this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}function wm(e,t){let o=[],r=new Set;function n(i){if(r.has(i))return;r.add(i);let a=e.get(i);if(!a)throw Error(`Missing preview dependency metadata: ${i}`);for(let c of[...a.imports,...a.styles,...a.references])n(c);o.push(i)}return n(t),o}function Rm(e,t){if(!e||e.revision===t.revision)return[];let o=(r,n)=>{let i=new Map(Object.entries(r.assets));return JSON.stringify(wm(i,n.module).map((a)=>[a,i.get(a)]))};return t.scenarios.filter((r)=>{let n=e.scenarios.find((i)=>i.id===r.id);return!n||o(e,n)!==o(t,r)}).map((r)=>r.id)}class sl{constructor(e){this.read=e,this.records=new Map,this.bytes=new Map,this.urls=new Map,this.styles=new Map,this.styleReady=new Map,this.revisions=new Set,this.loadedModules=new Set,this.importing=Promise.resolve(),this.generation=0,this.prefetchGeneration=0,this.closed=!1,globalThis.__dsPreviewImport=(t)=>this.importModule(t)}register(e){if(e.schemaVersion!==1||!Array.isArray(e.scenarios)||!e.assets||typeof e.revision!=="string")throw Error("Unsupported preview manifest. Rebuild previews with the installed ADS version.");for(let[t,o]of Object.entries(e.assets)){if(!/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/.test(t)||!/^sha256:[a-f0-9]{64}$/.test(o.digest)||!["imports","dynamicImports","styles","references"].every((r)=>Array.isArray(o[r])&&o[r].every((n)=>Object.hasOwn(e.assets,n))))throw Error("Invalid preview dependency graph.");if(this.records.has(t)&&this.records.get(t).digest!==o.digest)throw Object.assign(Error("An immutable preview resource changed its content. Rebuild previews with the current ADS version."),{code:"ADS_RESOURCE_IDENTITY",category:"build",resourceUri:t})}for(let[t,o]of Object.entries(e.assets))this.records.set(t,o)}async resource(e){if(!this.bytes.has(e)){let t=(async()=>{let o=this.records.get(e);if(!o)throw Error(`Unknown preview dependency: ${e}`);let r;try{r=await this.read(e)}catch(d){throw Object.assign(Error(`Preview resource read failed for ${e}: ${d.message}`,{cause:d}),{code:"ADS_RESOURCE_READ",category:"transport",resourceUri:e})}if(this.closed)throw Error("The preview App was closed.");let n=r.contents.find((d)=>d.uri===e);if(!n)throw Object.assign(Error(`Missing preview dependency: ${e}`),{code:"ADS_RESOURCE_CONTENT",category:"build",resourceUri:e});let i=typeof n.text==="string"?new TextEncoder().encode(n.text):Uint8Array.from(atob(n.blob),(d)=>d.charCodeAt(0)),a=await crypto.subtle.digest("SHA-256",i),c="sha256:"+[...new Uint8Array(a)].map((d)=>d.toString(16).padStart(2,"0")).join("");if(i.length!==o.size||c!==o.digest)throw Object.assign(Error("Preview resource integrity check failed. Rebuild and reopen the preview."),{code:"ADS_RESOURCE_INTEGRITY",category:"build",resourceUri:e});return i})();this.bytes.set(e,t),t.catch(()=>this.bytes.delete(e))}return this.bytes.get(e)}closure(e){return wm(this.records,e)}async prefetch(e,t){if(this.closed)return;this.register(e);let o=++this.prefetchGeneration,r=new Set,n=[],i=0;for(let p of t){let m=e.scenarios.find((S)=>S.id===p);if(!m)continue;let f=this.closure(m.module).filter((S)=>!this.bytes.has(S)&&!r.has(S)),y=f.reduce((S,w)=>S+this.records.get(w).size,0);if(i+y>16777216||r.size+f.length>256)continue;i+=y,n.push(p);for(let S of f)r.add(S)}let a=[...r],c=0,d=async()=>{while(!this.closed&&o===this.prefetchGeneration&&c<a.length)await this.resource(a[c++])};return await Promise.all(Array.from({length:Math.min(3,a.length)},d)),{scenarios:n,resources:a.length}}async materialize(e){let t=this.closure(e);await Promise.all(t.map((r)=>this.resource(r)));let o={};for(let r of t){if(this.closed)throw Error("The preview App was closed.");if(this.urls.has(r))continue;let n=this.records.get(r),i=await this.resource(r);if(n.kind==="module"||n.mimeType==="text/css"||n.mimeType==="text/javascript"){let c=new TextDecoder().decode(i);for(let d of n.references){let p=this.urls.get(d);if(!p)throw Error("Unsupported cyclic asset reference.");c=c.replaceAll(d,p)}i=c}let a=URL.createObjectURL(new Blob([i],{type:n.mimeType}));if(this.urls.set(r,a),n.kind==="module")o[r]=a}if(Object.keys(o).length){let r=document.createElement("script");r.type="importmap",r.textContent=JSON.stringify({imports:o}),document.head.append(r)}return t}async importModule(e){let t=this.importing.then(()=>this.materialize(e));this.importing=t.catch(()=>{});let o=await t;await this.attachStyles(o);try{let r=await import(e);return this.loadedModules.add(e),r}catch(r){throw Error(`Preview module import failed for ${e}: ${r.message}. Inspect the App resource bridge, browser network/CSP diagnostics and current build.`,{cause:r})}}async attachStyles(e){for(let t of e){if(this.records.get(t).mimeType!=="text/css")continue;if(this.styles.has(t)){await this.styleReady.get(t);continue}let r=document.createElement("link");r.rel="stylesheet",r.href=this.urls.get(t),this.styles.set(t,r);let n=new Promise((i,a)=>{r.onload=i,r.onerror=()=>a(Error("The host CSP blocked a preview stylesheet."))});this.styleReady.set(t,n),document.head.append(r);try{await n}catch(i){throw r.remove(),this.styles.delete(t),this.styleReady.delete(t),i}}}async refreshStyles(e,t){let o=[e],r=new Set,n=new Set;for(let i=0;i<o.length;i++){let a=o[i];if(r.has(a))continue;r.add(a);for(let c of await this.materialize(a)){n.add(c);for(let d of this.records.get(c).dynamicImports)if(this.loadedModules.has(d))o.push(d)}}if(await this.attachStyles([...n]),t!==this.generation||this.closed)return!1;for(let[i,a]of this.styles)if(!n.has(i))a.remove(),this.styles.delete(i),this.styleReady.delete(i);for(let i of n)if(this.styles.has(i))document.head.append(this.styles.get(i));return!0}async mount(e,t,o){let r=++this.generation;this.register(e);let n=e.scenarios.find((d)=>d.id===t);if(!n)throw Error("The selected scenario is no longer registered.");let i=JSON.stringify(this.closure(n.module).map((d)=>[d,this.records.get(d)]));if(this.mounted?.id===t&&this.mounted.container===o&&this.mounted.signature===i)return this.refreshStyles(n.module,r);if(this.revisions.add(n.module),this.revisions.size>20)throw Object.assign(Error("Reopen the preview to release modules retained across 20 build revisions."),{code:"ADS_PREVIEW_REOPEN"});let a=await this.importModule(n.module);if(r!==this.generation)return!1;let c=this.unmount;if(this.unmount=void 0,this.mounted=void 0,await c?.(),r!==this.generation||this.closed)return!1;if(o.replaceChildren(),!await this.refreshStyles(n.module,r))return!1;if(typeof a.mount!=="function")throw Error("The compiled scenario has no mount adapter.");if(this.unmount=a.mount(o),typeof this.unmount!=="function")throw Error("The scenario mount adapter must return an unmount callback.");return this.mounted={id:t,container:o,signature:i},!0}async dispose(){if(this.closed)return;this.closed=!0,++this.generation,++this.prefetchGeneration,await this.unmount?.(),this.mounted=void 0;for(let e of this.styles.values())e.remove();for(let e of this.urls.values())URL.revokeObjectURL(e);this.styles.clear(),this.styleReady.clear(),this.urls.clear(),this.bytes.clear(),this.records.clear(),this.revisions.clear(),this.loadedModules.clear(),delete globalThis.__dsPreviewImport}}function xm(e){return Array.isArray(e)&&e.length>0&&e.every((t)=>t&&typeof t==="object"&&typeof t.token==="string"&&/^--[\w-]+$/.test(t.token)&&typeof t.property==="string"&&/^-?[a-z][a-z0-9-]*$/.test(t.property)&&typeof t.probe==="string"&&t.probe.trim().length>0)&&new Set(e.map((t)=>`${t.token}:${t.property}`)).size===e.length}function Pm(e,t){let o=t.getComputedStyle(e),r=e.getBoundingClientRect();if(o.display==="none"||o.visibility!=="visible"||!e.getClientRects().length||!(r.width||r.height))return!1;for(let n=e;n;n=n.parentElement)if(Number(t.getComputedStyle(n).opacity)===0)return!1;return!0}function Tm(e,t){if(!xm(t))return{ok:!1,diagnostics:["Token preview needs explicit { token, property, probe } samples from the project fixture. Rebuild with the current compiler."]};let o=e.ownerDocument,{defaultView:r,documentElement:n}=o,i=[],a=[],c=[...e.querySelectorAll("[data-ads-token], [data-ads-property]")],d=new Set(t.map((p)=>`${p.token}:${p.property}`));for(let p of c)if(!d.has(`${p.dataset.adsToken}:${p.dataset.adsProperty}`))i.push(`Undeclared rendered token sample ${p.dataset.adsToken}:${p.dataset.adsProperty}.`);for(let p of t){if(!r.CSS.supports(p.property,p.probe)){i.push(`${p.token}: the fixture probe is invalid for ${p.property}.`);continue}let m=r.getComputedStyle(n).getPropertyValue(p.token).trim();if(!m||!r.CSS.supports(p.property,m)){i.push(`${p.token}: its current value is invalid for the fixture's ${p.property} binding.`);continue}let f=c.filter((S)=>S.dataset.adsToken===p.token&&S.dataset.adsProperty===p.property);if(!f.length){i.push(`${p.token} needs a rendered ${p.property} sample, not only a name/value label.`);continue}let y=!1;for(let S of f){let w=[];for(let C=S.parentElement;C&&C!==e;C=C.parentElement)if(C.tagName==="DETAILS"&&!C.open)C.open=!0,w.push(C);let x=n.getAttribute("style"),R=S.getAttribute("style");try{if(!/^(?:-[a-z]+-)?transition(?:-|$)/.test(p.property))S.style.setProperty("transition","none","important");let C=r.getComputedStyle(S).getPropertyValue(p.property),N=Pm(S,r);n.style.setProperty(p.token,p.probe,"important");let O=r.getComputedStyle(S).getPropertyValue(p.property);y=Boolean(O&&O!==C&&(N||Pm(S,r)))}finally{if(x===null)n.removeAttribute("style");else n.setAttribute("style",x);if(R===null)S.removeAttribute("style");else S.setAttribute("style",R);for(let C of w)C.open=!1}if(y)break}if(y)a.push(p);else i.push(`${p.token} has no visible ${p.property} sample that responds to its value. Hardcoded copies do not satisfy coverage.`)}return{ok:!i.length,verified:a,diagnostics:i}}function Em({container:e=document.getElementById("root"),bindings:t=[],auditResources:o=!1}={}){let r=[],n=[],i=[];if(!e||!Array.isArray(t)||t.length>100)return{ok:!1,diagnostics:["Invalid bounded paint-audit descriptor."],verified:n};let a=e.ownerDocument,c=a.defaultView,d=["color","fill","stroke","stop-color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color"];function p(f,y,S,w=new Set){if(f=f.trim(),["none","currentColor"].includes(f))return!0;let x=/^var\(\s*(--[\w-]+)\s*\)$/.exec(f);if(x){let N=x[1];if(!S.tokens.includes(N)||w.has(N))return!1;let O=c.getComputedStyle(y).getPropertyValue(N).trim();return!!O&&c.CSS.supports("color",O)}let R=/^light-dark\(\s*(var\(\s*--[\w-]+\s*\)|currentColor)\s*,\s*(var\(\s*--[\w-]+\s*\)|currentColor)\s*\)$/.exec(f);if(R)return c.CSS.supports("color",f)&&p(R[1],y,S,w)&&p(R[2],y,S,w);let C=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(f);if(C&&c.CSS.supports("fill",f)){let N=[...a.querySelectorAll("[id]")].filter((O)=>O.id===C[2]);return N.length===1&&["linearGradient","radialGradient","pattern"].includes(N[0].localName)&&y.contains(N[0])}return!1}for(let f of t){if(!f||typeof f.scope!=="string"||!Array.isArray(f.tokens)||typeof f.prefix!=="string"||typeof f.suffix!=="string"){r.push("Invalid paint binding metadata; rebuild previews.");continue}let y;try{y=[...e.querySelectorAll(f.scope)]}catch{r.push(`${f.owner}: invalid binding scope.`);continue}if(y.length>20)i.push(`${f.owner}: only the first 20 instances were audited; use a focused scenario for complete evidence.`);for(let S of y.slice(0,20)){let w=[S,...S.querySelectorAll("*")];if(w.length>1000){i.push(`${f.owner}: instance exceeds 1000 elements; paint effects are not established.`);continue}let x=[...S.style].filter((R)=>R.startsWith(f.prefix)&&R.endsWith(f.suffix));if(x.length>100)i.push(`${f.owner}: only the first 100 binding keys were audited.`);for(let R of x.slice(0,100)){let C=S.style.getPropertyValue(R).trim(),N=R.slice(f.prefix.length,f.suffix?-f.suffix.length:void 0);if(!/^[A-Za-z0-9_-]+$/.test(N)||!p(C,S,f)){r.push(`${f.owner}: invalid or inaccessible paint ${R}: ${C}. Use an accessible token, instance-local SVG paint server, none or currentColor.`);continue}let O=S.getAttribute("style"),q=w.map((L)=>L.getAttribute("style"));try{for(let V of w)V.style.setProperty("transition","none","important");let L=w.map((V)=>d.map((ae)=>c.getComputedStyle(V).getPropertyValue(ae)));S.style.setProperty(R,"rgb(17, 103, 211)","important");let j=w.some((V,ae)=>d.some((Y,ge)=>c.getComputedStyle(V).getPropertyValue(Y)!==L[ae][ge]));if(!j)S.style.setProperty(R,"rgb(211, 67, 23)","important"),j=w.some((V,ae)=>d.some((Y,ge)=>c.getComputedStyle(V).getPropertyValue(Y)!==L[ae][ge]));if(!j)i.push(`${f.owner}: ${R} has no observed paint effect in its current instance. A written variable alone is not rendering evidence; check the relevant selected/visible consumer.`);else n.push({owner:f.owner,binding:f.name,variable:R})}finally{if(w.forEach((L,j)=>{if(q[j]===null)L.removeAttribute("style");else L.setAttribute("style",q[j])}),O===null)S.removeAttribute("style");else S.setAttribute("style",O)}}for(let R of w)for(let C of["fill","stroke","stop-color"]){let N=R.getAttribute(C);if(!N)continue;let O=/^var\(\s*(--[\w-]+)\s*\)$/.exec(N);if(O&&O[1].startsWith(f.prefix)&&O[1].endsWith(f.suffix)&&!x.includes(O[1]))r.push(`${f.owner}: ${O[1]} is consumed without a value in this instance.`);if(N.startsWith("url(")&&!p(N,S,f))r.push(`${f.owner}: missing, duplicated or out-of-instance local paint resource ${N}.`)}}}let m=o?[...e.querySelectorAll("[fill], [stroke], [style]")]:[];if(m.length>1000)i.push("Only the first 1000 potential SVG paint consumers were audited.");for(let f of m.slice(0,1000))for(let y of["fill","stroke"]){let S=f.getAttribute(y)??f.style.getPropertyValue(y);if(!S?.startsWith("url("))continue;let w=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(S)?.[2],x=w?[...a.querySelectorAll("[id]")].filter((C)=>C.id===w):[],R=f.ownerSVGElement??(f.localName==="svg"?f:null);if(x.length!==1||!R?.contains(x[0])||!["linearGradient","radialGradient","pattern"].includes(x[0]?.localName))r.push(`Invalid, missing, duplicated or nonlocal SVG paint resource ${S}. Keep IDs isolated per rendered instance.`)}return{ok:!r.length,complete:!i.length,verified:n,diagnostics:r.slice(0,40),limits:i.slice(0,20),scope:"observed App instances and current input; repeat after updates"}}var ye=new va({name:"ADS resource preview",version:"1.0.0"},{},{autoResize:!0}),Bt=document.getElementById("root"),il=document.getElementById("ads-preview-status"),ll,pl=async(e)=>{if(!ye.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");try{return await ye.readServerResource({uri:ll?ll+encodeURIComponent(e):e},{timeout:15000})}catch(t){if(t.code===-32601||t.message==="Method not found")throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");throw t}},ei=new sl(pl),He,$m,Gt,ul,hl,al=!1,lt=0,Ys={},_e="",Qs=!1,cl,km,Cm=new Set;function Im(e){if(ye.getHostVersion()?.name!=="ADS showcase")return;let t=km;if(km=e,!t)return;let o=Rm(t,e).filter((r)=>r!==He&&Cm.has(r));if(!o.length)return;ei.prefetch(e,o).then((r)=>ut("prefetched",{revision:e.revision,...r})).catch((r)=>console.warn("ADS preview prefetch",r.message))}function Oe(e,t=!1){il.textContent=e,il.hidden=!e||ye.getHostVersion()?.name==="ADS showcase",il.setAttribute("role",t?"alert":"status")}async function ut(e,t={}){try{if(ye.getHostCapabilities()?.logging)await ye.sendLog({level:e==="error"?"error":"info",logger:"ads-preview",data:{state:e,id:He,...t}})}catch{}}function Om(e){if(Ys={...Ys,...e,styles:{...Ys.styles,...e.styles}},["light","dark"].includes(Ys.theme))document.documentElement.dataset.theme=Ys.theme}async function dl(e="ads://preview/manifest"){let t;try{t=await pl(e)}catch(o){throw Object.assign(Error(o.message,{cause:o}),{code:"ADS_MANIFEST_READ",category:"transport"})}return JSON.parse(t.contents.find((o)=>typeof o.text==="string").text)}async function Xs(e,t,o=!1,r="",n=!1){let i=o||n;if(!r&&e===He&&t&&t===Gt&&i===Qs){Oe(_e||(i?"Checking changes…":""),Boolean(_e)),await ut(_e?"error":i?"checking":"ready",_e?{message:_e}:{revision:Gt});return}let a=++lt;++ei.generation,He=e,Cm.add(e),document.documentElement.dataset.adsScenario=e,document.documentElement.dataset.adsPreviewState="loading";for(let c of["adsPreviewErrorCategory","adsPreviewErrorCode","adsPreviewResourceUri"])delete document.documentElement.dataset[c];_e="",Oe(""),await ut(r?"reverting":"loading");try{let c=await dl(o?"ads://preview/live":"ads://preview/manifest");if(t&&c.revision!==t){if(a===lt)Oe("Updating preview…"),await ut("loading",{code:"ADS_PREVIEW_CHANGED"});return}if(a!==lt)return;if(!await ei.mount(c,e,Bt)||a!==lt)return;if(Gt=c.revision,ul=c.session,Qs=i,await new Promise((m)=>requestAnimationFrame(()=>requestAnimationFrame(m))),await document.fonts.ready,a!==lt)return;let p=c.scenarios.find((m)=>m.id===e);if(Bt.dataset.adsPaintBindings=JSON.stringify(p?.paintBindings??[]),Bt.dataset.adsPaintAudit=String(Boolean(p?.paintAudit)),Bt.dataset.adsPaintAuditComplete="not-requested",p?.paintBindings?.length||p?.paintAudit){let m=Em({container:Bt,bindings:p.paintBindings??[],auditResources:Boolean(p.paintAudit)});if(!m.ok)throw Object.assign(Error(`Paint binding verification failed:
|
|
107
107
|
${m.diagnostics.join(`
|
|
108
|
-
`)}`),{code:"ADS_PAINT_BINDING",category:"assertion"});if(Bt.dataset.adsPaintAuditComplete=String(m.complete),!m.complete)await ut("audit-limited",{limits:m.limits})}if(p?.kind==="tokens"){let m=Tm(Bt,p.samples);if(!m.ok)throw _e=`Token preview verification failed:
|
|
108
|
+
`)}`),{code:"ADS_PAINT_BINDING",category:"assertion"});if(Bt.dataset.adsPaintAuditComplete=String(m.complete),!m.complete)await ut("audit-limited",{limits:m.limits})}if(p?.kind==="tokens"&&!p.brand){let m=Tm(Bt,p.samples);if(!m.ok)throw _e=`Token preview verification failed:
|
|
109
109
|
${m.diagnostics.slice(0,20).join(`
|
|
110
110
|
`)}`,Object.assign(Error(_e),{code:"ADS_TOKEN_SAMPLE",category:"assertion"})}if(a===lt){if(document.documentElement.dataset.adsPreviewRevision=Gt,document.documentElement.dataset.adsPreviewState=r?"error":i?"checking":"ready",Oe(r||(i?"Checking changes…":""),Boolean(r)),await ut(r?"error":i?"checking":"ready",{revision:Gt,selectionRevision:$m,...r?{message:r}:{}}),!i&&!r)Im(c)}}catch(c){if(a===lt){if(document.documentElement.dataset.adsPreviewState="error",document.documentElement.dataset.adsPreviewErrorCategory=c.category??"runner",document.documentElement.dataset.adsPreviewErrorCode=c.code??"ADS_PREVIEW_STARTUP",c.resourceUri)document.documentElement.dataset.adsPreviewResourceUri=c.resourceUri;Oe(c.message,!0),await ut("error",{message:c.message,...c.code?{code:c.code}:{},...c.category?{category:c.category}:{},...c.resourceUri?{resourceUri:c.resourceUri}:{}})}}}async function w_(){if(!He||al||document.visibilityState==="hidden")return;al=!0;try{let e=JSON.parse((await pl("ads://project/build")).contents.find((o)=>typeof o.text==="string").text);cl=void 0;let t=e.previews.find((o)=>o.id===He);if(t?.live&&!t.current)if(t.live.revision!==Gt||e.session!==ul||!Qs)await Xs(He,t.live.revision,!0);else Oe(_e||"Checking changes…",Boolean(_e));else if(!t||!t.current){let o=t?.diagnostics?.[0]?.message;if(o&&Qs){let r=await dl();await Xs(He,r.revision,!1,`Build failed. Showing the previous preview.
|
|
111
111
|
${o}`)}Oe(o?`Build failed. Showing the previous preview.
|
|
@@ -105,7 +105,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
105
105
|
- "app": Tool callable by the app from this server only`),csp:vc().optional(),permissions:vc().optional()}),Xz=l({mimeTypes:h(s()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),ev=l({method:u("ui/download-file"),params:l({contents:h(z([qt,At])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),tv=l({method:u("ui/message"),params:l({role:u("user").describe('Message role, currently only "user" is supported.'),content:h(Te).describe("Message content blocks (text, image, etc.).")})}),ov=l({method:u("ui/notifications/sandbox-resource-ready"),params:l({html:s().describe("HTML content to load into the inner iframe."),sandbox:s().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Jc.optional().describe("CSP configuration from resource metadata."),permissions:Bc.optional().describe("Sandbox permissions from resource metadata.")})}),WS=l({method:u("ui/notifications/tool-result"),params:rt.describe("Standard MCP tool execution result.")}),om=l({toolInfo:l({id:ye.optional().describe("JSON-RPC id of the tools/call request."),tool:ot.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:CS.optional().describe("Current color theme preference."),styles:ZS.optional().describe("Style configuration for theming the app."),displayMode:Vs.optional().describe("How the UI is currently displayed."),availableDisplayModes:h(Vs).optional().describe("Display modes the host supports."),containerDimensions:z([l({height:g().describe("Fixed container height in pixels.")}),l({maxHeight:z([g(),zc()]).optional().describe("Maximum container height in pixels.")})]).and(z([l({width:g().describe("Fixed container width in pixels.")}),l({maxWidth:z([g(),zc()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
106
106
|
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:s().optional().describe("User's language and region preference in BCP 47 format."),timeZone:s().optional().describe("User's timezone in IANA format."),userAgent:s().optional().describe("Host application identifier."),platform:z([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:l({touch:v().optional().describe("Whether the device supports touch input."),hover:v().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:l({top:g().describe("Top safe area inset in pixels."),right:g().describe("Right safe area inset in pixels."),bottom:g().describe("Bottom safe area inset in pixels."),left:g().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),GS=l({method:u("ui/notifications/host-context-changed"),params:om.describe("Partial context update containing only changed fields.")}),rv=l({method:u("ui/update-model-context"),params:l({content:h(Te).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:y(s(),R().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),nv=l({method:u("ui/initialize"),params:l({appInfo:xe.describe("App identification (name and version)."),appCapabilities:FS.describe("Features and capabilities this app provides."),protocolVersion:s().describe("Protocol version this app supports.")})}),KS=l({protocolVersion:s().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:xe.describe("Host application identification and version."),hostCapabilities:HS.describe("Features and capabilities provided by the host."),hostContext:om.describe("Rich context about the host environment.")}).passthrough(),YS={target:"draft-2020-12"};async function Yh(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](YS);throw Error(`Schema (vendor: ${o.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Qh(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((i)=>{let a=i.path?.map((c)=>typeof c==="object"?c.key:c).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(o+n)}return r.value}function QS(e,t){let o={...e,...t};if(t.experimental!==void 0)o.experimental={...e.experimental,...t.experimental};if(t.tools!==void 0)o.tools={...e.tools,...t.tools};return o}class ua extends Fc{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new Xh;_methods=new em;setRequestHandler=(...e)=>{let[t,...o]=Gh("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=Gh("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:AS,toolinputpartial:jS,toolresult:WS,toolcancelled:LS,hostcontextchanged:GS};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!ua.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e))return;if(this._everHadListener.add(e),!this._initializedSent)return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){if(t)this._assertHandlerTiming(e);this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(o)=>{let r=o;if(e==="hostcontextchanged")this._hostContext={...this._hostContext,...r};this._events.dispatch(e,r)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},o={autoResize:!0}){super(o);if(this._appInfo=e,this._appCapabilities=t,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval)ce({jitless:!0});this.replaceRequestHandler("ping",(r)=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=QS(this._appCapabilities,e)}registerTool(e,t,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,n=()=>{if(r._initializedSent&&r._appCapabilities.tools?.listChanged)r.sendToolListChanged()},i=t.inputSchema!==void 0,a={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(c){Object.assign(this,c),n()},remove(){if(r._registeredTools[e]!==a)return;delete r._registeredTools[e],n()},handler:async(c,p)=>{if(!a.enabled)throw Error(`Tool ${e} is disabled`);let d;if(i){let f=a.inputSchema,S=f?await Qh(f,c??{},`Invalid input for tool ${e}: `):c??{};d=await o(S,p)}else d=await o(p);if(a.outputSchema&&!d.isError)d.structuredContent=await Qh(a.outputSchema,d.structuredContent,`Invalid output for tool ${e}: `);return d}};if(this._registeredTools[e]=a,!this._appCapabilities.tools&&!this.transport)this.registerAppCapabilities({tools:{listChanged:!0}});return this.ensureToolHandlersInitialized(),n(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){if(this._toolHandlersInitialized)return;this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let n={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await Yh(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await Yh(r.outputSchema,"output");if(r.annotations)n.annotations=r.annotations;if(r._meta)n._meta=r._meta;return n}))})}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:DS.shape.params,result:VS},(t,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(t,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,o)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e==="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},qS,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},tt,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},NS,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},MS,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},JS,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,o=0,r=()=>{if(e)return;e=!0,requestAnimationFrame(()=>{e=!1;let i=document.documentElement,a=i.style.height;i.style.height="max-content";let c=Math.ceil(i.getBoundingClientRect().height);i.style.height=a;let p=Math.ceil(window.innerWidth);if(p!==t||c!==o)t=p,o=c,this.sendSizeChanged({width:p,height:c})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new tm(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:ES}},KS,t);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);if(this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize)this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}function rm(e){return Array.isArray(e)&&e.length>0&&e.every((t)=>t&&typeof t==="object"&&typeof t.token==="string"&&/^--[\w-]+$/.test(t.token)&&typeof t.property==="string"&&/^-?[a-z][a-z0-9-]*$/.test(t.property)&&typeof t.probe==="string"&&t.probe.trim().length>0)&&new Set(e.map((t)=>`${t.token}:${t.property}`)).size===e.length}function nm(e,t){let o=t.getComputedStyle(e),r=e.getBoundingClientRect();if(o.display==="none"||o.visibility!=="visible"||!e.getClientRects().length||!(r.width||r.height))return!1;for(let n=e;n;n=n.parentElement)if(Number(t.getComputedStyle(n).opacity)===0)return!1;return!0}function sm(e,t){if(!rm(t))return{ok:!1,diagnostics:["Token preview needs explicit { token, property, probe } samples from the project fixture. Rebuild with the current compiler."]};let o=e.ownerDocument,{defaultView:r,documentElement:n}=o,i=[],a=[],c=[...e.querySelectorAll("[data-ads-token], [data-ads-property]")],p=new Set(t.map((d)=>`${d.token}:${d.property}`));for(let d of c)if(!p.has(`${d.dataset.adsToken}:${d.dataset.adsProperty}`))i.push(`Undeclared rendered token sample ${d.dataset.adsToken}:${d.dataset.adsProperty}.`);for(let d of t){if(!r.CSS.supports(d.property,d.probe)){i.push(`${d.token}: the fixture probe is invalid for ${d.property}.`);continue}let f=r.getComputedStyle(n).getPropertyValue(d.token).trim();if(!f||!r.CSS.supports(d.property,f)){i.push(`${d.token}: its current value is invalid for the fixture's ${d.property} binding.`);continue}let S=c.filter((b)=>b.dataset.adsToken===d.token&&b.dataset.adsProperty===d.property);if(!S.length){i.push(`${d.token} needs a rendered ${d.property} sample, not only a name/value label.`);continue}let _=!1;for(let b of S){let P=[];for(let I=b.parentElement;I&&I!==e;I=I.parentElement)if(I.tagName==="DETAILS"&&!I.open)I.open=!0,P.push(I);let k=n.getAttribute("style"),E=b.getAttribute("style");try{if(!/^(?:-[a-z]+-)?transition(?:-|$)/.test(d.property))b.style.setProperty("transition","none","important");let I=r.getComputedStyle(b).getPropertyValue(d.property),D=nm(b,r);n.style.setProperty(d.token,d.probe,"important");let M=r.getComputedStyle(b).getPropertyValue(d.property);_=Boolean(M&&M!==I&&(D||nm(b,r)))}finally{if(k===null)n.removeAttribute("style");else n.setAttribute("style",k);if(E===null)b.removeAttribute("style");else b.setAttribute("style",E);for(let I of P)I.open=!1}if(_)break}if(_)a.push(d);else i.push(`${d.token} has no visible ${d.property} sample that responds to its value. Hardcoded copies do not satisfy coverage.`)}return{ok:!i.length,verified:a,diagnostics:i}}var st=new ua({name:"ADS preview",version:"1.0.0"},{},{autoResize:!0}),im=document.getElementById("ads-preview-seed"),cm;function am(e,t){let o=document.createElement(e);return o.textContent=t,o}function lm(e){if(e==="light"||e==="dark")document.documentElement.dataset.theme=e}st.onhostcontextchanged=(e)=>lm(e.theme);if(im){let n=function(c){let p="";if(!c||c.state==="unreported")p="Preview freshness is unverified. Check the build status before reviewing.";else if(c.state==="error"){let d=c.diagnostics?.[0];if(p=`Build failed. Showing ${e.revision===null?"an earlier preview":`build ${e.revision}`}.`,d)p+=`
|
|
107
107
|
${d.file??""}${d.line?`:${d.line}`:""}${d.file?": ":""}${d.message}`}else if(["building","idle"].includes(c.state))p="Rebuilding. This view is the previous preview.";else if(c.revision!==e.revision||c.session!==e.session)p=`Build ${c.revision} is ready. Reopen this preview to load it.`;t.textContent=[p,r].filter(Boolean).join(`
|
|
108
|
-
`),t.hidden=!t.textContent},e=JSON.parse(im.textContent),t=am("aside","");t.id="ads-preview-build",t.setAttribute("role","status"),t.setAttribute("aria-live","polite");let o=am("style","#ads-preview-build{position:fixed;inset:12px 12px auto;z-index:2147483647;padding:10px 14px;border:1px solid GrayText;border-radius:6px;background:Canvas;color:CanvasText;font:13px system-ui;white-space:pre-wrap;overflow-wrap:anywhere;max-height:30vh;overflow:auto}#ads-preview-build[hidden]{display:none}");document.head.append(o),document.body.append(t);let r="";if(n(e),e.kind==="tokens")(async()=>{await new Promise((p)=>requestAnimationFrame(()=>requestAnimationFrame(p))),await document.fonts.ready;let c=sm(document.body,e.samples);if(!c.ok){r=`Token preview verification failed:
|
|
108
|
+
`),t.hidden=!t.textContent},e=JSON.parse(im.textContent),t=am("aside","");t.id="ads-preview-build",t.setAttribute("role","status"),t.setAttribute("aria-live","polite");let o=am("style","#ads-preview-build{position:fixed;inset:12px 12px auto;z-index:2147483647;padding:10px 14px;border:1px solid GrayText;border-radius:6px;background:Canvas;color:CanvasText;font:13px system-ui;white-space:pre-wrap;overflow-wrap:anywhere;max-height:30vh;overflow:auto}#ads-preview-build[hidden]{display:none}");document.head.append(o),document.body.append(t);let r="";if(n(e),e.kind==="tokens"&&!e.brand)(async()=>{await new Promise((p)=>requestAnimationFrame(()=>requestAnimationFrame(p))),await document.fonts.ready;let c=sm(document.body,e.samples);if(!c.ok){r=`Token preview verification failed:
|
|
109
109
|
${c.diagnostics.slice(0,20).join(`
|
|
110
110
|
`)}`,t.setAttribute("role","alert"),n(e);try{if(st.getHostCapabilities()?.logging)await st.sendLog({level:"error",logger:"ads-preview",data:{state:"error",id:e.id,message:r}})}catch{}}})();let i=!1,a;st.onteardown=async()=>(clearInterval(a),{}),window.addEventListener("pagehide",()=>clearInterval(a),{once:!0}),cm=()=>{if(!st.getHostCapabilities()?.serverResources)return;async function c(){if(i||document.visibilityState==="hidden")return;i=!0;try{let p=await st.readServerResource({uri:"ads://project/build"},{timeout:5000}),d=JSON.parse(p.contents.find((f)=>("text"in f)).text);n(d.previews.find((f)=>f.id===e.id))}catch{t.textContent=["Build status unavailable. Reopen the preview to verify it.",r].filter(Boolean).join(`
|
|
111
111
|
`),t.hidden=!1}finally{i=!1}}c(),a=setInterval(()=>{c()},2000)}}try{await st.connect(),cm?.(),lm(st.getHostContext()?.theme)}catch{}
|
package/dist/mcp/server.mjs
CHANGED
|
@@ -160,7 +160,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
160
160
|
return { ...registry, revision: previewSourceRevision(current) };
|
|
161
161
|
}
|
|
162
162
|
function captureIndex() { const inventory = captureInventory(); return captures.store.list(inventory.scenarios, inventory.revision, { prune: !inventory.diagnostics.length }); }
|
|
163
|
-
const scenarioApps = (quick = false) => (quick ? quickRegistry() : getRegistry()).scenarios.map(item => ({ id: item.id, title: item.title, kind: item.kind, ...(item.samples ? { samples: item.samples } : {}), file: item.artifact }));
|
|
163
|
+
const scenarioApps = (quick = false) => (quick ? quickRegistry() : getRegistry()).scenarios.map(item => ({ id: item.id, title: item.title, kind: item.kind, ...(item.samples ? { samples: item.samples } : {}), ...(item.brand ? { brand: true } : {}), file: item.artifact }));
|
|
164
164
|
const tokenScenarios = () => {
|
|
165
165
|
const references=drafts.list({unit:"tokens",limit:100000}).drafts.map(({id,title,revision,state,preview})=>({id,title,revision,state,preview}));
|
|
166
166
|
return getRegistry().scenarios.filter(item => item.kind === "tokens").map(item => ({ id:item.id,title:item.title,count:item.tokens.length,drafts:references }));
|
|
@@ -278,6 +278,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
278
278
|
...skills.skills.map(({ uri, frontmatter }) => ({ uri, name: frontmatter.name, description: frontmatter.description, mimeType: "text/markdown" })),
|
|
279
279
|
...documents.filter(document => promoted.has(document.uri)).sort((a, b) => Number(b.uri === context.publicEntryUri) - Number(a.uri === context.publicEntryUri)).map(({ file: _file, ...document }) => document),
|
|
280
280
|
{ uri: "ads://guides/tokens", name: "Shared Data and component variable boundaries", mimeType: "text/markdown" },
|
|
281
|
+
{ uri: "ads://guides/branding", name: "Brand artwork, icons, committed targets and glyph sets", mimeType: "text/markdown" },
|
|
281
282
|
{ uri: "ads://guides/reporting", name: "Report suspected ADS bugs and feature requests", mimeType: "text/markdown" },
|
|
282
283
|
{ uri: TOKENS_APP_URI, name: "Experimental token widget", mimeType: APP_MIME },
|
|
283
284
|
{ uri: SCENARIO_APP_URI, name: "Experimental scenario widget", mimeType: APP_MIME },
|
|
@@ -325,6 +326,7 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
325
326
|
if (uri === "ads://guides/validation") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/validation.md", import.meta.url), "utf8") }] };
|
|
326
327
|
if (uri === "ads://guides/runtimes") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/runtimes.md", import.meta.url), "utf8") }] };
|
|
327
328
|
if (uri === "ads://guides/evidence") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/evidence.md", import.meta.url), "utf8") }] };
|
|
329
|
+
if (uri === "ads://guides/branding") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/branding.md", import.meta.url), "utf8") }] };
|
|
328
330
|
if (uri === "ads://guides/tokens") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/design-data.md", import.meta.url), "utf8") }] };
|
|
329
331
|
if (uri === "ads://guides/reporting") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/reporting.md", import.meta.url), "utf8") }] };
|
|
330
332
|
if (uri === "ads://guides/atomic-styles") return { contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL("../skills/ads-designer/references/atomic-styles.md", import.meta.url), "utf8") }] };
|
|
@@ -498,7 +500,8 @@ export function createAdsMcp(directory, { era = "legacy", skillDirectory, pollIn
|
|
|
498
500
|
} },
|
|
499
501
|
{ name: "ads_show_tokens", title: "Token previews", description: "Render a discovered token scenario with project-owned templates and fixtures. Pass its id as category, or omit for the first token scenario. Default waitFor: verified requires current checks. Interactive browsers may use waitFor: compiled for explicitly unverified feedback or a retained view. Older compilers provide a generic definition inspector.", schema: z.object({ category: z.string().max(256).optional(), waitFor: z.enum(["verified", "compiled"]).default("verified") }).strict(), _meta: { ui: { resourceUri: options.config.mcp.previewManifest ? PREVIEW_APP_URI : TOKENS_APP_URI } }, call: async ({ category, waitFor }, signal) => {
|
|
500
502
|
const registry = await previewRegistry(waitFor);
|
|
501
|
-
|
|
503
|
+
// A token group first; a brand scenario only when it is the token folder's only preview.
|
|
504
|
+
if (!category && options.config.mcp.previewManifest) category = (registry.scenarios.find(item => item.kind === "tokens" && !item.brand) ?? registry.scenarios.find(item => item.kind === "tokens"))?.id;
|
|
502
505
|
if (!category && options.config.mcp.previewManifest) throw new Error("No token scenario is registered. Colocate a token scenario and fixture before opening the preview; ads_tokens still inspects definitions.");
|
|
503
506
|
if (category) {
|
|
504
507
|
const entry = registry.scenarios.find(item => item.kind === "tokens" && item.id === category);
|
package/dist/preview-bun.mjs
CHANGED
|
@@ -165,13 +165,15 @@ export function createBunPreviewBuilder() {
|
|
|
165
165
|
return{name:"ads-bun-preview",setup(build){
|
|
166
166
|
build.onResolve({filter:/./},args=>{
|
|
167
167
|
if(/[?&]worker(?:[&=]|$)/.test(args.path)){const specifier=args.path.split("?")[0];return{path:resolve(specifier,args.importer),namespace:args.path.includes("url")?"ads-worker-url":"ads-worker"};}
|
|
168
|
-
|
|
168
|
+
// Bun shares one module per path across namespaces: a raw import keeps its own path, so
|
|
169
|
+
// the same file can be both a URL (a brand preview) and text (a component's geometry).
|
|
170
|
+
if(/[?&](?:url|raw|ads-asset)(?:[&=]|$)/.test(args.path)){const raw=/[?&]raw(?:[&=]|$)/.test(args.path),file=resolve(args.path.split("?")[0],args.importer);return{path:raw?`${file}?raw`:file,namespace:raw?"ads-raw":"ads-file"};}
|
|
169
171
|
const mapped=alias(args.path);if(mapped!==args.path)return{path:resolve(mapped,args.importer)};
|
|
170
172
|
if(args.path.endsWith(".css")&&resolve(args.path,args.importer||foundation)===foundation)return{path:foundation,namespace:"ads-foundation"};
|
|
171
173
|
});
|
|
172
174
|
build.onLoad({filter:/./,namespace:"ads-foundation"},()=>({contents:"export {};",loader:"js"}));
|
|
173
175
|
build.onLoad({filter:/./,namespace:"ads-file"},args=>{inputs.add(args.path);return{contents:readFileSync(args.path),loader:"file"};});
|
|
174
|
-
build.onLoad({filter:/./,namespace:"ads-raw"},args=>{inputs.add(
|
|
176
|
+
build.onLoad({filter:/./,namespace:"ads-raw"},args=>{const file=args.path.replace(/\?raw$/,"");inputs.add(file);return{contents:readFileSync(file,"utf8"),loader:"text"};});
|
|
175
177
|
for(const namespace of ["ads-worker","ads-worker-url"])build.onLoad({filter:/./,namespace},async args=>{
|
|
176
178
|
await args.defer();
|
|
177
179
|
const name=await worker(args.path,ancestors),url=JSON.stringify("./"+name);
|
|
@@ -178,7 +178,7 @@ export function createPreviewResources(output, options, entries, {retain, prune
|
|
|
178
178
|
const scenarios = entries.map((entry, index) => {
|
|
179
179
|
const chunk = bundle.find(item => item.type === "chunk" && item.facadeModuleId === `\0ads-preview-entry:${index}`);
|
|
180
180
|
if (!chunk) throw new Error(`Missing compiled scenario entry: ${entry.id}`);
|
|
181
|
-
return retain?.manifest.scenarios.find(previous=>previous.id===entry.id) ?? { id: entry.id, title: entry.title, kind: entry.kind, ...(entry.samples ? { samples: entry.samples } : {}), ...(entry.paintBindings?.length ? {paintBindings:entry.paintBindings} : {}), ...(entry.paintAudit?{paintAudit:true}:{}), module: uris.get(chunk.fileName) };
|
|
181
|
+
return retain?.manifest.scenarios.find(previous=>previous.id===entry.id) ?? { id: entry.id, title: entry.title, kind: entry.kind, ...(entry.samples ? { samples: entry.samples } : {}), ...(entry.brand ? { brand: true } : {}), ...(entry.paintBindings?.length ? {paintBindings:entry.paintBindings} : {}), ...(entry.paintAudit?{paintAudit:true}:{}), module: uris.get(chunk.fileName) };
|
|
182
182
|
});
|
|
183
183
|
// Rechunking a growing warm graph must not replace already compiled views.
|
|
184
184
|
// Retain their exact closures for identical source/compiler modes, then prune
|
package/dist/scenarios.mjs
CHANGED
|
@@ -22,6 +22,8 @@ function literal(node, checker, seen = new Set()) {
|
|
|
22
22
|
if (!node || seen.has(node)) return undefined;
|
|
23
23
|
seen = new Set([...seen, node]);
|
|
24
24
|
if (node && ts.isStringLiteralLike(node)) return node.text;
|
|
25
|
+
if (node?.kind === ts.SyntaxKind.TrueKeyword) return true;
|
|
26
|
+
if (node?.kind === ts.SyntaxKind.FalseKeyword) return false;
|
|
25
27
|
if (node && ts.isArrayLiteralExpression(node)) return node.elements.map(item => literal(item, checker, seen));
|
|
26
28
|
if (node && ts.isObjectLiteralExpression(node)) return Object.fromEntries(node.properties.map((item) => ts.isPropertyAssignment(item) && item.name && (ts.isIdentifier(item.name) || ts.isStringLiteralLike(item.name)) ? [item.name.text, literal(item.initializer, checker, seen)] : ["invalid", undefined]));
|
|
27
29
|
if (checker && (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node))) {
|
|
@@ -123,7 +125,7 @@ export function inspectScenarios(options, suppliedProgram) {
|
|
|
123
125
|
report(file, "Scenario metadata is not statically readable. Render coverage is not established until this prerequisite is repaired.", metadataExpression, {coverage:"not-established",owner:units.owner(relative)});
|
|
124
126
|
continue;
|
|
125
127
|
}
|
|
126
|
-
for(const field of Object.keys(metadata))if(!["id","title","kind","covers","exercises","tokens","samples","captureTargets"].includes(field))report(file,`Unknown scenario field ${field}.`,entryNode(field),{entry:field});
|
|
128
|
+
for(const field of Object.keys(metadata))if(!["id","title","kind","covers","exercises","tokens","samples","captureTargets","brand"].includes(field))report(file,`Unknown scenario field ${field}.`,entryNode(field),{entry:field});
|
|
127
129
|
const group = scenarioGroup(file, units.owner(relative));
|
|
128
130
|
if(typeof metadata.title!=="string"||!metadata.title.trim()) {
|
|
129
131
|
report(file,"Scenario title must be a nonempty static string; independent render evidence is retained.",entryNode("title"),{entry:"title"});
|
|
@@ -136,7 +138,12 @@ export function inspectScenarios(options, suppliedProgram) {
|
|
|
136
138
|
if(Object.hasOwn(metadata,"tokens")&&(!Array.isArray(metadata.tokens)||metadata.tokens.some(name=>typeof name!=="string"||!name.startsWith("--")))) {
|
|
137
139
|
report(file,"Scenario tokens must be a static list of real token names.",entryNode("tokens"),{entry:"tokens"});metadata.tokens=[];
|
|
138
140
|
}
|
|
139
|
-
|
|
141
|
+
// A brand scenario in the token folder previews artwork, not token bindings.
|
|
142
|
+
if(Object.hasOwn(metadata,"brand")&&(metadata.brand!==true||kind!=="tokens"||Object.hasOwn(metadata,"samples"))) {
|
|
143
|
+
report(file,"brand: true marks a token-folder scenario that previews assets/brand artwork; it has no token samples.",entryNode("brand"),{entry:"brand"});delete metadata.brand;
|
|
144
|
+
}
|
|
145
|
+
const brand=metadata.brand===true;
|
|
146
|
+
if(kind==="tokens"&&Object.hasOwn(metadata,"tokens")||kind==="tokens"&&!brand&&!validTokenSamples(metadata.samples)||Object.hasOwn(metadata,"samples")&&!validTokenSamples(metadata.samples)) {
|
|
140
147
|
report(file,"Token scenarios need samples: fixture.samples, a literal list of { token, property, probe } real CSS bindings. Printing values or covers: [] is incomplete.",entryNode("samples"),{entry:"samples"});delete metadata.samples;
|
|
141
148
|
}
|
|
142
149
|
const covers = [];
|
|
@@ -176,7 +183,7 @@ export function inspectScenarios(options, suppliedProgram) {
|
|
|
176
183
|
if(bindingTrace) findBindings(source);
|
|
177
184
|
const paintBindings = inspectRuntimeContracts(options,program).bindings.filter(binding=>reachable.has(binding.scope.apiName)).map(binding=>({owner:binding.unit,name:binding.name,scope:binding.scope.selector,prefix:binding.prefix,suffix:binding.suffix,tokens:tokenInventory.tokens.filter(token=>!token.owner||token.owner==="tokens"||token.owner===binding.unit).map(token=>token.name)}));
|
|
178
185
|
const paintAudit=contractDeclarations.some(contract=>contract.paintInputs?.some(input=>reachable.has(input.apiName)));
|
|
179
|
-
scenarios.push({ id, kind, title: metadata.title, ...(group ? { group } : {}), ...(fixture ? { fixture: path.relative(root, fixture).replaceAll("\\", "/") } : {}), covers: [...new Set(metadata.covers)], ...(captureTargets ? { captureTargets } : {}), ...(Object.hasOwn(metadata, "exercises") ? { exercises: [...new Set(exercises)] } : {}), tokens, ...(metadata.samples ? { samples: metadata.samples } : {}), ...(paintBindings.length?{paintBindings}:{}), ...(paintAudit?{paintAudit:true}:{}), file: path.relative(root, file).replaceAll("\\", "/"), artifact: path.relative(root, scenarioArtifact(root, id)).replaceAll("\\", "/") });
|
|
186
|
+
scenarios.push({ id, kind, title: metadata.title, ...(group ? { group } : {}), ...(fixture ? { fixture: path.relative(root, fixture).replaceAll("\\", "/") } : {}), covers: [...new Set(metadata.covers)], ...(captureTargets ? { captureTargets } : {}), ...(Object.hasOwn(metadata, "exercises") ? { exercises: [...new Set(exercises)] } : {}), tokens, ...(metadata.samples ? { samples: metadata.samples } : {}), ...(metadata.brand ? { brand: true } : {}), ...(paintBindings.length?{paintBindings}:{}), ...(paintAudit?{paintAudit:true}:{}), file: path.relative(root, file).replaceAll("\\", "/"), artifact: path.relative(root, scenarioArtifact(root, id)).replaceAll("\\", "/") });
|
|
180
187
|
}
|
|
181
188
|
return { scenarios: scenarios.sort((a, b) => a.id.localeCompare(b.id)), diagnostics };
|
|
182
189
|
}
|
|
@@ -297,7 +304,7 @@ export function inspectScenarioCoverage(options, program, report, advise = () =>
|
|
|
297
304
|
else if (!exercised.has(name)) advise(source.fileName, "scenario-exercise-review", `${name} is referenced dynamically. Verify its invocation in the registered browser/behavior checks; a reference alone does not prove execution.`);
|
|
298
305
|
}
|
|
299
306
|
for (const name of referencedTokens) if (!declaredTokens.has(name)) report(source.fileName, "token-scenario-reference", `Reachable scenario input references undeclared token ${name}.`);
|
|
300
|
-
if (scenario.kind === "tokens" && !samplesPassed) report(source.fileName, "token-scenario-render", "Pass the declared fixture.samples into a rendered review renderer's samples prop. Printing token names or reading unused fixtures is not sample coverage.");
|
|
307
|
+
if (scenario.kind === "tokens" && !scenario.brand && !samplesPassed) report(source.fileName, "token-scenario-render", "Pass the declared fixture.samples into a rendered review renderer's samples prop. Printing token names or reading unused fixtures is not sample coverage.");
|
|
301
308
|
for (const name of scenario.tokens) {
|
|
302
309
|
if (!referencedTokens.has(name)) report(source.fileName, "token-scenario-render", `${name} is declared in tokens but has no reachable reference from the default scenario entry. Consume the real token fixture; metadata alone does not count.`);
|
|
303
310
|
else if (scenario.kind === "tokens" && samplesPassed && declaredTokens.has(name)) coveredTokens.add(name);
|
|
@@ -327,6 +327,15 @@ consumer paths, dimensions, and transparent/background variants. With no icon
|
|
|
327
327
|
source, generation is a no-op. Component imports retain destination branding;
|
|
328
328
|
artwork replacement and token-value adoption are explicit selections.
|
|
329
329
|
|
|
330
|
+
Committed native and export icons are `assets.targets` (SVG copy, PNG, ICO, ICNS),
|
|
331
|
+
and UI icon sets are `assets.glyphs`; `ads assets` keeps them and the committed
|
|
332
|
+
`assets/generated.json` current, and `ads check` fails when they are stale. Describe
|
|
333
|
+
and license each artwork in `assets/brand/README.md`, pair dark-theme variants as
|
|
334
|
+
`<name>.dark.svg`, show them through a component, and preview them in a
|
|
335
|
+
`brand: true` token-folder scenario. Read
|
|
336
|
+
[branding.md](references/branding.md) (`ads://guides/branding`) before changing
|
|
337
|
+
brand artwork, icon outputs or glyphs.
|
|
338
|
+
|
|
330
339
|
## Design craft and mobile behavior
|
|
331
340
|
|
|
332
341
|
For design direction, content/layout decisions, interface wording, component
|
|
@@ -24,8 +24,8 @@ The starter declares React in `ds.config.json`. Keep that choice, JSX, runtime
|
|
|
24
24
|
dependencies and the preview mount adapter consistent. Init records a choice for
|
|
25
25
|
an unconfigured project; it does not convert copied React source to Preact.
|
|
26
26
|
|
|
27
|
-
The starter has one example of each layer (Button, TextField, SearchBar,
|
|
28
|
-
SearchPage). Rename, restyle or replace them; add only what the product needs.
|
|
27
|
+
The starter has one example of each layer (Button, Logo, TextField, SearchBar,
|
|
28
|
+
SearchPage) and placeholder brand artwork. Rename, restyle or replace them; add only what the product needs.
|
|
29
29
|
Keep the ADS in root `design-system/`, beside application `src/`.
|
|
30
30
|
Keep public exports in `design-system/index.ts`; consumers use its `@ds` alias.
|
|
31
31
|
`styles.css` is the foundation CSS entry and contains token imports only.
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
This private React or Preact TypeScript workspace contains semantic CSS tokens, a project-owned
|
|
4
4
|
token review renderer, a public barrel, Linaria extraction and a preview compiler
|
|
5
5
|
adapter, plus one example of each layer to build on: two token groups (Color; Space, type &
|
|
6
|
-
motion),
|
|
7
|
-
`components/Forms/TextField`), one pattern
|
|
8
|
-
composition (`composition/Search/SearchPage`)
|
|
9
|
-
|
|
6
|
+
motion) and a Brand preview, components in three groups (`components/Actions/Button`,
|
|
7
|
+
`components/Content/Logo`, `components/Forms/TextField`), one pattern
|
|
8
|
+
(`patterns/Search/SearchBar`) and one composition (`composition/Search/SearchPage`),
|
|
9
|
+
plus placeholder brand artwork in `assets/brand/` (a logo with its dark-theme
|
|
10
|
+
variant, and the app icon that `assets.iconSource` names). Rename, restyle or
|
|
11
|
+
replace them as the product's own; it has no fonts. The minimal showcase shell and MCP client
|
|
10
12
|
come from ADS tooling.
|
|
11
13
|
|
|
12
14
|
Read the local [contract](ADS.md) and the
|
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
# Project branding
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
The starter's placeholder artwork. Replace each file with the product's own and keep this
|
|
4
|
+
table current: `ads check` warns about artwork that is undescribed, unlicensed, unused or
|
|
5
|
+
missing from the brand scenario (`tokens/Brand.ads.scenario.tsx`).
|
|
6
|
+
|
|
7
|
+
| File | Use | Backgrounds |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `logo.svg` | Logo in the UI (`components/Content/Logo`), light theme | Light surfaces |
|
|
10
|
+
| `logo.dark.svg` | The same logo for the dark theme | Dark surfaces |
|
|
11
|
+
| `app-icon.svg` | Master for web icons (`assets.iconSource`) and any `assets.targets` | Any; it has its own fill and padding |
|
|
12
|
+
|
|
13
|
+
License: placeholder artwork made for the ADS starter, free to use, change or remove
|
|
14
|
+
(MIT, like ADS). Record the real artwork's credits and license here when it replaces this.
|
|
15
|
+
|
|
16
|
+
## How branding works
|
|
6
17
|
|
|
7
18
|
UI branding uses the project-owned shared roles in `tokens/`: change values such as
|
|
8
19
|
`--accent`, `--font-sans`, and `--radius-md`. Components own `--ds-*` variables;
|
|
9
20
|
patterns and development review helpers own `--ux-*`; the showcase owns
|
|
10
|
-
`--showcase-*`. Do not introduce a
|
|
11
|
-
|
|
21
|
+
`--showcase-*`. Do not introduce a brand-prefixed token vocabulary or override
|
|
22
|
+
component state variables.
|
|
23
|
+
|
|
24
|
+
Name a dark-theme variant `<name>.dark.svg`; the component showing the artwork renders
|
|
25
|
+
both and the theme picks one. Fixed colors belong inside the artwork only.
|
|
12
26
|
|
|
13
27
|
Put licensed font files in `assets/fonts/` and their declarations in
|
|
14
28
|
`tokens/fonts.css`. Keep that optional import first in `styles.css`.
|
|
15
29
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
After `ads init`, the normal npm or Bun build generates `favicon.svg`,
|
|
24
|
-
`favicon.ico` (16/32/48), `apple-touch-icon.png` (180), `icon-192.png`, and
|
|
25
|
-
`icon-512.png` in ignored `.ds/assets/`. Run `ads assets` to regenerate manually.
|
|
26
|
-
Outputs retain the artwork's colors and transparent background; provide an
|
|
27
|
-
appropriate source background if a platform needs one. Mount this directory
|
|
28
|
-
through the application's existing bundler and keep app manifest metadata in
|
|
29
|
-
the application. Edit the original SVG, never generated variants.
|
|
30
|
+
`assets.iconSource` (here `assets/brand/app-icon.svg`) makes every build generate
|
|
31
|
+
`favicon.svg`, `favicon.ico` (16/32/48), `apple-touch-icon.png` (180), `icon-192.png` and
|
|
32
|
+
`icon-512.png` in ignored `.ds/assets/`; mount that folder through the application's
|
|
33
|
+
bundler and keep the manifest in the application. Native launchers, tray icons and
|
|
34
|
+
upload exports are committed `assets.targets` (PNG, ICO, ICNS or SVG copies), kept
|
|
35
|
+
fresh by `ads assets` and checked by `ads check`. Edit the masters here, never
|
|
36
|
+
generated files. See the [branding guide](https://github.com/reqvire-org/ads/blob/main/skills/ads-designer/references/branding.md).
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 40" role="img" aria-label="Starter">
|
|
2
|
+
<rect x="2" y="4" width="32" height="32" rx="8" fill="#fb7185"/>
|
|
3
|
+
<circle cx="18" cy="20" r="7" fill="#17191e"/>
|
|
4
|
+
<rect x="46" y="12" width="68" height="7" rx="3.5" fill="#f8fafc"/>
|
|
5
|
+
<rect x="46" y="24" width="44" height="5" rx="2.5" fill="#94a3b8"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 40" role="img" aria-label="Starter">
|
|
2
|
+
<rect x="2" y="4" width="32" height="32" rx="8" fill="#c62648"/>
|
|
3
|
+
<circle cx="18" cy="20" r="7" fill="#ffffff"/>
|
|
4
|
+
<rect x="46" y="12" width="68" height="7" rx="3.5" fill="#1e293b"/>
|
|
5
|
+
<rect x="46" y="24" width="44" height="5" rx="2.5" fill="#64748b"/>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const fixture = { title: "Logo", label: "Starter" } as const;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Logo } from "@ds";
|
|
2
|
+
import { DemoFrame } from "@ds/review";
|
|
3
|
+
import { fixture } from "./Logo.ads.fixture";
|
|
4
|
+
export const scenario = { title: fixture.title, covers: ["Logo"] };
|
|
5
|
+
export default function Scenario() {
|
|
6
|
+
return (
|
|
7
|
+
<DemoFrame>
|
|
8
|
+
<Logo label={fixture.label} />
|
|
9
|
+
<Logo label={fixture.label} size="large" />
|
|
10
|
+
</DemoFrame>
|
|
11
|
+
);
|
|
12
|
+
}
|
package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/Logo.tsx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { css, cx } from "@linaria/atomic";
|
|
2
|
+
import logo from "../../../assets/brand/logo.svg?url";
|
|
3
|
+
import logoDark from "../../../assets/brand/logo.dark.svg?url";
|
|
4
|
+
|
|
5
|
+
export interface LogoProps {
|
|
6
|
+
/** The product name, read by assistive technology. */
|
|
7
|
+
label: string;
|
|
8
|
+
size?: "small" | "large";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const base = css`
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
`;
|
|
15
|
+
const sizes = {
|
|
16
|
+
small: css`height: var(--space-12);`,
|
|
17
|
+
large: css`height: calc(var(--space-16) * 2);`,
|
|
18
|
+
};
|
|
19
|
+
const image = css`
|
|
20
|
+
display: block;
|
|
21
|
+
height: 100%;
|
|
22
|
+
width: auto;
|
|
23
|
+
`;
|
|
24
|
+
// Both variants are in the page; the theme shows one, so switching needs no script.
|
|
25
|
+
const light = css`
|
|
26
|
+
:root[data-theme="dark"] & { display: none; }
|
|
27
|
+
`;
|
|
28
|
+
const dark = css`
|
|
29
|
+
display: none;
|
|
30
|
+
:root[data-theme="dark"] & { display: block; }
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
/** The product logo, in its light- or dark-theme artwork. */
|
|
34
|
+
export function Logo({ label, size = "small" }: LogoProps) {
|
|
35
|
+
return (
|
|
36
|
+
<span className={cx("ds-logo", base, sizes[size])} role="img" aria-label={label}>
|
|
37
|
+
<img className={cx(image, light)} src={logo} alt="" />
|
|
38
|
+
<img className={cx(image, dark)} src={logoDark} alt="" />
|
|
39
|
+
</span>
|
|
40
|
+
);
|
|
41
|
+
}
|
package/dist/skills/ads-designer/assets/bootstrap-ds/design-system/components/Content/Logo/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Logo
|
|
2
|
+
|
|
3
|
+
The product logo from `assets/brand/`: `logo.svg` in the light theme and `logo.dark.svg`
|
|
4
|
+
in the dark theme. Both images are in the page and the theme shows one, so switching
|
|
5
|
+
themes needs no script. `label` is the accessible name.
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default |
|
|
8
|
+
|---|---|---|
|
|
9
|
+
| `label` | `string` | — |
|
|
10
|
+
| `size` | `"small" \| "large"` | `"small"` |
|
|
@@ -3,5 +3,6 @@ import "./styles.css";
|
|
|
3
3
|
|
|
4
4
|
// Public components and patterns. Add new ones here as they are implemented.
|
|
5
5
|
export { Button, type ButtonProps } from "./components/Actions/Button/Button";
|
|
6
|
+
export { Logo, type LogoProps } from "./components/Content/Logo/Logo";
|
|
6
7
|
export { TextField, type TextFieldProps } from "./components/Forms/TextField/TextField";
|
|
7
8
|
export { SearchBar, type SearchBarProps } from "./patterns/Search/SearchBar/SearchBar";
|