@agent-native/core 0.140.0 → 0.141.0
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/corpus/README.md +1 -1
- package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +1 -1
- package/corpus/templates/analytics/changelog/2026-08-05-historical-analytics-rollups-stay-complete-and-atomic.md +6 -0
- package/corpus/templates/analytics/server/lib/dashboard-report.ts +0 -2
- package/corpus/templates/analytics/server/lib/first-party-analytics-rollups.ts +11 -6
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +8 -18
- package/corpus/templates/analytics/server/plugins/db.ts +174 -0
- package/corpus/templates/calendar/app/components/calendar/OutOfOfficeEvent.tsx +38 -38
- package/corpus/templates/calendar/changelog/2026-08-05-out-of-office-blocks-now-open-from-their-scheduled-time-rang.md +6 -0
- package/corpus/templates/calendar/server/lib/booking-emails.ts +70 -154
- package/corpus/templates/calendar/server/lib/event-guest-notifications.ts +28 -64
- package/corpus/templates/clips/actions/get-recording-player-data.ts +1 -0
- package/corpus/templates/clips/actions/invite-member.ts +16 -39
- package/corpus/templates/clips/app/components/player/comments-panel.tsx +2 -3
- package/corpus/templates/clips/app/components/player/reaction-emojis.ts +10 -0
- package/corpus/templates/clips/app/components/player/reactions-tray.tsx +2 -2
- package/corpus/templates/clips/app/components/player/video-player.tsx +20 -6
- package/corpus/templates/clips/app/routes/embed.$shareId.tsx +33 -0
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +5 -1
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +27 -1
- package/corpus/templates/clips/changelog/2026-08-05-comment-and-video-reaction-pickers-now-include-eyes-and-mind.md +6 -0
- package/corpus/templates/clips/changelog/2026-08-05-fresh-recordings-now-open-with-the-complete-video.md +6 -0
- package/corpus/templates/clips/server/lib/transactional-email-templates.ts +0 -24
- package/corpus/templates/clips/server/routes/api/public-recording.get.ts +1 -0
- package/corpus/templates/content/server/lib/comment-notifications.ts +26 -57
- package/corpus/templates/design/.agents/skills/design-systems/SKILL.md +1 -44
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +1 -265
- package/corpus/templates/design/actions/create-design-system.ts +10 -9
- package/corpus/templates/design/actions/get-design-system.ts +0 -53
- package/corpus/templates/design/actions/import-design-tokens.ts +71 -5
- package/corpus/templates/design/actions/index-design-tokens.ts +80 -61
- package/corpus/templates/design/actions/update-design-system.ts +10 -7
- package/corpus/templates/design/app/components/design/EditPanel.tsx +2 -45
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +0 -12
- package/corpus/templates/design/app/components/design/edit-panel/document-colors.ts +6 -10
- package/corpus/templates/design/app/components/design/edit-panel/effects-properties.tsx +3 -19
- package/corpus/templates/design/app/components/design/edit-panel/fill-properties.tsx +10 -36
- package/corpus/templates/design/app/components/design/edit-panel/interaction-state-helpers.ts +0 -15
- package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +1 -19
- package/corpus/templates/design/app/components/design/edit-panel/position-helpers.ts +0 -6
- package/corpus/templates/design/app/components/design/edit-panel/stroke-properties.tsx +23 -53
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +4 -142
- package/corpus/templates/design/app/components/design/types.ts +0 -6
- package/corpus/templates/design/app/i18n-data.ts +0 -20
- package/corpus/templates/design/app/pages/DesignSystemSetup.tsx +1 -1
- package/corpus/templates/design/app/pages/DesignSystems.tsx +1 -78
- package/corpus/templates/design/app/pages/design-editor/html-layer-positioning.ts +1 -6
- package/corpus/templates/design/e2e/helpers.ts +0 -17
- package/corpus/templates/design/shared/resolve-tweaks.ts +18 -10
- package/corpus/templates/forms/server/lib/response-email.ts +0 -2
- package/corpus/templates/plan/actions/request-plan-access.ts +12 -33
- package/corpus/templates/plan/server/lib/comment-notifications.ts +27 -53
- package/corpus/templates/slides/server/lib/comment-notifications.ts +21 -44
- package/dist/a2a/handlers.js +9 -10
- package/dist/brand-kit/index.d.ts +0 -1
- package/dist/brand-kit/index.js +0 -1
- package/dist/brand-kit/types.d.ts +0 -25
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/client.js +8 -8
- package/dist/db/migrations.js +39 -19
- package/dist/localization/default-messages.d.ts +0 -45
- package/dist/localization/default-messages.js +0 -45
- package/dist/notifications/routes.d.ts +6 -6
- package/dist/observability/routes.d.ts +3 -3
- package/dist/org/handlers.js +1 -8
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +7 -7
- package/dist/provider-api/actions/provider-api.d.ts +7 -7
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/action-discovery.js +0 -22
- package/dist/server/auth.js +3 -1
- package/dist/server/better-auth-instance.js +2 -17
- package/dist/server/email.d.ts +0 -9
- package/dist/server/email.js +3 -44
- package/dist/server/index.d.ts +0 -1
- package/dist/server/index.js +0 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +3 -2
- package/docs/content/authentication.mdx +25 -19
- package/package.json +1 -1
- package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +3 -2
- package/corpus/templates/analytics/server/lib/emails.ts +0 -51
- package/corpus/templates/analytics/server/plugins/transactional-emails.ts +0 -5
- package/corpus/templates/calendar/server/lib/emails.ts +0 -167
- package/corpus/templates/calendar/server/plugins/transactional-emails.ts +0 -5
- package/corpus/templates/clips/server/lib/emails.ts +0 -256
- package/corpus/templates/clips/server/plugins/transactional-email-catalog.ts +0 -5
- package/corpus/templates/content/server/lib/emails.ts +0 -70
- package/corpus/templates/content/server/plugins/transactional-emails.ts +0 -5
- package/corpus/templates/design/app/components/design/edit-panel/design-system-swatches.ts +0 -215
- package/corpus/templates/design/changelog/2026-08-04-design-system-tokens-show-by-name-in-the-editor.md +0 -6
- package/corpus/templates/design/server/lib/design-system-tokens.ts +0 -35
- package/corpus/templates/design/shared/authored-color-styles.ts +0 -401
- package/corpus/templates/dispatch/app/routes/transactional-email.$appId.$id.tsx +0 -4
- package/corpus/templates/dispatch/app/routes/transactional-email.tsx +0 -4
- package/corpus/templates/forms/server/lib/emails.ts +0 -52
- package/corpus/templates/forms/server/plugins/transactional-emails.ts +0 -5
- package/corpus/templates/plan/server/lib/emails.ts +0 -67
- package/corpus/templates/plan/server/plugins/transactional-emails.ts +0 -5
- package/corpus/templates/slides/server/lib/emails.ts +0 -40
- package/corpus/templates/slides/server/plugins/transactional-emails.ts +0 -5
- package/dist/brand-kit/tokens.d.ts +0 -92
- package/dist/brand-kit/tokens.js +0 -280
- package/dist/email-catalog/actions/list-email-activity.d.ts +0 -6
- package/dist/email-catalog/actions/list-email-activity.js +0 -15
- package/dist/email-catalog/actions/list-email-engagement.d.ts +0 -6
- package/dist/email-catalog/actions/list-email-engagement.js +0 -15
- package/dist/email-catalog/actions/list-email-log.d.ts +0 -8
- package/dist/email-catalog/actions/list-email-log.js +0 -22
- package/dist/email-catalog/actions/list-transactional-emails.d.ts +0 -23
- package/dist/email-catalog/actions/list-transactional-emails.js +0 -61
- package/dist/email-catalog/actions/render-transactional-email-preview.d.ts +0 -10
- package/dist/email-catalog/actions/render-transactional-email-preview.js +0 -24
- package/dist/email-catalog/authorize.d.ts +0 -2
- package/dist/email-catalog/authorize.js +0 -10
- package/dist/email-catalog/log.d.ts +0 -57
- package/dist/email-catalog/log.js +0 -117
- package/dist/email-catalog/provider-metrics.d.ts +0 -34
- package/dist/email-catalog/provider-metrics.js +0 -165
- package/dist/email-catalog/registry.d.ts +0 -79
- package/dist/email-catalog/registry.js +0 -71
- package/dist/email-catalog/schema.d.ts +0 -212
- package/dist/email-catalog/schema.js +0 -49
- package/dist/email-catalog/system-emails.d.ts +0 -14
- package/dist/email-catalog/system-emails.js +0 -68
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
|
-
import {
|
|
3
|
-
brandKitRoleTokens,
|
|
4
|
-
resolveBrandKitTokens,
|
|
5
|
-
} from "@agent-native/core/brand-kit/tokens";
|
|
6
2
|
import {
|
|
7
3
|
hydrateBuilderDesignSystemReference,
|
|
8
4
|
parseBuilderDesignSystemProxyReference,
|
|
@@ -65,54 +61,6 @@ function formatTokenValues(tokenValues: Record<string, string>): string[] {
|
|
|
65
61
|
];
|
|
66
62
|
}
|
|
67
63
|
|
|
68
|
-
const MAX_LISTED_TOKENS = 40;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Require generated CSS to reference tokens rather than paste their values. A
|
|
72
|
-
* colour cannot identify a token afterwards — Carbon points four at one blue.
|
|
73
|
-
*/
|
|
74
|
-
function tokenReferenceDirective(data: unknown): string[] {
|
|
75
|
-
if (!data || typeof data !== "object") return [];
|
|
76
|
-
const kit = data as {
|
|
77
|
-
tokens?: unknown;
|
|
78
|
-
customCSS?: unknown;
|
|
79
|
-
colors?: object | null;
|
|
80
|
-
borders?: { radius?: string } | null;
|
|
81
|
-
spacing?: object | null;
|
|
82
|
-
};
|
|
83
|
-
const tokens = [
|
|
84
|
-
...resolveBrandKitTokens(kit),
|
|
85
|
-
...brandKitRoleTokens(kit),
|
|
86
|
-
].filter((token) => token.type === "color");
|
|
87
|
-
if (tokens.length === 0) return [];
|
|
88
|
-
|
|
89
|
-
const seen = new Set<string>();
|
|
90
|
-
const listed: string[] = [];
|
|
91
|
-
for (const token of tokens) {
|
|
92
|
-
if (seen.has(token.cssVar)) continue;
|
|
93
|
-
seen.add(token.cssVar);
|
|
94
|
-
listed.push(`- ${token.cssVar}: ${token.value}`);
|
|
95
|
-
if (listed.length >= MAX_LISTED_TOKENS) break;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return [
|
|
99
|
-
"",
|
|
100
|
-
"### Reference these color tokens, do not paste their values",
|
|
101
|
-
"Write the token reference with its value as a fallback:",
|
|
102
|
-
// guard:allow-raw-color — the do/don't example shown to the generating agent
|
|
103
|
-
" background: var(--color-accent, #0f62fe); /* yes */",
|
|
104
|
-
// guard:allow-raw-color — the counter-example it must not copy
|
|
105
|
-
" background: #0f62fe; /* no */",
|
|
106
|
-
"The fallback is required — exports and unlinked designs define no custom",
|
|
107
|
-
"properties, and a bare var() renders transparent there. Define every token",
|
|
108
|
-
"you reference in the screen's `:root` block too.",
|
|
109
|
-
...listed,
|
|
110
|
-
seen.size > MAX_LISTED_TOKENS
|
|
111
|
-
? `- …and ${seen.size - MAX_LISTED_TOKENS} more; call get-design-system for the full set.`
|
|
112
|
-
: "",
|
|
113
|
-
];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
64
|
function buildDesignSystemAgentContext({
|
|
117
65
|
id,
|
|
118
66
|
title,
|
|
@@ -134,7 +82,6 @@ function buildDesignSystemAgentContext({
|
|
|
134
82
|
"## Selected Design System Context",
|
|
135
83
|
`Use "${title}" (id: ${id}) as the visual source of truth for this generation.`,
|
|
136
84
|
"Apply these tokens, assets, and usage notes before choosing colors, type, spacing, radius, imagery, or component language.",
|
|
137
|
-
...tokenReferenceDirective(parseJson(data)),
|
|
138
85
|
];
|
|
139
86
|
|
|
140
87
|
if (description?.trim()) {
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
|
-
import {
|
|
3
|
-
classifyBrandKitToken as classifyVar,
|
|
4
|
-
friendlyTokenName as friendlyName,
|
|
5
|
-
isColorTokenValue as isColorValue,
|
|
6
|
-
} from "@agent-native/core/brand-kit/tokens";
|
|
7
2
|
import { buildDeepLink } from "@agent-native/core/server";
|
|
8
3
|
import {
|
|
9
4
|
CODE_MAX_FILES,
|
|
@@ -121,6 +116,70 @@ function designDeepLink(designId: string): string {
|
|
|
121
116
|
});
|
|
122
117
|
}
|
|
123
118
|
|
|
119
|
+
function classifyVar(name: string, value: string): ImportedTokenType {
|
|
120
|
+
const n = name.toLowerCase();
|
|
121
|
+
if (
|
|
122
|
+
/color|bg|background|text|border|accent|primary|secondary|surface|muted|foreground|fill|stroke/i.test(
|
|
123
|
+
n,
|
|
124
|
+
) ||
|
|
125
|
+
isColorValue(value)
|
|
126
|
+
) {
|
|
127
|
+
return "color";
|
|
128
|
+
}
|
|
129
|
+
if (/font|size|leading|tracking|weight|heading|body|type/i.test(n)) {
|
|
130
|
+
return "typography";
|
|
131
|
+
}
|
|
132
|
+
if (/radius|rounded/i.test(n)) return "radius";
|
|
133
|
+
if (/spacing|gap|padding|margin|space/i.test(n)) return "spacing";
|
|
134
|
+
if (/shadow|blur|drop/i.test(n)) return "shadow";
|
|
135
|
+
return "other";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function isColorValue(value: string): boolean {
|
|
139
|
+
const normalized = value.trim().toLowerCase();
|
|
140
|
+
if (
|
|
141
|
+
/^(#[0-9a-fA-F]{3,8}|rgba?\(|hsla?\(|oklch\(|color\()/i.test(normalized)
|
|
142
|
+
) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
return [
|
|
146
|
+
"red",
|
|
147
|
+
"blue",
|
|
148
|
+
"green",
|
|
149
|
+
"yellow",
|
|
150
|
+
"orange",
|
|
151
|
+
"purple",
|
|
152
|
+
"pink",
|
|
153
|
+
"cyan",
|
|
154
|
+
"magenta",
|
|
155
|
+
"teal",
|
|
156
|
+
"navy",
|
|
157
|
+
"maroon",
|
|
158
|
+
"coral",
|
|
159
|
+
"salmon",
|
|
160
|
+
"gold",
|
|
161
|
+
"silver",
|
|
162
|
+
"gray",
|
|
163
|
+
"grey",
|
|
164
|
+
"indigo",
|
|
165
|
+
"violet",
|
|
166
|
+
"lime",
|
|
167
|
+
"olive",
|
|
168
|
+
"aqua",
|
|
169
|
+
"fuchsia",
|
|
170
|
+
"crimson",
|
|
171
|
+
"turquoise",
|
|
172
|
+
"ivory",
|
|
173
|
+
"beige",
|
|
174
|
+
"lavender",
|
|
175
|
+
"tan",
|
|
176
|
+
"khaki",
|
|
177
|
+
"plum",
|
|
178
|
+
"orchid",
|
|
179
|
+
"sienna",
|
|
180
|
+
].includes(normalized);
|
|
181
|
+
}
|
|
182
|
+
|
|
124
183
|
function toKebab(value: string): string {
|
|
125
184
|
return (
|
|
126
185
|
value
|
|
@@ -134,6 +193,13 @@ function toKebab(value: string): string {
|
|
|
134
193
|
);
|
|
135
194
|
}
|
|
136
195
|
|
|
196
|
+
function friendlyName(cssVar: string): string {
|
|
197
|
+
return cssVar
|
|
198
|
+
.replace(/^--/, "")
|
|
199
|
+
.replace(/[-_]/g, " ")
|
|
200
|
+
.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
201
|
+
}
|
|
202
|
+
|
|
137
203
|
function normalizeValue(value: string): string {
|
|
138
204
|
return value
|
|
139
205
|
.trim()
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
|
-
import {
|
|
3
|
-
brandKitRoleTokens,
|
|
4
|
-
classifyBrandKitToken,
|
|
5
|
-
friendlyTokenName,
|
|
6
|
-
resolveBrandKitTokens,
|
|
7
|
-
} from "@agent-native/core/brand-kit/tokens";
|
|
8
2
|
import { extractCssVars } from "@agent-native/core/server/design-token-utils";
|
|
9
3
|
import { resolveAccess } from "@agent-native/core/sharing";
|
|
10
4
|
import { eq } from "drizzle-orm";
|
|
@@ -18,12 +12,52 @@ import {
|
|
|
18
12
|
resolveTweaksToCssVars,
|
|
19
13
|
} from "../shared/resolve-tweaks.js";
|
|
20
14
|
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
// Token type classification
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
function classifyVar(
|
|
20
|
+
name: string,
|
|
21
|
+
value: string,
|
|
22
|
+
): "color" | "typography" | "spacing" | "radius" | "shadow" | "other" {
|
|
23
|
+
const n = name.toLowerCase();
|
|
24
|
+
if (
|
|
25
|
+
/color|bg|background|text|border|accent|primary|secondary|surface|muted|foreground|fill|stroke/i.test(
|
|
26
|
+
n,
|
|
27
|
+
) ||
|
|
28
|
+
/^(#[0-9a-fA-F]{3,8}|rgba?\(|hsla?\(|oklch\(|color\()/.test(value.trim())
|
|
29
|
+
) {
|
|
30
|
+
return "color";
|
|
31
|
+
}
|
|
32
|
+
if (/font|size|leading|tracking|weight|heading|body|type/i.test(n)) {
|
|
33
|
+
return "typography";
|
|
34
|
+
}
|
|
35
|
+
if (/radius|rounded/i.test(n)) {
|
|
36
|
+
return "radius";
|
|
37
|
+
}
|
|
38
|
+
if (/spacing|gap|padding|margin|space/i.test(n)) {
|
|
39
|
+
return "spacing";
|
|
40
|
+
}
|
|
41
|
+
if (/shadow|blur|drop/i.test(n)) {
|
|
42
|
+
return "shadow";
|
|
43
|
+
}
|
|
44
|
+
return "other";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Derive a friendly display name from a CSS var name like `--primary-color`. */
|
|
48
|
+
function friendlyName(cssVar: string): string {
|
|
49
|
+
return cssVar
|
|
50
|
+
.replace(/^--/, "")
|
|
51
|
+
.replace(/[-_]/g, " ")
|
|
52
|
+
.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
53
|
+
}
|
|
54
|
+
|
|
21
55
|
// ---------------------------------------------------------------------------
|
|
22
56
|
// Token entry shape
|
|
23
57
|
// ---------------------------------------------------------------------------
|
|
24
58
|
|
|
25
59
|
export interface DesignToken {
|
|
26
|
-
/**
|
|
60
|
+
/** Human-readable display name, e.g. "Primary Color". */
|
|
27
61
|
name: string;
|
|
28
62
|
/** CSS custom property, e.g. "--primary-color". */
|
|
29
63
|
cssVar: string;
|
|
@@ -33,13 +67,6 @@ export interface DesignToken {
|
|
|
33
67
|
type: "color" | "typography" | "spacing" | "radius" | "shadow" | "other";
|
|
34
68
|
/** Opaque source chip label, e.g. "globals.css" or "Brand Kit". */
|
|
35
69
|
source: string;
|
|
36
|
-
/** Collection path from the Brand Kit, e.g. "Colors/Interactive". */
|
|
37
|
-
group?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Which layer supplied the token. Filter on this, not on `source` — that is a
|
|
40
|
-
* free-text chip label (a filename, "Brand Kit", "Tweaks", …).
|
|
41
|
-
*/
|
|
42
|
-
origin: "design" | "brand-kit";
|
|
43
70
|
/**
|
|
44
71
|
* True when the value comes from the design's own tweak selections (i.e.
|
|
45
72
|
* the user has already customised this token in the editor).
|
|
@@ -47,16 +74,6 @@ export interface DesignToken {
|
|
|
47
74
|
isTweakOverride?: boolean;
|
|
48
75
|
}
|
|
49
76
|
|
|
50
|
-
/** Layer of a token's provenance, before it is flattened into a DesignToken. */
|
|
51
|
-
interface RawToken {
|
|
52
|
-
value: string;
|
|
53
|
-
source: string;
|
|
54
|
-
origin: DesignToken["origin"];
|
|
55
|
-
/** Present only when a Brand Kit supplied the token's own name. */
|
|
56
|
-
name?: string;
|
|
57
|
-
group?: string;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
77
|
// ---------------------------------------------------------------------------
|
|
61
78
|
// Action
|
|
62
79
|
// ---------------------------------------------------------------------------
|
|
@@ -64,11 +81,9 @@ interface RawToken {
|
|
|
64
81
|
export default defineAction({
|
|
65
82
|
description:
|
|
66
83
|
"Index the design tokens for a design as a friendly { name, cssVar, " +
|
|
67
|
-
"value, type, source
|
|
84
|
+
"value, type, source } list. Parses CSS custom properties from the " +
|
|
68
85
|
"design's HTML :root block, the linked Brand Kit / design system, and " +
|
|
69
|
-
"the user's applied tweak selections.
|
|
70
|
-
"by name keep that name and collection group; the rest get a name derived " +
|
|
71
|
-
"from their CSS variable. Returns tokens grouped by type " +
|
|
86
|
+
"the user's applied tweak selections. Returns tokens grouped by type " +
|
|
72
87
|
"(color, typography, spacing, radius, shadow, other).",
|
|
73
88
|
schema: z.object({
|
|
74
89
|
designId: z.string().describe("Design project ID"),
|
|
@@ -94,21 +109,19 @@ export default defineAction({
|
|
|
94
109
|
.from(schema.designFiles)
|
|
95
110
|
.where(eq(schema.designFiles.designId, designId));
|
|
96
111
|
|
|
97
|
-
/** cssVar ->
|
|
98
|
-
const rawTokens: Map<string,
|
|
112
|
+
/** cssVar -> { value, source } */
|
|
113
|
+
const rawTokens: Map<string, { value: string; source: string }> = new Map();
|
|
99
114
|
// Persisted Brand Kit JSON can outlive its schema. Keep one malformed token
|
|
100
115
|
// from taking down the whole read action while preserving valid siblings.
|
|
101
116
|
const setRawToken = (
|
|
102
117
|
cssVar: string,
|
|
103
118
|
value: unknown,
|
|
104
119
|
source: unknown,
|
|
105
|
-
provenance: Omit<RawToken, "value" | "source">,
|
|
106
120
|
): void => {
|
|
107
121
|
if (typeof value !== "string") return;
|
|
108
122
|
rawTokens.set(cssVar, {
|
|
109
123
|
value,
|
|
110
124
|
source: typeof source === "string" && source ? source : "Unknown",
|
|
111
|
-
...provenance,
|
|
112
125
|
});
|
|
113
126
|
};
|
|
114
127
|
|
|
@@ -125,7 +138,7 @@ export default defineAction({
|
|
|
125
138
|
};
|
|
126
139
|
extractCssVars(state, file.content);
|
|
127
140
|
for (const [k, v] of Object.entries(state.cssCustomProperties)) {
|
|
128
|
-
setRawToken(k, v, file.filename
|
|
141
|
+
setRawToken(k, v, file.filename);
|
|
129
142
|
}
|
|
130
143
|
}
|
|
131
144
|
|
|
@@ -152,24 +165,38 @@ export default defineAction({
|
|
|
152
165
|
if (dsRow?.data) {
|
|
153
166
|
try {
|
|
154
167
|
const dsData = JSON.parse(dsRow.data) as Partial<DesignSystemData>;
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
168
|
+
// Flatten the Brand Kit's known token fields into CSS vars
|
|
169
|
+
const brandColors = dsData.colors ?? {};
|
|
170
|
+
const colorRoleMap: Record<string, string> = {
|
|
171
|
+
primary: "--color-primary",
|
|
172
|
+
secondary: "--color-secondary",
|
|
173
|
+
accent: "--color-accent",
|
|
174
|
+
background: "--color-background",
|
|
175
|
+
surface: "--color-surface",
|
|
176
|
+
text: "--color-text",
|
|
177
|
+
textMuted: "--color-text-muted",
|
|
178
|
+
};
|
|
179
|
+
for (const [role, cssVar] of Object.entries(colorRoleMap)) {
|
|
180
|
+
const v = (brandColors as Record<string, string>)[role];
|
|
181
|
+
if (v) setRawToken(cssVar, v, "Brand Kit");
|
|
182
|
+
}
|
|
183
|
+
// Border radius
|
|
184
|
+
if (dsData.borders?.radius) {
|
|
185
|
+
setRawToken("--radius", dsData.borders.radius, "Brand Kit");
|
|
160
186
|
}
|
|
161
|
-
//
|
|
162
|
-
|
|
163
|
-
for (const token of resolveBrandKitTokens(dsData, "Brand Kit")) {
|
|
187
|
+
// Spacing
|
|
188
|
+
if (dsData.spacing?.elementGap) {
|
|
164
189
|
setRawToken(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
190
|
+
"--spacing-element-gap",
|
|
191
|
+
dsData.spacing.elementGap,
|
|
192
|
+
"Brand Kit",
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
if (dsData.spacing?.pagePadding) {
|
|
196
|
+
setRawToken(
|
|
197
|
+
"--spacing-page-padding",
|
|
198
|
+
dsData.spacing.pagePadding,
|
|
199
|
+
"Brand Kit",
|
|
173
200
|
);
|
|
174
201
|
}
|
|
175
202
|
} catch {
|
|
@@ -223,28 +250,20 @@ export default defineAction({
|
|
|
223
250
|
...Object.keys(tweakSelections).filter(isDirectCssVarSelectionKey),
|
|
224
251
|
]);
|
|
225
252
|
for (const [cssVar, value] of Object.entries(resolvedOverrides)) {
|
|
226
|
-
|
|
227
|
-
const inherited = rawTokens.get(cssVar);
|
|
228
|
-
setRawToken(cssVar, value, tokenImportSources[cssVar] ?? "Tweaks", {
|
|
229
|
-
origin: inherited?.origin ?? "design",
|
|
230
|
-
...(inherited?.name ? { name: inherited.name } : {}),
|
|
231
|
-
...(inherited?.group ? { group: inherited.group } : {}),
|
|
232
|
-
});
|
|
253
|
+
setRawToken(cssVar, value, tokenImportSources[cssVar] ?? "Tweaks");
|
|
233
254
|
}
|
|
234
255
|
|
|
235
256
|
// ------------------------------------------------------------------
|
|
236
257
|
// 4. Build friendly token list
|
|
237
258
|
// ------------------------------------------------------------------
|
|
238
259
|
const tokens: DesignToken[] = [];
|
|
239
|
-
for (const [cssVar, { value, source
|
|
260
|
+
for (const [cssVar, { value, source }] of rawTokens) {
|
|
240
261
|
tokens.push({
|
|
241
|
-
name:
|
|
262
|
+
name: friendlyName(cssVar),
|
|
242
263
|
cssVar,
|
|
243
264
|
value,
|
|
244
|
-
type:
|
|
265
|
+
type: classifyVar(cssVar, value),
|
|
245
266
|
source,
|
|
246
|
-
origin,
|
|
247
|
-
...(group ? { group } : {}),
|
|
248
267
|
isTweakOverride: tweakCssVars.has(cssVar),
|
|
249
268
|
});
|
|
250
269
|
}
|
|
@@ -4,7 +4,6 @@ import { eq } from "drizzle-orm";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
import { getDb, schema } from "../server/db/index.js";
|
|
7
|
-
import { assertStorableDesignSystemTokens } from "../server/lib/design-system-tokens.js";
|
|
8
7
|
|
|
9
8
|
export default defineAction({
|
|
10
9
|
description:
|
|
@@ -24,11 +23,7 @@ export default defineAction({
|
|
|
24
23
|
.trim()
|
|
25
24
|
.min(1, "data cannot be empty")
|
|
26
25
|
.optional()
|
|
27
|
-
.describe(
|
|
28
|
-
"Updated JSON string of DesignSystemData. Replaces the whole object, so " +
|
|
29
|
-
"include the existing `tokens` array (the source system's named tokens) " +
|
|
30
|
-
"alongside any edit, or those names are dropped.",
|
|
31
|
-
),
|
|
26
|
+
.describe("Updated JSON string of DesignSystemData"),
|
|
32
27
|
assets: z
|
|
33
28
|
.string()
|
|
34
29
|
.optional()
|
|
@@ -41,8 +36,16 @@ export default defineAction({
|
|
|
41
36
|
),
|
|
42
37
|
}),
|
|
43
38
|
run: async ({ id, title, description, data, assets, customInstructions }) => {
|
|
39
|
+
// Validate that data/assets are valid JSON when provided
|
|
44
40
|
if (data !== undefined) {
|
|
45
|
-
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(data);
|
|
43
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
44
|
+
throw new Error();
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
throw new Error("data must be a valid JSON object string");
|
|
48
|
+
}
|
|
46
49
|
}
|
|
47
50
|
if (assets !== undefined) {
|
|
48
51
|
try {
|
|
@@ -155,12 +155,6 @@ import {
|
|
|
155
155
|
vscodeDeepLink,
|
|
156
156
|
} from "./edit-panel/code-inspect-helpers";
|
|
157
157
|
import { ComponentSection } from "./edit-panel/component-section";
|
|
158
|
-
import {
|
|
159
|
-
parseTokenReference,
|
|
160
|
-
resolveTokenNameForColor,
|
|
161
|
-
toDesignSystemColorSwatches,
|
|
162
|
-
type DesignSystemColorSwatch,
|
|
163
|
-
} from "./edit-panel/design-system-swatches";
|
|
164
158
|
import {
|
|
165
159
|
type DocumentColorSourceFile,
|
|
166
160
|
extractDocumentColorPalette,
|
|
@@ -389,9 +383,6 @@ export { deriveLockedAspectSize };
|
|
|
389
383
|
export { mergeRotationValue, normalizeRotationDegrees };
|
|
390
384
|
export { mixedElementFromSelection };
|
|
391
385
|
export { authoredStyleValue, resolveInteractionStateValue };
|
|
392
|
-
|
|
393
|
-
/** A `var()` reference names itself, so no kit lookup is needed to label it. */
|
|
394
|
-
const EMPTY_SWATCHES: DesignSystemColorSwatch[] = [];
|
|
395
386
|
export { isTextElement };
|
|
396
387
|
export { ComponentSection };
|
|
397
388
|
export { extractDocumentColorPalette, type DocumentColorSourceFile };
|
|
@@ -1476,15 +1467,12 @@ function PageProperties({
|
|
|
1476
1467
|
styles,
|
|
1477
1468
|
onStyleChange,
|
|
1478
1469
|
onStylesChange,
|
|
1479
|
-
designSystemColors,
|
|
1480
1470
|
canvasBackground,
|
|
1481
1471
|
onCanvasBackgroundChange,
|
|
1482
1472
|
}: {
|
|
1483
1473
|
styles: Record<string, string>;
|
|
1484
1474
|
onStyleChange: StyleChangeHandler;
|
|
1485
1475
|
onStylesChange?: StylesChangeHandler;
|
|
1486
|
-
/** Kit tokens offered by name in the canvas/page background pickers. */
|
|
1487
|
-
designSystemColors?: DesignSystemColorSwatch[];
|
|
1488
1476
|
canvasBackground?: string | null;
|
|
1489
1477
|
onCanvasBackgroundChange?: (value: string, meta?: StyleChangeMeta) => void;
|
|
1490
1478
|
}) {
|
|
@@ -1515,7 +1503,6 @@ function PageProperties({
|
|
|
1515
1503
|
<PanelSection title={t("editPanel.sections.canvas")}>
|
|
1516
1504
|
<ColorInput
|
|
1517
1505
|
label={t("editPanel.labels.background")}
|
|
1518
|
-
designSystemColors={designSystemColors}
|
|
1519
1506
|
value={canvasBackground ?? ""}
|
|
1520
1507
|
// meta carries phase: "preview" while dragging vs "commit" on
|
|
1521
1508
|
// release. Dropping it persists every tick and the picker jumps.
|
|
@@ -1526,7 +1513,6 @@ function PageProperties({
|
|
|
1526
1513
|
<PanelSection title={t("editPanel.sections.page")}>
|
|
1527
1514
|
<ColorInput
|
|
1528
1515
|
label={t("editPanel.labels.background")}
|
|
1529
|
-
designSystemColors={designSystemColors}
|
|
1530
1516
|
value={styles.backgroundColor || ""}
|
|
1531
1517
|
onChange={(v, meta) => onStyleChange("backgroundColor", v, meta)}
|
|
1532
1518
|
backgroundImage={styles.backgroundImage}
|
|
@@ -1738,15 +1724,8 @@ function SelectionColorsProperties({
|
|
|
1738
1724
|
className="size-4 shrink-0 rounded-[3px] border border-border/60"
|
|
1739
1725
|
style={swatchStyle(color.value)}
|
|
1740
1726
|
/>
|
|
1741
|
-
<span
|
|
1742
|
-
|
|
1743
|
-
"min-w-0 flex-1 truncate text-left tabular-nums",
|
|
1744
|
-
// Hex is conventionally upper-case; a token name is not.
|
|
1745
|
-
!parseTokenReference(color.value) && "uppercase",
|
|
1746
|
-
)}
|
|
1747
|
-
>
|
|
1748
|
-
{resolveTokenNameForColor(color.value, EMPTY_SWATCHES) ??
|
|
1749
|
-
selectionDisplayHex(color.value)}
|
|
1727
|
+
<span className="min-w-0 flex-1 truncate text-left uppercase tabular-nums">
|
|
1728
|
+
{selectionDisplayHex(color.value)}
|
|
1750
1729
|
</span>
|
|
1751
1730
|
<span className="shrink-0 tabular-nums text-muted-foreground">
|
|
1752
1731
|
{opacity}%
|
|
@@ -1941,24 +1920,6 @@ export const EditPanel = memo(function EditPanel({
|
|
|
1941
1920
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on filesContentKey (cheap length+id fingerprint) instead of `files` itself so an unstable-but-equal array identity from the parent doesn't force a full re-scan every render.
|
|
1942
1921
|
[filesContentKey],
|
|
1943
1922
|
);
|
|
1944
|
-
// The linked Brand Kit's named colour tokens, for the fill picker. Shares
|
|
1945
|
-
// react-query's cache with the Tokens panel, so opening both costs one fetch.
|
|
1946
|
-
const { data: indexedTokens } = useActionQuery<{
|
|
1947
|
-
tokens?: {
|
|
1948
|
-
name: string;
|
|
1949
|
-
cssVar: string;
|
|
1950
|
-
value: string;
|
|
1951
|
-
type: string;
|
|
1952
|
-
group?: string;
|
|
1953
|
-
source?: string;
|
|
1954
|
-
}[];
|
|
1955
|
-
}>("index-design-tokens", designId ? { designId } : undefined, {
|
|
1956
|
-
enabled: Boolean(designId),
|
|
1957
|
-
});
|
|
1958
|
-
const designSystemColors = useMemo(
|
|
1959
|
-
() => toDesignSystemColorSwatches(indexedTokens?.tokens),
|
|
1960
|
-
[indexedTokens],
|
|
1961
|
-
);
|
|
1962
1923
|
const selectionAlreadyComponent =
|
|
1963
1924
|
selectedCount === 1 &&
|
|
1964
1925
|
(selectedElementAlreadyComponent ||
|
|
@@ -2365,7 +2326,6 @@ export const EditPanel = memo(function EditPanel({
|
|
|
2365
2326
|
{!inspectorElement && !selectedScreenGeometry && (
|
|
2366
2327
|
<PageProperties
|
|
2367
2328
|
styles={pageStyles}
|
|
2368
|
-
designSystemColors={designSystemColors}
|
|
2369
2329
|
onStyleChange={onStyleChange}
|
|
2370
2330
|
onStylesChange={onStylesChange}
|
|
2371
2331
|
canvasBackground={canvasBackground}
|
|
@@ -2422,13 +2382,11 @@ export const EditPanel = memo(function EditPanel({
|
|
|
2422
2382
|
onStyleChange={onStyleChange}
|
|
2423
2383
|
onStylesChange={onStylesChange}
|
|
2424
2384
|
documentColorPalette={documentColorPalette}
|
|
2425
|
-
designSystemColors={designSystemColors}
|
|
2426
2385
|
glslShaderContext={glslShaderContext}
|
|
2427
2386
|
motionKeyframeContext={motionKeyframeFieldContext}
|
|
2428
2387
|
breakpointOverrideContext={breakpointOverrideFieldContext}
|
|
2429
2388
|
/>
|
|
2430
2389
|
<StrokeProperties
|
|
2431
|
-
designSystemColors={designSystemColors}
|
|
2432
2390
|
element={stateResolvedInspectorElement ?? inspectorElement}
|
|
2433
2391
|
onStyleChange={onStyleChange}
|
|
2434
2392
|
onStylesChange={onStylesChange}
|
|
@@ -2439,7 +2397,6 @@ export const EditPanel = memo(function EditPanel({
|
|
|
2439
2397
|
element={stateResolvedInspectorElement ?? inspectorElement}
|
|
2440
2398
|
onStyleChange={onStyleChange}
|
|
2441
2399
|
onStylesChange={onStylesChange}
|
|
2442
|
-
designSystemColors={designSystemColors}
|
|
2443
2400
|
glslShaderContext={glslShaderContext}
|
|
2444
2401
|
motionKeyframeContext={motionKeyframeFieldContext}
|
|
2445
2402
|
/>
|
|
@@ -29,8 +29,6 @@
|
|
|
29
29
|
*/
|
|
30
30
|
import { createCanvasGestureController } from "@agent-native/toolkit/canvas-interactions";
|
|
31
31
|
|
|
32
|
-
import { collectAuthoredColorStyles } from "../../../../shared/authored-color-styles";
|
|
33
|
-
|
|
34
32
|
declare var __READ_ONLY__: boolean;
|
|
35
33
|
declare var __TEXT_EDITING_ENABLED__: boolean;
|
|
36
34
|
declare var __EDITOR_CHROME_SCALE_X__: string;
|
|
@@ -1854,9 +1852,6 @@ declare var __SELECTED_LAYER_DRAG_PRIORITY__: boolean;
|
|
|
1854
1852
|
// and `right` — only the inline style tells you which side was actually
|
|
1855
1853
|
// set). Empty-string values are omitted so callers can treat key-absence as
|
|
1856
1854
|
// "not authored".
|
|
1857
|
-
// color/backgroundColor/borderColor/outlineColor are reported because
|
|
1858
|
-
// getComputedStyle resolves `var()`: without the authored declaration the
|
|
1859
|
-
// inspector cannot tell a design system token from the colour it resolves to.
|
|
1860
1855
|
var INLINE_STYLE_PROPERTIES = [
|
|
1861
1856
|
"position",
|
|
1862
1857
|
"left",
|
|
@@ -1867,12 +1862,6 @@ declare var __SELECTED_LAYER_DRAG_PRIORITY__: boolean;
|
|
|
1867
1862
|
"height",
|
|
1868
1863
|
"transform",
|
|
1869
1864
|
"whiteSpace",
|
|
1870
|
-
"color",
|
|
1871
|
-
"backgroundColor",
|
|
1872
|
-
"borderColor",
|
|
1873
|
-
"outlineColor",
|
|
1874
|
-
"boxShadow",
|
|
1875
|
-
"textShadow",
|
|
1876
1865
|
];
|
|
1877
1866
|
|
|
1878
1867
|
function collectInlineStyles(el: Element): Record<string, string> {
|
|
@@ -2132,7 +2121,6 @@ declare var __SELECTED_LAYER_DRAG_PRIORITY__: boolean;
|
|
|
2132
2121
|
whiteSpace: cs.whiteSpace,
|
|
2133
2122
|
},
|
|
2134
2123
|
inlineStyles: collectInlineStyles(el),
|
|
2135
|
-
authoredColorStyles: collectAuthoredColorStyles(el),
|
|
2136
2124
|
primitiveKind: el.getAttribute("data-an-primitive") || undefined,
|
|
2137
2125
|
portableStyleSnapshot: collectPortableStyleSnapshot(el),
|
|
2138
2126
|
boundingRect: {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { parseCssColor, rgbaToHex } from "@shared/color-utils";
|
|
2
2
|
|
|
3
3
|
import type { ElementInfo } from "../types";
|
|
4
|
-
import { authoredColorValue } from "./interaction-state-helpers";
|
|
5
4
|
|
|
6
5
|
export interface DocumentColorSourceFile {
|
|
7
6
|
id: string;
|
|
@@ -64,16 +63,13 @@ export interface SelectionColorValue {
|
|
|
64
63
|
export function selectionColorValues(
|
|
65
64
|
element: ElementInfo,
|
|
66
65
|
): SelectionColorValue[] {
|
|
67
|
-
|
|
66
|
+
const styles = element.computedStyles;
|
|
68
67
|
const rawValues: SelectionColorValue[] = [
|
|
69
|
-
"color",
|
|
70
|
-
"backgroundColor",
|
|
71
|
-
"borderColor",
|
|
72
|
-
"outlineColor",
|
|
73
|
-
]
|
|
74
|
-
property,
|
|
75
|
-
value: authoredColorValue(element, property) as string,
|
|
76
|
-
}));
|
|
68
|
+
{ property: "color", value: styles.color },
|
|
69
|
+
{ property: "backgroundColor", value: styles.backgroundColor },
|
|
70
|
+
{ property: "borderColor", value: styles.borderColor },
|
|
71
|
+
{ property: "outlineColor", value: styles.outlineColor },
|
|
72
|
+
];
|
|
77
73
|
const seen = new Set<string>();
|
|
78
74
|
return rawValues
|
|
79
75
|
.map((color) => ({ ...color, value: color.value?.trim() }))
|