zudoku 0.82.1 → 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 +261 -202
- 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/docs/configuration/navigation.mdx +32 -4
- package/package.json +17 -16
- 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 +4 -2
- package/src/lib/components/navigation/StackRows.tsx +1 -1
- package/src/lib/plugins/markdown/MdxPage.tsx +19 -4
- 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
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __esm = (fn, res) => function __init() {
|
|
4
|
-
|
|
3
|
+
var __esm = (fn, res, err) => function __init() {
|
|
4
|
+
if (err) throw err[0];
|
|
5
|
+
try {
|
|
6
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
+
} catch (e) {
|
|
8
|
+
throw err = [e], e;
|
|
9
|
+
}
|
|
5
10
|
};
|
|
6
11
|
var __export = (target, all) => {
|
|
7
12
|
for (var name in all)
|
|
@@ -54,7 +59,7 @@ __export(llms_exports, {
|
|
|
54
59
|
generateLlmsTxtFiles: () => generateLlmsTxtFiles
|
|
55
60
|
});
|
|
56
61
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
57
|
-
import
|
|
62
|
+
import path21 from "node:path";
|
|
58
63
|
import colors6 from "picocolors";
|
|
59
64
|
async function generateLlmsTxtFiles({
|
|
60
65
|
markdownFileInfos,
|
|
@@ -89,7 +94,7 @@ async function generateLlmsTxtFiles({
|
|
|
89
94
|
}
|
|
90
95
|
}
|
|
91
96
|
const llmsTxt2 = llmsTxtParts.join("\n");
|
|
92
|
-
await writeFile5(
|
|
97
|
+
await writeFile5(path21.join(baseOutputDir, "llms.txt"), llmsTxt2, "utf-8");
|
|
93
98
|
console.log(colors6.blue("\u2713 generated llms.txt"));
|
|
94
99
|
}
|
|
95
100
|
if (llmsTxtFull) {
|
|
@@ -115,7 +120,7 @@ ${info.content}
|
|
|
115
120
|
}
|
|
116
121
|
const llmsFull = llmsFullParts.join("\n");
|
|
117
122
|
await writeFile5(
|
|
118
|
-
|
|
123
|
+
path21.join(baseOutputDir, "llms-full.txt"),
|
|
119
124
|
llmsFull,
|
|
120
125
|
"utf-8"
|
|
121
126
|
);
|
|
@@ -134,12 +139,12 @@ import { hideBin } from "yargs/helpers";
|
|
|
134
139
|
import yargs from "yargs/yargs";
|
|
135
140
|
|
|
136
141
|
// src/cli/build/handler.ts
|
|
137
|
-
import
|
|
142
|
+
import path26 from "node:path";
|
|
138
143
|
|
|
139
144
|
// src/vite/build.ts
|
|
140
145
|
import { existsSync as existsSync2 } from "node:fs";
|
|
141
|
-
import { mkdir as mkdir6, readFile as
|
|
142
|
-
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";
|
|
143
148
|
import { build as esbuild } from "esbuild";
|
|
144
149
|
import { createBuilder } from "vite";
|
|
145
150
|
|
|
@@ -225,7 +230,7 @@ var getZudokuRootDir = () => path.dirname(getPackageJsonPath("zudoku"));
|
|
|
225
230
|
|
|
226
231
|
// src/config/loader.ts
|
|
227
232
|
import { stat as stat2 } from "node:fs/promises";
|
|
228
|
-
import
|
|
233
|
+
import path5 from "node:path";
|
|
229
234
|
import colors2 from "picocolors";
|
|
230
235
|
import {
|
|
231
236
|
runnerImport,
|
|
@@ -316,7 +321,47 @@ var ZudokuError = class extends Error {
|
|
|
316
321
|
|
|
317
322
|
// src/config/file-exists.ts
|
|
318
323
|
import { stat } from "node:fs/promises";
|
|
319
|
-
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
|
+
};
|
|
320
365
|
|
|
321
366
|
// src/config/validators/ZudokuConfig.ts
|
|
322
367
|
import colors from "picocolors";
|
|
@@ -324,7 +369,7 @@ import { isValidElement as isValidElement2 } from "react";
|
|
|
324
369
|
import { z as z7 } from "zod";
|
|
325
370
|
|
|
326
371
|
// src/vite/plugin-theme.ts
|
|
327
|
-
import
|
|
372
|
+
import path4 from "node:path";
|
|
328
373
|
import { normalizeTheme } from "shiki";
|
|
329
374
|
|
|
330
375
|
// src/lib/shiki.ts
|
|
@@ -777,7 +822,7 @@ ${rootVars.join("\n")}
|
|
|
777
822
|
config.__meta.rootDir,
|
|
778
823
|
...config.__meta.dependencies,
|
|
779
824
|
...config.__pluginDirs ?? []
|
|
780
|
-
].map((file) =>
|
|
825
|
+
].map((file) => path4.relative(path4.dirname(id), file))
|
|
781
826
|
);
|
|
782
827
|
const code = [...files].map((file) => `@source "${file}";`);
|
|
783
828
|
code.push("@theme inline {");
|
|
@@ -2985,8 +3030,8 @@ import { createNanoEvents } from "nanoevents";
|
|
|
2985
3030
|
|
|
2986
3031
|
// src/lib/util/url.ts
|
|
2987
3032
|
import { matchPath } from "react-router";
|
|
2988
|
-
var matchesProtectedPattern = (pattern,
|
|
2989
|
-
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));
|
|
2990
3035
|
|
|
2991
3036
|
// src/lib/core/ZudokuContext.ts
|
|
2992
3037
|
var normalizeProtectedRoutes = (val) => {
|
|
@@ -3630,7 +3675,7 @@ var zudokuConfigFiles = [
|
|
|
3630
3675
|
];
|
|
3631
3676
|
async function getConfigFilePath(rootDir) {
|
|
3632
3677
|
for (const fileName of zudokuConfigFiles) {
|
|
3633
|
-
const filepath =
|
|
3678
|
+
const filepath = path5.join(rootDir, fileName);
|
|
3634
3679
|
if (await fileExists(filepath)) {
|
|
3635
3680
|
return filepath;
|
|
3636
3681
|
}
|
|
@@ -3766,6 +3811,15 @@ async function loadZudokuConfig(configEnv, rootDir) {
|
|
|
3766
3811
|
colors2.cyan(`loaded config file `) + colors2.dim(config.__meta.configPath),
|
|
3767
3812
|
{ timestamp: true }
|
|
3768
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
|
+
}
|
|
3769
3823
|
return { config, envPrefix, publicEnv };
|
|
3770
3824
|
} catch (error) {
|
|
3771
3825
|
const lastValid = getConfig();
|
|
@@ -3841,7 +3895,7 @@ var getIssuer = async (config) => {
|
|
|
3841
3895
|
init_joinUrl();
|
|
3842
3896
|
|
|
3843
3897
|
// src/vite/config.ts
|
|
3844
|
-
import
|
|
3898
|
+
import path17 from "node:path";
|
|
3845
3899
|
import dotenv from "dotenv";
|
|
3846
3900
|
import colors4 from "picocolors";
|
|
3847
3901
|
import {
|
|
@@ -3889,22 +3943,12 @@ var buildManifest = (config) => {
|
|
|
3889
3943
|
// src/vite/config.ts
|
|
3890
3944
|
init_joinUrl();
|
|
3891
3945
|
|
|
3892
|
-
// src/vite/package-root.ts
|
|
3893
|
-
import path4 from "node:path";
|
|
3894
|
-
var findPackageRoot = async (startDir) => {
|
|
3895
|
-
let dir = startDir;
|
|
3896
|
-
while (dir !== path4.dirname(dir)) {
|
|
3897
|
-
if (await fileExists(path4.join(dir, "package.json"))) return dir;
|
|
3898
|
-
dir = path4.dirname(dir);
|
|
3899
|
-
}
|
|
3900
|
-
};
|
|
3901
|
-
|
|
3902
3946
|
// src/vite/plugin.ts
|
|
3903
3947
|
import tailwindcss from "@tailwindcss/vite";
|
|
3904
3948
|
import react from "@vitejs/plugin-react";
|
|
3905
3949
|
|
|
3906
3950
|
// src/vite/css/plugin.ts
|
|
3907
|
-
import
|
|
3951
|
+
import path6 from "node:path";
|
|
3908
3952
|
import { isCSSRequest as isCSSRequest2 } from "vite";
|
|
3909
3953
|
|
|
3910
3954
|
// src/vite/css/collect.ts
|
|
@@ -3939,7 +3983,7 @@ var VIRTUAL_ENTRY = "virtual:ssr-css.css";
|
|
|
3939
3983
|
function vitePluginSsrCss(pluginOpts) {
|
|
3940
3984
|
let server;
|
|
3941
3985
|
const config = getCurrentConfig();
|
|
3942
|
-
const virtualHref =
|
|
3986
|
+
const virtualHref = path6.join(
|
|
3943
3987
|
config.basePath ?? "",
|
|
3944
3988
|
`/@id/__x00__${VIRTUAL_ENTRY}?direct`
|
|
3945
3989
|
);
|
|
@@ -4071,12 +4115,12 @@ var plugin_api_keys_default = viteApiKeysPlugin;
|
|
|
4071
4115
|
|
|
4072
4116
|
// src/vite/plugin-api.ts
|
|
4073
4117
|
import fs2 from "node:fs/promises";
|
|
4074
|
-
import
|
|
4118
|
+
import path12 from "node:path";
|
|
4075
4119
|
import { deepEqual as deepEqual2 } from "fast-equals";
|
|
4076
4120
|
import { runnerImport as runnerImport3 } from "vite";
|
|
4077
4121
|
|
|
4078
4122
|
// src/config/validators/BuildSchema.ts
|
|
4079
|
-
import
|
|
4123
|
+
import path7 from "node:path";
|
|
4080
4124
|
import { runnerImport as runnerImport2 } from "vite";
|
|
4081
4125
|
import { z as z8 } from "zod";
|
|
4082
4126
|
var BuildProcessorSchema = z8.custom((val) => typeof val === "function");
|
|
@@ -4100,7 +4144,7 @@ var zudokuBuildConfigFiles = [
|
|
|
4100
4144
|
];
|
|
4101
4145
|
async function getBuildConfigFilePath(rootDir) {
|
|
4102
4146
|
for (const fileName of zudokuBuildConfigFiles) {
|
|
4103
|
-
const filepath =
|
|
4147
|
+
const filepath = path7.join(rootDir, fileName);
|
|
4104
4148
|
if (await fileExists(filepath)) {
|
|
4105
4149
|
return filepath;
|
|
4106
4150
|
}
|
|
@@ -4222,14 +4266,14 @@ var flattenAllOf = (schema2) => {
|
|
|
4222
4266
|
};
|
|
4223
4267
|
|
|
4224
4268
|
// src/lib/util/traverse.ts
|
|
4225
|
-
var traverse = (specification, transform,
|
|
4226
|
-
const transformed = transform(specification,
|
|
4269
|
+
var traverse = (specification, transform, path31 = []) => {
|
|
4270
|
+
const transformed = transform(specification, path31);
|
|
4227
4271
|
if (typeof transformed !== "object" || transformed === null) {
|
|
4228
4272
|
return transformed;
|
|
4229
4273
|
}
|
|
4230
4274
|
const result = Array.isArray(transformed) ? [] : {};
|
|
4231
4275
|
for (const [key, value] of Object.entries(transformed)) {
|
|
4232
|
-
const currentPath = [...
|
|
4276
|
+
const currentPath = [...path31, key];
|
|
4233
4277
|
if (Array.isArray(value)) {
|
|
4234
4278
|
result[key] = value.map(
|
|
4235
4279
|
(item, index) => typeof item === "object" && item != null ? traverse(item, transform, [...currentPath, index.toString()]) : item
|
|
@@ -4257,9 +4301,9 @@ var resolveLocalRef = (schema2, ref) => {
|
|
|
4257
4301
|
if (schemaCache?.has(ref)) {
|
|
4258
4302
|
return schemaCache.get(ref);
|
|
4259
4303
|
}
|
|
4260
|
-
const
|
|
4304
|
+
const path31 = ref.split("/").slice(1);
|
|
4261
4305
|
let current = schema2;
|
|
4262
|
-
for (const segment of
|
|
4306
|
+
for (const segment of path31) {
|
|
4263
4307
|
if (!current || typeof current !== "object") {
|
|
4264
4308
|
current = null;
|
|
4265
4309
|
}
|
|
@@ -4278,7 +4322,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4278
4322
|
}
|
|
4279
4323
|
const cloned = structuredClone(schema2);
|
|
4280
4324
|
const visited = /* @__PURE__ */ new Set();
|
|
4281
|
-
const resolve = async (current,
|
|
4325
|
+
const resolve = async (current, path31) => {
|
|
4282
4326
|
if (isIndexableObject(current)) {
|
|
4283
4327
|
if (visited.has(current)) {
|
|
4284
4328
|
return CIRCULAR_REF;
|
|
@@ -4286,7 +4330,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4286
4330
|
visited.add(current);
|
|
4287
4331
|
if (Array.isArray(current)) {
|
|
4288
4332
|
for (let index = 0; index < current.length; index++) {
|
|
4289
|
-
current[index] = await resolve(current[index], `${
|
|
4333
|
+
current[index] = await resolve(current[index], `${path31}/${index}`);
|
|
4290
4334
|
}
|
|
4291
4335
|
} else {
|
|
4292
4336
|
if ("$ref" in current && typeof current.$ref === "string") {
|
|
@@ -4297,13 +4341,13 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4297
4341
|
for (const resolver of resolvers) {
|
|
4298
4342
|
const resolved = await resolver($ref);
|
|
4299
4343
|
if (resolved) {
|
|
4300
|
-
result2 = await resolve(resolved,
|
|
4344
|
+
result2 = await resolve(resolved, path31);
|
|
4301
4345
|
break;
|
|
4302
4346
|
}
|
|
4303
4347
|
}
|
|
4304
4348
|
if (result2 === void 0) {
|
|
4305
4349
|
const resolved = await resolveLocalRef(cloned, $ref);
|
|
4306
|
-
result2 = await resolve(resolved,
|
|
4350
|
+
result2 = await resolve(resolved, path31);
|
|
4307
4351
|
}
|
|
4308
4352
|
if (hasSiblings) {
|
|
4309
4353
|
if (result2 === CIRCULAR_REF) {
|
|
@@ -4316,7 +4360,7 @@ var dereference = async (schema2, resolvers = []) => {
|
|
|
4316
4360
|
return result2;
|
|
4317
4361
|
}
|
|
4318
4362
|
for (const key in current) {
|
|
4319
|
-
current[key] = await resolve(current[key], `${
|
|
4363
|
+
current[key] = await resolve(current[key], `${path31}/${key}`);
|
|
4320
4364
|
}
|
|
4321
4365
|
}
|
|
4322
4366
|
visited.delete(current);
|
|
@@ -4355,9 +4399,9 @@ var upgradeSchema = (schema2) => {
|
|
|
4355
4399
|
}
|
|
4356
4400
|
return sub;
|
|
4357
4401
|
});
|
|
4358
|
-
schema2 = traverse(schema2, (sub,
|
|
4402
|
+
schema2 = traverse(schema2, (sub, path31) => {
|
|
4359
4403
|
if (sub.example !== void 0) {
|
|
4360
|
-
if (isSchemaPath(
|
|
4404
|
+
if (isSchemaPath(path31 ?? [])) {
|
|
4361
4405
|
sub.examples = [sub.example];
|
|
4362
4406
|
} else {
|
|
4363
4407
|
sub.examples = {
|
|
@@ -4370,11 +4414,11 @@ var upgradeSchema = (schema2) => {
|
|
|
4370
4414
|
}
|
|
4371
4415
|
return sub;
|
|
4372
4416
|
});
|
|
4373
|
-
schema2 = traverse(schema2, (schema3,
|
|
4417
|
+
schema2 = traverse(schema2, (schema3, path31) => {
|
|
4374
4418
|
if (schema3.type === "object" && schema3.properties !== void 0) {
|
|
4375
|
-
const parentPath =
|
|
4419
|
+
const parentPath = path31?.slice(0, -1);
|
|
4376
4420
|
const isMultipart = parentPath?.some((segment, index) => {
|
|
4377
|
-
return segment === "content" &&
|
|
4421
|
+
return segment === "content" && path31?.[index + 1] === "multipart/form-data";
|
|
4378
4422
|
});
|
|
4379
4423
|
if (isMultipart) {
|
|
4380
4424
|
const entries = Object.entries(schema3.properties);
|
|
@@ -4388,8 +4432,8 @@ var upgradeSchema = (schema2) => {
|
|
|
4388
4432
|
}
|
|
4389
4433
|
return schema3;
|
|
4390
4434
|
});
|
|
4391
|
-
schema2 = traverse(schema2, (schema3,
|
|
4392
|
-
if (
|
|
4435
|
+
schema2 = traverse(schema2, (schema3, path31) => {
|
|
4436
|
+
if (path31?.includes("content") && path31.includes("application/octet-stream")) {
|
|
4393
4437
|
return {};
|
|
4394
4438
|
}
|
|
4395
4439
|
if (schema3.type === "string" && schema3.format === "binary") {
|
|
@@ -4415,11 +4459,11 @@ var upgradeSchema = (schema2) => {
|
|
|
4415
4459
|
}
|
|
4416
4460
|
return sub;
|
|
4417
4461
|
});
|
|
4418
|
-
schema2 = traverse(schema2, (schema3,
|
|
4462
|
+
schema2 = traverse(schema2, (schema3, path31) => {
|
|
4419
4463
|
if (schema3.type === "string" && schema3.format === "byte") {
|
|
4420
|
-
const parentPath =
|
|
4464
|
+
const parentPath = path31?.slice(0, -1);
|
|
4421
4465
|
const contentMediaType = parentPath?.find(
|
|
4422
|
-
(_, index) =>
|
|
4466
|
+
(_, index) => path31?.[index - 1] === "content"
|
|
4423
4467
|
);
|
|
4424
4468
|
return {
|
|
4425
4469
|
type: "string",
|
|
@@ -4431,7 +4475,7 @@ var upgradeSchema = (schema2) => {
|
|
|
4431
4475
|
});
|
|
4432
4476
|
return schema2;
|
|
4433
4477
|
};
|
|
4434
|
-
function isSchemaPath(
|
|
4478
|
+
function isSchemaPath(path31) {
|
|
4435
4479
|
const schemaLocations = [
|
|
4436
4480
|
["components", "schemas"],
|
|
4437
4481
|
"properties",
|
|
@@ -4444,10 +4488,10 @@ function isSchemaPath(path30) {
|
|
|
4444
4488
|
];
|
|
4445
4489
|
return schemaLocations.some((location) => {
|
|
4446
4490
|
if (Array.isArray(location)) {
|
|
4447
|
-
return location.every((segment, index) =>
|
|
4491
|
+
return location.every((segment, index) => path31[index] === segment);
|
|
4448
4492
|
}
|
|
4449
|
-
return
|
|
4450
|
-
}) ||
|
|
4493
|
+
return path31.includes(location);
|
|
4494
|
+
}) || path31.includes("schema") || path31.some((segment) => segment.endsWith("Schema"));
|
|
4451
4495
|
}
|
|
4452
4496
|
|
|
4453
4497
|
// src/lib/oas/parser/index.ts
|
|
@@ -4529,13 +4573,13 @@ var OPENAPI_PROPS = /* @__PURE__ */ new Set([
|
|
|
4529
4573
|
"anyOf",
|
|
4530
4574
|
"oneOf"
|
|
4531
4575
|
]);
|
|
4532
|
-
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()) => {
|
|
4533
4577
|
if (obj === null || typeof obj !== "object") return obj;
|
|
4534
4578
|
const refPath = obj.__$ref;
|
|
4535
4579
|
const isCircular = currentPath.has(obj) || typeof refPath === "string" && currentRefPaths.has(refPath);
|
|
4536
4580
|
if (isCircular) {
|
|
4537
4581
|
if (typeof refPath === "string") return SCHEMA_REF_PREFIX + refPath;
|
|
4538
|
-
const circularProp =
|
|
4582
|
+
const circularProp = path31.find((p) => !OPENAPI_PROPS.has(p)) || path31[0];
|
|
4539
4583
|
return [CIRCULAR_REF, circularProp].filter(Boolean).join(":");
|
|
4540
4584
|
}
|
|
4541
4585
|
if (refs.has(obj)) return refs.get(obj);
|
|
@@ -4545,7 +4589,7 @@ var handleCircularRefs = (obj, currentPath = /* @__PURE__ */ new WeakSet(), refs
|
|
|
4545
4589
|
value,
|
|
4546
4590
|
currentPath,
|
|
4547
4591
|
refs,
|
|
4548
|
-
[...
|
|
4592
|
+
[...path31, key],
|
|
4549
4593
|
currentRefPaths
|
|
4550
4594
|
);
|
|
4551
4595
|
const result = Array.isArray(obj) ? obj.map((item, i) => recurse(item, i.toString())) : Object.fromEntries(
|
|
@@ -4583,7 +4627,7 @@ var resolveExtensions = (obj) => Object.fromEntries(
|
|
|
4583
4627
|
var getAllTags = (schema2) => {
|
|
4584
4628
|
const rootTags = schema2.tags ?? [];
|
|
4585
4629
|
const operations = Object.values(schema2.paths ?? {}).flatMap(
|
|
4586
|
-
(
|
|
4630
|
+
(path31) => HttpMethods.map((k) => path31?.[k]).filter((op) => op != null)
|
|
4587
4631
|
);
|
|
4588
4632
|
const operationTags = new Set(operations.flatMap((op) => op.tags ?? []));
|
|
4589
4633
|
const hasUntaggedOperations = operations.some(
|
|
@@ -4638,7 +4682,7 @@ var getAllSlugs = (ops, schemaTags = []) => {
|
|
|
4638
4682
|
var getOperationSlugKey = (op) => [op.path, op.method, op.operationId, op.summary].filter(Boolean).join("-");
|
|
4639
4683
|
var getAllOperations = (paths) => {
|
|
4640
4684
|
const operations = Object.entries(paths ?? {}).flatMap(
|
|
4641
|
-
([
|
|
4685
|
+
([path31, value]) => HttpMethods.flatMap((method) => {
|
|
4642
4686
|
if (!value?.[method]) return [];
|
|
4643
4687
|
const operation = value[method];
|
|
4644
4688
|
const pathParameters = value.parameters ?? [];
|
|
@@ -4658,7 +4702,7 @@ var getAllOperations = (paths) => {
|
|
|
4658
4702
|
return {
|
|
4659
4703
|
...operation,
|
|
4660
4704
|
method,
|
|
4661
|
-
path:
|
|
4705
|
+
path: path31,
|
|
4662
4706
|
parameters,
|
|
4663
4707
|
servers,
|
|
4664
4708
|
tags: operation.tags ?? []
|
|
@@ -5156,8 +5200,8 @@ var Schema = builder.objectRef("Schema").implement({
|
|
|
5156
5200
|
}),
|
|
5157
5201
|
paths: t.field({
|
|
5158
5202
|
type: [PathItem],
|
|
5159
|
-
resolve: (root) => Object.entries(root.paths ?? {}).map(([
|
|
5160
|
-
path:
|
|
5203
|
+
resolve: (root) => Object.entries(root.paths ?? {}).map(([path31, value]) => ({
|
|
5204
|
+
path: path31,
|
|
5161
5205
|
// biome-ignore lint/style/noNonNullAssertion: value is guaranteed to be defined
|
|
5162
5206
|
methods: Object.keys(value)
|
|
5163
5207
|
}))
|
|
@@ -5261,11 +5305,9 @@ var ensureArray = (value) => Array.isArray(value) ? value : [value];
|
|
|
5261
5305
|
|
|
5262
5306
|
// src/vite/api/SchemaManager.ts
|
|
5263
5307
|
import fs from "node:fs/promises";
|
|
5264
|
-
import
|
|
5265
|
-
import {
|
|
5266
|
-
|
|
5267
|
-
} from "@apidevtools/json-schema-ref-parser";
|
|
5268
|
-
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";
|
|
5269
5311
|
import { deepEqual } from "fast-equals";
|
|
5270
5312
|
|
|
5271
5313
|
// src/lib/util/flattenAllOfProcessor.ts
|
|
@@ -5313,7 +5355,7 @@ init_joinUrl();
|
|
|
5313
5355
|
|
|
5314
5356
|
// src/vite/api/schema-codegen.ts
|
|
5315
5357
|
var unescapeJsonPointer = (uri) => decodeURIComponent(uri.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
5316
|
-
var getSegmentsFromPath = (
|
|
5358
|
+
var getSegmentsFromPath = (path31) => path31.split("/").slice(1).map(unescapeJsonPointer);
|
|
5317
5359
|
var createLocalRefMap = (obj) => {
|
|
5318
5360
|
const refMap = /* @__PURE__ */ new Map();
|
|
5319
5361
|
const siblingsMap = /* @__PURE__ */ new Map();
|
|
@@ -5344,16 +5386,16 @@ var replaceMarkers = (code, mergedRefs) => code.replace(/"__refMap:(.*?)"/g, '__
|
|
|
5344
5386
|
/"__refMap\+Siblings:(.*?)"/g,
|
|
5345
5387
|
(_, key) => mergedRefs.get(key) ?? `__refMap["${key}"]`
|
|
5346
5388
|
);
|
|
5347
|
-
var lookup = (schema2,
|
|
5348
|
-
const parts = getSegmentsFromPath(
|
|
5389
|
+
var lookup = (schema2, path31, filePath) => {
|
|
5390
|
+
const parts = getSegmentsFromPath(path31);
|
|
5349
5391
|
let val = schema2;
|
|
5350
5392
|
for (const part of parts) {
|
|
5351
5393
|
while (val.$ref?.startsWith("#/")) {
|
|
5352
|
-
val = val.$ref ===
|
|
5394
|
+
val = val.$ref === path31 ? val : lookup(schema2, val.$ref, filePath);
|
|
5353
5395
|
}
|
|
5354
5396
|
if (val[part] === void 0) {
|
|
5355
5397
|
throw new Error(
|
|
5356
|
-
`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}`
|
|
5357
5399
|
);
|
|
5358
5400
|
}
|
|
5359
5401
|
val = val[part];
|
|
@@ -5445,24 +5487,30 @@ var SchemaManager = class {
|
|
|
5445
5487
|
this.storeDir = storeDir;
|
|
5446
5488
|
this.config = config;
|
|
5447
5489
|
this.processors = [
|
|
5448
|
-
({ 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
|
+
},
|
|
5449
5497
|
flattenAllOfProcessor,
|
|
5450
5498
|
...processors
|
|
5451
5499
|
];
|
|
5452
5500
|
}
|
|
5453
5501
|
getPathForFile = (input, params) => {
|
|
5454
|
-
const filePath =
|
|
5502
|
+
const filePath = path8.resolve(this.config.__meta.rootDir, input);
|
|
5455
5503
|
const apis = ensureArray(this.config.apis ?? []);
|
|
5456
5504
|
for (const apiConfig of apis) {
|
|
5457
5505
|
if (!apiConfig || apiConfig.type !== "file" || !apiConfig.path) continue;
|
|
5458
5506
|
const match = normalizeInputs(apiConfig.input).some(
|
|
5459
|
-
(i) =>
|
|
5507
|
+
(i) => path8.resolve(this.config.__meta.rootDir, i.input) === filePath && deepEqual(i.params, params)
|
|
5460
5508
|
);
|
|
5461
5509
|
if (match) return apiConfig.path;
|
|
5462
5510
|
}
|
|
5463
5511
|
};
|
|
5464
5512
|
processSchema = async (input) => {
|
|
5465
|
-
const filePath =
|
|
5513
|
+
const filePath = path8.resolve(this.config.__meta.rootDir, input.input);
|
|
5466
5514
|
const params = input.params;
|
|
5467
5515
|
const configuredPath = this.getPathForFile(input.input, params);
|
|
5468
5516
|
if (!configuredPath) {
|
|
@@ -5480,7 +5528,6 @@ var SchemaManager = class {
|
|
|
5480
5528
|
}
|
|
5481
5529
|
this.referencedBy.get(file)?.add(filePath);
|
|
5482
5530
|
});
|
|
5483
|
-
const validatedSchema = await this.validateSchema(schema2, filePath);
|
|
5484
5531
|
const processedSchema = await this.processors.reduce(
|
|
5485
5532
|
async (schema3, processor) => processor({
|
|
5486
5533
|
schema: await schema3,
|
|
@@ -5493,14 +5540,14 @@ var SchemaManager = class {
|
|
|
5493
5540
|
}
|
|
5494
5541
|
})
|
|
5495
5542
|
}),
|
|
5496
|
-
Promise.resolve(
|
|
5543
|
+
Promise.resolve(schema2)
|
|
5497
5544
|
);
|
|
5498
5545
|
const processedTime = Date.now();
|
|
5499
5546
|
const code = generateCode(processedSchema, filePath);
|
|
5500
5547
|
const prefixPath = slugify(configuredPath);
|
|
5501
|
-
const processedFilePath =
|
|
5548
|
+
const processedFilePath = path8.posix.join(
|
|
5502
5549
|
this.storeDir,
|
|
5503
|
-
`${prefixPath}-${
|
|
5550
|
+
`${prefixPath}-${path8.basename(filePath)}${paramsSuffix(params)}.js`
|
|
5504
5551
|
);
|
|
5505
5552
|
const importKey = processedFilePath;
|
|
5506
5553
|
await fs.writeFile(processedFilePath, code);
|
|
@@ -5553,7 +5600,7 @@ var SchemaManager = class {
|
|
|
5553
5600
|
};
|
|
5554
5601
|
getAllTrackedFiles = () => Array.from(this.referencedBy.keys());
|
|
5555
5602
|
getFilesToReprocess = (changedFile) => {
|
|
5556
|
-
const resolvedPath =
|
|
5603
|
+
const resolvedPath = path8.resolve(this.config.__meta.rootDir, changedFile);
|
|
5557
5604
|
const referencedBy = this.referencedBy.get(resolvedPath);
|
|
5558
5605
|
if (!referencedBy) return [];
|
|
5559
5606
|
const filesToProcess = referencedBy.size === 0 ? [resolvedPath] : Array.from(referencedBy);
|
|
@@ -5582,7 +5629,7 @@ var SchemaManager = class {
|
|
|
5582
5629
|
version: "",
|
|
5583
5630
|
path: input.path ?? "",
|
|
5584
5631
|
label: input.label,
|
|
5585
|
-
inputPath:
|
|
5632
|
+
inputPath: path8.resolve(this.config.__meta.rootDir, input.input),
|
|
5586
5633
|
params: input.params,
|
|
5587
5634
|
importKey: "",
|
|
5588
5635
|
downloadUrl: "",
|
|
@@ -5602,8 +5649,8 @@ var SchemaManager = class {
|
|
|
5602
5649
|
}
|
|
5603
5650
|
}
|
|
5604
5651
|
};
|
|
5605
|
-
getLatestSchema = (
|
|
5606
|
-
getSchemasForPath = (
|
|
5652
|
+
getLatestSchema = (path31) => this.processedSchemas[path31]?.at(0);
|
|
5653
|
+
getSchemasForPath = (path31) => this.processedSchemas[path31];
|
|
5607
5654
|
getSchemaImports = () => Object.values(this.processedSchemas).flat().filter((s) => s.importKey);
|
|
5608
5655
|
getUrlToFilePathMap = () => {
|
|
5609
5656
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -5625,7 +5672,7 @@ var SchemaManager = class {
|
|
|
5625
5672
|
};
|
|
5626
5673
|
createSchemaPath = (inputPath, versionPath, apiPath, params, config) => {
|
|
5627
5674
|
const suffix = paramsSuffix(params);
|
|
5628
|
-
const extension = suffix ? ".json" :
|
|
5675
|
+
const extension = suffix ? ".json" : path8.extname(inputPath);
|
|
5629
5676
|
const fileName = config?.schemaDownload?.fileName ?? this.config.defaults?.apis?.schemaDownload?.fileName ?? "schema";
|
|
5630
5677
|
return joinUrl(
|
|
5631
5678
|
this.config.basePath,
|
|
@@ -5634,20 +5681,10 @@ var SchemaManager = class {
|
|
|
5634
5681
|
`${fileName}${suffix}${extension}`
|
|
5635
5682
|
);
|
|
5636
5683
|
};
|
|
5637
|
-
validateSchema = async (schema2, filePath) => {
|
|
5638
|
-
const validated = await validate2(schema2);
|
|
5639
|
-
if (validated.errors?.length) {
|
|
5640
|
-
console.warn(`Schema warnings in ${filePath}:`);
|
|
5641
|
-
for (const error of validated.errors) {
|
|
5642
|
-
console.warn(error);
|
|
5643
|
-
}
|
|
5644
|
-
}
|
|
5645
|
-
return schema2;
|
|
5646
|
-
};
|
|
5647
5684
|
};
|
|
5648
5685
|
|
|
5649
5686
|
// src/vite/plugin-config-reload.ts
|
|
5650
|
-
import
|
|
5687
|
+
import path11 from "node:path";
|
|
5651
5688
|
import colors3 from "picocolors";
|
|
5652
5689
|
|
|
5653
5690
|
// src/vite/plugin-navigation.ts
|
|
@@ -5655,14 +5692,14 @@ import { stringify as stringify3 } from "javascript-stringify";
|
|
|
5655
5692
|
import { isElement } from "react-is";
|
|
5656
5693
|
|
|
5657
5694
|
// src/config/validators/NavigationSchema.ts
|
|
5658
|
-
import
|
|
5695
|
+
import path9 from "node:path";
|
|
5659
5696
|
import { glob } from "glob";
|
|
5660
5697
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
5661
5698
|
import { mdxFromMarkdown } from "mdast-util-mdx";
|
|
5662
5699
|
import { mdxjs } from "micromark-extension-mdxjs";
|
|
5663
5700
|
|
|
5664
5701
|
// src/lib/util/readFrontmatter.ts
|
|
5665
|
-
import { readFile } from "node:fs/promises";
|
|
5702
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
5666
5703
|
import matter from "gray-matter";
|
|
5667
5704
|
import { parse, stringify as stringify2 } from "yaml";
|
|
5668
5705
|
var yaml = {
|
|
@@ -5670,7 +5707,7 @@ var yaml = {
|
|
|
5670
5707
|
stringify: (obj) => stringify2(obj)
|
|
5671
5708
|
};
|
|
5672
5709
|
var readFrontmatter = async (filePath) => {
|
|
5673
|
-
const content = await
|
|
5710
|
+
const content = await readFile2(filePath, "utf-8");
|
|
5674
5711
|
const normalizedContent = content.replace(/\r\n/g, "\n");
|
|
5675
5712
|
return matter(normalizedContent, { engines: { yaml } });
|
|
5676
5713
|
};
|
|
@@ -5705,7 +5742,7 @@ var extractRichH1 = (content) => {
|
|
|
5705
5742
|
}
|
|
5706
5743
|
};
|
|
5707
5744
|
var isNavigationItem = (item) => item !== void 0;
|
|
5708
|
-
var toPosixPath = (filePath) => filePath.split(
|
|
5745
|
+
var toPosixPath = (filePath) => filePath.split(path9.win32.sep).join(path9.posix.sep);
|
|
5709
5746
|
var NavigationResolver = class {
|
|
5710
5747
|
rootDir;
|
|
5711
5748
|
globPatterns;
|
|
@@ -5838,13 +5875,13 @@ var NavigationResolver = class {
|
|
|
5838
5875
|
|
|
5839
5876
|
// src/vite/debug.ts
|
|
5840
5877
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5841
|
-
import
|
|
5878
|
+
import path10 from "node:path";
|
|
5842
5879
|
async function writePluginDebugCode(rootDir, pluginName, code, extension = "js") {
|
|
5843
5880
|
if (process.env.ZUDOKU_BUILD_DEBUG) {
|
|
5844
|
-
const debugDir =
|
|
5881
|
+
const debugDir = path10.join(rootDir, "dist", "debug");
|
|
5845
5882
|
await mkdir(debugDir, { recursive: true });
|
|
5846
5883
|
await writeFile(
|
|
5847
|
-
|
|
5884
|
+
path10.join(debugDir, `${pluginName}.${extension}`),
|
|
5848
5885
|
typeof code === "string" ? code : code.join("\n")
|
|
5849
5886
|
);
|
|
5850
5887
|
}
|
|
@@ -5955,7 +5992,7 @@ var viteConfigReloadPlugin = () => ({
|
|
|
5955
5992
|
});
|
|
5956
5993
|
logger.info(
|
|
5957
5994
|
colors3.blue(
|
|
5958
|
-
`Config ${
|
|
5995
|
+
`Config ${path11.basename(currentConfig.__meta.configPath)} changed. Reloading...`
|
|
5959
5996
|
),
|
|
5960
5997
|
{ timestamp: true }
|
|
5961
5998
|
);
|
|
@@ -5970,11 +6007,11 @@ var viteApiPlugin = async () => {
|
|
|
5970
6007
|
const resolvedVirtualModuleId4 = `\0${virtualModuleId4}`;
|
|
5971
6008
|
const initialConfig = getCurrentConfig();
|
|
5972
6009
|
const zuploProcessors = ZuploEnv.isZuplo ? await runnerImport3(
|
|
5973
|
-
|
|
6010
|
+
path12.resolve(getZudokuRootDir(), "src/zuplo/with-zuplo-processors.ts")
|
|
5974
6011
|
).then((m) => m.module.default(initialConfig.__meta.rootDir)) : [];
|
|
5975
6012
|
const buildConfig = await getBuildConfig();
|
|
5976
6013
|
const buildProcessors = buildConfig?.processors ?? [];
|
|
5977
|
-
const tmpStoreDir =
|
|
6014
|
+
const tmpStoreDir = path12.posix.join(
|
|
5978
6015
|
initialConfig.__meta.rootDir,
|
|
5979
6016
|
PROCESSED_STORE_SUBPATH
|
|
5980
6017
|
);
|
|
@@ -6002,7 +6039,7 @@ var viteApiPlugin = async () => {
|
|
|
6002
6039
|
const inputPath = pathMap.get(req.url);
|
|
6003
6040
|
if (!inputPath) return next();
|
|
6004
6041
|
const content = await fs2.readFile(inputPath, "utf-8");
|
|
6005
|
-
const mimeType =
|
|
6042
|
+
const mimeType = path12.extname(inputPath).toLowerCase() === ".json" ? "application/json" : "application/x-yaml";
|
|
6006
6043
|
res.setHeader("Content-Type", `${mimeType}; charset=utf-8`);
|
|
6007
6044
|
return res.end(content);
|
|
6008
6045
|
});
|
|
@@ -6228,8 +6265,8 @@ var viteApiPlugin = async () => {
|
|
|
6228
6265
|
if (process.env.NODE_ENV !== "production") return;
|
|
6229
6266
|
for (const [urlPath, inputPath] of pathMap) {
|
|
6230
6267
|
const content = await fs2.readFile(inputPath, "utf-8");
|
|
6231
|
-
const outputPath =
|
|
6232
|
-
await fs2.mkdir(
|
|
6268
|
+
const outputPath = path12.join(config.__meta.rootDir, "dist", urlPath);
|
|
6269
|
+
await fs2.mkdir(path12.dirname(outputPath), { recursive: true });
|
|
6233
6270
|
await fs2.writeFile(outputPath, content, "utf-8");
|
|
6234
6271
|
}
|
|
6235
6272
|
}
|
|
@@ -6394,7 +6431,7 @@ var viteDocMetadataPlugin = () => ({
|
|
|
6394
6431
|
});
|
|
6395
6432
|
|
|
6396
6433
|
// src/vite/plugin-docs.ts
|
|
6397
|
-
import
|
|
6434
|
+
import path13 from "node:path";
|
|
6398
6435
|
import { glob as glob3 } from "glob";
|
|
6399
6436
|
import globParent from "glob-parent";
|
|
6400
6437
|
|
|
@@ -6461,7 +6498,7 @@ var globMarkdownFiles = async (config, options = { absolute: false }) => {
|
|
|
6461
6498
|
if (process.env.NODE_ENV !== "development") {
|
|
6462
6499
|
const draftStatuses = await Promise.all(
|
|
6463
6500
|
globbedFiles.map(async (file) => {
|
|
6464
|
-
const absolutePath =
|
|
6501
|
+
const absolutePath = path13.resolve(config.__meta.rootDir, file);
|
|
6465
6502
|
const { data } = await readFrontmatter(absolutePath);
|
|
6466
6503
|
return { file, isDraft: data.draft === true };
|
|
6467
6504
|
})
|
|
@@ -6474,9 +6511,9 @@ var globMarkdownFiles = async (config, options = { absolute: false }) => {
|
|
|
6474
6511
|
if (draftFiles.has(file)) {
|
|
6475
6512
|
continue;
|
|
6476
6513
|
}
|
|
6477
|
-
const relativePath =
|
|
6514
|
+
const relativePath = path13.posix.relative(parent, file);
|
|
6478
6515
|
const routePath = ensureLeadingSlash(relativePath.replace(/\.mdx?$/, ""));
|
|
6479
|
-
const filePath = options.absolute ?
|
|
6516
|
+
const filePath = options.absolute ? path13.resolve(config.__meta.rootDir, file) : file;
|
|
6480
6517
|
fileMapping[routePath] = filePath;
|
|
6481
6518
|
}
|
|
6482
6519
|
}
|
|
@@ -6560,7 +6597,7 @@ var plugin_docs_default = viteDocsPlugin;
|
|
|
6560
6597
|
|
|
6561
6598
|
// src/vite/plugin-markdown-export.ts
|
|
6562
6599
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
6563
|
-
import
|
|
6600
|
+
import path14 from "node:path";
|
|
6564
6601
|
init_joinUrl();
|
|
6565
6602
|
var processMarkdownFile = async (filePath) => {
|
|
6566
6603
|
const { content: markdownContent, data: frontmatter } = await readFrontmatter(filePath);
|
|
@@ -6577,7 +6614,7 @@ ${markdownContent}`;
|
|
|
6577
6614
|
};
|
|
6578
6615
|
var getMarkdownOutputPath = (distDir, routePath) => {
|
|
6579
6616
|
const segments = routePath === "/" ? ["index"] : routePath.split("/").filter(Boolean);
|
|
6580
|
-
return `${
|
|
6617
|
+
return `${path14.join(distDir, ...segments)}.md`;
|
|
6581
6618
|
};
|
|
6582
6619
|
var resolveMarkdownRoutePath = (requestUrl, basePath) => {
|
|
6583
6620
|
const pathname = requestUrl.split(/[?#]/)[0] ?? requestUrl;
|
|
@@ -6649,7 +6686,7 @@ var viteMarkdownExportPlugin = () => {
|
|
|
6649
6686
|
if (process.env.NODE_ENV !== "production" || Object.keys(markdownFiles).length === 0 || !needsMdFiles(config)) {
|
|
6650
6687
|
return;
|
|
6651
6688
|
}
|
|
6652
|
-
const distDir =
|
|
6689
|
+
const distDir = path14.join(
|
|
6653
6690
|
config.__meta.rootDir,
|
|
6654
6691
|
"dist",
|
|
6655
6692
|
config.basePath ?? ""
|
|
@@ -6670,14 +6707,14 @@ var viteMarkdownExportPlugin = () => {
|
|
|
6670
6707
|
content: finalMarkdown
|
|
6671
6708
|
});
|
|
6672
6709
|
const outputPath = getMarkdownOutputPath(distDir, routePath);
|
|
6673
|
-
await mkdir2(
|
|
6710
|
+
await mkdir2(path14.dirname(outputPath), { recursive: true });
|
|
6674
6711
|
await writeFile2(outputPath, finalMarkdown, "utf-8");
|
|
6675
6712
|
} catch (error) {
|
|
6676
6713
|
console.warn(`Failed to export markdown for ${routePath}:`, error);
|
|
6677
6714
|
}
|
|
6678
6715
|
}
|
|
6679
6716
|
if (config.docs.llms.llmsTxt || config.docs.llms.llmsTxtFull) {
|
|
6680
|
-
const markdownInfoPath =
|
|
6717
|
+
const markdownInfoPath = path14.join(
|
|
6681
6718
|
config.__meta.rootDir,
|
|
6682
6719
|
"node_modules/.zudoku/markdown-info.json"
|
|
6683
6720
|
);
|
|
@@ -6694,9 +6731,11 @@ var plugin_markdown_export_default = viteMarkdownExportPlugin;
|
|
|
6694
6731
|
|
|
6695
6732
|
// src/vite/plugin-mdx.ts
|
|
6696
6733
|
import rehypeMetaAsAttributes from "@lekoarts/rehype-meta-as-attributes";
|
|
6734
|
+
import { nodeTypes } from "@mdx-js/mdx";
|
|
6697
6735
|
import mdx from "@mdx-js/rollup";
|
|
6698
6736
|
import { toString as hastToString2 } from "hast-util-to-string";
|
|
6699
6737
|
import rehypeMdxImportMedia from "rehype-mdx-import-media";
|
|
6738
|
+
import rehypeRaw from "rehype-raw";
|
|
6700
6739
|
import rehypeSlug from "rehype-slug";
|
|
6701
6740
|
import remarkComment from "remark-comment";
|
|
6702
6741
|
import remarkDirective from "remark-directive";
|
|
@@ -6827,9 +6866,9 @@ var remarkCodeTabs = () => (tree) => {
|
|
|
6827
6866
|
};
|
|
6828
6867
|
|
|
6829
6868
|
// src/vite/mdx/remark-inject-filepath.ts
|
|
6830
|
-
import
|
|
6869
|
+
import path15 from "node:path";
|
|
6831
6870
|
var remarkInjectFilepath = (rootDir) => (tree, vfile) => {
|
|
6832
|
-
const relativePath =
|
|
6871
|
+
const relativePath = path15.relative(rootDir, vfile.path).split(path15.sep).join(path15.posix.sep);
|
|
6833
6872
|
tree.children.unshift(exportMdxjsConst("__filepath", relativePath));
|
|
6834
6873
|
};
|
|
6835
6874
|
|
|
@@ -6916,7 +6955,7 @@ var remarkLastModified = () => {
|
|
|
6916
6955
|
};
|
|
6917
6956
|
|
|
6918
6957
|
// src/vite/mdx/remark-link-rewrite.ts
|
|
6919
|
-
import
|
|
6958
|
+
import path16 from "node:path";
|
|
6920
6959
|
import { visit as visit5 } from "unist-util-visit";
|
|
6921
6960
|
var markdownExtension = /\.mdx?$/;
|
|
6922
6961
|
var resolveToRoute = (url, filePath, routesByFile) => {
|
|
@@ -6924,7 +6963,7 @@ var resolveToRoute = (url, filePath, routesByFile) => {
|
|
|
6924
6963
|
if (!markdownExtension.test(pathname) || pathname.startsWith("/")) {
|
|
6925
6964
|
return void 0;
|
|
6926
6965
|
}
|
|
6927
|
-
const targetFile =
|
|
6966
|
+
const targetFile = path16.resolve(path16.dirname(filePath), pathname).replace(markdownExtension, "");
|
|
6928
6967
|
const route = routesByFile.get(targetFile);
|
|
6929
6968
|
if (route === void 0) return void 0;
|
|
6930
6969
|
return `${route}${suffix}`;
|
|
@@ -6939,11 +6978,11 @@ var remarkLinkRewrite = (basePath = "", routesByFile = /* @__PURE__ */ new Map()
|
|
|
6939
6978
|
node.url = resolved;
|
|
6940
6979
|
return;
|
|
6941
6980
|
}
|
|
6942
|
-
const base =
|
|
6981
|
+
const base = path16.posix.join(basePath);
|
|
6943
6982
|
if (basePath && node.url.startsWith(base)) {
|
|
6944
6983
|
node.url = node.url.slice(base.length);
|
|
6945
6984
|
} else if (!node.url.startsWith("/") && !node.url.startsWith("#")) {
|
|
6946
|
-
node.url =
|
|
6985
|
+
node.url = path16.posix.join("..", node.url);
|
|
6947
6986
|
}
|
|
6948
6987
|
node.url = node.url.replace(/\.mdx?(#.*)?$/, "$1");
|
|
6949
6988
|
});
|
|
@@ -7141,6 +7180,7 @@ var viteMdxPlugin = async () => {
|
|
|
7141
7180
|
];
|
|
7142
7181
|
const remarkPlugins = typeof buildConfig?.remarkPlugins === "function" ? buildConfig.remarkPlugins(defaultRemarkPlugins) : [...defaultRemarkPlugins, ...buildConfig?.remarkPlugins ?? []];
|
|
7143
7182
|
const defaultRehypePlugins = [
|
|
7183
|
+
[rehypeRaw, { passThrough: nodeTypes }],
|
|
7144
7184
|
rehypeSlug,
|
|
7145
7185
|
rehype_extract_toc_with_jsx_default,
|
|
7146
7186
|
rehype_extract_toc_with_jsx_export_default,
|
|
@@ -7451,8 +7491,8 @@ var protectedAnnotatorPlugin = () => ({
|
|
|
7451
7491
|
});
|
|
7452
7492
|
|
|
7453
7493
|
// src/vite/config.ts
|
|
7454
|
-
var getAppClientEntryPath = () =>
|
|
7455
|
-
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");
|
|
7456
7496
|
var hasLoggedCdnInfo = false;
|
|
7457
7497
|
var MEDIA_REGEX = /\.(a?png|jpe?g|gif|bmp|svg|webp|tiff|ico|webm|ogg|mp3|wav|m4a|avif|mp4)/i;
|
|
7458
7498
|
var defineEnvVars = (vars) => Object.fromEntries(
|
|
@@ -7486,7 +7526,7 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7486
7526
|
);
|
|
7487
7527
|
if (ZuploEnv.isZuplo) {
|
|
7488
7528
|
dotenv.config({
|
|
7489
|
-
path:
|
|
7529
|
+
path: path17.resolve(config.__meta.rootDir, "../.env.zuplo"),
|
|
7490
7530
|
quiet: true
|
|
7491
7531
|
});
|
|
7492
7532
|
}
|
|
@@ -7546,7 +7586,7 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7546
7586
|
sourcemap: true,
|
|
7547
7587
|
target: "es2022",
|
|
7548
7588
|
chunkSizeWarningLimit: 1500,
|
|
7549
|
-
outDir:
|
|
7589
|
+
outDir: path17.resolve(path17.join(dir, "dist", config.basePath ?? "")),
|
|
7550
7590
|
emptyOutDir: false,
|
|
7551
7591
|
rolldownOptions: {
|
|
7552
7592
|
external: [joinUrl(config.basePath, "/pagefind/pagefind.js")],
|
|
@@ -7576,8 +7616,8 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7576
7616
|
external: ["@shikijs/themes", "@shikijs/langs"]
|
|
7577
7617
|
},
|
|
7578
7618
|
build: {
|
|
7579
|
-
outDir:
|
|
7580
|
-
|
|
7619
|
+
outDir: path17.resolve(
|
|
7620
|
+
path17.join(dir, "dist", config.basePath ?? "", "server")
|
|
7581
7621
|
),
|
|
7582
7622
|
copyPublicDir: false,
|
|
7583
7623
|
rolldownOptions: {
|
|
@@ -7592,7 +7632,7 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7592
7632
|
if (filename.startsWith(`${PROTECTED_CHUNK_DIR}/`)) {
|
|
7593
7633
|
return joinUrl(config.basePath, `/${filename}`);
|
|
7594
7634
|
}
|
|
7595
|
-
if (cdnUrl?.base && [".js", ".css"].includes(
|
|
7635
|
+
if (cdnUrl?.base && [".js", ".css"].includes(path17.extname(filename))) {
|
|
7596
7636
|
return joinUrl(cdnUrl.base, filename);
|
|
7597
7637
|
}
|
|
7598
7638
|
if (cdnUrl?.media && MEDIA_REGEX.test(filename)) {
|
|
@@ -7602,7 +7642,7 @@ async function getViteConfig(dir, configEnv, options = {}) {
|
|
|
7602
7642
|
}
|
|
7603
7643
|
},
|
|
7604
7644
|
optimizeDeps: {
|
|
7605
|
-
entries: [
|
|
7645
|
+
entries: [path17.posix.join(getZudokuRootDir(), "src/{app,lib}/**")],
|
|
7606
7646
|
exclude: ["zudoku"],
|
|
7607
7647
|
include: [
|
|
7608
7648
|
"@mdx-js/react",
|
|
@@ -7699,10 +7739,10 @@ ${cssLinks}
|
|
|
7699
7739
|
|
|
7700
7740
|
// src/vite/manifest.ts
|
|
7701
7741
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
7702
|
-
import
|
|
7742
|
+
import path18 from "node:path";
|
|
7703
7743
|
var writeManifest = async (distDir, config) => {
|
|
7704
7744
|
await writeFile3(
|
|
7705
|
-
|
|
7745
|
+
path18.join(distDir, MANIFEST_FILENAME),
|
|
7706
7746
|
`${JSON.stringify(buildManifest(config), null, 2)}
|
|
7707
7747
|
`,
|
|
7708
7748
|
"utf-8"
|
|
@@ -7712,7 +7752,7 @@ var writeManifest = async (distDir, config) => {
|
|
|
7712
7752
|
// src/vite/output.ts
|
|
7713
7753
|
import assert from "node:assert";
|
|
7714
7754
|
import { cp, mkdir as mkdir3, writeFile as writeFile4 } from "node:fs/promises";
|
|
7715
|
-
import
|
|
7755
|
+
import path19 from "node:path";
|
|
7716
7756
|
init_joinUrl();
|
|
7717
7757
|
var pkgJson = getZudokuPackageJson();
|
|
7718
7758
|
function generateOutput({
|
|
@@ -7770,9 +7810,9 @@ async function writeOutput(dir, {
|
|
|
7770
7810
|
rewrites
|
|
7771
7811
|
}) {
|
|
7772
7812
|
const output = generateOutput({ config, redirects, rewrites });
|
|
7773
|
-
const outputDir = process.env.VERCEL ?
|
|
7813
|
+
const outputDir = process.env.VERCEL ? path19.join(dir, ".vercel/output") : path19.join(dir, "dist/.output");
|
|
7774
7814
|
await mkdir3(outputDir, { recursive: true });
|
|
7775
|
-
const outputFile =
|
|
7815
|
+
const outputFile = path19.join(outputDir, "config.json");
|
|
7776
7816
|
await writeFile4(outputFile, JSON.stringify(output, null, 2), "utf-8");
|
|
7777
7817
|
if (process.env.VERCEL) {
|
|
7778
7818
|
console.log("Wrote Vercel output to", outputDir);
|
|
@@ -7781,9 +7821,9 @@ async function writeOutput(dir, {
|
|
|
7781
7821
|
|
|
7782
7822
|
// src/vite/prerender/prerender.ts
|
|
7783
7823
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
7784
|
-
import { readFile as
|
|
7824
|
+
import { readFile as readFile3, rm } from "node:fs/promises";
|
|
7785
7825
|
import os from "node:os";
|
|
7786
|
-
import
|
|
7826
|
+
import path22 from "node:path";
|
|
7787
7827
|
import { pathToFileURL } from "node:url";
|
|
7788
7828
|
import { createIndex } from "pagefind";
|
|
7789
7829
|
import colors7 from "picocolors";
|
|
@@ -7823,7 +7863,7 @@ function throttle(fn) {
|
|
|
7823
7863
|
init_joinUrl();
|
|
7824
7864
|
import { createWriteStream, existsSync } from "node:fs";
|
|
7825
7865
|
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
7826
|
-
import
|
|
7866
|
+
import path20 from "node:path";
|
|
7827
7867
|
import colors5 from "picocolors";
|
|
7828
7868
|
import { SitemapStream } from "sitemap";
|
|
7829
7869
|
async function generateSitemap({
|
|
@@ -7837,11 +7877,11 @@ async function generateSitemap({
|
|
|
7837
7877
|
return;
|
|
7838
7878
|
}
|
|
7839
7879
|
const sitemap = new SitemapStream({ hostname: config.siteUrl });
|
|
7840
|
-
const outputDir =
|
|
7880
|
+
const outputDir = path20.resolve(baseOutputDir, config.outDir ?? "");
|
|
7841
7881
|
if (!existsSync(outputDir)) {
|
|
7842
7882
|
await mkdir4(outputDir, { recursive: true });
|
|
7843
7883
|
}
|
|
7844
|
-
const sitemapOutputPath =
|
|
7884
|
+
const sitemapOutputPath = path20.join(outputDir, "sitemap.xml");
|
|
7845
7885
|
const writeStream = createWriteStream(sitemapOutputPath);
|
|
7846
7886
|
sitemap.pipe(writeStream);
|
|
7847
7887
|
let lastmod;
|
|
@@ -7871,14 +7911,14 @@ async function generateSitemap({
|
|
|
7871
7911
|
|
|
7872
7912
|
// src/vite/prerender/utils.ts
|
|
7873
7913
|
init_joinUrl();
|
|
7874
|
-
var resolveRoutePath = (
|
|
7875
|
-
const segments =
|
|
7914
|
+
var resolveRoutePath = (path31) => {
|
|
7915
|
+
const segments = path31.split("/");
|
|
7876
7916
|
if (segments.some((s) => s.startsWith(":") && !s.endsWith("?"))) {
|
|
7877
7917
|
return void 0;
|
|
7878
7918
|
}
|
|
7879
7919
|
return segments.filter((s) => !s.startsWith(":")).join("/") || void 0;
|
|
7880
7920
|
};
|
|
7881
|
-
var isSkipped = (
|
|
7921
|
+
var isSkipped = (path31) => path31.includes("*") || /^\d+$/.test(path31);
|
|
7882
7922
|
var resolveRoutes = (routes, parentPath = "") => routes.flatMap((route) => {
|
|
7883
7923
|
if (route.path && isSkipped(route.path)) return [];
|
|
7884
7924
|
const routePath = route.path ? resolveRoutePath(route.path) : void 0;
|
|
@@ -7908,6 +7948,16 @@ var collectRewrites = (resolved) => resolved.flatMap((r) => [
|
|
|
7908
7948
|
]);
|
|
7909
7949
|
var routesToPaths = (routes) => collectPaths(resolveRoutes(routes), "");
|
|
7910
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
|
+
};
|
|
7911
7961
|
|
|
7912
7962
|
// src/vite/prerender/prerender.ts
|
|
7913
7963
|
var Piscina = PiscinaImport;
|
|
@@ -7927,12 +7977,12 @@ var prerender = async ({
|
|
|
7927
7977
|
serverConfigFilename,
|
|
7928
7978
|
writeRedirects = true
|
|
7929
7979
|
}) => {
|
|
7930
|
-
const distDir =
|
|
7980
|
+
const distDir = path22.join(dir, "dist", basePath);
|
|
7931
7981
|
const serverConfigPath = pathToFileURL(
|
|
7932
|
-
|
|
7982
|
+
path22.join(distDir, "server", serverConfigFilename)
|
|
7933
7983
|
).href;
|
|
7934
7984
|
const entryServerPath = pathToFileURL(
|
|
7935
|
-
|
|
7985
|
+
path22.join(distDir, "server/entry.server.js")
|
|
7936
7986
|
).href;
|
|
7937
7987
|
const rawConfig = await import(serverConfigPath).then((m) => m.default);
|
|
7938
7988
|
const config = validateConfig(await runPluginTransformConfig(rawConfig));
|
|
@@ -8021,9 +8071,18 @@ var prerender = async ({
|
|
|
8021
8071
|
logger.info(colors7.blue(message));
|
|
8022
8072
|
}
|
|
8023
8073
|
if (pagefindIndex) {
|
|
8024
|
-
const pagesToIndex =
|
|
8025
|
-
|
|
8074
|
+
const { include: pagesToIndex, exclude } = selectPagesToIndex(
|
|
8075
|
+
workerResults,
|
|
8076
|
+
paths
|
|
8026
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
|
+
}
|
|
8027
8086
|
const BATCH_SIZE = 40;
|
|
8028
8087
|
const pagefindStart = performance.now();
|
|
8029
8088
|
for (let offset = 0; offset < pagesToIndex.length; offset += BATCH_SIZE) {
|
|
@@ -8042,7 +8101,7 @@ var prerender = async ({
|
|
|
8042
8101
|
}
|
|
8043
8102
|
if (isTTY()) writeLine("");
|
|
8044
8103
|
const { outputPath } = await pagefindIndex.writeFiles({
|
|
8045
|
-
outputPath:
|
|
8104
|
+
outputPath: path22.join(distDir, "pagefind")
|
|
8046
8105
|
});
|
|
8047
8106
|
if (outputPath) {
|
|
8048
8107
|
const duration = (performance.now() - pagefindStart) / 1e3;
|
|
@@ -8062,13 +8121,13 @@ var prerender = async ({
|
|
|
8062
8121
|
redirectUrls
|
|
8063
8122
|
});
|
|
8064
8123
|
const llmsConfig = config.docs.llms;
|
|
8065
|
-
const markdownInfoPath =
|
|
8124
|
+
const markdownInfoPath = path22.join(
|
|
8066
8125
|
dir,
|
|
8067
8126
|
"node_modules/.zudoku/markdown-info.json"
|
|
8068
8127
|
);
|
|
8069
8128
|
let markdownFileInfos = [];
|
|
8070
8129
|
if (await fileExists(markdownInfoPath)) {
|
|
8071
|
-
const markdownInfoContent = await
|
|
8130
|
+
const markdownInfoContent = await readFile3(markdownInfoPath, "utf-8");
|
|
8072
8131
|
markdownFileInfos = JSON.parse(markdownInfoContent);
|
|
8073
8132
|
}
|
|
8074
8133
|
if (llmsConfig.llmsTxt || llmsConfig.llmsTxtFull) {
|
|
@@ -8088,7 +8147,7 @@ var prerender = async ({
|
|
|
8088
8147
|
await Promise.all(
|
|
8089
8148
|
markdownFileInfos.map((info) => {
|
|
8090
8149
|
const outputPath = getMarkdownOutputPath(distDir, info.routePath);
|
|
8091
|
-
if (!
|
|
8150
|
+
if (!path22.resolve(outputPath).startsWith(path22.resolve(distDir))) {
|
|
8092
8151
|
return;
|
|
8093
8152
|
}
|
|
8094
8153
|
return rm(outputPath).catch(() => {
|
|
@@ -8146,8 +8205,8 @@ var getContainerMemoryLimitMb = () => {
|
|
|
8146
8205
|
};
|
|
8147
8206
|
|
|
8148
8207
|
// src/vite/protected/build.ts
|
|
8149
|
-
import { mkdir as mkdir5, readdir, readFile as
|
|
8150
|
-
import
|
|
8208
|
+
import { mkdir as mkdir5, readdir, readFile as readFile4, rename, rm as rm2 } from "node:fs/promises";
|
|
8209
|
+
import path23 from "node:path";
|
|
8151
8210
|
init_joinUrl();
|
|
8152
8211
|
var assertProtectedPatternsCovered = (config) => {
|
|
8153
8212
|
const { patterns } = getProtectedSourceMatcher(config);
|
|
@@ -8169,11 +8228,11 @@ var findProtectedLeaks = (output) => {
|
|
|
8169
8228
|
const visited = /* @__PURE__ */ new Set();
|
|
8170
8229
|
const stack = [{ fileName: entry.fileName, path: [entry.fileName] }];
|
|
8171
8230
|
while (stack.length > 0) {
|
|
8172
|
-
const { fileName, path:
|
|
8231
|
+
const { fileName, path: path31 } = stack.pop();
|
|
8173
8232
|
if (visited.has(fileName)) continue;
|
|
8174
8233
|
visited.add(fileName);
|
|
8175
8234
|
for (const imp of byFileName.get(fileName)?.imports ?? []) {
|
|
8176
|
-
const next = [...
|
|
8235
|
+
const next = [...path31, imp];
|
|
8177
8236
|
if (isProtected(imp)) {
|
|
8178
8237
|
leaks.push(next.join(" -> "));
|
|
8179
8238
|
continue;
|
|
@@ -8204,17 +8263,17 @@ This eagerly pulls gated content into the public bundle. Check that nothing in n
|
|
|
8204
8263
|
);
|
|
8205
8264
|
};
|
|
8206
8265
|
var moveProtectedChunks = async (clientOutDir, serverOutDir) => {
|
|
8207
|
-
const srcDir =
|
|
8266
|
+
const srcDir = path23.join(clientOutDir, PROTECTED_CHUNK_DIR);
|
|
8208
8267
|
const files = await readdir(srcDir).catch((err) => {
|
|
8209
8268
|
if (err.code === "ENOENT") return null;
|
|
8210
8269
|
throw err;
|
|
8211
8270
|
});
|
|
8212
8271
|
if (!files) return;
|
|
8213
|
-
const destDir =
|
|
8272
|
+
const destDir = path23.join(serverOutDir, PROTECTED_CHUNK_DIR);
|
|
8214
8273
|
await mkdir5(destDir, { recursive: true });
|
|
8215
8274
|
await Promise.all(
|
|
8216
8275
|
files.map(
|
|
8217
|
-
(file) => rename(
|
|
8276
|
+
(file) => rename(path23.join(srcDir, file), path23.join(destDir, file))
|
|
8218
8277
|
)
|
|
8219
8278
|
);
|
|
8220
8279
|
const leftover = await readdir(srcDir).catch(() => []);
|
|
@@ -8232,7 +8291,7 @@ var assertCloudflareWranglerGatesProtected = async (dir, config) => {
|
|
|
8232
8291
|
const protectedPrefix = `${joinUrl(config.basePath, PROTECTED_CHUNK_DIR)}/`;
|
|
8233
8292
|
const candidates = ["wrangler.toml", "wrangler.jsonc", "wrangler.json"];
|
|
8234
8293
|
for (const name of candidates) {
|
|
8235
|
-
const file = await
|
|
8294
|
+
const file = await readFile4(path23.join(dir, name), "utf-8").catch(
|
|
8236
8295
|
() => void 0
|
|
8237
8296
|
);
|
|
8238
8297
|
if (file === void 0) continue;
|
|
@@ -8260,7 +8319,7 @@ async function runBuild(options) {
|
|
|
8260
8319
|
const builder2 = await createBuilder(viteConfig);
|
|
8261
8320
|
invariant(builder2.environments.client, "Client environment is missing");
|
|
8262
8321
|
invariant(builder2.environments.ssr, "SSR environment is missing");
|
|
8263
|
-
const distDir =
|
|
8322
|
+
const distDir = path24.resolve(path24.join(dir, "dist"));
|
|
8264
8323
|
await rm3(distDir, { recursive: true, force: true });
|
|
8265
8324
|
const [clientResult, serverResult] = await Promise.all([
|
|
8266
8325
|
builder2.build(builder2.environments.client),
|
|
@@ -8310,13 +8369,13 @@ async function runBuild(options) {
|
|
|
8310
8369
|
await assertCloudflareWranglerGatesProtected(dir, config);
|
|
8311
8370
|
}
|
|
8312
8371
|
await writeFile6(
|
|
8313
|
-
|
|
8372
|
+
path24.join(distDir, "package.json"),
|
|
8314
8373
|
`${JSON.stringify({ type: "module" }, null, 2)}
|
|
8315
8374
|
`,
|
|
8316
8375
|
"utf-8"
|
|
8317
8376
|
);
|
|
8318
8377
|
await writeManifest(distDir, config);
|
|
8319
|
-
await rm3(
|
|
8378
|
+
await rm3(path24.join(clientOutDir, "index.html"), { force: true });
|
|
8320
8379
|
} else {
|
|
8321
8380
|
await runPrerender({
|
|
8322
8381
|
dir,
|
|
@@ -8347,25 +8406,25 @@ var runPrerender = async (options) => {
|
|
|
8347
8406
|
serverConfigFilename,
|
|
8348
8407
|
writeRedirects: process.env.VERCEL === void 0
|
|
8349
8408
|
});
|
|
8350
|
-
const indexHtml =
|
|
8409
|
+
const indexHtml = path24.join(clientOutDir, "index.html");
|
|
8351
8410
|
if (!workerResults.find((r) => r.outputPath === indexHtml)) {
|
|
8352
8411
|
await writeFile6(indexHtml, html, "utf-8");
|
|
8353
8412
|
}
|
|
8354
8413
|
const statusPages = workerResults.flatMap(
|
|
8355
|
-
(r) => /^(400|404|500)\.html$/.test(
|
|
8414
|
+
(r) => /^(400|404|500)\.html$/.test(path24.basename(r.outputPath)) ? r.outputPath : []
|
|
8356
8415
|
);
|
|
8357
8416
|
for (const statusPage of statusPages) {
|
|
8358
8417
|
await rename2(
|
|
8359
8418
|
statusPage,
|
|
8360
|
-
|
|
8419
|
+
path24.join(dir, DIST_DIR, path24.basename(statusPage))
|
|
8361
8420
|
);
|
|
8362
8421
|
}
|
|
8363
8422
|
await rm3(serverOutDir, { recursive: true, force: true });
|
|
8364
8423
|
if (process.env.VERCEL) {
|
|
8365
|
-
await mkdir6(
|
|
8424
|
+
await mkdir6(path24.join(dir, ".vercel/output/static"), { recursive: true });
|
|
8366
8425
|
await rename2(
|
|
8367
|
-
|
|
8368
|
-
|
|
8426
|
+
path24.join(dir, DIST_DIR),
|
|
8427
|
+
path24.join(dir, ".vercel/output/static")
|
|
8369
8428
|
);
|
|
8370
8429
|
}
|
|
8371
8430
|
await writeOutput(dir, {
|
|
@@ -8376,7 +8435,7 @@ var runPrerender = async (options) => {
|
|
|
8376
8435
|
if (ZuploEnv.isZuplo && issuer) {
|
|
8377
8436
|
const provider = config.authentication?.type;
|
|
8378
8437
|
await writeFile6(
|
|
8379
|
-
|
|
8438
|
+
path24.join(dir, DIST_DIR, ".output/zuplo.json"),
|
|
8380
8439
|
JSON.stringify({ issuer, provider }, null, 2),
|
|
8381
8440
|
"utf-8"
|
|
8382
8441
|
);
|
|
@@ -8388,7 +8447,7 @@ var runPrerender = async (options) => {
|
|
|
8388
8447
|
};
|
|
8389
8448
|
var findUserEntry = (dir) => {
|
|
8390
8449
|
for (const ext of ["ts", "tsx", "js", "mjs"]) {
|
|
8391
|
-
const candidate =
|
|
8450
|
+
const candidate = path24.join(dir, `zudoku.server.${ext}`);
|
|
8392
8451
|
if (existsSync2(candidate)) return candidate;
|
|
8393
8452
|
}
|
|
8394
8453
|
};
|
|
@@ -8399,15 +8458,15 @@ var bundleSSREntry = async (options) => {
|
|
|
8399
8458
|
let entryPoint = userEntry;
|
|
8400
8459
|
let tempEntryPath;
|
|
8401
8460
|
if (!entryPoint) {
|
|
8402
|
-
tempEntryPath =
|
|
8403
|
-
const templateContent = await
|
|
8404
|
-
|
|
8461
|
+
tempEntryPath = path24.join(dir, "__ssr-entry.ts");
|
|
8462
|
+
const templateContent = await readFile5(
|
|
8463
|
+
path24.join(packageRoot, "src/vite/ssr-templates", `${adapter}.ts`),
|
|
8405
8464
|
"utf-8"
|
|
8406
8465
|
);
|
|
8407
8466
|
await writeFile6(tempEntryPath, templateContent, "utf-8");
|
|
8408
8467
|
entryPoint = tempEntryPath;
|
|
8409
8468
|
}
|
|
8410
|
-
const frameworkPath =
|
|
8469
|
+
const frameworkPath = path24.join(serverOutDir, "entry.server.js");
|
|
8411
8470
|
try {
|
|
8412
8471
|
await esbuild({
|
|
8413
8472
|
entryPoints: [entryPoint],
|
|
@@ -8415,9 +8474,9 @@ var bundleSSREntry = async (options) => {
|
|
|
8415
8474
|
platform: ["node", "lambda"].includes(adapter) ? "node" : "neutral",
|
|
8416
8475
|
target: "es2022",
|
|
8417
8476
|
format: "esm",
|
|
8418
|
-
outfile:
|
|
8477
|
+
outfile: path24.join(serverOutDir, "entry.js"),
|
|
8419
8478
|
external: ["./zudoku.config.js"],
|
|
8420
|
-
nodePaths: [
|
|
8479
|
+
nodePaths: [path24.join(packageRoot, "node_modules")],
|
|
8421
8480
|
banner: { js: "// Bundled SSR entry" },
|
|
8422
8481
|
define: {
|
|
8423
8482
|
__ZUDOKU_TEMPLATE__: JSON.stringify(html)
|
|
@@ -8436,7 +8495,7 @@ var bundleSSREntry = async (options) => {
|
|
|
8436
8495
|
await Promise.all([
|
|
8437
8496
|
rm3(frameworkPath, { force: true }),
|
|
8438
8497
|
rm3(`${frameworkPath}.map`, { force: true }),
|
|
8439
|
-
rm3(
|
|
8498
|
+
rm3(path24.join(serverOutDir, "assets"), {
|
|
8440
8499
|
recursive: true,
|
|
8441
8500
|
force: true
|
|
8442
8501
|
})
|
|
@@ -8466,11 +8525,11 @@ function printWarningToConsole(message) {
|
|
|
8466
8525
|
}
|
|
8467
8526
|
|
|
8468
8527
|
// src/cli/preview/handler.ts
|
|
8469
|
-
import
|
|
8528
|
+
import path25 from "node:path";
|
|
8470
8529
|
import { preview as vitePreview } from "vite";
|
|
8471
8530
|
var DEFAULT_PREVIEW_PORT = 4e3;
|
|
8472
8531
|
async function preview(argv) {
|
|
8473
|
-
const dir =
|
|
8532
|
+
const dir = path25.resolve(process.cwd(), argv.dir);
|
|
8474
8533
|
const viteConfig = await getViteConfig(dir, {
|
|
8475
8534
|
command: "serve",
|
|
8476
8535
|
mode: "production",
|
|
@@ -8508,7 +8567,7 @@ async function build(argv) {
|
|
|
8508
8567
|
printDiagnosticsToConsole(`Starting Zudoku build v${packageJson2.version}`);
|
|
8509
8568
|
printDiagnosticsToConsole("");
|
|
8510
8569
|
printDiagnosticsToConsole("");
|
|
8511
|
-
const dir =
|
|
8570
|
+
const dir = path26.resolve(process.cwd(), argv.dir);
|
|
8512
8571
|
try {
|
|
8513
8572
|
await runBuild({
|
|
8514
8573
|
dir,
|
|
@@ -8662,13 +8721,13 @@ var build_default = {
|
|
|
8662
8721
|
|
|
8663
8722
|
// src/cli/dev/handler.ts
|
|
8664
8723
|
init_joinUrl();
|
|
8665
|
-
import
|
|
8724
|
+
import path29 from "node:path";
|
|
8666
8725
|
|
|
8667
8726
|
// src/vite/dev-server.ts
|
|
8668
8727
|
import fs3 from "node:fs/promises";
|
|
8669
8728
|
import http from "node:http";
|
|
8670
8729
|
import https from "node:https";
|
|
8671
|
-
import
|
|
8730
|
+
import path28 from "node:path";
|
|
8672
8731
|
import { stripVTControlCharacters } from "node:util";
|
|
8673
8732
|
import { createHttpTerminator } from "http-terminator";
|
|
8674
8733
|
import {
|
|
@@ -8700,7 +8759,7 @@ async function findAvailablePort(startPort) {
|
|
|
8700
8759
|
init_joinUrl();
|
|
8701
8760
|
|
|
8702
8761
|
// src/vite/pagefind-dev-index.ts
|
|
8703
|
-
import
|
|
8762
|
+
import path27 from "node:path";
|
|
8704
8763
|
import { createIndex as createIndex2 } from "pagefind";
|
|
8705
8764
|
import { isRunnableDevEnvironment } from "vite";
|
|
8706
8765
|
init_joinUrl();
|
|
@@ -8754,7 +8813,7 @@ async function* buildPagefindDevIndex(vite, config) {
|
|
|
8754
8813
|
path: urlPath
|
|
8755
8814
|
};
|
|
8756
8815
|
}
|
|
8757
|
-
const outputPath =
|
|
8816
|
+
const outputPath = path27.join(vite.config.publicDir, "pagefind");
|
|
8758
8817
|
await pagefindIndex.writeFiles({ outputPath });
|
|
8759
8818
|
yield { type: "complete", success: true, indexed };
|
|
8760
8819
|
}
|
|
@@ -8774,9 +8833,9 @@ var DevServer = class {
|
|
|
8774
8833
|
this.protocol = "https";
|
|
8775
8834
|
const { dir } = this.#options;
|
|
8776
8835
|
const [key, cert, ca] = await Promise.all([
|
|
8777
|
-
fs3.readFile(
|
|
8778
|
-
fs3.readFile(
|
|
8779
|
-
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
|
|
8780
8839
|
]);
|
|
8781
8840
|
return https.createServer({ key, cert, ca });
|
|
8782
8841
|
}
|
|
@@ -8804,7 +8863,7 @@ var DevServer = class {
|
|
|
8804
8863
|
// built-in transform middleware which would treat the path as a static asset.
|
|
8805
8864
|
name: "zudoku:entry-client",
|
|
8806
8865
|
configureServer(server2) {
|
|
8807
|
-
const entryPath =
|
|
8866
|
+
const entryPath = path28.posix.join(
|
|
8808
8867
|
server2.config.base,
|
|
8809
8868
|
"/__z/entry.client.tsx"
|
|
8810
8869
|
);
|
|
@@ -8916,13 +8975,13 @@ var DevServer = class {
|
|
|
8916
8975
|
`Server-side rendering ${this.#options.ssr ? "enabled" : "disabled"}`
|
|
8917
8976
|
);
|
|
8918
8977
|
if (config.search?.type === "pagefind") {
|
|
8919
|
-
const pagefindPath =
|
|
8978
|
+
const pagefindPath = path28.join(
|
|
8920
8979
|
vite.config.publicDir,
|
|
8921
8980
|
"pagefind/pagefind.js"
|
|
8922
8981
|
);
|
|
8923
8982
|
const exists = await fs3.stat(pagefindPath).catch(() => false);
|
|
8924
8983
|
if (!exists) {
|
|
8925
|
-
await fs3.mkdir(
|
|
8984
|
+
await fs3.mkdir(path28.dirname(pagefindPath), { recursive: true });
|
|
8926
8985
|
await fs3.writeFile(pagefindPath, 'throw new Error("NOT_BUILT_YET");');
|
|
8927
8986
|
}
|
|
8928
8987
|
}
|
|
@@ -9024,7 +9083,7 @@ var DevServer = class {
|
|
|
9024
9083
|
async function dev(argv) {
|
|
9025
9084
|
const packageJson2 = getZudokuPackageJson();
|
|
9026
9085
|
process.env.NODE_ENV = "development";
|
|
9027
|
-
const dir =
|
|
9086
|
+
const dir = path29.resolve(process.cwd(), argv.dir);
|
|
9028
9087
|
const server = new DevServer({
|
|
9029
9088
|
dir,
|
|
9030
9089
|
argPort: argv.port,
|
|
@@ -9130,7 +9189,7 @@ var preview_default = previewCommand;
|
|
|
9130
9189
|
|
|
9131
9190
|
// src/cli/common/outdated.ts
|
|
9132
9191
|
import { existsSync as existsSync3, mkdirSync } from "node:fs";
|
|
9133
|
-
import { readFile as
|
|
9192
|
+
import { readFile as readFile6, writeFile as writeFile7 } from "node:fs/promises";
|
|
9134
9193
|
import { join } from "node:path";
|
|
9135
9194
|
import colors10 from "picocolors";
|
|
9136
9195
|
import { gt } from "semver";
|
|
@@ -9180,12 +9239,12 @@ function box(message, {
|
|
|
9180
9239
|
|
|
9181
9240
|
// src/cli/common/xdg/lib.ts
|
|
9182
9241
|
import { homedir } from "node:os";
|
|
9183
|
-
import
|
|
9242
|
+
import path30 from "node:path";
|
|
9184
9243
|
function defineDirectoryWithFallback(xdgName, fallback) {
|
|
9185
9244
|
if (process.env[xdgName]) {
|
|
9186
9245
|
return process.env[xdgName];
|
|
9187
9246
|
} else {
|
|
9188
|
-
return
|
|
9247
|
+
return path30.join(homedir(), fallback);
|
|
9189
9248
|
}
|
|
9190
9249
|
}
|
|
9191
9250
|
var XDG_CONFIG_HOME = defineDirectoryWithFallback(
|
|
@@ -9200,15 +9259,15 @@ var XDG_STATE_HOME = defineDirectoryWithFallback(
|
|
|
9200
9259
|
"XDG_DATA_HOME",
|
|
9201
9260
|
".local/state"
|
|
9202
9261
|
);
|
|
9203
|
-
var ZUDOKU_XDG_CONFIG_HOME =
|
|
9262
|
+
var ZUDOKU_XDG_CONFIG_HOME = path30.join(
|
|
9204
9263
|
XDG_CONFIG_HOME,
|
|
9205
9264
|
CLI_XDG_FOLDER_NAME
|
|
9206
9265
|
);
|
|
9207
|
-
var ZUDOKU_XDG_DATA_HOME =
|
|
9266
|
+
var ZUDOKU_XDG_DATA_HOME = path30.join(
|
|
9208
9267
|
XDG_DATA_HOME,
|
|
9209
9268
|
CLI_XDG_FOLDER_NAME
|
|
9210
9269
|
);
|
|
9211
|
-
var ZUDOKU_XDG_STATE_HOME =
|
|
9270
|
+
var ZUDOKU_XDG_STATE_HOME = path30.join(
|
|
9212
9271
|
XDG_STATE_HOME,
|
|
9213
9272
|
CLI_XDG_FOLDER_NAME
|
|
9214
9273
|
);
|
|
@@ -9257,7 +9316,7 @@ async function getVersionCheckInfo() {
|
|
|
9257
9316
|
let versionCheckInfo;
|
|
9258
9317
|
if (existsSync3(versionCheckPath)) {
|
|
9259
9318
|
try {
|
|
9260
|
-
versionCheckInfo = await
|
|
9319
|
+
versionCheckInfo = await readFile6(versionCheckPath, "utf-8").then(
|
|
9261
9320
|
JSON.parse
|
|
9262
9321
|
);
|
|
9263
9322
|
} catch {
|