handoff-app 1.2.2-7 → 2.0.0-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/Changelog.md +37 -15
- package/README.md +372 -118
- package/dist/app-builder/build.d.ts +41 -2
- package/dist/app-builder/build.js +455 -18
- package/dist/app-builder/client-config.d.ts +15 -2
- package/dist/app-builder/client-config.js +43 -4
- package/dist/app-builder/config-diff/snapshot.d.ts +1 -6
- package/dist/app-builder/config-diff/snapshot.js +2 -9
- package/dist/app-builder/index.d.ts +1 -1
- package/dist/app-builder/index.js +3 -1
- package/dist/app-builder/nav-shell.d.ts +23 -0
- package/dist/app-builder/nav-shell.js +80 -0
- package/dist/app-builder/static-export.d.ts +17 -0
- package/dist/app-builder/static-export.js +181 -0
- package/dist/app-builder/vercel-output.d.ts +39 -0
- package/dist/app-builder/vercel-output.js +259 -0
- package/dist/app-builder/watchers/utils.d.ts +2 -0
- package/dist/app-builder/watchers.d.ts +14 -4
- package/dist/app-builder/watchers.js +123 -28
- package/dist/app-builder/websocket.js +1 -1
- package/dist/artifacts/index.d.ts +2 -0
- package/dist/artifacts/index.js +13 -0
- package/dist/artifacts/types.d.ts +136 -0
- package/dist/artifacts/types.js +24 -0
- package/dist/artifacts/url.d.ts +49 -0
- package/dist/artifacts/url.js +86 -0
- package/dist/cache/build-cache.js +48 -4
- package/dist/cli.js +0 -0
- package/dist/commands/build/app.js +1 -2
- package/dist/commands/build/index.d.ts +17 -0
- package/dist/commands/build/index.js +66 -0
- package/dist/commands/checkout/index.d.ts +24 -0
- package/dist/commands/checkout/index.js +71 -0
- package/dist/commands/db/migrate.d.ts +11 -0
- package/dist/commands/db/migrate.js +33 -0
- package/dist/commands/index.js +8 -0
- package/dist/commands/publish/index.d.ts +21 -0
- package/dist/commands/publish/index.js +68 -0
- package/dist/config/defaults.js +15 -1
- package/dist/config/loader.js +6 -1
- package/dist/config/normalizers/declaration.js +4 -1
- package/dist/config/normalizers/page.d.ts +18 -0
- package/dist/config/normalizers/page.js +34 -0
- package/dist/config/normalizers/pattern.js +7 -1
- package/dist/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +53 -5
- package/dist/index.d.ts +65 -1
- package/dist/index.js +123 -3
- package/dist/nav/index.d.ts +83 -0
- package/dist/nav/index.js +9 -0
- package/dist/nav/registry.d.ts +15 -0
- package/dist/nav/registry.js +42 -0
- package/dist/nav/resolver.d.ts +8 -0
- package/dist/nav/resolver.js +192 -0
- package/dist/nav/workspace.d.ts +18 -0
- package/dist/nav/workspace.js +103 -0
- package/dist/pipeline/styles.js +7 -35
- package/dist/pipeline/token-transformers.d.ts +45 -0
- package/dist/pipeline/token-transformers.js +71 -0
- package/dist/registry/asset-storage/adapters/vercel-blob.d.ts +17 -0
- package/dist/registry/asset-storage/adapters/vercel-blob.js +87 -0
- package/dist/registry/asset-storage/define.d.ts +10 -0
- package/dist/registry/asset-storage/define.js +13 -0
- package/dist/registry/asset-storage/resolve.d.ts +45 -0
- package/dist/registry/asset-storage/resolve.js +36 -0
- package/dist/registry/asset-storage/types.d.ts +51 -0
- package/dist/registry/asset-storage/types.js +9 -0
- package/dist/registry/assets/layout.d.ts +22 -0
- package/dist/registry/assets/layout.js +30 -0
- package/dist/registry/assets/sets.d.ts +18 -0
- package/dist/registry/assets/sets.js +44 -0
- package/dist/registry/assets/transfer.d.ts +45 -0
- package/dist/registry/assets/transfer.js +11 -0
- package/dist/registry/checkout/assets.d.ts +16 -0
- package/dist/registry/checkout/assets.js +150 -0
- package/dist/registry/checkout/index.d.ts +33 -0
- package/dist/registry/checkout/index.js +610 -0
- package/dist/registry/checkout/tokens.d.ts +15 -0
- package/dist/registry/checkout/tokens.js +171 -0
- package/dist/registry/client.d.ts +61 -0
- package/dist/registry/client.js +211 -0
- package/dist/registry/connection.d.ts +30 -0
- package/dist/registry/connection.js +36 -0
- package/dist/registry/db/adapter.d.ts +43 -0
- package/dist/registry/db/adapter.js +59 -0
- package/dist/registry/db/client.d.ts +35 -0
- package/dist/registry/db/client.js +94 -0
- package/dist/registry/db/index.d.ts +5 -0
- package/dist/registry/db/index.js +24 -0
- package/dist/registry/db/migrate.d.ts +23 -0
- package/dist/registry/db/migrate.js +64 -0
- package/dist/registry/db/schema.d.ts +4869 -0
- package/dist/registry/db/schema.js +347 -0
- package/dist/registry/path.d.ts +4 -0
- package/dist/registry/path.js +31 -0
- package/dist/registry/publish/artifacts.d.ts +16 -0
- package/dist/registry/publish/artifacts.js +132 -0
- package/dist/registry/publish/assets.d.ts +16 -0
- package/dist/registry/publish/assets.js +129 -0
- package/dist/registry/publish/errors.d.ts +5 -0
- package/dist/registry/publish/errors.js +26 -0
- package/dist/registry/publish/index.d.ts +27 -0
- package/dist/registry/publish/index.js +126 -0
- package/dist/registry/publish/package.d.ts +27 -0
- package/dist/registry/publish/package.js +257 -0
- package/dist/registry/publish/publish-build.d.ts +12 -0
- package/dist/registry/publish/publish-build.js +43 -0
- package/dist/registry/publish/tokens.d.ts +18 -0
- package/dist/registry/publish/tokens.js +112 -0
- package/dist/registry/tokens/sets.d.ts +59 -0
- package/dist/registry/tokens/sets.js +109 -0
- package/dist/registry/tokens/transfer.d.ts +48 -0
- package/dist/registry/tokens/transfer.js +10 -0
- package/dist/registry/transfer.d.ts +75 -0
- package/dist/registry/transfer.js +11 -0
- package/dist/store/filesystem-assets.d.ts +17 -0
- package/dist/store/filesystem-assets.js +147 -0
- package/dist/store/filesystem.d.ts +76 -0
- package/dist/store/filesystem.js +208 -0
- package/dist/store/index.d.ts +20 -0
- package/dist/store/index.js +38 -0
- package/dist/store/registry.d.ts +77 -0
- package/dist/store/registry.js +350 -0
- package/dist/store/source-files.d.ts +24 -0
- package/dist/store/source-files.js +147 -0
- package/dist/store/types.d.ts +185 -0
- package/dist/store/types.js +12 -0
- package/dist/transformers/plugins/csf-render.js +17 -8
- package/dist/transformers/plugins/handlebars-previews.js +10 -3
- package/dist/transformers/plugins/ssr-render.js +116 -49
- package/dist/transformers/preview/component/api.js +3 -1
- package/dist/transformers/preview/component/artifacts.js +8 -1
- package/dist/transformers/preview/component/builder.js +13 -5
- package/dist/transformers/preview/component/css.js +9 -1
- package/dist/transformers/preview/component/javascript.d.ts +9 -3
- package/dist/transformers/preview/component/javascript.js +45 -17
- package/dist/transformers/preview/component/shared-artifacts.d.ts +83 -0
- package/dist/transformers/preview/component/shared-artifacts.js +92 -0
- package/dist/transformers/preview/component.js +5 -2
- package/dist/transformers/preview/pattern/builder.js +28 -9
- package/dist/transformers/preview/pattern/html.d.ts +13 -10
- package/dist/transformers/preview/pattern/html.js +62 -27
- package/dist/transformers/preview/types.d.ts +38 -0
- package/dist/transformers/utils/handlebars.d.ts +3 -0
- package/dist/transformers/utils/handlebars.js +19 -5
- package/dist/types/config.d.ts +118 -25
- package/dist/utils/menu-shell.d.ts +60 -0
- package/dist/utils/menu-shell.js +221 -0
- package/dist/utils/stable-stringify.d.ts +2 -0
- package/dist/utils/stable-stringify.js +8 -0
- package/docs/cli.md +4 -2
- package/drizzle/0000_init_registry_storage.sql +95 -0
- package/drizzle/0001_add_review_metadata.sql +2 -0
- package/drizzle/0002_add_pages.sql +28 -0
- package/drizzle/0003_add_tokens.sql +29 -0
- package/drizzle/0004_add_assets.sql +37 -0
- package/drizzle/meta/0000_snapshot.json +642 -0
- package/drizzle/meta/0001_snapshot.json +654 -0
- package/drizzle/meta/0002_snapshot.json +835 -0
- package/drizzle/meta/0003_snapshot.json +1023 -0
- package/drizzle/meta/0004_snapshot.json +1252 -0
- package/drizzle/meta/_journal.json +41 -0
- package/drizzle.config.ts +16 -0
- package/package.json +10 -1
- package/src/app/components/Component/Preview.tsx +3 -2
- package/src/app/components/Component/RegistryActions.tsx +150 -0
- package/src/app/components/Foundations/DisplayLogo.tsx +5 -3
- package/src/app/components/Layout/Header.tsx +21 -3
- package/src/app/components/Layout/Main.tsx +11 -3
- package/src/app/components/Navigation/MainNav.tsx +4 -2
- package/src/app/components/Navigation/MobileNav.tsx +4 -2
- package/src/app/components/Navigation/SideNav.tsx +46 -11
- package/src/app/components/NotFound.tsx +24 -0
- package/src/app/components/context/NavProvider.tsx +71 -0
- package/src/app/components/old/Header.tsx +3 -3
- package/src/app/components/util/index.ts +203 -380
- package/src/app/components/util/useCollectionAssets.ts +125 -0
- package/src/app/components/util/useFoundationTokens.ts +67 -0
- package/src/app/generated/default-pages.json +1 -0
- package/src/app/generated/nav-shell.json +1 -0
- package/src/app/lib/api/query.ts +6 -0
- package/src/app/lib/api/redact.ts +46 -0
- package/src/app/lib/asset-storage.ts +81 -0
- package/src/app/lib/docs-api/artifacts.ts +116 -0
- package/src/app/lib/docs-api/backend.ts +151 -0
- package/src/app/lib/docs-api/errors.ts +52 -0
- package/src/app/lib/docs-api/handler.ts +34 -0
- package/src/app/lib/docs-api/index.ts +7 -0
- package/src/app/lib/docs-api/records.ts +189 -0
- package/src/app/lib/docs-api/registry.ts +130 -0
- package/src/app/lib/docs-api/runtime-config.ts +173 -0
- package/src/app/lib/docs-api/serve.ts +37 -0
- package/src/app/lib/docs-api/token-detail.ts +19 -0
- package/src/app/lib/registry-api/allowlist.ts +163 -0
- package/src/app/lib/registry-api/asset-transfer.ts +363 -0
- package/src/app/lib/registry-api/auth.ts +68 -0
- package/src/app/lib/registry-api/entity-routes.ts +197 -0
- package/src/app/lib/registry-api/errors.ts +51 -0
- package/src/app/lib/registry-api/files.ts +135 -0
- package/src/app/lib/registry-api/handler.ts +96 -0
- package/src/app/lib/registry-api/index.ts +4 -0
- package/src/app/lib/registry-api/meta.ts +87 -0
- package/src/app/lib/registry-api/revalidate.ts +36 -0
- package/src/app/lib/registry-api/store.ts +348 -0
- package/src/app/lib/registry-api/token-transfer.ts +231 -0
- package/src/app/lib/registry-api/transfer.ts +513 -0
- package/src/app/lib/registry-api/validation.ts +74 -0
- package/src/app/lib/registry-connection.ts +58 -0
- package/src/app/lib/utils.ts +14 -0
- package/src/app/next.config.mjs +72 -13
- package/src/app/pages/[...slug]/index.tsx +74 -20
- package/src/app/pages/_app.tsx +5 -2
- package/src/app/pages/api/docs/artifacts/[...artifactPath].ts +16 -0
- package/src/app/pages/api/docs/assets/[collection]/[...path].ts +50 -0
- package/src/app/pages/api/docs/assets/[collection]/index.ts +22 -0
- package/src/app/pages/api/docs/components/[id]/assets/[asset].ts +33 -0
- package/src/app/pages/api/docs/components/[id]/inspect/[previewId].ts +20 -0
- package/src/app/pages/api/docs/components/[id]/previews/[previewId].ts +21 -0
- package/src/app/pages/api/docs/components/[id].ts +24 -0
- package/src/app/pages/api/docs/components.json.ts +12 -0
- package/src/app/pages/api/docs/nav.json.ts +48 -0
- package/src/app/pages/api/docs/patterns/[id]/preview.ts +19 -0
- package/src/app/pages/api/docs/patterns/[id].ts +24 -0
- package/src/app/pages/api/docs/patterns.json.ts +12 -0
- package/src/app/pages/api/docs/tokens/components/[id].ts +30 -0
- package/src/app/pages/api/docs/tokens/foundations/[type].ts +32 -0
- package/src/app/pages/api/registry/components/[id]/files/[...filePath].ts +19 -0
- package/src/app/pages/api/registry/components/[id]/files/index.ts +19 -0
- package/src/app/pages/api/registry/components/[id].ts +20 -0
- package/src/app/pages/api/registry/components/index.ts +19 -0
- package/src/app/pages/api/registry/health.ts +20 -0
- package/src/app/pages/api/registry/patterns/[id]/files/[...filePath].ts +19 -0
- package/src/app/pages/api/registry/patterns/[id]/files/index.ts +19 -0
- package/src/app/pages/api/registry/patterns/[id].ts +20 -0
- package/src/app/pages/api/registry/patterns/index.ts +19 -0
- package/src/app/pages/api/registry/transfer/[kind]/[id].ts +39 -0
- package/src/app/pages/api/registry/transfer/assets/[collection].ts +24 -0
- package/src/app/pages/api/registry/transfer/assets/blobs/[hash].ts +23 -0
- package/src/app/pages/api/registry/transfer/assets/blobs/have.ts +11 -0
- package/src/app/pages/api/registry/transfer/assets/index.ts +10 -0
- package/src/app/pages/api/registry/transfer/tokens/[...setId].ts +26 -0
- package/src/app/pages/api/registry/transfer/tokens/index.ts +11 -0
- package/src/app/pages/assets/fonts.tsx +41 -17
- package/src/app/pages/assets/index.tsx +2 -2
- package/src/app/pages/assets/logos.tsx +2 -2
- package/src/app/pages/foundations/colors.tsx +18 -8
- package/src/app/pages/foundations/effects.tsx +18 -8
- package/src/app/pages/foundations/icons/[name]/index.tsx +26 -14
- package/src/app/pages/foundations/icons/index.tsx +13 -9
- package/src/app/pages/foundations/index.tsx +1 -1
- package/src/app/pages/foundations/logo.tsx +7 -4
- package/src/app/pages/foundations/typography.tsx +19 -9
- package/src/app/pages/index.tsx +1 -1
- package/src/app/pages/system/component/[component]/index.tsx +87 -17
- package/src/app/pages/system/index.tsx +13 -4
- package/src/app/pages/system/pattern/[pattern]/index.tsx +70 -14
- package/src/app/pages/system/tokens/components/[component]/index.tsx +42 -14
- package/src/app/pages/system/tokens/foundations/colors.tsx +7 -5
- package/src/app/pages/system/tokens/foundations/effects.tsx +7 -5
- package/src/app/pages/system/tokens/foundations/typography.tsx +8 -4
- package/src/app/tsconfig.json +2 -3
- package/src/app-builder/build.ts +555 -11
- package/src/app-builder/client-config.ts +61 -4
- package/src/app-builder/config-diff/snapshot.ts +1 -11
- package/src/app-builder/index.ts +1 -1
- package/src/app-builder/nav-shell.ts +74 -0
- package/src/app-builder/static-export.ts +215 -0
- package/src/app-builder/vercel-output.ts +297 -0
- package/src/app-builder/watchers/utils.ts +2 -0
- package/src/app-builder/watchers.ts +149 -25
- package/src/app-builder/websocket.ts +2 -2
- package/src/artifacts/README.md +14 -0
- package/src/artifacts/index.ts +17 -0
- package/src/artifacts/types.ts +146 -0
- package/src/artifacts/url.ts +90 -0
- package/src/cache/build-cache.ts +47 -2
- package/src/commands/build/app.ts +1 -2
- package/src/commands/build/index.ts +61 -0
- package/src/commands/checkout/index.ts +66 -0
- package/src/commands/db/migrate.ts +25 -0
- package/src/commands/index.ts +8 -0
- package/src/commands/publish/index.ts +63 -0
- package/src/config/defaults.ts +15 -0
- package/src/config/loader.ts +10 -1
- package/src/config/normalizers/declaration.ts +3 -0
- package/src/config/normalizers/page.ts +45 -0
- package/src/config/normalizers/pattern.ts +4 -1
- package/src/config/runtime.ts +48 -2
- package/src/index.ts +126 -3
- package/src/nav/index.ts +94 -0
- package/src/nav/registry.ts +54 -0
- package/src/nav/resolver.ts +217 -0
- package/src/nav/workspace.ts +87 -0
- package/src/pipeline/styles.ts +4 -35
- package/src/pipeline/token-transformers.ts +97 -0
- package/src/registry/asset-storage/adapters/vercel-blob.ts +51 -0
- package/src/registry/asset-storage/define.ts +15 -0
- package/src/registry/asset-storage/resolve.ts +72 -0
- package/src/registry/asset-storage/types.ts +46 -0
- package/src/registry/assets/layout.ts +38 -0
- package/src/registry/assets/sets.ts +48 -0
- package/src/registry/assets/transfer.ts +50 -0
- package/src/registry/checkout/assets.ts +126 -0
- package/src/registry/checkout/index.ts +596 -0
- package/src/registry/checkout/tokens.ts +152 -0
- package/src/registry/client.ts +234 -0
- package/src/registry/connection.ts +50 -0
- package/src/registry/db/adapter.ts +74 -0
- package/src/registry/db/client.ts +88 -0
- package/src/registry/db/index.ts +35 -0
- package/src/registry/db/migrate.ts +56 -0
- package/src/registry/db/schema.ts +444 -0
- package/src/registry/path.ts +26 -0
- package/src/registry/publish/artifacts.ts +147 -0
- package/src/registry/publish/assets.ts +129 -0
- package/src/registry/publish/errors.ts +34 -0
- package/src/registry/publish/index.ts +128 -0
- package/src/registry/publish/package.ts +272 -0
- package/src/registry/publish/publish-build.ts +51 -0
- package/src/registry/publish/tokens.ts +119 -0
- package/src/registry/tokens/sets.ts +132 -0
- package/src/registry/tokens/transfer.ts +53 -0
- package/src/registry/transfer.ts +82 -0
- package/src/store/filesystem-assets.ts +152 -0
- package/src/store/filesystem.ts +237 -0
- package/src/store/index.ts +62 -0
- package/src/store/registry.ts +334 -0
- package/src/store/source-files.ts +155 -0
- package/src/store/types.ts +210 -0
- package/src/transformers/plugins/csf-render.ts +31 -7
- package/src/transformers/plugins/handlebars-previews.ts +22 -3
- package/src/transformers/plugins/ssr-render.ts +145 -57
- package/src/transformers/preview/component/api.ts +2 -1
- package/src/transformers/preview/component/artifacts.ts +10 -1
- package/src/transformers/preview/component/builder.ts +9 -2
- package/src/transformers/preview/component/css.ts +10 -1
- package/src/transformers/preview/component/javascript.ts +55 -20
- package/src/transformers/preview/component/shared-artifacts.ts +146 -0
- package/src/transformers/preview/component.ts +5 -2
- package/src/transformers/preview/pattern/builder.ts +33 -7
- package/src/transformers/preview/pattern/html.ts +71 -27
- package/src/transformers/preview/types.ts +42 -0
- package/src/transformers/utils/handlebars.ts +31 -5
- package/src/types/config.ts +123 -25
- package/src/utils/menu-shell.ts +241 -0
- package/src/utils/stable-stringify.ts +7 -0
- package/templates/default/package.json.tpl +1 -1
- package/handoff.config.js +0 -90
- package/src/app/components/ComponentSearch.tsx +0 -93
package/dist/pipeline/styles.js
CHANGED
|
@@ -18,6 +18,7 @@ const handoff_core_1 = require("handoff-core");
|
|
|
18
18
|
const lodash_1 = require("lodash");
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
20
|
const archive_1 = require("./archive");
|
|
21
|
+
const token_transformers_1 = require("./token-transformers");
|
|
21
22
|
/**
|
|
22
23
|
* Build just the custom fonts — zips font directories and copies them to the export folder.
|
|
23
24
|
*/
|
|
@@ -49,39 +50,10 @@ exports.buildCustomFonts = buildCustomFonts;
|
|
|
49
50
|
* Builds design token style files using core and user-configured transformers.
|
|
50
51
|
*/
|
|
51
52
|
const buildStyles = (handoff, documentationObject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
var _a, _b
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
transformer: handoff_core_1.Transformers.ScssTransformer,
|
|
57
|
-
outDir: 'sass',
|
|
58
|
-
format: 'scss',
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
transformer: handoff_core_1.Transformers.ScssTypesTransformer,
|
|
62
|
-
outDir: 'types',
|
|
63
|
-
format: 'scss',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
transformer: handoff_core_1.Transformers.CssTransformer,
|
|
67
|
-
outDir: 'css',
|
|
68
|
-
format: 'css',
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
// Get user-configured transformers
|
|
72
|
-
const userTransformers = ((_b = (_a = handoff.config) === null || _a === void 0 ? void 0 : _a.pipeline) === null || _b === void 0 ? void 0 : _b.transformers) || [];
|
|
73
|
-
// Merge core transformers with user transformers
|
|
74
|
-
// If a user transformer matches a core transformer, use user's outDir and format
|
|
75
|
-
const transformers = coreTransformers.map((coreTransformer) => {
|
|
76
|
-
const userTransformer = userTransformers.find((t) => t.transformer === coreTransformer.transformer);
|
|
77
|
-
return userTransformer ? Object.assign(Object.assign({}, coreTransformer), { outDir: userTransformer.outDir, format: userTransformer.format }) : coreTransformer;
|
|
78
|
-
});
|
|
79
|
-
// Add any additional user transformers that aren't core transformers
|
|
80
|
-
userTransformers.forEach((userTransformer) => {
|
|
81
|
-
if (!coreTransformers.some((core) => core.transformer === userTransformer.transformer)) {
|
|
82
|
-
transformers.push(userTransformer);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
53
|
+
var _a, _b;
|
|
54
|
+
// Resolve the merged core + user-configured transformer list (single source of truth, shared with
|
|
55
|
+
// the registry publish packaging so the on-disk layout never drifts).
|
|
56
|
+
const transformers = (0, token_transformers_1.resolveTokenTransformers)(handoff);
|
|
85
57
|
const baseDir = handoff.getVariablesFilePath();
|
|
86
58
|
const runner = yield handoff.getRunner();
|
|
87
59
|
// Create transformer instances and transform documentation object
|
|
@@ -100,7 +72,7 @@ const buildStyles = (handoff, documentationObject) => __awaiter(void 0, void 0,
|
|
|
100
72
|
// Special case for SD tokens components directory
|
|
101
73
|
const sdTransformer = transformers.find((t) => t.transformer === handoff_core_1.Transformers.StyleDictionaryTransformer);
|
|
102
74
|
if (sdTransformer) {
|
|
103
|
-
const sdFiles = (
|
|
75
|
+
const sdFiles = (_a = transformedFiles.find((t) => t.transformer === handoff_core_1.Transformers.StyleDictionaryTransformer)) === null || _a === void 0 ? void 0 : _a.files;
|
|
104
76
|
if (sdFiles === null || sdFiles === void 0 ? void 0 : sdFiles.components) {
|
|
105
77
|
yield Promise.all(Object.keys(sdFiles.components).map((name) => fs_extra_1.default.ensureDir(path_1.default.join(baseDir, sdTransformer.outDir, name))));
|
|
106
78
|
}
|
|
@@ -125,7 +97,7 @@ const buildStyles = (handoff, documentationObject) => __awaiter(void 0, void 0,
|
|
|
125
97
|
return [...componentPromises, ...designPromises];
|
|
126
98
|
});
|
|
127
99
|
// Generate tokens-map.json
|
|
128
|
-
const mapFiles = (
|
|
100
|
+
const mapFiles = (_b = transformedFiles.find((t) => t.transformer === handoff_core_1.Transformers.MapTransformer)) === null || _b === void 0 ? void 0 : _b.files;
|
|
129
101
|
if (mapFiles) {
|
|
130
102
|
const tokensMapContent = JSON.stringify(Object.entries(mapFiles.components || {}).reduce((acc, [_, data]) => (Object.assign(Object.assign({}, acc), JSON.parse(data))), Object.assign(Object.assign(Object.assign({}, JSON.parse(mapFiles.design.colors)), JSON.parse(mapFiles.design.typography)), JSON.parse(mapFiles.design.effects))), null, 2);
|
|
131
103
|
writePromises.push(fs_extra_1.default.writeFile(path_1.default.join(handoff.getOutputPath(), 'tokens-map.json'), tokensMapContent));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared resolution of the design-token style transformers and their on-disk layout.
|
|
3
|
+
*
|
|
4
|
+
* Both {@link import('./styles').buildStyles} (which writes the generated token files) and the
|
|
5
|
+
* registry publish packaging (which reads them back byte-for-byte) must agree on exactly which
|
|
6
|
+
* transformers run, their output directories/formats, and the path each set's files land at. This
|
|
7
|
+
* module is the single source of that layout so the two never drift.
|
|
8
|
+
*/
|
|
9
|
+
import type { TransformerConfig } from '../types/config';
|
|
10
|
+
/** Minimal shape needed to resolve transformers: just the pipeline transformer config. */
|
|
11
|
+
export interface TokenTransformerContext {
|
|
12
|
+
config?: {
|
|
13
|
+
pipeline?: {
|
|
14
|
+
transformers?: TransformerConfig[];
|
|
15
|
+
} | null;
|
|
16
|
+
} | null;
|
|
17
|
+
}
|
|
18
|
+
/** A resolved token transformer: the factory plus its output directory, file format, and logical label. */
|
|
19
|
+
export interface ResolvedTokenTransformer {
|
|
20
|
+
transformer: any;
|
|
21
|
+
outDir: string;
|
|
22
|
+
format: string;
|
|
23
|
+
/** Stable logical label for the output (`css`|`scss`|`types`|`styleDictionary`|custom `outDir`). */
|
|
24
|
+
label: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the merged transformer list (core + user-configured). A user transformer matching a core
|
|
28
|
+
* transformer overrides its `outDir`/`format`; other user transformers (e.g. Style Dictionary or a
|
|
29
|
+
* fully custom transformer) are appended. Mirrors the historical inline logic in `buildStyles`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const resolveTokenTransformers: (context: TokenTransformerContext) => ResolvedTokenTransformer[];
|
|
32
|
+
/** A generated token artifact expected for a set: its registry-safe relative path + logical label. */
|
|
33
|
+
export interface TokenArtifactLayout {
|
|
34
|
+
/** Path relative to `getVariablesFilePath()`, e.g. `css/colors.css` or `sd/button/button.tokens.json`. */
|
|
35
|
+
path: string;
|
|
36
|
+
/** Logical format label (`css`|`scss`|`types`|`styleDictionary`|custom). */
|
|
37
|
+
format: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Compute the registry-safe relative paths (under `getVariablesFilePath()`) a single set's generated
|
|
41
|
+
* files land at, across every resolved transformer. Honors the Style Dictionary nesting special-case
|
|
42
|
+
* (`buildStyles`): SD component tokens go to `<outDir>/<name>/<name>.tokens.json`, SD foundation
|
|
43
|
+
* tokens to `<outDir>/<name>.tokens.json`; every other transformer writes `<outDir>/<name>.<format>`.
|
|
44
|
+
*/
|
|
45
|
+
export declare const tokenArtifactPathsForSet: (transformers: ResolvedTokenTransformer[], setName: string, isComponent: boolean) => TokenArtifactLayout[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared resolution of the design-token style transformers and their on-disk layout.
|
|
4
|
+
*
|
|
5
|
+
* Both {@link import('./styles').buildStyles} (which writes the generated token files) and the
|
|
6
|
+
* registry publish packaging (which reads them back byte-for-byte) must agree on exactly which
|
|
7
|
+
* transformers run, their output directories/formats, and the path each set's files land at. This
|
|
8
|
+
* module is the single source of that layout so the two never drift.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.tokenArtifactPathsForSet = exports.resolveTokenTransformers = void 0;
|
|
12
|
+
const handoff_core_1 = require("handoff-core");
|
|
13
|
+
/** The three core transformers Handoff always runs, matching the historical `buildStyles` defaults. */
|
|
14
|
+
const CORE_TRANSFORMERS = [
|
|
15
|
+
{ transformer: handoff_core_1.Transformers.ScssTransformer, outDir: 'sass', format: 'scss', label: 'scss' },
|
|
16
|
+
{ transformer: handoff_core_1.Transformers.ScssTypesTransformer, outDir: 'types', format: 'scss', label: 'types' },
|
|
17
|
+
{ transformer: handoff_core_1.Transformers.CssTransformer, outDir: 'css', format: 'css', label: 'css' },
|
|
18
|
+
];
|
|
19
|
+
/** Logical label for a transformer factory: known core/SD labels, else the custom transformer's outDir. */
|
|
20
|
+
const labelForTransformer = (transformer, outDir) => {
|
|
21
|
+
if (transformer === handoff_core_1.Transformers.ScssTransformer)
|
|
22
|
+
return 'scss';
|
|
23
|
+
if (transformer === handoff_core_1.Transformers.ScssTypesTransformer)
|
|
24
|
+
return 'types';
|
|
25
|
+
if (transformer === handoff_core_1.Transformers.CssTransformer)
|
|
26
|
+
return 'css';
|
|
27
|
+
if (transformer === handoff_core_1.Transformers.StyleDictionaryTransformer)
|
|
28
|
+
return 'styleDictionary';
|
|
29
|
+
return outDir;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Resolve the merged transformer list (core + user-configured). A user transformer matching a core
|
|
33
|
+
* transformer overrides its `outDir`/`format`; other user transformers (e.g. Style Dictionary or a
|
|
34
|
+
* fully custom transformer) are appended. Mirrors the historical inline logic in `buildStyles`.
|
|
35
|
+
*/
|
|
36
|
+
const resolveTokenTransformers = (context) => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const userTransformers = ((_b = (_a = context.config) === null || _a === void 0 ? void 0 : _a.pipeline) === null || _b === void 0 ? void 0 : _b.transformers) || [];
|
|
39
|
+
const transformers = CORE_TRANSFORMERS.map((core) => {
|
|
40
|
+
const override = userTransformers.find((t) => t.transformer === core.transformer);
|
|
41
|
+
return override
|
|
42
|
+
? { transformer: core.transformer, outDir: override.outDir, format: override.format, label: labelForTransformer(core.transformer, override.outDir) }
|
|
43
|
+
: Object.assign({}, core);
|
|
44
|
+
});
|
|
45
|
+
userTransformers.forEach((userTransformer) => {
|
|
46
|
+
if (!CORE_TRANSFORMERS.some((core) => core.transformer === userTransformer.transformer)) {
|
|
47
|
+
transformers.push({
|
|
48
|
+
transformer: userTransformer.transformer,
|
|
49
|
+
outDir: userTransformer.outDir,
|
|
50
|
+
format: userTransformer.format,
|
|
51
|
+
label: labelForTransformer(userTransformer.transformer, userTransformer.outDir),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return transformers;
|
|
56
|
+
};
|
|
57
|
+
exports.resolveTokenTransformers = resolveTokenTransformers;
|
|
58
|
+
/**
|
|
59
|
+
* Compute the registry-safe relative paths (under `getVariablesFilePath()`) a single set's generated
|
|
60
|
+
* files land at, across every resolved transformer. Honors the Style Dictionary nesting special-case
|
|
61
|
+
* (`buildStyles`): SD component tokens go to `<outDir>/<name>/<name>.tokens.json`, SD foundation
|
|
62
|
+
* tokens to `<outDir>/<name>.tokens.json`; every other transformer writes `<outDir>/<name>.<format>`.
|
|
63
|
+
*/
|
|
64
|
+
const tokenArtifactPathsForSet = (transformers, setName, isComponent) => transformers.map(({ outDir, format, label }) => {
|
|
65
|
+
if (label === 'styleDictionary') {
|
|
66
|
+
const path = isComponent ? `${outDir}/${setName}/${setName}.tokens.json` : `${outDir}/${setName}.tokens.json`;
|
|
67
|
+
return { path, format: label };
|
|
68
|
+
}
|
|
69
|
+
return { path: `${outDir}/${setName}.${format}`, format: label };
|
|
70
|
+
});
|
|
71
|
+
exports.tokenArtifactPathsForSet = tokenArtifactPathsForSet;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-packaged Vercel Blob asset storage adapter.
|
|
3
|
+
*
|
|
4
|
+
* Ships with Handoff and is selected via `runtime.registry.assetStorage.adapter: "vercel-blob"`. The
|
|
5
|
+
* read/write token is read from `process.env[tokenEnv]` at request time (never persisted in config).
|
|
6
|
+
* Blobs are stored public and content-addressed by hash, so reads resolve to a direct provider URL
|
|
7
|
+
* (a `redirect` result), keeping large payloads out of the serverless function body/response.
|
|
8
|
+
*
|
|
9
|
+
* The `@vercel/blob` SDK is loaded lazily so it is only pulled into memory (and traced into the
|
|
10
|
+
* registry bundle) when this adapter is actually used.
|
|
11
|
+
*/
|
|
12
|
+
import type { AssetStorage } from '../types';
|
|
13
|
+
/** Build a Vercel Blob storage adapter bound to a token env-var name + non-secret options. */
|
|
14
|
+
export declare const createVercelBlobStorage: (params: {
|
|
15
|
+
tokenEnv: string;
|
|
16
|
+
options: Record<string, unknown>;
|
|
17
|
+
}) => AssetStorage;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Pre-packaged Vercel Blob asset storage adapter.
|
|
4
|
+
*
|
|
5
|
+
* Ships with Handoff and is selected via `runtime.registry.assetStorage.adapter: "vercel-blob"`. The
|
|
6
|
+
* read/write token is read from `process.env[tokenEnv]` at request time (never persisted in config).
|
|
7
|
+
* Blobs are stored public and content-addressed by hash, so reads resolve to a direct provider URL
|
|
8
|
+
* (a `redirect` result), keeping large payloads out of the serverless function body/response.
|
|
9
|
+
*
|
|
10
|
+
* The `@vercel/blob` SDK is loaded lazily so it is only pulled into memory (and traced into the
|
|
11
|
+
* registry bundle) when this adapter is actually used.
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.createVercelBlobStorage = void 0;
|
|
47
|
+
/** Build a Vercel Blob storage adapter bound to a token env-var name + non-secret options. */
|
|
48
|
+
const createVercelBlobStorage = (params) => {
|
|
49
|
+
const prefix = typeof params.options.prefix === 'string' && params.options.prefix.trim() ? params.options.prefix.trim() : 'handoff/assets';
|
|
50
|
+
const resolveToken = () => {
|
|
51
|
+
var _a;
|
|
52
|
+
const token = (_a = process.env[params.tokenEnv]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
53
|
+
if (!token) {
|
|
54
|
+
throw new Error(`Vercel Blob storage is configured but the token env var "${params.tokenEnv}" is not set. ` +
|
|
55
|
+
'Set it to a Blob read/write token, or change runtime.registry.assetStorage.tokenEnv.');
|
|
56
|
+
}
|
|
57
|
+
return token;
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
put(_a) {
|
|
61
|
+
return __awaiter(this, arguments, void 0, function* ({ hash, bytes, contentType }) {
|
|
62
|
+
const { put } = yield Promise.resolve().then(() => __importStar(require('@vercel/blob')));
|
|
63
|
+
// Content-addressed pathname + no random suffix so the same bytes map to a stable, dedupable key.
|
|
64
|
+
const result = yield put(`${prefix}/${hash}`, bytes, {
|
|
65
|
+
access: 'public',
|
|
66
|
+
token: resolveToken(),
|
|
67
|
+
contentType,
|
|
68
|
+
addRandomSuffix: false,
|
|
69
|
+
});
|
|
70
|
+
return { storageRef: result.url };
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
get(storageRef) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
// Public blob URLs are directly fetchable; redirect the client to avoid proxying bytes.
|
|
76
|
+
return { kind: 'redirect', url: storageRef };
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
delete(storageRef) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const { del } = yield Promise.resolve().then(() => __importStar(require('@vercel/blob')));
|
|
82
|
+
yield del(storageRef, { token: resolveToken() });
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
exports.createVercelBlobStorage = createVercelBlobStorage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed identity helper for custom asset storage adapters (mirrors `defineComponent`): a consumer
|
|
3
|
+
* default-exports its result from a **server-only** module and points
|
|
4
|
+
* `runtime.registry.assetStorage.module` at it. It must be its own module (not an inline
|
|
5
|
+
* `defineConfig` function) so the build can trace it into the deployed registry. The default export
|
|
6
|
+
* may be the adapter object, or a factory `(context) => AssetStorage` when it needs its options/env.
|
|
7
|
+
*/
|
|
8
|
+
import type { AssetStorage, AssetStorageFactory } from './types';
|
|
9
|
+
export declare function defineAssetStorage(adapter: AssetStorage): AssetStorage;
|
|
10
|
+
export declare function defineAssetStorage(factory: AssetStorageFactory): AssetStorageFactory;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Typed identity helper for custom asset storage adapters (mirrors `defineComponent`): a consumer
|
|
4
|
+
* default-exports its result from a **server-only** module and points
|
|
5
|
+
* `runtime.registry.assetStorage.module` at it. It must be its own module (not an inline
|
|
6
|
+
* `defineConfig` function) so the build can trace it into the deployed registry. The default export
|
|
7
|
+
* may be the adapter object, or a factory `(context) => AssetStorage` when it needs its options/env.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.defineAssetStorage = defineAssetStorage;
|
|
11
|
+
function defineAssetStorage(input) {
|
|
12
|
+
return input;
|
|
13
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asset storage settings resolution.
|
|
3
|
+
*
|
|
4
|
+
* `runtime.registry.assetStorage` selects the active provider for **new** uploads: the built-in
|
|
5
|
+
* `database` inline default, the pre-packaged `vercel-blob` adapter, or a `custom` module. Mirrors
|
|
6
|
+
* {@link import('../db/adapter')}: only provider selection, module location, non-secret options, and
|
|
7
|
+
* env-var *names* are ever persisted; secret *values* are read from `process.env` at request time.
|
|
8
|
+
*/
|
|
9
|
+
import type { Config } from '../../types/config';
|
|
10
|
+
import type { AssetStorageProvider } from '../db/schema';
|
|
11
|
+
/** Which adapter implementation is active. */
|
|
12
|
+
export type AssetStorageAdapterKind = 'database' | 'vercel-blob' | 'custom';
|
|
13
|
+
/** The raw, authored settings block (a structural copy of the config type, resolvable from bake). */
|
|
14
|
+
export interface AssetStorageSettings {
|
|
15
|
+
adapter?: AssetStorageAdapterKind;
|
|
16
|
+
module?: string;
|
|
17
|
+
tokenEnv?: string;
|
|
18
|
+
maxInlineBytes?: number;
|
|
19
|
+
options?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
/** Default adapter when none is configured. */
|
|
22
|
+
export declare const DEFAULT_ASSET_STORAGE_ADAPTER: AssetStorageAdapterKind;
|
|
23
|
+
/** Default env-var name holding the Vercel Blob read/write token. */
|
|
24
|
+
export declare const DEFAULT_BLOB_TOKEN_ENV = "BLOB_READ_WRITE_TOKEN";
|
|
25
|
+
/** Default max bytes kept inline in Postgres `bytea` (4 MB, under Vercel's ~4.5 MB function limit). */
|
|
26
|
+
export declare const DEFAULT_MAX_INLINE_BYTES: number;
|
|
27
|
+
/** Fully resolved asset storage settings. */
|
|
28
|
+
export interface ResolvedAssetStorage {
|
|
29
|
+
/** The active adapter implementation. */
|
|
30
|
+
adapterKind: AssetStorageAdapterKind;
|
|
31
|
+
/** Provider id recorded on blob rows written by the active adapter (drives read resolution). */
|
|
32
|
+
provider: AssetStorageProvider;
|
|
33
|
+
/** For `custom`: the server-only adapter module path. */
|
|
34
|
+
module?: string;
|
|
35
|
+
/** For `vercel-blob`: the env-var name holding the token. */
|
|
36
|
+
tokenEnv: string;
|
|
37
|
+
/** For `database`: the inline-content size ceiling. */
|
|
38
|
+
maxInlineBytes: number;
|
|
39
|
+
/** Non-secret adapter options. */
|
|
40
|
+
options: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
/** Resolve raw asset storage settings into a fully-defaulted shape. */
|
|
43
|
+
export declare const resolveAssetStorageSettings: (settings: AssetStorageSettings | null | undefined) => ResolvedAssetStorage;
|
|
44
|
+
/** Resolve the active asset storage settings from a loaded config (CLI/build side). */
|
|
45
|
+
export declare const resolveAssetStorageFromConfig: (config: Config | null | undefined) => ResolvedAssetStorage;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Asset storage settings resolution.
|
|
4
|
+
*
|
|
5
|
+
* `runtime.registry.assetStorage` selects the active provider for **new** uploads: the built-in
|
|
6
|
+
* `database` inline default, the pre-packaged `vercel-blob` adapter, or a `custom` module. Mirrors
|
|
7
|
+
* {@link import('../db/adapter')}: only provider selection, module location, non-secret options, and
|
|
8
|
+
* env-var *names* are ever persisted; secret *values* are read from `process.env` at request time.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.resolveAssetStorageFromConfig = exports.resolveAssetStorageSettings = exports.DEFAULT_MAX_INLINE_BYTES = exports.DEFAULT_BLOB_TOKEN_ENV = exports.DEFAULT_ASSET_STORAGE_ADAPTER = void 0;
|
|
12
|
+
/** Default adapter when none is configured. */
|
|
13
|
+
exports.DEFAULT_ASSET_STORAGE_ADAPTER = 'database';
|
|
14
|
+
/** Default env-var name holding the Vercel Blob read/write token. */
|
|
15
|
+
exports.DEFAULT_BLOB_TOKEN_ENV = 'BLOB_READ_WRITE_TOKEN';
|
|
16
|
+
/** Default max bytes kept inline in Postgres `bytea` (4 MB, under Vercel's ~4.5 MB function limit). */
|
|
17
|
+
exports.DEFAULT_MAX_INLINE_BYTES = 4 * 1024 * 1024;
|
|
18
|
+
/** The stable provider id recorded on blobs for a custom adapter (single custom provider at a time). */
|
|
19
|
+
const customProviderId = (options) => {
|
|
20
|
+
const id = typeof options.providerId === 'string' && options.providerId.trim() ? options.providerId.trim() : 'custom';
|
|
21
|
+
return id;
|
|
22
|
+
};
|
|
23
|
+
/** Resolve raw asset storage settings into a fully-defaulted shape. */
|
|
24
|
+
const resolveAssetStorageSettings = (settings) => {
|
|
25
|
+
var _a, _b, _c, _d;
|
|
26
|
+
const adapterKind = (_a = settings === null || settings === void 0 ? void 0 : settings.adapter) !== null && _a !== void 0 ? _a : exports.DEFAULT_ASSET_STORAGE_ADAPTER;
|
|
27
|
+
const options = (_b = settings === null || settings === void 0 ? void 0 : settings.options) !== null && _b !== void 0 ? _b : {};
|
|
28
|
+
const tokenEnv = ((_c = settings === null || settings === void 0 ? void 0 : settings.tokenEnv) === null || _c === void 0 ? void 0 : _c.trim()) || exports.DEFAULT_BLOB_TOKEN_ENV;
|
|
29
|
+
const maxInlineBytes = typeof (settings === null || settings === void 0 ? void 0 : settings.maxInlineBytes) === 'number' && settings.maxInlineBytes > 0 ? settings.maxInlineBytes : exports.DEFAULT_MAX_INLINE_BYTES;
|
|
30
|
+
const provider = adapterKind === 'vercel-blob' ? 'vercel-blob' : adapterKind === 'custom' ? customProviderId(options) : 'database';
|
|
31
|
+
return { adapterKind, provider, module: ((_d = settings === null || settings === void 0 ? void 0 : settings.module) === null || _d === void 0 ? void 0 : _d.trim()) || undefined, tokenEnv, maxInlineBytes, options };
|
|
32
|
+
};
|
|
33
|
+
exports.resolveAssetStorageSettings = resolveAssetStorageSettings;
|
|
34
|
+
/** Resolve the active asset storage settings from a loaded config (CLI/build side). */
|
|
35
|
+
const resolveAssetStorageFromConfig = (config) => { var _a, _b; return (0, exports.resolveAssetStorageSettings)((_b = (_a = config === null || config === void 0 ? void 0 : config.runtime) === null || _a === void 0 ? void 0 : _a.registry) === null || _b === void 0 ? void 0 : _b.assetStorage); };
|
|
36
|
+
exports.resolveAssetStorageFromConfig = resolveAssetStorageFromConfig;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-only asset storage contract for object-backed providers (Vercel Blob + custom
|
|
3
|
+
* {@link defineAssetStorage} modules), so callers need no provider-specific logic. The built-in
|
|
4
|
+
* `database` provider is the inline default: bytes live in the `asset_blobs.content` bytea column,
|
|
5
|
+
* read/written directly by the registry, so it needs no adapter. Object providers record a
|
|
6
|
+
* `storageRef` + provider id so reads resolve back through whichever provider stored the blob.
|
|
7
|
+
*/
|
|
8
|
+
/** Input for storing one content-addressed blob. */
|
|
9
|
+
export interface AssetStorageInput {
|
|
10
|
+
/** SHA-256 of the bytes (hex), the content identity, usable as a stable object key. */
|
|
11
|
+
hash: string;
|
|
12
|
+
bytes: Buffer;
|
|
13
|
+
contentType: string;
|
|
14
|
+
size: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* How a provider returns stored content: raw bytes, a readable stream, or a signed/redirect URL the
|
|
18
|
+
* client can fetch directly (used to avoid routing large payloads through the serverless function).
|
|
19
|
+
*/
|
|
20
|
+
export type AssetStorageReadResult = {
|
|
21
|
+
kind: 'bytes';
|
|
22
|
+
bytes: Buffer;
|
|
23
|
+
contentType?: string;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'stream';
|
|
26
|
+
stream: NodeJS.ReadableStream;
|
|
27
|
+
contentType?: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'redirect';
|
|
30
|
+
url: string;
|
|
31
|
+
};
|
|
32
|
+
/** The pluggable storage adapter contract for object-backed asset providers. */
|
|
33
|
+
export interface AssetStorage {
|
|
34
|
+
/** Store one blob and return the reference to persist on its `asset_blobs` row. */
|
|
35
|
+
put(input: AssetStorageInput): Promise<{
|
|
36
|
+
storageRef: string;
|
|
37
|
+
}>;
|
|
38
|
+
/** Resolve stored content by its `storageRef`. */
|
|
39
|
+
get(storageRef: string): Promise<AssetStorageReadResult>;
|
|
40
|
+
/** Delete stored content by its `storageRef`. Should be retryable/idempotent. */
|
|
41
|
+
delete(storageRef: string): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/** Context passed to a custom adapter factory: its non-secret config options + the process env. */
|
|
44
|
+
export interface AssetStorageContext {
|
|
45
|
+
/** Non-secret options from `runtime.registry.assetStorage.options` (bucket env-var names, region, …). */
|
|
46
|
+
options: Record<string, unknown>;
|
|
47
|
+
/** The process environment. Read secret *values* here by the env-var *names* carried in options. */
|
|
48
|
+
env: NodeJS.ProcessEnv;
|
|
49
|
+
}
|
|
50
|
+
/** A custom adapter may export the adapter directly or a factory that builds it from its context. */
|
|
51
|
+
export type AssetStorageFactory = (context: AssetStorageContext) => AssetStorage | Promise<AssetStorage>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Server-only asset storage contract for object-backed providers (Vercel Blob + custom
|
|
4
|
+
* {@link defineAssetStorage} modules), so callers need no provider-specific logic. The built-in
|
|
5
|
+
* `database` provider is the inline default: bytes live in the `asset_blobs.content` bytea column,
|
|
6
|
+
* read/written directly by the registry, so it needs no adapter. Object providers record a
|
|
7
|
+
* `storageRef` + provider id so reads resolve back through whichever provider stored the blob.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace physical layout for asset logical paths.
|
|
3
|
+
*
|
|
4
|
+
* A collection's logical paths are portable (no project id): icon/logo bodies + the collection JSON +
|
|
5
|
+
* the sprite live under `public/api`, the downloadable ZIP archives live at the generated output
|
|
6
|
+
* root, and font archives live under the workspace `fonts/` dir. Both the filesystem store (reading
|
|
7
|
+
* for publish) and checkout (writing restored files) resolve through this one mapping so they never
|
|
8
|
+
* drift.
|
|
9
|
+
*/
|
|
10
|
+
/** The absolute roots a logical asset path can resolve against. */
|
|
11
|
+
export interface AssetPhysicalRoots {
|
|
12
|
+
/** `<workingPath>/public/api`: icon/logo bodies, collection JSON, sprite + manifest. */
|
|
13
|
+
apiPath: string;
|
|
14
|
+
/** Absolute path of `icons.zip` (`Handoff.getIconsZipFilePath()`). */
|
|
15
|
+
iconsZip: string;
|
|
16
|
+
/** Absolute path of `logos.zip` (`Handoff.getLogosZipFilePath()`). */
|
|
17
|
+
logosZip: string;
|
|
18
|
+
/** Workspace root, holding the `fonts/` dir. */
|
|
19
|
+
workingPath: string;
|
|
20
|
+
}
|
|
21
|
+
/** Resolve a collection-relative logical asset path to its absolute workspace location. */
|
|
22
|
+
export declare const resolveAssetPhysicalPath: (logicalPath: string, roots: AssetPhysicalRoots) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Workspace physical layout for asset logical paths.
|
|
4
|
+
*
|
|
5
|
+
* A collection's logical paths are portable (no project id): icon/logo bodies + the collection JSON +
|
|
6
|
+
* the sprite live under `public/api`, the downloadable ZIP archives live at the generated output
|
|
7
|
+
* root, and font archives live under the workspace `fonts/` dir. Both the filesystem store (reading
|
|
8
|
+
* for publish) and checkout (writing restored files) resolve through this one mapping so they never
|
|
9
|
+
* drift.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.resolveAssetPhysicalPath = void 0;
|
|
13
|
+
const path_1 = require("../path");
|
|
14
|
+
/** Resolve a collection-relative logical asset path to its absolute workspace location. */
|
|
15
|
+
const resolveAssetPhysicalPath = (logicalPath, roots) => {
|
|
16
|
+
if (!(0, path_1.isSafeRelativePath)(logicalPath)) {
|
|
17
|
+
throw new Error(`Unsafe asset path "${logicalPath}".`);
|
|
18
|
+
}
|
|
19
|
+
if (logicalPath === 'icons.zip')
|
|
20
|
+
return roots.iconsZip;
|
|
21
|
+
if (logicalPath === 'logos.zip')
|
|
22
|
+
return roots.logosZip;
|
|
23
|
+
const root = logicalPath.startsWith('fonts/') ? roots.workingPath : roots.apiPath;
|
|
24
|
+
const resolved = (0, path_1.resolvePathWithin)(root, logicalPath);
|
|
25
|
+
if (!resolved) {
|
|
26
|
+
throw new Error(`Asset path "${logicalPath}" escapes its workspace root.`);
|
|
27
|
+
}
|
|
28
|
+
return resolved;
|
|
29
|
+
};
|
|
30
|
+
exports.resolveAssetPhysicalPath = resolveAssetPhysicalPath;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logical asset-collection identity: the pure, dependency-light boundary shared by the store,
|
|
3
|
+
* publish, checkout, server ingestion, and the DB schema.
|
|
4
|
+
*
|
|
5
|
+
* Assets are organized into named **collections**. Unlike token sets (a single JSON slice), each
|
|
6
|
+
* collection is a set of individually addressed files (icons/logos SVGs, the icon sprite + manifest,
|
|
7
|
+
* downloadable ZIP archives, font archives). File discovery + the workspace physical layout live in
|
|
8
|
+
* the filesystem asset store; this module only owns the stable collection vocabulary and the
|
|
9
|
+
* content-type mapping, so it stays free of fs/DB/React dependencies.
|
|
10
|
+
*/
|
|
11
|
+
/** A named asset collection. */
|
|
12
|
+
export type AssetCollection = 'icons' | 'logos' | 'fonts';
|
|
13
|
+
/** The supported collections, in deterministic order. */
|
|
14
|
+
export declare const ASSET_COLLECTIONS: readonly ["icons", "logos", "fonts"];
|
|
15
|
+
/** Whether a string is a supported asset collection. */
|
|
16
|
+
export declare const isAssetCollection: (value: string) => value is AssetCollection;
|
|
17
|
+
/** Resolve the content type to serve/transfer an asset with, keyed by its logical path extension. */
|
|
18
|
+
export declare const assetContentType: (logicalPath: string) => string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Logical asset-collection identity: the pure, dependency-light boundary shared by the store,
|
|
4
|
+
* publish, checkout, server ingestion, and the DB schema.
|
|
5
|
+
*
|
|
6
|
+
* Assets are organized into named **collections**. Unlike token sets (a single JSON slice), each
|
|
7
|
+
* collection is a set of individually addressed files (icons/logos SVGs, the icon sprite + manifest,
|
|
8
|
+
* downloadable ZIP archives, font archives). File discovery + the workspace physical layout live in
|
|
9
|
+
* the filesystem asset store; this module only owns the stable collection vocabulary and the
|
|
10
|
+
* content-type mapping, so it stays free of fs/DB/React dependencies.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.assetContentType = exports.isAssetCollection = exports.ASSET_COLLECTIONS = void 0;
|
|
14
|
+
/** The supported collections, in deterministic order. */
|
|
15
|
+
exports.ASSET_COLLECTIONS = ['icons', 'logos', 'fonts'];
|
|
16
|
+
/** Whether a string is a supported asset collection. */
|
|
17
|
+
const isAssetCollection = (value) => exports.ASSET_COLLECTIONS.includes(value);
|
|
18
|
+
exports.isAssetCollection = isAssetCollection;
|
|
19
|
+
/** File extension of a logical path, lower-cased and including the leading dot (`''` when none). */
|
|
20
|
+
const extnameOf = (filePath) => {
|
|
21
|
+
var _a;
|
|
22
|
+
const base = (_a = filePath.replace(/\\/g, '/').split('/').pop()) !== null && _a !== void 0 ? _a : '';
|
|
23
|
+
const dot = base.lastIndexOf('.');
|
|
24
|
+
return dot > 0 ? base.slice(dot).toLowerCase() : '';
|
|
25
|
+
};
|
|
26
|
+
/** Content type for an asset by extension. Binary-first (assets are SVG/PNG/ZIP/font/JSON). */
|
|
27
|
+
const CONTENT_TYPE_BY_EXT = {
|
|
28
|
+
'.svg': 'image/svg+xml',
|
|
29
|
+
'.png': 'image/png',
|
|
30
|
+
'.jpg': 'image/jpeg',
|
|
31
|
+
'.jpeg': 'image/jpeg',
|
|
32
|
+
'.gif': 'image/gif',
|
|
33
|
+
'.webp': 'image/webp',
|
|
34
|
+
'.json': 'application/json; charset=utf-8',
|
|
35
|
+
'.zip': 'application/zip',
|
|
36
|
+
'.woff': 'font/woff',
|
|
37
|
+
'.woff2': 'font/woff2',
|
|
38
|
+
'.ttf': 'font/ttf',
|
|
39
|
+
'.otf': 'font/otf',
|
|
40
|
+
'.eot': 'application/vnd.ms-fontobject',
|
|
41
|
+
};
|
|
42
|
+
/** Resolve the content type to serve/transfer an asset with, keyed by its logical path extension. */
|
|
43
|
+
const assetContentType = (logicalPath) => { var _a; return (_a = CONTENT_TYPE_BY_EXT[extnameOf(logicalPath)]) !== null && _a !== void 0 ? _a : 'application/octet-stream'; };
|
|
44
|
+
exports.assetContentType = assetContentType;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transfer payload contract for asset collections, shared by the connected-workspace publish/checkout
|
|
3
|
+
* client and the registry-side asset ingestion endpoints.
|
|
4
|
+
*
|
|
5
|
+
* Assets are their own transfer concern: a collection is a set of individually addressed binary files
|
|
6
|
+
* whose bytes travel as content-addressed **blobs** (uploaded/downloaded one at a time so a large
|
|
7
|
+
* collection never becomes one oversized request), while the collection **manifest** carries only
|
|
8
|
+
* metadata. Types only, no behavior.
|
|
9
|
+
*/
|
|
10
|
+
import type { AssetCollection } from './sets';
|
|
11
|
+
import type { ArtifactBuildStatus } from '../../artifacts/types';
|
|
12
|
+
import type { TransferBuild } from '../transfer';
|
|
13
|
+
/** One asset's metadata in a collection manifest (never the binary body). */
|
|
14
|
+
export interface AssetManifestEntry {
|
|
15
|
+
/** Registry-safe logical path within the collection. */
|
|
16
|
+
path: string;
|
|
17
|
+
/** Human-facing asset name. */
|
|
18
|
+
name: string;
|
|
19
|
+
contentType: string;
|
|
20
|
+
size: number;
|
|
21
|
+
/** SHA-256 of the bytes (hex), the blob identity this entry references. */
|
|
22
|
+
contentHash: string;
|
|
23
|
+
/** Free-form asset metadata carried from extraction. */
|
|
24
|
+
metadata?: Record<string, unknown> | null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The collection publish package uploaded to `PUT /api/registry/transfer/assets/:collection` after
|
|
28
|
+
* its blobs have been uploaded: the full manifest and build metadata keyed by `sourceHash`.
|
|
29
|
+
*/
|
|
30
|
+
export interface AssetCollectionTransferPackage {
|
|
31
|
+
collection: AssetCollection;
|
|
32
|
+
build: TransferBuild;
|
|
33
|
+
assets: AssetManifestEntry[];
|
|
34
|
+
}
|
|
35
|
+
/** The checkout payload returned by `GET /api/registry/transfer/assets/:collection`. */
|
|
36
|
+
export interface AssetCollectionCheckoutPayload {
|
|
37
|
+
collection: AssetCollection;
|
|
38
|
+
assets: AssetManifestEntry[];
|
|
39
|
+
}
|
|
40
|
+
/** A lightweight collection summary (`GET /api/registry/transfer/assets`) driving skip-unchanged / bulk checkout. */
|
|
41
|
+
export interface AssetCollectionSummary {
|
|
42
|
+
collection: AssetCollection;
|
|
43
|
+
sourceHash: string | null;
|
|
44
|
+
status: ArtifactBuildStatus | null;
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Transfer payload contract for asset collections, shared by the connected-workspace publish/checkout
|
|
4
|
+
* client and the registry-side asset ingestion endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Assets are their own transfer concern: a collection is a set of individually addressed binary files
|
|
7
|
+
* whose bytes travel as content-addressed **blobs** (uploaded/downloaded one at a time so a large
|
|
8
|
+
* collection never becomes one oversized request), while the collection **manifest** carries only
|
|
9
|
+
* metadata. Types only, no behavior.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|