veryfront 0.1.83 → 0.1.84
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/knowledge/command.d.ts +10 -13
- package/esm/cli/commands/knowledge/command.d.ts.map +1 -1
- package/esm/cli/commands/knowledge/command.js +294 -110
- package/esm/cli/commands/knowledge/parser-source.d.ts.map +1 -1
- package/esm/cli/commands/knowledge/parser-source.js +52 -0
- package/esm/cli/commands/knowledge/result.d.ts +54 -0
- package/esm/cli/commands/knowledge/result.d.ts.map +1 -0
- package/esm/cli/commands/knowledge/result.js +22 -0
- package/esm/cli/commands/knowledge/source-policy.d.ts +11 -0
- package/esm/cli/commands/knowledge/source-policy.d.ts.map +1 -0
- package/esm/cli/commands/knowledge/source-policy.js +135 -0
- package/esm/deno.js +1 -1
- package/esm/src/jobs/index.d.ts +1 -1
- package/esm/src/jobs/index.d.ts.map +1 -1
- package/esm/src/jobs/index.js +1 -1
- package/esm/src/jobs/schemas.d.ts +1104 -185
- package/esm/src/jobs/schemas.d.ts.map +1 -1
- package/esm/src/jobs/schemas.js +81 -8
- package/esm/src/proxy/error-response.d.ts +7 -0
- package/esm/src/proxy/error-response.d.ts.map +1 -0
- package/esm/src/proxy/error-response.js +26 -0
- package/esm/src/proxy/handler.d.ts.map +1 -1
- package/esm/src/proxy/handler.js +25 -0
- package/esm/src/proxy/main.js +2 -23
- package/esm/src/transforms/esm/http-cache-helpers.d.ts.map +1 -1
- package/esm/src/transforms/esm/http-cache-helpers.js +7 -1
- package/esm/src/transforms/import-rewriter/strategies/bare-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/bare-strategy.js +11 -8
- package/esm/src/transforms/shared/package-specifier.d.ts +7 -0
- package/esm/src/transforms/shared/package-specifier.d.ts.map +1 -0
- package/esm/src/transforms/shared/package-specifier.js +19 -0
- package/package.json +1 -1
- package/src/cli/commands/knowledge/command.ts +375 -139
- package/src/cli/commands/knowledge/parser-source.ts +52 -0
- package/src/cli/commands/knowledge/result.ts +88 -0
- package/src/cli/commands/knowledge/source-policy.ts +164 -0
- package/src/deno.js +1 -1
- package/src/src/jobs/index.ts +16 -0
- package/src/src/jobs/schemas.ts +105 -8
- package/src/src/proxy/error-response.ts +33 -0
- package/src/src/proxy/handler.ts +43 -0
- package/src/src/proxy/main.ts +2 -27
- package/src/src/transforms/esm/http-cache-helpers.ts +12 -1
- package/src/src/transforms/import-rewriter/strategies/bare-strategy.ts +11 -12
- package/src/src/transforms/shared/package-specifier.ts +29 -0
package/src/src/proxy/main.ts
CHANGED
|
@@ -37,12 +37,12 @@ import {
|
|
|
37
37
|
withSpan,
|
|
38
38
|
} from "./tracing.js";
|
|
39
39
|
import { proxyLogger, runWithProxyRequestContext } from "./logger.js";
|
|
40
|
-
import { ErrorPages } from "../server/utils/error-html.js";
|
|
41
40
|
import { RendererRouter } from "./renderer-router.js";
|
|
42
41
|
import { ServerResolver } from "./server-resolver.js";
|
|
43
42
|
import { parseProjectDomain } from "../server/utils/domain-parser.js";
|
|
44
43
|
import { exit, getEnv, onSignal } from "../platform/compat/process.js";
|
|
45
44
|
import { createHttpServer, upgradeWebSocket } from "../platform/compat/http/index.js";
|
|
45
|
+
import { createProxyErrorResponse, jsonErrorResponse } from "./error-response.js";
|
|
46
46
|
|
|
47
47
|
function getLocalProjects(): Record<string, string> {
|
|
48
48
|
const raw = getEnv("LOCAL_PROJECTS");
|
|
@@ -274,13 +274,6 @@ function handleWebSocketUpgrade(req: dntShim.Request): dntShim.Response {
|
|
|
274
274
|
return response;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
function jsonErrorResponse(status: number, body: Record<string, unknown>): dntShim.Response {
|
|
278
|
-
return new dntShim.Response(JSON.stringify(body), {
|
|
279
|
-
status,
|
|
280
|
-
headers: { "Content-Type": "application/json" },
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
277
|
function forwardToServer(req: dntShim.Request): Promise<dntShim.Response> {
|
|
285
278
|
const startTime = performance.now();
|
|
286
279
|
const url = new URL(req.url);
|
|
@@ -311,25 +304,7 @@ function forwardToServer(req: dntShim.Request): Promise<dntShim.Response> {
|
|
|
311
304
|
const logLevel = ctx.error.status < 500 ? "warn" : "error";
|
|
312
305
|
proxyLogger[logLevel](`${ctx.error.status} ${req.method} ${url.pathname}`, { ms });
|
|
313
306
|
endSpan(spanInfo?.span, ctx.error.status);
|
|
314
|
-
|
|
315
|
-
if (ctx.error.redirectUrl) {
|
|
316
|
-
return new dntShim.Response(null, {
|
|
317
|
-
status: 302,
|
|
318
|
-
headers: { Location: ctx.error.redirectUrl },
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (ctx.error.slug === "release-not-found") {
|
|
323
|
-
return new dntShim.Response(ErrorPages.notFound(), {
|
|
324
|
-
status: 404,
|
|
325
|
-
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
return jsonErrorResponse(ctx.error.status, {
|
|
330
|
-
error: ctx.error.message,
|
|
331
|
-
status: ctx.error.status,
|
|
332
|
-
});
|
|
307
|
+
return createProxyErrorResponse(ctx.error);
|
|
333
308
|
}
|
|
334
309
|
|
|
335
310
|
const reqLogger = proxyLogger.child({
|
|
@@ -9,6 +9,8 @@ import { cwd } from "../../platform/compat/process.js";
|
|
|
9
9
|
import { rendererLogger } from "../../utils/index.js";
|
|
10
10
|
import { resolveImport } from "../../modules/import-map/resolver.js";
|
|
11
11
|
import type { ImportMapConfig } from "../../modules/import-map/types.js";
|
|
12
|
+
import { buildEsmShUrl } from "../import-rewriter/url-builder.js";
|
|
13
|
+
import { parseBarePackageSpecifier } from "../shared/package-specifier.js";
|
|
12
14
|
import { DEFAULT_REACT_VERSION, getReactImportMap } from "./package-registry.js";
|
|
13
15
|
|
|
14
16
|
const logger = rendererLogger.component("http-cache");
|
|
@@ -149,7 +151,16 @@ export function resolveBareSpecifier(
|
|
|
149
151
|
const mapped = resolveImport(specifier, importMap);
|
|
150
152
|
if (mapped !== specifier) return mapped;
|
|
151
153
|
|
|
152
|
-
|
|
154
|
+
const parsed = parseBarePackageSpecifier(specifier);
|
|
155
|
+
if (parsed == null) {
|
|
156
|
+
return `https://esm.sh/${specifier}?target=es2022`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return buildEsmShUrl(
|
|
160
|
+
parsed.packageName,
|
|
161
|
+
parsed.version ?? undefined,
|
|
162
|
+
parsed.subpath ?? undefined,
|
|
163
|
+
);
|
|
153
164
|
}
|
|
154
165
|
|
|
155
166
|
/**
|
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
RewriteResult,
|
|
14
14
|
} from "../types.js";
|
|
15
15
|
import { buildEsmShUrl, TAILWIND_VERSION } from "../url-builder.js";
|
|
16
|
+
import { parseBarePackageSpecifier } from "../../shared/package-specifier.js";
|
|
16
17
|
|
|
17
18
|
const logger = rendererLogger.component("esm");
|
|
18
19
|
|
|
@@ -22,10 +23,6 @@ function hasVersionSpecifier(specifier: string): boolean {
|
|
|
22
23
|
return /@[\d^~x][\d.x^~-]*(?=\/|$)/.test(specifier);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
function normalizeVersionedSpecifier(specifier: string): string {
|
|
26
|
-
return specifier.replace(/@[\d^~x][\d.x^~-]*(?=\/|$)/, "");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
26
|
function warnUnversionedImport(specifier: string, projectId: string): void {
|
|
30
27
|
const key = `${projectId}:${specifier}`;
|
|
31
28
|
if (unversionedImportsWarned.has(key)) return;
|
|
@@ -73,20 +70,22 @@ export class BareStrategy implements ImportRewriteStrategy {
|
|
|
73
70
|
rewrite(info: ImportSpecifierInfo, ctx: RewriteContext): RewriteResult {
|
|
74
71
|
if (ctx.target === "ssr") return { specifier: null };
|
|
75
72
|
|
|
76
|
-
const
|
|
73
|
+
const parsed = parseBarePackageSpecifier(info.specifier);
|
|
74
|
+
if (parsed == null) {
|
|
75
|
+
return { specifier: null };
|
|
76
|
+
}
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
const packageName = parsed.packageName;
|
|
79
|
+
let version = parsed.version ?? undefined;
|
|
80
|
+
const subpath = parsed.subpath ?? undefined;
|
|
79
81
|
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
/^tailwindcss/,
|
|
83
|
-
`tailwindcss@${TAILWIND_VERSION}`,
|
|
84
|
-
);
|
|
82
|
+
if (packageName === "tailwindcss") {
|
|
83
|
+
version = TAILWIND_VERSION;
|
|
85
84
|
} else if (!hasVersionSpecifier(info.specifier)) {
|
|
86
85
|
warnUnversionedImport(info.specifier, ctx.projectId);
|
|
87
86
|
}
|
|
88
87
|
|
|
89
|
-
const url = buildEsmShUrl(
|
|
88
|
+
const url = buildEsmShUrl(packageName, version, subpath, {
|
|
90
89
|
external: ["react"],
|
|
91
90
|
});
|
|
92
91
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface ParsedBarePackageSpecifier {
|
|
2
|
+
packageName: string;
|
|
3
|
+
version: string | null;
|
|
4
|
+
subpath: string | null;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function parseBarePackageSpecifier(
|
|
8
|
+
specifier: string,
|
|
9
|
+
): ParsedBarePackageSpecifier | null {
|
|
10
|
+
const scopedMatch = specifier.match(/^(@[^/]+\/[^/@]+)(?:@([^/]+))?(\/.*)?$/);
|
|
11
|
+
if (scopedMatch?.[1]) {
|
|
12
|
+
return {
|
|
13
|
+
packageName: scopedMatch[1],
|
|
14
|
+
version: scopedMatch[2] ?? null,
|
|
15
|
+
subpath: scopedMatch[3] ?? null,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const unscopedMatch = specifier.match(/^([^/@][^/@]*?)(?:@([^/]+))?(\/.*)?$/);
|
|
20
|
+
if (unscopedMatch?.[1]) {
|
|
21
|
+
return {
|
|
22
|
+
packageName: unscopedMatch[1],
|
|
23
|
+
version: unscopedMatch[2] ?? null,
|
|
24
|
+
subpath: unscopedMatch[3] ?? null,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return null;
|
|
29
|
+
}
|