vitepress-plugin-api-extractor 0.5.5 → 0.6.1

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/Registry.js CHANGED
@@ -1,5 +1,6 @@
1
+ import { registryHttpClientLayer } from "./RegistryHttpClient.js";
1
2
  import { Effect, Layer, Path } from "effect";
2
- import { NodeFileSystem, NodeHttpClient } from "@effect/platform-node";
3
+ import { NodeFileSystem } from "@effect/platform-node";
3
4
  import { Cache } from "@effected/store";
4
5
  import { AppDirs, Xdg } from "@effected/xdg";
5
6
  import { PackageFetcher, PackageSpec, RegistryObserver, TypeCache, TypeRegistry } from "@tsdoctor/registry";
@@ -40,13 +41,23 @@ const MetadataCacheLive = Layer.unwrap(Effect.gen(function* () {
40
41
  /** The registry emits no logs of its own; this adapter listens to nothing yet. */
41
42
  const RegistryObserverLive = Layer.succeed(RegistryObserver, { emit: () => Effect.void });
42
43
  /**
44
+ * The registry's HTTP client: pnpm's proxy and TLS configuration from the
45
+ * directory VitePress runs in, or a plain undici client with a warning.
46
+ */
47
+ const RegistryHttpClientLive = registryHttpClientLayer({
48
+ cwd: process.cwd(),
49
+ env: process.env,
50
+ platform: process.platform,
51
+ onFallback: (reason) => Effect.sync(() => console.warn(`[vitepress-plugin-api-extractor] ${reason}`))
52
+ }).pipe(Layer.provide(PlatformLive));
53
+ /**
43
54
  * The full registry runtime: `TypeRegistry` over an XDG-rooted `TypeCache`
44
55
  * and the jsDelivr `PackageFetcher`. Bound to a const so the stack builds
45
56
  * once per runtime.
46
57
  *
47
58
  * @public
48
59
  */
49
- const RegistryLive = TypeRegistry.layer.pipe(Layer.provideMerge(Layer.mergeAll(TypeCache.layerXdg(), PackageFetcher.layer)), Layer.provideMerge(RegistryObserverLive), Layer.provide(Layer.mergeAll(MetadataCacheLive, AppDirsLive, PlatformLive, NodeHttpClient.layerUndici)), Layer.orDie);
60
+ const RegistryLive = TypeRegistry.layer.pipe(Layer.provideMerge(Layer.mergeAll(TypeCache.layerXdg(), PackageFetcher.layer)), Layer.provideMerge(RegistryObserverLive), Layer.provide(Layer.mergeAll(MetadataCacheLive, AppDirsLive, PlatformLive, RegistryHttpClientLive)), Layer.orDie);
50
61
  /**
51
62
  * The dependency-field names `package.json` declares packages under.
52
63
  */
@@ -0,0 +1,60 @@
1
+ import { Cause, Effect, Layer } from "effect";
2
+ import { NodeHttpClient } from "@effect/platform-node";
3
+ import { ErrorText } from "@effected/kit";
4
+ import { NpmHttpClient } from "@effected/npm/node";
5
+ import { PnpmNpmConfig } from "@effected/pnpm";
6
+ import * as HttpClient from "effect/http/HttpClient";
7
+
8
+ // src/RegistryHttpClient.ts
9
+ /**
10
+ * The HTTP client the type registry fetches from jsDelivr with.
11
+ *
12
+ * @remarks
13
+ * A plain undici client ignores every proxy and TLS setting a developer
14
+ * configured for their package manager: `HTTPS_PROXY`/`NO_PROXY`, an npmrc's
15
+ * `proxy`/`https-proxy`/`noproxy`, `cafile`/`ca` and `strict-ssl`. Behind a
16
+ * corporate proxy or a TLS-intercepting CA every external-types fetch then
17
+ * fails, and because external types degrade rather than fail the build, the
18
+ * only symptom is Twoslash pages that lost their dependencies' types.
19
+ *
20
+ * This layer reads the configuration pnpm 12 would connect with
21
+ * (`PnpmNpmConfig.load`: the environment, `pnpm-workspace.yaml`, pnpm's global
22
+ * `config.yaml` and the npmrc files) and hands it to `NpmHttpClient`, so the
23
+ * registry connects the way `pnpm install` does from the same directory.
24
+ *
25
+ * A configuration that cannot be loaded, or a transport that cannot be built
26
+ * from it (an unreadable `cafile`, an unparseable proxy URL), falls back to the
27
+ * plain undici client and reports why. It never fails: external types are an
28
+ * enhancement.
29
+ *
30
+ * The report is deferred to the first request rather than made while the layer
31
+ * builds, so a build that never fetches (every package cached, or none
32
+ * declared) prints nothing. The RSPress adapter keeps a twin of this file; keep
33
+ * the two in step.
34
+ *
35
+ * @packageDocumentation
36
+ */
37
+ /**
38
+ * An `HttpClient` that honours pnpm's proxy and TLS configuration, falling back
39
+ * to a plain undici client.
40
+ *
41
+ * @remarks
42
+ * Each call builds a new layer and layers memoize by reference, so bind the
43
+ * result to a `const` once.
44
+ */
45
+ const registryHttpClientLayer = (options) => Layer.unwrap(PnpmNpmConfig.load({
46
+ cwd: options.cwd,
47
+ env: options.env,
48
+ platform: options.platform
49
+ }).pipe(Effect.map((config) => NpmHttpClient.layer(config, {
50
+ env: options.env,
51
+ packageManager: "pnpm"
52
+ })))).pipe(Layer.catchCause((cause) => Cause.hasInterrupts(cause) ? Layer.effectContext(Effect.failCause(Cause.interrupt([...Cause.interruptors(cause)][0]))) : fallbackLayer(`proxy and TLS settings not applied, fetching external types directly: ${ErrorText.describe(Cause.squash(cause))}`, options.onFallback)));
53
+ /** The plain undici client, reporting `reason` once on its first request. */
54
+ const fallbackLayer = (reason, onFallback) => Layer.effect(HttpClient.HttpClient, Effect.gen(function* () {
55
+ const client = yield* HttpClient.HttpClient;
56
+ const reportOnce = yield* Effect.cached(onFallback(reason));
57
+ return HttpClient.tapRequest(client, () => reportOnce);
58
+ })).pipe(Layer.provide(NodeHttpClient.layerUndici));
59
+
60
+ export { registryHttpClientLayer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitepress-plugin-api-extractor",
3
- "version": "0.5.5",
3
+ "version": "0.6.1",
4
4
  "private": false,
5
5
  "description": "VitePress adapter for generating API documentation from TypeScript API Extractor models: markdown pages over the @tsdoctor/pages IR, a sidebar from its navigation tree, and Twoslash type-checking over the same virtual file system the RSPress plugin resolves.",
6
6
  "keywords": [
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@effect/platform-node": "4.1.4",
41
- "@effected/commands": "0.21.0",
41
+ "@effected/commands": "0.22.0",
42
42
  "@effected/config-file": "0.28.0",
43
43
  "@effected/crypto": "0.7.0",
44
44
  "@effected/files": "0.3.0",
@@ -51,9 +51,10 @@
51
51
  "@effected/kit": "0.14.0",
52
52
  "@effected/manifest": "0.2.0",
53
53
  "@effected/markdown": "0.29.0",
54
- "@effected/npm": "0.34.1",
54
+ "@effected/npm": "0.35.0",
55
55
  "@effected/oidc": "0.5.0",
56
- "@effected/package-json": "0.32.1",
56
+ "@effected/package-json": "0.32.2",
57
+ "@effected/pnpm": "0.1.0",
57
58
  "@effected/schema-org": "0.15.0",
58
59
  "@effected/semver": "0.24.0",
59
60
  "@effected/source": "0.5.0",
@@ -66,10 +67,10 @@
66
67
  "@microsoft/api-extractor-model": "^7.33.16",
67
68
  "@shikijs/twoslash": "^4.6.0",
68
69
  "@shikijs/vitepress-twoslash": "^4.4.3",
69
- "@tsdoctor/bundle": "0.9.4",
70
+ "@tsdoctor/bundle": "0.9.5",
70
71
  "@tsdoctor/model": "0.10.6",
71
- "@tsdoctor/pages": "0.5.7",
72
- "@tsdoctor/registry": "0.7.7",
72
+ "@tsdoctor/pages": "0.5.8",
73
+ "@tsdoctor/registry": "0.7.8",
73
74
  "@tsdoctor/seo": "0.6.5",
74
75
  "@tsdoctor/vfs": "0.7.6",
75
76
  "effect": "4.1.4",