handoff-app 1.2.0-0 → 1.2.0-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-builder/build.js +24 -10
- package/dist/app-builder/config-diff/index.d.ts +1 -1
- package/dist/app-builder/config-diff/registry.d.ts +2 -2
- package/dist/app-builder/config-diff/registry.js +2 -2
- package/dist/app-builder/config-diff/strategies/pattern.js +14 -1
- package/dist/app-builder/config-diff/types.d.ts +15 -1
- package/dist/app-builder/paths.js +18 -1
- package/dist/app-builder/watchers.js +35 -3
- package/dist/app-builder/websocket.js +10 -4
- package/dist/cli.js +1 -1
- package/dist/config/normalizers/pattern.d.ts +0 -1
- package/dist/config/normalizers/pattern.js +0 -3
- package/dist/config/runtime.js +10 -4
- package/dist/pipeline/patterns.d.ts +3 -1
- package/dist/pipeline/patterns.js +2 -2
- package/dist/transformers/plugins/csf-render.js +2 -1
- package/dist/transformers/plugins/ssr-render.js +2 -1
- package/dist/transformers/preview/component/api.d.ts +2 -13
- package/dist/transformers/preview/component/api.js +7 -46
- package/dist/transformers/preview/component/artifacts.d.ts +4 -0
- package/dist/transformers/preview/component/artifacts.js +126 -0
- package/dist/transformers/preview/component/builder.js +62 -6
- package/dist/transformers/preview/component/css.d.ts +2 -0
- package/dist/transformers/preview/component/css.js +25 -9
- package/dist/transformers/preview/component/javascript.d.ts +1 -1
- package/dist/transformers/preview/component/javascript.js +45 -19
- package/dist/transformers/preview/component/summary.d.ts +6 -0
- package/dist/transformers/preview/component/summary.js +55 -0
- package/dist/transformers/preview/component.js +3 -25
- package/dist/transformers/preview/pattern/api.d.ts +4 -0
- package/dist/transformers/preview/pattern/api.js +19 -1
- package/dist/transformers/preview/pattern/builder.d.ts +9 -1
- package/dist/transformers/preview/pattern/builder.js +123 -42
- package/dist/transformers/utils/vite-logger.js +4 -4
- package/dist/transformers/vite-config.js +2 -0
- package/dist/utils/duration.d.ts +2 -0
- package/dist/utils/duration.js +6 -0
- package/dist/utils/logger.d.ts +42 -5
- package/dist/utils/logger.js +135 -15
- package/package.json +1 -1
- package/src/app/pages/system/pattern/[pattern]/index.tsx +178 -55
- package/src/app-builder/build.ts +26 -10
- package/src/app-builder/config-diff/index.ts +1 -1
- package/src/app-builder/config-diff/registry.ts +3 -3
- package/src/app-builder/config-diff/strategies/pattern.ts +17 -2
- package/src/app-builder/config-diff/types.ts +16 -1
- package/src/app-builder/paths.ts +22 -1
- package/src/app-builder/watchers.ts +15 -3
- package/src/app-builder/websocket.ts +16 -5
- package/src/cli.ts +1 -1
- package/src/config/normalizers/pattern.ts +0 -7
- package/src/config/runtime.ts +11 -4
- package/src/pipeline/patterns.ts +5 -3
- package/src/transformers/plugins/csf-render.ts +2 -1
- package/src/transformers/plugins/ssr-render.ts +2 -1
- package/src/transformers/preview/component/api.ts +2 -50
- package/src/transformers/preview/component/artifacts.ts +131 -0
- package/src/transformers/preview/component/builder.ts +72 -6
- package/src/transformers/preview/component/css.ts +26 -10
- package/src/transformers/preview/component/javascript.ts +50 -23
- package/src/transformers/preview/component/summary.ts +54 -0
- package/src/transformers/preview/component.ts +2 -1
- package/src/transformers/preview/pattern/api.ts +17 -0
- package/src/transformers/preview/pattern/builder.ts +156 -58
- package/src/transformers/utils/vite-logger.ts +4 -4
- package/src/transformers/vite-config.ts +2 -0
- package/src/utils/duration.ts +3 -0
- package/src/utils/logger.ts +143 -16
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.syncComponentArtifacts = exports.removeComponentApi = exports.getComponentApiPath = void 0;
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const previews_1 = require("./previews");
|
|
19
|
+
const api_1 = require("./api");
|
|
20
|
+
const css_1 = require("./css");
|
|
21
|
+
const javascript_1 = require("./javascript");
|
|
22
|
+
const COMPONENT_JS_RESERVED_FILES = new Set([javascript_1.MAIN_COMPONENT_JS_FILE]);
|
|
23
|
+
const COMPONENT_CSS_RESERVED_FILES = new Set([css_1.MAIN_COMPONENT_CSS_FILE, css_1.SHARED_COMPONENT_CSS_FILE]);
|
|
24
|
+
const getComponentApiPath = (handoff) => path_1.default.resolve((0, api_1.getAPIPath)(handoff), 'component');
|
|
25
|
+
exports.getComponentApiPath = getComponentApiPath;
|
|
26
|
+
const getComponentPreviewKeys = (handoff, componentId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
const runtimeComponent = (_c = (_b = (_a = handoff.runtimeConfig) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c[componentId];
|
|
29
|
+
const previewKeys = new Set();
|
|
30
|
+
const outputFilePath = path_1.default.resolve((0, exports.getComponentApiPath)(handoff), `${componentId}.json`);
|
|
31
|
+
if (fs_extra_1.default.existsSync(outputFilePath)) {
|
|
32
|
+
try {
|
|
33
|
+
const existingJson = yield fs_extra_1.default.readFile(outputFilePath, 'utf8');
|
|
34
|
+
if (existingJson) {
|
|
35
|
+
const existingData = (0, api_1.sanitizeComponentApiData)(JSON.parse(existingJson));
|
|
36
|
+
for (const previewKey of Object.keys((existingData === null || existingData === void 0 ? void 0 : existingData.previews) || {})) {
|
|
37
|
+
previewKeys.add(previewKey);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (_d) {
|
|
42
|
+
// Fall back to runtime config below.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const previewKey of Object.keys((0, previews_1.getDocumentedPreviews)(runtimeComponent === null || runtimeComponent === void 0 ? void 0 : runtimeComponent.previews) || {})) {
|
|
46
|
+
previewKeys.add(previewKey);
|
|
47
|
+
}
|
|
48
|
+
for (const previewKey of Object.keys((runtimeComponent === null || runtimeComponent === void 0 ? void 0 : runtimeComponent.internalPatternPreviews) || {})) {
|
|
49
|
+
previewKeys.add(previewKey);
|
|
50
|
+
}
|
|
51
|
+
return previewKeys;
|
|
52
|
+
});
|
|
53
|
+
const getArtifactComponentId = (fileName, componentIds) => {
|
|
54
|
+
let match = null;
|
|
55
|
+
for (const componentId of componentIds) {
|
|
56
|
+
if (!fileName.startsWith(`${componentId}-`))
|
|
57
|
+
continue;
|
|
58
|
+
if (!match || componentId.length > match.length) {
|
|
59
|
+
match = componentId;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return match;
|
|
63
|
+
};
|
|
64
|
+
const removeComponentApi = (handoff, id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
const outputDirPath = (0, exports.getComponentApiPath)(handoff);
|
|
66
|
+
const outputFilePath = path_1.default.resolve(outputDirPath, `${id}.json`);
|
|
67
|
+
if (yield fs_extra_1.default.pathExists(outputFilePath)) {
|
|
68
|
+
yield fs_extra_1.default.remove(outputFilePath);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
exports.removeComponentApi = removeComponentApi;
|
|
72
|
+
const syncComponentArtifacts = (handoff) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
const componentPath = (0, exports.getComponentApiPath)(handoff);
|
|
75
|
+
yield fs_extra_1.default.ensureDir(componentPath);
|
|
76
|
+
const runtimeComponents = (_c = (_b = (_a = handoff.runtimeConfig) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.components) !== null && _c !== void 0 ? _c : {};
|
|
77
|
+
const runtimeIds = Object.keys(runtimeComponents);
|
|
78
|
+
const entries = yield fs_extra_1.default.readdir(componentPath);
|
|
79
|
+
const discoveredArtifactIds = new Set(runtimeIds);
|
|
80
|
+
for (const entry of entries) {
|
|
81
|
+
const parsed = path_1.default.parse(entry);
|
|
82
|
+
if (parsed.ext === '.json' || parsed.ext === '.js' || parsed.ext === '.css') {
|
|
83
|
+
if (!COMPONENT_JS_RESERVED_FILES.has(entry) && !COMPONENT_CSS_RESERVED_FILES.has(entry)) {
|
|
84
|
+
discoveredArtifactIds.add(parsed.name);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const validFiles = new Set();
|
|
89
|
+
for (const componentId of runtimeIds) {
|
|
90
|
+
validFiles.add(`${componentId}.json`);
|
|
91
|
+
if (yield fs_extra_1.default.pathExists(path_1.default.resolve(componentPath, `${componentId}.js`))) {
|
|
92
|
+
validFiles.add(`${componentId}.js`);
|
|
93
|
+
}
|
|
94
|
+
if (yield fs_extra_1.default.pathExists(path_1.default.resolve(componentPath, `${componentId}.css`))) {
|
|
95
|
+
validFiles.add(`${componentId}.css`);
|
|
96
|
+
}
|
|
97
|
+
const previewKeys = yield getComponentPreviewKeys(handoff, componentId);
|
|
98
|
+
for (const previewKey of previewKeys) {
|
|
99
|
+
validFiles.add(`${componentId}-${previewKey}.html`);
|
|
100
|
+
validFiles.add(`${componentId}-${previewKey}-inspect.html`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
for (const entry of entries) {
|
|
104
|
+
if (COMPONENT_JS_RESERVED_FILES.has(entry) || COMPONENT_CSS_RESERVED_FILES.has(entry)) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const parsed = path_1.default.parse(entry);
|
|
108
|
+
if (parsed.ext === '.json' || parsed.ext === '.js' || parsed.ext === '.css') {
|
|
109
|
+
if (!validFiles.has(entry)) {
|
|
110
|
+
yield fs_extra_1.default.remove(path_1.default.resolve(componentPath, entry));
|
|
111
|
+
}
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (parsed.ext !== '.html') {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const ownerId = getArtifactComponentId(entry, discoveredArtifactIds);
|
|
118
|
+
if (!ownerId) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (!validFiles.has(entry)) {
|
|
122
|
+
yield fs_extra_1.default.remove(path_1.default.resolve(componentPath, entry));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
exports.syncComponentArtifacts = syncComponentArtifacts;
|
|
@@ -27,11 +27,14 @@ exports.ComponentSegment = void 0;
|
|
|
27
27
|
exports.processComponents = processComponents;
|
|
28
28
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
29
29
|
const cache_1 = require("../../../cache");
|
|
30
|
+
const duration_1 = require("../../../utils/duration");
|
|
30
31
|
const logger_1 = require("../../../utils/logger");
|
|
31
32
|
const schema_1 = require("../../utils/schema");
|
|
32
33
|
const types_1 = require("../types");
|
|
33
34
|
const api_1 = require("./api");
|
|
35
|
+
const artifacts_1 = require("./artifacts");
|
|
34
36
|
const previews_1 = require("./previews");
|
|
37
|
+
const summary_1 = require("./summary");
|
|
35
38
|
const css_1 = __importDefault(require("./css"));
|
|
36
39
|
const html_1 = __importDefault(require("./html"));
|
|
37
40
|
const javascript_1 = __importDefault(require("./javascript"));
|
|
@@ -83,6 +86,37 @@ const ensureDefaultPreview = (data) => {
|
|
|
83
86
|
const getBuildPreviews = (data) => {
|
|
84
87
|
return Object.assign(Object.assign({}, ((data === null || data === void 0 ? void 0 : data.previews) || {})), ((data === null || data === void 0 ? void 0 : data.internalPatternPreviews) || {}));
|
|
85
88
|
};
|
|
89
|
+
/** Vite-backed segments in execution order; extend here if new steps are added. */
|
|
90
|
+
const VITE_BUILD_SEGMENTS = [
|
|
91
|
+
{ key: 'js', label: 'script' },
|
|
92
|
+
{ key: 'css', label: 'styles' },
|
|
93
|
+
{ key: 'previews', label: 'previews' },
|
|
94
|
+
];
|
|
95
|
+
const isFullViteComponentBuild = (plan) => plan.js && plan.css && plan.previews;
|
|
96
|
+
const getActiveViteBuildLabels = (plan) => VITE_BUILD_SEGMENTS.filter(({ key }) => plan[key]).map(({ label }) => label);
|
|
97
|
+
/** e.g. "a", "a and b", "a, b, and c" — common CLI copy style. */
|
|
98
|
+
const formatEnglishList = (items) => {
|
|
99
|
+
if (items.length === 0)
|
|
100
|
+
return '';
|
|
101
|
+
if (items.length === 1)
|
|
102
|
+
return items[0];
|
|
103
|
+
if (items.length === 2)
|
|
104
|
+
return `${items[0]} and ${items[1]}`;
|
|
105
|
+
return `${items.slice(0, -1).join(', ')}, and ${items[items.length - 1]}`;
|
|
106
|
+
};
|
|
107
|
+
const viteBuildStartMessage = (componentId, plan) => {
|
|
108
|
+
if (isFullViteComponentBuild(plan)) {
|
|
109
|
+
return `Building component "${componentId}"…`;
|
|
110
|
+
}
|
|
111
|
+
return `Building ${formatEnglishList(getActiveViteBuildLabels(plan))} for component "${componentId}"…`;
|
|
112
|
+
};
|
|
113
|
+
const viteBuildFinishMessage = (componentId, plan, elapsedMs) => {
|
|
114
|
+
const duration = (0, duration_1.formatDurationMs)(elapsedMs);
|
|
115
|
+
if (isFullViteComponentBuild(plan)) {
|
|
116
|
+
return `Finished building component "${componentId}" in ${duration}`;
|
|
117
|
+
}
|
|
118
|
+
return `Finished building ${formatEnglishList(getActiveViteBuildLabels(plan))} for component "${componentId}" in ${duration}`;
|
|
119
|
+
};
|
|
86
120
|
/**
|
|
87
121
|
* Returns a normalized build plan describing which component segments need rebuilding.
|
|
88
122
|
*
|
|
@@ -121,6 +155,12 @@ function processComponents(handoff, id, segmentToProcess, options) {
|
|
|
121
155
|
const components = (_a = documentationObject === null || documentationObject === void 0 ? void 0 : documentationObject.components) !== null && _a !== void 0 ? _a : {};
|
|
122
156
|
const runtimeComponents = (_d = (_c = (_b = handoff.runtimeConfig) === null || _b === void 0 ? void 0 : _b.entries) === null || _c === void 0 ? void 0 : _c.components) !== null && _d !== void 0 ? _d : {};
|
|
123
157
|
const allComponentIds = Object.keys(runtimeComponents);
|
|
158
|
+
if (id && !runtimeComponents[id]) {
|
|
159
|
+
yield (0, artifacts_1.removeComponentApi)(handoff, id);
|
|
160
|
+
yield (0, summary_1.removeComponentFromSummaryApi)(handoff, id);
|
|
161
|
+
yield (0, artifacts_1.syncComponentArtifacts)(handoff);
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
124
164
|
// Determine which components need building based on cache (when enabled)
|
|
125
165
|
let componentsToBuild;
|
|
126
166
|
let cache = null;
|
|
@@ -170,12 +210,17 @@ function processComponents(handoff, id, segmentToProcess, options) {
|
|
|
170
210
|
if (cache) {
|
|
171
211
|
(0, cache_1.pruneRemovedComponents)(cache, allComponentIds);
|
|
172
212
|
}
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
213
|
+
const total = allComponentIds.length;
|
|
214
|
+
const toBuildCount = componentsToBuild.size;
|
|
215
|
+
const skippedCount = total - toBuildCount;
|
|
216
|
+
if (total > 0 && toBuildCount === 0) {
|
|
217
|
+
logger_1.Logger.info(`All ${total} components unchanged; skipping build`);
|
|
218
|
+
}
|
|
219
|
+
else if (skippedCount > 0 && toBuildCount > 0) {
|
|
220
|
+
logger_1.Logger.info(`Building ${toBuildCount} of ${total} components (${skippedCount} unchanged)`);
|
|
176
221
|
}
|
|
177
|
-
else if (
|
|
178
|
-
logger_1.Logger.info(`Building all ${
|
|
222
|
+
else if (toBuildCount > 0) {
|
|
223
|
+
logger_1.Logger.info(`Building all ${toBuildCount} components`);
|
|
179
224
|
}
|
|
180
225
|
else {
|
|
181
226
|
logger_1.Logger.info('All components up to date, nothing to build');
|
|
@@ -266,6 +311,12 @@ function processComponents(handoff, id, segmentToProcess, options) {
|
|
|
266
311
|
}
|
|
267
312
|
// Components should always have at least one preview variation.
|
|
268
313
|
ensureDefaultPreview(data);
|
|
314
|
+
const runsViteBuildSteps = buildPlan.js || buildPlan.css || buildPlan.previews;
|
|
315
|
+
let viteBuildStartedAtMs = 0;
|
|
316
|
+
if (runsViteBuildSteps) {
|
|
317
|
+
viteBuildStartedAtMs = Date.now();
|
|
318
|
+
logger_1.Logger.info(viteBuildStartMessage(runtimeComponentId, buildPlan));
|
|
319
|
+
}
|
|
269
320
|
// Build JS if needed (new build, validation missing, or explicit segment request).
|
|
270
321
|
if (buildPlan.js) {
|
|
271
322
|
data = yield (0, javascript_1.default)(data, handoff);
|
|
@@ -278,6 +329,10 @@ function processComponents(handoff, id, segmentToProcess, options) {
|
|
|
278
329
|
if (buildPlan.previews) {
|
|
279
330
|
data = yield (0, html_1.default)(Object.assign(Object.assign({}, data), { previews: getBuildPreviews(data) }), handoff, components);
|
|
280
331
|
}
|
|
332
|
+
if (runsViteBuildSteps) {
|
|
333
|
+
const elapsedMs = Date.now() - viteBuildStartedAtMs;
|
|
334
|
+
logger_1.Logger.info(viteBuildFinishMessage(runtimeComponentId, buildPlan, elapsedMs));
|
|
335
|
+
}
|
|
281
336
|
/**
|
|
282
337
|
* Run validation if explicitly requested and a hook is configured.
|
|
283
338
|
* This allows custom logic to assess the validity of the generated component data.
|
|
@@ -320,7 +375,8 @@ function processComponents(handoff, id, segmentToProcess, options) {
|
|
|
320
375
|
}
|
|
321
376
|
// Always merge and write summary file, even if no components processed
|
|
322
377
|
const isFullRebuild = !id;
|
|
323
|
-
yield (0,
|
|
378
|
+
yield (0, summary_1.updateComponentSummaryApi)(handoff, result, isFullRebuild);
|
|
379
|
+
yield (0, artifacts_1.syncComponentArtifacts)(handoff);
|
|
324
380
|
return result;
|
|
325
381
|
});
|
|
326
382
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Handoff from '../../../index';
|
|
2
2
|
import { TransformComponentTokensResult } from '../types';
|
|
3
|
+
export declare const MAIN_COMPONENT_CSS_FILE = "main.css";
|
|
4
|
+
export declare const SHARED_COMPONENT_CSS_FILE = "shared.css";
|
|
3
5
|
declare const buildComponentCss: (data: TransformComponentTokensResult, handoff: Handoff) => Promise<{
|
|
4
6
|
id: string;
|
|
5
7
|
type?: import("../types").ComponentType;
|
|
@@ -12,15 +12,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.buildMainCss = void 0;
|
|
15
|
+
exports.buildMainCss = exports.SHARED_COMPONENT_CSS_FILE = exports.MAIN_COMPONENT_CSS_FILE = void 0;
|
|
16
16
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const vite_1 = require("vite");
|
|
19
19
|
const config_1 = require("../../../config");
|
|
20
|
+
const duration_1 = require("../../../utils/duration");
|
|
20
21
|
const logger_1 = require("../../../utils/logger");
|
|
21
22
|
const vite_config_1 = __importDefault(require("../../vite-config"));
|
|
22
23
|
const component_1 = require("../component");
|
|
23
24
|
const { pathToFileURL } = require('url');
|
|
25
|
+
exports.MAIN_COMPONENT_CSS_FILE = 'main.css';
|
|
26
|
+
exports.SHARED_COMPONENT_CSS_FILE = 'shared.css';
|
|
24
27
|
/**
|
|
25
28
|
* Builds a CSS bundle using Vite
|
|
26
29
|
*
|
|
@@ -90,17 +93,26 @@ const buildComponentCss = (data, handoff) => __awaiter(void 0, void 0, void 0, f
|
|
|
90
93
|
var _a, _b, _c;
|
|
91
94
|
const id = data.id;
|
|
92
95
|
logger_1.Logger.debug(`buildComponentCss`, id);
|
|
96
|
+
const outputPath = (0, component_1.getComponentOutputPath)(handoff);
|
|
97
|
+
const builtCssPath = path_1.default.resolve(outputPath, `${id}.css`);
|
|
93
98
|
const entry = (_a = data.entries) === null || _a === void 0 ? void 0 : _a.scss;
|
|
94
99
|
if (!entry) {
|
|
100
|
+
// Keep generated output aligned with the current component declaration.
|
|
101
|
+
yield fs_extra_1.default.remove(builtCssPath);
|
|
102
|
+
delete data['css'];
|
|
103
|
+
delete data['sass'];
|
|
104
|
+
delete data['sharedStyles'];
|
|
95
105
|
return data;
|
|
96
106
|
}
|
|
97
107
|
const extension = path_1.default.extname(entry);
|
|
98
108
|
if (!extension) {
|
|
99
109
|
return data;
|
|
100
110
|
}
|
|
101
|
-
const outputPath = (0, component_1.getComponentOutputPath)(handoff);
|
|
102
111
|
try {
|
|
103
112
|
if (extension === '.scss' || extension === '.css') {
|
|
113
|
+
// Remove the previous artifact before rebuilding so "no emitted CSS"
|
|
114
|
+
// doesn't silently preserve stale output from an earlier build.
|
|
115
|
+
yield fs_extra_1.default.remove(builtCssPath);
|
|
104
116
|
// Read the original source
|
|
105
117
|
const sourceContent = yield fs_extra_1.default.readFile(entry, 'utf8');
|
|
106
118
|
if (extension === '.scss') {
|
|
@@ -123,7 +135,6 @@ const buildComponentCss = (data, handoff) => __awaiter(void 0, void 0, void 0, f
|
|
|
123
135
|
handoff,
|
|
124
136
|
});
|
|
125
137
|
// Read the built CSS
|
|
126
|
-
const builtCssPath = path_1.default.resolve(outputPath, `${id}.css`);
|
|
127
138
|
if (fs_extra_1.default.existsSync(builtCssPath)) {
|
|
128
139
|
const builtCss = yield fs_extra_1.default.readFile(builtCssPath, 'utf8');
|
|
129
140
|
data['css'] = builtCss;
|
|
@@ -133,9 +144,13 @@ const buildComponentCss = (data, handoff) => __awaiter(void 0, void 0, void 0, f
|
|
|
133
144
|
if (splitCSS && splitCSS.length > 1) {
|
|
134
145
|
data['css'] = splitCSS[1];
|
|
135
146
|
data['sharedStyles'] = splitCSS[0];
|
|
136
|
-
yield fs_extra_1.default.writeFile(path_1.default.resolve(outputPath,
|
|
147
|
+
yield fs_extra_1.default.writeFile(path_1.default.resolve(outputPath, exports.SHARED_COMPONENT_CSS_FILE), data['sharedStyles']);
|
|
137
148
|
}
|
|
138
149
|
}
|
|
150
|
+
else {
|
|
151
|
+
delete data['css'];
|
|
152
|
+
delete data['sharedStyles'];
|
|
153
|
+
}
|
|
139
154
|
}
|
|
140
155
|
}
|
|
141
156
|
catch (e) {
|
|
@@ -155,9 +170,9 @@ const buildMainCss = (handoff) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
155
170
|
const stat = yield fs_extra_1.default.stat(runtimeConfig.entries.scss);
|
|
156
171
|
const entryPath = stat.isDirectory() ? path_1.default.resolve(runtimeConfig.entries.scss, 'main.scss') : runtimeConfig.entries.scss;
|
|
157
172
|
if (entryPath === runtimeConfig.entries.scss || fs_extra_1.default.existsSync(entryPath)) {
|
|
158
|
-
logger_1.Logger.
|
|
173
|
+
logger_1.Logger.info(`Building styles for global entry (${exports.MAIN_COMPONENT_CSS_FILE})…`);
|
|
174
|
+
const startedAt = Date.now();
|
|
159
175
|
try {
|
|
160
|
-
// Setup SASS load paths
|
|
161
176
|
const loadPaths = [
|
|
162
177
|
path_1.default.resolve(handoff.workingPath),
|
|
163
178
|
path_1.default.resolve(handoff.workingPath, handoff.exportsDirectory, handoff.getProjectId()),
|
|
@@ -169,13 +184,14 @@ const buildMainCss = (handoff) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
169
184
|
yield buildCssBundle({
|
|
170
185
|
entry: entryPath,
|
|
171
186
|
outputPath,
|
|
172
|
-
outputFilename:
|
|
187
|
+
outputFilename: exports.MAIN_COMPONENT_CSS_FILE,
|
|
173
188
|
loadPaths,
|
|
174
189
|
handoff,
|
|
175
190
|
});
|
|
191
|
+
logger_1.Logger.info(`Finished building styles for global entry (${exports.MAIN_COMPONENT_CSS_FILE}) in ${(0, duration_1.formatDurationMs)(Date.now() - startedAt)}`);
|
|
176
192
|
}
|
|
177
|
-
catch (
|
|
178
|
-
|
|
193
|
+
catch (_d) {
|
|
194
|
+
// buildCssBundle already logs failure for the entry path
|
|
179
195
|
}
|
|
180
196
|
}
|
|
181
197
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Handoff from '../../../index';
|
|
2
2
|
import { TransformComponentTokensResult } from '../types';
|
|
3
|
+
export declare const MAIN_COMPONENT_JS_FILE = "main.js";
|
|
3
4
|
/**
|
|
4
5
|
* Builds the JavaScript file for a single component if it exists.
|
|
5
6
|
* Reads the component JavaScript file, bundles it using the buildJsBundle utility,
|
|
@@ -18,7 +19,6 @@ export declare const buildComponentJs: (data: TransformComponentTokensResult, ha
|
|
|
18
19
|
*
|
|
19
20
|
* @param handoff - The Handoff configuration object containing build settings
|
|
20
21
|
* @returns A Promise that resolves when the build process is complete
|
|
21
|
-
* @throws May throw an error if the build process fails
|
|
22
22
|
*/
|
|
23
23
|
export declare const buildMainJS: (handoff: Handoff) => Promise<void>;
|
|
24
24
|
export default buildComponentJs;
|
|
@@ -12,14 +12,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.buildMainJS = exports.buildComponentJs = void 0;
|
|
15
|
+
exports.buildMainJS = exports.buildComponentJs = exports.MAIN_COMPONENT_JS_FILE = void 0;
|
|
16
16
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const vite_1 = require("vite");
|
|
19
19
|
const config_1 = require("../../../config");
|
|
20
|
+
const duration_1 = require("../../../utils/duration");
|
|
20
21
|
const logger_1 = require("../../../utils/logger");
|
|
21
22
|
const vite_config_1 = __importDefault(require("../../vite-config"));
|
|
22
23
|
const component_1 = require("../component");
|
|
24
|
+
exports.MAIN_COMPONENT_JS_FILE = 'main.js';
|
|
23
25
|
/**
|
|
24
26
|
* Builds a JavaScript bundle using Vite
|
|
25
27
|
*
|
|
@@ -50,9 +52,6 @@ const buildJsBundle = (_a, handoff_1) => __awaiter(void 0, [_a, handoff_1], void
|
|
|
50
52
|
}
|
|
51
53
|
yield (0, vite_1.build)(viteConfig);
|
|
52
54
|
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
logger_1.Logger.error(`Failed to build JS for "${outputFilename}":`, e);
|
|
55
|
-
}
|
|
56
55
|
finally {
|
|
57
56
|
// Restore the original NODE_ENV value after vite build completes
|
|
58
57
|
// This prevents interference with Next.js app building/running processes
|
|
@@ -77,20 +76,40 @@ const buildJsBundle = (_a, handoff_1) => __awaiter(void 0, [_a, handoff_1], void
|
|
|
77
76
|
const buildComponentJs = (data, handoff) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
77
|
var _a;
|
|
79
78
|
const id = data.id;
|
|
79
|
+
const outputPath = (0, component_1.getComponentOutputPath)(handoff);
|
|
80
|
+
const builtJsPath = path_1.default.resolve(outputPath, `${id}.js`);
|
|
80
81
|
const entry = (_a = data.entries) === null || _a === void 0 ? void 0 : _a.js;
|
|
81
|
-
if (!entry)
|
|
82
|
+
if (!entry) {
|
|
83
|
+
// Keep generated output aligned with the current component declaration.
|
|
84
|
+
yield fs_extra_1.default.remove(builtJsPath);
|
|
85
|
+
delete data.js;
|
|
86
|
+
delete data['jsCompiled'];
|
|
82
87
|
return data;
|
|
83
|
-
|
|
88
|
+
}
|
|
84
89
|
try {
|
|
90
|
+
// Remove the previous artifact before rebuilding so a no-output build
|
|
91
|
+
// cannot accidentally preserve stale compiled JS.
|
|
92
|
+
yield fs_extra_1.default.remove(builtJsPath);
|
|
85
93
|
const js = yield fs_extra_1.default.readFile(path_1.default.resolve(entry), 'utf8');
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
try {
|
|
95
|
+
yield buildJsBundle({
|
|
96
|
+
entry,
|
|
97
|
+
outputPath,
|
|
98
|
+
outputFilename: `${id}.js`,
|
|
99
|
+
}, handoff);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
logger_1.Logger.error(`Failed to bundle JS for component "${id}" (${id}.js):`, e);
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
91
105
|
data.js = js;
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
if (yield fs_extra_1.default.pathExists(builtJsPath)) {
|
|
107
|
+
const compiled = yield fs_extra_1.default.readFile(builtJsPath, 'utf8');
|
|
108
|
+
data['jsCompiled'] = compiled;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
delete data['jsCompiled'];
|
|
112
|
+
}
|
|
94
113
|
}
|
|
95
114
|
catch (e) {
|
|
96
115
|
logger_1.Logger.error(`JS build failed for component "${id}":`, e);
|
|
@@ -106,17 +125,24 @@ exports.buildComponentJs = buildComponentJs;
|
|
|
106
125
|
*
|
|
107
126
|
* @param handoff - The Handoff configuration object containing build settings
|
|
108
127
|
* @returns A Promise that resolves when the build process is complete
|
|
109
|
-
* @throws May throw an error if the build process fails
|
|
110
128
|
*/
|
|
111
129
|
const buildMainJS = (handoff) => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
130
|
const outputPath = (0, component_1.getComponentOutputPath)(handoff);
|
|
113
131
|
const runtimeConfig = (0, config_1.initRuntimeConfig)(handoff)[0];
|
|
114
132
|
if (runtimeConfig && runtimeConfig.entries.js && fs_extra_1.default.existsSync(path_1.default.resolve(runtimeConfig.entries.js))) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
133
|
+
logger_1.Logger.info(`Building script for global entry (${exports.MAIN_COMPONENT_JS_FILE})…`);
|
|
134
|
+
const startedAt = Date.now();
|
|
135
|
+
try {
|
|
136
|
+
yield buildJsBundle({
|
|
137
|
+
entry: runtimeConfig.entries.js,
|
|
138
|
+
outputPath,
|
|
139
|
+
outputFilename: exports.MAIN_COMPONENT_JS_FILE,
|
|
140
|
+
}, handoff);
|
|
141
|
+
logger_1.Logger.info(`Finished building script for global entry (${exports.MAIN_COMPONENT_JS_FILE}) in ${(0, duration_1.formatDurationMs)(Date.now() - startedAt)}`);
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
logger_1.Logger.error(`Failed to build global script (${exports.MAIN_COMPONENT_JS_FILE}):`, e);
|
|
145
|
+
}
|
|
120
146
|
}
|
|
121
147
|
});
|
|
122
148
|
exports.buildMainJS = buildMainJS;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Handoff from '../../../index';
|
|
2
|
+
import { ComponentListObject } from '../types';
|
|
3
|
+
declare const writeComponentSummaryAPI: (handoff: Handoff, componentData: ComponentListObject[]) => Promise<void>;
|
|
4
|
+
export declare const updateComponentSummaryApi: (handoff: Handoff, componentData: ComponentListObject[], isFullRebuild?: boolean) => Promise<void>;
|
|
5
|
+
export declare const removeComponentFromSummaryApi: (handoff: Handoff, id: string) => Promise<void>;
|
|
6
|
+
export default writeComponentSummaryAPI;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.removeComponentFromSummaryApi = exports.updateComponentSummaryApi = void 0;
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const previews_1 = require("./previews");
|
|
19
|
+
const api_1 = require("./api");
|
|
20
|
+
const getComponentSummaryPath = (handoff) => path_1.default.resolve((0, api_1.getAPIPath)(handoff), 'components.json');
|
|
21
|
+
const writeComponentSummaryAPI = (handoff, componentData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
componentData.sort((a, b) => a.title.localeCompare(b.title));
|
|
23
|
+
yield fs_extra_1.default.writeFile(getComponentSummaryPath(handoff), JSON.stringify(componentData, null, 2));
|
|
24
|
+
});
|
|
25
|
+
const readExistingComponentSummaryApi = (handoff) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
const apiPath = getComponentSummaryPath(handoff);
|
|
27
|
+
if (!fs_extra_1.default.existsSync(apiPath)) {
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const existing = yield fs_extra_1.default.readFile(apiPath, 'utf8');
|
|
32
|
+
return JSON.parse(existing).map((component) => (Object.assign(Object.assign({}, component), { previews: (0, previews_1.getDocumentedPreviews)(component.previews) })));
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const updateComponentSummaryApi = (handoff_1, componentData_1, ...args_1) => __awaiter(void 0, [handoff_1, componentData_1, ...args_1], void 0, function* (handoff, componentData, isFullRebuild = false) {
|
|
39
|
+
if (isFullRebuild) {
|
|
40
|
+
yield writeComponentSummaryAPI(handoff, componentData);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const existingData = yield readExistingComponentSummaryApi(handoff);
|
|
44
|
+
const incomingIds = new Set(componentData.map((c) => c.id));
|
|
45
|
+
const merged = [...componentData, ...existingData.filter((c) => !incomingIds.has(c.id))];
|
|
46
|
+
yield writeComponentSummaryAPI(handoff, merged);
|
|
47
|
+
});
|
|
48
|
+
exports.updateComponentSummaryApi = updateComponentSummaryApi;
|
|
49
|
+
const removeComponentFromSummaryApi = (handoff, id) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const existingData = yield readExistingComponentSummaryApi(handoff);
|
|
51
|
+
const filtered = existingData.filter((component) => component.id !== id);
|
|
52
|
+
yield writeComponentSummaryAPI(handoff, filtered);
|
|
53
|
+
});
|
|
54
|
+
exports.removeComponentFromSummaryApi = removeComponentFromSummaryApi;
|
|
55
|
+
exports.default = writeComponentSummaryAPI;
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -38,7 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
15
|
exports.getComponentOutputPath = exports.SlotType = void 0;
|
|
39
16
|
exports.componentTransformer = componentTransformer;
|
|
40
17
|
const path_1 = __importDefault(require("path"));
|
|
41
|
-
const api_1 =
|
|
18
|
+
const api_1 = require("./component/api");
|
|
19
|
+
const summary_1 = __importDefault(require("./component/summary"));
|
|
42
20
|
const builder_1 = __importDefault(require("./component/builder"));
|
|
43
21
|
const css_1 = require("./component/css");
|
|
44
22
|
const javascript_1 = require("./component/javascript");
|
|
@@ -66,7 +44,7 @@ exports.getComponentOutputPath = getComponentOutputPath;
|
|
|
66
44
|
function componentTransformer(handoff) {
|
|
67
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
46
|
const componentData = yield (0, builder_1.default)(handoff);
|
|
69
|
-
yield (0,
|
|
47
|
+
yield (0, summary_1.default)(handoff, componentData);
|
|
70
48
|
yield (0, javascript_1.buildMainJS)(handoff);
|
|
71
49
|
yield (0, css_1.buildMainCss)(handoff);
|
|
72
50
|
});
|
|
@@ -4,4 +4,8 @@ export declare const getPatternAPIPath: (handoff: Handoff) => string;
|
|
|
4
4
|
export declare const writePatternApi: (id: string, pattern: PatternObject, handoff: Handoff) => Promise<void>;
|
|
5
5
|
export declare const writePatternHtml: (id: string, html: string, handoff: Handoff) => Promise<void>;
|
|
6
6
|
export declare const writePatternSummaryApi: (handoff: Handoff, patterns: PatternListObject[]) => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Reads the pattern list summary when present (used for partial pattern rebuilds).
|
|
9
|
+
*/
|
|
10
|
+
export declare const readPatternSummaryApi: (handoff: Handoff) => Promise<PatternListObject[] | null>;
|
|
7
11
|
export declare const syncPatternArtifacts: (handoff: Handoff, validIds: Iterable<string>) => Promise<void>;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.syncPatternArtifacts = exports.writePatternSummaryApi = exports.writePatternHtml = exports.writePatternApi = exports.getPatternAPIPath = void 0;
|
|
15
|
+
exports.syncPatternArtifacts = exports.readPatternSummaryApi = exports.writePatternSummaryApi = exports.writePatternHtml = exports.writePatternApi = exports.getPatternAPIPath = void 0;
|
|
16
16
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const getPatternAPIPath = (handoff) => {
|
|
@@ -44,6 +44,24 @@ const writePatternSummaryApi = (handoff, patterns) => __awaiter(void 0, void 0,
|
|
|
44
44
|
yield fs_extra_1.default.writeFile(path_1.default.resolve(apiPath, 'patterns.json'), JSON.stringify(patterns, null, 2));
|
|
45
45
|
});
|
|
46
46
|
exports.writePatternSummaryApi = writePatternSummaryApi;
|
|
47
|
+
/**
|
|
48
|
+
* Reads the pattern list summary when present (used for partial pattern rebuilds).
|
|
49
|
+
*/
|
|
50
|
+
const readPatternSummaryApi = (handoff) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
const summaryPath = path_1.default.resolve(handoff.workingPath, 'public/api/patterns.json');
|
|
52
|
+
if (!fs_extra_1.default.existsSync(summaryPath)) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const raw = yield fs_extra_1.default.readFile(summaryPath, 'utf8');
|
|
57
|
+
const parsed = JSON.parse(raw);
|
|
58
|
+
return Array.isArray(parsed) ? parsed : null;
|
|
59
|
+
}
|
|
60
|
+
catch (_a) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
exports.readPatternSummaryApi = readPatternSummaryApi;
|
|
47
65
|
const syncPatternArtifacts = (handoff, validIds) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
66
|
const validIdSet = new Set(validIds);
|
|
49
67
|
const patternPath = (0, exports.getPatternAPIPath)(handoff);
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import Handoff from '../../../index';
|
|
2
2
|
import { PatternListObject } from '../types';
|
|
3
|
+
export type ProcessPatternsOptions = {
|
|
4
|
+
/** When set, only these pattern ids are recomposed; others keep existing artifacts. */
|
|
5
|
+
onlyPatternIds?: Set<string>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Returns pattern ids whose declarations reference any of the given component ids.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getPatternIdsReferencingComponents: (handoff: Handoff, componentIds: string[]) => string[];
|
|
3
11
|
/**
|
|
4
12
|
* Process all pattern declarations and compose their HTML from pre-built
|
|
5
13
|
* component preview files. This function must run AFTER buildComponents
|
|
6
14
|
* so that all component preview HTML files already exist on disk.
|
|
7
15
|
*/
|
|
8
|
-
export declare function processPatterns(handoff: Handoff): Promise<PatternListObject[]>;
|
|
16
|
+
export declare function processPatterns(handoff: Handoff, options?: ProcessPatternsOptions): Promise<PatternListObject[]>;
|
|
9
17
|
export default processPatterns;
|