@farming-labs/docs 0.2.120 → 0.2.121
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/README.md +8 -0
- package/dist/access.d.mts +13 -0
- package/dist/access.mjs +56 -0
- package/dist/agent-conformance.d.mts +60 -0
- package/dist/agent-conformance.mjs +538 -0
- package/dist/agent-contract.d.mts +47 -0
- package/dist/agent-contract.mjs +645 -0
- package/dist/agent-detection.d.mts +6 -0
- package/dist/agent-detection.mjs +83 -0
- package/dist/agent-evals.d.mts +224 -0
- package/dist/{agent-evals-BLNLvXbG.mjs → agent-evals.mjs} +7 -565
- package/dist/agent-feedback-evaluations-node.mjs +38 -0
- package/dist/agent-feedback-evaluations.d.mts +91 -0
- package/dist/{agent-feedback-evaluations-CcMGlgsO.mjs → agent-feedback-evaluations.mjs} +2 -2
- package/dist/agent-feedback-loop.d.mts +45 -0
- package/dist/{agent-feedback-loop-CcZL_sb1.mjs → agent-feedback-loop.mjs} +1 -1
- package/dist/agent-maintenance.d.mts +71 -0
- package/dist/{agent-maintenance-CuZ7iAKq.mjs → agent-maintenance.mjs} +1 -1
- package/dist/agent-provenance.d.mts +23 -0
- package/dist/agent-provenance.mjs +77 -0
- package/dist/agent-scope.mjs +321 -0
- package/dist/agent-skills-archive.mjs +86 -0
- package/dist/agent-skills-bundle.d.mts +1 -1
- package/dist/{agent-skills-progressive-disclosure-PjPtTYL-.mjs → agent-skills-progressive-disclosure.mjs} +2 -2
- package/dist/{agent-skills-server-D5IuvwM7.d.mts → agent-skills-server.d.mts} +3 -3
- package/dist/{agent-skills-server-BC7md56k.mjs → agent-skills-server.mjs} +2 -2
- package/dist/agent-skills-vite.d.mts +3 -3
- package/dist/agent-skills-vite.mjs +1 -2
- package/dist/agent-surface-drift.mjs +236 -0
- package/dist/{golden-evaluations-CLUViycJ.mjs → agent-usefulness.mjs} +5 -290
- package/dist/{content-change-hydration-wqXIZHp6.d.mts → agent.d.mts} +10 -411
- package/dist/agent.mjs +2729 -0
- package/dist/{analytics-w3FDOksr.d.mts → analytics.d.mts} +2 -2
- package/dist/{analytics-p8Vhhu2P.mjs → analytics.mjs} +2 -2
- package/dist/{sitemap-server-BUdPBcGs.d.mts → api-reference.d.mts} +2 -6
- package/dist/api-reference.mjs +1481 -0
- package/dist/{audience-exposure-DBrFWULA.d.mts → audience-exposure.d.mts} +1 -1
- package/dist/audience-exposure.mjs +8 -0
- package/dist/audience.d.mts +44 -0
- package/dist/audience.mjs +1654 -0
- package/dist/authoring-mcp.d.mts +44 -0
- package/dist/{authoring-mcp-CiCUQe3o.mjs → authoring-mcp.mjs} +3 -3
- package/dist/browser.d.mts +6 -4
- package/dist/browser.mjs +6 -7
- package/dist/build.d.mts +8 -0
- package/dist/build.mjs +8 -0
- package/dist/changelog.d.mts +20 -0
- package/dist/changelog.mjs +39 -0
- package/dist/{agent-export-CA6IUQ7T.mjs → cli/agent-export.mjs} +19 -45
- package/dist/{agent-CYk2DxY7.mjs → cli/agent.mjs} +6 -35
- package/dist/{agents-BUiVmj8i.mjs → cli/agents.mjs} +5 -18
- package/dist/cli/api-doctor.mjs +206 -0
- package/dist/{authoring-C2ymvYWl.mjs → cli/authoring.mjs} +2 -8
- package/dist/{cloud-6eKrlmKd.mjs → cli/cloud.mjs} +3 -3
- package/dist/{codeblocks-CHpgAwY-.mjs → cli/codeblocks.mjs} +2 -2
- package/dist/cli/config.d.mts +11 -0
- package/dist/{config-BZnKAj_Y.mjs → cli/config.mjs} +1 -1
- package/dist/cli/dev-banner.mjs +58 -0
- package/dist/{dev-Bnn-NUNa.mjs → cli/dev.mjs} +3 -57
- package/dist/{doctor-Bfkrkzad.mjs → cli/doctor.mjs} +41 -226
- package/dist/{downgrade-CHMta85e.mjs → cli/downgrade.mjs} +2 -2
- package/dist/cli/errors.d.mts +4 -0
- package/dist/{errors-BtnVLhNF.mjs → cli/errors.mjs} +1 -1
- package/dist/{feedback-evals-DMilg9pY.mjs → cli/feedback-evals.mjs} +3 -36
- package/dist/{feedback-DL4T5oIO.mjs → cli/feedback.mjs} +1 -1
- package/dist/cli/git-dates.mjs +35 -0
- package/dist/cli/golden-evaluations.mjs +52 -0
- package/dist/cli/index.d.mts +2 -3
- package/dist/cli/index.mjs +38 -38
- package/dist/{init-K0LmXDZ5.mjs → cli/init.mjs} +3 -3
- package/dist/{mcp-iLCmnPJI.mjs → cli/mcp.mjs} +7 -19
- package/dist/{openapi-diff-HcpUNjA-.mjs → cli/openapi-diff.mjs} +2 -7
- package/dist/{openapi-sdk-BQKC6H-_.mjs → cli/openapi-sdk.mjs} +2 -7
- package/dist/{openapi-source-DK6ts_Bk.mjs → cli/openapi-source.mjs} +2 -2
- package/dist/{package-version-HJhYeq4M.mjs → cli/package-version.mjs} +2 -2
- package/dist/{propose-JmUv_BTt.mjs → cli/propose.mjs} +1 -1
- package/dist/{review-C6EmbV0l.mjs → cli/review.mjs} +16 -15
- package/dist/{robots-DteZB8vl.mjs → cli/robots.mjs} +3 -7
- package/dist/{search-Bhuv_YsL.mjs → cli/search.mjs} +7 -20
- package/dist/{sitemap-DW5LDKDa.mjs → cli/sitemap.mjs} +7 -42
- package/dist/{skills-BAPQLSCm.mjs → cli/skills.mjs} +5 -19
- package/dist/{templates-BuQ8YsGv.mjs → cli/templates.mjs} +1 -1
- package/dist/{upgrade-DlQMOFV1.mjs → cli/upgrade.mjs} +2 -2
- package/dist/{utils-C7KDrPpA.mjs → cli/utils.mjs} +1 -1
- package/dist/client/react.d.mts +2 -18
- package/dist/client/react.mjs +1 -157
- package/dist/{cloud-analytics-D14HplI7.mjs → cloud-analytics.mjs} +1 -1
- package/dist/{cloud-ask-ai-BrsTXQf6.d.mts → cloud-ask-ai.d.mts} +2 -2
- package/dist/{cloud-ask-ai-BqKhjpS5.mjs → cloud-ask-ai.mjs} +3 -3
- package/dist/code-blocks.d.mts +51 -0
- package/dist/{code-blocks-GYdvS3BH.mjs → code-blocks.mjs} +2 -2
- package/dist/code-group-mdx.d.mts +11 -0
- package/dist/code-group-mdx.mjs +57 -0
- package/dist/content-change-hydration.d.mts +87 -0
- package/dist/{openapi-mcp-BIOTLiA7.mjs → content-change-hydration.mjs} +5 -210
- package/dist/content-changes.d.mts +47 -0
- package/dist/content-changes.mjs +216 -0
- package/dist/create-theme.d.mts +48 -0
- package/dist/create-theme.mjs +57 -0
- package/dist/date.d.mts +5 -0
- package/dist/date.mjs +17 -0
- package/dist/define-docs.d.mts +9 -0
- package/dist/define-docs.mjs +46 -0
- package/dist/docs-cloud-client.d.mts +18 -0
- package/dist/docs-cloud-client.mjs +161 -0
- package/dist/docs-cloud-server.d.mts +2 -2
- package/dist/docs-cloud-server.mjs +2 -3
- package/dist/heading-toc.d.mts +10 -0
- package/dist/heading-toc.mjs +23 -0
- package/dist/http-body.d.mts +14 -0
- package/dist/{http-body-DkAPk6D5.mjs → http-body.mjs} +1 -1
- package/dist/http-cache.d.mts +25 -0
- package/dist/http-cache.mjs +140 -0
- package/dist/http-link.mjs +81 -0
- package/dist/i18n.d.mts +18 -0
- package/dist/{i18n-B1gJ9EW0.mjs → i18n.mjs} +1 -1
- package/dist/index.d.mts +42 -674
- package/dist/index.mjs +40 -14
- package/dist/markdown-rendering.mjs +1 -1
- package/dist/markdown-section-cache.mjs +49 -0
- package/dist/markdown-sections.d.mts +47 -0
- package/dist/{markdown-sections-9Oxr33b-.mjs → markdown-sections.mjs} +29 -703
- package/dist/mcp-auth.d.mts +14 -0
- package/dist/mcp-auth.mjs +99 -0
- package/dist/mcp.d.mts +5 -3
- package/dist/mcp.mjs +21 -9
- package/dist/mdx.d.mts +6 -0
- package/dist/mdx.mjs +7 -0
- package/dist/metadata.d.mts +60 -0
- package/dist/{metadata-BOHn0Y5K.mjs → metadata.mjs} +2 -2
- package/dist/native-api-reference.mjs +968 -0
- package/dist/okf.d.mts +42 -0
- package/dist/okf.mjs +145 -0
- package/dist/openapi-contract.mjs +154 -0
- package/dist/{openapi-mcp-node-C4jUpZG6.mjs → openapi-mcp-node.mjs} +1 -1
- package/dist/openapi-mcp.d.mts +26 -0
- package/dist/openapi-mcp.mjs +132 -0
- package/dist/openapi-operations.d.mts +71 -0
- package/dist/{openapi-operations-DFpaqOqA.mjs → openapi-operations.mjs} +1 -1
- package/dist/openapi-overlays.mjs +221 -0
- package/dist/openapi-references.mjs +233 -0
- package/dist/pagination.d.mts +7 -0
- package/dist/pagination.mjs +100 -0
- package/dist/prompt-references.d.mts +12 -0
- package/dist/prompt-references.mjs +132 -0
- package/dist/prompt-utils.d.mts +36 -0
- package/dist/{prompt-utils-B5g-bv7o.mjs → prompt-utils.mjs} +1 -57
- package/dist/reading-time.d.mts +23 -0
- package/dist/reading-time.mjs +58 -0
- package/dist/related.d.mts +7 -0
- package/dist/related.mjs +50 -0
- package/dist/retrieval-digest.d.mts +16 -0
- package/dist/{retrieval-digest-CT-eIEcp.mjs → retrieval-digest.mjs} +1 -1
- package/dist/review.d.mts +69 -0
- package/dist/review.mjs +562 -0
- package/dist/robots.d.mts +54 -0
- package/dist/{robots-BYJAVeI6.mjs → robots.mjs} +5 -3
- package/dist/runtime.d.mts +3 -3
- package/dist/runtime.mjs +3 -9
- package/dist/search.d.mts +210 -0
- package/dist/search.mjs +3401 -0
- package/dist/server.d.mts +22 -198
- package/dist/server.mjs +21 -19
- package/dist/sidebar.d.mts +15 -0
- package/dist/sidebar.mjs +73 -0
- package/dist/sitemap-server.d.mts +7 -0
- package/dist/{sitemap-server-Lg3YhUx4.mjs → sitemap-server.mjs} +2 -2
- package/dist/{sitemap-Cl8vrixd.d.mts → sitemap.d.mts} +3 -3
- package/dist/sitemap.mjs +254 -0
- package/dist/{standards-discovery-BHPc7YIX.d.mts → standards-discovery.d.mts} +2 -2
- package/dist/{standards-discovery-sSEojU80.mjs → standards-discovery.mjs} +3 -139
- package/dist/telemetry-runtime.d.mts +42 -0
- package/dist/telemetry-runtime.mjs +238 -0
- package/dist/telemetry.d.mts +15 -0
- package/dist/telemetry.mjs +117 -0
- package/dist/{types-BJFeMXWZ.d.mts → types.d.mts} +3 -2
- package/dist/urls.d.mts +7 -0
- package/dist/urls.mjs +21 -0
- package/dist/utils.d.mts +8 -0
- package/dist/utils.mjs +22 -0
- package/package.json +21 -3
- package/dist/agent-DkAidqtV.mjs +0 -9026
- package/dist/api-reference-BYee4zMo.mjs +0 -3046
- package/dist/prompt-references-DMgbu_dz.mjs +0 -1082
- package/dist/retrieval-digest-AOx2-LbC.d.mts +0 -367
- package/dist/sidebar-CFHBj29f.mjs +0 -421
- package/dist/sidebar-CMPbVfGP.d.mts +0 -63
- /package/dist/{openapi-CfCzX_a1.mjs → cli/openapi.mjs} +0 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
//#region src/telemetry-runtime.ts
|
|
2
|
+
const DOCS_PACKAGE_NAME = "@farming-labs/docs";
|
|
3
|
+
const DOCS_PACKAGE_VERSION = "0.2.25";
|
|
4
|
+
const DEFAULT_DOCS_TELEMETRY_ENDPOINT = "https://docs.farming-labs.dev/api/telemetry/events";
|
|
5
|
+
function getRuntimeEnv() {
|
|
6
|
+
if (typeof process === "undefined" || !process.env) return;
|
|
7
|
+
return process.env;
|
|
8
|
+
}
|
|
9
|
+
function readRuntimeEnv(name) {
|
|
10
|
+
const value = getRuntimeEnv()?.[name]?.trim();
|
|
11
|
+
return value ? value : void 0;
|
|
12
|
+
}
|
|
13
|
+
function isTruthyEnv(value) {
|
|
14
|
+
return /^(1|true|yes|on)$/i.test(value ?? "");
|
|
15
|
+
}
|
|
16
|
+
function isFalsyEnv(value) {
|
|
17
|
+
return /^(0|false|no|off)$/i.test(value ?? "");
|
|
18
|
+
}
|
|
19
|
+
function isBrowserRuntime() {
|
|
20
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
21
|
+
}
|
|
22
|
+
function isProductionTelemetryRuntime() {
|
|
23
|
+
if (isBrowserRuntime()) return false;
|
|
24
|
+
const env = getRuntimeEnv();
|
|
25
|
+
if (!env) return true;
|
|
26
|
+
if (env.NODE_ENV === "test") return false;
|
|
27
|
+
if (env.VERCEL_ENV === "production") return true;
|
|
28
|
+
if (env.CONTEXT === "production" && isTruthyEnv(env.NETLIFY)) return true;
|
|
29
|
+
if (isTruthyEnv(env.CF_PAGES)) return true;
|
|
30
|
+
if (env.RENDER_SERVICE_ID || env.FLY_APP_NAME || env.RAILWAY_ENVIRONMENT) return true;
|
|
31
|
+
return env.NODE_ENV === "production";
|
|
32
|
+
}
|
|
33
|
+
function resolveDocsTelemetryConfig(telemetry) {
|
|
34
|
+
const envToggle = readRuntimeEnv("DOCS_TELEMETRY");
|
|
35
|
+
const envDisabled = readRuntimeEnv("DOCS_TELEMETRY_DISABLED");
|
|
36
|
+
if (isFalsyEnv(envToggle) || isTruthyEnv(envDisabled) || telemetry === false) return { enabled: false };
|
|
37
|
+
const objectConfig = telemetry && typeof telemetry === "object" ? telemetry : void 0;
|
|
38
|
+
if (objectConfig?.enabled === false) return { enabled: false };
|
|
39
|
+
return {
|
|
40
|
+
enabled: telemetry === true || objectConfig?.enabled === true || isTruthyEnv(envToggle) || isProductionTelemetryRuntime(),
|
|
41
|
+
endpoint: objectConfig?.endpoint?.trim() || readRuntimeEnv("DOCS_TELEMETRY_ENDPOINT") || DEFAULT_DOCS_TELEMETRY_ENDPOINT
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function readRequestOrigin(request) {
|
|
45
|
+
if (!request?.url) return void 0;
|
|
46
|
+
try {
|
|
47
|
+
return new URL(request.url).origin;
|
|
48
|
+
} catch {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Normalize an HTTP(S) telemetry site value to its origin. */
|
|
53
|
+
function normalizeDocsTelemetryOrigin(candidate) {
|
|
54
|
+
if (typeof candidate !== "string") return void 0;
|
|
55
|
+
const trimmed = candidate.trim();
|
|
56
|
+
if (!trimmed) return void 0;
|
|
57
|
+
try {
|
|
58
|
+
const hasScheme = /^[a-z][a-z\d+.-]*:(?!\d)/i.test(trimmed);
|
|
59
|
+
const url = new URL(hasScheme ? trimmed : `https://${trimmed}`);
|
|
60
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return void 0;
|
|
61
|
+
return url.origin;
|
|
62
|
+
} catch {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Return whether a telemetry origin points at a local development server. */
|
|
67
|
+
function isLocalDocsTelemetryOrigin(candidate) {
|
|
68
|
+
const origin = normalizeDocsTelemetryOrigin(candidate);
|
|
69
|
+
if (!origin) return false;
|
|
70
|
+
const hostname = new URL(origin).hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.+$/, "");
|
|
71
|
+
if ([
|
|
72
|
+
"localhost",
|
|
73
|
+
"localhost.localdomain",
|
|
74
|
+
"localhost6",
|
|
75
|
+
"localhost6.localdomain6",
|
|
76
|
+
"ip6-localhost",
|
|
77
|
+
"ip6-loopback"
|
|
78
|
+
].includes(hostname) || hostname.endsWith(".localhost")) return true;
|
|
79
|
+
if (hostname === "::" || hostname === "::1") return true;
|
|
80
|
+
const ipv4 = hostname.split(".").map((part) => Number(part));
|
|
81
|
+
if (ipv4.length === 4 && ipv4.every((part) => Number.isInteger(part) && part >= 0 && part <= 255)) return ipv4[0] === 127 || ipv4.every((part) => part === 0);
|
|
82
|
+
return /^::ffff:7f[0-9a-f]{2}:/.test(hostname) || hostname === "::ffff:0:0";
|
|
83
|
+
}
|
|
84
|
+
function isBlockedDocsTelemetryOrigin(candidate) {
|
|
85
|
+
if (candidate === void 0) return false;
|
|
86
|
+
return !normalizeDocsTelemetryOrigin(candidate) || isLocalDocsTelemetryOrigin(candidate);
|
|
87
|
+
}
|
|
88
|
+
function readDeploymentOrigin() {
|
|
89
|
+
const candidates = [
|
|
90
|
+
readRuntimeEnv("DOCS_SITE_URL"),
|
|
91
|
+
readRuntimeEnv("NEXT_PUBLIC_BASE_URL"),
|
|
92
|
+
readRuntimeEnv("NEXT_PUBLIC_SITE_URL"),
|
|
93
|
+
readRuntimeEnv("SITE_URL"),
|
|
94
|
+
readRuntimeEnv("URL"),
|
|
95
|
+
readRuntimeEnv("CF_PAGES_URL"),
|
|
96
|
+
readRuntimeEnv("VERCEL_PROJECT_PRODUCTION_URL"),
|
|
97
|
+
readRuntimeEnv("VERCEL_URL"),
|
|
98
|
+
readRuntimeEnv("DEPLOY_PRIME_URL")
|
|
99
|
+
];
|
|
100
|
+
for (const candidate of candidates) {
|
|
101
|
+
const origin = normalizeDocsTelemetryOrigin(candidate);
|
|
102
|
+
if (origin) return origin;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function detectDeployment() {
|
|
106
|
+
const env = getRuntimeEnv();
|
|
107
|
+
if (!env) return void 0;
|
|
108
|
+
if (env.VERCEL || env.VERCEL_ENV) return {
|
|
109
|
+
provider: "vercel",
|
|
110
|
+
environment: env.VERCEL_ENV,
|
|
111
|
+
id: env.VERCEL_DEPLOYMENT_ID ?? env.VERCEL_GIT_COMMIT_SHA,
|
|
112
|
+
region: env.VERCEL_REGION
|
|
113
|
+
};
|
|
114
|
+
if (env.NETLIFY) return {
|
|
115
|
+
provider: "netlify",
|
|
116
|
+
environment: env.CONTEXT,
|
|
117
|
+
id: env.DEPLOY_ID ?? env.COMMIT_REF
|
|
118
|
+
};
|
|
119
|
+
if (env.CF_PAGES) return {
|
|
120
|
+
provider: "cloudflare-pages",
|
|
121
|
+
environment: env.CF_PAGES_BRANCH,
|
|
122
|
+
id: env.CF_PAGES_COMMIT_SHA
|
|
123
|
+
};
|
|
124
|
+
if (env.RENDER_SERVICE_ID) return {
|
|
125
|
+
provider: "render",
|
|
126
|
+
environment: env.RENDER_ENV,
|
|
127
|
+
id: env.RENDER_SERVICE_ID
|
|
128
|
+
};
|
|
129
|
+
if (env.FLY_APP_NAME) return {
|
|
130
|
+
provider: "fly",
|
|
131
|
+
environment: env.FLY_APP_NAME,
|
|
132
|
+
id: env.FLY_ALLOC_ID,
|
|
133
|
+
region: env.FLY_REGION
|
|
134
|
+
};
|
|
135
|
+
if (env.RAILWAY_ENVIRONMENT) return {
|
|
136
|
+
provider: "railway",
|
|
137
|
+
environment: env.RAILWAY_ENVIRONMENT,
|
|
138
|
+
id: env.RAILWAY_DEPLOYMENT_ID
|
|
139
|
+
};
|
|
140
|
+
return env.NODE_ENV === "production" ? { environment: "production" } : void 0;
|
|
141
|
+
}
|
|
142
|
+
function detectRuntime() {
|
|
143
|
+
if (typeof process !== "undefined" && process.versions?.node) return {
|
|
144
|
+
name: "node",
|
|
145
|
+
version: process.versions.node
|
|
146
|
+
};
|
|
147
|
+
if (typeof navigator !== "undefined" && navigator.userAgent) return { name: "web-standard" };
|
|
148
|
+
}
|
|
149
|
+
function createDocsTelemetryEvent(config, input, context = {}, resolveFeatures) {
|
|
150
|
+
const telemetryConfig = config.telemetry && typeof config.telemetry === "object" ? config.telemetry : void 0;
|
|
151
|
+
const siteOriginCandidates = [
|
|
152
|
+
context.siteOrigin,
|
|
153
|
+
input.site?.origin,
|
|
154
|
+
telemetryConfig?.siteOrigin,
|
|
155
|
+
readRequestOrigin(context.request),
|
|
156
|
+
readDeploymentOrigin()
|
|
157
|
+
];
|
|
158
|
+
if (siteOriginCandidates.some(isBlockedDocsTelemetryOrigin)) return void 0;
|
|
159
|
+
const siteOrigin = siteOriginCandidates.map(normalizeDocsTelemetryOrigin).find((origin) => Boolean(origin));
|
|
160
|
+
const deployment = input.deployment ?? detectDeployment();
|
|
161
|
+
const properties = context.properties || input.properties ? {
|
|
162
|
+
...input.properties,
|
|
163
|
+
...context.properties
|
|
164
|
+
} : void 0;
|
|
165
|
+
return {
|
|
166
|
+
...input,
|
|
167
|
+
timestamp: input.timestamp ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
168
|
+
package: {
|
|
169
|
+
name: DOCS_PACKAGE_NAME,
|
|
170
|
+
version: DOCS_PACKAGE_VERSION,
|
|
171
|
+
...input.package
|
|
172
|
+
},
|
|
173
|
+
framework: input.framework ?? context.framework,
|
|
174
|
+
runtime: input.runtime ?? detectRuntime(),
|
|
175
|
+
site: siteOrigin ? { origin: siteOrigin } : input.site,
|
|
176
|
+
deployment,
|
|
177
|
+
features: input.features ?? resolveFeatures?.() ?? {},
|
|
178
|
+
properties
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async function emitDocsTelemetryEvent(telemetry, event) {
|
|
182
|
+
const resolved = resolveDocsTelemetryConfig(telemetry);
|
|
183
|
+
const eventSiteOrigin = event.site?.origin;
|
|
184
|
+
const normalizedSiteOrigin = normalizeDocsTelemetryOrigin(eventSiteOrigin);
|
|
185
|
+
if (!resolved.enabled || !resolved.endpoint || typeof fetch !== "function" || eventSiteOrigin !== void 0 && (!normalizedSiteOrigin || isLocalDocsTelemetryOrigin(eventSiteOrigin))) return;
|
|
186
|
+
const eventToSend = normalizedSiteOrigin ? {
|
|
187
|
+
...event,
|
|
188
|
+
site: { origin: normalizedSiteOrigin }
|
|
189
|
+
} : event;
|
|
190
|
+
try {
|
|
191
|
+
const ingestKey = readRuntimeEnv("DOCS_TELEMETRY_INGEST_KEY");
|
|
192
|
+
const browserRequest = isBrowserRuntime() && !ingestKey;
|
|
193
|
+
const headers = { "content-type": browserRequest ? "text/plain;charset=UTF-8" : "application/json" };
|
|
194
|
+
if (ingestKey) headers["x-docs-telemetry-key"] = ingestKey;
|
|
195
|
+
await fetch(resolved.endpoint, {
|
|
196
|
+
method: "POST",
|
|
197
|
+
headers,
|
|
198
|
+
body: JSON.stringify({ event: eventToSend }),
|
|
199
|
+
keepalive: true,
|
|
200
|
+
...browserRequest ? {
|
|
201
|
+
credentials: "omit",
|
|
202
|
+
mode: "no-cors"
|
|
203
|
+
} : {}
|
|
204
|
+
});
|
|
205
|
+
} catch {}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Emit a privacy-preserving browser page view for the maintainer telemetry dashboard.
|
|
209
|
+
*
|
|
210
|
+
* Page views include only the public site origin, pathname, locale, framework, and package
|
|
211
|
+
* metadata. They never include a query string, referrer, visitor id, IP address, or user agent.
|
|
212
|
+
*/
|
|
213
|
+
function emitDocsTelemetryPageViewEvent(telemetry, context = {}) {
|
|
214
|
+
if (telemetry === false || telemetry && typeof telemetry === "object" && telemetry.enabled === false) return;
|
|
215
|
+
const runtimeSiteOrigin = context.siteOrigin ?? (typeof window !== "undefined" ? window.location?.origin : void 0);
|
|
216
|
+
if (isBlockedDocsTelemetryOrigin(runtimeSiteOrigin)) return;
|
|
217
|
+
const siteOrigin = (telemetry && typeof telemetry === "object" ? telemetry.siteOrigin : void 0) ?? runtimeSiteOrigin;
|
|
218
|
+
const event = createDocsTelemetryEvent({ telemetry }, {
|
|
219
|
+
type: "page_view",
|
|
220
|
+
features: {},
|
|
221
|
+
properties: {
|
|
222
|
+
trafficType: "human",
|
|
223
|
+
...context.path ? { path: context.path.slice(0, 2048) } : {},
|
|
224
|
+
...context.locale ? { locale: context.locale.slice(0, 80) } : {}
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
framework: context.framework,
|
|
228
|
+
siteOrigin
|
|
229
|
+
});
|
|
230
|
+
if (!event) return;
|
|
231
|
+
emitDocsTelemetryEvent(telemetry && typeof telemetry === "object" ? {
|
|
232
|
+
...telemetry,
|
|
233
|
+
enabled: true
|
|
234
|
+
} : true, event);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
//#endregion
|
|
238
|
+
export { createDocsTelemetryEvent, emitDocsTelemetryEvent, emitDocsTelemetryPageViewEvent, isLocalDocsTelemetryOrigin, normalizeDocsTelemetryOrigin, resolveDocsTelemetryConfig };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DocsConfig, DocsTelemetryAgentSurface, DocsTelemetryFeatures } from "./types.mjs";
|
|
2
|
+
import { DocsTelemetryAgentSurfaceContext, DocsTelemetryAgentSurfaceRequestOptions, DocsTelemetryContext, DocsTelemetryPageViewContext, ResolvedDocsTelemetryConfig, emitDocsTelemetryEvent, emitDocsTelemetryPageViewEvent, isLocalDocsTelemetryOrigin, normalizeDocsTelemetryOrigin, resolveDocsTelemetryConfig } from "./telemetry-runtime.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/telemetry.d.ts
|
|
5
|
+
declare function getDocsTelemetryFeatures(config: Partial<DocsConfig>): DocsTelemetryFeatures;
|
|
6
|
+
declare function emitDocsTelemetryProjectEvent(config: Partial<DocsConfig>, context?: DocsTelemetryContext): void;
|
|
7
|
+
declare function emitDocsTelemetryAgentSurfaceEvent(config: Partial<DocsConfig>, context: DocsTelemetryAgentSurfaceContext): void;
|
|
8
|
+
declare function emitDocsTelemetryMcpToolEvent(config: Partial<DocsConfig>, context: DocsTelemetryContext & {
|
|
9
|
+
tool: string;
|
|
10
|
+
locale?: string;
|
|
11
|
+
resultCount?: number;
|
|
12
|
+
}): void;
|
|
13
|
+
declare function inferDocsTelemetryAgentSurface(request: Request, options: DocsTelemetryAgentSurfaceRequestOptions): DocsTelemetryAgentSurface | undefined;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryMcpToolEvent, emitDocsTelemetryProjectEvent, getDocsTelemetryFeatures, inferDocsTelemetryAgentSurface };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { isDocsContentChangesRequest, resolveDocsContentChangesConfig } from "./content-changes.mjs";
|
|
2
|
+
import { isDocsAgentDiscoveryRequest, isDocsAgentsRequest, isDocsSkillRequest, resolveDocsAgentFeedbackConfig, resolveDocsAgentFeedbackRequest, resolveDocsAgentsFormat, resolveDocsLlmsTxtRequest, resolveDocsMarkdownRequest, resolveDocsSkillFormat } from "./agent.mjs";
|
|
3
|
+
import { createDocsTelemetryEvent, emitDocsTelemetryEvent, emitDocsTelemetryPageViewEvent, isLocalDocsTelemetryOrigin, normalizeDocsTelemetryOrigin, resolveDocsTelemetryConfig } from "./telemetry-runtime.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/telemetry.ts
|
|
6
|
+
const PROJECT_TELEMETRY_CACHE_TTL_MS = 1440 * 60 * 1e3;
|
|
7
|
+
const PROJECT_TELEMETRY_CACHE_MAX_KEYS = 256;
|
|
8
|
+
function isObjectConfigEnabled(value, defaultEnabled) {
|
|
9
|
+
if (value === false) return false;
|
|
10
|
+
if (value === true) return true;
|
|
11
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
12
|
+
const enabled = value.enabled;
|
|
13
|
+
return enabled === false ? false : defaultEnabled || enabled === true;
|
|
14
|
+
}
|
|
15
|
+
return defaultEnabled;
|
|
16
|
+
}
|
|
17
|
+
function hasObjectConfig(value) {
|
|
18
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
19
|
+
}
|
|
20
|
+
function getDocsTelemetryFeatures(config) {
|
|
21
|
+
const pageActions = config.pageActions;
|
|
22
|
+
const feedback = config.feedback;
|
|
23
|
+
return {
|
|
24
|
+
search: isObjectConfigEnabled(config.search, true),
|
|
25
|
+
contentChanges: resolveDocsContentChangesConfig(config.agent?.contentChanges, { staticExport: config.staticExport === true }).enabled,
|
|
26
|
+
ai: isObjectConfigEnabled(config.ai, false),
|
|
27
|
+
mcp: isObjectConfigEnabled(config.mcp, true),
|
|
28
|
+
llmsTxt: isObjectConfigEnabled(config.llmsTxt, true),
|
|
29
|
+
pageActions: hasObjectConfig(pageActions),
|
|
30
|
+
feedback: feedback === true || hasObjectConfig(feedback) && feedback.enabled !== false,
|
|
31
|
+
agentFeedback: feedback !== false && !(hasObjectConfig(feedback) && feedback.agent === false) && !(hasObjectConfig(feedback) && hasObjectConfig(feedback.agent) && feedback.agent.enabled === false),
|
|
32
|
+
sitemap: isObjectConfigEnabled(config.sitemap, true),
|
|
33
|
+
robots: isObjectConfigEnabled(config.robots, true),
|
|
34
|
+
apiReference: isObjectConfigEnabled(config.apiReference, false),
|
|
35
|
+
staticExport: config.staticExport === true,
|
|
36
|
+
changelog: isObjectConfigEnabled(config.changelog, false),
|
|
37
|
+
cloud: typeof config.cloud !== "undefined" && isObjectConfigEnabled(config.cloud, true),
|
|
38
|
+
review: isObjectConfigEnabled(config.review, true),
|
|
39
|
+
codeBlocksValidate: hasObjectConfig(config.codeBlocks) && Boolean(config.codeBlocks.validate)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function projectEventKey(event) {
|
|
43
|
+
return [
|
|
44
|
+
event.package.name,
|
|
45
|
+
event.package.version,
|
|
46
|
+
event.framework ?? "",
|
|
47
|
+
event.site?.origin ?? "",
|
|
48
|
+
event.deployment?.provider ?? "",
|
|
49
|
+
event.deployment?.environment ?? "",
|
|
50
|
+
event.deployment?.id ?? ""
|
|
51
|
+
].join("|");
|
|
52
|
+
}
|
|
53
|
+
function getSentProjectKeys() {
|
|
54
|
+
const globalValue = globalThis;
|
|
55
|
+
globalValue.__farmingLabsDocsTelemetryProjectKeys__ ??= /* @__PURE__ */ new Map();
|
|
56
|
+
return globalValue.__farmingLabsDocsTelemetryProjectKeys__;
|
|
57
|
+
}
|
|
58
|
+
function pruneSentProjectKeys(sent, now) {
|
|
59
|
+
for (const [key, expiresAt] of sent) if (expiresAt <= now) sent.delete(key);
|
|
60
|
+
while (sent.size >= PROJECT_TELEMETRY_CACHE_MAX_KEYS) {
|
|
61
|
+
const oldestKey = sent.keys().next().value;
|
|
62
|
+
if (!oldestKey) return;
|
|
63
|
+
sent.delete(oldestKey);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function emitDocsTelemetryProjectEvent(config, context = {}) {
|
|
67
|
+
const event = createDocsTelemetryEvent(config, { type: "project_detected" }, context, () => getDocsTelemetryFeatures(config));
|
|
68
|
+
if (!event) return;
|
|
69
|
+
const key = projectEventKey(event);
|
|
70
|
+
const sent = getSentProjectKeys();
|
|
71
|
+
const now = Date.now();
|
|
72
|
+
const expiresAt = sent.get(key);
|
|
73
|
+
if (expiresAt && expiresAt > now) return;
|
|
74
|
+
if (typeof expiresAt === "number") sent.delete(key);
|
|
75
|
+
pruneSentProjectKeys(sent, now);
|
|
76
|
+
sent.set(key, now + PROJECT_TELEMETRY_CACHE_TTL_MS);
|
|
77
|
+
emitDocsTelemetryEvent(config.telemetry, event);
|
|
78
|
+
}
|
|
79
|
+
function emitDocsTelemetryAgentSurfaceEvent(config, context) {
|
|
80
|
+
const event = createDocsTelemetryEvent(config, {
|
|
81
|
+
type: context.surface === "mcp" ? "mcp_request" : "agent_surface_used",
|
|
82
|
+
properties: { surface: context.surface }
|
|
83
|
+
}, context, () => getDocsTelemetryFeatures(config));
|
|
84
|
+
if (!event) return;
|
|
85
|
+
emitDocsTelemetryEvent(config.telemetry, event);
|
|
86
|
+
}
|
|
87
|
+
function emitDocsTelemetryMcpToolEvent(config, context) {
|
|
88
|
+
const event = createDocsTelemetryEvent(config, {
|
|
89
|
+
type: "mcp_tool_used",
|
|
90
|
+
properties: {
|
|
91
|
+
tool: context.tool,
|
|
92
|
+
locale: context.locale,
|
|
93
|
+
resultCount: context.resultCount
|
|
94
|
+
}
|
|
95
|
+
}, context, () => getDocsTelemetryFeatures(config));
|
|
96
|
+
if (!event) return;
|
|
97
|
+
emitDocsTelemetryEvent(config.telemetry, event);
|
|
98
|
+
}
|
|
99
|
+
function inferDocsTelemetryAgentSurface(request, options) {
|
|
100
|
+
const url = new URL(request.url);
|
|
101
|
+
const method = request.method.toUpperCase();
|
|
102
|
+
const feedbackRequest = resolveDocsAgentFeedbackRequest(url, resolveDocsAgentFeedbackConfig(options.feedback));
|
|
103
|
+
if ((method === "GET" || method === "HEAD") && isDocsAgentDiscoveryRequest(url)) return "agent_spec";
|
|
104
|
+
if ((method === "GET" || method === "HEAD") && feedbackRequest?.kind === "schema") return "agent_feedback_schema";
|
|
105
|
+
if (method === "POST" && feedbackRequest?.kind === "submit") return "agent_feedback_submit";
|
|
106
|
+
if (method === "GET" || method === "HEAD") {
|
|
107
|
+
if (isDocsContentChangesRequest(url)) return "content_changes";
|
|
108
|
+
if (isDocsAgentsRequest(url) || resolveDocsAgentsFormat(url) === "agents") return "agents";
|
|
109
|
+
if (isDocsSkillRequest(url) || resolveDocsSkillFormat(url) === "skill") return "skill";
|
|
110
|
+
if (resolveDocsMarkdownRequest(options.entry, url, request)) return "markdown";
|
|
111
|
+
if (resolveDocsLlmsTxtRequest(url, options.llmsTxt, options.entry)) return "llms";
|
|
112
|
+
}
|
|
113
|
+
if (method === "POST") return "ask_ai";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
export { emitDocsTelemetryAgentSurfaceEvent, emitDocsTelemetryMcpToolEvent, emitDocsTelemetryProjectEvent, getDocsTelemetryFeatures, inferDocsTelemetryAgentSurface };
|
|
@@ -1960,7 +1960,8 @@ type ReadingTimeFormat = "long" | "short";
|
|
|
1960
1960
|
interface ReadingTimeConfig {
|
|
1961
1961
|
/**
|
|
1962
1962
|
* Whether to show the estimated reading time.
|
|
1963
|
-
*
|
|
1963
|
+
* This must be set to `true` to opt in when using an options object.
|
|
1964
|
+
* @default false
|
|
1964
1965
|
*/
|
|
1965
1966
|
enabled?: boolean;
|
|
1966
1967
|
/**
|
|
@@ -4192,4 +4193,4 @@ interface DocsConfig {
|
|
|
4192
4193
|
og?: OGConfig;
|
|
4193
4194
|
}
|
|
4194
4195
|
//#endregion
|
|
4195
|
-
export {
|
|
4196
|
+
export { AIConfig, AgentFeedbackConfig, AlgoliaDocsSearchConfig, ApiReferenceConfig, ApiReferenceRenderer, ApiReferenceRendererConfig, ApiReferenceRendererInput, ApiReferenceVersionConfig, BreadcrumbConfig, ChangelogConfig, ChangelogFrontmatter, CodeBlockCopyData, CopyMarkdownConfig, CopyMarkdownFormat, CustomDocsSearchConfig, DocsAccessClaimValue, DocsAccessPrincipal, DocsAgentA2AApiKeySecurityScheme, DocsAgentA2ACapabilities, DocsAgentA2AConfig, DocsAgentA2AExtension, DocsAgentA2AHttpAuthSecurityScheme, DocsAgentA2AInterfaceConfig, DocsAgentA2AMutualTlsSecurityScheme, DocsAgentA2AOAuth2SecurityScheme, DocsAgentA2AOAuthAuthorizationCodeFlow, DocsAgentA2AOAuthClientCredentialsFlow, DocsAgentA2AOAuthDeviceCodeFlow, DocsAgentA2AOAuthFlows, DocsAgentA2AOAuthImplicitFlow, DocsAgentA2AOAuthPasswordFlow, DocsAgentA2AOpenIdConnectSecurityScheme, DocsAgentA2AProtocolBinding, DocsAgentA2ASecurityRequirement, DocsAgentA2ASecurityScheme, DocsAgentA2ASecurityScopeList, DocsAgentA2ASkill, DocsAgentCompactConfig, DocsAgentConfig, DocsAgentContentChangesConfig, DocsAgentEvaluationAnswerInput, DocsAgentEvaluationAnswerProvider, DocsAgentEvaluationAnswerRequest, DocsAgentEvaluationAnswerResult, DocsAgentEvaluationAnswerRunner, DocsAgentEvaluationSourceReference, DocsAgentEvaluationSurface, DocsAgentEvaluationTaskInput, DocsAgentEvaluationsConfig, DocsAgentFeedbackContext, DocsAgentFeedbackData, DocsAgentGoldenAnswerExpectation, DocsAgentGoldenAuthenticatedContentExpectation, DocsAgentGoldenCoverageApplicability, DocsAgentGoldenExampleVerification, DocsAgentGoldenExpectedExample, DocsAgentGoldenFreshnessExpectation, DocsAgentGoldenPromptInjectionExpectation, DocsAgentGoldenQueryVariant, DocsAgentGoldenQueryVariantKind, DocsAgentGoldenSafetyExpectation, DocsAgentGoldenTask, DocsAgentGoldenTaskExpectation, DocsAgentGoldenTaskFilters, DocsAgentSkillsCompatibilityPolicy, DocsAgentSkillsConfig, DocsAgentSkillsInput, DocsAgentSkillsProgressiveDisclosureConfig, DocsAgentTraceEventInput, DocsAgentTraceEventType, DocsAgentTraceStatus, DocsAnalyticsConfig, DocsAnalyticsEvent, DocsAnalyticsEventInput, DocsAnalyticsEventType, DocsAnalyticsInput, DocsAnalyticsSource, DocsAskAIActionData, DocsAskAIActionType, DocsAskAIFeedbackConfig, DocsAskAIFeedbackData, DocsAskAIFeedbackMessage, DocsAskAIFeedbackValue, DocsAskAIMcpConfig, DocsCloudApiKeyConfig, DocsCloudConfig, DocsCloudFeatureConfig, DocsCloudPreviewConfig, DocsCloudPublishConfig, DocsCodeBlocksConfig, DocsCodeBlocksPlannerConfig, DocsCodeBlocksPlannerProvider, DocsCodeBlocksRunnerConfig, DocsCodeBlocksRunnerProvider, DocsCodeBlocksValidateConfig, DocsCodeBlocksValidationMode, DocsCodeBlocksValidationPolicy, DocsConfig, DocsContentChangeDocument, DocsContentChangeSnapshotContext, DocsContentChangeSnapshotLoader, DocsContentChangeSnapshotSaver, DocsContentChangedDocument, DocsContentChangesResponse, DocsContentSnapshot, DocsContentSnapshotDocument, DocsFeedbackData, DocsFeedbackValue, DocsI18nConfig, DocsMcpAllowedOrigins, DocsMcpAuthPrincipal, DocsMcpAuthenticate, DocsMcpAuthenticateContext, DocsMcpAuthenticateResult, DocsMcpConfig, DocsMcpCorsConfig, DocsMcpOriginContext, DocsMcpPromptsConfig, DocsMcpProtectedResourceConfig, DocsMcpSecurityConfig, DocsMcpToolsConfig, DocsMetadata, DocsNav, DocsObservabilityConfig, DocsObservabilityEvent, DocsObservabilityEventInput, DocsOkfActorTimestamp, DocsOkfConfig, DocsOkfSource, DocsOkfStatus, DocsOkfTrustMetadata, DocsOkfTrustMetadataInput, DocsOkfTrustTier, DocsOpenApiMcpConfig, DocsOpenApiMcpCredentialContext, DocsOpenApiMcpHeaders, DocsPageAccessPolicy, DocsPaginatedSearchResponse, DocsRelatedItem, DocsRetrievalSourceProvenance, DocsRetrievalSourceScope, DocsReviewCiConfig, DocsReviewCiMode, DocsReviewConfig, DocsReviewRulesConfig, DocsReviewScoreConfig, DocsReviewSeverity, DocsRobotsConfig, DocsRobotsRule, DocsSearchAdapter, DocsSearchAdapterContext, DocsSearchAdapterFactory, DocsSearchAdapterPage, DocsSearchAmbiguityDecision, DocsSearchAmbiguityDecisionStatus, DocsSearchAmbiguityResolution, DocsSearchChunkingConfig, DocsSearchConfig, DocsSearchDocument, DocsSearchEmbeddingsConfig, DocsSearchExplanation, DocsSearchFacet, DocsSearchFacetValue, DocsSearchFacetsResponse, DocsSearchFilterDecision, DocsSearchFilterDecisionOutcome, DocsSearchFilterField, DocsSearchFilterInput, DocsSearchFilters, DocsSearchMatchField, DocsSearchMatchedTerm, DocsSearchQuery, DocsSearchRankingReason, DocsSearchRankingReasonCode, DocsSearchRankingStrategy, DocsSearchRequest, DocsSearchResponse, DocsSearchResult, DocsSearchResultType, DocsSearchSourcePage, DocsSearchWarning, DocsSearchWarningCode, DocsSitemapConfig, DocsTelemetryAgentSurface, DocsTelemetryConfig, DocsTelemetryEvent, DocsTelemetryEventInput, DocsTelemetryEventType, DocsTelemetryFeatures, DocsTelemetryFramework, DocsTheme, FeedbackConfig, FontStyle, GithubConfig, LastUpdatedConfig, LlmsTxtConfig, LlmsTxtMaxCharsConfig, LlmsTxtMaxCharsMode, LlmsTxtSectionConfig, McpDocsSearchConfig, OGConfig, OpenDocsConfig, OpenDocsProvider, OpenDocsProviderConfig, OpenDocsProviderId, OpenDocsTarget, OpenGraphImage, OrderingItem, PageActionConnectMcpConfig, PageActionInstallSkillsConfig, PageActionMcpProvider, PageActionsConfig, PageAgentAppliesTo, PageAgentCommand, PageAgentFailureMode, PageAgentFrontmatter, PageAgentVerification, PageFrontmatter, PageOpenGraph, PageSidebarFrontmatter, PageTwitter, ReadingTimeConfig, ReadingTimeFormat, ResolvedDocsRelatedLink, SidebarComponentProps, SidebarConfig, SidebarFolderIndexBehavior, SidebarFolderNode, SidebarNode, SidebarPageNode, SidebarTree, SimpleDocsSearchConfig, ThemeToggleConfig, TypesenseDocsSearchConfig, TypographyConfig, UIConfig };
|
package/dist/urls.d.mts
ADDED
package/dist/urls.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/urls.ts
|
|
2
|
+
function normalizeDocsUrlPath(value) {
|
|
3
|
+
const normalized = value.replace(/\/+/g, "/");
|
|
4
|
+
if (normalized === "/") return normalized;
|
|
5
|
+
return normalized.replace(/\/+$/, "");
|
|
6
|
+
}
|
|
7
|
+
function toDocsMarkdownUrl(url, options = {}) {
|
|
8
|
+
const hashIndex = url.indexOf("#");
|
|
9
|
+
const withoutHash = hashIndex >= 0 ? url.slice(0, hashIndex) : url;
|
|
10
|
+
const hash = hashIndex >= 0 ? url.slice(hashIndex + 1) : "";
|
|
11
|
+
const [pathname, query = ""] = withoutHash.split("?", 2);
|
|
12
|
+
const normalizedPath = normalizeDocsUrlPath(pathname || "/");
|
|
13
|
+
const markdownPath = normalizedPath.endsWith(".md") ? normalizedPath : `${normalizedPath}.md`;
|
|
14
|
+
const params = new URLSearchParams(query);
|
|
15
|
+
if (options.locale && !params.has("lang")) params.set("lang", options.locale);
|
|
16
|
+
const search = params.toString();
|
|
17
|
+
return `${markdownPath}${search ? `?${search}` : ""}${hash ? `#${hash}` : ""}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { normalizeDocsUrlPath, toDocsMarkdownUrl };
|
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/utils.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Deep merge utility for theme overrides.
|
|
4
|
+
* Merges objects recursively; later values override earlier ones.
|
|
5
|
+
*/
|
|
6
|
+
declare function deepMerge<T extends Record<string, unknown>>(target: T, ...sources: Partial<T>[]): T;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { deepMerge };
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* Deep merge utility for theme overrides.
|
|
4
|
+
* Merges objects recursively; later values override earlier ones.
|
|
5
|
+
*/
|
|
6
|
+
function deepMerge(target, ...sources) {
|
|
7
|
+
if (!sources.length) return target;
|
|
8
|
+
const source = sources.shift();
|
|
9
|
+
if (!source) return target;
|
|
10
|
+
const result = { ...target };
|
|
11
|
+
for (const key of Object.keys(source)) {
|
|
12
|
+
const sourceVal = source[key];
|
|
13
|
+
const targetVal = result[key];
|
|
14
|
+
if (sourceVal && typeof sourceVal === "object" && !Array.isArray(sourceVal) && targetVal && typeof targetVal === "object" && !Array.isArray(targetVal)) result[key] = deepMerge(targetVal, sourceVal);
|
|
15
|
+
else if (sourceVal !== void 0) result[key] = sourceVal;
|
|
16
|
+
}
|
|
17
|
+
if (sources.length) return deepMerge(result, ...sources);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { deepMerge };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/docs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.121",
|
|
4
4
|
"description": "Modern, flexible MDX-based docs framework — core types, config, and CLI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"dist",
|
|
20
20
|
"styles"
|
|
21
21
|
],
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"**/*.css",
|
|
24
|
+
"./dist/cli/**"
|
|
25
|
+
],
|
|
22
26
|
"type": "module",
|
|
23
27
|
"main": "./dist/index.mjs",
|
|
24
28
|
"module": "./dist/index.mjs",
|
|
@@ -39,6 +43,11 @@
|
|
|
39
43
|
"import": "./dist/runtime.mjs",
|
|
40
44
|
"default": "./dist/runtime.mjs"
|
|
41
45
|
},
|
|
46
|
+
"./mdx": {
|
|
47
|
+
"types": "./dist/mdx.d.mts",
|
|
48
|
+
"import": "./dist/mdx.mjs",
|
|
49
|
+
"default": "./dist/mdx.mjs"
|
|
50
|
+
},
|
|
42
51
|
"./markdown-rendering": {
|
|
43
52
|
"types": "./dist/markdown-rendering.d.mts",
|
|
44
53
|
"import": "./dist/markdown-rendering.mjs",
|
|
@@ -79,14 +88,18 @@
|
|
|
79
88
|
"import": "./dist/mcp.mjs",
|
|
80
89
|
"default": "./dist/mcp.mjs"
|
|
81
90
|
},
|
|
82
|
-
"./styles/themes/shadcn.css": "./styles/themes/shadcn.css"
|
|
91
|
+
"./styles/themes/shadcn.css": "./styles/themes/shadcn.css",
|
|
92
|
+
"./build": {
|
|
93
|
+
"types": "./dist/build.d.mts",
|
|
94
|
+
"import": "./dist/build.mjs",
|
|
95
|
+
"default": "./dist/build.mjs"
|
|
96
|
+
}
|
|
83
97
|
},
|
|
84
98
|
"dependencies": {
|
|
85
99
|
"@clack/prompts": "^1.7.0",
|
|
86
100
|
"@mdx-js/mdx": "^3.1.1",
|
|
87
101
|
"@modelcontextprotocol/server": "2.0.0",
|
|
88
102
|
"@scalar/core": "^0.4.3",
|
|
89
|
-
"@vercel/sandbox": "^2.0.0",
|
|
90
103
|
"github-slugger": "^2.0.0",
|
|
91
104
|
"gray-matter": "^4.0.3",
|
|
92
105
|
"jiti": "^2.7.0",
|
|
@@ -98,9 +111,13 @@
|
|
|
98
111
|
"zod": "^4.3.6"
|
|
99
112
|
},
|
|
100
113
|
"peerDependencies": {
|
|
114
|
+
"@vercel/sandbox": "^2.0.0",
|
|
101
115
|
"react": ">=19.2.0"
|
|
102
116
|
},
|
|
103
117
|
"peerDependenciesMeta": {
|
|
118
|
+
"@vercel/sandbox": {
|
|
119
|
+
"optional": true
|
|
120
|
+
},
|
|
104
121
|
"react": {
|
|
105
122
|
"optional": true
|
|
106
123
|
}
|
|
@@ -109,6 +126,7 @@
|
|
|
109
126
|
"@modelcontextprotocol/client": "2.2.0",
|
|
110
127
|
"@types/node": "^22.10.0",
|
|
111
128
|
"@types/react": "^19.2.2",
|
|
129
|
+
"@vercel/sandbox": "^2.0.0",
|
|
112
130
|
"ajv": "^8.18.0",
|
|
113
131
|
"ajv-formats": "^3.0.1",
|
|
114
132
|
"react": "^19.2.0",
|