@kubb/react-fabric 0.3.0 → 0.4.0
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/{Fabric-D1uNzkRd.d.cts → Fabric-DECM64S6.d.cts} +1 -1
- package/dist/{Fabric-OfeFgFB2.d.ts → Fabric-DGhsnD3H.d.ts} +1 -4
- package/dist/{chunk-CUT6urMc.cjs → chunk-DWy1uDak.cjs} +9 -0
- package/dist/chunk-OzOGZVnI.js +38 -0
- package/dist/{devtools-BajE-eCd.cjs → devtools-Bu3zlaPp.cjs} +2 -2
- package/dist/{devtools-BajE-eCd.cjs.map → devtools-Bu3zlaPp.cjs.map} +1 -1
- package/dist/{devtools-wdFpV122.js → devtools-D6dZodXp.js} +1 -1
- package/dist/{devtools-wdFpV122.js.map → devtools-D6dZodXp.js.map} +1 -1
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.js +1 -1
- package/dist/globals.d.cts +2 -2
- package/dist/globals.d.ts +2 -2
- package/dist/index.cjs +80 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -4
- package/dist/index.d.ts +27 -16
- package/dist/index.js +71 -57
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime-CB2e_LA2.js +1352 -0
- package/dist/jsx-dev-runtime-CB2e_LA2.js.map +1 -0
- package/dist/jsx-dev-runtime-CB3pf-1W.cjs +1363 -0
- package/dist/jsx-dev-runtime-CB3pf-1W.cjs.map +1 -0
- package/dist/jsx-dev-runtime.cjs +9 -5
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.d.cts +3 -3
- package/dist/jsx-dev-runtime.d.ts +3 -3
- package/dist/jsx-dev-runtime.js +9 -2
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/{jsx-namespace-kapEWb5o.d.cts → jsx-namespace-C5bbnidQ.d.cts} +2 -2
- package/dist/{jsx-namespace-BEUVmgyn.d.ts → jsx-namespace-eskZDKHk.d.ts} +2 -2
- package/dist/jsx-runtime-5qOQhPPb.js +252 -0
- package/dist/jsx-runtime-5qOQhPPb.js.map +1 -0
- package/dist/jsx-runtime-cOHyKGzA.cjs +263 -0
- package/dist/jsx-runtime-cOHyKGzA.cjs.map +1 -0
- package/dist/jsx-runtime.cjs +6 -8
- package/dist/jsx-runtime.d.cts +3 -3
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.js +6 -1
- package/dist/parsers.d.cts +1 -1
- package/dist/parsers.d.ts +1 -1
- package/dist/plugins.cjs +3 -2
- package/dist/plugins.d.cts +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +3 -2
- package/dist/reactPlugin-BWBCDdIm.js +15598 -0
- package/dist/reactPlugin-BWBCDdIm.js.map +1 -0
- package/dist/{reactPlugin-DVGn6gSn.d.ts → reactPlugin-DAOLEVg9.d.ts} +2 -2
- package/dist/reactPlugin-DCT6yE8D.cjs +15640 -0
- package/dist/reactPlugin-DCT6yE8D.cjs.map +1 -0
- package/dist/{reactPlugin-heqDYGKi.d.cts → reactPlugin-DkhxnXP_.d.cts} +2 -2
- package/dist/{types-zrCju594.d.cts → types-C2T-S5lY.d.cts} +2 -2
- package/dist/{types-34ycUiHt.d.ts → types-rKVyNQC0.d.ts} +2 -2
- package/dist/types.d.cts +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +5 -5
- package/src/index.ts +12 -2
- package/dist/jsx-runtime-BhbaU98p.cjs +0 -2
- package/dist/jsx-runtime-Dm0btT2y.js +0 -4
- package/dist/reactPlugin-B7zzvM5n.js +0 -625
- package/dist/reactPlugin-B7zzvM5n.js.map +0 -1
- package/dist/reactPlugin-B9OmXm5F.cjs +0 -669
- package/dist/reactPlugin-B9OmXm5F.cjs.map +0 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["RootContext","React","result: React.ReactNode[]","Root","reactPlugin","types: string[]","names: string[]","item","key","name","acc: string[]","parsedItem"],"sources":["../src/components/App.tsx","../src/utils/createJSDoc.ts","../src/components/Const.tsx","../src/components/File.tsx","../../../node_modules/.pnpm/indent-string@5.0.0/node_modules/indent-string/index.js","../src/components/Indent.tsx","../src/components/Function.tsx","../src/components/Type.tsx","../src/composables/useApp.ts","../src/composables/useFile.ts","../src/composables/useLifecycle.tsx","../src/createReactFabric.ts","../src/utils/getFunctionParams.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\nimport type { KubbNode } from '../types.ts'\nimport { RootContext } from './Root.tsx'\n\nexport type AppContextProps<TMeta = unknown> = {\n /**\n * Exit (unmount)\n */\n readonly exit: (error?: Error) => void\n readonly meta: TMeta\n}\n\nconst AppContext = createContext<AppContextProps | undefined>(undefined)\n\ntype Props<TMeta = unknown> = {\n readonly children?: KubbNode\n readonly meta: TMeta\n}\n\nexport function App<TMeta = unknown>({ meta, children }: Props<TMeta>) {\n const { exit } = useContext(RootContext)\n\n return <AppContext.Provider value={{ exit, meta }}>{children}</AppContext.Provider>\n}\n\nApp.Context = AppContext\nApp.displayName = 'KubbApp'\n","export function createJSDoc({ comments }: { comments: Array<string> }): string {\n const filtered = comments.filter((c) => c.trim())\n if (!filtered.length) {\n return ''\n }\n\n return `/**\\n * ${filtered.join('\\n * ')}\\n */`\n}\n","import type { JSDoc, Key, KubbNode } from '../types.ts'\n\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\ntype Props = {\n key?: Key\n /**\n * Name of the const\n */\n name: string\n /**\n * Does this type need to be exported.\n */\n export?: boolean\n /**\n * Type to make the const being typed\n */\n type?: string\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n /**\n * Use of `const` assertions\n */\n asConst?: boolean\n children?: KubbNode\n}\n\nexport function Const({ name, export: canExport, type, JSDoc, asConst, children }: Props) {\n return (\n <>\n {JSDoc?.comments && (\n <>\n {createJSDoc({ comments: JSDoc?.comments })}\n <br />\n </>\n )}\n {canExport && <>export </>}\n const {name}{' '}\n {type && (\n <>\n {':'}\n {type}{' '}\n </>\n )}\n = {children}\n {asConst && <> as const</>}\n </>\n )\n}\n\nConst.displayName = 'KubbConst'\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { createContext } from 'react'\nimport type { Key, KubbNode } from '../types.ts'\n\nexport type FileContextProps<TMeta extends object = object> = {\n /**\n * Name to be used to dynamicly create the baseName(based on input.path).\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: KubbFile.BaseName\n /**\n * Path will be full qualified path to a specified file.\n */\n path: KubbFile.Path\n meta?: TMeta\n}\nconst FileContext = createContext<FileContextProps>({} as FileContextProps)\n\ntype BasePropsWithBaseName = {\n /**\n * Name to be used to dynamicly create the baseName(based on input.path).\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: KubbFile.BaseName\n /**\n * Path will be full qualified path to a specified file.\n */\n path: KubbFile.Path\n}\n\ntype BasePropsWithoutBaseName = {\n baseName?: never\n /**\n * Path will be full qualified path to a specified file.\n */\n path?: KubbFile.Path\n}\n\ntype BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName\n\ntype Props<TMeta> = BaseProps & {\n key?: Key\n meta?: TMeta\n banner?: string\n footer?: string\n children?: KubbNode\n}\n\nexport function File<TMeta extends object = object>({ children, ...rest }: Props<TMeta>) {\n if (!rest.baseName || !rest.path) {\n return <>{children}</>\n }\n\n return (\n <kubb-file {...rest}>\n <FileContext.Provider value={{ baseName: rest.baseName, path: rest.path, meta: rest.meta }}>{children}</FileContext.Provider>\n </kubb-file>\n )\n}\n\nFile.displayName = 'KubbFile'\n\ntype FileSourceProps = Omit<KubbFile.Source, 'value'> & {\n key?: Key\n children?: KubbNode\n}\n\nfunction FileSource({ isTypeOnly, name, isExportable, isIndexable, children }: FileSourceProps) {\n return (\n <kubb-source name={name} isTypeOnly={isTypeOnly} isExportable={isExportable} isIndexable={isIndexable}>\n {children}\n </kubb-source>\n )\n}\n\nFileSource.displayName = 'KubbFileSource'\n\ntype FileExportProps = KubbFile.Export & { key?: Key }\n\nfunction FileExport({ name, path, isTypeOnly, asAlias }: FileExportProps) {\n return <kubb-export name={name} path={path} isTypeOnly={isTypeOnly || false} asAlias={asAlias} />\n}\n\nFileExport.displayName = 'KubbFileExport'\n\ntype FileImportProps = KubbFile.Import & { key?: Key }\n\nfunction FileImport({ name, root, path, isTypeOnly, isNameSpace }: FileImportProps) {\n return <kubb-import name={name} root={root} path={path} isNameSpace={isNameSpace} isTypeOnly={isTypeOnly || false} />\n}\n\nFileImport.displayName = 'KubbFileImport'\n\nFile.Export = FileExport\nFile.Import = FileImport\nFile.Source = FileSource\nFile.Context = FileContext\n","export default function indentString(string, count = 1, options = {}) {\n\tconst {\n\t\tindent = ' ',\n\t\tincludeEmptyLines = false\n\t} = options;\n\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t`Expected \\`input\\` to be a \\`string\\`, got \\`${typeof string}\\``\n\t\t);\n\t}\n\n\tif (typeof count !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t`Expected \\`count\\` to be a \\`number\\`, got \\`${typeof count}\\``\n\t\t);\n\t}\n\n\tif (count < 0) {\n\t\tthrow new RangeError(\n\t\t\t`Expected \\`count\\` to be at least 0, got \\`${count}\\``\n\t\t);\n\t}\n\n\tif (typeof indent !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t`Expected \\`options.indent\\` to be a \\`string\\`, got \\`${typeof indent}\\``\n\t\t);\n\t}\n\n\tif (count === 0) {\n\t\treturn string;\n\t}\n\n\tconst regex = includeEmptyLines ? /^/gm : /^(?!\\s*$)/gm;\n\n\treturn string.replace(regex, indent.repeat(count));\n}\n","import dedent from 'dedent'\nimport indentString from 'indent-string'\nimport React from 'react'\n\ntype IndentProps = {\n size?: number\n children?: React.ReactNode\n}\n\n/**\n * Indents all children by `size` spaces.\n * Collapses consecutive <br /> tags to at most 2.\n */\nexport function Indent({ size = 2, children }: IndentProps) {\n if (!children) return null\n\n const childrenArray = React.Children.toArray(children)\n const result: React.ReactNode[] = []\n\n let prevWasBr = false\n let brCount = 0\n\n for (const child of childrenArray) {\n if (React.isValidElement(child) && child.type === 'br') {\n if (!prevWasBr || brCount < 2) {\n result.push(child)\n brCount++\n }\n prevWasBr = true\n } else {\n prevWasBr = false\n brCount = 0\n result.push(child)\n }\n }\n\n return (\n <>\n {result.map((child) => {\n if (typeof child === 'string') {\n const cleaned = dedent(child)\n return <>{indentString(cleaned, size)}</>\n }\n return (\n <>\n {' '.repeat(size)}\n {child}\n </>\n )\n })}\n </>\n )\n}\n","import type { JSDoc, Key, KubbNode } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\nimport { Indent } from './Indent.tsx'\n\ntype Props = {\n key?: Key\n /**\n * Name of the function.\n */\n name: string\n /**\n * Add default when export is being used\n */\n default?: boolean\n /**\n * Parameters/options/props that need to be used.\n */\n params?: string\n /**\n * Does this function need to be exported.\n */\n export?: boolean\n /**\n * Does the function has async/promise behaviour.\n * This will also add `Promise<returnType>` as the returnType.\n */\n async?: boolean\n /**\n * Generics that needs to be added for TypeScript.\n */\n generics?: string | string[]\n\n /**\n * ReturnType(see async for adding Promise type).\n */\n returnType?: string\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n children?: KubbNode\n}\n\nexport function Function({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, children }: Props) {\n return (\n <>\n {JSDoc?.comments && (\n <>\n {createJSDoc({ comments: JSDoc?.comments })}\n <br />\n </>\n )}\n {canExport && <>export </>}\n {isDefault && <>default </>}\n {async && <>async </>}\n function {name}\n {generics && (\n <>\n {'<'}\n {Array.isArray(generics) ? generics.join(', ').trim() : generics}\n {'>'}\n </>\n )}\n ({params}){returnType && !async && <>: {returnType}</>}\n {returnType && async && (\n <>\n : Promise{'<'}\n {returnType}\n {'>'}\n </>\n )}\n {' {'}\n <br />\n <Indent size={2}>{children}</Indent>\n <br />\n {'}'}\n </>\n )\n}\n\nFunction.displayName = 'KubbFunction'\n\ntype ArrowFunctionProps = Props & {\n /**\n * Create Arrow function in one line\n */\n singleLine?: boolean\n}\n\nfunction ArrowFunction({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine, children }: ArrowFunctionProps) {\n return (\n <>\n {JSDoc?.comments && (\n <>\n {createJSDoc({ comments: JSDoc?.comments })}\n <br />\n </>\n )}\n {canExport && <>export </>}\n {isDefault && <>default </>}\n const {name} = {async && <>async </>}\n {generics && (\n <>\n {'<'}\n {Array.isArray(generics) ? generics.join(', ').trim() : generics}\n {'>'}\n </>\n )}\n ({params}){returnType && !async && <>: {returnType}</>}\n {returnType && async && (\n <>\n : Promise{'<'}\n {returnType}\n {'>'}\n </>\n )}\n {singleLine && (\n <>\n {' => '}\n {children}\n <br />\n </>\n )}\n {!singleLine && (\n <>\n {' => {'}\n <br />\n <Indent size={2}>{children}</Indent>\n <br />\n {'}'}\n <br />\n </>\n )}\n </>\n )\n}\n\nArrowFunction.displayName = 'KubbArrowFunction'\nFunction.Arrow = ArrowFunction\n","import type { JSDoc, Key, KubbNode } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\ntype Props = {\n key?: Key\n /**\n * Name of the type, this needs to start with a capital letter.\n */\n name: string\n /**\n * Does this type need to be exported.\n */\n export?: boolean\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n children?: KubbNode\n}\n\nexport function Type({ name, export: canExport, JSDoc, children }: Props) {\n if (name.charAt(0).toUpperCase() !== name.charAt(0)) {\n throw new Error('Name should start with a capital letter(see TypeScript types)')\n }\n\n return (\n <>\n {JSDoc?.comments && (\n <>\n {createJSDoc({ comments: JSDoc?.comments })}\n <br />\n </>\n )}\n {canExport && <>export </>}\n type {name} = {children}\n </>\n )\n}\n\nType.displayName = 'KubbType'\n","import { useContext } from 'react'\nimport { App, type AppContextProps } from '../components/App.tsx'\n\n/**\n * `useApp` will return the current App with plugin, pluginManager, fileManager and mode.\n */\nexport function useApp<TMeta = unknown>(): AppContextProps<TMeta> {\n const app = useContext(App.Context)\n\n if (!app) {\n throw new Error('<App /> should be set')\n }\n\n return app as AppContextProps<TMeta>\n}\n","import { useContext } from 'react'\nimport type { FileContextProps } from '../components/File.tsx'\nimport { File } from '../components/File.tsx'\n\n/**\n * `useFile` will return the current file when <File/> is used.\n */\nexport function useFile(): FileContextProps {\n const file = useContext(File.Context)\n\n return file as FileContextProps\n}\n","import { useContext } from 'react'\n\nimport { Root } from '../components/Root.tsx'\n\n/**\n * `useLifecycle` will return some helpers to exit/restart the generation.\n */\nexport function useLifecycle() {\n const { exit } = useContext(Root.Context)\n\n return {\n exit: () => {\n const timeout = setTimeout(() => {\n clearTimeout(timeout)\n\n exit()\n }, 0)\n },\n }\n}\n","import type { Fabric } from '@kubb/fabric-core'\nimport { createFabric } from '@kubb/fabric-core'\nimport type { FabricConfig, FabricMode } from '@kubb/fabric-core/types'\nimport { open } from './devtools.ts'\nimport type { Options } from './plugins/reactPlugin.ts'\nimport { reactPlugin } from './plugins/reactPlugin.ts'\n\nexport function createReactFabric(\n config: FabricConfig<Options & { mode?: FabricMode; devtools?: boolean }> = {},\n): Fabric<Options & { mode?: FabricMode; devtools?: boolean }> {\n const fabric = createFabric({ mode: config.mode })\n\n if (config.devtools) {\n open()\n }\n\n fabric.use(reactPlugin, {\n stdout: config.stdout,\n stderr: config.stderr,\n debug: config.debug,\n stdin: config.stdin,\n })\n\n return fabric\n}\n","import { orderBy } from 'natural-orderby'\n\nexport type Param = {\n /**\n * `object` will return the pathParams as an object.\n *\n * `inline` will return the pathParams as comma separated params.\n * @default `'inline'`\n * @private\n */\n mode?: 'object' | 'inline' | 'inlineSpread'\n type?: 'string' | 'number' | (string & {})\n optional?: boolean\n /**\n * @example test = \"default\"\n */\n default?: string\n /**\n * Used for no TypeScript(with mode object)\n * @example test: \"default\"\n */\n value?: string\n children?: Params\n}\n\ntype ParamItem =\n | (Pick<Param, 'mode' | 'type' | 'value'> & {\n optional?: true\n default?: never\n children?: Params\n })\n | (Pick<Param, 'mode' | 'type' | 'value'> & {\n optional?: false\n default?: string\n children?: Params\n })\n\nexport type Params = Record<string, Param | undefined>\n\ntype Options = {\n type: 'constructor' | 'call' | 'object' | 'objectValue'\n transformName?: (name: string) => string\n transformType?: (type: string) => string\n}\n\nfunction order(items: Array<[key: string, item?: ParamItem]>) {\n return orderBy(\n items.filter(Boolean),\n [\n ([_key, item]) => {\n if (item?.children) {\n return undefined\n }\n return !item?.default\n },\n ([_key, item]) => {\n if (item?.children) {\n return undefined\n }\n return !item?.optional\n },\n ],\n ['desc', 'desc'],\n )\n}\n\nfunction parseChild(key: string, item: ParamItem, options: Options): string | null {\n // @ts-expect-error\n const entries = order(Object.entries(item.children))\n\n const types: string[] = []\n const names: string[] = []\n\n const optional = entries.every(([_key, item]) => item?.optional)\n\n entries.forEach(([key, entryItem]) => {\n if (entryItem) {\n const name = parseItem(key, { ...entryItem, type: undefined }, options)\n if (entryItem.children) {\n const subTypes = Object.entries(entryItem.children)\n .map(([key]) => {\n return key\n })\n .join(', ')\n\n if (subTypes) {\n names.push(`${name}: { ${subTypes} }`)\n } else {\n names.push(name)\n }\n } else {\n if (options.type === 'call' && options.transformName) {\n names.push(`${key}: ${name}`)\n } else {\n names.push(name)\n }\n }\n\n if (entries.some(([_key, item]) => item?.type)) {\n types.push(parseItem(key, { ...entryItem, default: undefined }, options))\n }\n }\n })\n\n const name = item.mode === 'inline' ? key : names.length ? `{ ${names.join(', ')} }` : undefined\n const type = item.type ? item.type : types.length ? `{ ${types.join('; ')} }` : undefined\n\n if (!name) {\n return null\n }\n\n return parseItem(\n name,\n {\n type,\n default: item.default,\n optional: !item.default ? optional : undefined,\n } as ParamItem,\n options,\n )\n}\n\nfunction parseItem(name: string, item: ParamItem, options: Options): string {\n const acc: string[] = []\n const transformedName = options.transformName ? options.transformName(name) : name\n const transformedType = options.transformType && item.type ? options.transformType(item.type) : item.type\n\n if (options.type === 'object') {\n return transformedName\n }\n\n if (options.type === 'objectValue') {\n return item.value ? `${transformedName}: ${item.value}` : transformedName\n }\n\n //LEGACY\n if (item.type && options.type === 'constructor') {\n if (item.optional) {\n acc.push(`${transformedName}?: ${transformedType}`)\n } else {\n acc.push(`${transformedName}: ${transformedType}${item.default ? ` = ${item.default}` : ''}`)\n }\n } else if (item.default && options.type === 'constructor') {\n acc.push(`${transformedName} = ${item.default}`)\n } else if (item.value) {\n acc.push(`${transformedName} : ${item.value}`)\n } else if (item.mode === 'inlineSpread') {\n acc.push(`... ${transformedName}`)\n } else {\n acc.push(transformedName)\n }\n\n return acc[0] as string\n}\n\nexport function getFunctionParams(params: Params, options: Options): string {\n const entries = order(Object.entries(params as Record<string, ParamItem | undefined>))\n\n return entries\n .reduce((acc, [key, item]) => {\n if (!item) {\n return acc\n }\n\n if (item.children) {\n if (Object.keys(item.children).length === 0) {\n return acc\n }\n\n if (item.mode === 'inlineSpread') {\n return [...acc, getFunctionParams(item.children, options)]\n }\n\n const parsedItem = parseChild(key, item, options)\n if (!parsedItem) {\n return acc\n }\n\n return [...acc, parsedItem]\n }\n\n const parsedItem = parseItem(key, item, options)\n\n return [...acc, parsedItem]\n }, [] as string[])\n .join(', ')\n}\n\nexport function createFunctionParams(params: Params): Params {\n return params\n}\n// TODO use of zod\n//TODO use of string as `$name: $type` to create templates for functions instead of call/constructor\nexport class FunctionParams {\n #params: Params\n\n static factory(params: Params) {\n return new FunctionParams(params)\n }\n constructor(params: Params) {\n this.#params = params\n }\n\n get params(): Params {\n return this.#params\n }\n\n get flatParams(): Params {\n const flatter = (acc: Params, [key, item]: [key: string, item?: Param]): Params => {\n if (item?.children) {\n return Object.entries(item.children).reduce(flatter, acc)\n }\n if (item) {\n acc[key] = item\n }\n\n return acc\n }\n return Object.entries(this.#params).reduce(flatter, {} as Params)\n }\n\n toCall({ transformName, transformType }: Pick<Options, 'transformName' | 'transformType'> = {}): string {\n return getFunctionParams(this.#params, { type: 'call', transformName, transformType })\n }\n\n toObject(): string {\n return getFunctionParams(this.#params, { type: 'object' })\n }\n toObjectValue(): string {\n return getFunctionParams(this.#params, { type: 'objectValue' })\n }\n\n toConstructor(): string {\n return getFunctionParams(this.#params, { type: 'constructor' })\n }\n}\n"],"x_google_ignoreList":[4],"mappings":";;;;;;;;;;;;;AAYA,MAAM,sCAAwD,OAAU;AAOxE,SAAgB,IAAqB,EAAE,MAAM,YAA0B;CACrE,MAAM,EAAE,+BAAoBA,gCAAY;AAExC,QAAO,2CAAC,WAAW;EAAS,OAAO;GAAE;GAAM;GAAM;EAAG;GAA+B;;AAGrF,IAAI,UAAU;AACd,IAAI,cAAc;;;;AC1BlB,SAAgB,YAAY,EAAE,YAAiD;CAC7E,MAAM,WAAW,SAAS,QAAQ,MAAM,EAAE,MAAM,CAAC;AACjD,KAAI,CAAC,SAAS,OACZ,QAAO;AAGT,QAAO,WAAW,SAAS,KAAK,QAAQ,CAAC;;;;;ACuB3C,SAAgB,MAAM,EAAE,MAAM,QAAQ,WAAW,MAAM,OAAO,SAAS,YAAmB;AACxF,QACE;iDACG,MAAO,aACN,qFACG,YAAY,EAAE,wDAAU,MAAO,UAAU,CAAC,EAC3C,2CAAC,SAAK,IACL;EAEJ,aAAa,mFAAE,YAAU;EAAC;EACpB;EAAM;EACZ,QACC;GACG;GACA;GAAM;MACN;EACH;EACC;EACF,WAAW,mFAAE,cAAY;KACzB;;AAIP,MAAM,cAAc;;;;ACnCpB,MAAM,uCAA8C,EAAE,CAAqB;AAiC3E,SAAgB,KAAoC,EAAE,SAAU,GAAG,QAAsB;AACvF,KAAI,CAAC,KAAK,YAAY,CAAC,KAAK,KAC1B,QAAO,yEAAG,WAAY;AAGxB,QACE,2CAAC;EAAU,GAAI;YACb,2CAAC,YAAY;GAAS,OAAO;IAAE,UAAU,KAAK;IAAU,MAAM,KAAK;IAAM,MAAM,KAAK;IAAM;GAAG;IAAgC;GACnH;;AAIhB,KAAK,cAAc;AAOnB,SAAS,WAAW,EAAE,YAAY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K,SAAS,eAChB,QAAO,CAAC,GAAG,KAAK,kBAAkB,KAAK,UAAU,QAAQ,CAAC;GAG5D,MAAMC,eAAa,WAAW,KAAK,MAAM,QAAQ;AACjD,OAAI,CAACA,aACH,QAAO;AAGT,UAAO,CAAC,GAAG,KAAKA,aAAW;;EAG7B,MAAM,aAAa,UAAU,KAAK,MAAM,QAAQ;AAEhD,SAAO,CAAC,GAAG,KAAK,WAAW;IAC1B,EAAE,CAAa,CACjB,KAAK,KAAK;;AAGf,SAAgB,qBAAqB,QAAwB;AAC3D,QAAO;;;AAIT,IAAa,iBAAb,MAAa,eAAe;CAG1B,OAAO,QAAQ,QAAgB;AAC7B,SAAO,IAAI,eAAe,OAAO;;CAEnC,YAAY,QAAgB;;AAC1B,4DAAe,OAAM;;CAGvB,IAAI,SAAiB;AACnB,6DAAO,KAAY;;CAGrB,IAAI,aAAqB;EACvB,MAAM,WAAW,KAAa,CAAC,KAAK,UAA+C;AACjF,mDAAI,KAAM,SACR,QAAO,OAAO,QAAQ,KAAK,SAAS,CAAC,OAAO,SAAS,IAAI;AAE3D,OAAI,KACF,KAAI,OAAO;AAGb,UAAO;;AAET,SAAO,OAAO,4DAAQ,KAAY,CAAC,CAAC,OAAO,SAAS,EAAE,CAAW;;CAGnE,OAAO,EAAE,eAAe,kBAAoE,EAAE,EAAU;AACtG,SAAO,sEAAkB,KAAY,EAAE;GAAE,MAAM;GAAQ;GAAe;GAAe,CAAC;;CAGxF,WAAmB;AACjB,SAAO,sEAAkB,KAAY,EAAE,EAAE,MAAM,UAAU,CAAC;;CAE5D,gBAAwB;AACtB,SAAO,sEAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC;;CAGjE,gBAAwB;AACtB,SAAO,sEAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["RootContext","result: React.ReactNode[]","Root","reactPlugin","types: string[]","names: string[]","item","key","name","acc: string[]","parsedItem"],"sources":["../src/components/App.tsx","../src/utils/createJSDoc.ts","../src/components/Const.tsx","../src/components/File.tsx","../../../node_modules/.pnpm/indent-string@5.0.0/node_modules/indent-string/index.js","../src/components/Indent.tsx","../src/components/Function.tsx","../src/components/Type.tsx","../src/composables/useApp.ts","../src/composables/useFile.ts","../src/composables/useLifecycle.tsx","../src/createReactFabric.ts","../src/utils/getFunctionParams.ts","../src/index.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\nimport type { KubbNode } from '../types.ts'\nimport { RootContext } from './Root.tsx'\n\nexport type AppContextProps<TMeta = unknown> = {\n /**\n * Exit (unmount)\n */\n readonly exit: (error?: Error) => void\n readonly meta: TMeta\n}\n\nconst AppContext = createContext<AppContextProps | undefined>(undefined)\n\ntype Props<TMeta = unknown> = {\n readonly children?: KubbNode\n readonly meta: TMeta\n}\n\nexport function App<TMeta = unknown>({ meta, children }: Props<TMeta>) {\n const { exit } = useContext(RootContext)\n\n return <AppContext.Provider value={{ exit, meta }}>{children}</AppContext.Provider>\n}\n\nApp.Context = AppContext\nApp.displayName = 'KubbApp'\n","export function createJSDoc({ comments }: { comments: Array<string> }): string {\n const filtered = comments.filter((c) => c.trim())\n if (!filtered.length) {\n return ''\n }\n\n return `/**\\n * ${filtered.join('\\n * ')}\\n */`\n}\n","import type { JSDoc, Key, KubbNode } from '../types.ts'\n\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\ntype Props = {\n key?: Key\n /**\n * Name of the const\n */\n name: string\n /**\n * Does this type need to be exported.\n */\n export?: boolean\n /**\n * Type to make the const being typed\n */\n type?: string\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n /**\n * Use of `const` assertions\n */\n asConst?: boolean\n children?: KubbNode\n}\n\nexport function Const({ name, export: canExport, type, JSDoc, asConst, children }: Props) {\n return (\n <>\n {JSDoc?.comments && (\n <>\n {createJSDoc({ comments: JSDoc?.comments })}\n <br />\n </>\n )}\n {canExport && <>export </>}\n const {name}{' '}\n {type && (\n <>\n {':'}\n {type}{' '}\n </>\n )}\n = {children}\n {asConst && <> as const</>}\n </>\n )\n}\n\nConst.displayName = 'KubbConst'\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport { createContext } from 'react'\nimport type { Key, KubbNode } from '../types.ts'\n\nexport type FileContextProps<TMeta extends object = object> = {\n /**\n * Name to be used to dynamicly create the baseName(based on input.path).\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: KubbFile.BaseName\n /**\n * Path will be full qualified path to a specified file.\n */\n path: KubbFile.Path\n meta?: TMeta\n}\nconst FileContext = createContext<FileContextProps>({} as FileContextProps)\n\ntype BasePropsWithBaseName = {\n /**\n * Name to be used to dynamicly create the baseName(based on input.path).\n * Based on UNIX basename\n * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix\n */\n baseName: KubbFile.BaseName\n /**\n * Path will be full qualified path to a specified file.\n */\n path: KubbFile.Path\n}\n\ntype BasePropsWithoutBaseName = {\n baseName?: never\n /**\n * Path will be full qualified path to a specified file.\n */\n path?: KubbFile.Path\n}\n\ntype BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName\n\ntype Props<TMeta> = BaseProps & {\n key?: Key\n meta?: TMeta\n banner?: string\n footer?: string\n children?: KubbNode\n}\n\nexport function File<TMeta extends object = object>({ children, ...rest }: Props<TMeta>) {\n if (!rest.baseName || !rest.path) {\n return <>{children}</>\n }\n\n return (\n <kubb-file {...rest}>\n <FileContext.Provider value={{ baseName: rest.baseName, path: rest.path, meta: rest.meta }}>{children}</FileContext.Provider>\n </kubb-file>\n )\n}\n\nFile.displayName = 'KubbFile'\n\ntype FileSourceProps = Omit<KubbFile.Source, 'value'> & {\n key?: Key\n children?: KubbNode\n}\n\nfunction FileSource({ isTypeOnly, name, isExportable, isIndexable, children }: FileSourceProps) {\n return (\n <kubb-source name={name} isTypeOnly={isTypeOnly} isExportable={isExportable} isIndexable={isIndexable}>\n {children}\n </kubb-source>\n )\n}\n\nFileSource.displayName = 'KubbFileSource'\n\ntype FileExportProps = KubbFile.Export & { key?: Key }\n\nfunction FileExport({ name, path, isTypeOnly, asAlias }: FileExportProps) {\n return <kubb-export name={name} path={path} isTypeOnly={isTypeOnly || false} asAlias={asAlias} />\n}\n\nFileExport.displayName = 'KubbFileExport'\n\ntype FileImportProps = KubbFile.Import & { key?: Key }\n\nfunction FileImport({ name, root, path, isTypeOnly, isNameSpace }: FileImportProps) {\n return <kubb-import name={name} root={root} path={path} isNameSpace={isNameSpace} isTypeOnly={isTypeOnly || false} />\n}\n\nFileImport.displayName = 'KubbFileImport'\n\nFile.Export = FileExport\nFile.Import = FileImport\nFile.Source = FileSource\nFile.Context = FileContext\n","export default function indentString(string, count = 1, options = {}) {\n\tconst {\n\t\tindent = ' ',\n\t\tincludeEmptyLines = false\n\t} = options;\n\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t`Expected \\`input\\` to be a \\`string\\`, got \\`${typeof string}\\``\n\t\t);\n\t}\n\n\tif (typeof count !== 'number') {\n\t\tthrow new TypeError(\n\t\t\t`Expected \\`count\\` to be a \\`number\\`, got \\`${typeof count}\\``\n\t\t);\n\t}\n\n\tif (count < 0) {\n\t\tthrow new RangeError(\n\t\t\t`Expected \\`count\\` to be at least 0, got \\`${count}\\``\n\t\t);\n\t}\n\n\tif (typeof indent !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t`Expected \\`options.indent\\` to be a \\`string\\`, got \\`${typeof indent}\\``\n\t\t);\n\t}\n\n\tif (count === 0) {\n\t\treturn string;\n\t}\n\n\tconst regex = includeEmptyLines ? /^/gm : /^(?!\\s*$)/gm;\n\n\treturn string.replace(regex, indent.repeat(count));\n}\n","import dedent from 'dedent'\nimport indentString from 'indent-string'\nimport React from 'react'\n\ntype IndentProps = {\n size?: number\n children?: React.ReactNode\n}\n\n/**\n * Indents all children by `size` spaces.\n * Collapses consecutive <br /> tags to at most 2.\n */\nexport function Indent({ size = 2, children }: IndentProps) {\n if (!children) return null\n\n const childrenArray = React.Children.toArray(children)\n const result: React.ReactNode[] = []\n\n let prevWasBr = false\n let brCount = 0\n\n for (const child of childrenArray) {\n if (React.isValidElement(child) && child.type === 'br') {\n if (!prevWasBr || brCount < 2) {\n result.push(child)\n brCount++\n }\n prevWasBr = true\n } else {\n prevWasBr = false\n brCount = 0\n result.push(child)\n }\n }\n\n return (\n <>\n {result.map((child) => {\n if (typeof child === 'string') {\n const cleaned = dedent(child)\n return <>{indentString(cleaned, size)}</>\n }\n return (\n <>\n {' '.repeat(size)}\n {child}\n </>\n )\n })}\n </>\n )\n}\n","import type { JSDoc, Key, KubbNode } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\nimport { Indent } from './Indent.tsx'\n\ntype Props = {\n key?: Key\n /**\n * Name of the function.\n */\n name: string\n /**\n * Add default when export is being used\n */\n default?: boolean\n /**\n * Parameters/options/props that need to be used.\n */\n params?: string\n /**\n * Does this function need to be exported.\n */\n export?: boolean\n /**\n * Does the function has async/promise behaviour.\n * This will also add `Promise<returnType>` as the returnType.\n */\n async?: boolean\n /**\n * Generics that needs to be added for TypeScript.\n */\n generics?: string | string[]\n\n /**\n * ReturnType(see async for adding Promise type).\n */\n returnType?: string\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n children?: KubbNode\n}\n\nexport function Function({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, children }: Props) {\n return (\n <>\n {JSDoc?.comments && (\n <>\n {createJSDoc({ comments: JSDoc?.comments })}\n <br />\n </>\n )}\n {canExport && <>export </>}\n {isDefault && <>default </>}\n {async && <>async </>}\n function {name}\n {generics && (\n <>\n {'<'}\n {Array.isArray(generics) ? generics.join(', ').trim() : generics}\n {'>'}\n </>\n )}\n ({params}){returnType && !async && <>: {returnType}</>}\n {returnType && async && (\n <>\n : Promise{'<'}\n {returnType}\n {'>'}\n </>\n )}\n {' {'}\n <br />\n <Indent size={2}>{children}</Indent>\n <br />\n {'}'}\n </>\n )\n}\n\nFunction.displayName = 'KubbFunction'\n\ntype ArrowFunctionProps = Props & {\n /**\n * Create Arrow function in one line\n */\n singleLine?: boolean\n}\n\nfunction ArrowFunction({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine, children }: ArrowFunctionProps) {\n return (\n <>\n {JSDoc?.comments && (\n <>\n {createJSDoc({ comments: JSDoc?.comments })}\n <br />\n </>\n )}\n {canExport && <>export </>}\n {isDefault && <>default </>}\n const {name} = {async && <>async </>}\n {generics && (\n <>\n {'<'}\n {Array.isArray(generics) ? generics.join(', ').trim() : generics}\n {'>'}\n </>\n )}\n ({params}){returnType && !async && <>: {returnType}</>}\n {returnType && async && (\n <>\n : Promise{'<'}\n {returnType}\n {'>'}\n </>\n )}\n {singleLine && (\n <>\n {' => '}\n {children}\n <br />\n </>\n )}\n {!singleLine && (\n <>\n {' => {'}\n <br />\n <Indent size={2}>{children}</Indent>\n <br />\n {'}'}\n <br />\n </>\n )}\n </>\n )\n}\n\nArrowFunction.displayName = 'KubbArrowFunction'\nFunction.Arrow = ArrowFunction\n","import type { JSDoc, Key, KubbNode } from '../types.ts'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\n\ntype Props = {\n key?: Key\n /**\n * Name of the type, this needs to start with a capital letter.\n */\n name: string\n /**\n * Does this type need to be exported.\n */\n export?: boolean\n /**\n * Options for JSdocs.\n */\n JSDoc?: JSDoc\n children?: KubbNode\n}\n\nexport function Type({ name, export: canExport, JSDoc, children }: Props) {\n if (name.charAt(0).toUpperCase() !== name.charAt(0)) {\n throw new Error('Name should start with a capital letter(see TypeScript types)')\n }\n\n return (\n <>\n {JSDoc?.comments && (\n <>\n {createJSDoc({ comments: JSDoc?.comments })}\n <br />\n </>\n )}\n {canExport && <>export </>}\n type {name} = {children}\n </>\n )\n}\n\nType.displayName = 'KubbType'\n","import { useContext } from 'react'\nimport { App, type AppContextProps } from '../components/App.tsx'\n\n/**\n * `useApp` will return the current App with plugin, pluginManager, fileManager and mode.\n */\nexport function useApp<TMeta = unknown>(): AppContextProps<TMeta> {\n const app = useContext(App.Context)\n\n if (!app) {\n throw new Error('<App /> should be set')\n }\n\n return app as AppContextProps<TMeta>\n}\n","import { useContext } from 'react'\nimport type { FileContextProps } from '../components/File.tsx'\nimport { File } from '../components/File.tsx'\n\n/**\n * `useFile` will return the current file when <File/> is used.\n */\nexport function useFile(): FileContextProps {\n const file = useContext(File.Context)\n\n return file as FileContextProps\n}\n","import { useContext } from 'react'\n\nimport { Root } from '../components/Root.tsx'\n\n/**\n * `useLifecycle` will return some helpers to exit/restart the generation.\n */\nexport function useLifecycle() {\n const { exit } = useContext(Root.Context)\n\n return {\n exit: () => {\n const timeout = setTimeout(() => {\n clearTimeout(timeout)\n\n exit()\n }, 0)\n },\n }\n}\n","import type { Fabric } from '@kubb/fabric-core'\nimport { createFabric } from '@kubb/fabric-core'\nimport type { FabricConfig, FabricMode } from '@kubb/fabric-core/types'\nimport { open } from './devtools.ts'\nimport type { Options } from './plugins/reactPlugin.ts'\nimport { reactPlugin } from './plugins/reactPlugin.ts'\n\nexport function createReactFabric(\n config: FabricConfig<Options & { mode?: FabricMode; devtools?: boolean }> = {},\n): Fabric<Options & { mode?: FabricMode; devtools?: boolean }> {\n const fabric = createFabric({ mode: config.mode })\n\n if (config.devtools) {\n open()\n }\n\n fabric.use(reactPlugin, {\n stdout: config.stdout,\n stderr: config.stderr,\n debug: config.debug,\n stdin: config.stdin,\n })\n\n return fabric\n}\n","import { orderBy } from 'natural-orderby'\n\nexport type Param = {\n /**\n * `object` will return the pathParams as an object.\n *\n * `inline` will return the pathParams as comma separated params.\n * @default `'inline'`\n * @private\n */\n mode?: 'object' | 'inline' | 'inlineSpread'\n type?: 'string' | 'number' | (string & {})\n optional?: boolean\n /**\n * @example test = \"default\"\n */\n default?: string\n /**\n * Used for no TypeScript(with mode object)\n * @example test: \"default\"\n */\n value?: string\n children?: Params\n}\n\ntype ParamItem =\n | (Pick<Param, 'mode' | 'type' | 'value'> & {\n optional?: true\n default?: never\n children?: Params\n })\n | (Pick<Param, 'mode' | 'type' | 'value'> & {\n optional?: false\n default?: string\n children?: Params\n })\n\nexport type Params = Record<string, Param | undefined>\n\ntype Options = {\n type: 'constructor' | 'call' | 'object' | 'objectValue'\n transformName?: (name: string) => string\n transformType?: (type: string) => string\n}\n\nfunction order(items: Array<[key: string, item?: ParamItem]>) {\n return orderBy(\n items.filter(Boolean),\n [\n ([_key, item]) => {\n if (item?.children) {\n return undefined\n }\n return !item?.default\n },\n ([_key, item]) => {\n if (item?.children) {\n return undefined\n }\n return !item?.optional\n },\n ],\n ['desc', 'desc'],\n )\n}\n\nfunction parseChild(key: string, item: ParamItem, options: Options): string | null {\n // @ts-expect-error\n const entries = order(Object.entries(item.children))\n\n const types: string[] = []\n const names: string[] = []\n\n const optional = entries.every(([_key, item]) => item?.optional)\n\n entries.forEach(([key, entryItem]) => {\n if (entryItem) {\n const name = parseItem(key, { ...entryItem, type: undefined }, options)\n if (entryItem.children) {\n const subTypes = Object.entries(entryItem.children)\n .map(([key]) => {\n return key\n })\n .join(', ')\n\n if (subTypes) {\n names.push(`${name}: { ${subTypes} }`)\n } else {\n names.push(name)\n }\n } else {\n if (options.type === 'call' && options.transformName) {\n names.push(`${key}: ${name}`)\n } else {\n names.push(name)\n }\n }\n\n if (entries.some(([_key, item]) => item?.type)) {\n types.push(parseItem(key, { ...entryItem, default: undefined }, options))\n }\n }\n })\n\n const name = item.mode === 'inline' ? key : names.length ? `{ ${names.join(', ')} }` : undefined\n const type = item.type ? item.type : types.length ? `{ ${types.join('; ')} }` : undefined\n\n if (!name) {\n return null\n }\n\n return parseItem(\n name,\n {\n type,\n default: item.default,\n optional: !item.default ? optional : undefined,\n } as ParamItem,\n options,\n )\n}\n\nfunction parseItem(name: string, item: ParamItem, options: Options): string {\n const acc: string[] = []\n const transformedName = options.transformName ? options.transformName(name) : name\n const transformedType = options.transformType && item.type ? options.transformType(item.type) : item.type\n\n if (options.type === 'object') {\n return transformedName\n }\n\n if (options.type === 'objectValue') {\n return item.value ? `${transformedName}: ${item.value}` : transformedName\n }\n\n //LEGACY\n if (item.type && options.type === 'constructor') {\n if (item.optional) {\n acc.push(`${transformedName}?: ${transformedType}`)\n } else {\n acc.push(`${transformedName}: ${transformedType}${item.default ? ` = ${item.default}` : ''}`)\n }\n } else if (item.default && options.type === 'constructor') {\n acc.push(`${transformedName} = ${item.default}`)\n } else if (item.value) {\n acc.push(`${transformedName} : ${item.value}`)\n } else if (item.mode === 'inlineSpread') {\n acc.push(`... ${transformedName}`)\n } else {\n acc.push(transformedName)\n }\n\n return acc[0] as string\n}\n\nexport function getFunctionParams(params: Params, options: Options): string {\n const entries = order(Object.entries(params as Record<string, ParamItem | undefined>))\n\n return entries\n .reduce((acc, [key, item]) => {\n if (!item) {\n return acc\n }\n\n if (item.children) {\n if (Object.keys(item.children).length === 0) {\n return acc\n }\n\n if (item.mode === 'inlineSpread') {\n return [...acc, getFunctionParams(item.children, options)]\n }\n\n const parsedItem = parseChild(key, item, options)\n if (!parsedItem) {\n return acc\n }\n\n return [...acc, parsedItem]\n }\n\n const parsedItem = parseItem(key, item, options)\n\n return [...acc, parsedItem]\n }, [] as string[])\n .join(', ')\n}\n\nexport function createFunctionParams(params: Params): Params {\n return params\n}\n// TODO use of zod\n//TODO use of string as `$name: $type` to create templates for functions instead of call/constructor\nexport class FunctionParams {\n #params: Params\n\n static factory(params: Params) {\n return new FunctionParams(params)\n }\n constructor(params: Params) {\n this.#params = params\n }\n\n get params(): Params {\n return this.#params\n }\n\n get flatParams(): Params {\n const flatter = (acc: Params, [key, item]: [key: string, item?: Param]): Params => {\n if (item?.children) {\n return Object.entries(item.children).reduce(flatter, acc)\n }\n if (item) {\n acc[key] = item\n }\n\n return acc\n }\n return Object.entries(this.#params).reduce(flatter, {} as Params)\n }\n\n toCall({ transformName, transformType }: Pick<Options, 'transformName' | 'transformType'> = {}): string {\n return getFunctionParams(this.#params, { type: 'call', transformName, transformType })\n }\n\n toObject(): string {\n return getFunctionParams(this.#params, { type: 'object' })\n }\n toObjectValue(): string {\n return getFunctionParams(this.#params, { type: 'objectValue' })\n }\n\n toConstructor(): string {\n return getFunctionParams(this.#params, { type: 'constructor' })\n }\n}\n","// import './globals.ts'\nimport React from 'react'\n\n// expose fabric core helpers\nexport * from '@kubb/fabric-core'\n\n// react helpers\nexport const useState = React.useState\nexport const createContext = React.createContext\nexport const createElement = React.createElement\nexport const Fragment = React.Fragment\nexport const use = React.use\nexport const useContext = React.useContext\nexport const useEffect = React.useEffect\nexport const useReducer = React.useReducer\nexport const useRef = React.useRef\n// // components\nexport { App } from './components/App.tsx'\nexport { Const } from './components/Const.tsx'\nexport { File } from './components/File.tsx'\nexport { Function } from './components/Function.tsx'\nexport { Indent } from './components/Indent.tsx'\nexport { Type } from './components/Type.tsx'\nexport { useApp } from './composables/useApp.ts'\nexport { useFile } from './composables/useFile.ts'\nexport { useLifecycle } from './composables/useLifecycle.tsx'\nexport { createReactFabric } from './createReactFabric.ts'\nexport { Runtime } from './Runtime.tsx'\n// utils\nexport { createFunctionParams, FunctionParams } from './utils/getFunctionParams.ts'\n"],"x_google_ignoreList":[4],"mappings":";;;;;;;;;;;;AAYA,MAAM,6CAAwD,OAAU;AAOxE,SAAgB,IAAqB,EAAE,MAAM,YAA0B;CACrE,MAAM,EAAE,sCAAoBA,gCAAY;AAExC,QAAO,gEAAC,WAAW;EAAS,OAAO;GAAE;GAAM;GAAM;EAAG;GAA+B;;AAGrF,IAAI,UAAU;AACd,IAAI,cAAc;;;;AC1BlB,SAAgB,YAAY,EAAE,YAAiD;CAC7E,MAAM,WAAW,SAAS,QAAQ,MAAM,EAAE,MAAM,CAAC;AACjD,KAAI,CAAC,SAAS,OACZ,QAAO;AAGT,QAAO,WAAW,SAAS,KAAK,QAAQ,CAAC;;;;;ACuB3C,SAAgB,MAAM,EAAE,MAAM,QAAQ,WAAW,MAAM,OAAO,SAAS,YAAmB;AACxF,QACE;iDACG,MAAO,aACN,+HACG,YAAY,EAAE,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;AAET,SAAO,OAAO,4DAAQ,KAAY,CAAC,CAAC,OAAO,SAAS,EAAE,CAAW;;CAGnE,OAAO,EAAE,eAAe,kBAAoE,EAAE,EAAU;AACtG,SAAO,sEAAkB,KAAY,EAAE;GAAE,MAAM;GAAQ;GAAe;GAAe,CAAC;;CAGxF,WAAmB;AACjB,SAAO,sEAAkB,KAAY,EAAE,EAAE,MAAM,UAAU,CAAC;;CAE5D,gBAAwB;AACtB,SAAO,sEAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC;;CAGjE,gBAAwB;AACtB,SAAO,sEAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC;;;;;;AClOnE,MAAa,wBAAiB;AAC9B,MAAa,6BAAsB;AACnC,MAAa,6BAAsB;AACnC,MAAa,wBAAiB;AAC9B,MAAa,mBAAY;AACzB,MAAa,0BAAmB;AAChC,MAAa,yBAAkB;AAC/B,MAAa,0BAAmB;AAChC,MAAa,sBAAe"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as FabricOptions, b as Source, c as FileManager, f as BaseName, g as Import, h as File$1, i as FabricMode, l as FileProcessor, n as FabricConfig, p as Export, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-
|
|
2
|
-
import { a as JSDoc, d as KubbNode, g as FunctionParams, o as Key, y as createFunctionParams } from "./types-
|
|
3
|
-
import { t as Options$1 } from "./reactPlugin-
|
|
1
|
+
import { a as FabricOptions, b as Source, c as FileManager, f as BaseName, g as Import, h as File$1, i as FabricMode, l as FileProcessor, n as FabricConfig, p as Export, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-DECM64S6.cjs";
|
|
2
|
+
import { a as JSDoc, d as KubbNode, g as FunctionParams, o as Key, y as createFunctionParams } from "./types-C2T-S5lY.cjs";
|
|
3
|
+
import { t as Options$1 } from "./reactPlugin-DkhxnXP_.cjs";
|
|
4
4
|
import * as react0 from "react";
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { ReactNode } from "react";
|
|
6
6
|
|
|
7
7
|
//#region ../fabric-core/src/defineFabric.d.ts
|
|
8
8
|
/**
|
|
@@ -358,5 +358,16 @@ declare class Runtime {
|
|
|
358
358
|
waitUntilExit(): Promise<void>;
|
|
359
359
|
}
|
|
360
360
|
//#endregion
|
|
361
|
+
//#region src/index.d.ts
|
|
362
|
+
declare const useState: typeof React.useState;
|
|
363
|
+
declare const createContext: typeof React.createContext;
|
|
364
|
+
declare const createElement: typeof React.createElement;
|
|
365
|
+
declare const Fragment: React.ExoticComponent<React.FragmentProps>;
|
|
366
|
+
declare const use: typeof React.use;
|
|
367
|
+
declare const useContext: typeof React.useContext;
|
|
368
|
+
declare const useEffect: typeof React.useEffect;
|
|
369
|
+
declare const useReducer: typeof React.useReducer;
|
|
370
|
+
declare const useRef: typeof React.useRef;
|
|
371
|
+
//#endregion
|
|
361
372
|
export { App, Const, type Fabric, File, FileManager, FileProcessor, Fragment, Function, FunctionParams, Indent, Runtime, Type, createContext, createElement, createFabric, createFile, createFunctionParams, createReactFabric, defineFabric, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
|
|
362
373
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as FabricOptions, b as Source, c as FileManager, f as BaseName, g as Import, h as File$1, i as FabricMode, l as FileProcessor, n as FabricConfig, p as Export, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-
|
|
2
|
-
import { a as JSDoc, d as KubbNode, g as FunctionParams, o as Key, y as createFunctionParams } from "./types-
|
|
3
|
-
import { t as Options$1 } from "./reactPlugin-
|
|
4
|
-
import * as
|
|
5
|
-
import React, {
|
|
1
|
+
import { a as FabricOptions, b as Source, c as FileManager, f as BaseName, g as Import, h as File$1, i as FabricMode, l as FileProcessor, n as FabricConfig, p as Export, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-DGhsnD3H.js";
|
|
2
|
+
import { a as JSDoc, d as KubbNode, g as FunctionParams, o as Key, y as createFunctionParams } from "./types-rKVyNQC0.js";
|
|
3
|
+
import { t as Options$1 } from "./reactPlugin-DAOLEVg9.js";
|
|
4
|
+
import * as react4 from "react";
|
|
5
|
+
import React, { ReactNode } from "react";
|
|
6
6
|
|
|
7
7
|
//#region ../fabric-core/src/defineFabric.d.ts
|
|
8
8
|
/**
|
|
@@ -50,9 +50,9 @@ type Props$4<TMeta = unknown> = {
|
|
|
50
50
|
declare function App<TMeta = unknown>({
|
|
51
51
|
meta,
|
|
52
52
|
children
|
|
53
|
-
}: Props$4<TMeta>):
|
|
53
|
+
}: Props$4<TMeta>): react4.JSX.Element;
|
|
54
54
|
declare namespace App {
|
|
55
|
-
var Context:
|
|
55
|
+
var Context: react4.Context<AppContextProps<unknown> | undefined>;
|
|
56
56
|
var displayName: string;
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
@@ -88,7 +88,7 @@ declare function Const({
|
|
|
88
88
|
JSDoc,
|
|
89
89
|
asConst,
|
|
90
90
|
children
|
|
91
|
-
}: Props$3):
|
|
91
|
+
}: Props$3): react4.JSX.Element;
|
|
92
92
|
declare namespace Const {
|
|
93
93
|
var displayName: string;
|
|
94
94
|
}
|
|
@@ -137,13 +137,13 @@ type Props$2<TMeta> = BaseProps & {
|
|
|
137
137
|
declare function File<TMeta extends object = object>({
|
|
138
138
|
children,
|
|
139
139
|
...rest
|
|
140
|
-
}: Props$2<TMeta>):
|
|
140
|
+
}: Props$2<TMeta>): react4.JSX.Element;
|
|
141
141
|
declare namespace File {
|
|
142
142
|
var displayName: string;
|
|
143
143
|
var Export: typeof FileExport;
|
|
144
144
|
var Import: typeof FileImport;
|
|
145
145
|
var Source: typeof FileSource;
|
|
146
|
-
var Context:
|
|
146
|
+
var Context: react4.Context<FileContextProps<object>>;
|
|
147
147
|
}
|
|
148
148
|
type FileSourceProps = Omit<Source, 'value'> & {
|
|
149
149
|
key?: Key;
|
|
@@ -155,7 +155,7 @@ declare function FileSource({
|
|
|
155
155
|
isExportable,
|
|
156
156
|
isIndexable,
|
|
157
157
|
children
|
|
158
|
-
}: FileSourceProps):
|
|
158
|
+
}: FileSourceProps): react4.JSX.Element;
|
|
159
159
|
declare namespace FileSource {
|
|
160
160
|
var displayName: string;
|
|
161
161
|
}
|
|
@@ -167,7 +167,7 @@ declare function FileExport({
|
|
|
167
167
|
path,
|
|
168
168
|
isTypeOnly,
|
|
169
169
|
asAlias
|
|
170
|
-
}: FileExportProps):
|
|
170
|
+
}: FileExportProps): react4.JSX.Element;
|
|
171
171
|
declare namespace FileExport {
|
|
172
172
|
var displayName: string;
|
|
173
173
|
}
|
|
@@ -180,7 +180,7 @@ declare function FileImport({
|
|
|
180
180
|
path,
|
|
181
181
|
isTypeOnly,
|
|
182
182
|
isNameSpace
|
|
183
|
-
}: FileImportProps):
|
|
183
|
+
}: FileImportProps): react4.JSX.Element;
|
|
184
184
|
declare namespace FileImport {
|
|
185
185
|
var displayName: string;
|
|
186
186
|
}
|
|
@@ -233,7 +233,7 @@ declare function Function({
|
|
|
233
233
|
returnType,
|
|
234
234
|
JSDoc,
|
|
235
235
|
children
|
|
236
|
-
}: Props$1):
|
|
236
|
+
}: Props$1): react4.JSX.Element;
|
|
237
237
|
declare namespace Function {
|
|
238
238
|
var displayName: string;
|
|
239
239
|
var Arrow: typeof ArrowFunction;
|
|
@@ -255,7 +255,7 @@ declare function ArrowFunction({
|
|
|
255
255
|
JSDoc,
|
|
256
256
|
singleLine,
|
|
257
257
|
children
|
|
258
|
-
}: ArrowFunctionProps):
|
|
258
|
+
}: ArrowFunctionProps): react4.JSX.Element;
|
|
259
259
|
declare namespace ArrowFunction {
|
|
260
260
|
var displayName: string;
|
|
261
261
|
}
|
|
@@ -296,7 +296,7 @@ declare function Type({
|
|
|
296
296
|
export: canExport,
|
|
297
297
|
JSDoc,
|
|
298
298
|
children
|
|
299
|
-
}: Props):
|
|
299
|
+
}: Props): react4.JSX.Element;
|
|
300
300
|
declare namespace Type {
|
|
301
301
|
var displayName: string;
|
|
302
302
|
}
|
|
@@ -358,5 +358,16 @@ declare class Runtime {
|
|
|
358
358
|
waitUntilExit(): Promise<void>;
|
|
359
359
|
}
|
|
360
360
|
//#endregion
|
|
361
|
+
//#region src/index.d.ts
|
|
362
|
+
declare const useState: typeof React.useState;
|
|
363
|
+
declare const createContext: typeof React.createContext;
|
|
364
|
+
declare const createElement: typeof React.createElement;
|
|
365
|
+
declare const Fragment: React.ExoticComponent<React.FragmentProps>;
|
|
366
|
+
declare const use: typeof React.use;
|
|
367
|
+
declare const useContext: typeof React.useContext;
|
|
368
|
+
declare const useEffect: typeof React.useEffect;
|
|
369
|
+
declare const useReducer: typeof React.useReducer;
|
|
370
|
+
declare const useRef: typeof React.useRef;
|
|
371
|
+
//#endregion
|
|
361
372
|
export { App, Const, type Fabric, File, FileManager, FileProcessor, Fragment, Function, FunctionParams, Indent, Runtime, Type, createContext, createElement, createFabric, createFile, createFunctionParams, createReactFabric, defineFabric, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
|
|
362
373
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
1
|
+
import { r as __toESM } from "./chunk-OzOGZVnI.js";
|
|
2
|
+
import { n as require_react } from "./jsx-dev-runtime-CB2e_LA2.js";
|
|
3
|
+
import { a as _classPrivateFieldInitSpec, i as _classPrivateFieldGet2, n as Runtime, o as Root, r as _classPrivateFieldSet2, s as RootContext, t as reactPlugin } from "./reactPlugin-BWBCDdIm.js";
|
|
4
|
+
import { n as import_jsx_runtime } from "./jsx-runtime-5qOQhPPb.js";
|
|
5
|
+
import { t as open } from "./devtools-D6dZodXp.js";
|
|
4
6
|
import { createFabric } from "@kubb/fabric-core";
|
|
5
|
-
import React, { Fragment, createContext, createContext as createContext$1, createElement, use, useContext, useContext as useContext$1, useEffect, useReducer, useRef, useState } from "react";
|
|
6
7
|
import dedent from "dedent";
|
|
7
8
|
import { orderBy } from "natural-orderby";
|
|
8
9
|
|
|
9
10
|
export * from "@kubb/fabric-core"
|
|
10
11
|
|
|
11
12
|
//#region src/components/App.tsx
|
|
12
|
-
|
|
13
|
+
var import_react = require_react();
|
|
14
|
+
const AppContext = (0, import_react.createContext)(void 0);
|
|
13
15
|
function App({ meta, children }) {
|
|
14
|
-
const { exit } = useContext
|
|
15
|
-
return /* @__PURE__ */ jsx(AppContext.Provider, {
|
|
16
|
+
const { exit } = (0, import_react.useContext)(RootContext);
|
|
17
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppContext.Provider, {
|
|
16
18
|
value: {
|
|
17
19
|
exit,
|
|
18
20
|
meta
|
|
@@ -34,32 +36,32 @@ function createJSDoc({ comments }) {
|
|
|
34
36
|
//#endregion
|
|
35
37
|
//#region src/components/Const.tsx
|
|
36
38
|
function Const({ name, export: canExport, type, JSDoc, asConst, children }) {
|
|
37
|
-
return /* @__PURE__ */ jsxs(Fragment
|
|
38
|
-
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ jsxs(Fragment
|
|
39
|
-
canExport && /* @__PURE__ */ jsx(Fragment
|
|
39
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
40
|
+
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})] }),
|
|
41
|
+
canExport && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "export " }),
|
|
40
42
|
"const ",
|
|
41
43
|
name,
|
|
42
44
|
" ",
|
|
43
|
-
type && /* @__PURE__ */ jsxs(Fragment
|
|
45
|
+
type && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
44
46
|
":",
|
|
45
47
|
type,
|
|
46
48
|
" "
|
|
47
49
|
] }),
|
|
48
50
|
"= ",
|
|
49
51
|
children,
|
|
50
|
-
asConst && /* @__PURE__ */ jsx(Fragment
|
|
52
|
+
asConst && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: " as const" })
|
|
51
53
|
] });
|
|
52
54
|
}
|
|
53
55
|
Const.displayName = "KubbConst";
|
|
54
56
|
|
|
55
57
|
//#endregion
|
|
56
58
|
//#region src/components/File.tsx
|
|
57
|
-
const FileContext = createContext
|
|
58
|
-
function File({ children
|
|
59
|
-
if (!rest.baseName || !rest.path) return /* @__PURE__ */ jsx(Fragment
|
|
60
|
-
return /* @__PURE__ */ jsx("kubb-file", {
|
|
59
|
+
const FileContext = (0, import_react.createContext)({});
|
|
60
|
+
function File({ children, ...rest }) {
|
|
61
|
+
if (!rest.baseName || !rest.path) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
62
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kubb-file", {
|
|
61
63
|
...rest,
|
|
62
|
-
children: /* @__PURE__ */ jsx(FileContext.Provider, {
|
|
64
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileContext.Provider, {
|
|
63
65
|
value: {
|
|
64
66
|
baseName: rest.baseName,
|
|
65
67
|
path: rest.path,
|
|
@@ -71,7 +73,7 @@ function File({ children,...rest }) {
|
|
|
71
73
|
}
|
|
72
74
|
File.displayName = "KubbFile";
|
|
73
75
|
function FileSource({ isTypeOnly, name, isExportable, isIndexable, children }) {
|
|
74
|
-
return /* @__PURE__ */ jsx("kubb-source", {
|
|
76
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kubb-source", {
|
|
75
77
|
name,
|
|
76
78
|
isTypeOnly,
|
|
77
79
|
isExportable,
|
|
@@ -81,7 +83,7 @@ function FileSource({ isTypeOnly, name, isExportable, isIndexable, children }) {
|
|
|
81
83
|
}
|
|
82
84
|
FileSource.displayName = "KubbFileSource";
|
|
83
85
|
function FileExport({ name, path, isTypeOnly, asAlias }) {
|
|
84
|
-
return /* @__PURE__ */ jsx("kubb-export", {
|
|
86
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kubb-export", {
|
|
85
87
|
name,
|
|
86
88
|
path,
|
|
87
89
|
isTypeOnly: isTypeOnly || false,
|
|
@@ -90,7 +92,7 @@ function FileExport({ name, path, isTypeOnly, asAlias }) {
|
|
|
90
92
|
}
|
|
91
93
|
FileExport.displayName = "KubbFileExport";
|
|
92
94
|
function FileImport({ name, root, path, isTypeOnly, isNameSpace }) {
|
|
93
|
-
return /* @__PURE__ */ jsx("kubb-import", {
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kubb-import", {
|
|
94
96
|
name,
|
|
95
97
|
root,
|
|
96
98
|
path,
|
|
@@ -125,11 +127,11 @@ function indentString(string, count = 1, options = {}) {
|
|
|
125
127
|
*/
|
|
126
128
|
function Indent({ size = 2, children }) {
|
|
127
129
|
if (!children) return null;
|
|
128
|
-
const childrenArray =
|
|
130
|
+
const childrenArray = import_react.Children.toArray(children);
|
|
129
131
|
const result = [];
|
|
130
132
|
let prevWasBr = false;
|
|
131
133
|
let brCount = 0;
|
|
132
|
-
for (const child of childrenArray) if (
|
|
134
|
+
for (const child of childrenArray) if (import_react.isValidElement(child) && child.type === "br") {
|
|
133
135
|
if (!prevWasBr || brCount < 2) {
|
|
134
136
|
result.push(child);
|
|
135
137
|
brCount++;
|
|
@@ -140,23 +142,23 @@ function Indent({ size = 2, children }) {
|
|
|
140
142
|
brCount = 0;
|
|
141
143
|
result.push(child);
|
|
142
144
|
}
|
|
143
|
-
return /* @__PURE__ */ jsx(Fragment
|
|
144
|
-
if (typeof child === "string") return /* @__PURE__ */ jsx(Fragment
|
|
145
|
-
return /* @__PURE__ */ jsxs(Fragment
|
|
145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: result.map((child) => {
|
|
146
|
+
if (typeof child === "string") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: indentString(dedent(child), size) });
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [" ".repeat(size), child] });
|
|
146
148
|
}) });
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
//#endregion
|
|
150
152
|
//#region src/components/Function.tsx
|
|
151
153
|
function Function({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, children }) {
|
|
152
|
-
return /* @__PURE__ */ jsxs(Fragment
|
|
153
|
-
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ jsxs(Fragment
|
|
154
|
-
canExport && /* @__PURE__ */ jsx(Fragment
|
|
155
|
-
isDefault && /* @__PURE__ */ jsx(Fragment
|
|
156
|
-
async && /* @__PURE__ */ jsx(Fragment
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
155
|
+
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})] }),
|
|
156
|
+
canExport && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "export " }),
|
|
157
|
+
isDefault && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "default " }),
|
|
158
|
+
async && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "async " }),
|
|
157
159
|
"function ",
|
|
158
160
|
name,
|
|
159
|
-
generics && /* @__PURE__ */ jsxs(Fragment
|
|
161
|
+
generics && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
160
162
|
"<",
|
|
161
163
|
Array.isArray(generics) ? generics.join(", ").trim() : generics,
|
|
162
164
|
">"
|
|
@@ -164,34 +166,34 @@ function Function({ name, default: isDefault, export: canExport, async, generics
|
|
|
164
166
|
"(",
|
|
165
167
|
params,
|
|
166
168
|
")",
|
|
167
|
-
returnType && !async && /* @__PURE__ */ jsxs(Fragment
|
|
168
|
-
returnType && async && /* @__PURE__ */ jsxs(Fragment
|
|
169
|
+
returnType && !async && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [": ", returnType] }),
|
|
170
|
+
returnType && async && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
169
171
|
": Promise",
|
|
170
172
|
"<",
|
|
171
173
|
returnType,
|
|
172
174
|
">"
|
|
173
175
|
] }),
|
|
174
176
|
" {",
|
|
175
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
176
|
-
/* @__PURE__ */ jsx(Indent, {
|
|
177
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
178
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Indent, {
|
|
177
179
|
size: 2,
|
|
178
180
|
children
|
|
179
181
|
}),
|
|
180
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
182
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
181
183
|
"}"
|
|
182
184
|
] });
|
|
183
185
|
}
|
|
184
186
|
Function.displayName = "KubbFunction";
|
|
185
187
|
function ArrowFunction({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine, children }) {
|
|
186
|
-
return /* @__PURE__ */ jsxs(Fragment
|
|
187
|
-
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ jsxs(Fragment
|
|
188
|
-
canExport && /* @__PURE__ */ jsx(Fragment
|
|
189
|
-
isDefault && /* @__PURE__ */ jsx(Fragment
|
|
188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
189
|
+
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})] }),
|
|
190
|
+
canExport && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "export " }),
|
|
191
|
+
isDefault && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "default " }),
|
|
190
192
|
"const ",
|
|
191
193
|
name,
|
|
192
194
|
" = ",
|
|
193
|
-
async && /* @__PURE__ */ jsx(Fragment
|
|
194
|
-
generics && /* @__PURE__ */ jsxs(Fragment
|
|
195
|
+
async && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "async " }),
|
|
196
|
+
generics && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
195
197
|
"<",
|
|
196
198
|
Array.isArray(generics) ? generics.join(", ").trim() : generics,
|
|
197
199
|
">"
|
|
@@ -199,28 +201,28 @@ function ArrowFunction({ name, default: isDefault, export: canExport, async, gen
|
|
|
199
201
|
"(",
|
|
200
202
|
params,
|
|
201
203
|
")",
|
|
202
|
-
returnType && !async && /* @__PURE__ */ jsxs(Fragment
|
|
203
|
-
returnType && async && /* @__PURE__ */ jsxs(Fragment
|
|
204
|
+
returnType && !async && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [": ", returnType] }),
|
|
205
|
+
returnType && async && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
204
206
|
": Promise",
|
|
205
207
|
"<",
|
|
206
208
|
returnType,
|
|
207
209
|
">"
|
|
208
210
|
] }),
|
|
209
|
-
singleLine && /* @__PURE__ */ jsxs(Fragment
|
|
211
|
+
singleLine && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
210
212
|
" => ",
|
|
211
213
|
children,
|
|
212
|
-
/* @__PURE__ */ jsx("br", {})
|
|
214
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})
|
|
213
215
|
] }),
|
|
214
|
-
!singleLine && /* @__PURE__ */ jsxs(Fragment
|
|
216
|
+
!singleLine && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
215
217
|
" => {",
|
|
216
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
217
|
-
/* @__PURE__ */ jsx(Indent, {
|
|
218
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
219
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Indent, {
|
|
218
220
|
size: 2,
|
|
219
221
|
children
|
|
220
222
|
}),
|
|
221
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
223
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
222
224
|
"}",
|
|
223
|
-
/* @__PURE__ */ jsx("br", {})
|
|
225
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})
|
|
224
226
|
] })
|
|
225
227
|
] });
|
|
226
228
|
}
|
|
@@ -231,9 +233,9 @@ Function.Arrow = ArrowFunction;
|
|
|
231
233
|
//#region src/components/Type.tsx
|
|
232
234
|
function Type({ name, export: canExport, JSDoc, children }) {
|
|
233
235
|
if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
|
|
234
|
-
return /* @__PURE__ */ jsxs(Fragment
|
|
235
|
-
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ jsxs(Fragment
|
|
236
|
-
canExport && /* @__PURE__ */ jsx(Fragment
|
|
236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
237
|
+
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {})] }),
|
|
238
|
+
canExport && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: "export " }),
|
|
237
239
|
"type ",
|
|
238
240
|
name,
|
|
239
241
|
" = ",
|
|
@@ -248,7 +250,7 @@ Type.displayName = "KubbType";
|
|
|
248
250
|
* `useApp` will return the current App with plugin, pluginManager, fileManager and mode.
|
|
249
251
|
*/
|
|
250
252
|
function useApp() {
|
|
251
|
-
const app = useContext
|
|
253
|
+
const app = (0, import_react.useContext)(App.Context);
|
|
252
254
|
if (!app) throw new Error("<App /> should be set");
|
|
253
255
|
return app;
|
|
254
256
|
}
|
|
@@ -259,7 +261,7 @@ function useApp() {
|
|
|
259
261
|
* `useFile` will return the current file when <File/> is used.
|
|
260
262
|
*/
|
|
261
263
|
function useFile() {
|
|
262
|
-
return useContext
|
|
264
|
+
return (0, import_react.useContext)(File.Context);
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
//#endregion
|
|
@@ -268,7 +270,7 @@ function useFile() {
|
|
|
268
270
|
* `useLifecycle` will return some helpers to exit/restart the generation.
|
|
269
271
|
*/
|
|
270
272
|
function useLifecycle() {
|
|
271
|
-
const { exit } = useContext
|
|
273
|
+
const { exit } = (0, import_react.useContext)(Root.Context);
|
|
272
274
|
return { exit: () => {
|
|
273
275
|
const timeout = setTimeout(() => {
|
|
274
276
|
clearTimeout(timeout);
|
|
@@ -405,6 +407,18 @@ var FunctionParams = class FunctionParams {
|
|
|
405
407
|
}
|
|
406
408
|
};
|
|
407
409
|
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/index.ts
|
|
412
|
+
const useState = import_react.useState;
|
|
413
|
+
const createContext = import_react.createContext;
|
|
414
|
+
const createElement = import_react.createElement;
|
|
415
|
+
const Fragment = import_react.Fragment;
|
|
416
|
+
const use = import_react.use;
|
|
417
|
+
const useContext = import_react.useContext;
|
|
418
|
+
const useEffect = import_react.useEffect;
|
|
419
|
+
const useReducer = import_react.useReducer;
|
|
420
|
+
const useRef = import_react.useRef;
|
|
421
|
+
|
|
408
422
|
//#endregion
|
|
409
423
|
export { App, Const, File, Fragment, Function, FunctionParams, Indent, Runtime, Type, createContext, createElement, createFunctionParams, createReactFabric, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
|
|
410
424
|
//# sourceMappingURL=index.js.map
|