@kubb/ast 5.25.0 → 5.25.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/dist/{file-3gsgXreK.js → combineFileMembers-DJHNAZBN.js} +204 -161
- package/dist/combineFileMembers-DJHNAZBN.js.map +1 -0
- package/dist/{file-D73XubVb.cjs → combineFileMembers-DmmuOmY8.cjs} +216 -160
- package/dist/combineFileMembers-DmmuOmY8.cjs.map +1 -0
- package/dist/factory.cjs +6 -6
- package/dist/factory.d.cts +2 -2
- package/dist/factory.d.ts +2 -2
- package/dist/factory.js +2 -2
- package/dist/{file-CMHRNuMX.d.cts → file-DJqd2j3y.d.cts} +3 -1
- package/dist/{file-D67ITWja.d.ts → file-Dg70hXm3.d.ts} +3 -1
- package/dist/{file-1YtTOZeL.js → file-HwCmj--S.js} +5 -3
- package/dist/file-HwCmj--S.js.map +1 -0
- package/dist/{file-azmmZwDb.cjs → file-z3xToonr.cjs} +11 -9
- package/dist/file-z3xToonr.cjs.map +1 -0
- package/dist/file.cjs +7 -5
- package/dist/file.d.cts +2 -2
- package/dist/file.d.ts +2 -2
- package/dist/file.js +3 -3
- package/dist/{index-DNZgWmNq.d.cts → index-BjmAaymt.d.cts} +1 -1
- package/dist/{index-CIUD99Ft.d.ts → index-Br4bwEnS.d.ts} +2 -2
- package/dist/{index-CGmrJThc.d.ts → index-Bz33tfQo.d.ts} +1 -1
- package/dist/{index-Bcxj7FqZ.d.cts → index-C5SXJAtZ.d.cts} +2 -2
- package/dist/{index-bkTCYnZj.d.cts → index-CCUB1hoV.d.cts} +1 -1
- package/dist/{index-C-nsgwuD.d.ts → index-D3yqgtiN.d.ts} +2 -2
- package/dist/{index-84453BaS.d.cts → index-DBKL6vyC.d.cts} +16 -3
- package/dist/{index-BvdIGsVr.d.cts → index-DNDNDzyJ.d.cts} +2 -2
- package/dist/{index-C7U9EiIP.d.ts → index-DXdwkq7X.d.ts} +2 -2
- package/dist/{index-B3o1AkNE.d.ts → index-MzcNxet1.d.ts} +1 -1
- package/dist/{index-DR9ahJ-x.d.cts → index-OfWkiJ5O.d.cts} +2 -2
- package/dist/{index-BFwAhPp8.d.ts → index-VPq6RwTm.d.ts} +16 -3
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/macro-3uGSg-ic.js.map +1 -1
- package/dist/macro-Ywn4-0s5.cjs.map +1 -1
- package/dist/macro.d.cts +1 -1
- package/dist/macro.d.ts +1 -1
- package/dist/mediaType-BbIfudh0.cjs.map +1 -1
- package/dist/mediaType-DXQCNYdM.js.map +1 -1
- package/dist/mediaType.d.cts +2 -2
- package/dist/mediaType.d.ts +2 -2
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/{nodes-BdZfapPI.cjs → nodes-TtDfZ9qf.cjs} +12 -12
- package/dist/{nodes-BdZfapPI.cjs.map → nodes-TtDfZ9qf.cjs.map} +1 -1
- package/dist/{nodes-D9nwroV5.js → nodes-u9i-tqFp.js} +2 -2
- package/dist/{nodes-D9nwroV5.js.map → nodes-u9i-tqFp.js.map} +1 -1
- package/dist/promise-B3YkZ4C8.js.map +1 -1
- package/dist/promise-DScaykew.cjs.map +1 -1
- package/dist/schema-0YJZqRXb.cjs.map +1 -1
- package/dist/schema-BvUrXIoX.js.map +1 -1
- package/dist/schema-CC008xgK.js.map +1 -1
- package/dist/schema-DfLGJ-oh.cjs.map +1 -1
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/{visitor-VYLe7Q4m.d.cts → visitor-BN5QJX7-.d.cts} +1 -1
- package/dist/{visitor-CqI8T9Qa.d.ts → visitor-BNGMMmpe.d.ts} +1 -1
- package/dist/visitor-DA5yfOJz.js.map +1 -1
- package/dist/visitor-DhuKS-7x.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/file-1YtTOZeL.js.map +0 -1
- package/dist/file-3gsgXreK.js.map +0 -1
- package/dist/file-D73XubVb.cjs.map +0 -1
- package/dist/file-azmmZwDb.cjs.map +0 -1
|
@@ -605,6 +605,7 @@ type ExportInput = Omit<ExportNode, 'kind'>;
|
|
|
605
605
|
/**
|
|
606
606
|
* Creates an `ImportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
|
|
607
607
|
* `isTypeOnly` that differs from the one `names` gives overrides it, so `{ ...imp, isTypeOnly: true }` still works.
|
|
608
|
+
* Fields a spread copies over unchanged are not overrides, so `{ ...imp, names }` uses the new `names`.
|
|
608
609
|
*
|
|
609
610
|
* @example Named import
|
|
610
611
|
* ```ts
|
|
@@ -615,7 +616,8 @@ type ExportInput = Omit<ExportNode, 'kind'>;
|
|
|
615
616
|
declare function createImport(input: ImportInput): ImportNode;
|
|
616
617
|
/**
|
|
617
618
|
* Creates an `ExportNode`. A node built from `names` also gets the deprecated fields. A deprecated `name` or
|
|
618
|
-
* `isTypeOnly` that differs from the one `names` gives overrides it.
|
|
619
|
+
* `isTypeOnly` that differs from the one `names` gives overrides it. Fields a spread copies over unchanged are not
|
|
620
|
+
* overrides, so `{ ...exp, names }` uses the new `names`.
|
|
619
621
|
*
|
|
620
622
|
* @example Named export
|
|
621
623
|
* ```ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BYyVTPww.js";
|
|
2
|
+
import { c as getSpace, i as createImport, l as isExported, r as createFile, s as getNames, t as getRelativePath } from "./combineFileMembers-DJHNAZBN.js";
|
|
2
3
|
import { t as nodeKinds } from "./constants-UorsTFsa.js";
|
|
3
|
-
import { n as createFile, o as getNames, r as createImport, s as getSpace } from "./file-3gsgXreK.js";
|
|
4
4
|
import { n as getNodeText, t as CODE_NODE_TEXT_FIELDS } from "./nodeText-DFak5VpX.js";
|
|
5
5
|
// src/utils/inline.ts
|
|
6
6
|
/**
|
|
@@ -136,9 +136,11 @@ function rewriteNodes(nodes, rewrite) {
|
|
|
136
136
|
// src/file/index.ts
|
|
137
137
|
var file_exports = /* @__PURE__ */ __exportAll({
|
|
138
138
|
getNames: () => getNames,
|
|
139
|
+
getRelativePath: () => getRelativePath,
|
|
139
140
|
getSpace: () => getSpace,
|
|
140
|
-
inline: () => inlineFiles
|
|
141
|
+
inline: () => inlineFiles,
|
|
142
|
+
isExported: () => isExported
|
|
141
143
|
});
|
|
142
144
|
export { inlineFiles as n, file_exports as t };
|
|
143
145
|
|
|
144
|
-
//# sourceMappingURL=file-
|
|
146
|
+
//# sourceMappingURL=file-HwCmj--S.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-HwCmj--S.js","names":[],"sources":["../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { CodeNode } from '../nodes/code.ts'\nimport { createFile, createImport } from '../nodes/file.ts'\nimport type { FileNode, ImportNode, SourceNode } from '../nodes/file.ts'\nimport { getNames } from './moduleNames.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\nexport type InlineFilesResult = {\n /**\n * Files that imported an inline name, rewritten to hold its definition.\n */\n files: Array<FileNode>\n /**\n * Paths of the virtual files, which are not written.\n */\n virtualPaths: Array<string>\n /**\n * One message per name that could not be inlined.\n */\n problems: Array<{ path: string; message: string }>\n}\n\ntype Definition = { expression: string; imports: Array<ImportNode> }\n\n/**\n * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.\n */\nexport type InlineLanguage = {\n /**\n * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.\n */\n replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string\n /**\n * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.\n */\n wrap(expression: string): string\n}\n\nexport type InlineFilesOptions = {\n /**\n * The inline support for a file's language, or `undefined` when it has none.\n */\n language: (file: FileNode) => InlineLanguage | undefined\n}\n\n/**\n * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's\n * declaration, until no inline names are left. The definitions' own imports move to the importing file.\n */\nexport function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult {\n const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineFilesResult = { files: [], virtualPaths: [...virtualFiles.keys()], problems: [] }\n if (virtualFiles.size === 0) return result\n\n // `null` marks a definition that is being resolved, so a name that reaches itself is a cycle.\n const definitions = new Map<string, Definition | null>()\n\n function define(path: string, name: string, from: string, lang: InlineLanguage): Definition | undefined {\n const key = `${path}\\0${name}`\n if (definitions.has(key)) {\n const definition = definitions.get(key)\n if (definition === null) result.problems.push({ path: from, message: `\"${name}\" from \"${path}\" is defined in terms of itself.` })\n return definition ?? undefined\n }\n\n const file = virtualFiles.get(path)!\n const expression = bodyOf(file.sources.find((source) => source.name === name))\n if (expression === undefined) {\n result.problems.push({ path: from, message: `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.` })\n return undefined\n }\n\n definitions.set(key, null)\n const imports: Array<ImportNode> = []\n const { text, used } = replaceNames(expression, file, lang, imports)\n imports.push(...file.imports.flatMap((imp) => (virtualFiles.has(imp.path) ? [] : pickNames(imp, used))))\n\n const definition = { expression: text, imports }\n definitions.set(key, definition)\n return definition\n }\n\n // Pushes the imports the replaced definitions need onto `imports`; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, imports: Array<ImportNode>) {\n const used = new Set<string>()\n const text = lang.replaceIdentifiers(input, (local) => {\n const target = findTarget(file, local)\n const definition = target && define(target.path, target.name, file.path, lang)\n if (!definition) {\n used.add(local)\n return undefined\n }\n\n imports.push(...definition.imports)\n return lang.wrap(definition.expression)\n })\n\n return { text, used }\n }\n\n function findTarget(file: FileNode, local: string): { path: string; name: string } | undefined {\n if (virtualFiles.has(file.path) && file.sources.some((source) => source.name === local)) return { path: file.path, name: local }\n\n for (const imp of file.imports) {\n const item = virtualFiles.has(imp.path) && getNames(imp).find((item) => (item.alias ?? item.name) === local)\n if (item) return { path: imp.path, name: item.name }\n }\n\n return undefined\n }\n\n for (const file of files) {\n if (virtualFiles.has(file.path) || !file.imports.some((imp) => virtualFiles.has(imp.path))) continue\n\n const lang = language(file)\n if (!lang) {\n result.problems.push({ path: file.path, message: `No parser for \"${file.extname}\" files supports inline sources.` })\n continue\n }\n\n const carried: Array<ImportNode> = []\n const sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carried).text) }))\n\n // A carried import keeps its target; `root` moves to the importing file so the relative path is computed from there.\n const imports = [...file.imports.filter((imp) => !virtualFiles.has(imp.path)), ...carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))]\n\n result.files.push(createFile({ ...file, sources, imports }))\n }\n\n return result\n}\n\n// A file of only deprecated per-source `inline` counts as inline too.\nfunction isInlineFile(file: FileNode): boolean {\n return !!file.inline || (file.sources.length > 0 && file.sources.every((source) => source.inline))\n}\n\n// The right-hand side of a `Const` or `Type`. A function body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf(source: SourceNode | undefined): string | undefined {\n if (source?.inline) return source.inline.expression\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return undefined\n return getNodeText(node.nodes) || undefined\n}\n\nfunction pickNames(imp: ImportNode, used: ReadonlySet<string>): Array<ImportNode> {\n const names = getNames(imp).filter((item) => used.has(item.alias ?? item.name))\n return names.length > 0 ? [createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names })] : []\n}\n\n// Rewrites the string fields `getNodeText` reads; JSDoc stays as written.\nfunction rewriteNodes(nodes: Array<CodeNode> | undefined, rewrite: (text: string) => string): Array<CodeNode> | undefined {\n return nodes?.map((node): CodeNode => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return rewrite(node) as unknown as CodeNode\n if (node.kind === nodeKinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const field of CODE_NODE_TEXT_FIELDS[node.kind] ?? []) {\n const value = next[field]\n if (Array.isArray(value)) next[field] = value.map(rewrite)\n if (typeof value === 'string' && value) next[field] = rewrite(value)\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite)\n return next as unknown as CodeNode\n })\n}\n","export { getRelativePath } from '../utils/combineFileMembers.ts'\nexport { inlineFiles as inline } from '../utils/inline.ts'\nexport { getNames, getSpace, isExported } from '../utils/moduleNames.ts'\n"],"mappings":";;;;;;;;;AAiDA,SAAgB,YAAY,OAAgC,EAAE,YAAmD;CAC/G,MAAM,eAAe,IAAI,IAAI,MAAM,OAAO,YAAY,CAAC,CAAC,KAAK,SAAS,CAAC,KAAK,MAAM,IAAI,CAAC,CAAC;CACxF,MAAM,SAA4B;EAAE,OAAO,CAAC;EAAG,cAAc,CAAC,GAAG,aAAa,KAAK,CAAC;EAAG,UAAU,CAAC;CAAE;CACpG,IAAI,aAAa,SAAS,GAAG,OAAO;CAGpC,MAAM,8BAAc,IAAI,IAA+B;CAEvD,SAAS,OAAO,MAAc,MAAc,MAAc,MAA8C;EACtG,MAAM,MAAM,GAAG,KAAK,IAAI;EACxB,IAAI,YAAY,IAAI,GAAG,GAAG;GACxB,MAAM,aAAa,YAAY,IAAI,GAAG;GACtC,IAAI,eAAe,MAAM,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI,KAAK,UAAU,KAAK;GAAkC,CAAC;GAChI,OAAO,cAAc,KAAA;EACvB;EAEA,MAAM,OAAO,aAAa,IAAI,IAAI;EAClC,MAAM,aAAa,OAAO,KAAK,QAAQ,MAAM,WAAW,OAAO,SAAS,IAAI,CAAC;EAC7E,IAAI,eAAe,KAAA,GAAW;GAC5B,OAAO,SAAS,KAAK;IAAE,MAAM;IAAM,SAAS,IAAI,KAAK,sBAAsB,KAAK;GAA+D,CAAC;GAChJ;EACF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Aa;EAAE,MAAM,IAAI;EAAM,GAAI,IAAI,QAAQ,OAAO,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;EAAI;CAAM,CAAC,CAAC,IAAI,CAAC;AAC1H;AAGA,SAAS,aAAa,OAAoC,SAAgE;CACxH,OAAO,OAAO,KAAK,SAAmB;EAEpC,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ,IAAI;EACjD,IAAI,KAAK,SAAS,UAAU,OAAO,OAAO;EAE1C,MAAM,OAAO,EAAE,GAAG,KAAK;EACvB,KAAK,MAAM,SAAS,sBAAsB,KAAK,SAAS,CAAC,GAAG;GAC1D,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,MAAM,IAAI,OAAO;GACzD,IAAI,OAAO,UAAU,YAAY,OAAO,KAAK,SAAS,QAAQ,KAAK;EACrE;EACA,IAAI,WAAW,QAAQ,KAAK,OAAO,KAAK,QAAQ,aAAa,KAAK,OAAO,OAAO;EAChF,OAAO;CACT,CAAC;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
|
|
2
|
+
const require_combineFileMembers = require("./combineFileMembers-DmmuOmY8.cjs");
|
|
2
3
|
const require_constants = require("./constants-BCRkFAiy.cjs");
|
|
3
|
-
const require_file = require("./file-D73XubVb.cjs");
|
|
4
4
|
const require_nodeText = require("./nodeText-DH4dLGUb.cjs");
|
|
5
5
|
// src/utils/inline.ts
|
|
6
6
|
/**
|
|
@@ -68,7 +68,7 @@ function inlineFiles(files, { language }) {
|
|
|
68
68
|
name: local
|
|
69
69
|
};
|
|
70
70
|
for (const imp of file.imports) {
|
|
71
|
-
const item = virtualFiles.has(imp.path) &&
|
|
71
|
+
const item = virtualFiles.has(imp.path) && require_combineFileMembers.getNames(imp).find((item) => (item.alias ?? item.name) === local);
|
|
72
72
|
if (item) return {
|
|
73
73
|
path: imp.path,
|
|
74
74
|
name: item.name
|
|
@@ -94,7 +94,7 @@ function inlineFiles(files, { language }) {
|
|
|
94
94
|
...imp,
|
|
95
95
|
root: file.path
|
|
96
96
|
} : imp)];
|
|
97
|
-
result.files.push(
|
|
97
|
+
result.files.push(require_combineFileMembers.createFile({
|
|
98
98
|
...file,
|
|
99
99
|
sources,
|
|
100
100
|
imports
|
|
@@ -112,8 +112,8 @@ function bodyOf(source) {
|
|
|
112
112
|
return require_nodeText.getNodeText(node.nodes) || void 0;
|
|
113
113
|
}
|
|
114
114
|
function pickNames(imp, used) {
|
|
115
|
-
const names =
|
|
116
|
-
return names.length > 0 ? [
|
|
115
|
+
const names = require_combineFileMembers.getNames(imp).filter((item) => used.has(item.alias ?? item.name));
|
|
116
|
+
return names.length > 0 ? [require_combineFileMembers.createImport({
|
|
117
117
|
path: imp.path,
|
|
118
118
|
...imp.root != null ? { root: imp.root } : {},
|
|
119
119
|
names
|
|
@@ -135,9 +135,11 @@ function rewriteNodes(nodes, rewrite) {
|
|
|
135
135
|
}
|
|
136
136
|
// src/file/index.ts
|
|
137
137
|
var file_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
138
|
-
getNames: () =>
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
getNames: () => require_combineFileMembers.getNames,
|
|
139
|
+
getRelativePath: () => require_combineFileMembers.getRelativePath,
|
|
140
|
+
getSpace: () => require_combineFileMembers.getSpace,
|
|
141
|
+
inline: () => inlineFiles,
|
|
142
|
+
isExported: () => require_combineFileMembers.isExported
|
|
141
143
|
});
|
|
142
144
|
Object.defineProperty(exports, "file_exports", {
|
|
143
145
|
enumerable: true,
|
|
@@ -152,4 +154,4 @@ Object.defineProperty(exports, "inlineFiles", {
|
|
|
152
154
|
}
|
|
153
155
|
});
|
|
154
156
|
|
|
155
|
-
//# sourceMappingURL=file-
|
|
157
|
+
//# sourceMappingURL=file-z3xToonr.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-z3xToonr.cjs","names":["getNames","createFile","nodeKinds","getNodeText","createImport","CODE_NODE_TEXT_FIELDS"],"sources":["../src/utils/inline.ts","../src/file/index.ts"],"sourcesContent":["import { nodeKinds } from '../constants.ts'\nimport type { CodeNode } from '../nodes/code.ts'\nimport { createFile, createImport } from '../nodes/file.ts'\nimport type { FileNode, ImportNode, SourceNode } from '../nodes/file.ts'\nimport { getNames } from './moduleNames.ts'\nimport { CODE_NODE_TEXT_FIELDS, getNodeText } from './nodeText.ts'\n\nexport type InlineFilesResult = {\n /**\n * Files that imported an inline name, rewritten to hold its definition.\n */\n files: Array<FileNode>\n /**\n * Paths of the virtual files, which are not written.\n */\n virtualPaths: Array<string>\n /**\n * One message per name that could not be inlined.\n */\n problems: Array<{ path: string; message: string }>\n}\n\ntype Definition = { expression: string; imports: Array<ImportNode> }\n\n/**\n * The language-specific half of {@link inlineFiles}, supplied by the parser that prints the file.\n */\nexport type InlineLanguage = {\n /**\n * Swaps in what `replace` returns for every identifier in `text` that references a name, skipping strings and comments.\n */\n replaceIdentifiers(text: string, replace: (name: string) => string | undefined): string\n /**\n * Makes `expression` safe to put where a name was, such as `(A | B)` in TypeScript.\n */\n wrap(expression: string): string\n}\n\nexport type InlineFilesOptions = {\n /**\n * The inline support for a file's language, or `undefined` when it has none.\n */\n language: (file: FileNode) => InlineLanguage | undefined\n}\n\n/**\n * Replaces every name a file imports from a virtual file (one marked `inline`, so it is never written) with the body of that name's\n * declaration, until no inline names are left. The definitions' own imports move to the importing file.\n */\nexport function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult {\n const virtualFiles = new Map(files.filter(isInlineFile).map((file) => [file.path, file]))\n const result: InlineFilesResult = { files: [], virtualPaths: [...virtualFiles.keys()], problems: [] }\n if (virtualFiles.size === 0) return result\n\n // `null` marks a definition that is being resolved, so a name that reaches itself is a cycle.\n const definitions = new Map<string, Definition | null>()\n\n function define(path: string, name: string, from: string, lang: InlineLanguage): Definition | undefined {\n const key = `${path}\\0${name}`\n if (definitions.has(key)) {\n const definition = definitions.get(key)\n if (definition === null) result.problems.push({ path: from, message: `\"${name}\" from \"${path}\" is defined in terms of itself.` })\n return definition ?? undefined\n }\n\n const file = virtualFiles.get(path)!\n const expression = bodyOf(file.sources.find((source) => source.name === name))\n if (expression === undefined) {\n result.problems.push({ path: from, message: `\"${name}\" is imported from \"${path}\", which never writes it and has no inline definition for it.` })\n return undefined\n }\n\n definitions.set(key, null)\n const imports: Array<ImportNode> = []\n const { text, used } = replaceNames(expression, file, lang, imports)\n imports.push(...file.imports.flatMap((imp) => (virtualFiles.has(imp.path) ? [] : pickNames(imp, used))))\n\n const definition = { expression: text, imports }\n definitions.set(key, definition)\n return definition\n }\n\n // Pushes the imports the replaced definitions need onto `imports`; `used` holds the names left as they are.\n function replaceNames(input: string, file: FileNode, lang: InlineLanguage, imports: Array<ImportNode>) {\n const used = new Set<string>()\n const text = lang.replaceIdentifiers(input, (local) => {\n const target = findTarget(file, local)\n const definition = target && define(target.path, target.name, file.path, lang)\n if (!definition) {\n used.add(local)\n return undefined\n }\n\n imports.push(...definition.imports)\n return lang.wrap(definition.expression)\n })\n\n return { text, used }\n }\n\n function findTarget(file: FileNode, local: string): { path: string; name: string } | undefined {\n if (virtualFiles.has(file.path) && file.sources.some((source) => source.name === local)) return { path: file.path, name: local }\n\n for (const imp of file.imports) {\n const item = virtualFiles.has(imp.path) && getNames(imp).find((item) => (item.alias ?? item.name) === local)\n if (item) return { path: imp.path, name: item.name }\n }\n\n return undefined\n }\n\n for (const file of files) {\n if (virtualFiles.has(file.path) || !file.imports.some((imp) => virtualFiles.has(imp.path))) continue\n\n const lang = language(file)\n if (!lang) {\n result.problems.push({ path: file.path, message: `No parser for \"${file.extname}\" files supports inline sources.` })\n continue\n }\n\n const carried: Array<ImportNode> = []\n const sources = file.sources.map((source) => ({ ...source, nodes: rewriteNodes(source.nodes, (text) => replaceNames(text, file, lang, carried).text) }))\n\n // A carried import keeps its target; `root` moves to the importing file so the relative path is computed from there.\n const imports = [...file.imports.filter((imp) => !virtualFiles.has(imp.path)), ...carried.map((imp) => (imp.root ? { ...imp, root: file.path } : imp))]\n\n result.files.push(createFile({ ...file, sources, imports }))\n }\n\n return result\n}\n\n// A file of only deprecated per-source `inline` counts as inline too.\nfunction isInlineFile(file: FileNode): boolean {\n return !!file.inline || (file.sources.length > 0 && file.sources.every((source) => source.inline))\n}\n\n// The right-hand side of a `Const` or `Type`. A function body is not an expression, and printed text such as `Code` has none.\nfunction bodyOf(source: SourceNode | undefined): string | undefined {\n if (source?.inline) return source.inline.expression\n const node = source?.nodes?.length === 1 ? source.nodes[0] : undefined\n if (node?.kind !== nodeKinds.const && node?.kind !== nodeKinds.type) return undefined\n return getNodeText(node.nodes) || undefined\n}\n\nfunction pickNames(imp: ImportNode, used: ReadonlySet<string>): Array<ImportNode> {\n const names = getNames(imp).filter((item) => used.has(item.alias ?? item.name))\n return names.length > 0 ? [createImport({ path: imp.path, ...(imp.root != null ? { root: imp.root } : {}), names })] : []\n}\n\n// Rewrites the string fields `getNodeText` reads; JSDoc stays as written.\nfunction rewriteNodes(nodes: Array<CodeNode> | undefined, rewrite: (text: string) => string): Array<CodeNode> | undefined {\n return nodes?.map((node): CodeNode => {\n // Backward-compat: compiled plugins may still pass bare strings at runtime\n if (typeof node === 'string') return rewrite(node) as unknown as CodeNode\n if (node.kind === nodeKinds.break) return node\n\n const next = { ...node } as unknown as Record<string, unknown>\n for (const field of CODE_NODE_TEXT_FIELDS[node.kind] ?? []) {\n const value = next[field]\n if (Array.isArray(value)) next[field] = value.map(rewrite)\n if (typeof value === 'string' && value) next[field] = rewrite(value)\n }\n if ('nodes' in node && node.nodes) next.nodes = rewriteNodes(node.nodes, rewrite)\n return next as unknown as CodeNode\n })\n}\n","export { getRelativePath } from '../utils/combineFileMembers.ts'\nexport { inlineFiles as inline } from '../utils/inline.ts'\nexport { getNames, getSpace, isExported } from '../utils/moduleNames.ts'\n"],"mappings":";;;;;;;;;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AE,GAAG,KAAK;EACvB,KAAK,MAAM,SAASG,iBAAAA,sBAAsB,KAAK,SAAS,CAAC,GAAG;GAC1D,MAAM,QAAQ,KAAK;GACnB,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,SAAS,MAAM,IAAI,OAAO;GACzD,IAAI,OAAO,UAAU,YAAY,OAAO,KAAK,SAAS,QAAQ,KAAK;EACrE;EACA,IAAI,WAAW,QAAQ,KAAK,OAAO,KAAK,QAAQ,aAAa,KAAK,OAAO,OAAO;EAChF,OAAO;CACT,CAAC;AACH"}
|
package/dist/file.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const require_file
|
|
4
|
-
exports.getNames =
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
2
|
+
const require_combineFileMembers = require("./combineFileMembers-DmmuOmY8.cjs");
|
|
3
|
+
const require_file = require("./file-z3xToonr.cjs");
|
|
4
|
+
exports.getNames = require_combineFileMembers.getNames;
|
|
5
|
+
exports.getRelativePath = require_combineFileMembers.getRelativePath;
|
|
6
|
+
exports.getSpace = require_combineFileMembers.getSpace;
|
|
7
|
+
exports.inline = require_file.inlineFiles;
|
|
8
|
+
exports.isExported = require_combineFileMembers.isExported;
|
package/dist/file.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { getNames, getSpace, inlineFiles as inline };
|
|
1
|
+
import { a as getRelativePath, i as isExported, n as getNames, r as getSpace, s as inlineFiles } from "./index-DBKL6vyC.cjs";
|
|
2
|
+
export { getNames, getRelativePath, getSpace, inlineFiles as inline, isExported };
|
package/dist/file.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { getNames, getSpace, inlineFiles as inline };
|
|
1
|
+
import { a as getRelativePath, i as isExported, n as getNames, r as getSpace, s as inlineFiles } from "./index-VPq6RwTm.js";
|
|
2
|
+
export { getNames, getRelativePath, getSpace, inlineFiles as inline, isExported };
|
package/dist/file.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as inlineFiles } from "./file-
|
|
3
|
-
export { getNames, getSpace, inlineFiles as inline };
|
|
1
|
+
import { c as getSpace, l as isExported, s as getNames, t as getRelativePath } from "./combineFileMembers-DJHNAZBN.js";
|
|
2
|
+
import { n as inlineFiles } from "./file-HwCmj--S.js";
|
|
3
|
+
export { getNames, getRelativePath, getSpace, inlineFiles as inline, isExported };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-
|
|
1
|
+
import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-DJqd2j3y.cjs";
|
|
2
2
|
import { $ as PropertyNode, D as InputNode, G as SchemaNode, Q as createSchema, _ as createParameter, a as OperationsNode, d as createResponse, et as createProperty, f as RequestBodyNode, h as ParameterNode, i as OperationNode, j as createInput, l as ResponseNode, o as createOperation, p as createRequestBody, s as createOperations, v as ContentNode, x as createContent } from "./operation-De4lbIZS.cjs";
|
|
3
3
|
declare namespace index_d_exports {
|
|
4
4
|
export { ExportInput, ImportInput, ModuleName, Node, Space, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createOperations, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as nodeKinds } from "./base-A-xF4pUL.js";
|
|
2
|
-
import { g as CodeNode } from "./file-
|
|
3
|
-
import { a as collect, s as transform } from "./visitor-
|
|
2
|
+
import { g as CodeNode } from "./file-Dg70hXm3.js";
|
|
3
|
+
import { a as collect, s as transform } from "./visitor-BNGMMmpe.js";
|
|
4
4
|
/**
|
|
5
5
|
* Extracts all string content from a `CodeNode` tree recursively.
|
|
6
6
|
* Collects the text fields and nested node content, to build the source string for import filtering.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-
|
|
1
|
+
import { C as createArrowFunction, D as createJsx, E as createFunction, O as createText, S as TypeNode, T as createConst, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, d as createFile, f as createImport, h as BreakNode, i as ImportInput, k as createType, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, p as createSource, r as FileNode, s as SourceNode, t as ExportInput, u as createExport, v as FunctionNode, w as createBreak, x as TextNode } from "./file-Dg70hXm3.js";
|
|
2
2
|
import { $ as PropertyNode, D as InputNode, G as SchemaNode, Q as createSchema, _ as createParameter, a as OperationsNode, d as createResponse, et as createProperty, f as RequestBodyNode, h as ParameterNode, i as OperationNode, j as createInput, l as ResponseNode, o as createOperation, p as createRequestBody, s as createOperations, v as ContentNode, x as createContent } from "./operation-Dd0-l2VB.js";
|
|
3
3
|
declare namespace index_d_exports {
|
|
4
4
|
export { ExportInput, ImportInput, ModuleName, Node, Space, UserFileNode, createArrowFunction, createBreak, createConst, createContent, createExport, createFile, createFunction, createImport, createInput, createJsx, createOperation, createOperations, createParameter, createProperty, createRequestBody, createResponse, createSchema, createSource, createText, createType };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as nodeKinds } from "./base-CyJhBRMi.cjs";
|
|
2
|
-
import { g as CodeNode } from "./file-
|
|
3
|
-
import { a as collect, s as transform } from "./visitor-
|
|
2
|
+
import { g as CodeNode } from "./file-DJqd2j3y.cjs";
|
|
3
|
+
import { a as collect, s as transform } from "./visitor-BN5QJX7-.cjs";
|
|
4
4
|
/**
|
|
5
5
|
* Extracts all string content from a `CodeNode` tree recursively.
|
|
6
6
|
* Collects the text fields and nested node content, to build the source string for import filtering.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $ as PropertyNode, G as SchemaNode, J as StringSchemaNode } from "./operation-De4lbIZS.cjs";
|
|
2
2
|
import { a as schemaTypes } from "./base-CyJhBRMi.cjs";
|
|
3
3
|
import { n as narrowSchema } from "./guards-B6LgmDhJ.cjs";
|
|
4
|
-
import { o as findSchema } from "./visitor-
|
|
4
|
+
import { o as findSchema } from "./visitor-BN5QJX7-.cjs";
|
|
5
5
|
/**
|
|
6
6
|
* Generic JSON Schema optionality: a non-required field is optional, and a
|
|
7
7
|
* non-required nullable field is nullish.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace index_d_exports {
|
|
2
|
-
export { getBase, isJson };
|
|
2
|
+
export { MediaTypeInput, getBase, isJson };
|
|
3
3
|
}
|
|
4
4
|
type MediaTypeInput = string | {
|
|
5
5
|
contentType: string;
|
|
@@ -8,4 +8,4 @@ type MediaTypeInput = string | {
|
|
|
8
8
|
declare function getBase(mediaType: MediaTypeInput): string;
|
|
9
9
|
/** Whether the media type is `application/json`, `text/json`, or has a `+json` suffix. */
|
|
10
10
|
declare function isJson(mediaType: MediaTypeInput): boolean;
|
|
11
|
-
export {
|
|
11
|
+
export { isJson as i, getBase as n, index_d_exports as r, MediaTypeInput as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ImportNode, c as Space, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode } from "./file-
|
|
1
|
+
import { a as ImportNode, c as Space, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode } from "./file-DJqd2j3y.cjs";
|
|
2
2
|
type InlineFilesResult = {
|
|
3
3
|
/**
|
|
4
4
|
* Files that imported an inline name, rewritten to hold its definition.
|
|
@@ -40,13 +40,26 @@ type InlineFilesOptions = {
|
|
|
40
40
|
* declaration, until no inline names are left. The definitions' own imports move to the importing file.
|
|
41
41
|
*/
|
|
42
42
|
declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
|
|
43
|
+
/**
|
|
44
|
+
* Module specifier that imports `filePath` from the file at `root`: POSIX, relative to that file's directory, `./`-prefixed unless it climbs with `../`.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* getRelativePath('/root/src/models/pet.ts', '/root/lib/client.ts') // '../../lib/client.ts'
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
declare function getRelativePath(root: string, filePath: string): string;
|
|
43
52
|
/**
|
|
44
53
|
* Returns the names an import or export brings across. A node built with the deprecated fields gets them from
|
|
45
54
|
* those, each with an explicit `space`, so it prints exactly as before.
|
|
46
55
|
*/
|
|
47
56
|
declare function getNames(node: ImportNode | ExportNode): Array<ModuleName>;
|
|
57
|
+
/**
|
|
58
|
+
* Returns `true` when a source is an exported declaration. Reads the deprecated `isIndexable` and `isExportable`, in that order, when `export` is unset.
|
|
59
|
+
*/
|
|
60
|
+
declare function isExported(source: Pick<SourceNode, 'export' | 'isIndexable' | 'isExportable'>): boolean;
|
|
48
61
|
declare function getSpace(source: SourceNode): Space;
|
|
49
62
|
declare namespace index_d_exports {
|
|
50
|
-
export { getNames, getSpace, inlineFiles as inline };
|
|
63
|
+
export { getNames, getRelativePath, getSpace, inlineFiles as inline, isExported };
|
|
51
64
|
}
|
|
52
|
-
export {
|
|
65
|
+
export { getRelativePath as a, isExported as i, getNames as n, InlineLanguage as o, getSpace as r, inlineFiles as s, index_d_exports as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Node } from "./index-
|
|
2
|
-
import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-
|
|
1
|
+
import { t as Node } from "./index-BjmAaymt.cjs";
|
|
2
|
+
import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-BN5QJX7-.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
|
|
5
5
|
* and `undefined` keeps declaration order.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as Node } from "./index-
|
|
2
|
-
import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-
|
|
1
|
+
import { t as Node } from "./index-Bz33tfQo.js";
|
|
2
|
+
import { i as VisitorKey, n as VisitorContext, r as VisitorDepth, t as Visitor } from "./visitor-BNGMMmpe.js";
|
|
3
3
|
/**
|
|
4
4
|
* Ordering hint shared by macros and plugins. `pre` runs before unmarked items, `post` after,
|
|
5
5
|
* and `undefined` keeps declaration order.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $ as PropertyNode, G as SchemaNode, J as StringSchemaNode } from "./operation-Dd0-l2VB.js";
|
|
2
2
|
import { a as schemaTypes } from "./base-A-xF4pUL.js";
|
|
3
3
|
import { n as narrowSchema } from "./guards-l2AsKeHR.js";
|
|
4
|
-
import { o as findSchema } from "./visitor-
|
|
4
|
+
import { o as findSchema } from "./visitor-BNGMMmpe.js";
|
|
5
5
|
/**
|
|
6
6
|
* Generic JSON Schema optionality: a non-required field is optional, and a
|
|
7
7
|
* non-required nullable field is nullish.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare namespace index_d_exports {
|
|
2
|
-
export { getBase, isJson };
|
|
2
|
+
export { MediaTypeInput, getBase, isJson };
|
|
3
3
|
}
|
|
4
4
|
type MediaTypeInput = string | {
|
|
5
5
|
contentType: string;
|
|
@@ -8,4 +8,4 @@ type MediaTypeInput = string | {
|
|
|
8
8
|
declare function getBase(mediaType: MediaTypeInput): string;
|
|
9
9
|
/** Whether the media type is `application/json`, `text/json`, or has a `+json` suffix. */
|
|
10
10
|
declare function isJson(mediaType: MediaTypeInput): boolean;
|
|
11
|
-
export {
|
|
11
|
+
export { isJson as i, getBase as n, index_d_exports as r, MediaTypeInput as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ImportNode, c as Space, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode } from "./file-
|
|
1
|
+
import { a as ImportNode, c as Space, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode } from "./file-Dg70hXm3.js";
|
|
2
2
|
type InlineFilesResult = {
|
|
3
3
|
/**
|
|
4
4
|
* Files that imported an inline name, rewritten to hold its definition.
|
|
@@ -40,13 +40,26 @@ type InlineFilesOptions = {
|
|
|
40
40
|
* declaration, until no inline names are left. The definitions' own imports move to the importing file.
|
|
41
41
|
*/
|
|
42
42
|
declare function inlineFiles(files: ReadonlyArray<FileNode>, { language }: InlineFilesOptions): InlineFilesResult;
|
|
43
|
+
/**
|
|
44
|
+
* Module specifier that imports `filePath` from the file at `root`: POSIX, relative to that file's directory, `./`-prefixed unless it climbs with `../`.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* getRelativePath('/root/src/models/pet.ts', '/root/lib/client.ts') // '../../lib/client.ts'
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
declare function getRelativePath(root: string, filePath: string): string;
|
|
43
52
|
/**
|
|
44
53
|
* Returns the names an import or export brings across. A node built with the deprecated fields gets them from
|
|
45
54
|
* those, each with an explicit `space`, so it prints exactly as before.
|
|
46
55
|
*/
|
|
47
56
|
declare function getNames(node: ImportNode | ExportNode): Array<ModuleName>;
|
|
57
|
+
/**
|
|
58
|
+
* Returns `true` when a source is an exported declaration. Reads the deprecated `isIndexable` and `isExportable`, in that order, when `export` is unset.
|
|
59
|
+
*/
|
|
60
|
+
declare function isExported(source: Pick<SourceNode, 'export' | 'isIndexable' | 'isExportable'>): boolean;
|
|
48
61
|
declare function getSpace(source: SourceNode): Space;
|
|
49
62
|
declare namespace index_d_exports {
|
|
50
|
-
export { getNames, getSpace, inlineFiles as inline };
|
|
63
|
+
export { getNames, getRelativePath, getSpace, inlineFiles as inline, isExported };
|
|
51
64
|
}
|
|
52
|
-
export {
|
|
65
|
+
export { getRelativePath as a, isExported as i, getNames as n, InlineLanguage as o, getSpace as r, inlineFiles as s, index_d_exports as t };
|
package/dist/index.cjs
CHANGED
|
@@ -10,9 +10,9 @@ const require_refs = require("./refs-rmr2LFV1.cjs");
|
|
|
10
10
|
const require_macro = require("./macro-Ywn4-0s5.cjs");
|
|
11
11
|
const require_node = require("./node-BeccjrHH.cjs");
|
|
12
12
|
const require_optionality = require("./optionality-C-qULYxo.cjs");
|
|
13
|
-
const require_file = require("./file-
|
|
13
|
+
const require_file = require("./file-z3xToonr.cjs");
|
|
14
14
|
const require_nodeText = require("./nodeText-DH4dLGUb.cjs");
|
|
15
|
-
const require_nodes = require("./nodes-
|
|
15
|
+
const require_nodes = require("./nodes-TtDfZ9qf.cjs");
|
|
16
16
|
const require_http = require("./http-Dv8py6wh.cjs");
|
|
17
17
|
const require_json = require("./json-KV2VhBue.cjs");
|
|
18
18
|
const require_mediaType = require("./mediaType-BbIfudh0.cjs");
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["createPrinter","mergeRef","createPrinterImpl","defineMacroImpl"],"sources":["../src/createPrinter.ts","../src/deprecated.ts","../src/index.ts"],"sourcesContent":["import type { ImportNode } from './nodes/file.ts'\nimport type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/schema.ts'\n\n/**\n * Runtime context passed to printer handlers, both as `this` and as the second argument.\n *\n * `this.transform` dispatches to node-level handlers from `nodes`.\n *\n * @example\n * ```ts\n * const context: PrinterHandlerContext<string, {}> = {\n * options: {},\n * transform: () => 'value',\n * base: () => 'value',\n * }\n * ```\n */\ntype PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.\n * Use `this.transform` inside `nodes` handlers and inside the `print` override.\n * The optional `options` are merged over `this.options` for that child call only.\n */\n transform: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /**\n * Run the printer's built-in handler for the node, ignoring any override for its type.\n * Inside an override, `this.base(node)` returns what the printer would have emitted,\n * so the override can wrap it instead of re-implementing the handler. Nested nodes\n * still dispatch through the overrides. The optional `options` merge like `this.transform`.\n */\n base: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /** Declares an import the printed code needs. The generator reads it back with `printer.drainImports()`. */\n import: (node: ImportNode) => void\n /**\n * Options for this printer instance.\n */\n options: TOptions\n /** The schema node whose handler called `this.transform`, `undefined` at the root. */\n parent?: SchemaNode\n}\n\n/**\n * Handler for one schema node type. The handler context is `this` and the second argument,\n * so an arrow function can read it as `ctx`. The second argument is typed as optional, so an\n * arrow function asserts it with `ctx!`.\n *\n * @example\n * ```ts\n * const handler: PrinterHandler<string, {}, 'array'> = (node, ctx) => `Array<${ctx!.transform(node.items[0]!)}>`\n * ```\n */\ntype PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n // Optional and without the options type, so one-argument handler types stay assignable and\n // a union of printer tables keeps its contextual `this`. Use `this.options` for typed options.\n ctx?: PrinterHandlerContext<TOutput, object>,\n) => TOutput | null\n\n/**\n * Partial map of per-node-type handler overrides for a printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).\n * Supply only the handlers you want to replace. The printer's built-in\n * defaults fill in the rest.\n *\n * @example\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(): string {\n * return 'z.string().date()'\n * },\n * } satisfies PrinterPartial<string, PrinterZodOptions>,\n * },\n * })\n * ```\n */\nexport type PrinterPartial<TOutput, TOptions extends object> = Partial<{\n [K in SchemaType]: PrinterHandler<TOutput, TOptions, K>\n}>\n\n/**\n * Generic shape used by `definePrinter`.\n *\n * - `TName` unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` options passed to and stored on the printer instance\n * - `TOutput` the type emitted by node handlers\n * - `TPrintOutput` type returned by public `print` (defaults to `TOutput`)\n *\n * @example\n * ```ts\n * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>\n * ```\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * Printer instance returned by a printer factory.\n *\n * @example\n * ```ts\n * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})\n * ```\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Node-level dispatcher, converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.\n * Always dispatches through the `nodes` map. Never calls the `print` override.\n * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.\n */\n transform: (node: SchemaNode) => T['output'] | null\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations).\n * Otherwise, falls back to the node-level dispatcher.\n */\n print: (node: SchemaNode) => T['printOutput'] | null\n /** Returns this printer with `extra` merged over its options, sharing its handlers and imports, such as `printer.with({ keysToOmit: ['id'] })`. */\n with: (extra: Partial<T['options']>) => Printer<T>\n /** Returns the imports declared with `this.import(...)` since the last call, then clears them. */\n drainImports: () => Array<ImportNode>\n}\n\n/**\n * Builder function passed to `definePrinter`.\n *\n * It receives resolved options and returns:\n * - `name`\n * - `options`\n * - `nodes` handlers\n * - optional top-level `print` override\n *\n * @example\n * ```ts\n * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })\n * ```\n */\ntype PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: PrinterPartial<T['output'], T['options']>\n /**\n * User-supplied handler overrides. An override wins over the matching `nodes` handler,\n * and can call `this.base(node)` to reuse the handler it replaced. Pass overrides here\n * instead of spreading them into `nodes`, otherwise `this.base` cannot find the original.\n */\n overrides?: PrinterPartial<T['output'], T['options']>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),\n * not the override itself, so recursion is safe. The root context is also the second argument.\n */\n print?: (\n this: PrinterHandlerContext<T['output'], T['options']>,\n node: SchemaNode,\n ctx: PrinterHandlerContext<T['output'], T['options']>,\n ) => T['printOutput'] | null\n}\n/**\n * Creates a schema printer: a function that takes a `SchemaNode` and emits\n * code in your target language. Each plugin that produces code from schemas\n * (TypeScript types, Zod schemas, Faker factories) ships a printer built\n * with this helper.\n *\n * The builder receives resolved options and returns:\n *\n * - `name` unique identifier for the printer.\n * - `options` stored on the returned printer instance.\n * - `nodes` map of `SchemaType` → handler. Handlers return the rendered\n * output (a string, a TypeScript AST node, ...) for that schema type.\n * - `overrides` (optional), user-supplied handlers that win over `nodes`.\n * An override can call `this.base(node)` to reuse the handler it replaced.\n * - `print` (optional), top-level override exposed as `printer.print`.\n * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.\n *\n * Without a `print` override, `printer.print` falls back to `printer.transform`\n * (the node-level dispatcher).\n *\n * @example Tiny Zod printer\n * ```ts\n * import { ast, createPrinter } from '@kubb/kit'\n *\n * type PrinterZod = ast.PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = createPrinter<PrinterZod>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties\n * .map((p) => `${p.name}: ${this.transform(p.schema)}`)\n * .join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n */\nexport function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return (options) => {\n const { name, options: resolvedOptions, nodes, overrides, print: printOverride } = build((options ?? {}) as T['options'])\n const merged = overrides ? { ...nodes, ...overrides } : nodes\n\n const collectedImports: Array<ImportNode> = []\n const importNode = (node: ImportNode): void => {\n collectedImports.push(node)\n }\n type Context = PrinterHandlerContext<T['output'], T['options']>\n const withOptions = (current: T['options'], extra?: Partial<T['options']>): T['options'] => (extra ? { ...current, ...extra } : current)\n\n const dispatch = (table: PrinterPartial<T['output'], T['options']>, node: SchemaNode, options: T['options'], parent?: SchemaNode): T['output'] | null => {\n const handler = table[node.type]\n if (!handler) return null\n\n const context = createContext(options, node, parent)\n return (handler as (this: Context, node: SchemaNode, ctx: Context) => T['output'] | null).call(context, node, context)\n }\n\n // `current` is the node whose handler gets this context, so it becomes the parent of what that handler transforms.\n function createContext(options: T['options'], current?: SchemaNode, parent?: SchemaNode): Context {\n const context: Context = {\n options,\n parent,\n import: importNode,\n transform: (node, extra) => dispatch(merged, node, withOptions(context.options, extra), current),\n base: (node, extra) => dispatch(nodes, node, withOptions(context.options, extra), parent),\n }\n return context\n }\n\n const drainImports = () => collectedImports.splice(0)\n\n const toPrinter = (options: T['options']): Printer<T> => {\n const root = createContext(options)\n return {\n name,\n options,\n transform: (node) => root.transform(node),\n print: (printOverride ? (node: SchemaNode) => printOverride.call(root, node, root) : (node: SchemaNode) => root.transform(node)) as Printer<T>['print'],\n with: (extra) => toPrinter(withOptions(options, extra)),\n drainImports,\n }\n }\n\n return toPrinter(resolvedOptions)\n }\n}\n","import * as graph from './graph/index.ts'\nimport * as http from './http/index.ts'\nimport * as ref from './ref/index.ts'\nimport * as schema from './schema/index.ts'\nimport { mergeRefWithSchema as mergeRef } from './utils/refs.ts'\nimport { createPrinter as createPrinterImpl } from './createPrinter.ts'\nimport { defineMacro as defineMacroImpl } from './defineMacro.ts'\nimport * as macro from './macro/index.ts'\nimport * as node from './node/index.ts'\nimport * as file from './file/index.ts'\n\n/** @deprecated Use `ast.ref.isAlias`. Removed in Kubb v6. */\nexport const isBareRef = ref.isAlias\n\n/** @deprecated Use `ast.ref.mergeSchema`. Removed in Kubb v6. */\nexport const mergeRefWithSchema = mergeRef\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const refName = ref.getName\n\n/** @deprecated Use `ast.ref.getSchema`. Removed in Kubb v6. */\nexport const resolveRef = ref.getSchema\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const resolveRefName = ref.getName\n\n/** @deprecated Use `ast.graph.getImportedNames`. Removed in Kubb v6. */\nexport const collectImportedRefNames = graph.getImportedNames\n\n/** @deprecated Use `ast.graph.getRefNames`. Removed in Kubb v6. */\nexport const collectSchemaRefs = graph.getRefNames\n\n/** @deprecated Use `ast.graph.getUsedNames`. Removed in Kubb v6. */\nexport const collectUsedSchemaNames = graph.getUsedNames\n\n/** @deprecated Use `ast.graph.getCircularNames`. Removed in Kubb v6. */\nexport const findCircularSchemas = graph.getCircularNames\n\n/** @deprecated Use `ast.schema.getLiterals`. Removed in Kubb v6. */\nexport const getSchemaLiteralValues = schema.getLiterals\n\n/** @deprecated Use `ast.schema.inferDiscriminator`. Removed in Kubb v6. */\nexport const inferDiscriminatorPropertyName = schema.inferDiscriminator\n\n/** @deprecated Use `ast.schema.findProperties`. Removed in Kubb v6. */\nexport const resolveSchemaProperties = schema.findProperties\n\n/** @deprecated Use `ast.http.isOperation`. Removed in Kubb v6. */\nexport const isHttpOperationNode = http.isOperation\n\n/** @deprecated Use `ast.node.collect`, which returns the same array. Removed in Kubb v6. */\nexport const collectSync = node.collect\n\n/** @deprecated Use `ast.schema.applyOptionality`. Removed in Kubb v6. */\nexport const optionality = schema.applyOptionality\n\n/** @deprecated Use `ast.node.getText`. Removed in Kubb v6. */\nexport const extractStringsFromNodes = node.getText\n\n/** @deprecated Use `ast.macro.compareOrder`. Removed in Kubb v6. */\nexport const compareEnforce = macro.compareOrder\n\n/** @deprecated Use `createPrinter` from `@kubb/kit`. Removed in Kubb v6. */\nexport const createPrinter = createPrinterImpl\n\n/** @deprecated Use `defineMacro` from `@kubb/kit`. Removed in Kubb v6. */\nexport const defineMacro = defineMacroImpl\n\n/** @deprecated Use `ast.macro.apply`. Removed in Kubb v6. */\nexport const applyMacros = macro.apply\n\n/** @deprecated Use `ast.node.kinds`. Removed in Kubb v6. */\nexport const nodeKinds = node.kinds\n\n/** @deprecated Use `ast.schema.types`. Removed in Kubb v6. */\nexport const schemaTypes = schema.types\n\n/** @deprecated Use `ast.schema.find`. Removed in Kubb v6. */\nexport const findSchema = schema.find\n\n/** @deprecated Use `ast.schema.narrow`. Removed in Kubb v6. */\nexport const narrowSchema = schema.narrow\n\n/** @deprecated Use `ast.node.transform`. Removed in Kubb v6. */\nexport const transform = node.transform\n\n/** @deprecated Use `ast.node.collect`. Removed in Kubb v6. */\nexport const collect = node.collect\n\n/** @deprecated Use `ast.file.inline`. Removed in Kubb v6. */\nexport const inlineFiles = file.inline\n","export type { InlineLanguage } from './utils/inline.ts'\nexport * from './deprecated.ts'\n\nexport * as factory from './nodes/index.ts'\nexport * as file from './file/index.ts'\nexport * as graph from './graph/index.ts'\nexport * as http from './http/index.ts'\nexport * as json from './json/index.ts'\nexport * as macro from './macro/index.ts'\nexport * as mediaType from './mediaType/index.ts'\nexport * as node from './node/index.ts'\nexport *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IAC9H,OAAO,UAAU,UAAU,YAAY,SAAS,KAAK,CAAC;IACtD;GACF;EACF;EAEA,OAAO,UAAU,eAAe;CAClC;AACF;;;;AC7PA,MAAa,YAAA,aAAA;;AAGb,MAAa,qBAAqBC,aAAAA;;AAGlC,MAAa,UAAA,YAAA;;AAGb,MAAa,aAAA,aAAA;;AAGb,MAAa,iBAAA,YAAA;;AAGb,MAAa,0BAAA,cAAA;;AAGb,MAAa,oBAAA,cAAA;;AAGb,MAAa,yBAAA,cAAA;;AAGb,MAAa,sBAAA,cAAA;;AAGb,MAAa,yBAAA,eAAA;;AAGb,MAAa,iCAAA,eAAA;;AAGb,MAAa,0BAAA,eAAA;;AAGb,MAAa,sBAAA,eAAA;;AAGb,MAAa,cAAA,gBAAA;;AAGb,MAAa,cAAA,oBAAA;;AAGb,MAAa,0BAAA,iBAAA;;AAGb,MAAa,iBAAA,cAAA;;AAGb,MAAa,gBAAgBC;;AAG7B,MAAa,cAAcC,cAAAA;;AAG3B,MAAa,cAAA,cAAA;;AAGb,MAAa,YAAA,kBAAA;;AAGb,MAAa,cAAA,kBAAA;;AAGb,MAAa,aAAA,gBAAA;;AAGb,MAAa,eAAA,eAAA;;AAGb,MAAa,YAAA,gBAAA;;AAGb,MAAa,UAAA,gBAAA;;AAGb,MAAa,cAAA,aAAA"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createPrinter","mergeRef","createPrinterImpl","defineMacroImpl"],"sources":["../src/createPrinter.ts","../src/deprecated.ts","../src/index.ts"],"sourcesContent":["import type { ImportNode } from './nodes/file.ts'\nimport type { SchemaNode, SchemaNodeByType, SchemaType } from './nodes/schema.ts'\n\n/**\n * Runtime context passed to printer handlers, both as `this` and as the second argument.\n *\n * `this.transform` dispatches to node-level handlers from `nodes`.\n *\n * @example\n * ```ts\n * const context: PrinterHandlerContext<string, {}> = {\n * options: {},\n * transform: () => 'value',\n * base: () => 'value',\n * }\n * ```\n */\nexport type PrinterHandlerContext<TOutput, TOptions extends object> = {\n /**\n * Recursively transform a nested `SchemaNode` to `TOutput` using the node-level handlers.\n * Use `this.transform` inside `nodes` handlers and inside the `print` override.\n * The optional `options` are merged over `this.options` for that child call only.\n */\n transform: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /**\n * Run the printer's built-in handler for the node, ignoring any override for its type.\n * Inside an override, `this.base(node)` returns what the printer would have emitted,\n * so the override can wrap it instead of re-implementing the handler. Nested nodes\n * still dispatch through the overrides. The optional `options` merge like `this.transform`.\n */\n base: (node: SchemaNode, options?: Partial<TOptions>) => TOutput | null\n /** Declares an import the printed code needs. The generator reads it back with `printer.drainImports()`. */\n import: (node: ImportNode) => void\n /**\n * Options for this printer instance.\n */\n options: TOptions\n /** The schema node whose handler called `this.transform`, `undefined` at the root. */\n parent?: SchemaNode\n}\n\n/**\n * Handler for one schema node type. The handler context is `this` and the second argument,\n * so an arrow function can read it as `ctx`. The second argument is typed as optional, so an\n * arrow function asserts it with `ctx!`.\n *\n * @example\n * ```ts\n * const handler: PrinterHandler<string, {}, 'array'> = (node, ctx) => `Array<${ctx!.transform(node.items[0]!)}>`\n * ```\n */\nexport type PrinterHandler<TOutput, TOptions extends object, T extends SchemaType = SchemaType> = (\n this: PrinterHandlerContext<TOutput, TOptions>,\n node: SchemaNodeByType[T],\n // Optional and without the options type, so one-argument handler types stay assignable and\n // a union of printer tables keeps its contextual `this`. Use `this.options` for typed options.\n ctx?: PrinterHandlerContext<TOutput, object>,\n) => TOutput | null\n\n/**\n * Partial map of per-node-type handler overrides for a printer.\n *\n * Each key is a `SchemaType` string (e.g. `'date'`, `'string'`).\n * Supply only the handlers you want to replace. The printer's built-in\n * defaults fill in the rest.\n *\n * @example\n * ```ts\n * pluginZod({\n * printer: {\n * nodes: {\n * date(): string {\n * return 'z.string().date()'\n * },\n * } satisfies PrinterPartial<string, PrinterZodOptions>,\n * },\n * })\n * ```\n */\nexport type PrinterPartial<TOutput, TOptions extends object> = Partial<{\n [K in SchemaType]: PrinterHandler<TOutput, TOptions, K>\n}>\n\n/**\n * Generic shape used by `definePrinter`.\n *\n * - `TName` unique string identifier (e.g. `'zod'`, `'ts'`)\n * - `TOptions` options passed to and stored on the printer instance\n * - `TOutput` the type emitted by node handlers\n * - `TPrintOutput` type returned by public `print` (defaults to `TOutput`)\n *\n * @example\n * ```ts\n * type MyPrinter = PrinterFactoryOptions<'my', { strict: boolean }, string>\n * ```\n */\nexport type PrinterFactoryOptions<TName extends string = string, TOptions extends object = object, TOutput = unknown, TPrintOutput = TOutput> = {\n name: TName\n options: TOptions\n output: TOutput\n printOutput: TPrintOutput\n}\n\n/**\n * Printer instance returned by a printer factory.\n *\n * @example\n * ```ts\n * const printer = definePrinter((options: {}) => ({ name: 'x', options, nodes: {} }))({})\n * ```\n */\nexport type Printer<T extends PrinterFactoryOptions = PrinterFactoryOptions> = {\n /**\n * Unique identifier supplied at creation time.\n */\n name: T['name']\n /**\n * Options for this printer instance.\n */\n options: T['options']\n /**\n * Node-level dispatcher, converts a `SchemaNode` directly to `TOutput` using the `nodes` handlers.\n * Always dispatches through the `nodes` map. Never calls the `print` override.\n * Reach for it when you need the raw output (e.g. `ts.TypeNode`) without declaration wrapping.\n */\n transform: (node: SchemaNode) => T['output'] | null\n /**\n * Public printer. If the builder provides a root-level `print`, this calls that\n * higher-level function (which may produce full declarations).\n * Otherwise, falls back to the node-level dispatcher.\n */\n print: (node: SchemaNode) => T['printOutput'] | null\n /** Returns this printer with `extra` merged over its options, sharing its handlers and imports, such as `printer.with({ keysToOmit: ['id'] })`. */\n with: (extra: Partial<T['options']>) => Printer<T>\n /** Returns the imports declared with `this.import(...)` since the last call, then clears them. */\n drainImports: () => Array<ImportNode>\n}\n\n/**\n * Builder function passed to `definePrinter`.\n *\n * It receives resolved options and returns:\n * - `name`\n * - `options`\n * - `nodes` handlers\n * - optional top-level `print` override\n *\n * @example\n * ```ts\n * const build = (options: {}) => ({ name: 'x' as const, options, nodes: {} })\n * ```\n */\nexport type PrinterBuilder<T extends PrinterFactoryOptions> = (options: T['options']) => {\n name: T['name']\n /**\n * Options to store on the printer.\n */\n options: T['options']\n nodes: PrinterPartial<T['output'], T['options']>\n /**\n * User-supplied handler overrides. An override wins over the matching `nodes` handler,\n * and can call `this.base(node)` to reuse the handler it replaced. Pass overrides here\n * instead of spreading them into `nodes`, otherwise `this.base` cannot find the original.\n */\n overrides?: PrinterPartial<T['output'], T['options']>\n /**\n * Optional root-level print override. When provided, becomes the public `printer.print`.\n * Use `this.transform(node)` inside this function to dispatch to the node-level handlers (`nodes`),\n * not the override itself, so recursion is safe. The root context is also the second argument.\n */\n print?: (\n this: PrinterHandlerContext<T['output'], T['options']>,\n node: SchemaNode,\n ctx: PrinterHandlerContext<T['output'], T['options']>,\n ) => T['printOutput'] | null\n}\n/**\n * Creates a schema printer: a function that takes a `SchemaNode` and emits\n * code in your target language. Each plugin that produces code from schemas\n * (TypeScript types, Zod schemas, Faker factories) ships a printer built\n * with this helper.\n *\n * The builder receives resolved options and returns:\n *\n * - `name` unique identifier for the printer.\n * - `options` stored on the returned printer instance.\n * - `nodes` map of `SchemaType` → handler. Handlers return the rendered\n * output (a string, a TypeScript AST node, ...) for that schema type.\n * - `overrides` (optional), user-supplied handlers that win over `nodes`.\n * An override can call `this.base(node)` to reuse the handler it replaced.\n * - `print` (optional), top-level override exposed as `printer.print`.\n * Use `this.transform(node)` inside it to dispatch to `nodes` recursively.\n *\n * Without a `print` override, `printer.print` falls back to `printer.transform`\n * (the node-level dispatcher).\n *\n * @example Tiny Zod printer\n * ```ts\n * import { ast, createPrinter } from '@kubb/kit'\n *\n * type PrinterZod = ast.PrinterFactoryOptions<'zod', { strict?: boolean }, string>\n *\n * export const zodPrinter = createPrinter<PrinterZod>((options) => ({\n * name: 'zod',\n * options: { strict: options.strict ?? true },\n * nodes: {\n * string: () => 'z.string()',\n * object(node) {\n * const props = node.properties\n * .map((p) => `${p.name}: ${this.transform(p.schema)}`)\n * .join(', ')\n * return `z.object({ ${props} })`\n * },\n * },\n * }))\n * ```\n */\nexport function createPrinter<T extends PrinterFactoryOptions = PrinterFactoryOptions>(build: PrinterBuilder<T>): (options?: T['options']) => Printer<T> {\n return (options) => {\n const { name, options: resolvedOptions, nodes, overrides, print: printOverride } = build((options ?? {}) as T['options'])\n const merged = overrides ? { ...nodes, ...overrides } : nodes\n\n const collectedImports: Array<ImportNode> = []\n const importNode = (node: ImportNode): void => {\n collectedImports.push(node)\n }\n type Context = PrinterHandlerContext<T['output'], T['options']>\n const withOptions = (current: T['options'], extra?: Partial<T['options']>): T['options'] => (extra ? { ...current, ...extra } : current)\n\n const dispatch = (table: PrinterPartial<T['output'], T['options']>, node: SchemaNode, options: T['options'], parent?: SchemaNode): T['output'] | null => {\n const handler = table[node.type]\n if (!handler) return null\n\n const context = createContext(options, node, parent)\n return (handler as (this: Context, node: SchemaNode, ctx: Context) => T['output'] | null).call(context, node, context)\n }\n\n // `current` is the node whose handler gets this context, so it becomes the parent of what that handler transforms.\n function createContext(options: T['options'], current?: SchemaNode, parent?: SchemaNode): Context {\n const context: Context = {\n options,\n parent,\n import: importNode,\n transform: (node, extra) => dispatch(merged, node, withOptions(context.options, extra), current),\n base: (node, extra) => dispatch(nodes, node, withOptions(context.options, extra), parent),\n }\n return context\n }\n\n const drainImports = () => collectedImports.splice(0)\n\n const toPrinter = (options: T['options']): Printer<T> => {\n const root = createContext(options)\n return {\n name,\n options,\n transform: (node) => root.transform(node),\n print: (printOverride ? (node: SchemaNode) => printOverride.call(root, node, root) : (node: SchemaNode) => root.transform(node)) as Printer<T>['print'],\n with: (extra) => toPrinter(withOptions(options, extra)),\n drainImports,\n }\n }\n\n return toPrinter(resolvedOptions)\n }\n}\n","import * as graph from './graph/index.ts'\nimport * as http from './http/index.ts'\nimport * as ref from './ref/index.ts'\nimport * as schema from './schema/index.ts'\nimport { mergeRefWithSchema as mergeRef } from './utils/refs.ts'\nimport { createPrinter as createPrinterImpl } from './createPrinter.ts'\nimport { defineMacro as defineMacroImpl } from './defineMacro.ts'\nimport * as macro from './macro/index.ts'\nimport * as node from './node/index.ts'\nimport * as file from './file/index.ts'\n\n/** @deprecated Use `ast.ref.isAlias`. Removed in Kubb v6. */\nexport const isBareRef = ref.isAlias\n\n/** @deprecated Use `ast.ref.mergeSchema`. Removed in Kubb v6. */\nexport const mergeRefWithSchema = mergeRef\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const refName = ref.getName\n\n/** @deprecated Use `ast.ref.getSchema`. Removed in Kubb v6. */\nexport const resolveRef = ref.getSchema\n\n/** @deprecated Use `ast.ref.getName`. Removed in Kubb v6. */\nexport const resolveRefName = ref.getName\n\n/** @deprecated Use `ast.graph.getImportedNames`. Removed in Kubb v6. */\nexport const collectImportedRefNames = graph.getImportedNames\n\n/** @deprecated Use `ast.graph.getRefNames`. Removed in Kubb v6. */\nexport const collectSchemaRefs = graph.getRefNames\n\n/** @deprecated Use `ast.graph.getUsedNames`. Removed in Kubb v6. */\nexport const collectUsedSchemaNames = graph.getUsedNames\n\n/** @deprecated Use `ast.graph.getCircularNames`. Removed in Kubb v6. */\nexport const findCircularSchemas = graph.getCircularNames\n\n/** @deprecated Use `ast.schema.getLiterals`. Removed in Kubb v6. */\nexport const getSchemaLiteralValues = schema.getLiterals\n\n/** @deprecated Use `ast.schema.inferDiscriminator`. Removed in Kubb v6. */\nexport const inferDiscriminatorPropertyName = schema.inferDiscriminator\n\n/** @deprecated Use `ast.schema.findProperties`. Removed in Kubb v6. */\nexport const resolveSchemaProperties = schema.findProperties\n\n/** @deprecated Use `ast.http.isOperation`. Removed in Kubb v6. */\nexport const isHttpOperationNode = http.isOperation\n\n/** @deprecated Use `ast.node.collect`, which returns the same array. Removed in Kubb v6. */\nexport const collectSync = node.collect\n\n/** @deprecated Use `ast.schema.applyOptionality`. Removed in Kubb v6. */\nexport const optionality = schema.applyOptionality\n\n/** @deprecated Use `ast.node.getText`. Removed in Kubb v6. */\nexport const extractStringsFromNodes = node.getText\n\n/** @deprecated Use `ast.macro.compareOrder`. Removed in Kubb v6. */\nexport const compareEnforce = macro.compareOrder\n\n/** @deprecated Use `createPrinter` from `@kubb/kit`. Removed in Kubb v6. */\nexport const createPrinter = createPrinterImpl\n\n/** @deprecated Use `defineMacro` from `@kubb/kit`. Removed in Kubb v6. */\nexport const defineMacro = defineMacroImpl\n\n/** @deprecated Use `ast.macro.apply`. Removed in Kubb v6. */\nexport const applyMacros = macro.apply\n\n/** @deprecated Use `ast.node.kinds`. Removed in Kubb v6. */\nexport const nodeKinds = node.kinds\n\n/** @deprecated Use `ast.schema.types`. Removed in Kubb v6. */\nexport const schemaTypes = schema.types\n\n/** @deprecated Use `ast.schema.find`. Removed in Kubb v6. */\nexport const findSchema = schema.find\n\n/** @deprecated Use `ast.schema.narrow`. Removed in Kubb v6. */\nexport const narrowSchema = schema.narrow\n\n/** @deprecated Use `ast.node.transform`. Removed in Kubb v6. */\nexport const transform = node.transform\n\n/** @deprecated Use `ast.node.collect`. Removed in Kubb v6. */\nexport const collect = node.collect\n\n/** @deprecated Use `ast.file.inline`. Removed in Kubb v6. */\nexport const inlineFiles = file.inline\n","export type { InlineLanguage } from './utils/inline.ts'\nexport * from './deprecated.ts'\n\nexport * as factory from './nodes/index.ts'\nexport * as file from './file/index.ts'\nexport * as graph from './graph/index.ts'\nexport * as http from './http/index.ts'\nexport * as json from './json/index.ts'\nexport * as macro from './macro/index.ts'\nexport * as mediaType from './mediaType/index.ts'\nexport * as node from './node/index.ts'\nexport * as ref from './ref/index.ts'\nexport * as schema from './schema/index.ts'\nexport type * from './types.ts'\nexport * as ast from './index.ts'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyNA,SAAgBA,gBAAuE,OAAkE;CACvJ,QAAQ,YAAY;EAClB,MAAM,EAAE,MAAM,SAAS,iBAAiB,OAAO,WAAW,OAAO,kBAAkB,MAAO,WAAW,CAAC,CAAkB;EACxH,MAAM,SAAS,YAAY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AGb,MAAa,sBAAA,cAAA;;AAGb,MAAa,yBAAA,eAAA;;AAGb,MAAa,iCAAA,eAAA;;AAGb,MAAa,0BAAA,eAAA;;AAGb,MAAa,sBAAA,eAAA;;AAGb,MAAa,cAAA,gBAAA;;AAGb,MAAa,cAAA,oBAAA;;AAGb,MAAa,0BAAA,iBAAA;;AAGb,MAAa,iBAAA,cAAA;;AAGb,MAAa,gBAAgBC;;AAG7B,MAAa,cAAcC,cAAAA;;AAG3B,MAAa,cAAA,cAAA;;AAGb,MAAa,YAAA,kBAAA;;AAGb,MAAa,cAAA,kBAAA;;AAGb,MAAa,aAAA,gBAAA;;AAGb,MAAa,eAAA,eAAA;;AAGb,MAAa,YAAA,gBAAA;;AAGb,MAAa,UAAA,gBAAA;;AAGb,MAAa,cAAA,aAAA"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as InlineLanguage, s as inlineFiles$1, t as index_d_exports$2 } from "./index-DBKL6vyC.cjs";
|
|
2
2
|
import { a as findCircularSchemas$1, i as collectUsedSchemaNames$1, n as collectImportedRefNames$1, r as collectSchemaRefs$1, t as index_d_exports$3 } from "./index-DfTgdgaH.cjs";
|
|
3
3
|
import { t as index_d_exports$4 } from "./index-BiXrjYNm.cjs";
|
|
4
4
|
import { a as mergeRefWithSchema$1, i as isBareRef$1, n as index_d_exports$9, o as resolveRef$1, t as getName } from "./index-D2tWPgnK.cjs";
|
|
5
5
|
import { n as narrowSchema$1, t as isHttpOperationNode$1 } from "./guards-B6LgmDhJ.cjs";
|
|
6
|
-
import { a as resolveSchemaProperties$1, d as applyOptionality, i as inferDiscriminatorPropertyName$1, r as getSchemaLiteralValues$1, t as index_d_exports$10 } from "./index-
|
|
7
|
-
import { S as TypeNode, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, g as CodeNode, h as BreakNode, i as ImportInput, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode, t as ExportInput, v as FunctionNode, x as TextNode, y as JSDocNode } from "./file-
|
|
6
|
+
import { a as resolveSchemaProperties$1, d as applyOptionality, i as inferDiscriminatorPropertyName$1, r as getSchemaLiteralValues$1, t as index_d_exports$10 } from "./index-CCUB1hoV.cjs";
|
|
7
|
+
import { S as TypeNode, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, g as CodeNode, h as BreakNode, i as ImportInput, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode, t as ExportInput, v as FunctionNode, x as TextNode, y as JSDocNode } from "./file-DJqd2j3y.cjs";
|
|
8
8
|
import { $ as PropertyNode, A as OAuthFlow, B as ObjectSchemaNode, C as AuthRequirement, D as InputNode, E as InputMeta, F as DatetimeSchemaNode, G as SchemaNode, H as RefSchemaNode, I as EnumSchemaNode, J as StringSchemaNode, K as SchemaNodeByType, L as IntersectionSchemaNode, M as ArraySchemaNode, N as BlobSchemaNode, O as InputServer, P as DateSchemaNode, R as NotSchemaNode, S as AuthCredential, T as ExternalDocs, U as ScalarSchemaNode, V as PrimitiveSchemaType, W as ScalarSchemaType, X as UnionSchemaNode, Y as TimeSchemaNode, Z as UrlSchemaNode, a as OperationsNode, b as ExampleNode, c as ResponseLink, f as RequestBodyNode, g as ParameterStyle, h as ParameterNode, i as OperationNode, k as InputTag, l as ResponseNode, m as ParameterLocation, n as HttpMethod, q as SchemaType, r as HttpOperationNode, t as GenericOperationNode, u as StatusCode, v as ContentNode, w as AuthScheme, y as EncodingNode, z as NumberSchemaNode } from "./operation-De4lbIZS.cjs";
|
|
9
|
-
import { a as compareMacroOrder, i as applyMacros$1, n as Enforce, o as defineMacro$1, r as Macro, t as index_d_exports$6 } from "./index-
|
|
10
|
-
import { n as getNodeText, t as index_d_exports$8 } from "./index-
|
|
11
|
-
import { n as index_d_exports$1, t as Node } from "./index-
|
|
9
|
+
import { a as compareMacroOrder, i as applyMacros$1, n as Enforce, o as defineMacro$1, r as Macro, t as index_d_exports$6 } from "./index-DNDNDzyJ.cjs";
|
|
10
|
+
import { n as getNodeText, t as index_d_exports$8 } from "./index-C5SXJAtZ.cjs";
|
|
11
|
+
import { n as index_d_exports$1, t as Node } from "./index-BjmAaymt.cjs";
|
|
12
12
|
import { t as index_d_exports$5 } from "./index-2hzFweaD.cjs";
|
|
13
|
-
import {
|
|
13
|
+
import { r as index_d_exports$7 } from "./index-OfWkiJ5O.cjs";
|
|
14
14
|
import { n as DistributiveOmit, r as NodeKind } from "./base-CyJhBRMi.cjs";
|
|
15
|
-
import { a as collect$1, n as VisitorContext, o as findSchema$1, s as transform$1, t as Visitor } from "./visitor-
|
|
15
|
+
import { a as collect$1, n as VisitorContext, o as findSchema$1, s as transform$1, t as Visitor } from "./visitor-BN5QJX7-.cjs";
|
|
16
16
|
/**
|
|
17
17
|
* Runtime context passed to printer handlers, both as `this` and as the second argument.
|
|
18
18
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as InlineLanguage, s as inlineFiles$1, t as index_d_exports$2 } from "./index-VPq6RwTm.js";
|
|
2
2
|
import { a as findCircularSchemas$1, i as collectUsedSchemaNames$1, n as collectImportedRefNames$1, r as collectSchemaRefs$1, t as index_d_exports$3 } from "./index-DerFkxlp.js";
|
|
3
3
|
import { t as index_d_exports$4 } from "./index-CC5Rmgcm.js";
|
|
4
4
|
import { a as mergeRefWithSchema$1, i as isBareRef$1, n as index_d_exports$9, o as resolveRef$1, t as getName } from "./index-YTyLBHFN.js";
|
|
5
5
|
import { n as narrowSchema$1, t as isHttpOperationNode$1 } from "./guards-l2AsKeHR.js";
|
|
6
|
-
import { a as resolveSchemaProperties$1, d as applyOptionality, i as inferDiscriminatorPropertyName$1, r as getSchemaLiteralValues$1, t as index_d_exports$10 } from "./index-
|
|
7
|
-
import { S as TypeNode, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, g as CodeNode, h as BreakNode, i as ImportInput, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode, t as ExportInput, v as FunctionNode, x as TextNode, y as JSDocNode } from "./file-
|
|
6
|
+
import { a as resolveSchemaProperties$1, d as applyOptionality, i as inferDiscriminatorPropertyName$1, r as getSchemaLiteralValues$1, t as index_d_exports$10 } from "./index-MzcNxet1.js";
|
|
7
|
+
import { S as TypeNode, _ as ConstNode, a as ImportNode, b as JsxNode, c as Space, g as CodeNode, h as BreakNode, i as ImportInput, l as UserFileNode, m as ArrowFunctionNode, n as ExportNode, o as ModuleName, r as FileNode, s as SourceNode, t as ExportInput, v as FunctionNode, x as TextNode, y as JSDocNode } from "./file-Dg70hXm3.js";
|
|
8
8
|
import { $ as PropertyNode, A as OAuthFlow, B as ObjectSchemaNode, C as AuthRequirement, D as InputNode, E as InputMeta, F as DatetimeSchemaNode, G as SchemaNode, H as RefSchemaNode, I as EnumSchemaNode, J as StringSchemaNode, K as SchemaNodeByType, L as IntersectionSchemaNode, M as ArraySchemaNode, N as BlobSchemaNode, O as InputServer, P as DateSchemaNode, R as NotSchemaNode, S as AuthCredential, T as ExternalDocs, U as ScalarSchemaNode, V as PrimitiveSchemaType, W as ScalarSchemaType, X as UnionSchemaNode, Y as TimeSchemaNode, Z as UrlSchemaNode, a as OperationsNode, b as ExampleNode, c as ResponseLink, f as RequestBodyNode, g as ParameterStyle, h as ParameterNode, i as OperationNode, k as InputTag, l as ResponseNode, m as ParameterLocation, n as HttpMethod, q as SchemaType, r as HttpOperationNode, t as GenericOperationNode, u as StatusCode, v as ContentNode, w as AuthScheme, y as EncodingNode, z as NumberSchemaNode } from "./operation-Dd0-l2VB.js";
|
|
9
|
-
import { a as compareMacroOrder, i as applyMacros$1, n as Enforce, o as defineMacro$1, r as Macro, t as index_d_exports$6 } from "./index-
|
|
10
|
-
import { n as getNodeText, t as index_d_exports$8 } from "./index-
|
|
11
|
-
import { n as index_d_exports$1, t as Node } from "./index-
|
|
9
|
+
import { a as compareMacroOrder, i as applyMacros$1, n as Enforce, o as defineMacro$1, r as Macro, t as index_d_exports$6 } from "./index-DXdwkq7X.js";
|
|
10
|
+
import { n as getNodeText, t as index_d_exports$8 } from "./index-Br4bwEnS.js";
|
|
11
|
+
import { n as index_d_exports$1, t as Node } from "./index-Bz33tfQo.js";
|
|
12
12
|
import { t as index_d_exports$5 } from "./index-f90iIhHX.js";
|
|
13
|
-
import {
|
|
13
|
+
import { r as index_d_exports$7 } from "./index-D3yqgtiN.js";
|
|
14
14
|
import { n as DistributiveOmit, r as NodeKind } from "./base-A-xF4pUL.js";
|
|
15
|
-
import { a as collect$1, n as VisitorContext, o as findSchema$1, s as transform$1, t as Visitor } from "./visitor-
|
|
15
|
+
import { a as collect$1, n as VisitorContext, o as findSchema$1, s as transform$1, t as Visitor } from "./visitor-BNGMMmpe.js";
|
|
16
16
|
/**
|
|
17
17
|
* Runtime context passed to printer handlers, both as `this` and as the second argument.
|
|
18
18
|
*
|
package/dist/index.js
CHANGED
|
@@ -9,9 +9,9 @@ import { i as resolveRef$1, n as mergeRefWithSchema$1, t as isBareRef$1 } from "
|
|
|
9
9
|
import { i as defineMacro$1, n as applyMacros$1, r as compareMacroOrder, t as macro_exports } from "./macro-3uGSg-ic.js";
|
|
10
10
|
import { t as node_exports } from "./node-Dm56432_.js";
|
|
11
11
|
import { t as applyOptionality } from "./optionality-FkRredTC.js";
|
|
12
|
-
import { n as inlineFiles$1, t as file_exports } from "./file-
|
|
12
|
+
import { n as inlineFiles$1, t as file_exports } from "./file-HwCmj--S.js";
|
|
13
13
|
import { n as getNodeText } from "./nodeText-DFak5VpX.js";
|
|
14
|
-
import { t as nodes_exports } from "./nodes-
|
|
14
|
+
import { t as nodes_exports } from "./nodes-u9i-tqFp.js";
|
|
15
15
|
import { t as http_exports } from "./http-CAWf6TAJ.js";
|
|
16
16
|
import { t as json_exports } from "./json-DeqPhPUQ.js";
|
|
17
17
|
import { r as mediaType_exports } from "./mediaType-DXQCNYdM.js";
|