veryfront 0.1.91 → 0.1.93
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/esm/cli/commands/styles/command-help.d.ts +3 -0
- package/esm/cli/commands/styles/command-help.d.ts.map +1 -0
- package/esm/cli/commands/styles/command-help.js +19 -0
- package/esm/cli/commands/styles/command.d.ts +3 -0
- package/esm/cli/commands/styles/command.d.ts.map +1 -0
- package/esm/cli/commands/styles/command.js +198 -0
- package/esm/cli/commands/styles/handler.d.ts +24 -0
- package/esm/cli/commands/styles/handler.d.ts.map +1 -0
- package/esm/cli/commands/styles/handler.js +17 -0
- package/esm/cli/help/command-definitions.d.ts.map +1 -1
- package/esm/cli/help/command-definitions.js +2 -0
- package/esm/cli/router.d.ts.map +1 -1
- package/esm/cli/router.js +2 -0
- package/esm/deno.d.ts +1 -0
- package/esm/deno.js +2 -1
- package/esm/src/config/environment-config.js +1 -1
- package/esm/src/html/styles-builder/css-pregeneration.d.ts +9 -0
- package/esm/src/html/styles-builder/css-pregeneration.d.ts.map +1 -1
- package/esm/src/html/styles-builder/css-pregeneration.js +26 -15
- package/esm/src/jobs/schemas.d.ts +54 -54
- package/esm/src/jobs/schemas.js +3 -3
- package/esm/src/observability/metrics/manager.js +2 -2
- package/esm/src/observability/tracing/otlp-setup.js +2 -2
- package/esm/src/platform/adapters/fs/veryfront/adapter.d.ts +1 -0
- package/esm/src/platform/adapters/fs/veryfront/adapter.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/adapter.js +11 -5
- package/esm/src/platform/adapters/veryfront-api-client/client.d.ts +2 -1
- package/esm/src/platform/adapters/veryfront-api-client/client.d.ts.map +1 -1
- package/esm/src/platform/adapters/veryfront-api-client/client.js +3 -0
- package/esm/src/platform/adapters/veryfront-api-client/index.d.ts +1 -1
- package/esm/src/platform/adapters/veryfront-api-client/index.d.ts.map +1 -1
- package/esm/src/platform/adapters/veryfront-api-client/operations.d.ts +11 -2
- package/esm/src/platform/adapters/veryfront-api-client/operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/veryfront-api-client/operations.js +30 -0
- package/esm/src/platform/adapters/veryfront-api-client/schemas/api.schema.d.ts +14 -3
- package/esm/src/platform/adapters/veryfront-api-client/schemas/api.schema.d.ts.map +1 -1
- package/esm/src/platform/adapters/veryfront-api-client/schemas/api.schema.js +8 -1
- package/esm/src/proxy/logger.d.ts.map +1 -1
- package/esm/src/proxy/logger.js +2 -6
- package/esm/src/proxy/tracing.d.ts.map +1 -1
- package/esm/src/proxy/tracing.js +2 -5
- package/esm/src/proxy/version.d.ts +2 -0
- package/esm/src/proxy/version.d.ts.map +1 -0
- package/esm/src/proxy/version.js +18 -0
- package/esm/src/rendering/styles.d.ts +9 -0
- package/esm/src/rendering/styles.d.ts.map +1 -0
- package/esm/src/rendering/styles.js +8 -0
- package/esm/src/sandbox/index.d.ts +1 -1
- package/esm/src/sandbox/index.d.ts.map +1 -1
- package/esm/src/sandbox/sandbox.d.ts +14 -3
- package/esm/src/sandbox/sandbox.d.ts.map +1 -1
- package/esm/src/sandbox/sandbox.js +20 -6
- package/esm/src/security/http/base-handler.d.ts.map +1 -1
- package/esm/src/security/http/base-handler.js +5 -2
- package/esm/src/server/context/request-context.d.ts.map +1 -1
- package/esm/src/server/context/request-context.js +4 -2
- package/esm/src/server/handlers/dev/styles-css.handler.d.ts +2 -0
- package/esm/src/server/handlers/dev/styles-css.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/styles-css.handler.js +23 -0
- package/esm/src/server/handlers/monitoring/health.handler.js +2 -2
- package/esm/src/server/handlers/preview/markdown-preview.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/preview/markdown-preview.handler.js +4 -2
- package/esm/src/server/handlers/request/css.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/css.handler.js +4 -2
- package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/ssr/ssr.handler.js +4 -2
- package/esm/src/utils/logger/logger.js +2 -2
- package/esm/src/utils/version.d.ts +9 -1
- package/esm/src/utils/version.d.ts.map +1 -1
- package/esm/src/utils/version.js +29 -2
- package/package.json +1 -1
- package/src/cli/commands/styles/command-help.ts +21 -0
- package/src/cli/commands/styles/command.ts +296 -0
- package/src/cli/commands/styles/handler.ts +23 -0
- package/src/cli/help/command-definitions.ts +2 -0
- package/src/cli/router.ts +2 -0
- package/src/deno.js +2 -1
- package/src/src/config/environment-config.ts +1 -1
- package/src/src/html/styles-builder/css-pregeneration.ts +57 -29
- package/src/src/jobs/schemas.ts +3 -3
- package/src/src/observability/metrics/manager.ts +2 -2
- package/src/src/observability/tracing/otlp-setup.ts +2 -2
- package/src/src/platform/adapters/fs/veryfront/adapter.ts +12 -5
- package/src/src/platform/adapters/veryfront-api-client/client.ts +8 -0
- package/src/src/platform/adapters/veryfront-api-client/index.ts +1 -0
- package/src/src/platform/adapters/veryfront-api-client/operations.ts +48 -2
- package/src/src/platform/adapters/veryfront-api-client/schemas/api.schema.ts +9 -1
- package/src/src/proxy/logger.ts +2 -8
- package/src/src/proxy/tracing.ts +2 -6
- package/src/src/proxy/version.ts +21 -0
- package/src/src/rendering/styles.ts +15 -0
- package/src/src/sandbox/index.ts +1 -0
- package/src/src/sandbox/sandbox.ts +33 -6
- package/src/src/security/http/base-handler.ts +5 -2
- package/src/src/server/context/request-context.ts +4 -2
- package/src/src/server/handlers/dev/styles-css.handler.ts +31 -0
- package/src/src/server/handlers/monitoring/health.handler.ts +2 -2
- package/src/src/server/handlers/preview/markdown-preview.handler.ts +4 -2
- package/src/src/server/handlers/request/css.handler.ts +4 -2
- package/src/src/server/handlers/request/ssr/ssr.handler.ts +4 -2
- package/src/src/utils/logger/logger.ts +2 -2
- package/src/src/utils/version.ts +37 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-help.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/styles/command-help.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,eAAO,MAAM,UAAU,EAAE,WAkBxB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const stylesHelp = {
|
|
2
|
+
name: "styles",
|
|
3
|
+
description: "Build project CSS artifacts",
|
|
4
|
+
usage: "veryfront styles build-artifact --config <json>",
|
|
5
|
+
options: [
|
|
6
|
+
{
|
|
7
|
+
flag: "--config <json>",
|
|
8
|
+
description: "JSON build config with exactly one selector and an optional style_profile_hash",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
flag: "--debug",
|
|
12
|
+
description: "Enable debug logging",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
examples: [
|
|
16
|
+
'veryfront styles build-artifact --config \'{"branch":"main"}\'',
|
|
17
|
+
'veryfront styles build-artifact --config \'{"style_profile_hash":"profile-1","environment_name":"Production"}\'',
|
|
18
|
+
],
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/styles/command.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA2K/C,wBAAsB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CA4GtE"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { getConfig } from "../../../src/config/index.js";
|
|
4
|
+
import { enhanceAdapterWithFS, getEnv, isExtendedFSAdapter, runtime, } from "../../../src/platform/index.js";
|
|
5
|
+
import { buildPreparedCSSArtifactFromFiles, createStyleScopeProfile, resolveStyleContentVersion, } from "../../../src/rendering/styles.js";
|
|
6
|
+
import { cliLogger, exitProcess } from "../../utils/index.js";
|
|
7
|
+
import { writeJobResultIfConfigured } from "../../utils/write-job-result.js";
|
|
8
|
+
const StyleArtifactBuildConfigSchema = z.object({
|
|
9
|
+
style_profile_hash: z.string().min(1).optional(),
|
|
10
|
+
branch: z.string().min(1).optional(),
|
|
11
|
+
environment_name: z.string().min(1).optional(),
|
|
12
|
+
release_id: z.string().min(1).optional(),
|
|
13
|
+
}).superRefine((value, ctx) => {
|
|
14
|
+
const selectorCount = [value.branch, value.environment_name, value.release_id].filter(Boolean)
|
|
15
|
+
.length;
|
|
16
|
+
if (selectorCount !== 1) {
|
|
17
|
+
ctx.addIssue({
|
|
18
|
+
code: z.ZodIssueCode.custom,
|
|
19
|
+
message: "Exactly one of branch, environment_name, or release_id is required.",
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function parseStyleArtifactBuildConfig(rawConfig) {
|
|
24
|
+
if (!rawConfig) {
|
|
25
|
+
throw new Error("Missing --config JSON");
|
|
26
|
+
}
|
|
27
|
+
let parsed;
|
|
28
|
+
try {
|
|
29
|
+
parsed = JSON.parse(rawConfig);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
throw new Error("Invalid --config JSON");
|
|
33
|
+
}
|
|
34
|
+
return StyleArtifactBuildConfigSchema.parse(parsed);
|
|
35
|
+
}
|
|
36
|
+
function resolveStyleArtifactSelector(config) {
|
|
37
|
+
if (config.branch) {
|
|
38
|
+
return {
|
|
39
|
+
branch: config.branch,
|
|
40
|
+
type: "branch",
|
|
41
|
+
value: config.branch,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (config.environment_name) {
|
|
45
|
+
return {
|
|
46
|
+
environmentName: config.environment_name,
|
|
47
|
+
type: "environment",
|
|
48
|
+
value: config.environment_name,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
releaseId: config.release_id,
|
|
53
|
+
type: "release",
|
|
54
|
+
value: config.release_id,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function resolveContentContextSelector(selector) {
|
|
58
|
+
if (selector.type === "branch") {
|
|
59
|
+
return { type: "branch", branch: selector.branch };
|
|
60
|
+
}
|
|
61
|
+
if (selector.type === "environment") {
|
|
62
|
+
return { type: "environment", name: selector.environmentName };
|
|
63
|
+
}
|
|
64
|
+
return { type: "release", releaseId: selector.releaseId };
|
|
65
|
+
}
|
|
66
|
+
function requireEnv(name) {
|
|
67
|
+
const value = getEnv(name)?.trim();
|
|
68
|
+
if (!value) {
|
|
69
|
+
throw new Error(`${name} is required`);
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
function getUnderlyingVeryfrontClient(adapter) {
|
|
74
|
+
if (!isExtendedFSAdapter(adapter.fs)) {
|
|
75
|
+
throw new Error("Styles build requires a Veryfront FS adapter");
|
|
76
|
+
}
|
|
77
|
+
const fsAdapter = adapter.fs.getUnderlyingAdapter();
|
|
78
|
+
if (typeof fsAdapter.getAllSourceFiles !== "function" ||
|
|
79
|
+
typeof fsAdapter.getClient !== "function") {
|
|
80
|
+
throw new Error("Styles build requires a Veryfront source adapter");
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
client: fsAdapter.getClient(),
|
|
84
|
+
contentContext: typeof fsAdapter.getContentContext === "function"
|
|
85
|
+
? fsAdapter.getContentContext()
|
|
86
|
+
: null,
|
|
87
|
+
getAllSourceFiles: fsAdapter.getAllSourceFiles,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async function markStyleArtifactFailed(client, selector, styleProfileHash, error) {
|
|
91
|
+
if (!client || !styleProfileHash)
|
|
92
|
+
return;
|
|
93
|
+
try {
|
|
94
|
+
await client.upsertStyleArtifact({
|
|
95
|
+
...(selector.type === "branch" ? { branch: selector.branch } : {}),
|
|
96
|
+
...(selector.type === "environment" ? { environmentName: selector.environmentName } : {}),
|
|
97
|
+
...(selector.type === "release" ? { releaseId: selector.releaseId } : {}),
|
|
98
|
+
styleProfileHash,
|
|
99
|
+
status: "failed",
|
|
100
|
+
failureReason: error,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (updateError) {
|
|
104
|
+
cliLogger.warn("Failed to mark style artifact as failed", updateError);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export async function stylesCommand(options) {
|
|
108
|
+
const buildConfig = parseStyleArtifactBuildConfig(options.config);
|
|
109
|
+
const selector = resolveStyleArtifactSelector(buildConfig);
|
|
110
|
+
const projectSlug = requireEnv("VERYFRONT_PROJECT_SLUG");
|
|
111
|
+
const apiToken = requireEnv("VERYFRONT_API_TOKEN");
|
|
112
|
+
const apiBaseUrl = requireEnv("VERYFRONT_API_BASE_URL");
|
|
113
|
+
const projectId = getEnv("VERYFRONT_PROJECT_ID")?.trim();
|
|
114
|
+
const projectDir = dntShim.Deno.cwd();
|
|
115
|
+
const baseAdapter = await runtime.get();
|
|
116
|
+
const adapter = await enhanceAdapterWithFS(baseAdapter, {
|
|
117
|
+
fs: {
|
|
118
|
+
type: "veryfront-api",
|
|
119
|
+
projectDir,
|
|
120
|
+
veryfront: {
|
|
121
|
+
apiBaseUrl,
|
|
122
|
+
apiToken,
|
|
123
|
+
projectSlug,
|
|
124
|
+
projectId,
|
|
125
|
+
contentSource: resolveContentContextSelector(selector),
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
}, projectDir);
|
|
129
|
+
let client = null;
|
|
130
|
+
let resolvedStyleProfileHash = buildConfig.style_profile_hash ?? null;
|
|
131
|
+
try {
|
|
132
|
+
const sourceAdapter = getUnderlyingVeryfrontClient(adapter);
|
|
133
|
+
client = sourceAdapter.client;
|
|
134
|
+
const cacheKey = projectId || projectSlug;
|
|
135
|
+
const config = await getConfig(projectDir, adapter, { cacheKey });
|
|
136
|
+
const styleProfile = createStyleScopeProfile(config);
|
|
137
|
+
resolvedStyleProfileHash = styleProfile.hash;
|
|
138
|
+
if (buildConfig.style_profile_hash && styleProfile.hash !== buildConfig.style_profile_hash) {
|
|
139
|
+
const message = `Style profile hash mismatch: expected ${buildConfig.style_profile_hash}, got ${styleProfile.hash}`;
|
|
140
|
+
await markStyleArtifactFailed(client, selector, buildConfig.style_profile_hash, message);
|
|
141
|
+
throw new Error(message);
|
|
142
|
+
}
|
|
143
|
+
const files = await sourceAdapter.getAllSourceFiles();
|
|
144
|
+
if (files.length === 0) {
|
|
145
|
+
throw new Error("No project files were available to build the style artifact");
|
|
146
|
+
}
|
|
147
|
+
const projectVersion = resolveStyleContentVersion(null, {
|
|
148
|
+
branch: sourceAdapter.contentContext?.branch ?? null,
|
|
149
|
+
releaseId: sourceAdapter.contentContext?.releaseId ?? null,
|
|
150
|
+
environmentName: sourceAdapter.contentContext?.environmentName ?? null,
|
|
151
|
+
});
|
|
152
|
+
const build = await buildPreparedCSSArtifactFromFiles({
|
|
153
|
+
projectSlug,
|
|
154
|
+
projectVersion,
|
|
155
|
+
projectDir,
|
|
156
|
+
files,
|
|
157
|
+
styleProfile,
|
|
158
|
+
stylesheetPath: config?.tailwind?.stylesheet,
|
|
159
|
+
minify: true,
|
|
160
|
+
environment: "preview",
|
|
161
|
+
buildMode: "production",
|
|
162
|
+
});
|
|
163
|
+
const resolution = await client.upsertStyleArtifact({
|
|
164
|
+
...(selector.type === "branch" ? { branch: selector.branch } : {}),
|
|
165
|
+
...(selector.type === "environment" ? { environmentName: selector.environmentName } : {}),
|
|
166
|
+
...(selector.type === "release" ? { releaseId: selector.releaseId } : {}),
|
|
167
|
+
styleProfileHash: styleProfile.hash,
|
|
168
|
+
status: "ready",
|
|
169
|
+
artifactHash: build.hash,
|
|
170
|
+
});
|
|
171
|
+
const result = {
|
|
172
|
+
kind: "style_artifact",
|
|
173
|
+
status: "ready",
|
|
174
|
+
style_profile_hash: styleProfile.hash,
|
|
175
|
+
artifact_hash: build.hash,
|
|
176
|
+
asset_path: resolution.assetPath ?? `/_vf/css/${build.hash}.css`,
|
|
177
|
+
content_type: resolution.contentType ?? "text/css; charset=utf-8",
|
|
178
|
+
etag: resolution.etag ?? `"${build.hash}"`,
|
|
179
|
+
selector: {
|
|
180
|
+
type: selector.type,
|
|
181
|
+
value: selector.value,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
await writeJobResultIfConfigured(result);
|
|
185
|
+
cliLogger.info(`Built style artifact ${build.hash}`);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
189
|
+
await markStyleArtifactFailed(client, selector, resolvedStyleProfileHash ?? buildConfig.style_profile_hash, message);
|
|
190
|
+
cliLogger.error(message);
|
|
191
|
+
exitProcess(1);
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
if (isExtendedFSAdapter(adapter.fs)) {
|
|
195
|
+
await adapter.fs.shutdown();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ParsedArgs } from "../../shared/types.js";
|
|
3
|
+
declare const StylesArgsSchema: z.ZodObject<{
|
|
4
|
+
subcommand: z.ZodLiteral<"build-artifact">;
|
|
5
|
+
config: z.ZodOptional<z.ZodString>;
|
|
6
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
debug: boolean;
|
|
9
|
+
subcommand: "build-artifact";
|
|
10
|
+
config?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
subcommand: "build-artifact";
|
|
13
|
+
config?: string | undefined;
|
|
14
|
+
debug?: boolean | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export type StylesArgs = z.infer<typeof StylesArgsSchema>;
|
|
17
|
+
export declare const parseStylesArgs: (args: ParsedArgs) => z.SafeParseReturnType<unknown, {
|
|
18
|
+
debug: boolean;
|
|
19
|
+
subcommand: "build-artifact";
|
|
20
|
+
config?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function handleStylesCommand(args: ParsedArgs): Promise<void>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/styles/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,QAAA,MAAM,gBAAgB;;;;;;;;;;;;EAIpB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,eAAe;;;;EAI1B,CAAC;AAEH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAIzE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createArgParser, parseArgsOrThrow } from "../../shared/args.js";
|
|
3
|
+
const StylesArgsSchema = z.object({
|
|
4
|
+
subcommand: z.literal("build-artifact"),
|
|
5
|
+
config: z.string().optional(),
|
|
6
|
+
debug: z.boolean().default(false),
|
|
7
|
+
});
|
|
8
|
+
export const parseStylesArgs = createArgParser(StylesArgsSchema, {
|
|
9
|
+
subcommand: { keys: ["subcommand"], type: "string", positional: 0 },
|
|
10
|
+
config: { keys: ["config"], type: "string" },
|
|
11
|
+
debug: { keys: ["debug"], type: "boolean" },
|
|
12
|
+
});
|
|
13
|
+
export async function handleStylesCommand(args) {
|
|
14
|
+
const opts = parseArgsOrThrow(parseStylesArgs, "styles", args);
|
|
15
|
+
const { stylesCommand } = await import("./command.js");
|
|
16
|
+
await stylesCommand(opts);
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-definitions.d.ts","sourceRoot":"","sources":["../../../src/cli/help/command-definitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"command-definitions.d.ts","sourceRoot":"","sources":["../../../src/cli/help/command-definitions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAkClD;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,eAgCtB,CAAC"}
|
|
@@ -13,6 +13,7 @@ import { doctorHelp } from "../commands/doctor/command-help.js";
|
|
|
13
13
|
import { cleanHelp } from "../commands/clean/command-help.js";
|
|
14
14
|
import { routesHelp } from "../commands/routes/command-help.js";
|
|
15
15
|
import { studioHelp } from "../commands/studio/command-help.js";
|
|
16
|
+
import { stylesHelp } from "../commands/styles/command-help.js";
|
|
16
17
|
import { lockHelp } from "../commands/lock/command-help.js";
|
|
17
18
|
import { analyzeChunksHelp } from "../commands/analyze-chunks/command-help.js";
|
|
18
19
|
import { generateHelp } from "../commands/generate/command-help.js";
|
|
@@ -47,6 +48,7 @@ export const COMMANDS = {
|
|
|
47
48
|
clean: cleanHelp,
|
|
48
49
|
routes: routesHelp,
|
|
49
50
|
studio: studioHelp,
|
|
51
|
+
styles: stylesHelp,
|
|
50
52
|
lock: lockHelp,
|
|
51
53
|
"analyze-chunks": analyzeChunksHelp,
|
|
52
54
|
generate: generateHelp,
|
package/esm/cli/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/cli/router.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/cli/router.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqCH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA4DpD;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAwClE"}
|
package/esm/cli/router.js
CHANGED
|
@@ -28,6 +28,7 @@ import { handleRoutesCommand } from "./commands/routes/handler.js";
|
|
|
28
28
|
import { handleServeCommand } from "./commands/serve/handler.js";
|
|
29
29
|
import { handleStartCommand } from "./commands/start/handler.js";
|
|
30
30
|
import { handleStudioCommand } from "./commands/studio/handler.js";
|
|
31
|
+
import { handleStylesCommand } from "./commands/styles/handler.js";
|
|
31
32
|
import { handleUpCommand } from "./commands/up/index.js";
|
|
32
33
|
import { handleTaskCommand } from "./commands/task/handler.js";
|
|
33
34
|
import { handleWorkflowCommand } from "./commands/workflow/handler.js";
|
|
@@ -52,6 +53,7 @@ const commands = {
|
|
|
52
53
|
"analyze-chunks": handleAnalyzeChunksCommand,
|
|
53
54
|
"routes": handleRoutesCommand,
|
|
54
55
|
"studio": handleStudioCommand,
|
|
56
|
+
"styles": handleStylesCommand,
|
|
55
57
|
"lock": handleLockCommand,
|
|
56
58
|
"generate": handleGenerateCommand,
|
|
57
59
|
"g": handleGenerateCommand,
|
package/esm/deno.d.ts
CHANGED
package/esm/deno.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.93",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"nodeModulesDir": "auto",
|
|
6
6
|
"exclude": [
|
|
@@ -97,6 +97,7 @@ export default {
|
|
|
97
97
|
"veryfront/config": "./src/config/index.ts",
|
|
98
98
|
"veryfront/build": "./src/build/index.ts",
|
|
99
99
|
"veryfront/rendering": "./src/rendering/index.ts",
|
|
100
|
+
"veryfront/rendering/styles": "./src/rendering/styles.ts",
|
|
100
101
|
"veryfront/cache": "./src/cache/index.ts",
|
|
101
102
|
"veryfront/security": "./src/security/index.ts",
|
|
102
103
|
"veryfront/errors": "./src/errors/index.ts",
|
|
@@ -91,7 +91,7 @@ function readEnvSnapshot() {
|
|
|
91
91
|
v8MaxOldSpaceSize: v8MaxOldSpaceSizeRaw
|
|
92
92
|
? parseNumber(v8MaxOldSpaceSizeRaw, 0) || undefined
|
|
93
93
|
: undefined,
|
|
94
|
-
veryfrontVersion: getEnv("VERYFRONT_VERSION") || undefined,
|
|
94
|
+
veryfrontVersion: getEnv("VERYFRONT_VERSION") || getEnv("RELEASE_VERSION") || undefined,
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
export function initEnvironmentConfig() {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* until HTML shell generation during SSR. This runs in parallel with other
|
|
6
6
|
* initialization work, reducing first-request latency by ~2-3 seconds.
|
|
7
7
|
*/
|
|
8
|
+
import { createPreparedProjectCSSContext } from "./prepared-project-css-cache.js";
|
|
8
9
|
import type { StyleScopeProfile } from "./style-scope-profile.js";
|
|
9
10
|
interface CSSPregenerationOptions {
|
|
10
11
|
/** Project slug for cache keying */
|
|
@@ -31,6 +32,14 @@ interface CSSPregenerationOptions {
|
|
|
31
32
|
/** Build mode recorded in the prepared artifact profile */
|
|
32
33
|
buildMode?: "development" | "production";
|
|
33
34
|
}
|
|
35
|
+
export interface PreparedCSSArtifactBuildResult {
|
|
36
|
+
css: string;
|
|
37
|
+
hash: string;
|
|
38
|
+
candidateCount: number;
|
|
39
|
+
fromCache: boolean;
|
|
40
|
+
context: ReturnType<typeof createPreparedProjectCSSContext>;
|
|
41
|
+
}
|
|
42
|
+
export declare function buildPreparedCSSArtifactFromFiles(options: CSSPregenerationOptions): Promise<PreparedCSSArtifactBuildResult>;
|
|
34
43
|
/**
|
|
35
44
|
* Pre-generate and cache CSS from file list.
|
|
36
45
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-pregeneration.d.ts","sourceRoot":"","sources":["../../../../src/src/html/styles-builder/css-pregeneration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"css-pregeneration.d.ts","sourceRoot":"","sources":["../../../../src/src/html/styles-builder/css-pregeneration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EACL,+BAA+B,EAEhC,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,UAAU,uBAAuB;IAC/B,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,cAAc,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,yDAAyD;IACzD,YAAY,EAAE,iBAAiB,CAAC;IAChC,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,aAAa,GAAG,YAAY,CAAC;CAC1C;AAED,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC;CAC7D;AAED,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,8BAA8B,CAAC,CA0CzC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAwCf;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAChD,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,GAAG,SAAS,CAUpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GAC/C,MAAM,GAAG,SAAS,CAgBpB"}
|
|
@@ -9,6 +9,28 @@ import { serverLogger } from "../../utils/index.js";
|
|
|
9
9
|
import { extractCandidatesFromFiles, getProjectCSS } from "./tailwind-compiler.js";
|
|
10
10
|
import { createPreparedProjectCSSContext, storePreparedProjectCSS, } from "./prepared-project-css-cache.js";
|
|
11
11
|
const logger = serverLogger.component("css-pregeneration");
|
|
12
|
+
export async function buildPreparedCSSArtifactFromFiles(options) {
|
|
13
|
+
const { projectSlug, projectVersion, projectDir, files, styleProfile, stylesheet, stylesheetPath, minify = true, environment = "preview", buildMode = "production", } = options;
|
|
14
|
+
const resolvedStylesheet = stylesheet ?? findStylesheetFromFiles(files, stylesheetPath);
|
|
15
|
+
const candidates = extractCandidatesFromFiles(files, {
|
|
16
|
+
projectDir,
|
|
17
|
+
styleProfile,
|
|
18
|
+
});
|
|
19
|
+
const result = await getProjectCSS(projectSlug, resolvedStylesheet, candidates, {
|
|
20
|
+
minify,
|
|
21
|
+
environment,
|
|
22
|
+
buildMode,
|
|
23
|
+
});
|
|
24
|
+
const context = createPreparedProjectCSSContext(projectSlug, projectVersion, resolvedStylesheet, styleProfile.hash, { minify, environment, buildMode });
|
|
25
|
+
await storePreparedProjectCSS(context, { css: result.css, hash: result.hash });
|
|
26
|
+
return {
|
|
27
|
+
css: result.css,
|
|
28
|
+
hash: result.hash,
|
|
29
|
+
candidateCount: candidates.size,
|
|
30
|
+
fromCache: result.fromCache,
|
|
31
|
+
context,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
12
34
|
/**
|
|
13
35
|
* Pre-generate and cache CSS from file list.
|
|
14
36
|
*
|
|
@@ -22,33 +44,22 @@ const logger = serverLogger.component("css-pregeneration");
|
|
|
22
44
|
* @returns Promise that resolves when CSS is generated (or immediately on error)
|
|
23
45
|
*/
|
|
24
46
|
export async function pregenerateCSSFromFiles(options) {
|
|
25
|
-
const { projectSlug, projectVersion,
|
|
47
|
+
const { projectSlug, projectVersion, files, styleProfile, stylesheet, } = options;
|
|
26
48
|
const startTime = performance.now();
|
|
27
49
|
try {
|
|
28
|
-
const resolvedStylesheet = stylesheet ?? findStylesheetFromFiles(files, stylesheetPath);
|
|
29
|
-
const candidates = extractCandidatesFromFiles(files, {
|
|
30
|
-
projectDir,
|
|
31
|
-
styleProfile,
|
|
32
|
-
});
|
|
33
50
|
logger.debug("Starting", {
|
|
34
51
|
projectSlug,
|
|
35
52
|
projectVersion,
|
|
36
53
|
fileCount: files.length,
|
|
37
|
-
|
|
38
|
-
hasStylesheet: Boolean(resolvedStylesheet),
|
|
54
|
+
hasStylesheet: Boolean(stylesheet),
|
|
39
55
|
styleProfileHash: styleProfile.hash,
|
|
40
56
|
});
|
|
41
|
-
const result = await
|
|
42
|
-
minify,
|
|
43
|
-
environment,
|
|
44
|
-
buildMode,
|
|
45
|
-
});
|
|
46
|
-
await storePreparedProjectCSS(createPreparedProjectCSSContext(projectSlug, projectVersion, resolvedStylesheet, styleProfile.hash, { minify, environment, buildMode }), { css: result.css, hash: result.hash });
|
|
57
|
+
const result = await buildPreparedCSSArtifactFromFiles(options);
|
|
47
58
|
const duration = performance.now() - startTime;
|
|
48
59
|
logger.debug("Complete", {
|
|
49
60
|
projectSlug,
|
|
50
61
|
projectVersion,
|
|
51
|
-
candidateCount:
|
|
62
|
+
candidateCount: result.candidateCount,
|
|
52
63
|
cssLength: result.css.length,
|
|
53
64
|
cssHash: result.hash,
|
|
54
65
|
fromCache: result.fromCache,
|