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.
Files changed (201) hide show
  1. package/README.md +174 -41
  2. package/UPGRADE.md +198 -0
  3. package/config/config.template.js +1 -4
  4. package/config/config.template.ts +1 -2
  5. package/dist/app-builder/build.js +11 -6
  6. package/dist/app-builder/client-config.js +1 -0
  7. package/dist/app-builder/config-diff/strategies/pattern.js +3 -3
  8. package/dist/app-builder/watchers/component.js +5 -5
  9. package/dist/app-builder/watchers/utils.d.ts +2 -3
  10. package/dist/app-builder/watchers.d.ts +8 -15
  11. package/dist/app-builder/watchers.js +53 -54
  12. package/dist/cache/build-cache.js +18 -22
  13. package/dist/catalog/define.d.ts +6 -0
  14. package/dist/catalog/define.js +72 -0
  15. package/dist/catalog/implementation.d.ts +27 -0
  16. package/dist/catalog/implementation.js +133 -0
  17. package/dist/catalog/index.d.ts +6 -0
  18. package/dist/catalog/index.js +22 -0
  19. package/dist/catalog/normalize.d.ts +16 -0
  20. package/dist/catalog/normalize.js +115 -0
  21. package/dist/catalog/previews.d.ts +18 -0
  22. package/dist/catalog/previews.js +106 -0
  23. package/dist/catalog/renderers.d.ts +43 -0
  24. package/dist/catalog/renderers.js +62 -0
  25. package/dist/catalog/types.d.ts +63 -0
  26. package/dist/cli/make.d.ts +0 -5
  27. package/dist/cli/make.js +22 -67
  28. package/dist/cli/scaffold.js +25 -33
  29. package/dist/commands/checkout/index.d.ts +7 -4
  30. package/dist/commands/checkout/index.js +9 -6
  31. package/dist/commands/compat/push-args.d.ts +2 -2
  32. package/dist/commands/index.js +0 -2
  33. package/dist/commands/publish/index.d.ts +9 -6
  34. package/dist/commands/publish/index.js +11 -8
  35. package/dist/commands/pull/index.js +1 -1
  36. package/dist/commands/push/index.js +1 -1
  37. package/dist/commands/utils.d.ts +15 -4
  38. package/dist/commands/utils.js +19 -6
  39. package/dist/config/catalog-include.d.ts +43 -0
  40. package/dist/config/catalog-include.js +203 -0
  41. package/dist/config/defaults.d.ts +2 -0
  42. package/dist/config/defaults.js +4 -1
  43. package/dist/config/index.d.ts +3 -3
  44. package/dist/config/index.js +6 -5
  45. package/dist/config/loader.js +9 -1
  46. package/dist/config/runtime.d.ts +5 -6
  47. package/dist/config/runtime.js +154 -154
  48. package/dist/handlebars.d.ts +9 -0
  49. package/dist/handlebars.js +16 -0
  50. package/dist/index.d.ts +15 -4
  51. package/dist/index.js +29 -15
  52. package/dist/pattern.d.ts +7 -0
  53. package/dist/pattern.js +13 -0
  54. package/dist/react.d.ts +43 -0
  55. package/dist/react.js +11 -0
  56. package/dist/registry/asset-storage/define.d.ts +1 -1
  57. package/dist/registry/asset-storage/define.js +1 -1
  58. package/dist/registry/checkout/index.d.ts +9 -0
  59. package/dist/registry/checkout/index.js +335 -149
  60. package/dist/registry/db/schema.d.ts +34 -0
  61. package/dist/registry/db/schema.js +2 -0
  62. package/dist/registry/publish/index.d.ts +13 -2
  63. package/dist/registry/publish/index.js +109 -25
  64. package/dist/registry/publish/package.js +14 -1
  65. package/dist/registry/selection.d.ts +20 -0
  66. package/dist/registry/selection.js +37 -1
  67. package/dist/store/filesystem.d.ts +1 -1
  68. package/dist/store/filesystem.js +7 -7
  69. package/dist/store/registry.js +24 -3
  70. package/dist/transformers/plugins/csf-render.js +4 -2
  71. package/dist/transformers/plugins/ssr-render.js +14 -5
  72. package/dist/transformers/preview/component/api.d.ts +8 -0
  73. package/dist/transformers/preview/component/api.js +11 -15
  74. package/dist/transformers/preview/component/artifacts.d.ts +1 -1
  75. package/dist/transformers/preview/component/artifacts.js +11 -7
  76. package/dist/transformers/preview/component/builder.js +15 -18
  77. package/dist/transformers/preview/component/css.d.ts +2 -0
  78. package/dist/transformers/preview/component/css.js +8 -11
  79. package/dist/transformers/preview/component/html.js +18 -16
  80. package/dist/transformers/preview/component/javascript.js +2 -4
  81. package/dist/transformers/preview/pattern/builder.js +31 -18
  82. package/dist/transformers/preview/types.d.ts +15 -1
  83. package/dist/types/config.d.ts +36 -11
  84. package/docs/api.md +3 -0
  85. package/docs/cli.md +1 -1
  86. package/drizzle/0006_add_component_source_format.sql +3 -0
  87. package/drizzle/meta/0006_snapshot.json +1941 -0
  88. package/drizzle/meta/_journal.json +8 -1
  89. package/package.json +37 -2
  90. package/src/app/components/Component/Preview.tsx +36 -50
  91. package/src/app/components/CopyToClipboard.tsx +27 -26
  92. package/src/app/components/Layout/Header.tsx +4 -12
  93. package/src/app/components/Layout/RuntimeModeBadge.tsx +18 -0
  94. package/src/app/components/Markdown/CodeHighlight.tsx +73 -70
  95. package/src/app/components/McpIntegration/McpConfigDialog.tsx +349 -0
  96. package/src/app/components/McpIntegration/McpIcon.tsx +10 -0
  97. package/src/app/components/Navigation/MobileNav.tsx +3 -1
  98. package/src/app/components/context/PreviewContext.tsx +5 -5
  99. package/src/app/components/ui/dialog.tsx +73 -0
  100. package/src/app/components/util/index.ts +7 -15
  101. package/src/app/lib/docs-api/backend.ts +5 -1
  102. package/src/app/lib/docs-api/page-discovery.ts +1 -6
  103. package/src/app/lib/docs-api/page-rendering.ts +21 -1
  104. package/src/app/lib/docs-api/records.ts +25 -10
  105. package/src/app/lib/docs-api/registry.ts +4 -2
  106. package/src/app/lib/docs-api/runtime-config.ts +5 -0
  107. package/src/app/lib/docs-api/search.ts +7 -2
  108. package/src/app/lib/mcp/auth.ts +64 -0
  109. package/src/app/lib/mcp/index.ts +2 -0
  110. package/src/app/lib/mcp/server.ts +343 -0
  111. package/src/app/lib/mcp/shape.ts +596 -0
  112. package/src/app/lib/registry-api/transfer.ts +7 -5
  113. package/src/app/next.config.mjs +3 -0
  114. package/src/app/pages/[...slug]/index.tsx +16 -30
  115. package/src/app/pages/api/mcp.ts +56 -0
  116. package/src/app/pages/index.tsx +10 -9
  117. package/src/app-builder/build.ts +12 -8
  118. package/src/app-builder/client-config.ts +2 -1
  119. package/src/app-builder/config-diff/strategies/pattern.ts +1 -1
  120. package/src/app-builder/watchers/component.ts +3 -3
  121. package/src/app-builder/watchers/utils.ts +2 -3
  122. package/src/app-builder/watchers.ts +46 -50
  123. package/src/cache/build-cache.ts +11 -14
  124. package/src/catalog/README.md +92 -0
  125. package/src/catalog/define.ts +79 -0
  126. package/src/catalog/implementation.ts +145 -0
  127. package/src/catalog/index.ts +31 -0
  128. package/src/catalog/normalize.ts +143 -0
  129. package/src/catalog/previews.ts +111 -0
  130. package/src/catalog/renderers.ts +94 -0
  131. package/src/catalog/types.ts +74 -0
  132. package/src/cli/README.md +1 -1
  133. package/src/cli/make.ts +20 -72
  134. package/src/cli/scaffold.ts +25 -31
  135. package/src/commands/README.md +1 -1
  136. package/src/commands/checkout/index.ts +17 -7
  137. package/src/commands/compat/push-args.ts +2 -2
  138. package/src/commands/index.ts +0 -2
  139. package/src/commands/publish/index.ts +19 -9
  140. package/src/commands/pull/index.ts +2 -2
  141. package/src/commands/push/index.ts +2 -2
  142. package/src/commands/utils.ts +22 -7
  143. package/src/config/README.md +2 -1
  144. package/src/config/catalog-include.ts +227 -0
  145. package/src/config/defaults.ts +3 -0
  146. package/src/config/index.ts +4 -4
  147. package/src/config/loader.ts +12 -0
  148. package/src/config/runtime.ts +186 -191
  149. package/src/handlebars.ts +18 -0
  150. package/src/index.ts +39 -26
  151. package/src/pattern.ts +14 -0
  152. package/src/react.ts +52 -0
  153. package/src/registry/asset-storage/define.ts +1 -1
  154. package/src/registry/checkout/index.ts +416 -152
  155. package/src/registry/db/schema.ts +2 -0
  156. package/src/registry/publish/index.ts +123 -26
  157. package/src/registry/publish/package.ts +14 -1
  158. package/src/registry/selection.ts +44 -0
  159. package/src/store/filesystem.ts +4 -4
  160. package/src/store/registry.ts +13 -2
  161. package/src/transformers/plugins/csf-render.ts +4 -2
  162. package/src/transformers/plugins/ssr-render.ts +15 -5
  163. package/src/transformers/preview/component/api.ts +13 -1
  164. package/src/transformers/preview/component/artifacts.ts +8 -4
  165. package/src/transformers/preview/component/builder.ts +17 -4
  166. package/src/transformers/preview/component/css.ts +6 -10
  167. package/src/transformers/preview/component/html.ts +30 -19
  168. package/src/transformers/preview/component/javascript.ts +1 -3
  169. package/src/transformers/preview/pattern/builder.ts +33 -20
  170. package/src/transformers/preview/types.ts +15 -1
  171. package/src/types/config.ts +38 -11
  172. package/templates/default/README.md.tpl +10 -0
  173. package/templates/default/components/button/button.react.handoff.js.tpl +19 -23
  174. package/templates/default/components/button/button.react.handoff.ts.tpl +22 -22
  175. package/templates/default/handoff.config.js.tpl +11 -18
  176. package/templates/default/handoff.config.ts.tpl +11 -18
  177. package/templates/default/handoff.config.with-examples.js.tpl +12 -16
  178. package/templates/default/handoff.config.with-examples.ts.tpl +12 -16
  179. package/config/templates/component/template.json +0 -49
  180. package/config/templates/template.html +0 -7
  181. package/dist/commands/make/template.d.ts +0 -8
  182. package/dist/commands/make/template.js +0 -43
  183. package/dist/config/entries.d.ts +0 -47
  184. package/dist/config/entries.js +0 -162
  185. package/dist/config/normalizers/declaration.d.ts +0 -11
  186. package/dist/config/normalizers/declaration.js +0 -122
  187. package/dist/config/normalizers/pattern.d.ts +0 -8
  188. package/dist/config/normalizers/pattern.js +0 -41
  189. package/dist/declarations/helpers.d.ts +0 -6
  190. package/dist/declarations/helpers.js +0 -19
  191. package/dist/declarations/index.d.ts +0 -2
  192. package/dist/declarations/index.js +0 -9
  193. package/dist/declarations/types.d.ts +0 -60
  194. package/src/commands/make/template.ts +0 -46
  195. package/src/config/entries.ts +0 -175
  196. package/src/config/normalizers/declaration.ts +0 -179
  197. package/src/config/normalizers/pattern.ts +0 -59
  198. package/src/declarations/helpers.ts +0 -36
  199. package/src/declarations/index.ts +0 -19
  200. package/src/declarations/types.ts +0 -70
  201. /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.defineReactComponent = exports.definePattern = exports.defineHandlebarsComponent = exports.defineCsfComponent = exports.defineComponent = exports.defineConfig = void 0;
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>;
@@ -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;
@@ -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 `defineComponent`): a consumer
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 `defineComponent`): a consumer
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>;