veryfront 0.1.82 → 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/platform/adapters/base.d.ts +4 -1
- package/esm/src/platform/adapters/base.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/github/adapter.d.ts +2 -1
- package/esm/src/platform/adapters/fs/github/adapter.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/github/adapter.js +2 -2
- package/esm/src/platform/adapters/fs/github/stat-operations.d.ts +2 -1
- package/esm/src/platform/adapters/fs/github/stat-operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/github/stat-operations.js +2 -2
- package/esm/src/platform/adapters/fs/veryfront/adapter.d.ts +2 -2
- package/esm/src/platform/adapters/fs/veryfront/adapter.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/adapter.js +17 -2
- package/esm/src/platform/adapters/fs/veryfront/multi-project-adapter.d.ts +2 -2
- package/esm/src/platform/adapters/fs/veryfront/multi-project-adapter.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/multi-project-adapter.js +2 -2
- package/esm/src/platform/adapters/fs/veryfront/read-operations.d.ts +1 -0
- package/esm/src/platform/adapters/fs/veryfront/read-operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/stat-operations.d.ts +6 -2
- package/esm/src/platform/adapters/fs/veryfront/stat-operations.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/veryfront/stat-operations.js +131 -21
- package/esm/src/platform/adapters/fs/veryfront/types.d.ts +2 -1
- package/esm/src/platform/adapters/fs/veryfront/types.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/wrapper.d.ts +2 -2
- package/esm/src/platform/adapters/fs/wrapper.d.ts.map +1 -1
- package/esm/src/platform/adapters/fs/wrapper.js +2 -2
- 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/rendering/app-route-resolver.js +0 -9
- package/esm/src/rendering/orchestrator/file-resolver/index.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/file-resolver/index.js +17 -0
- package/esm/src/rendering/page-resolution/page-resolver.d.ts.map +1 -1
- package/esm/src/rendering/page-resolution/page-resolver.js +19 -6
- package/esm/src/rendering/router-detection.d.ts +1 -0
- package/esm/src/rendering/router-detection.d.ts.map +1 -1
- package/esm/src/rendering/router-detection.js +3 -0
- 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/esm/src/types/entities/getEntityInfo.d.ts.map +1 -1
- package/esm/src/types/entities/getEntityInfo.js +59 -42
- 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/platform/adapters/base.ts +5 -1
- package/src/src/platform/adapters/fs/github/adapter.ts +3 -2
- package/src/src/platform/adapters/fs/github/stat-operations.ts +3 -2
- package/src/src/platform/adapters/fs/veryfront/adapter.ts +24 -3
- package/src/src/platform/adapters/fs/veryfront/multi-project-adapter.ts +6 -3
- package/src/src/platform/adapters/fs/veryfront/read-operations.ts +1 -0
- package/src/src/platform/adapters/fs/veryfront/stat-operations.ts +161 -25
- package/src/src/platform/adapters/fs/veryfront/types.ts +2 -1
- package/src/src/platform/adapters/fs/wrapper.ts +10 -3
- 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/rendering/app-route-resolver.ts +0 -8
- package/src/src/rendering/orchestrator/file-resolver/index.ts +19 -0
- package/src/src/rendering/page-resolution/page-resolver.ts +26 -17
- package/src/src/rendering/router-detection.ts +7 -0
- 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/types/entities/getEntityInfo.ts +78 -59
|
@@ -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
|
+
}
|
|
@@ -43,49 +43,55 @@ export async function getEntityInfo(
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
try {
|
|
46
|
+
const shouldReadDirectly = adapter
|
|
47
|
+
? isExtendedFSAdapter(adapter.fs) && adapter.fs.isVeryfrontAdapter()
|
|
48
|
+
: false;
|
|
49
|
+
|
|
50
|
+
let content: string;
|
|
46
51
|
if (adapter) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
if (!shouldReadDirectly) {
|
|
53
|
+
try {
|
|
54
|
+
const stat = await withFallback(
|
|
55
|
+
() => adapter.fs.stat(normalizedPath),
|
|
56
|
+
async () => {
|
|
57
|
+
const exists = await fs.exists(filePath);
|
|
58
|
+
if (!exists) {
|
|
59
|
+
throw toError(
|
|
60
|
+
createError({
|
|
61
|
+
type: "file",
|
|
62
|
+
message: "File not found",
|
|
63
|
+
context: { path: filePath, operation: "read" },
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return await fs.stat(filePath);
|
|
68
|
+
},
|
|
69
|
+
{ operationName: "stat:getEntityInfo", logError: false },
|
|
70
|
+
);
|
|
65
71
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
if (!stat.isFile) return null;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
entityInfoScope.runSync(
|
|
75
|
+
() => {
|
|
76
|
+
throw error;
|
|
77
|
+
},
|
|
78
|
+
{ path: filePath, details: { reason: "stat-failed" } },
|
|
79
|
+
undefined,
|
|
80
|
+
);
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
76
83
|
}
|
|
77
|
-
} else {
|
|
78
|
-
const exists = await fs.exists(filePath);
|
|
79
|
-
if (!exists) return null;
|
|
80
|
-
}
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
? await withFallback(
|
|
85
|
+
content = await withFallback(
|
|
84
86
|
() => adapter.fs.readFile(normalizedPath),
|
|
85
87
|
() => fs.readTextFile(filePath),
|
|
86
88
|
{ operationName: "readFile:getEntityInfo", logError: false },
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
const exists = await fs.exists(filePath);
|
|
92
|
+
if (!exists) return null;
|
|
93
|
+
content = await fs.readTextFile(filePath);
|
|
94
|
+
}
|
|
89
95
|
|
|
90
96
|
const ext = pathHelper.extname(filePath).toLowerCase();
|
|
91
97
|
|
|
@@ -171,26 +177,30 @@ export async function getEntityBySlug(
|
|
|
171
177
|
return await withSpan(
|
|
172
178
|
"types.getEntityBySlug",
|
|
173
179
|
async () => {
|
|
174
|
-
const
|
|
180
|
+
const normalizedSlug = normalizeSlug(slug);
|
|
181
|
+
const isVeryfrontRoute = normalizedSlug.startsWith(".veryfront/") ||
|
|
182
|
+
normalizedSlug === ".veryfront";
|
|
175
183
|
const resolveFile = adapter?.fs.resolveFile;
|
|
176
184
|
|
|
177
185
|
logger.debug("START", {
|
|
178
186
|
slug,
|
|
187
|
+
normalizedSlug,
|
|
179
188
|
projectDir,
|
|
180
189
|
isVeryfrontRoute,
|
|
181
190
|
hasResolveFile: !!resolveFile,
|
|
182
191
|
});
|
|
183
192
|
|
|
184
193
|
if (resolveFile) {
|
|
185
|
-
const basePaths = [pathHelper.join(projectDir, "pages",
|
|
194
|
+
const basePaths = [pathHelper.join(projectDir, "pages", normalizedSlug)];
|
|
186
195
|
|
|
187
|
-
if (isVeryfrontRoute) basePaths.unshift(pathHelper.join(projectDir,
|
|
188
|
-
if (
|
|
196
|
+
if (isVeryfrontRoute) basePaths.unshift(pathHelper.join(projectDir, normalizedSlug));
|
|
197
|
+
if (normalizedSlug === "index" || normalizedSlug === "") {
|
|
189
198
|
basePaths.unshift(pathHelper.join(projectDir, "pages", "index"));
|
|
190
199
|
}
|
|
191
200
|
|
|
192
201
|
logger.debug("Checking paths (resolveFile branch)", {
|
|
193
202
|
slug,
|
|
203
|
+
normalizedSlug,
|
|
194
204
|
basePaths,
|
|
195
205
|
});
|
|
196
206
|
|
|
@@ -208,13 +218,14 @@ export async function getEntityBySlug(
|
|
|
208
218
|
if (info?.entity.isPage) {
|
|
209
219
|
logger.debug("Found page via resolveFile", {
|
|
210
220
|
slug,
|
|
221
|
+
normalizedSlug,
|
|
211
222
|
path: info.entity.path,
|
|
212
223
|
});
|
|
213
224
|
return info;
|
|
214
225
|
}
|
|
215
226
|
}
|
|
216
227
|
|
|
217
|
-
const slugParts =
|
|
228
|
+
const slugParts = normalizedSlug === "" ? [] : normalizedSlug.split("/");
|
|
218
229
|
for (let depth = slugParts.length - 1; depth >= 0; depth--) {
|
|
219
230
|
const parentPath = slugParts.slice(0, depth).join("/");
|
|
220
231
|
const pagesDir = parentPath
|
|
@@ -259,33 +270,33 @@ export async function getEntityBySlug(
|
|
|
259
270
|
}
|
|
260
271
|
}
|
|
261
272
|
|
|
262
|
-
logger.debug("No page found via resolveFile branch", { slug });
|
|
273
|
+
logger.debug("No page found via resolveFile branch", { slug, normalizedSlug });
|
|
263
274
|
return null;
|
|
264
275
|
}
|
|
265
276
|
|
|
266
277
|
const possiblePaths = [
|
|
267
|
-
pathHelper.join(projectDir, "pages", `${
|
|
268
|
-
pathHelper.join(projectDir, "pages", `${
|
|
269
|
-
pathHelper.join(projectDir, "pages", `${
|
|
270
|
-
pathHelper.join(projectDir, "pages", `${
|
|
271
|
-
pathHelper.join(projectDir, "pages", `${
|
|
272
|
-
pathHelper.join(projectDir, "pages", `${
|
|
273
|
-
pathHelper.join(projectDir, "pages", `${
|
|
274
|
-
pathHelper.join(projectDir, "pages", `${
|
|
275
|
-
pathHelper.join(projectDir, "pages", `${
|
|
276
|
-
pathHelper.join(projectDir, "pages", `${
|
|
278
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}.mdx`),
|
|
279
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}.md`),
|
|
280
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}.tsx`),
|
|
281
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}.jsx`),
|
|
282
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}.ts`),
|
|
283
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}/index.mdx`),
|
|
284
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}/index.md`),
|
|
285
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}/index.tsx`),
|
|
286
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}/index.jsx`),
|
|
287
|
+
pathHelper.join(projectDir, "pages", `${normalizedSlug}/index.ts`),
|
|
277
288
|
];
|
|
278
289
|
|
|
279
290
|
if (isVeryfrontRoute) {
|
|
280
291
|
possiblePaths.unshift(
|
|
281
|
-
pathHelper.join(projectDir, `${
|
|
282
|
-
pathHelper.join(projectDir, `${
|
|
283
|
-
pathHelper.join(projectDir, `${
|
|
284
|
-
pathHelper.join(projectDir, `${
|
|
292
|
+
pathHelper.join(projectDir, `${normalizedSlug}.mdx`),
|
|
293
|
+
pathHelper.join(projectDir, `${normalizedSlug}.md`),
|
|
294
|
+
pathHelper.join(projectDir, `${normalizedSlug}.tsx`),
|
|
295
|
+
pathHelper.join(projectDir, `${normalizedSlug}.ts`),
|
|
285
296
|
);
|
|
286
297
|
}
|
|
287
298
|
|
|
288
|
-
if (
|
|
299
|
+
if (normalizedSlug === "index" || normalizedSlug === "") {
|
|
289
300
|
possiblePaths.unshift(
|
|
290
301
|
pathHelper.join(projectDir, "pages", "index.mdx"),
|
|
291
302
|
pathHelper.join(projectDir, "pages", "index.md"),
|
|
@@ -302,7 +313,7 @@ export async function getEntityBySlug(
|
|
|
302
313
|
if (info?.entity.isPage) return info;
|
|
303
314
|
}
|
|
304
315
|
|
|
305
|
-
const slugParts =
|
|
316
|
+
const slugParts = normalizedSlug === "" ? [] : normalizedSlug.split("/");
|
|
306
317
|
for (let depth = slugParts.length - 1; depth >= 0; depth--) {
|
|
307
318
|
const parentPath = slugParts.slice(0, depth).join("/");
|
|
308
319
|
const pagesDir = parentPath
|
|
@@ -356,7 +367,11 @@ export async function getEntityBySlug(
|
|
|
356
367
|
|
|
357
368
|
return null;
|
|
358
369
|
},
|
|
359
|
-
{
|
|
370
|
+
{
|
|
371
|
+
"entity.slug": slug,
|
|
372
|
+
"entity.normalized_slug": normalizeSlug(slug),
|
|
373
|
+
"entity.projectDir": projectDir,
|
|
374
|
+
},
|
|
360
375
|
);
|
|
361
376
|
}
|
|
362
377
|
|
|
@@ -448,3 +463,7 @@ function getSlugFromPath(filePath: string): string {
|
|
|
448
463
|
const parentDir = parts[parts.length - 2];
|
|
449
464
|
return parentDir === "pages" ? "" : parentDir ?? "";
|
|
450
465
|
}
|
|
466
|
+
|
|
467
|
+
function normalizeSlug(slug: string): string {
|
|
468
|
+
return slug === "/" ? "" : slug.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
469
|
+
}
|