zudoku 0.82.2 → 0.82.3
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/cli/cli.js +254 -200
- package/dist/cli/worker.js +4 -0
- package/dist/declarations/app/wrapProtectedRoutes.d.ts +5 -0
- package/dist/declarations/config/plugin-versions.d.ts +5 -0
- package/dist/declarations/vite/package-root.d.ts +1 -0
- package/docs/components/landing-page.mdx +1 -1
- package/package.json +12 -11
- package/src/app/entry.server.tsx +9 -5
- package/src/app/wrapProtectedRoutes.ts +25 -0
- package/src/config/loader.ts +15 -0
- package/src/config/plugin-versions.ts +38 -0
- package/src/lib/components/navigation/NavigationCategory.tsx +3 -2
- package/src/lib/components/navigation/StackRows.tsx +1 -1
- package/src/vite/api/SchemaManager.ts +11 -25
- package/src/vite/plugin-mdx.ts +3 -0
- package/src/vite/prerender/prerender.ts +28 -3
- package/src/vite/prerender/utils.ts +33 -0
- package/src/vite/prerender/worker.ts +8 -1
package/dist/cli/cli.js
CHANGED
|
@@ -59,7 +59,7 @@ __export(llms_exports, {
|
|
|
59
59
|
generateLlmsTxtFiles: () => generateLlmsTxtFiles
|
|
60
60
|
});
|
|
61
61
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
62
|
-
import
|
|
62
|
+
import path21 from "node:path";
|
|
63
63
|
import colors6 from "picocolors";
|
|
64
64
|
async function generateLlmsTxtFiles({
|
|
65
65
|
markdownFileInfos,
|
|
@@ -94,7 +94,7 @@ async function generateLlmsTxtFiles({
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
const llmsTxt2 = llmsTxtParts.join("\n");
|
|
97
|
-
await writeFile5(
|
|
97
|
+
await writeFile5(path21.join(baseOutputDir, "llms.txt"), llmsTxt2, "utf-8");
|
|
98
98
|
console.log(colors6.blue("\u2713 generated llms.txt"));
|
|
99
99
|
}
|
|
100
100
|
if (llmsTxtFull) {
|
|
@@ -120,7 +120,7 @@ ${info.content}
|
|
|
120
120
|
}
|
|
121
121
|
const llmsFull = llmsFullParts.join("\n");
|
|
122
122
|
await writeFile5(
|
|
123
|
-
|
|
123
|
+
path21.join(baseOutputDir, "llms-full.txt"),
|
|
124
124
|
llmsFull,
|
|
125
125
|
"utf-8"
|
|
126
126
|
);
|
|
@@ -139,12 +139,12 @@ import { hideBin } from "yargs/helpers";
|
|
|
139
139
|
import yargs from "yargs/yargs";
|
|
140
140
|
|
|
141
141
|
// src/cli/build/handler.ts
|
|
142
|
-
import
|
|
142
|
+
import path26 from "node:path";
|
|
143
143
|
|
|
144
144
|
// src/vite/build.ts
|
|
145
145
|
import { existsSync as existsSync2 } from "node:fs";
|
|
146
|
-
import { mkdir as mkdir6, readFile as
|
|
147
|
-
import
|
|
146
|
+
import { mkdir as mkdir6, readFile as readFile5, rename as rename2, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
|
|
147
|
+
import path24 from "node:path";
|
|
148
148
|
import { build as esbuild } from "esbuild";
|
|
149
149
|
import { createBuilder } from "vite";
|
|
150
150
|
|
|
@@ -230,7 +230,7 @@ var getZudokuRootDir = () => path.dirname(getPackageJsonPath("zudoku"));
|
|
|
230
230
|
|
|
231
231
|
// src/config/loader.ts
|
|
232
232
|
import { stat as stat2 } from "node:fs/promises";
|
|
233
|
-
import
|
|
233
|
+
import path5 from "node:path";
|
|
234
234
|
import colors2 from "picocolors";
|
|
235
235
|
import {
|
|
236
236
|
runnerImport,
|
|
@@ -321,7 +321,47 @@ var ZudokuError = class extends Error {
|
|
|
321
321
|
|
|
322
322
|
// src/config/file-exists.ts
|
|
323
323
|
import { stat } from "node:fs/promises";
|
|
324
|
-
var fileExists = (
|
|
324
|
+
var fileExists = (path31) => stat(path31).then(() => true).catch(() => false);
|
|
325
|
+
|
|
326
|
+
// src/config/plugin-versions.ts
|
|
327
|
+
import { readFile } from "node:fs/promises";
|
|
328
|
+
import path3 from "node:path";
|
|
329
|
+
|
|
330
|
+
// src/vite/package-root.ts
|
|
331
|
+
import path2 from "node:path";
|
|
332
|
+
var findPackageRoot = async (startDir) => {
|
|
333
|
+
let dir = startDir;
|
|
334
|
+
while (dir !== path2.dirname(dir)) {
|
|
335
|
+
if (await fileExists(path2.join(dir, "package.json"))) return dir;
|
|
336
|
+
dir = path2.dirname(dir);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// src/config/plugin-versions.ts
|
|
341
|
+
var getPluginVersions = async (pluginDirs) => {
|
|
342
|
+
const roots = await Promise.all(
|
|
343
|
+
[...new Set(pluginDirs)].map(findPackageRoot)
|
|
344
|
+
);
|
|
345
|
+
const resolved = await Promise.all(
|
|
346
|
+
roots.map(async (root) => {
|
|
347
|
+
if (!root) return void 0;
|
|
348
|
+
try {
|
|
349
|
+
const pkg = JSON.parse(
|
|
350
|
+
await readFile(path3.join(root, "package.json"), "utf-8")
|
|
351
|
+
);
|
|
352
|
+
if (!pkg.name) return void 0;
|
|
353
|
+
return { name: pkg.name, version: pkg.version ?? "unknown" };
|
|
354
|
+
} catch {
|
|
355
|
+
return void 0;
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
);
|
|
359
|
+
const byName = /* @__PURE__ */ new Map();
|
|
360
|
+
for (const version of resolved) {
|
|
361
|
+
if (version && !byName.has(version.name)) byName.set(version.name, version);
|
|
362
|
+
}
|
|
363
|
+
return [...byName.values()];
|
|
364
|
+
};
|
|
325
365
|
|
|
326
366
|
// src/config/validators/ZudokuConfig.ts
|
|
327
367
|
import colors from "picocolors";
|
|
@@ -329,7 +369,7 @@ import { isValidElement as isValidElement2 } from "react";
|
|
|
329
369
|
import { z as z7 } from "zod";
|
|
330
370
|
|
|
331
371
|
// src/vite/plugin-theme.ts
|
|
332
|
-
import
|
|
372
|
+
import path4 from "node:path";
|
|
333
373
|
import { normalizeTheme } from "shiki";
|
|
334
374
|
|
|
335
375
|
// src/lib/shiki.ts
|
|
@@ -782,7 +822,7 @@ ${rootVars.join("\n")}
|
|
|
782
822
|
config.__meta.rootDir,
|
|
783
823
|
...config.__meta.dependencies,
|
|
784
824
|
...config.__pluginDirs ?? []
|
|
785
|
-
].map((file) =>
|
|
825
|
+
].map((file) => path4.relative(path4.dirname(id), file))
|
|
786
826
|
);
|
|
787
827
|
const code = [...files].map((file) => `@source "${file}";`);
|
|
788
828
|
code.push("@theme inline {");
|
|
@@ -2990,8 +3030,8 @@ import { createNanoEvents } from "nanoevents";
|
|
|
2990
3030
|
|
|
2991
3031
|
// src/lib/util/url.ts
|
|
2992
3032
|
import { matchPath } from "react-router";
|
|
2993
|
-
var matchesProtectedPattern = (pattern,
|
|
2994
|
-
var matchesAnyProtectedPattern = (patterns,
|
|
3033
|
+
var matchesProtectedPattern = (pattern, path31) => matchPath({ path: pattern, end: true }, path31) != null;
|
|
3034
|
+
var matchesAnyProtectedPattern = (patterns, path31) => patterns.some((p) => matchesProtectedPattern(p, path31));
|
|
2995
3035
|
|
|
2996
3036
|
// src/lib/core/ZudokuContext.ts
|
|
2997
3037
|
var normalizeProtectedRoutes = (val) => {
|
|
@@ -3635,7 +3675,7 @@ var zudokuConfigFiles = [
|
|
|
3635
3675
|
];
|
|
3636
3676
|
async function getConfigFilePath(rootDir) {
|
|
3637
3677
|
for (const fileName of zudokuConfigFiles) {
|
|
3638
|
-
const filepath =
|
|
3678
|
+
const filepath = path5.join(rootDir, fileName);
|
|
3639
3679
|
if (await fileExists(filepath)) {
|
|
3640
3680
|
return filepath;
|
|
3641
3681
|
}
|
|
@@ -3771,6 +3811,15 @@ async function loadZudokuConfig(configEnv, rootDir) {
|
|
|
3771
3811
|
colors2.cyan(`loaded config file `) + colors2.dim(config.__meta.configPath),
|
|
3772
3812
|
{ timestamp: true }
|
|
3773
3813
|
);
|
|
3814
|
+
const pluginVersions = await getPluginVersions(config.__pluginDirs ?? []);
|
|
3815
|
+
if (pluginVersions.length > 0) {
|
|
3816
|
+
logger.info(
|
|
3817
|
+
colors2.cyan(`loaded plugins `) + colors2.dim(
|
|
3818
|
+
pluginVersions.map((p) => `${p.name}@${p.version}`).join(", ")
|
|
3819
|
+
),
|
|
3820
|
+
{ timestamp: true }
|
|
3821
|
+
);
|
|
3822
|
+
}
|
|
3774
3823
|
return { config, envPrefix, publicEnv };
|
|
3775
3824
|
} catch (error) {
|
|
3776
3825
|
const lastValid = getConfig();
|
|
@@ -3846,7 +3895,7 @@ var getIssuer = async (config) => {
|
|
|
3846
3895
|
init_joinUrl();
|
|
3847
3896
|
|
|
3848
3897
|
// src/vite/config.ts
|
|
3849
|
-
import
|
|
3898
|
+
import path17 from "node:path";
|
|
3850
3899
|
import dotenv from "dotenv";
|
|
3851
3900
|
import colors4 from "picocolors";
|
|
3852
3901
|
import {
|
|
@@ -3894,22 +3943,12 @@ var buildManifest = (config) => {
|
|
|
3894
3943
|
// src/vite/config.ts
|
|
3895
3944
|
init_joinUrl();
|
|
3896
3945
|
|
|
3897
|
-
// src/vite/package-root.ts
|
|
3898
|
-
import path4 from "node:path";
|
|
3899
|
-
var findPackageRoot = async (startDir) => {
|
|
3900
|
-
let dir = startDir;
|
|
3901
|
-
while (dir !== path4.dirname(dir)) {
|
|
3902
|
-
if (await fileExists(path4.join(dir, "package.json"))) return dir;
|
|
3903
|
-
dir = path4.dirname(dir);
|
|
3904
|
-
}
|
|
3905
|
-
};
|
|
3906
|
-
|
|
3907
3946
|
// src/vite/plugin.ts
|
|
3908
3947
|
import tailwindcss from "@tailwindcss/vite";
|
|
3909
3948
|
import react from "@vitejs/plugin-react";
|
|
3910
3949
|
|
|
3911
3950
|
// src/vite/css/plugin.ts
|
|
3912
|
-
import
|
|
3951
|
+
import path6 from "node:path";
|
|
3913
3952
|
import { isCSSRequest as isCSSRequest2 } from "vite";
|
|
3914
3953
|
|
|
3915
3954
|
// src/vite/css/collect.ts
|
|
@@ -3944,7 +3983,7 @@ var VIRTUAL_ENTRY = "virtual:ssr-css.css";
|
|
|
3944
3983
|
function vitePluginSsrCss(pluginOpts) {
|
|
3945
3984
|
let server;
|
|
3946
3985
|
const config = getCurrentConfig();
|
|
3947
|
-
const virtualHref =
|
|
3986
|
+
const virtualHref = path6.join(
|
|
3948
3987
|
config.basePath ?? "",
|
|
3949
3988
|
`/@id/__x00__${VIRTUAL_ENTRY}?direct`
|
|
3950
3989
|
);
|
|
@@ -4076,12 +4115,12 @@ var plugin_api_keys_default = viteApiKeysPlugin;
|
|
|
4076
4115
|
|
|
4077
4116
|
// src/vite/plugin-api.ts
|
|
4078
4117
|
import fs2 from "node:fs/promises";
|
|
4079
|
-
import
|
|
4118
|
+
import path12 from "node:path";
|
|
4080
4119
|
import { deepEqual as deepEqual2 } from "fast-equals";
|
|
4081
4120
|
import { runnerImport as runnerImport3 } from "vite";
|
|
4082
4121
|
|
|
4083
4122
|
// src/config/validators/BuildSchema.ts
|
|
4084
|
-
import
|
|
4123
|
+
import path7 from "node:path";
|
|
4085
4124
|
import { runnerImport as runnerImport2 } from "vite";
|
|
4086
4125
|
import { z as z8 } from "zod";
|
|
4087
4126
|
var BuildProcessorSchema = z8.custom((val) => typeof val === "function");
|
|
@@ -4105,7 +4144,7 @@ var zudokuBuildConfigFiles = [
|
|
|
4105
4144
|
];
|
|
4106
4145
|
async function getBuildConfigFilePath(rootDir) {
|
|
4107
4146
|
for (const fileName of zudokuBuildConfigFiles) {
|
|
4108
|
-
const filepath =
|
|
4147
|
+
const filepath = path7.join(rootDir, fileName);
|
|
4109
4148
|
if (await fileExists(filepath)) {
|
|
4110
4149
|
return filepath;
|
|
4111
4150
|
}
|
|
@@ -4227,14 +4266,14 @@ var flattenAllOf = (schema2) => {
|
|
|
4227
4266
|
};
|
|
4228
4267
|
|
|
4229
4268
|
// src/lib/util/traverse.ts
|
|
4230
|
-
var traverse = (specification, transform,
|
|
4231
|
-
const transformed = transform(specification,
|
|
4269
|
+
var traverse = (specification, transform, path31 = []) => {
|
|
4270
|
+
const transformed = transform(specification, path31);
|
|
4232
4271
|
if (typeof transformed !== "object" || transformed === null) {
|
|
4233
4272
|
return transformed;
|
|
4234
4273
|
}
|
|
4235
4274
|
const result = Array.isArray(transformed) ? [] : {};
|
|
4236
4275
|
for (const [key, value] of Object.entries(transformed)) {
|
|
4237
|
-
const currentPath = [...
|
|
4276
|
+
const currentPath = [...path31, key];
|
|
4238
4277
|
if (Array.isArray(value)) {
|
|
4239
4278
|
result[key] = value.map(
|
|
4240
4279
|
(item, index) => typeof item === "object" && item != null ? traverse(item, transform, [...currentPath, index.toString()]) : item
|
|
@@ -4262,9 +4301,9 @@ var resolveLocalRef = (schema2, ref) => {
|
|
|
4262
4301
|
if (schemaCache?.has(ref)) {
|
|
4263
4302
|
return schemaCache.get(ref);
|
|
4264
4303
|
}
|
|
4265
|
-
const
|
|
4304
|
+
const path31 = ref.split("/").slice(1);
|
|
4266
4305
|
let current = schema2;
|
|
4267
|
-
for (const segment of
|
|
4306
|
+
for (const segment of path31) {
|
|
4268
4307
|
if (!current || typeof current !== "object") {
|
|
4269
4308
|
current = null;
|
|
4270
4309
|
}
|
|
@@ -4283,7 +4322,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4283
4322
|
}
|
|
4284
4323
|
const cloned = structuredClone(schema2);
|
|
4285
4324
|
const visited = /* @__PURE__ */ new Set();
|
|
4286
|
-
const resolve = async (current,
|
|
4325
|
+
const resolve = async (current, path31) => {
|
|
4287
4326
|
if (isIndexableObject(current)) {
|
|
4288
4327
|
if (visited.has(current)) {
|
|
4289
4328
|
return CIRCULAR_REF;
|
|
@@ -4291,7 +4330,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4291
4330
|
visited.add(current);
|
|
4292
4331
|
if (Array.isArray(current)) {
|
|
4293
4332
|
for (let index = 0; index < current.length; index++) {
|
|
4294
|
-
current[index] = await resolve(current[index], `${
|
|
4333
|
+
current[index] = await resolve(current[index], `${path31}/${index}`);
|
|
4295
4334
|
}
|
|
4296
4335
|
} else {
|
|
4297
4336
|
if ("$ref" in current && typeof current.$ref === "string") {
|
|
@@ -4302,13 +4341,13 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4302
4341
|
for (const resolver of resolvers) {
|
|
4303
4342
|
const resolved = await resolver($ref);
|
|
4304
4343
|
if (resolved) {
|
|
4305
|
-
result2 = await resolve(resolved,
|
|
4344
|
+
result2 = await resolve(resolved, path31);
|
|
4306
4345
|
break;
|
|
4307
4346
|
}
|
|
4308
4347
|
}
|
|
4309
4348
|
if (result2 === void 0) {
|
|
4310
4349
|
const resolved = await resolveLocalRef(cloned, $ref);
|
|
4311
|
-
result2 = await resolve(resolved,
|
|
4350
|
+
result2 = await resolve(resolved, path31);
|
|
4312
4351
|
}
|
|
4313
4352
|
if (hasSiblings) {
|
|
4314
4353
|
if (result2 === CIRCULAR_REF) {
|
|
@@ -4321,7 +4360,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4321
4360
|
return result2;
|
|
4322
4361
|
}
|
|
4323
4362
|
for (const key in current) {
|
|
4324
|
-
current[key] = await resolve(current[key], `${
|
|
4363
|
+
current[key] = await resolve(current[key], `${path31}/${key}`);
|
|
4325
4364
|
}
|
|
4326
4365
|
}
|
|
4327
4366
|
visited.delete(current);
|
|
@@ -4360,9 +4399,9 @@ var upgradeSchema = (schema2) => {
|
|
|
4360
4399
|
}
|
|
4361
4400
|
return sub;
|
|
4362
4401
|
});
|
|
4363
|
-
schema2 = traverse(schema2, (sub,
|
|
4402
|
+
schema2 = traverse(schema2, (sub, path31) => {
|
|
4364
4403
|
if (sub.example !== void 0) {
|
|
4365
|
-
if (isSchemaPath(
|
|
4404
|
+
if (isSchemaPath(path31 ?? [])) {
|
|
4366
4405
|
sub.examples = [sub.example];
|
|
4367
4406
|
} else {
|
|
4368
4407
|
sub.examples = {
|
|
@@ -4375,11 +4414,11 @@ var upgradeSchema = (schema2) => {
|
|
|
4375
4414
|
}
|
|
4376
4415
|
return sub;
|
|
4377
4416
|
});
|
|
4378
|
-
schema2 = traverse(schema2, (schema3,
|
|
4417
|
+
schema2 = traverse(schema2, (schema3, path31) => {
|
|
4379
4418
|
if (schema3.type === "object" && schema3.properties !== void 0) {
|
|
4380
|
-
const parentPath =
|
|
4419
|
+
const parentPath = path31?.slice(0, -1);
|
|
4381
4420
|
const isMultipart = parentPath?.some((segment, index) => {
|
|
4382
|
-
return segment === "content" &&
|
|
4421
|
+
return segment === "content" && path31?.[index + 1] === "multipart/form-data";
|
|
4383
4422
|
});
|
|
4384
4423
|
if (isMultipart) {
|
|
4385
4424
|
const entries = Object.entries(schema3.properties);
|
|
@@ -4393,8 +4432,8 @@ var upgradeSchema = (schema2) => {
|
|
|
4393
4432
|
}
|
|
4394
4433
|
return schema3;
|
|
4395
4434
|
});
|
|
4396
|
-
schema2 = traverse(schema2, (schema3,
|
|
4397
|
-
if (
|
|
4435
|
+
schema2 = traverse(schema2, (schema3, path31) => {
|
|
4436
|
+
if (path31?.includes("content") && path31.includes("application/octet-stream")) {
|
|
4398
4437
|
return {};
|
|
4399
4438
|
}
|
|
4400
4439
|
if (schema3.type === "string" && schema3.format === "binary") {
|
|
@@ -4420,11 +4459,11 @@ var upgradeSchema = (schema2) => {
|
|
|
4420
4459
|
}
|
|
4421
4460
|
return sub;
|
|
4422
4461
|
});
|
|
4423
|
-
schema2 = traverse(schema2, (schema3,
|
|
4462
|
+
schema2 = traverse(schema2, (schema3, path31) => {
|
|
4424
4463
|
if (schema3.type === "string" && schema3.format === "byte") {
|
|
4425
|
-
const parentPath =
|
|
4464
|
+
const parentPath = path31?.slice(0, -1);
|
|
4426
4465
|
const contentMediaType = parentPath?.find(
|
|
4427
|
-
(_, index) =>
|
|
4466
|
+
(_, index) => path31?.[index - 1] === "content"
|
|
4428
4467
|
);
|
|
4429
4468
|
return {
|
|
4430
4469
|
type: "string",
|
|
@@ -4436,7 +4475,7 @@ var upgradeSchema = (schema2) => {
|
|
|
4436
4475
|
});
|
|
4437
4476
|
return schema2;
|
|
4438
4477
|
};
|
|
4439
|
-
function isSchemaPath(
|
|
4478
|
+
function isSchemaPath(path31) {
|
|
4440
4479
|
const schemaLocations = [
|
|
4441
4480
|
["components", "schemas"],
|
|
4442
4481
|
"properties",
|
|
@@ -4449,10 +4488,10 @@ function isSchemaPath(path30) {
|
|
|
4449
4488
|
];
|
|
4450
4489
|
return schemaLocations.some((location) => {
|
|
4451
4490
|
if (Array.isArray(location)) {
|
|
4452
|
-
return location.every((segment, index) =>
|
|
4491
|
+
return location.every((segment, index) => path31[index] === segment);
|
|
4453
4492
|
}
|
|
4454
|
-
return
|
|
4455
|
-
}) ||
|
|
4493
|
+
return path31.includes(location);
|
|
4494
|
+
}) || path31.includes("schema") || path31.some((segment) => segment.endsWith("Schema"));
|
|
4456
4495
|
}
|
|
4457
4496
|
|
|
4458
4497
|
// src/lib/oas/parser/index.ts
|
|
@@ -4534,13 +4573,13 @@ var OPENAPI_PROPS = /* @__PURE__ */ new Set([
|
|
|
4534
4573
|
"anyOf",
|
|
4535
4574
|
"oneOf"
|
|
4536
4575
|
]);
|
|
4537
|
-
var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs = /* @__PURE__ */ new WeakMap(),
|
|
4576
|
+
var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs = /* @__PURE__ */ new WeakMap(), path31 = [], currentRefPaths = /* @__PURE__ */ new Set()) => {
|
|
4538
4577
|
if (obj === null || typeof obj !== "object") return obj;
|
|
4539
4578
|
const refPath = obj.__$ref;
|
|
4540
4579
|
const isCircular = currentPath.has(obj) || typeof refPath === "string" && currentRefPaths.has(refPath);
|
|
4541
4580
|
if (isCircular) {
|
|
4542
4581
|
if (typeof refPath === "string") return SCHEMA_REF_PREFIX + refPath;
|
|
4543
|
-
const circularProp =
|
|
4582
|
+
const circularProp = path31.find((p) => !OPENAPI_PROPS.has(p)) || path31[0];
|
|
4544
4583
|
return [CIRCULAR_REF, circularProp].filter(Boolean).join(":");
|
|
4545
4584
|
}
|
|
4546
4585
|
if (refs.has(obj)) return refs.get(obj);
|
|
@@ -4550,7 +4589,7 @@ var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs
|
|
|
4550
4589
|
value,
|
|
4551
4590
|
currentPath,
|
|
4552
4591
|
refs,
|
|
4553
|
-
[...
|
|
4592
|
+
[...path31, key],
|
|
4554
4593
|
currentRefPaths
|
|
4555
4594
|
);
|
|
4556
4595
|
const result = Array.isArray(obj) ? obj.map((item, i) => recurse(item, i.toString())) : Object.fromEntries(
|
|
@@ -4588,7 +4627,7 @@ var resolveExtensions = (obj) => Object.fromEntries(
|
|
|
4588
4627
|
var getAllTags = (schema2) => {
|
|
4589
4628
|
const rootTags = schema2.tags ?? [];
|
|
4590
4629
|
const operations = Object.values(schema2.paths ?? {}).flatMap(
|
|
4591
|
-
(
|
|
4630
|
+
(path31) => HttpMethods.map((k) => path31?.[k]).filter((op) => op != null)
|
|
4592
4631
|
);
|
|
4593
4632
|
const operationTags = new Set(operations.flatMap((op) => op.tags ?? []));
|
|
4594
4633
|
const hasUntaggedOperations = operations.some(
|
|
@@ -4643,7 +4682,7 @@ var getAllSlugs = (ops, schemaTags = []) => {
|
|
|
4643
4682
|
var getOperationSlugKey = (op) => [op.path, op.method, op.operationId, op.summary].filter(Boolean).join("-");
|
|
4644
4683
|
var getAllOperations = (paths) => {
|
|
4645
4684
|
const operations = Object.entries(paths ?? {}).flatMap(
|
|
4646
|
-
([
|
|
4685
|
+
([path31, value]) => HttpMethods.flatMap((method) => {
|
|
4647
4686
|
if (!value?.[method]) return [];
|
|
4648
4687
|
const operation = value[method];
|
|
4649
4688
|
const pathParameters = value.parameters ?? [];
|
|
@@ -4663,7 +4702,7 @@ var getAllOperations = (paths) => {
|
|
|
4663
4702
|
return {
|
|
4664
4703
|
...operation,
|
|
4665
4704
|
method,
|
|
4666
|
-
path:
|
|
4705
|
+
path: path31,
|
|
4667
4706
|
parameters,
|
|
4668
4707
|
servers,
|
|
4669
4708
|
tags: operation.tags ?? []
|
|
@@ -5161,8 +5200,8 @@ var Schema = builder.objectRef("Schema").implement({
|
|
|
5161
5200
|
}),
|
|
5162
5201
|
paths: t.field({
|
|
5163
5202
|
type: [PathItem],
|
|
5164
|
-
resolve: (root) => Object.entries(root.paths ?? {}).map(([
|
|
5165
|
-
path:
|
|
5203
|
+
resolve: (root) => Object.entries(root.paths ?? {}).map(([path31, value]) => ({
|
|
5204
|
+
path: path31,
|
|
5166
5205
|
// biome-ignore lint/style/noNonNullAssertion: value is guaranteed to be defined
|
|
5167
5206
|
methods: Object.keys(value)
|
|
5168
5207
|
}))
|
|
@@ -5266,11 +5305,9 @@ var ensureArray = (value) => Array.isArray(value) ? value : [value];
|
|
|
5266
5305
|
|
|
5267
5306
|
// src/vite/api/SchemaManager.ts
|
|
5268
5307
|
import fs from "node:fs/promises";
|
|
5269
|
-
import
|
|
5270
|
-
import {
|
|
5271
|
-
|
|
5272
|
-
} from "@apidevtools/json-schema-ref-parser";
|
|
5273
|
-
import { upgrade, validate as validate2 } from "@scalar/openapi-parser";
|
|
5308
|
+
import path8 from "node:path";
|
|
5309
|
+
import { $RefParser as $RefParser2 } from "@apidevtools/json-schema-ref-parser";
|
|
5310
|
+
import { upgrade } from "@scalar/openapi-parser";
|
|
5274
5311
|
import { deepEqual } from "fast-equals";
|
|
5275
5312
|
|
|
5276
5313
|
// src/lib/util/flattenAllOfProcessor.ts
|
|
@@ -5318,7 +5355,7 @@ init_joinUrl();
|
|
|
5318
5355
|
|
|
5319
5356
|
// src/vite/api/schema-codegen.ts
|
|
5320
5357
|
var unescapeJsonPointer = (uri) => decodeURIComponent(uri.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
5321
|
-
var getSegmentsFromPath = (
|
|
5358
|
+
var getSegmentsFromPath = (path31) => path31.split("/").slice(1).map(unescapeJsonPointer);
|
|
5322
5359
|
var createLocalRefMap = (obj) => {
|
|
5323
5360
|
const refMap = /* @__PURE__ */ new Map();
|
|
5324
5361
|
const siblingsMap = /* @__PURE__ */ new Map();
|
|
@@ -5349,16 +5386,16 @@ var replaceMarkers = (code, mergedRefs) => code.replace(/"__refMap:(.*?)"/g, '__
|
|
|
5349
5386
|
/"__refMap\+Siblings:(.*?)"/g,
|
|
5350
5387
|
(_, key) => mergedRefs.get(key) ?? `__refMap["${key}"]`
|
|
5351
5388
|
);
|
|
5352
|
-
var lookup = (schema2,
|
|
5353
|
-
const parts = getSegmentsFromPath(
|
|
5389
|
+
var lookup = (schema2, path31, filePath) => {
|
|
5390
|
+
const parts = getSegmentsFromPath(path31);
|
|
5354
5391
|
let val = schema2;
|
|
5355
5392
|
for (const part of parts) {
|
|
5356
5393
|
while (val.$ref?.startsWith("#/")) {
|
|
5357
|
-
val = val.$ref ===
|
|
5394
|
+
val = val.$ref === path31 ? val : lookup(schema2, val.$ref, filePath);
|
|
5358
5395
|
}
|
|
5359
5396
|
if (val[part] === void 0) {
|
|
5360
5397
|
throw new Error(
|
|
5361
|
-
`Error in ${filePath ?? "code generation"}: Could not find path segment ${part} in path: ${
|
|
5398
|
+
`Error in ${filePath ?? "code generation"}: Could not find path segment ${part} in path: ${path31}`
|
|
5362
5399
|
);
|
|
5363
5400
|
}
|
|
5364
5401
|
val = val[part];
|
|
@@ -5450,24 +5487,30 @@ var SchemaManager = class {
|
|
|
5450
5487
|
this.storeDir = storeDir;
|
|
5451
5488
|
this.config = config;
|
|
5452
5489
|
this.processors = [
|
|
5453
|
-
({ schema: schema2 }) =>
|
|
5490
|
+
({ schema: schema2 }) => {
|
|
5491
|
+
const upgraded = upgrade(schema2).specification;
|
|
5492
|
+
if (upgraded?.info && typeof upgraded.info.version !== "string") {
|
|
5493
|
+
upgraded.info.version = "0.0.1";
|
|
5494
|
+
}
|
|
5495
|
+
return upgraded;
|
|
5496
|
+
},
|
|
5454
5497
|
flattenAllOfProcessor,
|
|
5455
5498
|
...processors
|
|
5456
5499
|
];
|
|
5457
5500
|
}
|
|
5458
5501
|
getPathForFile = (input, params) => {
|
|
5459
|
-
const filePath =
|
|
5502
|
+
const filePath = path8.resolve(this.config.__meta.rootDir, input);
|
|
5460
5503
|
const apis = ensureArray(this.config.apis ?? []);
|
|
5461
5504
|
for (const apiConfig of apis) {
|
|
5462
5505
|
if (!apiConfig || apiConfig.type !== "file" || !apiConfig.path) continue;
|
|
5463
5506
|
const match = normalizeInputs(apiConfig.input).some(
|
|
5464
|
-
(i) =>
|
|
5507
|
+
(i) => path8.resolve(this.config.__meta.rootDir, i.input) === filePath && deepEqual(i.params, params)
|
|
5465
5508
|
);
|
|
5466
5509
|
if (match) return apiConfig.path;
|
|
5467
5510
|
}
|
|
5468
5511
|
};
|
|
5469
5512
|
processSchema = async (input) => {
|
|
5470
|
-
const filePath =
|
|
5513
|
+
const filePath = path8.resolve(this.config.__meta.rootDir, input.input);
|
|
5471
5514
|
const params = input.params;
|
|
5472
5515
|
const configuredPath = this.getPathForFile(input.input, params);
|
|
5473
5516
|
if (!configuredPath) {
|
|
@@ -5485,7 +5528,6 @@ var SchemaManager = class {
|
|
|
5485
5528
|
}
|
|
5486
5529
|
this.referencedBy.get(file)?.add(filePath);
|
|
5487
5530
|
});
|
|
5488
|
-
const validatedSchema = await this.validateSchema(schema2, filePath);
|
|
5489
5531
|
const processedSchema = await this.processors.reduce(
|
|
5490
5532
|
async (schema3, processor) => processor({
|
|
5491
5533
|
schema: await schema3,
|
|
@@ -5498,14 +5540,14 @@ var SchemaManager = class {
|
|
|
5498
5540
|
}
|
|
5499
5541
|
})
|
|
5500
5542
|
}),
|
|
5501
|
-
Promise.resolve(
|
|
5543
|
+
Promise.resolve(schema2)
|
|
5502
5544
|
);
|
|
5503
5545
|
const processedTime = Date.now();
|
|
5504
5546
|
const code = generateCode(processedSchema, filePath);
|
|
5505
5547
|
const prefixPath = slugify(configuredPath);
|
|
5506
|
-
const processedFilePath =
|
|
5548
|
+
const processedFilePath = path8.posix.join(
|
|
5507
5549
|
this.storeDir,
|
|
5508
|
-
`${prefixPath}-${
|
|
5550
|
+
`${prefixPath}-${path8.basename(filePath)}${paramsSuffix(params)}.js`
|
|
5509
5551
|
);
|
|
5510
5552
|
const importKey = processedFilePath;
|
|
5511
5553
|
await fs.writeFile(processedFilePath, code);
|
|
@@ -5558,7 +5600,7 @@ var SchemaManager = class {
|
|
|
5558
5600
|
};
|
|
5559
5601
|
getAllTrackedFiles = () => Array.from(this.referencedBy.keys());
|
|
5560
5602
|
getFilesToReprocess = (changedFile) => {
|
|
5561
|
-
const resolvedPath =
|
|
5603
|
+
const resolvedPath = path8.resolve(this.config.__meta.rootDir, changedFile);
|
|
5562
5604
|
const referencedBy = this.referencedBy.get(resolvedPath);
|
|
5563
5605
|
if (!referencedBy) return [];
|
|
5564
5606
|
const filesToProcess = referencedBy.size === 0 ? [resolvedPath] : Array.from(referencedBy);
|
|
@@ -5587,7 +5629,7 @@ var SchemaManager = class {
|
|
|
5587
5629
|
version: "",
|
|
5588
5630
|
path: input.path ?? "",
|
|
5589
5631
|
label: input.label,
|
|
5590
|
-
inputPath:
|
|
5632
|
+
inputPath: path8.resolve(this.config.__meta.rootDir, input.input),
|
|
5591
5633
|
params: input.params,
|
|
5592
5634
|
importKey: "",
|
|
5593
5635
|
downloadUrl: "",
|
|
@@ -5607,8 +5649,8 @@ var SchemaManager = class {
|
|
|
5607
5649
|
}
|
|
5608
5650
|
}
|
|
5609
5651
|
};
|
|
5610
|
-
getLatestSchema = (
|
|
5611
|
-
getSchemasForPath = (
|
|
5652
|
+
getLatestSchema = (path31) => this.processedSchemas[path31]?.at(0);
|
|
5653
|
+
getSchemasForPath = (path31) => this.processedSchemas[path31];
|
|
5612
5654
|
getSchemaImports = () => Object.values(this.processedSchemas).flat().filter((s) => s.importKey);
|
|
5613
5655
|
getUrlToFilePathMap = () => {
|
|
5614
5656
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -5630,7 +5672,7 @@ var SchemaManager = class {
|
|
|
5630
5672
|
};
|
|
5631
5673
|
createSchemaPath = (inputPath, versionPath, apiPath, params, config) => {
|
|
5632
5674
|
const suffix = paramsSuffix(params);
|
|
5633
|
-
const extension = suffix ? ".json" :
|
|
5675
|
+
const extension = suffix ? ".json" : path8.extname(inputPath);
|
|
5634
5676
|
const fileName = config?.schemaDownload?.fileName ?? this.config.defaults?.apis?.schemaDownload?.fileName ?? "schema";
|
|
5635
5677
|
return joinUrl(
|
|
5636
5678
|
this.config.basePath,
|
|
@@ -5639,20 +5681,10 @@ var SchemaManager = class {
|
|
|
5639
5681
|
`${fileName}${suffix}${extension}`
|
|
5640
5682
|
);
|
|
5641
5683
|
};
|
|
5642
|
-
validateSchema = async (schema2, filePath) => {
|
|
5643
|
-
const validated = await validate2(schema2);
|
|
5644
|
-
if (validated.errors?.length) {
|
|
5645
|
-
console.warn(`Schema warnings in ${filePath}:`);
|
|
5646
|
-
for (const error of validated.errors) {
|
|
5647
|
-
console.warn(error);
|
|
5648
|
-
}
|
|
5649
|
-
}
|
|
5650
|
-
return schema2;
|
|
5651
|
-
};
|
|
5652
5684
|
};
|
|
5653
5685
|
|
|
5654
5686
|
// src/vite/plugin-config-reload.ts
|
|
5655
|
-
import
|
|
5687
|
+
import path11 from "node:path";
|
|
5656
5688
|
import colors3 from "picocolors";
|
|
5657
5689
|
|
|
5658
5690
|
// src/vite/plugin-navigation.ts
|
|
@@ -5660,14 +5692,14 @@ import { stringify as stringify3 } from "javascript-stringify";
|
|
|
5660
5692
|
import { isElement } from "react-is";
|
|
5661
5693
|
|
|
5662
5694
|
// src/config/validators/NavigationSchema.ts
|
|
5663
|
-
import
|
|
5695
|
+
import path9 from "node:path";
|
|
5664
5696
|
import { glob } from "glob";
|
|
5665
5697
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
5666
5698
|
import { mdxFromMarkdown } from "mdast-util-mdx";
|
|
5667
5699
|
import { mdxjs } from "micromark-extension-mdxjs";
|
|
5668
5700
|
|
|
5669
5701
|
// src/lib/util/readFrontmatter.ts
|
|
5670
|
-
import { readFile } from "node:fs/promises";
|
|
5702
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
5671
5703
|
import matter from "gray-matter";
|
|
5672
5704
|
import { parse, stringify as stringify2 } from "yaml";
|
|
5673
5705
|
var yaml = {
|
|
@@ -5675,7 +5707,7 @@ var yaml = {
|
|
|
5675
5707
|
stringify: (obj) => stringify2(obj)
|
|
5676
5708
|
};
|
|
5677
5709
|
var readFrontmatter = async (filePath) => {
|
|
5678
|
-
const content = await
|
|
5710
|
+
const content = await readFile2(filePath, "utf-8");
|
|
5679
5711
|
const normalizedContent = content.replace(/\r\n/g, "\n");
|
|
5680
5712
|
return matter(normalizedContent, { engines: { yaml } });
|
|
5681
5713
|
};
|
|
@@ -5710,7 +5742,7 @@ var extractRichH1 = (content) => {
|
|
|
5710
5742
|
}
|
|
5711
5743
|
};
|
|
5712
5744
|
var isNavigationItem = (item) => item !== void 0;
|
|
5713
|
-
var toPosixPath = (filePath) => filePath.split(
|
|
5745
|
+
var toPosixPath = (filePath) => filePath.split(path9.win32.sep).join(path9.posix.sep);
|
|
5714
5746
|
var NavigationResolver = class {
|
|
5715
5747
|
rootDir;
|
|
5716
5748
|
globPatterns;
|
|
@@ -5843,13 +5875,13 @@ var NavigationResolver = class {
|
|
|
5843
5875
|
|
|
5844
5876
|
// src/vite/debug.ts
|
|
5845
5877
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5846
|
-
import
|
|
5878
|
+
import path10 from "node:path";
|
|
5847
5879
|
async function writePluginDebugCode(rootDir, pluginName, code, extension = "js") {
|
|
5848
5880
|
if (process.env.ZUDOKU_BUILD_DEBUG) {
|
|
5849
|
-
const debugDir =
|
|
5881
|
+
const debugDir = path10.join(rootDir, "dist", "debug");
|
|
5850
5882
|
await mkdir(debugDir, { recursive: true });
|
|
5851
5883
|
await writeFile(
|
|
5852
|
-
|
|
5884
|
+
path10.join(debugDir, `${pluginName}.${extension}`),
|
|
5853
5885
|
typeof code === "string" ? code : code.join("\n")
|
|
5854
5886
|
);
|
|
5855
5887
|
}
|
|
@@ -5960,7 +5992,7 @@ var viteConfigReloadPlugin = () => ({
|
|
|
5960
5992
|
});
|
|
5961
5993
|
logger.info(
|
|
5962
5994
|
colors3.blue(
|
|
5963
|
-
`Config ${
|
|
5995
|
+
`Config ${path11.basename(currentConfig.__meta.configPath)} changed. Reloading...`
|
|
5964
5996
|
),
|
|
5965
5997
|
{ timestamp: true }
|
|
5966
5998
|
);
|
|
@@ -5975,11 +6007,11 @@ var viteApiPlugin = async () => {
|
|
|
5975
6007
|
const resolvedVirtualModuleId4 = `\0${virtualModuleId4}`;
|
|
5976
6008
|
const initialConfig = getCurrentConfig();
|
|
5977
6009
|
const zuploProcessors = ZuploEnv.isZuplo ? await runnerImport3(
|
|
5978
|
-
|
|
6010
|
+
path12.resolve(getZudokuRootDir(), "src/zuplo/with-zuplo-processors.ts")
|
|
5979
6011
|
).then((m) => m.module.default(initialConfig.__meta.rootDir)) : [];
|
|
5980
6012
|
const buildConfig = await getBuildConfig();
|
|
5981
6013
|
const buildProcessors = buildConfig?.processors ?? [];
|
|
5982
|
-
const tmpStoreDir =
|
|
6014
|
+
const tmpStoreDir = path12.posix.join(
|
|
5983
6015
|
initialConfig.__meta.rootDir,
|
|
5984
6016
|
PROCESSED_STORE_SUBPATH
|
|
5985
6017
|
);
|
|
@@ -6007,7 +6039,7 @@ var viteApiPlugin = async () => {
|
|
|
6007
6039
|
const inputPath = pathMap.get(req.url);
|
|
6008
6040
|
if (!inputPath) return next();
|
|
6009
6041
|
const content = await fs2.readFile(inputPath, "utf-8");
|
|
6010
|
-
const mimeType =
|
|
6042
|
+
const mimeType = path12.extname(inputPath).toLowerCase() === ".json" ? "application/json" : "application/x-yaml";
|
|
6011
6043
|
res.setHeader("Content-Type", `${mimeType}; charset=utf-8`);
|
|
6012
6044
|
return res.end(content);
|
|
6013
6045
|
});
|
|
@@ -6233,8 +6265,8 @@ var viteApiPlugin = async () => {
|
|
|
6233
6265
|
if (process.env.NODE_ENV !== "production") return;
|
|
6234
6266
|
for (const [urlPath, inputPath] of pathMap) {
|
|
6235
6267
|
const content = await fs2.readFile(inputPath, "utf-8");
|
|
6236
|
-
const outputPath =
|
|
6237
|
-
await fs2.mkdir(
|
|
6268
|
+
const outputPath = path12.join(config.__meta.rootDir, "dist", urlPath);
|
|
6269
|
+
await fs2.mkdir(path12.dirname(outputPath), { recursive: true });
|
|
6238
6270
|
await fs2.writeFile(outputPath, content, "utf-8");
|
|
6239
6271
|
}
|
|
6240
6272
|
}
|
|
@@ -6399,7 +6431,7 @@ var viteDocMetadataPlugin = () => ({
|
|
|
6399
6431
|
});
|
|
6400
6432
|
|
|
6401
6433
|
// src/vite/plugin-docs.ts
|
|
6402
|
-
import
|
|
6434
|
+
import path13 from "node:path";
|
|
6403
6435
|
import { glob as glob3 } from "glob";
|
|
6404
6436
|
import globParent from "glob-parent";
|
|
6405
6437
|
|
|
@@ -6466,7 +6498,7 @@ var globMarkdownFiles = async (config, options = { absolute: false }) => {
|
|
|
6466
6498
|
if (process.env.NODE_ENV !== "development") {
|
|
6467
6499
|
const draftStatuses = await Promise.all(
|
|
6468
6500
|
globbedFiles.map(async (file) => {
|
|
6469
|
-
const absolutePath =
|
|
6501
|
+
const absolutePath = path13.resolve(config.__meta.rootDir, file);
|
|
6470
6502
|
const { data } = await readFrontmatter(absolutePath);
|
|
6471
6503
|
return { file, isDraft: data.draft === true };
|
|
6472
6504
|
})
|
|
@@ -6479,9 +6511,9 @@ var globMarkdownFiles = async (config, options = { absolute: false }) => {
|
|
|
6479
6511
|
if (draftFiles.has(file)) {
|
|
6480
6512
|
continue;
|
|
6481
6513
|
}
|
|
6482
|
-
const relativePath =
|
|
6514
|
+
const relativePath = path13.posix.relative(parent, file);
|
|
6483
6515
|
const routePath = ensureLeadingSlash(relativePath.replace(/\.mdx?$/, ""));
|
|
6484
|
-
const filePath = options.absolute ?
|
|
6516
|
+
const filePath = options.absolute ? path13.resolve(config.__meta.rootDir, file) : file;
|
|
6485
6517
|
fileMapping[routePath] = filePath;
|
|
6486
6518
|
}
|
|
6487
6519
|
}
|
|
@@ -6565,7 +6597,7 @@ var plugin_docs_default = viteDocsPlugin;
|
|
|
6565
6597
|
|
|
6566
6598
|
// src/vite/plugin-markdown-export.ts
|
|
6567
6599
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
6568
|
-
import
|
|
6600
|
+
import path14 from "node:path";
|
|
6569
6601
|
init_joinUrl();
|
|
6570
6602
|
var processMarkdownFile = async (filePath) => {
|
|
6571
6603
|
const { content: markdownContent, data: frontmatter } = await readFrontmatter(filePath);
|
|
@@ -6582,7 +6614,7 @@ ${markdownContent}`;
|
|
|
6582
6614
|
};
|
|
6583
6615
|
var getMarkdownOutputPath = (distDir, routePath) => {
|
|
6584
6616
|
const segments = routePath === "/" ? ["index"] : routePath.split("/").filter(Boolean);
|
|
6585
|
-
return `${
|
|
6617
|
+
return `${path14.join(distDir, ...segments)}.md`;
|
|
6586
6618
|
};
|
|
6587
6619
|
var resolveMarkdownRoutePath = (requestUrl, basePath) => {
|
|
6588
6620
|
const pathname = requestUrl.split(/[?#]/)[0] ?? requestUrl;
|
|
@@ -6654,7 +6686,7 @@ var viteMarkdownExportPlugin = () => {
|
|
|
6654
6686
|
if (process.env.NODE_ENV !== "production" || Object.keys(markdownFiles).length === 0 || !needsMdFiles(config)) {
|
|
6655
6687
|
return;
|
|
6656
6688
|
}
|
|
6657
|
-
const distDir =
|
|
6689
|
+
const distDir = path14.join(
|
|
6658
6690
|
config.__meta.rootDir,
|
|
6659
6691
|
"dist",
|
|
6660
6692
|
config.basePath ?? ""
|
|
@@ -6675,14 +6707,14 @@ var viteMarkdownExportPlugin = () => {
|
|
|
6675
6707
|
content: finalMarkdown
|
|
6676
6708
|
});
|
|
6677
6709
|
const outputPath = getMarkdownOutputPath(distDir, routePath);
|
|
6678
|
-
await mkdir2(
|
|
6710
|
+
await mkdir2(path14.dirname(outputPath), { recursive: true });
|
|
6679
6711
|
await writeFile2(outputPath, finalMarkdown, "utf-8");
|
|
6680
6712
|
} catch (error) {
|
|
6681
6713
|
console.warn(`Failed to export markdown for ${routePath}:`, error);
|
|
6682
6714
|
}
|
|
6683
6715
|
}
|
|
6684
6716
|
if (config.docs.llms.llmsTxt || config.docs.llms.llmsTxtFull) {
|
|
6685
|
-
const markdownInfoPath =
|
|
6717
|
+
const markdownInfoPath = path14.join(
|
|
6686
6718
|
config.__meta.rootDir,
|
|
6687
6719
|
"node_modules/.zudoku/markdown-info.json"
|
|
6688
6720
|
);
|
|
@@ -6699,9 +6731,11 @@ var plugin_markdown_export_default = viteMarkdownExportPlugin;
|
|
|
6699
6731
|
|
|
6700
6732
|
// src/vite/plugin-mdx.ts
|
|
6701
6733
|
import rehypeMetaAsAttributes from "@lekoarts/rehype-meta-as-attributes";
|
|
6734
|
+
import { nodeTypes } from "@mdx-js/mdx";
|
|
6702
6735
|
import mdx from "@mdx-js/rollup";
|
|
6703
6736
|
import { toString as hastToString2 } from "hast-util-to-string";
|
|
6704
6737
|
import rehypeMdxImportMedia from "rehype-mdx-import-media";
|
|
6738
|
+
import rehypeRaw from "rehype-raw";
|
|
6705
6739
|
import rehypeSlug from "rehype-slug";
|
|
6706
6740
|
import remarkComment from "remark-comment";
|
|
6707
6741
|
import remarkDirective from "remark-directive";
|
|
@@ -6832,9 +6866,9 @@ var remarkCodeTabs = () => (tree) => {
|
|
|
6832
6866
|
};
|
|
6833
6867
|
|
|
6834
6868
|
// src/vite/mdx/remark-inject-filepath.ts
|
|
6835
|
-
import
|
|
6869
|
+
import path15 from "node:path";
|
|
6836
6870
|
var remarkInjectFilepath = (rootDir) => (tree, vfile) => {
|
|
6837
|
-
const relativePath =
|
|
6871
|
+
const relativePath = path15.relative(rootDir, vfile.path).split(path15.sep).join(path15.posix.sep);
|
|
6838
6872
|
tree.children.unshift(exportMdxjsConst("__filepath", relativePath));
|
|
6839
6873
|
};
|
|
6840
6874
|
|
|
@@ -6921,7 +6955,7 @@ var remarkLastModified = () => {
|
|
|
6921
6955
|
};
|
|
6922
6956
|
|
|
6923
6957
|
// src/vite/mdx/remark-link-rewrite.ts
|
|
6924
|
-
import
|
|
6958
|
+
import path16 from "node:path";
|
|
6925
6959
|
import { visit as visit5 } from "unist-util-visit";
|
|
6926
6960
|
var markdownExtension = /\.mdx?$/;
|
|
6927
6961
|
var resolveToRoute = (url, filePath, routesByFile) => {
|
|
@@ -6929,7 +6963,7 @@ var resolveToRoute = (url, filePath, routesByFile) => {
|
|
|
6929
6963
|
if (!markdownExtension.test(pathname) || pathname.startsWith("/")) {
|
|
6930
6964
|
return void 0;
|
|
6931
6965
|
}
|
|
6932
|
-
const targetFile =
|
|
6966
|
+
const targetFile = path16.resolve(path16.dirname(filePath), pathname).replace(markdownExtension, "");
|
|
6933
6967
|
const route = routesByFile.get(targetFile);
|
|
6934
6968
|
if (route === void 0) return void 0;
|
|
6935
6969
|
return `${route}${suffix}`;
|
|
@@ -6944,11 +6978,11 @@ var remarkLinkRewrite = (basePath = "", routesByFile = /* @__PURE__ */ new Map()
|
|
|
6944
6978
|
node.url = resolved;
|
|
6945
6979
|
return;
|
|
6946
6980
|
}
|
|
6947
|
-
const base =
|
|
6981
|
+
const base = path16.posix.join(basePath);
|
|
6948
6982
|
if (basePath && node.url.startsWith(base)) {
|
|
6949
6983
|
node.url = node.url.slice(base.length);
|
|
6950
6984
|
} else if (!node.url.startsWith("/") && !node.url.startsWith("#")) {
|
|
6951
|
-
node.url =
|
|
6985
|
+
node.url = path16.posix.join("..", node.url);
|
|
6952
6986
|
}
|
|
6953
6987
|
node.url = node.url.replace(/\.mdx?(#.*)?$/, "$1");
|
|
6954
6988
|
});
|
|
@@ -7146,6 +7180,7 @@ var viteMdxPlugin = async () => {
|
|
|
7146
7180
|
];
|
|
7147
7181
|
const remarkPlugins = typeof buildConfig?.remarkPlugins === "function" ? buildConfig.remarkPlugins(defaultRemarkPlugins) : [...defaultRemarkPlugins, ...buildConfig?.remarkPlugins ?? []];
|
|
7148
7182
|
const defaultRehypePlugins = [
|
|
7183
|
+
[rehypeRaw, { passThrough: nodeTypes }],
|
|
7149
7184
|
rehypeSlug,
|
|
7150
7185
|
rehype_extract_toc_with_jsx_default,
|
|
7151
7186
|
rehype_extract_toc_with_jsx_export_default,
|
|
@@ -7456,8 +7491,8 @@ var protectedAnnotatorPlugin = () => ({
|
|
|
7456
7491
|
});
|
|
7457
7492
|
|
|
7458
7493
|
// src/vite/config.ts
|
|
7459
|
-
var getAppClientEntryPath = () =>
|
|
7460
|
-
var getAppServerEntryPath = () =>
|
|
7494
|
+
var getAppClientEntryPath = () => path17.posix.join(getZudokuRootDir(), "src/app/entry.client.tsx");
|
|
7495
|
+
var getAppServerEntryPath = () => path17.posix.join(getZudokuRootDir(), "src/app/entry.server.tsx");
|
|
7461
7496
|
var hasLoggedCdnInfo = false;
|
|
7462
7497
|
var MEDIA_REGEX = /\.(a?png|jpe?g|gif|bmp|svg|webp|tiff|ico|webm|ogg|mp3|wav|m4a|avif|mp4)/i;
|
|
7463
7498
|
var defineEnvVars = (vars) => Object.fromEntries(
|
|
@@ -7491,7 +7526,7 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7491
7526
|
);
|
|
7492
7527
|
if (ZuploEnv.isZuplo) {
|
|
7493
7528
|
dotenv.config({
|
|
7494
|
-
path:
|
|
7529
|
+
path: path17.resolve(config.__meta.rootDir, "../.env.zuplo"),
|
|
7495
7530
|
quiet: true
|
|
7496
7531
|
});
|
|
7497
7532
|
}
|
|
@@ -7551,7 +7586,7 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7551
7586
|
sourcemap: true,
|
|
7552
7587
|
target: "es2022",
|
|
7553
7588
|
chunkSizeWarningLimit: 1500,
|
|
7554
|
-
outDir:
|
|
7589
|
+
outDir: path17.resolve(path17.join(dir, "dist", config.basePath ?? "")),
|
|
7555
7590
|
emptyOutDir: false,
|
|
7556
7591
|
rolldownOptions: {
|
|
7557
7592
|
external: [joinUrl(config.basePath, "/pagefind/pagefind.js")],
|
|
@@ -7581,8 +7616,8 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7581
7616
|
external: ["@shikijs/themes", "@shikijs/langs"]
|
|
7582
7617
|
},
|
|
7583
7618
|
build: {
|
|
7584
|
-
outDir:
|
|
7585
|
-
|
|
7619
|
+
outDir: path17.resolve(
|
|
7620
|
+
path17.join(dir, "dist", config.basePath ?? "", "server")
|
|
7586
7621
|
),
|
|
7587
7622
|
copyPublicDir: false,
|
|
7588
7623
|
rolldownOptions: {
|
|
@@ -7597,7 +7632,7 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7597
7632
|
if (filename.startsWith(`${PROTECTED_CHUNK_DIR}/`)) {
|
|
7598
7633
|
return joinUrl(config.basePath, `/${filename}`);
|
|
7599
7634
|
}
|
|
7600
|
-
if (cdnUrl?.base && [".js", ".css"].includes(
|
|
7635
|
+
if (cdnUrl?.base && [".js", ".css"].includes(path17.extname(filename))) {
|
|
7601
7636
|
return joinUrl(cdnUrl.base, filename);
|
|
7602
7637
|
}
|
|
7603
7638
|
if (cdnUrl?.media && MEDIA_REGEX.test(filename)) {
|
|
@@ -7607,7 +7642,7 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7607
7642
|
}
|
|
7608
7643
|
},
|
|
7609
7644
|
optimizeDeps: {
|
|
7610
|
-
entries: [
|
|
7645
|
+
entries: [path17.posix.join(getZudokuRootDir(), "src/{app,lib}/**")],
|
|
7611
7646
|
exclude: ["zudoku"],
|
|
7612
7647
|
include: [
|
|
7613
7648
|
"@mdx-js/react",
|
|
@@ -7704,10 +7739,10 @@ ${cssLinks}
|
|
|
7704
7739
|
|
|
7705
7740
|
// src/vite/manifest.ts
|
|
7706
7741
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
7707
|
-
import
|
|
7742
|
+
import path18 from "node:path";
|
|
7708
7743
|
var writeManifest = async (distDir, config) => {
|
|
7709
7744
|
await writeFile3(
|
|
7710
|
-
|
|
7745
|
+
path18.join(distDir, MANIFEST_FILENAME),
|
|
7711
7746
|
`${JSON.stringify(buildManifest(config), null, 2)}
|
|
7712
7747
|
`,
|
|
7713
7748
|
"utf-8"
|
|
@@ -7717,7 +7752,7 @@ var writeManifest = async (distDir, config) => {
|
|
|
7717
7752
|
// src/vite/output.ts
|
|
7718
7753
|
import assert from "node:assert";
|
|
7719
7754
|
import { cp, mkdir as mkdir3, writeFile as writeFile4 } from "node:fs/promises";
|
|
7720
|
-
import
|
|
7755
|
+
import path19 from "node:path";
|
|
7721
7756
|
init_joinUrl();
|
|
7722
7757
|
var pkgJson = getZudokuPackageJson();
|
|
7723
7758
|
function generateOutput({
|
|
@@ -7775,9 +7810,9 @@ async function writeOutput(dir, {
|
|
|
7775
7810
|
rewrites
|
|
7776
7811
|
}) {
|
|
7777
7812
|
const output = generateOutput({ config, redirects, rewrites });
|
|
7778
|
-
const outputDir = process.env.VERCEL ?
|
|
7813
|
+
const outputDir = process.env.VERCEL ? path19.join(dir, ".vercel/output") : path19.join(dir, "dist/.output");
|
|
7779
7814
|
await mkdir3(outputDir, { recursive: true });
|
|
7780
|
-
const outputFile =
|
|
7815
|
+
const outputFile = path19.join(outputDir, "config.json");
|
|
7781
7816
|
await writeFile4(outputFile, JSON.stringify(output, null, 2), "utf-8");
|
|
7782
7817
|
if (process.env.VERCEL) {
|
|
7783
7818
|
console.log("Wrote Vercel output to", outputDir);
|
|
@@ -7786,9 +7821,9 @@ async function writeOutput(dir, {
|
|
|
7786
7821
|
|
|
7787
7822
|
// src/vite/prerender/prerender.ts
|
|
7788
7823
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
7789
|
-
import { readFile as
|
|
7824
|
+
import { readFile as readFile3, rm } from "node:fs/promises";
|
|
7790
7825
|
import os from "node:os";
|
|
7791
|
-
import
|
|
7826
|
+
import path22 from "node:path";
|
|
7792
7827
|
import { pathToFileURL } from "node:url";
|
|
7793
7828
|
import { createIndex } from "pagefind";
|
|
7794
7829
|
import colors7 from "picocolors";
|
|
@@ -7828,7 +7863,7 @@ function throttle(fn) {
|
|
|
7828
7863
|
init_joinUrl();
|
|
7829
7864
|
import { createWriteStream, existsSync } from "node:fs";
|
|
7830
7865
|
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
7831
|
-
import
|
|
7866
|
+
import path20 from "node:path";
|
|
7832
7867
|
import colors5 from "picocolors";
|
|
7833
7868
|
import { SitemapStream } from "sitemap";
|
|
7834
7869
|
async function generateSitemap({
|
|
@@ -7842,11 +7877,11 @@ async function generateSitemap({
|
|
|
7842
7877
|
return;
|
|
7843
7878
|
}
|
|
7844
7879
|
const sitemap = new SitemapStream({ hostname: config.siteUrl });
|
|
7845
|
-
const outputDir =
|
|
7880
|
+
const outputDir = path20.resolve(baseOutputDir, config.outDir ?? "");
|
|
7846
7881
|
if (!existsSync(outputDir)) {
|
|
7847
7882
|
await mkdir4(outputDir, { recursive: true });
|
|
7848
7883
|
}
|
|
7849
|
-
const sitemapOutputPath =
|
|
7884
|
+
const sitemapOutputPath = path20.join(outputDir, "sitemap.xml");
|
|
7850
7885
|
const writeStream = createWriteStream(sitemapOutputPath);
|
|
7851
7886
|
sitemap.pipe(writeStream);
|
|
7852
7887
|
let lastmod;
|
|
@@ -7876,14 +7911,14 @@ async function generateSitemap({
|
|
|
7876
7911
|
|
|
7877
7912
|
// src/vite/prerender/utils.ts
|
|
7878
7913
|
init_joinUrl();
|
|
7879
|
-
var resolveRoutePath = (
|
|
7880
|
-
const segments =
|
|
7914
|
+
var resolveRoutePath = (path31) => {
|
|
7915
|
+
const segments = path31.split("/");
|
|
7881
7916
|
if (segments.some((s) => s.startsWith(":") && !s.endsWith("?"))) {
|
|
7882
7917
|
return void 0;
|
|
7883
7918
|
}
|
|
7884
7919
|
return segments.filter((s) => !s.startsWith(":")).join("/") || void 0;
|
|
7885
7920
|
};
|
|
7886
|
-
var isSkipped = (
|
|
7921
|
+
var isSkipped = (path31) => path31.includes("*") || /^\d+$/.test(path31);
|
|
7887
7922
|
var resolveRoutes = (routes, parentPath = "") => routes.flatMap((route) => {
|
|
7888
7923
|
if (route.path && isSkipped(route.path)) return [];
|
|
7889
7924
|
const routePath = route.path ? resolveRoutePath(route.path) : void 0;
|
|
@@ -7913,6 +7948,16 @@ var collectRewrites = (resolved) => resolved.flatMap((r) => [
|
|
|
7913
7948
|
]);
|
|
7914
7949
|
var routesToPaths = (routes) => collectPaths(resolveRoutes(routes), "");
|
|
7915
7950
|
var routesToRewrites = (routes) => collectRewrites(resolveRoutes(routes));
|
|
7951
|
+
var selectPagesToIndex = (pages, paths) => {
|
|
7952
|
+
const withUrl = pages.flatMap(({ indexStatusCode, html }, i) => {
|
|
7953
|
+
const url = paths[i];
|
|
7954
|
+
return url === void 0 ? [] : [{ url, html, indexStatusCode }];
|
|
7955
|
+
});
|
|
7956
|
+
return {
|
|
7957
|
+
include: withUrl.filter((p) => p.indexStatusCode < 400).map(({ url, html }) => ({ url, html })),
|
|
7958
|
+
exclude: withUrl.filter((p) => p.indexStatusCode >= 400).map(({ url, indexStatusCode }) => ({ url, status: indexStatusCode }))
|
|
7959
|
+
};
|
|
7960
|
+
};
|
|
7916
7961
|
|
|
7917
7962
|
// src/vite/prerender/prerender.ts
|
|
7918
7963
|
var Piscina = PiscinaImport;
|
|
@@ -7932,12 +7977,12 @@ var prerender = async ({
|
|
|
7932
7977
|
serverConfigFilename,
|
|
7933
7978
|
writeRedirects = true
|
|
7934
7979
|
}) => {
|
|
7935
|
-
const distDir =
|
|
7980
|
+
const distDir = path22.join(dir, "dist", basePath);
|
|
7936
7981
|
const serverConfigPath = pathToFileURL(
|
|
7937
|
-
|
|
7982
|
+
path22.join(distDir, "server", serverConfigFilename)
|
|
7938
7983
|
).href;
|
|
7939
7984
|
const entryServerPath = pathToFileURL(
|
|
7940
|
-
|
|
7985
|
+
path22.join(distDir, "server/entry.server.js")
|
|
7941
7986
|
).href;
|
|
7942
7987
|
const rawConfig = await import(serverConfigPath).then((m) => m.default);
|
|
7943
7988
|
const config = validateConfig(await runPluginTransformConfig(rawConfig));
|
|
@@ -8026,9 +8071,18 @@ var prerender = async ({
|
|
|
8026
8071
|
logger.info(colors7.blue(message));
|
|
8027
8072
|
}
|
|
8028
8073
|
if (pagefindIndex) {
|
|
8029
|
-
const pagesToIndex =
|
|
8030
|
-
|
|
8074
|
+
const { include: pagesToIndex, exclude } = selectPagesToIndex(
|
|
8075
|
+
workerResults,
|
|
8076
|
+
paths
|
|
8031
8077
|
);
|
|
8078
|
+
if (exclude.length > 0) {
|
|
8079
|
+
const details = exclude.map(({ url, status }) => `${url} (${status})`).join(", ");
|
|
8080
|
+
logger.warn(
|
|
8081
|
+
colors7.yellow(
|
|
8082
|
+
`\u26A0 ${exclude.length} route(s) excluded from the search index (render status >= 400): ${details}`
|
|
8083
|
+
)
|
|
8084
|
+
);
|
|
8085
|
+
}
|
|
8032
8086
|
const BATCH_SIZE = 40;
|
|
8033
8087
|
const pagefindStart = performance.now();
|
|
8034
8088
|
for (let offset = 0; offset < pagesToIndex.length; offset += BATCH_SIZE) {
|
|
@@ -8047,7 +8101,7 @@ var prerender = async ({
|
|
|
8047
8101
|
}
|
|
8048
8102
|
if (isTTY()) writeLine("");
|
|
8049
8103
|
const { outputPath } = await pagefindIndex.writeFiles({
|
|
8050
|
-
outputPath:
|
|
8104
|
+
outputPath: path22.join(distDir, "pagefind")
|
|
8051
8105
|
});
|
|
8052
8106
|
if (outputPath) {
|
|
8053
8107
|
const duration = (performance.now() - pagefindStart) / 1e3;
|
|
@@ -8067,13 +8121,13 @@ var prerender = async ({
|
|
|
8067
8121
|
redirectUrls
|
|
8068
8122
|
});
|
|
8069
8123
|
const llmsConfig = config.docs.llms;
|
|
8070
|
-
const markdownInfoPath =
|
|
8124
|
+
const markdownInfoPath = path22.join(
|
|
8071
8125
|
dir,
|
|
8072
8126
|
"node_modules/.zudoku/markdown-info.json"
|
|
8073
8127
|
);
|
|
8074
8128
|
let markdownFileInfos = [];
|
|
8075
8129
|
if (await fileExists(markdownInfoPath)) {
|
|
8076
|
-
const markdownInfoContent = await
|
|
8130
|
+
const markdownInfoContent = await readFile3(markdownInfoPath, "utf-8");
|
|
8077
8131
|
markdownFileInfos = JSON.parse(markdownInfoContent);
|
|
8078
8132
|
}
|
|
8079
8133
|
if (llmsConfig.llmsTxt || llmsConfig.llmsTxtFull) {
|
|
@@ -8093,7 +8147,7 @@ var prerender = async ({
|
|
|
8093
8147
|
await Promise.all(
|
|
8094
8148
|
markdownFileInfos.map((info) => {
|
|
8095
8149
|
const outputPath = getMarkdownOutputPath(distDir, info.routePath);
|
|
8096
|
-
if (!
|
|
8150
|
+
if (!path22.resolve(outputPath).startsWith(path22.resolve(distDir))) {
|
|
8097
8151
|
return;
|
|
8098
8152
|
}
|
|
8099
8153
|
return rm(outputPath).catch(() => {
|
|
@@ -8151,8 +8205,8 @@ var getContainerMemoryLimitMb = () => {
|
|
|
8151
8205
|
};
|
|
8152
8206
|
|
|
8153
8207
|
// src/vite/protected/build.ts
|
|
8154
|
-
import { mkdir as mkdir5, readdir, readFile as
|
|
8155
|
-
import
|
|
8208
|
+
import { mkdir as mkdir5, readdir, readFile as readFile4, rename, rm as rm2 } from "node:fs/promises";
|
|
8209
|
+
import path23 from "node:path";
|
|
8156
8210
|
init_joinUrl();
|
|
8157
8211
|
var assertProtectedPatternsCovered = (config) => {
|
|
8158
8212
|
const { patterns } = getProtectedSourceMatcher(config);
|
|
@@ -8174,11 +8228,11 @@ var findProtectedLeaks = (output) => {
|
|
|
8174
8228
|
const visited = /* @__PURE__ */ new Set();
|
|
8175
8229
|
const stack = [{ fileName: entry.fileName, path: [entry.fileName] }];
|
|
8176
8230
|
while (stack.length > 0) {
|
|
8177
|
-
const { fileName, path:
|
|
8231
|
+
const { fileName, path: path31 } = stack.pop();
|
|
8178
8232
|
if (visited.has(fileName)) continue;
|
|
8179
8233
|
visited.add(fileName);
|
|
8180
8234
|
for (const imp of byFileName.get(fileName)?.imports ?? []) {
|
|
8181
|
-
const next = [...
|
|
8235
|
+
const next = [...path31, imp];
|
|
8182
8236
|
if (isProtected(imp)) {
|
|
8183
8237
|
leaks.push(next.join(" -> "));
|
|
8184
8238
|
continue;
|
|
@@ -8209,17 +8263,17 @@ This eagerly pulls gated content into the public bundle. Check that nothing in n
|
|
|
8209
8263
|
);
|
|
8210
8264
|
};
|
|
8211
8265
|
var moveProtectedChunks = async (clientOutDir, serverOutDir) => {
|
|
8212
|
-
const srcDir =
|
|
8266
|
+
const srcDir = path23.join(clientOutDir, PROTECTED_CHUNK_DIR);
|
|
8213
8267
|
const files = await readdir(srcDir).catch((err) => {
|
|
8214
8268
|
if (err.code === "ENOENT") return null;
|
|
8215
8269
|
throw err;
|
|
8216
8270
|
});
|
|
8217
8271
|
if (!files) return;
|
|
8218
|
-
const destDir =
|
|
8272
|
+
const destDir = path23.join(serverOutDir, PROTECTED_CHUNK_DIR);
|
|
8219
8273
|
await mkdir5(destDir, { recursive: true });
|
|
8220
8274
|
await Promise.all(
|
|
8221
8275
|
files.map(
|
|
8222
|
-
(file) => rename(
|
|
8276
|
+
(file) => rename(path23.join(srcDir, file), path23.join(destDir, file))
|
|
8223
8277
|
)
|
|
8224
8278
|
);
|
|
8225
8279
|
const leftover = await readdir(srcDir).catch(() => []);
|
|
@@ -8237,7 +8291,7 @@ var assertCloudflareWranglerGatesProtected = async (dir, config) => {
|
|
|
8237
8291
|
const protectedPrefix = `${joinUrl(config.basePath, PROTECTED_CHUNK_DIR)}/`;
|
|
8238
8292
|
const candidates = ["wrangler.toml", "wrangler.jsonc", "wrangler.json"];
|
|
8239
8293
|
for (const name of candidates) {
|
|
8240
|
-
const file = await
|
|
8294
|
+
const file = await readFile4(path23.join(dir, name), "utf-8").catch(
|
|
8241
8295
|
() => void 0
|
|
8242
8296
|
);
|
|
8243
8297
|
if (file === void 0) continue;
|
|
@@ -8265,7 +8319,7 @@ async function runBuild(options) {
|
|
|
8265
8319
|
const builder2 = await createBuilder(viteConfig);
|
|
8266
8320
|
invariant(builder2.environments.client, "Client environment is missing");
|
|
8267
8321
|
invariant(builder2.environments.ssr, "SSR environment is missing");
|
|
8268
|
-
const distDir =
|
|
8322
|
+
const distDir = path24.resolve(path24.join(dir, "dist"));
|
|
8269
8323
|
await rm3(distDir, { recursive: true, force: true });
|
|
8270
8324
|
const [clientResult, serverResult] = await Promise.all([
|
|
8271
8325
|
builder2.build(builder2.environments.client),
|
|
@@ -8315,13 +8369,13 @@ async function runBuild(options) {
|
|
|
8315
8369
|
await assertCloudflareWranglerGatesProtected(dir, config);
|
|
8316
8370
|
}
|
|
8317
8371
|
await writeFile6(
|
|
8318
|
-
|
|
8372
|
+
path24.join(distDir, "package.json"),
|
|
8319
8373
|
`${JSON.stringify({ type: "module" }, null, 2)}
|
|
8320
8374
|
`,
|
|
8321
8375
|
"utf-8"
|
|
8322
8376
|
);
|
|
8323
8377
|
await writeManifest(distDir, config);
|
|
8324
|
-
await rm3(
|
|
8378
|
+
await rm3(path24.join(clientOutDir, "index.html"), { force: true });
|
|
8325
8379
|
} else {
|
|
8326
8380
|
await runPrerender({
|
|
8327
8381
|
dir,
|
|
@@ -8352,25 +8406,25 @@ var runPrerender = async (options) => {
|
|
|
8352
8406
|
serverConfigFilename,
|
|
8353
8407
|
writeRedirects: process.env.VERCEL === void 0
|
|
8354
8408
|
});
|
|
8355
|
-
const indexHtml =
|
|
8409
|
+
const indexHtml = path24.join(clientOutDir, "index.html");
|
|
8356
8410
|
if (!workerResults.find((r) => r.outputPath === indexHtml)) {
|
|
8357
8411
|
await writeFile6(indexHtml, html, "utf-8");
|
|
8358
8412
|
}
|
|
8359
8413
|
const statusPages = workerResults.flatMap(
|
|
8360
|
-
(r) => /^(400|404|500)\.html$/.test(
|
|
8414
|
+
(r) => /^(400|404|500)\.html$/.test(path24.basename(r.outputPath)) ? r.outputPath : []
|
|
8361
8415
|
);
|
|
8362
8416
|
for (const statusPage of statusPages) {
|
|
8363
8417
|
await rename2(
|
|
8364
8418
|
statusPage,
|
|
8365
|
-
|
|
8419
|
+
path24.join(dir, DIST_DIR, path24.basename(statusPage))
|
|
8366
8420
|
);
|
|
8367
8421
|
}
|
|
8368
8422
|
await rm3(serverOutDir, { recursive: true, force: true });
|
|
8369
8423
|
if (process.env.VERCEL) {
|
|
8370
|
-
await mkdir6(
|
|
8424
|
+
await mkdir6(path24.join(dir, ".vercel/output/static"), { recursive: true });
|
|
8371
8425
|
await rename2(
|
|
8372
|
-
|
|
8373
|
-
|
|
8426
|
+
path24.join(dir, DIST_DIR),
|
|
8427
|
+
path24.join(dir, ".vercel/output/static")
|
|
8374
8428
|
);
|
|
8375
8429
|
}
|
|
8376
8430
|
await writeOutput(dir, {
|
|
@@ -8381,7 +8435,7 @@ var runPrerender = async (options) => {
|
|
|
8381
8435
|
if (ZuploEnv.isZuplo && issuer) {
|
|
8382
8436
|
const provider = config.authentication?.type;
|
|
8383
8437
|
await writeFile6(
|
|
8384
|
-
|
|
8438
|
+
path24.join(dir, DIST_DIR, ".output/zuplo.json"),
|
|
8385
8439
|
JSON.stringify({ issuer, provider }, null, 2),
|
|
8386
8440
|
"utf-8"
|
|
8387
8441
|
);
|
|
@@ -8393,7 +8447,7 @@ var runPrerender = async (options) => {
|
|
|
8393
8447
|
};
|
|
8394
8448
|
var findUserEntry = (dir) => {
|
|
8395
8449
|
for (const ext of ["ts", "tsx", "js", "mjs"]) {
|
|
8396
|
-
const candidate =
|
|
8450
|
+
const candidate = path24.join(dir, `zudoku.server.${ext}`);
|
|
8397
8451
|
if (existsSync2(candidate)) return candidate;
|
|
8398
8452
|
}
|
|
8399
8453
|
};
|
|
@@ -8404,15 +8458,15 @@ var bundleSSREntry = async (options) => {
|
|
|
8404
8458
|
let entryPoint = userEntry;
|
|
8405
8459
|
let tempEntryPath;
|
|
8406
8460
|
if (!entryPoint) {
|
|
8407
|
-
tempEntryPath =
|
|
8408
|
-
const templateContent = await
|
|
8409
|
-
|
|
8461
|
+
tempEntryPath = path24.join(dir, "__ssr-entry.ts");
|
|
8462
|
+
const templateContent = await readFile5(
|
|
8463
|
+
path24.join(packageRoot, "src/vite/ssr-templates", `${adapter}.ts`),
|
|
8410
8464
|
"utf-8"
|
|
8411
8465
|
);
|
|
8412
8466
|
await writeFile6(tempEntryPath, templateContent, "utf-8");
|
|
8413
8467
|
entryPoint = tempEntryPath;
|
|
8414
8468
|
}
|
|
8415
|
-
const frameworkPath =
|
|
8469
|
+
const frameworkPath = path24.join(serverOutDir, "entry.server.js");
|
|
8416
8470
|
try {
|
|
8417
8471
|
await esbuild({
|
|
8418
8472
|
entryPoints: [entryPoint],
|
|
@@ -8420,9 +8474,9 @@ var bundleSSREntry = async (options) => {
|
|
|
8420
8474
|
platform: ["node", "lambda"].includes(adapter) ? "node" : "neutral",
|
|
8421
8475
|
target: "es2022",
|
|
8422
8476
|
format: "esm",
|
|
8423
|
-
outfile:
|
|
8477
|
+
outfile: path24.join(serverOutDir, "entry.js"),
|
|
8424
8478
|
external: ["./zudoku.config.js"],
|
|
8425
|
-
nodePaths: [
|
|
8479
|
+
nodePaths: [path24.join(packageRoot, "node_modules")],
|
|
8426
8480
|
banner: { js: "// Bundled SSR entry" },
|
|
8427
8481
|
define: {
|
|
8428
8482
|
__ZUDOKU_TEMPLATE__: JSON.stringify(html)
|
|
@@ -8441,7 +8495,7 @@ var bundleSSREntry = async (options) => {
|
|
|
8441
8495
|
await Promise.all([
|
|
8442
8496
|
rm3(frameworkPath, { force: true }),
|
|
8443
8497
|
rm3(`${frameworkPath}.map`, { force: true }),
|
|
8444
|
-
rm3(
|
|
8498
|
+
rm3(path24.join(serverOutDir, "assets"), {
|
|
8445
8499
|
recursive: true,
|
|
8446
8500
|
force: true
|
|
8447
8501
|
})
|
|
@@ -8471,11 +8525,11 @@ function printWarningToConsole(message) {
|
|
|
8471
8525
|
}
|
|
8472
8526
|
|
|
8473
8527
|
// src/cli/preview/handler.ts
|
|
8474
|
-
import
|
|
8528
|
+
import path25 from "node:path";
|
|
8475
8529
|
import { preview as vitePreview } from "vite";
|
|
8476
8530
|
var DEFAULT_PREVIEW_PORT = 4e3;
|
|
8477
8531
|
async function preview(argv) {
|
|
8478
|
-
const dir =
|
|
8532
|
+
const dir = path25.resolve(process.cwd(), argv.dir);
|
|
8479
8533
|
const viteConfig = await getViteConfig(dir, {
|
|
8480
8534
|
command: "serve",
|
|
8481
8535
|
mode: "production",
|
|
@@ -8513,7 +8567,7 @@ async function build(argv) {
|
|
|
8513
8567
|
printDiagnosticsToConsole(`Starting Zudoku build v${packageJson2.version}`);
|
|
8514
8568
|
printDiagnosticsToConsole("");
|
|
8515
8569
|
printDiagnosticsToConsole("");
|
|
8516
|
-
const dir =
|
|
8570
|
+
const dir = path26.resolve(process.cwd(), argv.dir);
|
|
8517
8571
|
try {
|
|
8518
8572
|
await runBuild({
|
|
8519
8573
|
dir,
|
|
@@ -8667,13 +8721,13 @@ var build_default = {
|
|
|
8667
8721
|
|
|
8668
8722
|
// src/cli/dev/handler.ts
|
|
8669
8723
|
init_joinUrl();
|
|
8670
|
-
import
|
|
8724
|
+
import path29 from "node:path";
|
|
8671
8725
|
|
|
8672
8726
|
// src/vite/dev-server.ts
|
|
8673
8727
|
import fs3 from "node:fs/promises";
|
|
8674
8728
|
import http from "node:http";
|
|
8675
8729
|
import https from "node:https";
|
|
8676
|
-
import
|
|
8730
|
+
import path28 from "node:path";
|
|
8677
8731
|
import { stripVTControlCharacters } from "node:util";
|
|
8678
8732
|
import { createHttpTerminator } from "http-terminator";
|
|
8679
8733
|
import {
|
|
@@ -8705,7 +8759,7 @@ async function findAvailablePort(startPort) {
|
|
|
8705
8759
|
init_joinUrl();
|
|
8706
8760
|
|
|
8707
8761
|
// src/vite/pagefind-dev-index.ts
|
|
8708
|
-
import
|
|
8762
|
+
import path27 from "node:path";
|
|
8709
8763
|
import { createIndex as createIndex2 } from "pagefind";
|
|
8710
8764
|
import { isRunnableDevEnvironment } from "vite";
|
|
8711
8765
|
init_joinUrl();
|
|
@@ -8759,7 +8813,7 @@ async function* buildPagefindDevIndex(vite, config) {
|
|
|
8759
8813
|
path: urlPath
|
|
8760
8814
|
};
|
|
8761
8815
|
}
|
|
8762
|
-
const outputPath =
|
|
8816
|
+
const outputPath = path27.join(vite.config.publicDir, "pagefind");
|
|
8763
8817
|
await pagefindIndex.writeFiles({ outputPath });
|
|
8764
8818
|
yield { type: "complete", success: true, indexed };
|
|
8765
8819
|
}
|
|
@@ -8779,9 +8833,9 @@ var DevServer = class {
|
|
|
8779
8833
|
this.protocol = "https";
|
|
8780
8834
|
const { dir } = this.#options;
|
|
8781
8835
|
const [key, cert, ca] = await Promise.all([
|
|
8782
|
-
fs3.readFile(
|
|
8783
|
-
fs3.readFile(
|
|
8784
|
-
config.https.ca ? fs3.readFile(
|
|
8836
|
+
fs3.readFile(path28.resolve(dir, config.https.key)),
|
|
8837
|
+
fs3.readFile(path28.resolve(dir, config.https.cert)),
|
|
8838
|
+
config.https.ca ? fs3.readFile(path28.resolve(dir, config.https.ca)) : void 0
|
|
8785
8839
|
]);
|
|
8786
8840
|
return https.createServer({ key, cert, ca });
|
|
8787
8841
|
}
|
|
@@ -8809,7 +8863,7 @@ var DevServer = class {
|
|
|
8809
8863
|
// built-in transform middleware which would treat the path as a static asset.
|
|
8810
8864
|
name: "zudoku:entry-client",
|
|
8811
8865
|
configureServer(server2) {
|
|
8812
|
-
const entryPath =
|
|
8866
|
+
const entryPath = path28.posix.join(
|
|
8813
8867
|
server2.config.base,
|
|
8814
8868
|
"/__z/entry.client.tsx"
|
|
8815
8869
|
);
|
|
@@ -8921,13 +8975,13 @@ var DevServer = class {
|
|
|
8921
8975
|
`Server-side rendering ${this.#options.ssr ? "enabled" : "disabled"}`
|
|
8922
8976
|
);
|
|
8923
8977
|
if (config.search?.type === "pagefind") {
|
|
8924
|
-
const pagefindPath =
|
|
8978
|
+
const pagefindPath = path28.join(
|
|
8925
8979
|
vite.config.publicDir,
|
|
8926
8980
|
"pagefind/pagefind.js"
|
|
8927
8981
|
);
|
|
8928
8982
|
const exists = await fs3.stat(pagefindPath).catch(() => false);
|
|
8929
8983
|
if (!exists) {
|
|
8930
|
-
await fs3.mkdir(
|
|
8984
|
+
await fs3.mkdir(path28.dirname(pagefindPath), { recursive: true });
|
|
8931
8985
|
await fs3.writeFile(pagefindPath, 'throw new Error("NOT_BUILT_YET");');
|
|
8932
8986
|
}
|
|
8933
8987
|
}
|
|
@@ -9029,7 +9083,7 @@ var DevServer = class {
|
|
|
9029
9083
|
async function dev(argv) {
|
|
9030
9084
|
const packageJson2 = getZudokuPackageJson();
|
|
9031
9085
|
process.env.NODE_ENV = "development";
|
|
9032
|
-
const dir =
|
|
9086
|
+
const dir = path29.resolve(process.cwd(), argv.dir);
|
|
9033
9087
|
const server = new DevServer({
|
|
9034
9088
|
dir,
|
|
9035
9089
|
argPort: argv.port,
|
|
@@ -9135,7 +9189,7 @@ var preview_default = previewCommand;
|
|
|
9135
9189
|
|
|
9136
9190
|
// src/cli/common/outdated.ts
|
|
9137
9191
|
import { existsSync as existsSync3, mkdirSync } from "node:fs";
|
|
9138
|
-
import { readFile as
|
|
9192
|
+
import { readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
|
|
9139
9193
|
import { join } from "node:path";
|
|
9140
9194
|
import colors10 from "picocolors";
|
|
9141
9195
|
import { gt } from "semver";
|
|
@@ -9185,12 +9239,12 @@ function box(message, {
|
|
|
9185
9239
|
|
|
9186
9240
|
// src/cli/common/xdg/lib.ts
|
|
9187
9241
|
import { homedir } from "node:os";
|
|
9188
|
-
import
|
|
9242
|
+
import path30 from "node:path";
|
|
9189
9243
|
function defineDirectoryWithFallback(xdgName, fallback) {
|
|
9190
9244
|
if (process.env[xdgName]) {
|
|
9191
9245
|
return process.env[xdgName];
|
|
9192
9246
|
} else {
|
|
9193
|
-
return
|
|
9247
|
+
return path30.join(homedir(), fallback);
|
|
9194
9248
|
}
|
|
9195
9249
|
}
|
|
9196
9250
|
var XDG_CONFIG_HOME = defineDirectoryWithFallback(
|
|
@@ -9205,15 +9259,15 @@ var XDG_STATE_HOME = defineDirectoryWithFallback(
|
|
|
9205
9259
|
"XDG_DATA_HOME",
|
|
9206
9260
|
".local/state"
|
|
9207
9261
|
);
|
|
9208
|
-
var ZUDOKU_XDG_CONFIG_HOME =
|
|
9262
|
+
var ZUDOKU_XDG_CONFIG_HOME = path30.join(
|
|
9209
9263
|
XDG_CONFIG_HOME,
|
|
9210
9264
|
CLI_XDG_FOLDER_NAME
|
|
9211
9265
|
);
|
|
9212
|
-
var ZUDOKU_XDG_DATA_HOME =
|
|
9266
|
+
var ZUDOKU_XDG_DATA_HOME = path30.join(
|
|
9213
9267
|
XDG_DATA_HOME,
|
|
9214
9268
|
CLI_XDG_FOLDER_NAME
|
|
9215
9269
|
);
|
|
9216
|
-
var ZUDOKU_XDG_STATE_HOME =
|
|
9270
|
+
var ZUDOKU_XDG_STATE_HOME = path30.join(
|
|
9217
9271
|
XDG_STATE_HOME,
|
|
9218
9272
|
CLI_XDG_FOLDER_NAME
|
|
9219
9273
|
);
|
|
@@ -9262,7 +9316,7 @@ async function getVersionCheckInfo() {
|
|
|
9262
9316
|
let versionCheckInfo;
|
|
9263
9317
|
if (existsSync3(versionCheckPath)) {
|
|
9264
9318
|
try {
|
|
9265
|
-
versionCheckInfo = await
|
|
9319
|
+
versionCheckInfo = await readFile6(versionCheckPath, "utf-8").then(
|
|
9266
9320
|
JSON.parse
|
|
9267
9321
|
);
|
|
9268
9322
|
} catch {
|