@helpra/design 0.1.0 → 0.1.2
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 +71 -58
- package/design-system/helpra/tokens.json +56 -118
- package/dist/embed/types.d.ts +2 -2
- package/dist/ui/assets/browserHost-DO0VE7SS.js +1 -0
- package/dist/ui/assets/{index-DCndCScv.js → index-B0caw0Dc.js} +10 -10
- package/dist/ui/assets/session.schemas-o3W88yfn.js +352 -0
- package/dist/ui/index.html +1 -1
- package/docs/orca-integration.md +1 -1
- package/package.json +2 -1
- package/src/contracts/agent-targets.ts +1 -1
- package/src/contracts/publication-publish.schemas.ts +2 -2
- package/src/contracts/publication.schemas.ts +1 -1
- package/src/contracts/publication.types.ts +1 -1
- package/src/embed/types.ts +2 -2
- package/src/project/git.ts +2 -4
- package/src/publication/cutover.ts +1 -1
- package/src/publication/store.constants.ts +2 -2
- package/src/publication/validate-store.ts +1 -1
- package/src/service/agent/dispatch.ts +2 -2
- package/src/service/agent/payload.ts +1 -1
- package/src/ui/HomeRecents.tsx +8 -52
- package/src/ui/ProjectDialog.tsx +3 -1
- package/src/ui/ThreadDetail.tsx +10 -7
- package/src/ui/agentDelivery.ts +1 -1
- package/src/ui/browserHost.ts +1 -1
- package/src/ui/system/ScreenConstantsSection.tsx +1 -1
- package/dist/ui/assets/browserHost-CgiYo1Ht.js +0 -1
- package/dist/ui/assets/session.schemas-DqTxSFE-.js +0 -352
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@ export const dispatchDestinationSchema = /* @__PURE__ */ (() => z.strictObject({
|
|
|
29
29
|
ideId: idSchema.max(64).optional(),
|
|
30
30
|
targetRef: z.string().min(1).max(200).optional(),
|
|
31
31
|
hostTarget: z.string().min(1).max(200).optional(),
|
|
32
|
-
hostKind: z.enum(['orca', '
|
|
32
|
+
hostKind: z.enum(['orca', 'desktop']).optional(),
|
|
33
33
|
}).refine(value => Boolean(value.hostTarget) === Boolean(value.hostKind)
|
|
34
34
|
&& !(value.ideId && value.hostTarget) && (!value.targetRef || Boolean(value.ideId)),
|
|
35
35
|
'Choose one destination'))();
|
|
@@ -8,14 +8,14 @@ const digest = revisionSchema.length(71);
|
|
|
8
8
|
export const publishOperationIdSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}(?![\s\S])/);
|
|
9
9
|
export const publicationPublishInputSchema = z.strictObject({
|
|
10
10
|
operationId: publishOperationIdSchema,
|
|
11
|
-
repository: z.literal('
|
|
11
|
+
repository: z.literal('example-org/design-assets'), branch: z.literal('dev'), sourceCommit: commit,
|
|
12
12
|
expected: z.strictObject({ sourceCommit: commit, storeTreeDigest: digest }),
|
|
13
13
|
});
|
|
14
14
|
const catalog = (projectId: string) => z.strictObject({ projectId: z.literal(projectId), contentRevision: digest, sourceTreeDigest: digest });
|
|
15
15
|
export const publicationPublishReceiptSchema = z.strictObject({
|
|
16
16
|
sourceCommit: commit, observedRevision: commit, storeTreeDigest: digest, guide: guideIdentitySchema.extend({ sha256: digest }),
|
|
17
17
|
catalogs: z.strictObject({
|
|
18
|
-
business: catalog('project-
|
|
18
|
+
business: catalog('project-example-business'), works: catalog('project-example-workspace'),
|
|
19
19
|
}),
|
|
20
20
|
}).refine(value => value.sourceCommit === value.observedRevision && value.guide.version === `git:${value.sourceCommit}`, 'Receipt must describe one verified generation');
|
|
21
21
|
export const publicationPublishErrorSchema = z.enum([
|
|
@@ -3,7 +3,7 @@ import { idSchema, revisionSchema } from './common.js';
|
|
|
3
3
|
export const guideIdentitySchema = z.strictObject({ version: z.string().regex(/^(?:git:[a-f0-9]{40}|content:[a-f0-9]{64})$/), sha256: revisionSchema });
|
|
4
4
|
export const publishedCatalogSchema = z.strictObject({
|
|
5
5
|
catalogId: z.enum(['business', 'works']), projectId: idSchema,
|
|
6
|
-
source: z.strictObject({ kind: z.literal('git'), repository: z.literal('
|
|
6
|
+
source: z.strictObject({ kind: z.literal('git'), repository: z.literal('example-org/design-assets'), branch: z.literal('dev'), gitCommit: z.string().regex(/^[a-f0-9]{40}$/) }),
|
|
7
7
|
contentRevision: revisionSchema, sourceTreeDigest: revisionSchema, servedAt: z.iso.datetime(), observedRevision: z.string().regex(/^[a-f0-9]{40}$/).optional(),
|
|
8
8
|
});
|
|
9
9
|
export const publicationMetadataSchema = publishedCatalogSchema.extend({ checkedAt: z.iso.datetime(), lastAttempt: z.enum(['ok', 'pending', 'error']), freshness: z.enum(['current', 'update_pending', 'stale', 'error']), errorCode: z.string().regex(/^[a-z][a-z0-9_]{0,63}$/).optional(), guide: guideIdentitySchema, storeTreeDigest: revisionSchema });
|
|
@@ -20,6 +20,6 @@ export interface PublicationReceipt {
|
|
|
20
20
|
durable: { reviewDigest: string; localDigest: string; exportsDigest: string };
|
|
21
21
|
}
|
|
22
22
|
export interface StorePublicationReceipt {
|
|
23
|
-
schemaVersion: 1; repository: '
|
|
23
|
+
schemaVersion: 1; repository: 'example-org/design-assets'; branch: 'dev'; gitCommit: string; sourceTreeDigest: string;
|
|
24
24
|
catalogs: Record<CatalogId, PublicationReceipt>; guide: GuideIdentity;
|
|
25
25
|
}
|
package/src/embed/types.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface DesignAgentTarget {
|
|
|
8
8
|
export interface AgentCommentDispatchPayload {
|
|
9
9
|
schemaVersion: 1;
|
|
10
10
|
dispatchId: string;
|
|
11
|
-
host: 'orca' | '
|
|
11
|
+
host: 'orca' | 'desktop' | 'local-cli' | 'remote-webhook';
|
|
12
12
|
targetAgentId: string;
|
|
13
13
|
project: { projectId: string; workingCopyId: string; name: string; contentRevision: string };
|
|
14
14
|
artboard: {
|
|
@@ -30,7 +30,7 @@ export type EmbedContextMenuKind = 'empty_canvas' | 'artboard' | 'nav_page' | 'n
|
|
|
30
30
|
| 'home_item' | 'region_or_element' | 'comment_thread' | 'approval_row' | 'design_system_item' | 'text_input';
|
|
31
31
|
|
|
32
32
|
export interface HelpraDesignHostContext {
|
|
33
|
-
host: 'orca' | '
|
|
33
|
+
host: 'orca' | 'desktop';
|
|
34
34
|
authMode: 'trusted-local';
|
|
35
35
|
theme: string;
|
|
36
36
|
locale: 'ru' | 'en';
|
package/src/project/git.ts
CHANGED
|
@@ -23,11 +23,9 @@ export async function inspectGit(root: string, budget?: ProjectReadBudget): Prom
|
|
|
23
23
|
const designRoot = await realpath(root);
|
|
24
24
|
let gitRoot: string;
|
|
25
25
|
try { gitRoot = await realpath(await git(['-C', designRoot, 'rev-parse', '--show-toplevel'], Math.min(15_000, budget?.timeLeft() ?? 15_000))); }
|
|
26
|
-
catch
|
|
26
|
+
catch {
|
|
27
27
|
budget?.check();
|
|
28
|
-
|
|
29
|
-
if (typeof error === 'object' && error !== null && 'stderr' in error && typeof error.stderr === 'string' && error.stderr.includes('not a git repository')) return {};
|
|
30
|
-
throw new DesignError('service_unavailable', 'Git metadata could not be inspected');
|
|
28
|
+
return {};
|
|
31
29
|
}
|
|
32
30
|
let gitCommit: string | undefined;
|
|
33
31
|
try { gitCommit = await git(['-C', designRoot, 'rev-parse', '--verify', 'HEAD'], Math.min(15_000, budget?.timeLeft() ?? 15_000)); }
|
|
@@ -75,7 +75,7 @@ export async function validateAssembledPublication(root: string, gitCommit: stri
|
|
|
75
75
|
await provePortableSource(root, proof);
|
|
76
76
|
if (JSON.stringify(guide.identity) !== JSON.stringify(proof.guide)) invalid();
|
|
77
77
|
return {
|
|
78
|
-
schemaVersion: 1, repository: '
|
|
78
|
+
schemaVersion: 1, repository: 'example-org/design-assets', branch: 'dev', gitCommit,
|
|
79
79
|
sourceTreeDigest: proof.sourceTreeDigest, guide: guide.identity,
|
|
80
80
|
catalogs: { business: { ...proof.catalogs.business, ...business }, works: { ...proof.catalogs.works, ...works } },
|
|
81
81
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const NATIVE_CATALOGS = {
|
|
2
|
-
business: { projectId: 'project-
|
|
3
|
-
works: { projectId: 'project-
|
|
2
|
+
business: { projectId: 'project-example-business' },
|
|
3
|
+
works: { projectId: 'project-example-workspace' },
|
|
4
4
|
} as const;
|
|
5
5
|
export const CATALOG_DIRECTORY = 'design-catalog';
|
|
6
6
|
export const STORE_GUIDE_PATH = `${CATALOG_DIRECTORY}/skills/helpra-design`;
|
|
@@ -19,5 +19,5 @@ export async function validateStorePublication(root: string, gitCommit: string,
|
|
|
19
19
|
if (!source.some(file => file.path.startsWith('design-system/'))) throw new DesignError('publication_invalid', 'Shared system source is missing');
|
|
20
20
|
if (source.some(file => isForbiddenSourcePath(file.path) && !(file.path.split('/').at(-1) === '.gitkeep' && file.size === 0) && !STORE_METADATA_PATHS.some(relative => relative === file.path))) throw new DesignError('publication_invalid', 'Store contains a private portable source member');
|
|
21
21
|
await assertPublishedGitSource(root, source.map(file => file.path), gitCommit);
|
|
22
|
-
return { schemaVersion: 1, repository: '
|
|
22
|
+
return { schemaVersion: 1, repository: 'example-org/design-assets', branch: 'dev', gitCommit, sourceTreeDigest: membersDigest(source), catalogs: { business, works }, guide: guide.identity };
|
|
23
23
|
}
|
|
@@ -32,7 +32,7 @@ type Browser = { session: string; origin: string; userAgent: string; hostEnabled
|
|
|
32
32
|
type Recipient = Pick<DispatchReceipt, 'targetId' | 'targetName' | 'recipient'>;
|
|
33
33
|
|
|
34
34
|
function hostName(kind: DispatchDestination['hostKind']): string {
|
|
35
|
-
return kind === 'orca' ? 'Orca' : '
|
|
35
|
+
return kind === 'orca' ? 'Orca' : 'Desktop';
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export class AgentDispatchService {
|
|
@@ -193,7 +193,7 @@ export class AgentDispatchService {
|
|
|
193
193
|
|
|
194
194
|
if (native) {
|
|
195
195
|
try {
|
|
196
|
-
const payload = await this.payload(saved, saved.targetName === hostName('orca') ? 'orca' : '
|
|
196
|
+
const payload = await this.payload(saved, saved.targetName === hostName('orca') ? 'orca' : 'desktop');
|
|
197
197
|
const started = await this.claim(saved);
|
|
198
198
|
return started ? { dispatch, payload, attempt: saved.attempt } : { dispatch };
|
|
199
199
|
} catch {
|
|
@@ -17,7 +17,7 @@ const webUrl = z.url({ protocol: /^https?$/ });
|
|
|
17
17
|
export const dispatchPayloadSchema = z.strictObject({
|
|
18
18
|
schemaVersion: z.literal(1),
|
|
19
19
|
dispatchId: dispatchIdSchema,
|
|
20
|
-
host: z.enum(['orca', '
|
|
20
|
+
host: z.enum(['orca', 'desktop', 'local-cli', 'remote-webhook']),
|
|
21
21
|
targetAgentId: z.string().min(1).max(200),
|
|
22
22
|
project: z.strictObject({ projectId: idSchema, workingCopyId: idSchema, name: z.string(), contentRevision: z.string() }),
|
|
23
23
|
artboard: z.strictObject({
|
package/src/ui/HomeRecents.tsx
CHANGED
|
@@ -13,46 +13,15 @@ export interface ResolvedCanvasScene {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const CANONICAL_DESIGN_PROJECT_IDS = new Set([
|
|
16
|
-
"project-helpra-design-
|
|
16
|
+
"project-helpra-design-demo",
|
|
17
17
|
]);
|
|
18
18
|
const CANONICAL_DESIGN_CANVAS_IDS = new Set([
|
|
19
19
|
"canvas-helpra-design",
|
|
20
20
|
]);
|
|
21
21
|
|
|
22
|
-
const CANONICAL_WORKS_PROJECT_IDS = new Set([
|
|
23
|
-
"project-helpra-works-catalog",
|
|
24
|
-
]);
|
|
25
|
-
const CANONICAL_WORKS_CANVAS_IDS = new Set([
|
|
26
|
-
"canvas-mvp3",
|
|
27
|
-
"canvas-5b56d6f2e526cf9d40a4",
|
|
28
|
-
"canvas-0afd6f7fb298711b859b",
|
|
29
|
-
"canvas-898ae39795540025c2a9",
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
const CANONICAL_BUSINESS_PROJECT_IDS = new Set([
|
|
33
|
-
"project-efd0ea9e-eb78-4334-a3c1-9cbb01a088d9",
|
|
34
|
-
]);
|
|
35
|
-
const CANONICAL_BUSINESS_CANVAS_IDS = new Set([
|
|
36
|
-
"canvas-8ef744b86c3c358292de",
|
|
37
|
-
"canvas-analytics",
|
|
38
|
-
"canvas-01fce522bddfaf7cf9b0",
|
|
39
|
-
"canvas-af950bef681e3294c97e",
|
|
40
|
-
"canvas-3ab1f047c6132c7dbfe3",
|
|
41
|
-
"canvas-ebcf98273563c11a00f6",
|
|
42
|
-
"canvas-24f30b6dcfd82956d0a9",
|
|
43
|
-
"canvas-cd6718e5647ac2b56d1d",
|
|
44
|
-
"canvas-d5fc873188953b8270ac",
|
|
45
|
-
"canvas-19085a908e3bbe792f62",
|
|
46
|
-
"canvas-688597571b68705c6629",
|
|
47
|
-
"canvas-ab9ef602a179090fad7d",
|
|
48
|
-
"canvas-d96600cee38fb398757d",
|
|
49
|
-
"canvas-5a8cddf53197fa2ac2b2",
|
|
50
|
-
"canvas-ce7b4d38961770d7c0d1",
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
22
|
function sceneByKeywords(text: string): ResolvedCanvasScene | null {
|
|
54
23
|
const normalized = text.toLowerCase();
|
|
55
|
-
const isWorks = /(?:^|[^a-z0-9])(works|
|
|
24
|
+
const isWorks = /(?:^|[^a-z0-9])(works|workspace)(?:$|[^a-z0-9])/.test(normalized);
|
|
56
25
|
const isBusiness = /(?:^|[^a-z0-9а-яё])(business|админ[а-яё]*|admin)(?:$|[^a-z0-9а-яё])/.test(normalized);
|
|
57
26
|
const isDesign = /helpra[-_\s]+design/.test(normalized);
|
|
58
27
|
|
|
@@ -65,39 +34,26 @@ function sceneByKeywords(text: string): ResolvedCanvasScene | null {
|
|
|
65
34
|
export function resolveCanvasScene(
|
|
66
35
|
item: Pick<RecentCanvasItem, "workingCopyId" | "projectId" | "canvasId" | "projectName" | "canvasName">,
|
|
67
36
|
): ResolvedCanvasScene {
|
|
68
|
-
//
|
|
37
|
+
// The built-in design scene takes priority over keyword matching.
|
|
69
38
|
if (
|
|
70
39
|
CANONICAL_DESIGN_PROJECT_IDS.has(item.projectId) ||
|
|
71
40
|
CANONICAL_DESIGN_CANVAS_IDS.has(item.canvasId)
|
|
72
41
|
) {
|
|
73
42
|
return { scene: "design" };
|
|
74
43
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
CANONICAL_WORKS_CANVAS_IDS.has(item.canvasId)
|
|
78
|
-
) {
|
|
79
|
-
return { scene: "works", theme: "dark" };
|
|
80
|
-
}
|
|
81
|
-
if (
|
|
82
|
-
CANONICAL_BUSINESS_PROJECT_IDS.has(item.projectId) ||
|
|
83
|
-
CANONICAL_BUSINESS_CANVAS_IDS.has(item.canvasId)
|
|
84
|
-
) {
|
|
85
|
-
return { scene: "business", theme: "light" };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// 2. Stable ID slugs before mutable display names.
|
|
89
|
-
const stableIds = `${item.projectId} ${item.canvasId} ${item.workingCopyId}`;
|
|
90
|
-
const byIdSlug = sceneByKeywords(stableIds);
|
|
44
|
+
// Project and canvas IDs survive renames.
|
|
45
|
+
const byIdSlug = sceneByKeywords(`${item.projectId} ${item.canvasId}`);
|
|
91
46
|
if (byIdSlug) return byIdSlug;
|
|
92
47
|
if (/(?:^|[^a-z0-9])design(?:$|[^a-z0-9])/i.test(item.projectId)) {
|
|
93
48
|
return { scene: "design" };
|
|
94
49
|
}
|
|
95
50
|
|
|
96
|
-
|
|
51
|
+
const byWorkingCopy = sceneByKeywords(item.workingCopyId);
|
|
52
|
+
if (byWorkingCopy) return byWorkingCopy;
|
|
97
53
|
const byName = sceneByKeywords(`${item.projectName} ${item.canvasName}`);
|
|
98
54
|
if (byName) return byName;
|
|
99
55
|
|
|
100
|
-
//
|
|
56
|
+
// Assign a stable scene to projects with no recognized keywords.
|
|
101
57
|
let hash = 0;
|
|
102
58
|
const seed = `${item.projectId}:${item.canvasId}`;
|
|
103
59
|
for (let i = 0; i < seed.length; i += 1) hash = (hash * 31 + seed.charCodeAt(i)) | 0;
|
package/src/ui/ProjectDialog.tsx
CHANGED
|
@@ -44,6 +44,8 @@ export function ProjectDialog({
|
|
|
44
44
|
const [missingDs, setMissingDs] = useState<MissingDesignSystemInfo | null>(null);
|
|
45
45
|
|
|
46
46
|
const effectiveAction: ProjectAction = action === "clone" ? "clone" : mode;
|
|
47
|
+
const projectsDirectory = client.identity?.projectsDirectory ?? "~/.helpra/design/projects";
|
|
48
|
+
const pathSeparator = projectsDirectory.includes("\\") ? "\\" : "/";
|
|
47
49
|
|
|
48
50
|
useEffect(() => {
|
|
49
51
|
if (designSystems) {
|
|
@@ -168,7 +170,7 @@ export function ProjectDialog({
|
|
|
168
170
|
label={effectiveAction === "clone" ? localized("Папка назначения") : effectiveAction === "create" ? t("optionalProjectFolder") : localized("Папка проекта")}
|
|
169
171
|
autoFocus={effectiveAction === "open"} required={effectiveAction !== "create"}
|
|
170
172
|
value={path} onChange={setPath} onError={setError} disabled={busy}
|
|
171
|
-
placeholder={effectiveAction === "create" ? `${
|
|
173
|
+
placeholder={effectiveAction === "create" ? `${projectsDirectory}${pathSeparator}<slug>` : localized("Абсолютный путь к локальной папке")} />
|
|
172
174
|
{effectiveAction === "create" && client.can("design_list_design_systems") && (
|
|
173
175
|
<label>
|
|
174
176
|
{t("designSystem")}
|
package/src/ui/ThreadDetail.tsx
CHANGED
|
@@ -261,13 +261,16 @@ export function ThreadDetail({
|
|
|
261
261
|
disabled={busy}
|
|
262
262
|
compact
|
|
263
263
|
/>
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
264
|
+
<div className="comment-compose-actions">
|
|
265
|
+
{!publicSandbox && <AgentDeliveryControl delivery={delivery} />}
|
|
266
|
+
<Button
|
|
267
|
+
type="submit"
|
|
268
|
+
variant="primary"
|
|
269
|
+
disabled={busy || replyMedia.uploading || (!reply.trim() && replyMedia.attachments.length === 0)}
|
|
270
|
+
>
|
|
271
|
+
{localized("Отправить ответ")}
|
|
272
|
+
</Button>
|
|
273
|
+
</div>
|
|
271
274
|
</form>
|
|
272
275
|
)}
|
|
273
276
|
{(client.can("design_set_comment_status") || client.can("design_delete_comment")) && (
|
package/src/ui/agentDelivery.ts
CHANGED
|
@@ -24,7 +24,7 @@ export function useAgentTargets(client: DesignClient, enabled = true) {
|
|
|
24
24
|
const host = useSyncExternalStore(client.host?.subscribe ?? subscribe, client.host?.snapshot ?? snapshot);
|
|
25
25
|
const native = host?.capabilities.sendToAgent && host.activeAgent ? host.activeAgent : null;
|
|
26
26
|
const hostDestination = !publicSandbox && native && host ? {
|
|
27
|
-
ideId: 'host-bridge', ideLabel: host.host === 'orca' ? 'Orca' : '
|
|
27
|
+
ideId: 'host-bridge', ideLabel: host.host === 'orca' ? 'Orca' : 'Desktop',
|
|
28
28
|
hasOpenAgent: true as const, isSelectedForSession: true,
|
|
29
29
|
currentAgent: { targetRef: native.id, agentName: native.name },
|
|
30
30
|
} : null;
|
package/src/ui/browserHost.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { setLanguage } from './workbenchI18n.js';
|
|
|
5
5
|
|
|
6
6
|
const target = z.object({ id: z.string().min(1).max(200), name: z.string().min(1).max(120), kind: z.enum(['bot', 'session', 'worker', 'webhook']), isActiveDefault: z.boolean().optional() });
|
|
7
7
|
const contextSchema = z.object({
|
|
8
|
-
host: z.enum(['orca', '
|
|
8
|
+
host: z.enum(['orca', 'desktop']), authMode: z.literal('trusted-local'),
|
|
9
9
|
theme: z.string(), locale: z.enum(['ru', 'en']),
|
|
10
10
|
activeAgent: target.nullable(), availableAgents: z.array(target).max(64),
|
|
11
11
|
initialView: z.enum(['projects_and_ds', 'project', 'design_systems']).optional(),
|
|
@@ -41,7 +41,7 @@ function ScreenConstantSource({ onCopy }: {
|
|
|
41
41
|
<details className="screen-constant-source">
|
|
42
42
|
<summary>{localized("Как изменить константы")}</summary>
|
|
43
43
|
<p>{localized("Меняйте основные значения строками CSS. Связанные варианты обновятся при пересборке. Запускайте команды из каталога Helpra Design, подставив свои пути.")}</p>
|
|
44
|
-
<h3>{currentLanguage() === "ru" ? "Общая библиотека
|
|
44
|
+
<h3>{currentLanguage() === "ru" ? "Общая библиотека компонентов" : "Shared component library"}</h3>
|
|
45
45
|
<p>{localized("Измените") + " "}<code>shared-library/{SCREEN_CONSTANTS_PATH}</code> {localized("в каталоге набора. Синхронизация обновит и пересоберёт все три проекта.")}</p>
|
|
46
46
|
<SystemValue value={localized("%1 \"/путь/к/набору\" --apply", syncCommand)} label={localized("команду синхронизации")} onCopy={onCopy} />
|
|
47
47
|
<h3>{localized("Отдельный переносимый проект")}</h3>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{At as e,Ct as t,Dt as n,_t as r,at as i,gt as a,ht as o,xt as s}from"./index-DCndCScv.js";var c=`helpra-design-host/v1`;function l(e){if(e&&typeof e==`object`&&`protocol`in e&&e.protocol===c)return e}function u(e){if(!/^https?:\/\//.test(e)||new URL(e).origin!==e)throw Error(`Expected an exact host origin`);return e}function d(e){let t=e?.child??window,n=t.helpraDesignHost;if(typeof n?.getContext==`function`&&typeof n.onContextChanged==`function`&&typeof n.sendToAgent==`function`)return n;if(!e||t.parent===t)return;let r=u(e.parentOrigin),i=t.parent;function a(e,n){let a=crypto.randomUUID();return new Promise((o,s)=>{function u(){clearTimeout(f),t.removeEventListener(`message`,d)}function d(e){if(e.origin!==r||e.source!==i)return;let t=l(e.data);t?.type===`result`&&t.id===a&&(u(),t.ok===!0?o(t.value):s(Error(`Design host command failed`)))}let f=setTimeout(()=>{u(),s(Error(`Design host did not respond`))},1e4);t.addEventListener(`message`,d),i.postMessage({protocol:c,type:`call`,id:a,method:e,value:n},r)})}return{getContext:()=>a(`getContext`),sendToAgent:e=>a(`sendToAgent`,e),onContextChanged(e){let n=t=>{if(t.origin!==r||t.source!==i)return;let n=l(t.data);n?.type===`context`&&n.value&&typeof n.value==`object`&&e(n.value)};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)},titleChanged:e=>{a(`titleChanged`,e).catch(()=>void 0)},selectionChanged:e=>{a(`selectionChanged`,e).catch(()=>void 0)},openExternal:e=>a(`openExternal`,e),contextMenu:e=>{a(`contextMenu`,e).catch(()=>void 0)},revealInFolder:e=>a(`revealInFolder`,e),setFullscreen:e=>a(`setFullscreen`,e)}}var f=t({id:n().min(1).max(200),name:n().min(1).max(120),kind:o([`bot`,`session`,`worker`,`webhook`]),isActiveDefault:r().optional()}),p=t({host:o([`orca`,`helpra-works`]),authMode:s(`trusted-local`),theme:n(),locale:o([`ru`,`en`]),activeAgent:f.nullable(),availableAgents:a(f).max(64),initialView:o([`projects_and_ds`,`project`,`design_systems`]).optional(),initialTarget:t({workingCopyId:n().optional(),systemId:n().optional(),canvasId:n().optional(),pageId:n().optional(),artboardId:n().optional()}).optional(),capabilities:t({sendToAgent:r(),nativeContextMenu:r(),revealInFolder:r(),fullscreenToggle:r()})});function m(t){e(t.locale),(t.theme===`light`||t.theme===`dark`)&&i(t.theme)}var h;function g(e){return h??=_(e).catch(()=>void 0)}async function _(e){let t=d(e?{parentOrigin:e}:void 0);if(!t)return;let n=p.safeParse(await t.getContext());if(!n.success)return;let r=n.data,i=new Set;m(r);let a=new URL(location.href);if(!a.search){for(let[e,t]of Object.entries(r.initialTarget??{}))t&&a.searchParams.set(e,t);r.initialView===`design_systems`&&a.searchParams.set(`view`,`design-systems`),a.search&&history.replaceState(history.state,``,a)}let o=t.onContextChanged(e=>{let t=p.safeParse({...r,...e});if(!t.success)return;let n=r;r=t.data,(r.theme!==n.theme||r.locale!==n.locale)&&m(r);for(let e of i)e()}),s=!1;function c(e){e.key===`F11`&&r.capabilities.fullscreenToggle&&t?.setFullscreen&&(e.preventDefault(),s=!s,t.setFullscreen(s).catch(()=>{s=!s}))}function l(e){if(e.defaultPrevented||!(e.target instanceof Element)||!t?.openExternal)return;let n=e.target.closest(`a[href]`);if(!(n instanceof HTMLAnchorElement))return;let r=new URL(n.href);r.origin!==location.origin&&[`https:`,`http:`].includes(r.protocol)&&(e.preventDefault(),t.openExternal(r.href).catch(()=>void 0))}return window.addEventListener(`keydown`,c),window.addEventListener(`click`,l),window.addEventListener(`pagehide`,e=>{e.persisted||(o(),window.removeEventListener(`keydown`,c),window.removeEventListener(`click`,l))}),{bridge:t,snapshot:()=>r,subscribe(e){return i.add(e),()=>i.delete(e)}}}export{g as connectBrowserHost};
|