handoff-app 2.0.0-7 → 2.0.0-9
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 +130 -14
- package/UPGRADE.md +20 -0
- package/dist/app-builder/build.js +10 -2
- package/dist/app-builder/client-config.js +3 -1
- package/dist/app-builder/watchers.js +17 -7
- package/dist/cache/build-cache.js +5 -1
- package/dist/catalog/normalize.js +3 -0
- package/dist/catalog/previews.js +5 -4
- package/dist/catalog/types.d.ts +8 -0
- package/dist/cli/auth/device.d.ts +6 -1
- package/dist/cli/auth/device.js +5 -2
- package/dist/cli/auth/store.d.ts +15 -6
- package/dist/cli/auth/store.js +72 -19
- package/dist/commands/login/index.d.ts +5 -0
- package/dist/commands/login/index.js +18 -6
- package/dist/commands/logout/index.d.ts +5 -0
- package/dist/commands/logout/index.js +54 -15
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands/utils.d.ts +21 -7
- package/dist/commands/utils.js +11 -10
- package/dist/config/catalog-include.d.ts +2 -2
- package/dist/config/defaults.d.ts +3 -3
- package/dist/config/defaults.js +54 -48
- package/dist/config/env.d.ts +9 -0
- package/dist/config/env.js +43 -0
- package/dist/config/errors.d.ts +4 -0
- package/dist/config/errors.js +11 -0
- package/dist/config/from-env.d.ts +24 -0
- package/dist/config/from-env.js +7 -0
- package/dist/config/helpers.d.ts +2 -0
- package/dist/config/helpers.js +3 -1
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +6 -1
- package/dist/config/loader.d.ts +29 -11
- package/dist/config/loader.js +121 -46
- package/dist/config/resolve-env.d.ts +5 -0
- package/dist/config/resolve-env.js +102 -0
- package/dist/config/runtime.d.ts +3 -3
- package/dist/config/runtime.js +8 -10
- package/dist/config/validator.d.ts +2 -2
- package/dist/config/validator.js +2 -4
- package/dist/handlebars.d.ts +10 -2
- package/dist/index.d.ts +33 -4
- package/dist/index.js +60 -16
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.js +1 -1
- package/dist/registry/asset-storage/adapters/vercel-blob.js +1 -1
- package/dist/registry/asset-storage/resolve.d.ts +2 -2
- package/dist/registry/asset-storage/resolve.js +4 -1
- package/dist/registry/checkout/index.js +4 -4
- package/dist/registry/connection.d.ts +28 -24
- package/dist/registry/connection.js +53 -67
- package/dist/registry/db/driver.d.ts +4 -11
- package/dist/registry/db/driver.js +4 -16
- package/dist/registry/db/index.d.ts +1 -1
- package/dist/registry/db/index.js +1 -2
- package/dist/registry/publish/index.js +4 -4
- package/dist/store/filesystem.d.ts +2 -2
- package/dist/transformers/plugins/ssr-render.js +40 -15
- package/dist/transformers/preview/component/css.d.ts +1 -0
- package/dist/transformers/preview/component/css.js +85 -47
- package/dist/transformers/preview/pattern/html.js +3 -1
- package/dist/transformers/preview/types.d.ts +13 -0
- package/dist/transformers/utils/build.d.ts +19 -0
- package/dist/transformers/utils/build.js +83 -1
- package/dist/transformers/utils/module.js +2 -1
- package/dist/types/config.d.ts +54 -29
- package/docs/api.md +31 -0
- package/docs/cli.md +2 -2
- package/package.json +1 -1
- package/src/app/components/Component/PageSliceResolver.tsx +1 -0
- package/src/app/components/Component/Preview.tsx +380 -189
- package/src/app/components/Component/slices/ComponentDisplaySlice.tsx +4 -0
- package/src/app/pages/account/tokens.tsx +3 -1
- package/src/app-builder/build.ts +10 -2
- package/src/app-builder/client-config.ts +5 -3
- package/src/app-builder/watchers.ts +18 -8
- package/src/cache/build-cache.ts +5 -1
- package/src/catalog/README.md +3 -0
- package/src/catalog/normalize.ts +2 -0
- package/src/catalog/previews.ts +6 -3
- package/src/catalog/types.ts +8 -0
- package/src/cli/auth/device.ts +8 -3
- package/src/cli/auth/store.ts +75 -18
- package/src/commands/login/index.ts +20 -6
- package/src/commands/logout/index.ts +74 -20
- package/src/commands/types.ts +2 -0
- package/src/commands/utils.ts +14 -5
- package/src/config/README.md +61 -1
- package/src/config/catalog-include.ts +2 -2
- package/src/config/defaults.ts +24 -14
- package/src/config/env.ts +41 -0
- package/src/config/errors.ts +7 -0
- package/src/config/from-env.ts +26 -0
- package/src/config/helpers.ts +4 -2
- package/src/config/index.ts +4 -1
- package/src/config/loader.ts +158 -50
- package/src/config/resolve-env.ts +94 -0
- package/src/config/runtime.ts +12 -7
- package/src/config/validator.ts +4 -6
- package/src/handlebars.ts +8 -2
- package/src/index.d.ts +2 -2
- package/src/index.ts +85 -8
- package/src/pipeline/index.ts +1 -1
- package/src/registry/asset-storage/adapters/vercel-blob.ts +1 -1
- package/src/registry/asset-storage/resolve.ts +6 -3
- package/src/registry/checkout/index.ts +5 -5
- package/src/registry/connection.ts +72 -71
- package/src/registry/db/driver.ts +6 -17
- package/src/registry/db/index.ts +0 -1
- package/src/registry/publish/index.ts +5 -5
- package/src/store/filesystem.ts +2 -2
- package/src/transformers/plugins/ssr-render.ts +53 -16
- package/src/transformers/preview/component/css.ts +93 -50
- package/src/transformers/preview/pattern/html.ts +3 -1
- package/src/transformers/preview/types.ts +14 -0
- package/src/transformers/utils/build.ts +80 -0
- package/src/transformers/utils/module.ts +4 -2
- package/src/types/config.ts +51 -29
- package/templates/default/env.tpl +10 -0
- package/templates/default/gitignore.tpl +7 -0
- package/templates/default/handoff.config.js.tpl +21 -172
- package/templates/default/handoff.config.ts.tpl +21 -156
- package/templates/default/handoff.config.with-examples.js.tpl +20 -171
- package/templates/default/handoff.config.with-examples.ts.tpl +20 -155
package/dist/types/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { EnvValue, EnvSecret, RuntimeEnvReference } from '../config/from-env';
|
|
1
2
|
import { BuildOptions } from 'esbuild';
|
|
2
3
|
import type Handlebars from 'handlebars';
|
|
3
4
|
import { Types as HandoffTypes } from 'handoff-core';
|
|
@@ -63,8 +64,8 @@ export type RegisterHandlebarsHelpersContext = {
|
|
|
63
64
|
};
|
|
64
65
|
export interface NextAppConfig {
|
|
65
66
|
theme?: string;
|
|
66
|
-
title
|
|
67
|
-
client
|
|
67
|
+
title?: string;
|
|
68
|
+
client?: string;
|
|
68
69
|
google_tag_manager?: string | null | undefined;
|
|
69
70
|
googleTagManager?: string | null | undefined;
|
|
70
71
|
type_copy?: string;
|
|
@@ -73,15 +74,17 @@ export interface NextAppConfig {
|
|
|
73
74
|
typeSort?: string[];
|
|
74
75
|
color_sort?: string[];
|
|
75
76
|
colorSort?: string[];
|
|
76
|
-
|
|
77
|
+
/** Omit to keep the defaults; a declared block merges onto them rather than replacing them. */
|
|
78
|
+
breakpoints?: Breakpoints;
|
|
77
79
|
component_sort?: string[];
|
|
78
80
|
componentSort?: string[];
|
|
79
81
|
base_path?: string;
|
|
80
82
|
basePath?: string;
|
|
81
|
-
|
|
83
|
+
/** @default true */
|
|
84
|
+
attribution?: boolean;
|
|
82
85
|
ports?: {
|
|
83
|
-
app: number
|
|
84
|
-
websocket: number
|
|
86
|
+
app: EnvValue<number>;
|
|
87
|
+
websocket: EnvValue<number>;
|
|
85
88
|
};
|
|
86
89
|
}
|
|
87
90
|
/**
|
|
@@ -139,13 +142,8 @@ export interface HandoffRuntimeConfig {
|
|
|
139
142
|
};
|
|
140
143
|
/** Registry-mode host settings. Env-var values are stored as names, never as secrets. */
|
|
141
144
|
registry?: {
|
|
142
|
-
/**
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @deprecated Fixed registry secrets are no longer authorized. This option remains parseable
|
|
146
|
-
* only so existing configuration files do not break.
|
|
147
|
-
*/
|
|
148
|
-
apiTokenEnv?: string;
|
|
145
|
+
/** Environment reference to the database URL. @default fromEnv('DATABASE_URL') */
|
|
146
|
+
databaseUrl?: RuntimeEnvReference<string>;
|
|
149
147
|
database?: {
|
|
150
148
|
/**
|
|
151
149
|
* PostgreSQL is the supported database. `driver` selects the built-in connection driver — how
|
|
@@ -168,11 +166,11 @@ export interface HandoffRuntimeConfig {
|
|
|
168
166
|
adapter?: 'database' | 'vercel-blob' | 'custom';
|
|
169
167
|
/** For `adapter: "custom"` - server-only module path default-exporting a `defineAssetStorage` adapter. */
|
|
170
168
|
module?: string;
|
|
171
|
-
/** For `adapter: "vercel-blob"` -
|
|
172
|
-
|
|
169
|
+
/** For `adapter: "vercel-blob"` - environment reference to the Blob read/write token. @default fromEnv('BLOB_READ_WRITE_TOKEN') */
|
|
170
|
+
token?: RuntimeEnvReference<string>;
|
|
173
171
|
/** Max bytes kept inline in the database `bytea` column (larger uploads are rejected). @default 4194304 */
|
|
174
172
|
maxInlineBytes?: number;
|
|
175
|
-
/** Non-secret
|
|
173
|
+
/** Non-secret options, JSON-encoded into the bundle. Environment references are rejected. Pass variable names instead. */
|
|
176
174
|
options?: Record<string, unknown>;
|
|
177
175
|
};
|
|
178
176
|
};
|
|
@@ -181,21 +179,20 @@ export interface HandoffRuntimeConfig {
|
|
|
181
179
|
* `mode: 'workspace'` plus this block — it is not a third runtime mode.
|
|
182
180
|
*/
|
|
183
181
|
registryConnection?: {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
accessTokenEnv?: string;
|
|
182
|
+
/** @default fromEnv('HANDOFF_REGISTRY_URL', { default: '' }) */
|
|
183
|
+
url?: EnvValue<string>;
|
|
184
|
+
/** @default fromEnv('HANDOFF_REGISTRY_ACCESS_TOKEN', { default: '' }) */
|
|
185
|
+
accessToken?: EnvSecret<string>;
|
|
189
186
|
};
|
|
190
187
|
}
|
|
191
188
|
export interface Config {
|
|
192
|
-
dev_access_token?: string | null
|
|
193
|
-
devAccessToken?: string | null
|
|
194
|
-
figma_project_id?: string | null
|
|
195
|
-
figmaProjectId?: string | null
|
|
196
|
-
exportsOutputDirectory?: string
|
|
197
|
-
sitesOutputDirectory?: string
|
|
198
|
-
useVariables?: boolean
|
|
189
|
+
dev_access_token?: EnvSecret<string | null>;
|
|
190
|
+
devAccessToken?: EnvSecret<string | null>;
|
|
191
|
+
figma_project_id?: EnvValue<string | null>;
|
|
192
|
+
figmaProjectId?: EnvValue<string | null>;
|
|
193
|
+
exportsOutputDirectory?: EnvValue<string>;
|
|
194
|
+
sitesOutputDirectory?: EnvValue<string>;
|
|
195
|
+
useVariables?: EnvValue<boolean>;
|
|
199
196
|
/**
|
|
200
197
|
* Configuration for React component docs generation (handoff-docgen).
|
|
201
198
|
*/
|
|
@@ -276,6 +273,9 @@ export interface Config {
|
|
|
276
273
|
validateComponent?: (component: TransformComponentTokensResult) => Promise<Record<string, ValidationResult>>;
|
|
277
274
|
/**
|
|
278
275
|
* Optional hook to override the SSR build configuration used in the ssrRenderPlugin
|
|
276
|
+
*
|
|
277
|
+
* Stylesheet loaders are re-applied after this hook, so a `.css`/`.scss`/`.sass` import stays out
|
|
278
|
+
* of the JavaScript graph whatever the hook returns.
|
|
279
279
|
* @param config - The default esbuild configuration
|
|
280
280
|
* @returns Modified esbuild configuration
|
|
281
281
|
* @example
|
|
@@ -289,6 +289,9 @@ export interface Config {
|
|
|
289
289
|
ssrBuildConfig?: (config: BuildOptions) => BuildOptions;
|
|
290
290
|
/**
|
|
291
291
|
* Optional hook to override the client-side build configuration used in the ssrRenderPlugin
|
|
292
|
+
*
|
|
293
|
+
* Stylesheet loaders are re-applied after this hook, so a `.css`/`.scss`/`.sass` import stays out
|
|
294
|
+
* of the JavaScript graph whatever the hook returns.
|
|
292
295
|
* @param config - The default esbuild configuration
|
|
293
296
|
* @returns Modified esbuild configuration
|
|
294
297
|
* @example
|
|
@@ -387,7 +390,29 @@ export interface ClientRuntimeConfig {
|
|
|
387
390
|
*/
|
|
388
391
|
connected: boolean;
|
|
389
392
|
}
|
|
390
|
-
|
|
393
|
+
/** Values available after config loading. Deferred references retain their names. */
|
|
394
|
+
export type ResolvedConfig = Omit<Config, 'dev_access_token' | 'devAccessToken' | 'figma_project_id' | 'figmaProjectId' | 'exportsOutputDirectory' | 'sitesOutputDirectory' | 'useVariables' | 'app' | 'runtime'> & {
|
|
395
|
+
dev_access_token?: string | null;
|
|
396
|
+
devAccessToken?: string | null;
|
|
397
|
+
figma_project_id?: string | null;
|
|
398
|
+
figmaProjectId?: string | null;
|
|
399
|
+
exportsOutputDirectory?: string;
|
|
400
|
+
sitesOutputDirectory?: string;
|
|
401
|
+
useVariables?: boolean;
|
|
402
|
+
app?: Omit<NextAppConfig, 'ports'> & {
|
|
403
|
+
ports?: {
|
|
404
|
+
app: number;
|
|
405
|
+
websocket: number;
|
|
406
|
+
};
|
|
407
|
+
};
|
|
408
|
+
runtime?: Omit<HandoffRuntimeConfig, 'registryConnection'> & {
|
|
409
|
+
registryConnection?: {
|
|
410
|
+
url?: string;
|
|
411
|
+
accessToken?: string;
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
export type ClientConfig = Pick<ResolvedConfig, 'app' | 'exportsOutputDirectory' | 'sitesOutputDirectory' | 'assets_zip_links' | 'useVariables'> & {
|
|
391
416
|
runtime: ClientRuntimeConfig;
|
|
392
417
|
};
|
|
393
418
|
export interface RuntimeConfigComponentOptions {
|
package/docs/api.md
CHANGED
|
@@ -29,6 +29,37 @@ handoff.fetch();
|
|
|
29
29
|
3. Build your typescript `tsc`
|
|
30
30
|
4. Run your project `node handoff.js`
|
|
31
31
|
|
|
32
|
+
## Configuration profiles
|
|
33
|
+
|
|
34
|
+
A profile is a sidecar config file, `handoff.config.<profile>.*`, that merges
|
|
35
|
+
onto the base config. The CLI selects one with `--profile`, and the class takes
|
|
36
|
+
it as a constructor option. Handoff reads `HANDOFF_PROFILE` when neither is
|
|
37
|
+
given.
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
const handoff = new Handoff({ profile: 'registry' });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
A profile also names the saved registry login that `publish` and `checkout`
|
|
44
|
+
use, so one workspace can address several registries. `profileWithoutConfig`
|
|
45
|
+
decides what a profile may resolve to when it has no config file:
|
|
46
|
+
`'saved-login'` accepts a name a saved login uses, and `'any'` accepts any
|
|
47
|
+
valid name, which is how `login` creates a new one.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
const handoff = new Handoff({ profile: 'staging', profileWithoutConfig: 'saved-login' });
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`defineConfig` types a profile as well as a base config.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { defineConfig } from 'handoff-app';
|
|
57
|
+
|
|
58
|
+
export default defineConfig({
|
|
59
|
+
runtime: { registry: { database: { driver: 'neon' } } },
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
32
63
|
## Methods
|
|
33
64
|
|
|
34
65
|
Methods of the handoff class can be called to run actions in the
|
package/docs/cli.md
CHANGED
|
@@ -58,9 +58,9 @@ Commands:
|
|
|
58
58
|
|
|
59
59
|
db:migrate [opts] - Runs registry database migrations (Drizzle / PostgreSQL). Reads the project config and database env vars, applies the package-owned migration set, and runs independently of `build`.
|
|
60
60
|
|
|
61
|
-
login --url <registry-url> - Authorizes this workspace in the browser and stores a revocable token in `.handoff/cli-auth.json
|
|
61
|
+
login [--profile <name>] --url <registry-url> - Authorizes this workspace in the browser and stores a revocable token in `.handoff/cli-auth.json`, under the selected profile.
|
|
62
62
|
|
|
63
|
-
logout [--url <registry-url>] - Revokes the saved token when possible, then removes the local credential
|
|
63
|
+
logout [--profile <name>] [--url <registry-url>] [--all] - Revokes the saved token when possible, then removes the local credential of the selected profile, or of every profile with `--all`.
|
|
64
64
|
|
|
65
65
|
make
|
|
66
66
|
make:component <name> [opts] - Creates a new catalog item with a declaration
|
package/package.json
CHANGED
|
@@ -44,6 +44,7 @@ export const PageSliceResolver: React.FC<PageSliceResolverProps> = ({
|
|
|
44
44
|
showPreview={slice.showPreview}
|
|
45
45
|
showCodeHighlight={slice.showCodeHighlight}
|
|
46
46
|
defaultHeight={slice.defaultHeight}
|
|
47
|
+
defaultWidth={slice.defaultWidth}
|
|
47
48
|
filterBy={slice.filterBy}
|
|
48
49
|
codeHighlight={codeHighlight}
|
|
49
50
|
/>
|