fuma-content 0.0.2 → 1.0.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.
Files changed (75) hide show
  1. package/dist/bin.d.ts +1 -0
  2. package/dist/bin.js +18 -0
  3. package/dist/build-mdx-I4NROXCF.js +8 -0
  4. package/dist/bun/index.d.ts +16 -0
  5. package/dist/bun/index.js +37 -0
  6. package/dist/bun-DMNX4PBC.js +40 -0
  7. package/dist/chunk-3VQS3KSP.js +39 -0
  8. package/dist/chunk-BTRE6MOX.js +16 -0
  9. package/dist/chunk-E4HRKSP4.js +24 -0
  10. package/dist/chunk-ERBMAQYP.js +33 -0
  11. package/dist/chunk-GGL4EF6H.js +38 -0
  12. package/dist/chunk-JBZTQ55D.js +30 -0
  13. package/dist/chunk-KH5GT2Y5.js +104 -0
  14. package/dist/chunk-LUM7SIZN.js +40 -0
  15. package/dist/chunk-MT7RY65Y.js +167 -0
  16. package/dist/chunk-NRZ4GE5O.js +207 -0
  17. package/dist/chunk-OQQNA7L7.js +412 -0
  18. package/dist/chunk-OUJENWQ4.js +45 -0
  19. package/dist/chunk-RMSV4HP6.js +85 -0
  20. package/dist/chunk-RXR7OL76.js +37 -0
  21. package/dist/chunk-VWJKRQZR.js +19 -0
  22. package/dist/chunk-W6HENTK7.js +44 -0
  23. package/dist/chunk-XR5N6ZXJ.js +50 -0
  24. package/dist/collections/handlers/fs.d.ts +10 -0
  25. package/dist/collections/handlers/fs.js +6 -0
  26. package/dist/collections/index.d.ts +10 -0
  27. package/dist/collections/index.js +6 -0
  28. package/dist/collections/mdx/loader-webpack.d.ts +17 -0
  29. package/dist/collections/mdx/loader-webpack.js +39 -0
  30. package/dist/collections/mdx/runtime-browser.d.ts +55 -0
  31. package/dist/collections/mdx/runtime-browser.js +82 -0
  32. package/dist/collections/mdx/runtime-dynamic.d.ts +43 -0
  33. package/dist/collections/mdx/runtime-dynamic.js +96 -0
  34. package/dist/collections/mdx/runtime.d.ts +70 -0
  35. package/dist/collections/mdx/runtime.js +45 -0
  36. package/dist/collections/mdx.d.ts +10 -0
  37. package/dist/collections/mdx.js +291 -0
  38. package/dist/collections/meta/loader-webpack.d.ts +17 -0
  39. package/dist/collections/meta/loader-webpack.js +42 -0
  40. package/dist/collections/meta/runtime.d.ts +19 -0
  41. package/dist/collections/meta/runtime.js +18 -0
  42. package/dist/collections/meta.d.ts +10 -0
  43. package/dist/collections/meta.js +170 -0
  44. package/dist/collections/runtime/file-store.d.ts +19 -0
  45. package/dist/collections/runtime/file-store.js +7 -0
  46. package/dist/collections/runtime/store.d.ts +28 -0
  47. package/dist/collections/runtime/store.js +6 -0
  48. package/dist/config/index.d.ts +10 -0
  49. package/dist/config/index.js +7 -0
  50. package/dist/core-Bo8KaWQz.d.ts +411 -0
  51. package/dist/index.d.ts +15 -31
  52. package/dist/index.js +6 -49
  53. package/dist/load-from-file-HL2VEY3M.js +7 -0
  54. package/dist/loader-NFSL6P5I.js +7 -0
  55. package/dist/loader-T756NSCS.js +7 -0
  56. package/dist/next/index.cjs +594 -0
  57. package/dist/next/index.d.ts +27 -0
  58. package/dist/next/index.js +100 -0
  59. package/dist/node/loader.d.ts +5 -0
  60. package/dist/node/loader.js +47 -0
  61. package/dist/node-DCMYL4DL.js +34 -0
  62. package/dist/plugins/git.d.ts +10 -0
  63. package/dist/plugins/git.js +70 -0
  64. package/dist/plugins/json-schema.d.ts +10 -0
  65. package/dist/plugins/json-schema.js +59 -0
  66. package/dist/plugins/with-loader/index.d.ts +61 -0
  67. package/dist/plugins/with-loader/index.js +6 -0
  68. package/dist/plugins/with-loader/webpack.d.ts +27 -0
  69. package/dist/plugins/with-loader/webpack.js +12 -0
  70. package/dist/vite/index.d.ts +33 -0
  71. package/dist/vite/index.js +61 -0
  72. package/dist/vite-QCUPZHHB.js +32 -0
  73. package/package.json +104 -36
  74. package/dist/internal.d.ts +0 -114
  75. package/dist/internal.js +0 -420
