handoff-app 2.0.0-5 → 2.0.0-7
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 +174 -41
- package/UPGRADE.md +198 -0
- package/config/config.template.js +1 -4
- package/config/config.template.ts +1 -2
- package/dist/app-builder/build.js +11 -6
- package/dist/app-builder/client-config.js +1 -0
- package/dist/app-builder/config-diff/strategies/pattern.js +3 -3
- package/dist/app-builder/watchers/component.js +5 -5
- package/dist/app-builder/watchers/utils.d.ts +2 -3
- package/dist/app-builder/watchers.d.ts +8 -15
- package/dist/app-builder/watchers.js +53 -54
- package/dist/cache/build-cache.js +18 -22
- package/dist/catalog/define.d.ts +6 -0
- package/dist/catalog/define.js +72 -0
- package/dist/catalog/implementation.d.ts +27 -0
- package/dist/catalog/implementation.js +133 -0
- package/dist/catalog/index.d.ts +6 -0
- package/dist/catalog/index.js +22 -0
- package/dist/catalog/normalize.d.ts +16 -0
- package/dist/catalog/normalize.js +115 -0
- package/dist/catalog/previews.d.ts +18 -0
- package/dist/catalog/previews.js +106 -0
- package/dist/catalog/renderers.d.ts +43 -0
- package/dist/catalog/renderers.js +62 -0
- package/dist/catalog/types.d.ts +63 -0
- package/dist/cli/make.d.ts +0 -5
- package/dist/cli/make.js +22 -67
- package/dist/cli/scaffold.js +25 -33
- package/dist/commands/checkout/index.d.ts +7 -4
- package/dist/commands/checkout/index.js +9 -6
- package/dist/commands/compat/push-args.d.ts +2 -2
- package/dist/commands/index.js +0 -2
- package/dist/commands/publish/index.d.ts +9 -6
- package/dist/commands/publish/index.js +11 -8
- package/dist/commands/pull/index.js +1 -1
- package/dist/commands/push/index.js +1 -1
- package/dist/commands/utils.d.ts +15 -4
- package/dist/commands/utils.js +19 -6
- package/dist/config/catalog-include.d.ts +43 -0
- package/dist/config/catalog-include.js +203 -0
- package/dist/config/defaults.d.ts +2 -0
- package/dist/config/defaults.js +4 -1
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +6 -5
- package/dist/config/loader.js +9 -1
- package/dist/config/runtime.d.ts +5 -6
- package/dist/config/runtime.js +154 -154
- package/dist/handlebars.d.ts +9 -0
- package/dist/handlebars.js +16 -0
- package/dist/index.d.ts +15 -4
- package/dist/index.js +29 -15
- package/dist/pattern.d.ts +7 -0
- package/dist/pattern.js +13 -0
- package/dist/react.d.ts +43 -0
- package/dist/react.js +11 -0
- package/dist/registry/asset-storage/define.d.ts +1 -1
- package/dist/registry/asset-storage/define.js +1 -1
- package/dist/registry/checkout/index.d.ts +9 -0
- package/dist/registry/checkout/index.js +335 -149
- package/dist/registry/db/schema.d.ts +34 -0
- package/dist/registry/db/schema.js +2 -0
- package/dist/registry/publish/index.d.ts +13 -2
- package/dist/registry/publish/index.js +109 -25
- package/dist/registry/publish/package.js +14 -1
- package/dist/registry/selection.d.ts +20 -0
- package/dist/registry/selection.js +37 -1
- package/dist/store/filesystem.d.ts +1 -1
- package/dist/store/filesystem.js +7 -7
- package/dist/store/registry.js +24 -3
- package/dist/transformers/plugins/csf-render.js +4 -2
- package/dist/transformers/plugins/ssr-render.js +14 -5
- package/dist/transformers/preview/component/api.d.ts +8 -0
- package/dist/transformers/preview/component/api.js +11 -15
- package/dist/transformers/preview/component/artifacts.d.ts +1 -1
- package/dist/transformers/preview/component/artifacts.js +11 -7
- package/dist/transformers/preview/component/builder.js +15 -18
- package/dist/transformers/preview/component/css.d.ts +2 -0
- package/dist/transformers/preview/component/css.js +8 -11
- package/dist/transformers/preview/component/html.js +18 -16
- package/dist/transformers/preview/component/javascript.js +2 -4
- package/dist/transformers/preview/pattern/builder.js +31 -18
- package/dist/transformers/preview/types.d.ts +15 -1
- package/dist/types/config.d.ts +36 -11
- package/docs/api.md +3 -0
- package/docs/cli.md +1 -1
- package/drizzle/0006_add_component_source_format.sql +3 -0
- package/drizzle/meta/0006_snapshot.json +1941 -0
- package/drizzle/meta/_journal.json +8 -1
- package/package.json +37 -2
- package/src/app/components/Component/Preview.tsx +36 -50
- package/src/app/components/CopyToClipboard.tsx +27 -26
- package/src/app/components/Layout/Header.tsx +4 -12
- package/src/app/components/Layout/RuntimeModeBadge.tsx +18 -0
- package/src/app/components/Markdown/CodeHighlight.tsx +73 -70
- package/src/app/components/McpIntegration/McpConfigDialog.tsx +349 -0
- package/src/app/components/McpIntegration/McpIcon.tsx +10 -0
- package/src/app/components/Navigation/MobileNav.tsx +3 -1
- package/src/app/components/context/PreviewContext.tsx +5 -5
- package/src/app/components/ui/dialog.tsx +73 -0
- package/src/app/components/util/index.ts +7 -15
- package/src/app/lib/docs-api/backend.ts +5 -1
- package/src/app/lib/docs-api/page-discovery.ts +1 -6
- package/src/app/lib/docs-api/page-rendering.ts +21 -1
- package/src/app/lib/docs-api/records.ts +25 -10
- package/src/app/lib/docs-api/registry.ts +4 -2
- package/src/app/lib/docs-api/runtime-config.ts +5 -0
- package/src/app/lib/docs-api/search.ts +7 -2
- package/src/app/lib/mcp/auth.ts +64 -0
- package/src/app/lib/mcp/index.ts +2 -0
- package/src/app/lib/mcp/server.ts +343 -0
- package/src/app/lib/mcp/shape.ts +596 -0
- package/src/app/lib/registry-api/transfer.ts +7 -5
- package/src/app/next.config.mjs +3 -0
- package/src/app/pages/[...slug]/index.tsx +16 -30
- package/src/app/pages/api/mcp.ts +56 -0
- package/src/app/pages/index.tsx +10 -9
- package/src/app-builder/build.ts +12 -8
- package/src/app-builder/client-config.ts +2 -1
- package/src/app-builder/config-diff/strategies/pattern.ts +1 -1
- package/src/app-builder/watchers/component.ts +3 -3
- package/src/app-builder/watchers/utils.ts +2 -3
- package/src/app-builder/watchers.ts +46 -50
- package/src/cache/build-cache.ts +11 -14
- package/src/catalog/README.md +92 -0
- package/src/catalog/define.ts +79 -0
- package/src/catalog/implementation.ts +145 -0
- package/src/catalog/index.ts +31 -0
- package/src/catalog/normalize.ts +143 -0
- package/src/catalog/previews.ts +111 -0
- package/src/catalog/renderers.ts +94 -0
- package/src/catalog/types.ts +74 -0
- package/src/cli/README.md +1 -1
- package/src/cli/make.ts +20 -72
- package/src/cli/scaffold.ts +25 -31
- package/src/commands/README.md +1 -1
- package/src/commands/checkout/index.ts +17 -7
- package/src/commands/compat/push-args.ts +2 -2
- package/src/commands/index.ts +0 -2
- package/src/commands/publish/index.ts +19 -9
- package/src/commands/pull/index.ts +2 -2
- package/src/commands/push/index.ts +2 -2
- package/src/commands/utils.ts +22 -7
- package/src/config/README.md +2 -1
- package/src/config/catalog-include.ts +227 -0
- package/src/config/defaults.ts +3 -0
- package/src/config/index.ts +4 -4
- package/src/config/loader.ts +12 -0
- package/src/config/runtime.ts +186 -191
- package/src/handlebars.ts +18 -0
- package/src/index.ts +39 -26
- package/src/pattern.ts +14 -0
- package/src/react.ts +52 -0
- package/src/registry/asset-storage/define.ts +1 -1
- package/src/registry/checkout/index.ts +416 -152
- package/src/registry/db/schema.ts +2 -0
- package/src/registry/publish/index.ts +123 -26
- package/src/registry/publish/package.ts +14 -1
- package/src/registry/selection.ts +44 -0
- package/src/store/filesystem.ts +4 -4
- package/src/store/registry.ts +13 -2
- package/src/transformers/plugins/csf-render.ts +4 -2
- package/src/transformers/plugins/ssr-render.ts +15 -5
- package/src/transformers/preview/component/api.ts +13 -1
- package/src/transformers/preview/component/artifacts.ts +8 -4
- package/src/transformers/preview/component/builder.ts +17 -4
- package/src/transformers/preview/component/css.ts +6 -10
- package/src/transformers/preview/component/html.ts +30 -19
- package/src/transformers/preview/component/javascript.ts +1 -3
- package/src/transformers/preview/pattern/builder.ts +33 -20
- package/src/transformers/preview/types.ts +15 -1
- package/src/types/config.ts +38 -11
- package/templates/default/README.md.tpl +10 -0
- package/templates/default/components/button/button.react.handoff.js.tpl +19 -23
- package/templates/default/components/button/button.react.handoff.ts.tpl +22 -22
- package/templates/default/handoff.config.js.tpl +11 -18
- package/templates/default/handoff.config.ts.tpl +11 -18
- package/templates/default/handoff.config.with-examples.js.tpl +12 -16
- package/templates/default/handoff.config.with-examples.ts.tpl +12 -16
- package/config/templates/component/template.json +0 -49
- package/config/templates/template.html +0 -7
- package/dist/commands/make/template.d.ts +0 -8
- package/dist/commands/make/template.js +0 -43
- package/dist/config/entries.d.ts +0 -47
- package/dist/config/entries.js +0 -162
- package/dist/config/normalizers/declaration.d.ts +0 -11
- package/dist/config/normalizers/declaration.js +0 -122
- package/dist/config/normalizers/pattern.d.ts +0 -8
- package/dist/config/normalizers/pattern.js +0 -41
- package/dist/declarations/helpers.d.ts +0 -6
- package/dist/declarations/helpers.js +0 -19
- package/dist/declarations/index.d.ts +0 -2
- package/dist/declarations/index.js +0 -9
- package/dist/declarations/types.d.ts +0 -60
- package/src/commands/make/template.ts +0 -46
- package/src/config/entries.ts +0 -175
- package/src/config/normalizers/declaration.ts +0 -179
- package/src/config/normalizers/pattern.ts +0 -59
- package/src/declarations/helpers.ts +0 -36
- package/src/declarations/index.ts +0 -19
- package/src/declarations/types.ts +0 -70
- /package/dist/{declarations → catalog}/types.js +0 -0
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.CoreTypes = exports.CoreTransformerUtils = exports.CoreTransformers = exports.defineAssetStorage = exports.
|
|
38
|
+
exports.CoreTypes = exports.CoreTransformerUtils = exports.CoreTransformers = exports.defineAssetStorage = exports.defineConfig = void 0;
|
|
39
39
|
require("dotenv/config");
|
|
40
40
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
41
41
|
const handoff_core_1 = require("handoff-core");
|
|
@@ -142,7 +142,6 @@ class Handoff {
|
|
|
142
142
|
this.skipBuild = (_d = options.skipBuild) !== null && _d !== void 0 ? _d : false;
|
|
143
143
|
logger_1.Logger.init({ debug: this.debug });
|
|
144
144
|
this.init(options.config);
|
|
145
|
-
global.handoff = this;
|
|
146
145
|
}
|
|
147
146
|
init(configOverride) {
|
|
148
147
|
var _a, _b, _c;
|
|
@@ -268,6 +267,34 @@ class Handoff {
|
|
|
268
267
|
return this;
|
|
269
268
|
});
|
|
270
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* Publish the catalog items declared in this connected workspace to the configured remote registry:
|
|
272
|
+
* every one, or only the named ids. An item takes the component lane or the pattern lane depending
|
|
273
|
+
* on whether it declares an implementation or a composition, so the lane is resolved from the
|
|
274
|
+
* workspace rather than named by the caller. One build covers both lanes. The publish module is
|
|
275
|
+
* loaded lazily so the registry client and build code never enter the docs app bundle.
|
|
276
|
+
*/
|
|
277
|
+
publishCatalog(id) {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
this.preRunner();
|
|
280
|
+
const { publishCatalog } = yield Promise.resolve().then(() => __importStar(require('./registry/publish')));
|
|
281
|
+
yield publishCatalog(this, toSelection(id));
|
|
282
|
+
return this;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Checkout published catalog items from the connected remote registry into this workspace: every
|
|
287
|
+
* one, or only the named ids. The lane an item was published into is looked up in the registry.
|
|
288
|
+
* Mirrors {@link publishCatalog}.
|
|
289
|
+
*/
|
|
290
|
+
checkoutCatalog(id) {
|
|
291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
this.preRunner();
|
|
293
|
+
const { checkoutCatalog } = yield Promise.resolve().then(() => __importStar(require('./registry/checkout')));
|
|
294
|
+
yield checkoutCatalog(this, toSelection(id));
|
|
295
|
+
return this;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
271
298
|
/**
|
|
272
299
|
* Publish design token sets from this connected workspace to the configured remote registry. Runs a
|
|
273
300
|
* fresh token build (Figma extract + style transformers), discovers the logical sets, and uploads
|
|
@@ -392,13 +419,6 @@ class Handoff {
|
|
|
392
419
|
return this;
|
|
393
420
|
});
|
|
394
421
|
}
|
|
395
|
-
makeTemplate(component, state) {
|
|
396
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
397
|
-
this.preRunner();
|
|
398
|
-
yield (0, make_1.makeTemplate)(this, component, state);
|
|
399
|
-
return this;
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
422
|
makePage(name, parent) {
|
|
403
423
|
return __awaiter(this, void 0, void 0, function* () {
|
|
404
424
|
this.preRunner();
|
|
@@ -586,12 +606,6 @@ class Handoff {
|
|
|
586
606
|
}
|
|
587
607
|
var config_2 = require("./config");
|
|
588
608
|
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_2.defineConfig; } });
|
|
589
|
-
var declarations_1 = require("./declarations");
|
|
590
|
-
Object.defineProperty(exports, "defineComponent", { enumerable: true, get: function () { return declarations_1.defineComponent; } });
|
|
591
|
-
Object.defineProperty(exports, "defineCsfComponent", { enumerable: true, get: function () { return declarations_1.defineCsfComponent; } });
|
|
592
|
-
Object.defineProperty(exports, "defineHandlebarsComponent", { enumerable: true, get: function () { return declarations_1.defineHandlebarsComponent; } });
|
|
593
|
-
Object.defineProperty(exports, "definePattern", { enumerable: true, get: function () { return declarations_1.definePattern; } });
|
|
594
|
-
Object.defineProperty(exports, "defineReactComponent", { enumerable: true, get: function () { return declarations_1.defineReactComponent; } });
|
|
595
609
|
var define_1 = require("./registry/asset-storage/define");
|
|
596
610
|
Object.defineProperty(exports, "defineAssetStorage", { enumerable: true, get: function () { return define_1.defineAssetStorage; } });
|
|
597
611
|
// Export transformers and types from handoff-core
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CatalogItem, CatalogItemMeta, CompositionRef } from './catalog/types';
|
|
2
|
+
export type { CatalogItem, CatalogItemMeta, CompositionRef } from './catalog/types';
|
|
3
|
+
/** Declares a catalog item built from a `composition` of other items, referenced by id. */
|
|
4
|
+
export declare const defineCatalogItem: (input: CatalogItemMeta & {
|
|
5
|
+
composition: CompositionRef[];
|
|
6
|
+
implementation?: never;
|
|
7
|
+
}) => CatalogItem<never>;
|
package/dist/pattern.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineCatalogItem = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Composition catalog items.
|
|
6
|
+
*
|
|
7
|
+
* A composition renders by referencing other items, so it declares no implementation and owns no
|
|
8
|
+
* previews — `CatalogPreview` and `Preview` are deliberately not re-exported here.
|
|
9
|
+
*/
|
|
10
|
+
const define_1 = require("./catalog/define");
|
|
11
|
+
/** Declares a catalog item built from a `composition` of other items, referenced by id. */
|
|
12
|
+
const defineCatalogItem = (input) => (0, define_1.createCatalogItem)(input);
|
|
13
|
+
exports.defineCatalogItem = defineCatalogItem;
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** React catalog items, including the CSF source format. */
|
|
2
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
3
|
+
import type { CatalogItem, CatalogItemMeta, CsfSource } from './catalog/types';
|
|
4
|
+
export type { CatalogItem, CatalogItemMeta, CatalogPreview, CompositionRef, CsfSource, Preview, SourceDescriptor } from './catalog/types';
|
|
5
|
+
/** Reads the implementation from a CSF file. That file also defines the previews. */
|
|
6
|
+
export declare const fromCSF: (file: string) => CsfSource;
|
|
7
|
+
type PropsOf<TComponent> = TComponent extends ComponentType<infer TProps> ? TProps : Record<string, unknown>;
|
|
8
|
+
/** Argument metadata for one property, shaped like the Storybook equivalent. */
|
|
9
|
+
export type ArgType = {
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
control?: unknown;
|
|
13
|
+
table?: Record<string, unknown>;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
/** CSF meta type, so a story file type-checks without a Storybook dependency. */
|
|
17
|
+
export type Meta<TComponent = unknown> = {
|
|
18
|
+
title?: string;
|
|
19
|
+
component?: TComponent;
|
|
20
|
+
args?: Partial<PropsOf<TComponent>>;
|
|
21
|
+
argTypes?: Record<string, ArgType>;
|
|
22
|
+
render?: (args: PropsOf<TComponent>) => ReactNode;
|
|
23
|
+
};
|
|
24
|
+
/** CSF story type, so a story file type-checks without a Storybook dependency. */
|
|
25
|
+
export type StoryObj<TMeta = unknown> = TMeta extends {
|
|
26
|
+
component?: infer TComponent;
|
|
27
|
+
} ? {
|
|
28
|
+
name?: string;
|
|
29
|
+
args?: Partial<PropsOf<TComponent>>;
|
|
30
|
+
argTypes?: Record<string, ArgType>;
|
|
31
|
+
render?: (args: PropsOf<TComponent>) => ReactNode;
|
|
32
|
+
} : never;
|
|
33
|
+
/**
|
|
34
|
+
* `implementation` accepts an imported component, a file path, or `fromCSF(...)`. For an imported
|
|
35
|
+
* component, the file is resolved from the import in this declaration. The renderer comes from this
|
|
36
|
+
* module, so the build fails an item whose file does not match it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function defineCatalogItem<TProps = Record<string, unknown>>(input: CatalogItemMeta & {
|
|
39
|
+
implementation: ComponentType<TProps> | string;
|
|
40
|
+
}): CatalogItem<TProps>;
|
|
41
|
+
export declare function defineCatalogItem(input: CatalogItemMeta & {
|
|
42
|
+
implementation: CsfSource;
|
|
43
|
+
}): CatalogItem<never>;
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromCSF = void 0;
|
|
4
|
+
exports.defineCatalogItem = defineCatalogItem;
|
|
5
|
+
const define_1 = require("./catalog/define");
|
|
6
|
+
/** Reads the implementation from a CSF file. That file also defines the previews. */
|
|
7
|
+
const fromCSF = (file) => ({ format: 'csf', file });
|
|
8
|
+
exports.fromCSF = fromCSF;
|
|
9
|
+
function defineCatalogItem(input) {
|
|
10
|
+
return (0, define_1.createCatalogItem)(input, 'react');
|
|
11
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Typed identity helper for custom asset storage adapters (mirrors `
|
|
2
|
+
* Typed identity helper for custom asset storage adapters (mirrors `defineCatalogItem`): a consumer
|
|
3
3
|
* default-exports its result from a **server-only** module and points
|
|
4
4
|
* `runtime.registry.assetStorage.module` at it. It must be its own module (not an inline
|
|
5
5
|
* `defineConfig` function) so the build can trace it into the deployed registry. The default export
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Typed identity helper for custom asset storage adapters (mirrors `
|
|
3
|
+
* Typed identity helper for custom asset storage adapters (mirrors `defineCatalogItem`): a consumer
|
|
4
4
|
* default-exports its result from a **server-only** module and points
|
|
5
5
|
* `runtime.registry.assetStorage.module` at it. It must be its own module (not an inline
|
|
6
6
|
* `defineConfig` function) so the build can trace it into the deployed registry. The default export
|
|
@@ -43,3 +43,12 @@ export declare const checkoutEntity: (handoff: Handoff, kind: TransferEntityKind
|
|
|
43
43
|
* prompting is per entity (skipped under `--force`).
|
|
44
44
|
*/
|
|
45
45
|
export declare const checkoutEntities: (handoff: Handoff, kind: TransferEntityKind, ids?: string[]) => Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Checkout published catalog items into this workspace: every one, or only `ids` when given. An item
|
|
48
|
+
* was published as a component or as a pattern depending on its declaration, so the lane is looked up
|
|
49
|
+
* in the registry and the caller never names one.
|
|
50
|
+
*
|
|
51
|
+
* A failing lane is reported and never aborts the other. The run throws at the end if any item
|
|
52
|
+
* failed.
|
|
53
|
+
*/
|
|
54
|
+
export declare const checkoutCatalog: (handoff: Handoff, ids?: string[]) => Promise<void>;
|