fumapress 0.2.0 → 0.2.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/css/generated.css CHANGED
@@ -74,6 +74,7 @@
74
74
  @source inline("render");
75
75
  @source inline("renderCtx");
76
76
  @source inline("renderPageMeta");
77
+ @source inline("renderRootMeta");
77
78
  @source inline("result");
78
79
  @source inline("return");
79
80
  @source inline("root");
package/dist/config.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AppContext } from "./lib/shared.js";
2
2
  import { Adapter, Awaitable, ServerPlugin } from "./lib/types.js";
3
+ import { ReactNode } from "react";
3
4
  import { TranslationsOption } from "fumadocs-ui/contexts/i18n";
4
5
  import { LoaderConfig, LoaderOutput } from "fumadocs-core/source";
5
6
  import { I18nConfig } from "fumadocs-core/i18n";
@@ -23,6 +24,10 @@ interface Config<C extends ConfigContext = ConfigContext> {
23
24
  /** adapter for content sources, use `fumadocs-mdx` if not specified */
24
25
  adapters?: Adapter[];
25
26
  i18n?: I18nConfig$1;
27
+ meta?: {
28
+ /** render meta tags for any pages */root?: (this: AppContext<C>) => ReactNode; /** render meta tags for page */
29
+ page?: (this: AppContext<C>, page: C['loaderConfig']['page']) => ReactNode;
30
+ };
26
31
  }