package/dist/bin.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/bin.js ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/bin.ts
4
+ import { existsSync } from "fs";
5
+ async function start() {
6
+ const [configPath, outDir] = process.argv.slice(2);
7
+ const isNext = existsSync("next.config.js") || existsSync("next.config.mjs") || existsSync("next.config.mts") || existsSync("next.config.ts");
8
+ if (isNext) {
9
+ const { createStandaloneCore } = await import("./next/index.js");
10
+ const core = await createStandaloneCore({ configPath, outDir });
11
+ await core.emit({ write: true });
12
+ } else {
13
+ const { createStandaloneCore } = await import("./vite/index.js");
14
+ const core = await createStandaloneCore({ configPath, outDir });
15
+ await core.emit({ write: true });
16
+ }
17
+ }
18
+ void start();
@@ -0,0 +1,8 @@
1
+ import {
2
+ buildMDX
3
+ } from "./chunk-OQQNA7L7.js";
4
+ import "./chunk-VWJKRQZR.js";
5
+ import "./chunk-JBZTQ55D.js";
6
+ export {
7
+ buildMDX
8
+ };
@@ -0,0 +1,16 @@
1
+ import { BunPlugin } from 'bun';
2
+ import { C as CoreOptions } from '../core-Bo8KaWQz.js';
3
+ import 'chokidar';
4
+ import '@mdx-js/mdx';
5
+ import 'vfile';
6
+ import '@standard-schema/spec';
7
+ import 'unified';
8
+ import 'mdast';
9
+ import 'vite';
10
+ import 'next';
11
+ import 'node:module';
12
+
13
+ type ContentPluginOptions = Partial<CoreOptions>;
14
+ declare function createContentPlugin(options?: ContentPluginOptions): BunPlugin;
15
+
16
+ export { type ContentPluginOptions, createContentPlugin };
@@ -0,0 +1,37 @@
1
+ import {
2
+ buildConfig
3
+ } from "../chunk-W6HENTK7.js";
4
+ import {
5
+ Core
6
+ } from "../chunk-NRZ4GE5O.js";
7
+ import "../chunk-MT7RY65Y.js";
8
+ import "../chunk-JBZTQ55D.js";
9
+
10
+ // src/bun/index.ts
11
+ import { pathToFileURL } from "url";
12
+ function createContentPlugin(options = {}) {
13
+ const {
14
+ outDir = Core.defaultOptions.outDir,
15
+ configPath = Core.defaultOptions.configPath
16
+ } = options;
17
+ return {
18
+ name: "fuma-content",
19
+ async setup(build) {
20
+ const importPath = pathToFileURL(configPath).href;
21
+ const core = new Core({
22
+ outDir,
23
+ configPath
24
+ });
25
+ await core.init({
26
+ config: buildConfig(await import(importPath))
27
+ });
28
+ const ctx = core.getPluginContext();
29
+ for (const plugin of core.getPlugins(true)) {
30
+ await plugin.bun?.build?.call(ctx, build);
31
+ }
32
+ }
33
+ };
34
+ }
35
+ export {
36
+ createContentPlugin
37
+ };
@@ -0,0 +1,40 @@
1
+ // src/plugins/with-loader/bun.ts
2
+ import { parse } from "querystring";
3
+ import { readFileSync } from "fs";
4
+ function toBun(test = /.+/, loader) {
5
+ function toResult(output) {
6
+ if (!output) return;
7
+ return {
8
+ contents: output.code,
9
+ loader: "js"
10
+ };
11
+ }
12
+ return (build) => {
13
+ build.onLoad({ filter: test }, (args) => {
14
+ const [filePath, query = ""] = args.path.split("?", 2);
15
+ const input = {
16
+ async getSource() {
17
+ return Bun.file(filePath).text();
18
+ },
19
+ query: parse(query),
20
+ filePath,
21
+ development: false,
22
+ compiler: {
23
+ addDependency() {
24
+ }
25
+ }
26
+ };
27
+ if (loader.bun?.load) {
28
+ return loader.bun.load(readFileSync(filePath).toString(), input);
29
+ }
30
+ const result = loader.load(input);
31
+ if (result instanceof Promise) {
32
+ return result.then(toResult);
33
+ }
34
+ return toResult(result);
35
+ });
36
+ };
37
+ }
38
+ export {
39
+ toBun
40
+ };
@@ -0,0 +1,39 @@
1
+ // src/collections/runtime/store.ts
2
+ var SimpleCollectionStore = class {
3
+ dataMap;
4
+ dataList;
5
+ constructor(input) {
6
+ this.dataMap = input;
7
+ this.dataList = Array.from(input.values());
8
+ }
9
+ get(id) {
10
+ return this.dataMap.get(id);
11
+ }
12
+ list() {
13
+ return this.dataList;
14
+ }
15
+ $data(_cast) {
16
+ return this;
17
+ }
18
+ /**
19
+ * in-place transformation on all data
20
+ */
21
+ transform(fn) {
22
+ this.dataList.length = 0;
23
+ const dataMap = this.dataMap;
24
+ const dataList = this.dataList;
25
+ for (const [k, v] of this.dataMap) {
26
+ const updated = fn(v);
27
+ dataMap.set(k, updated);
28
+ dataList.push(updated);
29
+ }
30
+ return this;
31
+ }
32
+ get $inferData() {
33
+ return void 0;
34
+ }
35
+ };
36
+
37
+ export {
38
+ SimpleCollectionStore
39
+ };
@@ -0,0 +1,16 @@
1
+ // src/collections/index.ts
2
+ function createCollection(info, init) {
3
+ return {
4
+ name: "",
5
+ handlers: {},
6
+ init(options) {
7
+ this.name = options.name;
8
+ init(this, options);
9
+ },
10
+ typeInfo: info
11
+ };
12
+ }
13
+
14
+ export {
15
+ createCollection
16
+ };
@@ -0,0 +1,24 @@
1
+ // src/collections/handlers/fs.ts
2
+ import picomatch from "picomatch";
3
+ import path from "path";
4
+ function buildFileHandler({ workspace }, config, supportedFormats) {
5
+ const patterns = config.files ?? [`**/*.{${supportedFormats.join(",")}}`];
6
+ let matcher;
7
+ return {
8
+ patterns,
9
+ dir: workspace ? path.resolve(workspace.dir, config.dir) : config.dir,
10
+ isFileSupported(filePath) {
11
+ return supportedFormats.some((format) => filePath.endsWith(`.${format}`));
12
+ },
13
+ hasFile(filePath) {
14
+ if (!this.isFileSupported(filePath)) return false;
15
+ const relativePath = path.relative(this.dir, filePath);
16
+ if (relativePath.startsWith(`..${path.sep}`)) return false;
17
+ return (matcher ??= picomatch(patterns))(relativePath);
18
+ }
19
+ };
20
+ }
21
+
22
+ export {
23
+ buildFileHandler
24
+ };
@@ -0,0 +1,33 @@
1
+ // src/plugins/with-loader/index.ts
2
+ function withLoader(plugin, { test, createLoader }) {
3
+ let loader;
4
+ return {
5
+ bun: {
6
+ async build(build) {
7
+ const { toBun } = await import("./bun-DMNX4PBC.js");
8
+ toBun(test, await (loader ??= createLoader.call(this, "bun")))(build);
9
+ }
10
+ },
11
+ node: {
12
+ async createLoad() {
13
+ const { toNode } = await import("./node-DCMYL4DL.js");
14
+ return toNode(test, await (loader ??= createLoader.call(this, "node")));
15
+ }
16
+ },
17
+ vite: {
18
+ async createPlugin() {
19
+ const { toVite } = await import("./vite-QCUPZHHB.js");
20
+ return toVite(
21
+ plugin.name,
22
+ test,
23
+ await (loader ??= createLoader.call(this, "vite"))
24
+ );
25
+ }
26
+ },
27
+ ...plugin
28
+ };
29
+ }
30
+
31
+ export {
32
+ withLoader
33
+ };
@@ -0,0 +1,38 @@
1
+ // src/config/dynamic.ts
2
+ import fs from "fs/promises";
3
+ function createDynamicCore({
4
+ core,
5
+ buildConfig,
6
+ mode
7
+ }) {
8
+ let prev;
9
+ async function getConfigHash() {
10
+ if (mode === "production") return "static";
11
+ const stats = await fs.stat(core.getOptions().configPath).catch(() => {
12
+ throw new Error("Cannot find config file");
13
+ });
14
+ return stats.mtime.getTime().toString();
15
+ }
16
+ return {
17
+ async getCore() {
18
+ const hash = await getConfigHash();
19
+ if (!prev || hash !== prev.hash) {
20
+ prev = {
21
+ hash,
22
+ init: (async () => {
23
+ const { loadConfig } = await import("./load-from-file-HL2VEY3M.js");
24
+ await core.init({
25
+ config: loadConfig(core, buildConfig)
26
+ });
27
+ })()
28
+ };
29
+ }
30
+ await prev.init;
31
+ return core;
32
+ }
33
+ };
34
+ }
35
+
36
+ export {
37
+ createDynamicCore
38
+ };
@@ -0,0 +1,30 @@
1
+ // src/utils/async-cache.ts
2
+ function createCache(store = /* @__PURE__ */ new Map()) {
3
+ return {
4
+ cached(key, fn) {
5
+ let cached = store.get(key);
6
+ if (cached) return cached;
7
+ cached = fn();
8
+ if (cached instanceof Promise) {
9
+ cached = cached.then((out) => {
10
+ if (store.has(key)) {
11
+ store.set(key, out);
12
+ }
13
+ return out;
14
+ });
15
+ }
16
+ store.set(key, cached);
17
+ return cached;
18
+ },
19
+ invalidate(key) {
20
+ store.delete(key);
21
+ },
22
+ $value() {
23
+ return this;
24
+ }
25
+ };
26
+ }
27
+
28
+ export {
29
+ createCache
30
+ };
@@ -0,0 +1,104 @@
1
+ import {
2
+ fumaMatter
3
+ } from "./chunk-VWJKRQZR.js";
4
+
5
+ // src/collections/mdx/loader.ts
6
+ import { z } from "zod";
7
+ import fs from "fs/promises";
8
+ import path from "path";
9
+ import { createHash } from "crypto";
10
+ var querySchema = z.object({
11
+ only: z.literal(["frontmatter", "all"]).default("all"),
12
+ collection: z.string().optional(),
13
+ workspace: z.string().optional()
14
+ }).loose();
15
+ var cacheEntry = z.object({
16
+ code: z.string(),
17
+ map: z.any().optional(),
18
+ hash: z.string().optional()
19
+ });
20
+ function createMdxLoader({ getCore }) {
21
+ return {
22
+ async load({
23
+ getSource,
24
+ development: isDevelopment,
25
+ query,
26
+ compiler,
27
+ filePath
28
+ }) {
29
+ let core = await getCore();
30
+ const value = await getSource();
31
+ const matter = fumaMatter(value);
32
+ const {
33
+ collection: collectionName,
34
+ workspace,
35
+ only
36
+ } = querySchema.parse(query);
37
+ if (workspace) {
38
+ core = core.getWorkspaces().get(workspace) ?? core;
39
+ }
40
+ let after;
41
+ const { experimentalBuildCache = false } = core.getConfig();
42
+ if (!isDevelopment && experimentalBuildCache) {
43
+ const cacheDir = experimentalBuildCache;
44
+ const cacheKey = `${collectionName ?? "global"}_${generateCacheHash(filePath)}`;
45
+ const cached = await fs.readFile(path.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
46
+ if (cached && cached.hash === generateCacheHash(value)) return cached;
47
+ after = async () => {
48
+ await fs.mkdir(cacheDir, { recursive: true });
49
+ await fs.writeFile(
50
+ path.join(cacheDir, cacheKey),
51
+ JSON.stringify({
52
+ ...out,
53
+ hash: generateCacheHash(value)
54
+ })
55
+ );
56
+ };
57
+ }
58
+ const collection = collectionName ? core.getCollection(collectionName) : void 0;
59
+ const handler = collection?.handlers.mdx;
60
+ if (collection && handler?.frontmatter) {
61
+ matter.data = await handler.frontmatter.call(
62
+ { collection, filePath, source: value },
63
+ matter.data
64
+ );
65
+ }
66
+ if (only === "frontmatter") {
67
+ return {
68
+ code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
69
+ map: null
70
+ };
71
+ }
72
+ const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
73
+ const { buildMDX } = await import("./build-mdx-I4NROXCF.js");
74
+ const compiled = await buildMDX(core, collection, {
75
+ isDevelopment,
76
+ source: "\n".repeat(lineOffset) + matter.content,
77
+ filePath,
78
+ frontmatter: matter.data,
79
+ _compiler: compiler,
80
+ environment: "bundler"
81
+ });
82
+ const out = {
83
+ code: String(compiled.value),
84
+ map: compiled.map
85
+ };
86
+ await after?.();
87
+ return out;
88
+ }
89
+ };
90
+ }
91
+ function generateCacheHash(input) {
92
+ return createHash("md5").update(input).digest("hex");
93
+ }
94
+ function countLines(s) {
95
+ let num = 0;
96
+ for (const c of s) {
97
+ if (c === "\n") num++;
98
+ }
99
+ return num;
100
+ }
101
+
102
+ export {
103
+ createMdxLoader
104
+ };
@@ -0,0 +1,40 @@
1
+ import {
2
+ buildConfig
3
+ } from "./chunk-W6HENTK7.js";
4
+
5
+ // src/config/load-from-file.ts
6
+ import { pathToFileURL } from "url";
7
+ async function compileConfig(core) {
8
+ const { build } = await import("esbuild");
9
+ const { configPath, outDir } = core.getOptions();
10
+ const transformed = await build({
11
+ entryPoints: [{ in: configPath, out: "content.config" }],
12
+ bundle: true,
13
+ outdir: outDir,
14
+ target: "node20",
15
+ write: true,
16
+ platform: "node",
17
+ format: "esm",
18
+ packages: "external",
19
+ outExtension: {
20
+ ".js": ".mjs"
21
+ },
22
+ allowOverwrite: true
23
+ });
24
+ if (transformed.errors.length > 0) {
25
+ throw new Error("failed to compile configuration file");
26
+ }
27
+ }
28
+ async function loadConfig(core, build = false) {
29
+ if (build) await compileConfig(core);
30
+ const url = pathToFileURL(core.getCompiledConfigPath());
31
+ url.searchParams.set("hash", Date.now().toString());
32
+ const config = import(url.href).then(
33
+ (loaded) => buildConfig(loaded)
34
+ );
35
+ return await config;
36
+ }
37
+
38
+ export {
39
+ loadConfig
40
+ };
@@ -0,0 +1,167 @@
1
+ import {
2
+ createCache
3
+ } from "./chunk-JBZTQ55D.js";
4
+
5
+ // src/utils/code-generator.ts
6
+ import path from "path";
7
+ import { glob } from "tinyglobby";
8
+ function importInfo() {
9
+ return {
10
+ named: /* @__PURE__ */ new Map(),
11
+ namespaces: /* @__PURE__ */ new Set(),
12
+ isUsed: /* @__PURE__ */ new Set()
13
+ };
14
+ }
15
+ var CodeGenerator = class {
16
+ lines = [];
17
+ globCache;
18
+ // specifier -> imported members/info
19
+ importInfos = /* @__PURE__ */ new Map();
20
+ eagerImportId = 0;
21
+ options;
22
+ constructor({
23
+ target = "default",
24
+ jsExtension = false,
25
+ globCache = /* @__PURE__ */ new Map(),
26
+ outDir = ""
27
+ }) {
28
+ this.options = {
29
+ target,
30
+ jsExtension,
31
+ globCache,
32
+ outDir
33
+ };
34
+ this.globCache = createCache(globCache);
35
+ }
36
+ addNamespaceImport(namespace, specifier, types = false) {
37
+ const info = this.importInfos.get(specifier) ?? importInfo();
38
+ this.importInfos.set(specifier, info);
39
+ if (!types) info.isUsed.add(namespace);
40
+ info.namespaces.add(namespace);
41
+ }
42
+ addNamedImport(names, specifier, types = false) {
43
+ const info = this.importInfos.get(specifier) ?? importInfo();
44
+ this.importInfos.set(specifier, info);
45
+ for (const name of names) {
46
+ const [memberName, importName = memberName] = name.split(/\s+as\s+/, 2);
47
+ info.named.set(importName, memberName);
48
+ if (!types) info.isUsed.add(importName);
49
+ }
50
+ }
51
+ push(...insert) {
52
+ this.lines.push(...insert);
53
+ }
54
+ async pushAsync(insert) {
55
+ for (const line of await Promise.all(insert)) {
56
+ if (line === void 0) continue;
57
+ this.lines.push(line);
58
+ }
59
+ }
60
+ async generateGlobImport(patterns, options) {
61
+ if (this.options.target === "vite") {
62
+ return this.generateViteGlobImport(patterns, options);
63
+ }
64
+ return this.generateNodeGlobImport(patterns, options);
65
+ }
66
+ generateViteGlobImport(patterns, { base, ...rest }) {
67
+ patterns = (typeof patterns === "string" ? [patterns] : patterns).map(
68
+ normalizeViteGlobPath
69
+ );
70
+ return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(
71
+ {
72
+ base: normalizeViteGlobPath(path.relative(this.options.outDir, base)),
73
+ ...rest
74
+ },
75
+ null,
76
+ 2
77
+ )})`;
78
+ }
79
+ async generateNodeGlobImport(patterns, { base, eager = false, query = {}, import: importName }) {
80
+ const files = await this.globCache.cached(
81
+ JSON.stringify({ patterns, base }),
82
+ () => glob(patterns, {
83
+ cwd: base
84
+ })
85
+ );
86
+ let code = "{";
87
+ for (const item of files) {
88
+ const fullPath = path.join(base, item);
89
+ const searchParams = new URLSearchParams();
90
+ for (const [k, v] of Object.entries(query)) {
91
+ if (v !== void 0) searchParams.set(k, v);
92
+ }
93
+ const importPath = `${this.formatImportPath(fullPath)}?${searchParams.toString()}`;
94
+ if (eager) {
95
+ const name = `__fd_glob_${this.eagerImportId++}`;
96
+ this.lines.unshift(
97
+ importName ? `import { ${importName} as ${name} } from ${JSON.stringify(importPath)}` : `import * as ${name} from ${JSON.stringify(importPath)}`
98
+ );
99
+ code += `${JSON.stringify(item)}: ${name}, `;
100
+ } else {
101
+ let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(importPath)})`;
102
+ if (importName) {
103
+ line += `.then(mod => mod.${importName})`;
104
+ }
105
+ code += `${line}, `;
106
+ }
107
+ }
108
+ code += "}";
109
+ return code;
110
+ }
111
+ formatImportPath(file) {
112
+ const ext = path.extname(file);
113
+ let filename;
114
+ if (ext === ".ts") {
115
+ filename = file.substring(0, file.length - ext.length);
116
+ if (this.options.jsExtension) filename += ".js";
117
+ } else {
118
+ filename = file;
119
+ }
120
+ const importPath = slash(path.relative(this.options.outDir, filename));
121
+ return importPath.startsWith(".") ? importPath : `./${importPath}`;
122
+ }
123
+ toString() {
124
+ const final = ["// @ts-nocheck"];
125
+ if (this.options.target === "vite") {
126
+ final.push('/// <reference types="vite/client" />');
127
+ }
128
+ for (const [specifier, info] of this.importInfos) {
129
+ const { namespaces, named, isUsed } = info;
130
+ for (const namespace of namespaces) {
131
+ final.push(
132
+ isUsed.has(namespace) ? `import * as ${namespace} from "${specifier}";` : `import type * as ${namespace} from "${specifier}";`
133
+ );
134
+ }
135
+ const namedImports = [];
136
+ for (const [importName, memberName] of named) {
137
+ const item = importName === memberName ? importName : `${memberName} as ${importName}`;
138
+ namedImports.push(isUsed.has(importName) ? item : `type ${item}`);
139
+ }
140
+ if (namedImports.length > 0) {
141
+ final.push(
142
+ `import { ${namedImports.join(", ")} } from "${specifier}";`
143
+ );
144
+ }
145
+ }
146
+ final.push(...this.lines);
147
+ return final.join("\n");
148
+ }
149
+ };
150
+ function normalizeViteGlobPath(file) {
151
+ file = slash(file);
152
+ if (file.startsWith("./")) return file;
153
+ if (file.startsWith("/")) return `.${file}`;
154
+ return `./${file}`;
155
+ }
156
+ function slash(path2) {
157
+ const isExtendedLengthPath = path2.startsWith("\\\\?\\");
158
+ if (isExtendedLengthPath) {
159
+ return path2;
160
+ }
161
+ return path2.replaceAll("\\", "/");
162
+ }
163
+
164
+ export {
165
+ CodeGenerator,
166
+ slash
167
+ };