27
32
  interface I18nConfig$1 {
28
33
  /** locale code -> language info */
@@ -1,8 +1,8 @@
1
1
  import { baseOptions, getGitHubFileUrl, renderPageMeta } from "../lib/shared.js";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import { unstable_notFound } from "waku/router/server";
3
4
  import { DocsLayout } from "fumadocs-ui/layouts/docs";
4
5
  import { DocsBody, DocsDescription, DocsPage, DocsTitle, MarkdownCopyButton, ViewOptionsPopover } from "fumadocs-ui/layouts/docs/page";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/layouts/docs.tsx
7
7
  function createDocsLayout({ render = async function defaultRender(page) {
8
8
  let body;
@@ -1,6 +1,6 @@
1
1
  import { baseOptions, renderPageMeta } from "../lib/shared.js";
2
- import { unstable_notFound } from "waku/router/server";
3
2
  import { jsxs } from "react/jsx-runtime";
3
+ import { unstable_notFound } from "waku/router/server";
4
4
  import { HomeLayout } from "fumadocs-ui/layouts/home";
5
5
  //#region src/layouts/home.tsx
6
6
  function createHomeLayout({ render = async function renderDefault(page) {
@@ -1,9 +1,11 @@
1
+ import { renderRootMeta } from "../lib/shared.js";
1
2
  import { jsx, jsxs } from "react/jsx-runtime";
2
3
  import styles from "virtual:root.css?inline";
3
4
  import { RootProvider } from "fumadocs-ui/provider/waku";
4
5
  //#region src/layouts/root.tsx
5
6
  function createRootLayout() {
6
- return async function({ children, lang, i18nConfig, data }) {
7
+ return async function(props) {
8
+ const { children, lang, i18nConfig, data } = props;
7
9
  const hooks = data["core:provider"];
8
10
  let providerProps = {};
9
11
  if (i18nConfig) providerProps.i18n = {
@@ -18,7 +20,7 @@ function createRootLayout() {
18
20
  return /* @__PURE__ */ jsxs("html", {
19
21
  lang: lang ?? "en",
20
22
  suppressHydrationWarning: true,
21
- children: [/* @__PURE__ */ jsx("head", { children: /* @__PURE__ */ jsx("style", { children: styles }) }), /* @__PURE__ */ jsx("body", {
23
+ children: [/* @__PURE__ */ jsxs("head", { children: [/* @__PURE__ */ jsx("style", { children: styles }), renderRootMeta(props)] }), /* @__PURE__ */ jsx("body", {
22
24
  "data-version": "1.0",
23
25
  className: "flex flex-col min-h-screen",
24
26
  children: /* @__PURE__ */ jsx(RootProvider, {
@@ -1,4 +1,4 @@
1
- import { BuildMode, ConfigContext, I18nConfig } from "../config.js";
1
+ import { BuildMode, Config, ConfigContext, I18nConfig } from "../config.js";
2
2
  import { DocsLayoutContextData } from "../layouts/docs.js";
3
3
  import { HomeLayoutContextData } from "../layouts/home.js";
4
4
  import { Adapter, Awaitable, ServerPlugin } from "./types.js";
@@ -18,6 +18,7 @@ interface AppContext<C extends ConfigContext = ConfigContext> {
18
18
  */
19
19
  data: AppContextData & Record<string, unknown>;
20
20
  i18nConfig?: I18nConfig;
21
+ metaConfig?: Config['meta'];
21
22
  siteConfig: {
22
23
  name: string;
23
24
  git?: {
@@ -1,8 +1,9 @@
1
1
  import { getGitRootDir } from "./fs.js";
2
2
  import { fumadocsMdx } from "../adapters/mdx.js";
3
3
  import path from "node:path";
4
- import { Fragment, createElement } from "react";
5
- //#region src/lib/shared.ts
4
+ import { Fragment } from "react";
5
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/lib/shared.tsx
6
7
  function parseConfig(config) {
7
8
  const context = {
8
9
  getLoader() {
@@ -15,6 +16,7 @@ function parseConfig(config) {
15
16
  data: {},
16
17
  i18nConfig: config.i18n,
17
18
  mode: config.mode ?? "default",
19
+ metaConfig: config.meta,
18
20
  siteConfig: {
19
21
  name: config.site?.name ?? "Fumapress",
20
22
  git: config.site?.git ? {
@@ -26,10 +28,23 @@ function parseConfig(config) {
26
28
  if (typeof config.plugins === "function") context.plugins = config.plugins(context);
27
29
  return context;
28
30
  }
31
+ function renderRootMeta(context) {
32
+ return context.metaConfig?.root?.call(context);
33
+ }
29
34
  function renderPageMeta(page, context) {
30
- const meta = context.data["core:page-meta"];
31
- if (!meta) return;
32
- return meta.map((fn, i) => createElement(Fragment, { key: i }, fn(page)));
35
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
36
+ /* @__PURE__ */ jsx("title", { children: page.data.title }),
37
+ /* @__PURE__ */ jsx("meta", {
38
+ property: "og:title",
39
+ content: page.data.title
40
+ }),
41
+ page.data.description && /* @__PURE__ */ jsx("meta", {
42
+ property: "og:description",
43
+ content: page.data.description
44
+ }),
45
+ context.metaConfig?.page?.call(context, page),
46
+ context.data["core:page-meta"]?.map((hook, i) => /* @__PURE__ */ jsx(Fragment, { children: hook(page) }, i))
47
+ ] });
33
48
  }
34
49
  function getGitHubFileUrl(ctx, absolutePath) {
35
50
  const { git } = ctx.siteConfig;
@@ -46,4 +61,4 @@ function baseOptions(ctx) {
46
61
  };
47
62
  }
48
63
  //#endregion
49
- export { baseOptions, getGitHubFileUrl, parseConfig, renderPageMeta };
64
+ export { baseOptions, getGitHubFileUrl, parseConfig, renderPageMeta, renderRootMeta };
@@ -2,7 +2,7 @@ import { unstable_notFound } from "waku/router/server";
2
2
  import { llms } from "fumadocs-core/source/llms";
3
3
  //#region src/plugins/llms.txt.ts
4
4
  function llmsPlugin(options = {}) {
5
- const { getLLMText = async function getLLMTextDefault(page) {
5
+ const { getLLMText: _getLLMText = async function getLLMTextDefault(page) {
6
6
  for (const adapter of this.adapters) {
7
7
  const txt = await adapter["core:get-text"]?.call(this, page);
8
8
  if (txt !== void 0) return `# ${page.data.title} (${page.url})\n\n${txt}`;
@@ -20,6 +20,7 @@ function llmsPlugin(options = {}) {
20
20
  },
21
21
  async createPages({ createApiIsomorphic }) {
22
22
  const defaultRenderMode = this.mode === "dynamic" ? "dynamic" : "static";
23
+ const getLLMText = _getLLMText.bind(this);
23
24
  createApiIsomorphic({
24
25
  render: defaultRenderMode,
25
26
  path: "/llms.txt",
@@ -44,7 +45,7 @@ function llmsPlugin(options = {}) {
44
45
  handler: async (_req, { params }) => {
45
46
  const page = (await this.getLoader()).getPage(markdownPathToSlugs(params.slugs), params.lang);
46
47
  if (!page) unstable_notFound();
47
- return new Response(await getLLMText.call(this, page), { headers: { "Content-Type": "text/markdown" } });
48
+ return new Response(await getLLMText(page), { headers: { "Content-Type": "text/markdown" } });
48
49
  }
49
50
  });
50
51
  }
@@ -1,7 +1,7 @@
1
- import { createElement } from "react";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { unstable_notFound } from "waku/router/server";
3
3
  import { ImageResponse } from "@takumi-rs/image-response";
4
- //#region src/plugins/takumi.ts
4
+ //#region src/plugins/takumi.tsx
5
5
  function takumiPlugin(options = {}) {
6
6
  const { generate = async function generateDefault(page) {
7
7
  const { generate } = await import("fumadocs-ui/og/takumi");
@@ -11,13 +11,29 @@ function takumiPlugin(options = {}) {
11
11
  site: this.siteConfig.name
12
12
  }) };
13
13
  } } = options;
14
+ const width = 1200;
15
+ const height = 630;
14
16
  return {
15
17
  init() {
16
18
  (this.data["core:page-meta"] ??= []).push((page) => {
17
- return createElement("meta", {
18
- property: "og:image",
19
- content: slugsToImagePath(page.slugs, page.locale).url
20
- });
19
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
20
+ /* @__PURE__ */ jsx("meta", {
21
+ property: "og:image",
22
+ content: slugsToImagePath(page.slugs, page.locale).url
23
+ }),
24
+ /* @__PURE__ */ jsx("meta", {
25
+ property: "og:image:width",
26
+ content: `${width}`
27
+ }),
28
+ /* @__PURE__ */ jsx("meta", {
29
+ property: "og:image:height",
30
+ content: `${height}`
31
+ }),
32
+ /* @__PURE__ */ jsx("meta", {
33
+ property: "twitter:card",
34
+ content: "summary_large_image"
35
+ })
36
+ ] });
21
37
  });
22
38
  },
23
39
  async createPages({ createApiIsomorphic }) {
@@ -31,8 +47,8 @@ function takumiPlugin(options = {}) {
31
47
  if (!page) unstable_notFound();
32
48
  const { node, options } = await generate.call(this, page);
33
49
  return new ImageResponse(node, {
34
- width: 1200,
35
- height: 630,
50
+ width,
51
+ height,
36
52
  ...options,
37
53
  format: "webp"
38
54
  });
package/dist/vite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { crawlFrameworkPkgs } from "./node_modules/.pnpm/vitefu@1.1.3_vite@8.0.11_@types_node@25.6.2_esbuild@0.28.0_jiti@2.7.0_terser@5.47.1_tsx@4.21.0_yaml@2.8.4_/node_modules/vitefu/src/index.js";
1
+ import { crawlFrameworkPkgs } from "vitefu";
2
2
  //#region src/vite.ts
3
3
  function press() {
4
4
  return pressCore();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumapress",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "An opinionated docs framework powered by Fumadocs",
5
5
  "keywords": [
6
6
  "Docs",
@@ -41,6 +41,7 @@
41
41
  "flexsearch": "^0.8.212",
42
42
  "lucide-react": "^1.14.0",
43
43
  "tailwind-merge": "^3.5.0",
44
+ "vitefu": "^1.1.3",
44
45
  "fumadocs-core": "16.8.9",
45
46
  "fumadocs-ui": "16.8.9"
46
47
  },
@@ -54,9 +55,8 @@
54
55
  "tsdown": "0.22.0",
55
56
  "typescript": "^6.0.3",
56
57
  "vite": "^8.0.11",
57
- "vitefu": "^1.1.3",
58
58
  "waku": "1.0.0-alpha.10",
59
- "fumadocs-mdx": "15.0.1"
59
+ "fumadocs-mdx": "15.0.2"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "@types/react": "*",
@@ -77,9 +77,6 @@
77
77
  "optional": true
78
78
  }
79
79
  },
80
- "inlinedDependencies": {
81
- "vitefu": "1.1.3"
82
- },
83
80
  "scripts": {
84
81
  "dev": "tsdown --watch",
85
82
  "build": "tsdown",
@@ -1,4 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
3
- //#endregion
4
- export { __commonJSMin };
@@ -1,199 +0,0 @@
1
- import { require_sync } from "./sync.js";
2
- import fsSync from "node:fs";
3
- import path from "node:path";
4
- import fs from "node:fs/promises";
5
- import { createRequire } from "node:module";
6
- //#region ../../node_modules/.pnpm/vitefu@1.1.3_vite@8.0.11_@types+node@25.6.2_esbuild@0.28.0_jiti@2.7.0_terser@5.47.1_tsx@4.21.0_yaml@2.8.4_/node_modules/vitefu/src/index.js
7
- var import_sync = require_sync();
8
- /** @type {import('pnpapi')} */
9
- let pnp;
10
- /** @type {Array<{ name: string; reference: string; }>} */
11
- let pnpWorkspaceLocators;
12
- if (process.versions.pnp) try {
13
- pnp = createRequire(import.meta.url)("pnpapi");
14
- pnpWorkspaceLocators = pnp.getDependencyTreeRoots();
15
- } catch {}
16
- /** @type {import('./index.d.ts').crawlFrameworkPkgs} */
17
- async function crawlFrameworkPkgs(options) {
18
- const pkgJsonPath = await findClosestPkgJsonPath(options.root);
19
- if (!pkgJsonPath) return {
20
- optimizeDeps: {
21
- include: [],
22
- exclude: []
23
- },
24
- ssr: {
25
- noExternal: [],
26
- external: []
27
- }
28
- };
29
- const pkgJson = await readJson(pkgJsonPath).catch((e) => {
30
- throw new Error(`Unable to read ${pkgJsonPath}`, { cause: e });
31
- });
32
- /** @type {string[]} */
33
- let optimizeDepsInclude = [];
34
- /** @type {string[]} */
35
- let optimizeDepsExclude = [];
36
- /** @type {string[]} */
37
- let ssrNoExternal = [];
38
- /** @type {string[]} */
39
- let ssrExternal = [];
40
- await crawl(pkgJsonPath, pkgJson);
41
- if (options.viteUserConfig) {
42
- const _optimizeDepsExclude = options.viteUserConfig?.optimizeDeps?.exclude;
43
- if (_optimizeDepsExclude) optimizeDepsInclude = optimizeDepsInclude.filter((dep) => !(0, import_sync.isDepExcluded)(dep, _optimizeDepsExclude));
44
- const _optimizeDepsInclude = options.viteUserConfig?.optimizeDeps?.include;
45
- if (_optimizeDepsInclude) optimizeDepsExclude = optimizeDepsExclude.filter((dep) => !(0, import_sync.isDepIncluded)(dep, _optimizeDepsInclude));
46
- const _ssrExternal = options.viteUserConfig?.ssr?.external;
47
- if (_ssrExternal) ssrNoExternal = ssrNoExternal.filter((dep) => !(0, import_sync.isDepExternaled)(dep, _ssrExternal));
48
- const _ssrNoExternal = options.viteUserConfig?.ssr?.noExternal;
49
- if (_ssrNoExternal) ssrExternal = ssrExternal.filter((dep) => !(0, import_sync.isDepNoExternaled)(dep, _ssrNoExternal));
50
- }
51
- optimizeDepsInclude.sort();
52
- optimizeDepsExclude.sort();
53
- ssrExternal.sort();
54
- ssrNoExternal.sort();
55
- return {
56
- optimizeDeps: {
57
- include: optimizeDepsInclude,
58
- exclude: optimizeDepsExclude
59
- },
60
- ssr: {
61
- noExternal: ssrNoExternal,
62
- external: ssrExternal
63
- }
64
- };
65
- /**
66
- * crawl the package.json dependencies for framework packages. rules:
67
- * 1. a framework package should be `optimizeDeps.exclude` and `ssr.noExternal`.
68
- * 2. the deps of the framework package should be `optimizeDeps.include` and `ssr.external`
69
- * unless the dep is also a framework package, in which case do no1 & no2 recursively.
70
- * 3. any non-framework packages that aren't imported by a framework package can be skipped entirely.
71
- * 4. a semi-framework package is like a framework package, except it isn't `optimizeDeps.exclude`,
72
- * but only applies `ssr.noExternal`.
73
- * @param {string} pkgJsonPath
74
- * @param {Record<string, any>} pkgJson
75
- * @param {string[]} [parentDepNames]
76
- */
77
- async function crawl(pkgJsonPath, pkgJson, parentDepNames = []) {
78
- const isRoot = parentDepNames.length === 0;
79
- const crawlDevDependencies = isRoot || isPrivateWorkspacePackage(pkgJsonPath, pkgJson, options.workspaceRoot);
80
- /** @type {string[]} */
81
- let deps = [...Object.keys(pkgJson.dependencies || {}), ...crawlDevDependencies ? Object.keys(pkgJson.devDependencies || {}) : []];
82
- deps = deps.filter((dep) => {
83
- if (parentDepNames.includes(dep)) return false;
84
- const isFrameworkPkg = options.isFrameworkPkgByName?.(dep);
85
- const isSemiFrameworkPkg = options.isSemiFrameworkPkgByName?.(dep);
86
- if (isFrameworkPkg) {
87
- optimizeDepsExclude.push(dep);
88
- ssrNoExternal.push(dep);
89
- } else if (isSemiFrameworkPkg) ssrNoExternal.push(dep);
90
- if (isFrameworkPkg === false || isSemiFrameworkPkg === false) return false;
91
- else return true;
92
- });
93
- const promises = deps.map(async (dep) => {
94
- const depPkgJsonPath = await _findDepPkgJsonPath(dep, pkgJsonPath, !!options.workspaceRoot);
95
- if (!depPkgJsonPath) return;
96
- const depPkgJson = await readJson(depPkgJsonPath).catch(() => {});
97
- if (!depPkgJson) return;
98
- if (ssrNoExternal.includes(dep)) return crawl(depPkgJsonPath, depPkgJson, parentDepNames.concat(dep));
99
- const isFrameworkPkg = options.isFrameworkPkgByJson?.(depPkgJson);
100
- const isSemiFrameworkPkg = options.isSemiFrameworkPkgByJson?.(depPkgJson);
101
- if (isFrameworkPkg || isSemiFrameworkPkg) {
102
- if (isFrameworkPkg) {
103
- optimizeDepsExclude.push(dep);
104
- ssrNoExternal.push(dep);
105
- } else if (isSemiFrameworkPkg) ssrNoExternal.push(dep);
106
- return crawl(depPkgJsonPath, depPkgJson, parentDepNames.concat(dep));
107
- }
108
- if (!isRoot) {
109
- if (await pkgNeedsOptimization(depPkgJson, depPkgJsonPath)) optimizeDepsInclude.push(parentDepNames.concat(dep).join(" > "));
110
- if (!options.isBuild && !ssrExternal.includes(dep)) ssrExternal.push(dep);
111
- }
112
- });
113
- await Promise.all(promises);
114
- }
115
- }
116
- /**
117
- * internal implementation to avoid exposing the usePnpWorkspaceLocators flag
118
- *
119
- * @param {string} dep
120
- * @param {string} parent
121
- * @param {boolean} usePnpWorkspaceLocators
122
- * @returns {Promise<undefined|string>}
123
- * @private
124
- */
125
- async function _findDepPkgJsonPath(dep, parent, usePnpWorkspaceLocators) {
126
- if (pnp) {
127
- if (usePnpWorkspaceLocators) try {
128
- const locator = pnpWorkspaceLocators.find((root) => root.name === dep);
129
- if (locator) {
130
- const pkgPath = pnp.getPackageInformation(locator).packageLocation;
131
- return path.resolve(pkgPath, "package.json");
132
- }
133
- } catch {}
134
- try {
135
- const depRoot = pnp.resolveToUnqualified(dep, parent);
136
- if (!depRoot) return void 0;
137
- return path.join(depRoot, "package.json");
138
- } catch {
139
- return;
140
- }
141
- }
142
- let root = parent;
143
- while (root) {
144
- const pkg = path.join(root, "node_modules", dep, "package.json");
145
- try {
146
- await fs.access(pkg);
147
- return fsSync.realpathSync(pkg);
148
- } catch {}
149
- const nextRoot = path.dirname(root);
150
- if (nextRoot === root) break;
151
- root = nextRoot;
152
- }
153
- }
154
- /** @type {import('./index.d.ts').findClosestPkgJsonPath} */
155
- async function findClosestPkgJsonPath(dir, predicate = void 0) {
156
- if (dir.endsWith("package.json")) dir = path.dirname(dir);
157
- while (dir) {
158
- const pkg = path.join(dir, "package.json");
159
- try {
160
- if ((await fs.stat(pkg)).isFile() && (!predicate || await predicate(pkg))) return pkg;
161
- } catch {}
162
- const nextDir = path.dirname(dir);
163
- if (nextDir === dir) break;
164
- dir = nextDir;
165
- }
166
- }
167
- /** @type {import('./index.d.ts').pkgNeedsOptimization} */
168
- async function pkgNeedsOptimization(pkgJson, pkgJsonPath) {
169
- if (pkgJson.module || pkgJson.exports) return false;
170
- if (pkgJson.main) {
171
- const entryExt = path.extname(pkgJson.main);
172
- return !entryExt || entryExt === ".js" || entryExt === ".cjs";
173
- }
174
- try {
175
- await fs.access(path.join(path.dirname(pkgJsonPath), "index.js"));
176
- return true;
177
- } catch {
178
- return false;
179
- }
180
- }
181
- /**
182
- * @param {string} findDepPkgJsonPath
183
- * @returns {Promise<Record<string, any>>}
184
- */
185
- async function readJson(findDepPkgJsonPath) {
186
- return JSON.parse(await fs.readFile(findDepPkgJsonPath, "utf8"));
187
- }
188
- /**
189
- *
190
- * @param {string} pkgJsonPath
191
- * @param {Record<string,any>} pkgJson
192
- * @param {string} [workspaceRoot]
193
- * @returns {boolean}
194
- */
195
- function isPrivateWorkspacePackage(pkgJsonPath, pkgJson, workspaceRoot = void 0) {
196
- return !!(workspaceRoot && pkgJson.private && !pkgJsonPath.match(/[/\\]node_modules[/\\]/) && !path.relative(workspaceRoot, pkgJsonPath).startsWith(".."));
197
- }
198
- //#endregion
199
- export { crawlFrameworkPkgs };
@@ -1,48 +0,0 @@
1
- import { __commonJSMin } from "../../../../../../_virtual/_rolldown/runtime.js";
2
- //#region ../../node_modules/.pnpm/vitefu@1.1.3_vite@8.0.11_@types+node@25.6.2_esbuild@0.28.0_jiti@2.7.0_terser@5.47.1_tsx@4.21.0_yaml@2.8.4_/node_modules/vitefu/src/sync.cjs
3
- var require_sync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4
- /** @type {import('./index.d.ts').isDepIncluded} */
5
- function isDepIncluded(dep, optimizeDepsInclude) {
6
- return optimizeDepsInclude.some((id) => parseIncludeStr(id) === dep);
7
- }
8
- /** @type {import('./index.d.ts').isDepExcluded} */
9
- function isDepExcluded(dep, optimizeDepsExclude) {
10
- dep = parseIncludeStr(dep);
11
- return optimizeDepsExclude.some((id) => id === dep || dep.startsWith(`${id}/`));
12
- }
13
- /** @type {import('./index.d.ts').isDepNoExternaled} */
14
- function isDepNoExternaled(dep, ssrNoExternal) {
15
- if (ssrNoExternal === true) return true;
16
- else return isMatch(dep, ssrNoExternal);
17
- }
18
- /** @type {import('./index.d.ts').isDepExternaled} */
19
- function isDepExternaled(dep, ssrExternal) {
20
- if (ssrExternal === true) return false;
21
- else return ssrExternal.includes(dep);
22
- }
23
- /**
24
- * @param {string} raw could be "foo" or "foo > bar" etc
25
- */
26
- function parseIncludeStr(raw) {
27
- const lastArrow = raw.lastIndexOf(">");
28
- return lastArrow === -1 ? raw : raw.slice(lastArrow + 1).trim();
29
- }
30
- /**
31
- * @param {string} target
32
- * @param {string | RegExp | (string | RegExp)[]} pattern
33
- */
34
- function isMatch(target, pattern) {
35
- if (Array.isArray(pattern)) return pattern.some((p) => isMatch(target, p));
36
- else if (typeof pattern === "string") return target === pattern;
37
- else if (pattern instanceof RegExp) return pattern.test(target);
38
- }
39
- module.exports = {
40
- isDepIncluded,
41
- isDepExcluded,
42
- isDepNoExternaled,
43
- isDepExternaled
44
- };
45
- }));
46
- //#endregion
47
- export default require_sync();
48
- export { require_sync };