@kubb/react-fabric 0.2.12 → 0.2.14

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.
@@ -1,5 +1,5 @@
1
1
  import "./Fabric-B8W5_3xv.cjs";
2
- import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-C_IFxocB.cjs";
2
+ import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-kzoLNjog.cjs";
3
3
  import React from "react";
4
4
 
5
5
  //#region src/globals.d.ts
package/dist/globals.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./Fabric-mFmfnVJp.js";
2
- import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-BskFKkPW.js";
2
+ import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-DAb8l-KJ.js";
3
3
  import React from "react";
4
4
 
5
5
  //#region src/globals.d.ts
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_plugins = require('./plugins-DzBEnan-.cjs');
2
+ const require_reactPlugin = require('./reactPlugin-DN7FaU4S.cjs');
3
3
  require('./jsx-runtime-CpPZNgzW.cjs');
4
4
  const require_devtools = require('./devtools-D4p2T_2t.cjs');
5
5
  let react = require("react");
@@ -16,7 +16,7 @@ react_jsx_runtime = require_chunk.__toESM(react_jsx_runtime);
16
16
  //#region src/components/App.tsx
17
17
  const AppContext = (0, react.createContext)(void 0);
18
18
  function App({ meta, children }) {
19
- const { exit } = (0, react.useContext)(require_plugins.RootContext);
19
+ const { exit } = (0, react.useContext)(require_reactPlugin.RootContext);
20
20
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AppContext.Provider, {
21
21
  value: {
22
22
  exit,
@@ -275,7 +275,7 @@ function useFile() {
275
275
  * `useLifecycle` will return some helpers to exit/restart the generation.
276
276
  */
277
277
  function useLifecycle() {
278
- const { exit } = (0, react.useContext)(require_plugins.Root.Context);
278
+ const { exit } = (0, react.useContext)(require_reactPlugin.Root.Context);
279
279
  return { exit: () => {
280
280
  setTimeout(() => {
281
281
  exit();
@@ -289,7 +289,7 @@ function createReactFabric(config) {
289
289
  var _config$options;
290
290
  const fabric = (0, __kubb_fabric_core.createFabric)(config);
291
291
  if (config === null || config === void 0 || (_config$options = config.options) === null || _config$options === void 0 ? void 0 : _config$options.devtools) require_devtools.open();
292
- fabric.use(require_plugins.reactPlugin, config === null || config === void 0 ? void 0 : config.options);
292
+ fabric.use(require_reactPlugin.reactPlugin, config === null || config === void 0 ? void 0 : config.options);
293
293
  return fabric;
294
294
  }
295
295
 
@@ -375,11 +375,11 @@ var FunctionParams = class FunctionParams {
375
375
  return new FunctionParams(params);
376
376
  }
377
377
  constructor(params) {
378
- require_plugins._classPrivateFieldInitSpec(this, _params, void 0);
379
- require_plugins._classPrivateFieldSet2(_params, this, params);
378
+ require_reactPlugin._classPrivateFieldInitSpec(this, _params, void 0);
379
+ require_reactPlugin._classPrivateFieldSet2(_params, this, params);
380
380
  }
381
381
  get params() {
382
- return require_plugins._classPrivateFieldGet2(_params, this);
382
+ return require_reactPlugin._classPrivateFieldGet2(_params, this);
383
383
  }
384
384
  get flatParams() {
385
385
  const flatter = (acc, [key, item]) => {
@@ -387,23 +387,23 @@ var FunctionParams = class FunctionParams {
387
387
  if (item) acc[key] = item;
388
388
  return acc;
389
389
  };
390
- return Object.entries(require_plugins._classPrivateFieldGet2(_params, this)).reduce(flatter, {});
390
+ return Object.entries(require_reactPlugin._classPrivateFieldGet2(_params, this)).reduce(flatter, {});
391
391
  }
392
392
  toCall({ transformName, transformType } = {}) {
393
- return getFunctionParams(require_plugins._classPrivateFieldGet2(_params, this), {
393
+ return getFunctionParams(require_reactPlugin._classPrivateFieldGet2(_params, this), {
394
394
  type: "call",
395
395
  transformName,
396
396
  transformType
397
397
  });
398
398
  }
399
399
  toObject() {
400
- return getFunctionParams(require_plugins._classPrivateFieldGet2(_params, this), { type: "object" });
400
+ return getFunctionParams(require_reactPlugin._classPrivateFieldGet2(_params, this), { type: "object" });
401
401
  }
402
402
  toObjectValue() {
403
- return getFunctionParams(require_plugins._classPrivateFieldGet2(_params, this), { type: "objectValue" });
403
+ return getFunctionParams(require_reactPlugin._classPrivateFieldGet2(_params, this), { type: "objectValue" });
404
404
  }
405
405
  toConstructor() {
406
- return getFunctionParams(require_plugins._classPrivateFieldGet2(_params, this), { type: "constructor" });
406
+ return getFunctionParams(require_reactPlugin._classPrivateFieldGet2(_params, this), { type: "constructor" });
407
407
  }
408
408
  };
409
409
 
@@ -420,7 +420,7 @@ Object.defineProperty(exports, 'Fragment', {
420
420
  exports.Function = Function;
421
421
  exports.FunctionParams = FunctionParams;
422
422
  exports.Indent = Indent;
423
- exports.Runtime = require_plugins.Runtime;
423
+ exports.Runtime = require_reactPlugin.Runtime;
424
424
  exports.Type = Type;
425
425
  Object.defineProperty(exports, 'createContext', {
426
426
  enumerable: true,
@@ -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 filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return ''\n }\n\n return `/**\\n * ${filteredComments.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 { createContext } from 'react'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\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 filtered = React.Children.toArray(children).filter(Boolean)\n const result: React.ReactNode[] = []\n\n let prevWasBr = false\n let brCount = 0\n\n filtered.forEach((child) => {\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 { Indent } from './Indent.tsx'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\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'\n\nimport { File } from '../components/File.tsx'\n\nimport type { FileContextProps } 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 setTimeout(() => {\n exit()\n }, 0)\n },\n }\n}\n","import { createFabric } from '@kubb/fabric-core'\nimport { reactPlugin } from '@kubb/react-fabric/plugins'\nimport type { Options } from './plugins/reactPlugin.ts'\nimport type { FabricConfig, FabricMode } from '@kubb/fabric-core/types'\nimport { open } from './devtools.ts'\n\nexport function createReactFabric(config?: FabricConfig<Options & { mode?: FabricMode; devtools?: boolean }>) {\n const fabric = createFabric(config)\n\n if (config?.options?.devtools) {\n open()\n }\n\n fabric.use(reactPlugin, config?.options)\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,4BAAY;AAExC,QAAO,2CAAC,WAAW;EAAS,OAAO;GAAE;GAAM;GAAM;EAAG;GAA+B;;AAGrF,IAAI,UAAU;AACd,IAAI,cAAc;;;;AC1BlB,SAAgB,YAAY,EAAE,YAAiD;C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vB,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,wDAAQ,KAAY,CAAC,CAAC,OAAO,SAAS,EAAE,CAAW;;CAGnE,OAAO,EAAE,eAAe,kBAAoE,EAAE,EAAU;AACtG,SAAO,kEAAkB,KAAY,EAAE;GAAE,MAAM;GAAQ;GAAe;GAAe,CAAC;;CAGxF,WAAmB;AACjB,SAAO,kEAAkB,KAAY,EAAE,EAAE,MAAM,UAAU,CAAC;;CAE5D,gBAAwB;AACtB,SAAO,kEAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC;;CAGjE,gBAAwB;AACtB,SAAO,kEAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC"}
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 filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return ''\n }\n\n return `/**\\n * ${filteredComments.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 { createContext } from 'react'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\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 filtered = React.Children.toArray(children).filter(Boolean)\n const result: React.ReactNode[] = []\n\n let prevWasBr = false\n let brCount = 0\n\n filtered.forEach((child) => {\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 { Indent } from './Indent.tsx'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\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'\n\nimport { File } from '../components/File.tsx'\n\nimport type { FileContextProps } 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 setTimeout(() => {\n exit()\n }, 0)\n },\n }\n}\n","import { createFabric } from '@kubb/fabric-core'\nimport type { Fabric } from '@kubb/fabric-core'\nimport type { Options } from './plugins/reactPlugin.ts'\n\nimport { reactPlugin } from './plugins/reactPlugin.ts'\nimport type { FabricConfig, FabricMode } from '@kubb/fabric-core/types'\nimport { open } from './devtools.ts'\n\nexport function createReactFabric(\n config?: FabricConfig<Options & { mode?: FabricMode; devtools?: boolean }>,\n): Fabric<Options & { mode?: FabricMode; devtools?: boolean }> {\n const fabric = createFabric(config)\n\n if (config?.options?.devtools) {\n open()\n }\n\n fabric.use(reactPlugin, config?.options)\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,mBAAmB,SAAS,OAAO,QAAQ;AAEjD,KAAI,CAAC,iBAAiB,OACpB,QAAO;AAGT,QAAO,WAAW,iBAAiB,KAAK,QAAQ,CAAC;;;;;ACsBnD,SAAgB,MAAM,EAAE,MAAM,QAAQ,WAAW,MAAM,OAAO,SAAS,YAAm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AAC,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"}
package/dist/index.d.cts CHANGED
@@ -1,18 +1,9 @@
1
1
  import { a as FabricOptions, b as Source, f as BaseName, g as Import, h as File$1, i as FabricMode, n as FabricConfig, o as FileManager, p as Export, s as FileProcessor, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-B8W5_3xv.cjs";
2
- import { a as JSDoc, b as DefineFabric, d as KubbNode, g as FunctionParams, o as Key, x as defineFabric, y as createFunctionParams } from "./types-C_IFxocB.cjs";
2
+ import { a as JSDoc, b as DefineFabric, d as KubbNode, g as FunctionParams, o as Key, x as defineFabric, y as createFunctionParams } from "./types-kzoLNjog.cjs";
3
3
  import { t as Options$1 } from "./reactPlugin-wV1eBuBU.cjs";
4
4
  import * as react0 from "react";
5
5
  import React, { Fragment, ReactNode, createContext, createElement, use, useContext, useEffect, useReducer, useRef, useState } from "react";
6
6
 
7
- //#region ../fabric-core/src/createFabric.d.ts
8
- declare const createFabric: DefineFabric<FabricOptions>;
9
- //#endregion
10
- //#region ../fabric-core/src/createFile.d.ts
11
- /**
12
- * Helper to create a file with name and id set
13
- */
14
- declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
15
- //#endregion
16
7
  //#region src/components/App.d.ts
17
8
  type AppContextProps<TMeta = unknown> = {
18
9
  /**
@@ -299,11 +290,23 @@ declare function useLifecycle(): {
299
290
  exit: () => void;
300
291
  };
301
292
  //#endregion
293
+ //#region ../fabric-core/src/createFabric.d.ts
294
+ declare const createFabric: DefineFabric<FabricOptions>;
295
+ //#endregion
296
+ //#region ../fabric-core/src/createFile.d.ts
297
+ /**
298
+ * Helper to create a file with name and id set
299
+ */
300
+ declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
301
+ //#endregion
302
302
  //#region src/createReactFabric.d.ts
303
303
  declare function createReactFabric(config?: FabricConfig<Options$1 & {
304
304
  mode?: FabricMode;
305
305
  devtools?: boolean;
306
- }>): Fabric<FabricOptions>;
306
+ }>): Fabric<Options$1 & {
307
+ mode?: FabricMode;
308
+ devtools?: boolean;
309
+ }>;
307
310
  //#endregion
308
311
  //#region src/Runtime.d.ts
309
312
  type Options = {
@@ -333,5 +336,5 @@ declare class Runtime {
333
336
  waitUntilExit(): Promise<void>;
334
337
  }
335
338
  //#endregion
336
- export { App, Const, 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 };
339
+ 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 };
337
340
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,18 +1,9 @@
1
1
  import { a as FabricOptions, b as Source, f as BaseName, g as Import, h as File$1, i as FabricMode, n as FabricConfig, o as FileManager, p as Export, s as FileProcessor, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-mFmfnVJp.js";
2
- import { a as JSDoc, b as DefineFabric, d as KubbNode, g as FunctionParams, o as Key, x as defineFabric, y as createFunctionParams } from "./types-BskFKkPW.js";
2
+ import { a as JSDoc, b as DefineFabric, d as KubbNode, g as FunctionParams, o as Key, x as defineFabric, y as createFunctionParams } from "./types-DAb8l-KJ.js";
3
3
  import { t as Options$1 } from "./reactPlugin-DJqKlTY6.js";
4
4
  import * as react0 from "react";
5
5
  import React, { Fragment, ReactNode, createContext, createElement, use, useContext, useEffect, useReducer, useRef, useState } from "react";
6
6
 
7
- //#region ../fabric-core/src/createFabric.d.ts
8
- declare const createFabric: DefineFabric<FabricOptions>;
9
- //#endregion
10
- //#region ../fabric-core/src/createFile.d.ts
11
- /**
12
- * Helper to create a file with name and id set
13
- */
14
- declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
15
- //#endregion
16
7
  //#region src/components/App.d.ts
17
8
  type AppContextProps<TMeta = unknown> = {
18
9
  /**
@@ -299,11 +290,23 @@ declare function useLifecycle(): {
299
290
  exit: () => void;
300
291
  };
301
292
  //#endregion
293
+ //#region ../fabric-core/src/createFabric.d.ts
294
+ declare const createFabric: DefineFabric<FabricOptions>;
295
+ //#endregion
296
+ //#region ../fabric-core/src/createFile.d.ts
297
+ /**
298
+ * Helper to create a file with name and id set
299
+ */
300
+ declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
301
+ //#endregion
302
302
  //#region src/createReactFabric.d.ts
303
303
  declare function createReactFabric(config?: FabricConfig<Options$1 & {
304
304
  mode?: FabricMode;
305
305
  devtools?: boolean;
306
- }>): Fabric<FabricOptions>;
306
+ }>): Fabric<Options$1 & {
307
+ mode?: FabricMode;
308
+ devtools?: boolean;
309
+ }>;
307
310
  //#endregion
308
311
  //#region src/Runtime.d.ts
309
312
  type Options = {
@@ -333,5 +336,5 @@ declare class Runtime {
333
336
  waitUntilExit(): Promise<void>;
334
337
  }
335
338
  //#endregion
336
- export { App, Const, 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 };
339
+ 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 };
337
340
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as _classPrivateFieldInitSpec, i as _classPrivateFieldGet2, n as Runtime, o as Root, r as _classPrivateFieldSet2, s as RootContext, t as reactPlugin } from "./plugins-CftsHDZ2.js";
1
+ import { a as _classPrivateFieldInitSpec, i as _classPrivateFieldGet2, n as Runtime, o as Root, r as _classPrivateFieldSet2, s as RootContext, t as reactPlugin } from "./reactPlugin-DCuv3mQy.js";
2
2
  import { i as jsxs, n as jsx, t as Fragment$1 } from "./jsx-runtime-CVfJARUD.js";
3
3
  import { t as open } from "./devtools-Cb1pMQYm.js";
4
4
  import React, { Fragment, createContext, createContext as createContext$1, createElement, use, useContext, useContext as useContext$1, useEffect, useReducer, useRef, useState } from "react";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["createContext","useContext","createContext","result: React.ReactNode[]","useContext","useContext","useContext","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 filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return ''\n }\n\n return `/**\\n * ${filteredComments.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 { createContext } from 'react'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\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 filtered = React.Children.toArray(children).filter(Boolean)\n const result: React.ReactNode[] = []\n\n let prevWasBr = false\n let brCount = 0\n\n filtered.forEach((child) => {\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 { Indent } from './Indent.tsx'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\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'\n\nimport { File } from '../components/File.tsx'\n\nimport type { FileContextProps } 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 setTimeout(() => {\n exit()\n }, 0)\n },\n }\n}\n","import { createFabric } from '@kubb/fabric-core'\nimport { reactPlugin } from '@kubb/react-fabric/plugins'\nimport type { Options } from './plugins/reactPlugin.ts'\nimport type { FabricConfig, FabricMode } from '@kubb/fabric-core/types'\nimport { open } from './devtools.ts'\n\nexport function createReactFabric(config?: FabricConfig<Options & { mode?: FabricMode; devtools?: boolean }>) {\n const fabric = createFabric(config)\n\n if (config?.options?.devtools) {\n open()\n }\n\n fabric.use(reactPlugin, config?.options)\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,aAAaA,gBAA2C,OAAU;AAOxE,SAAgB,IAAqB,EAAE,MAAM,YAA0B;CACrE,MAAM,EAAE,SAASC,aAAW,YAAY;AAExC,QAAO,oBAAC,WAAW;EAAS,OAAO;GAAE;GAAM;GAAM;EAAG;GAA+B;;AAGrF,IAAI,UAAU;AACd,IAAI,cAAc;;;;AC1BlB,SAAgB,YAAY,EAAE,YAAiD;CAC7E,MAAM,mBAAmB,SAAS,OAAO,QAAQ;AAEjD,KAAI,CAAC,iBAAiB,OACpB,QAAO;AAGT,QAAO,WAAW,iBAAiB,KAAK,QAAQ,CAAC;;;;;ACsBnD,SAAgB,MAAM,EAAE,M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I,KACF,KAAI,OAAO;AAGb,UAAO;;AAET,SAAO,OAAO,wCAAQ,KAAY,CAAC,CAAC,OAAO,SAAS,EAAE,CAAW;;CAGnE,OAAO,EAAE,eAAe,kBAAoE,EAAE,EAAU;AACtG,SAAO,kDAAkB,KAAY,EAAE;GAAE,MAAM;GAAQ;GAAe;GAAe,CAAC;;CAGxF,WAAmB;AACjB,SAAO,kDAAkB,KAAY,EAAE,EAAE,MAAM,UAAU,CAAC;;CAE5D,gBAAwB;AACtB,SAAO,kDAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC;;CAGjE,gBAAwB;AACtB,SAAO,kDAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","names":["createContext","useContext","createContext","result: React.ReactNode[]","useContext","useContext","useContext","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 filteredComments = comments.filter(Boolean)\n\n if (!filteredComments.length) {\n return ''\n }\n\n return `/**\\n * ${filteredComments.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 { createContext } from 'react'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\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 filtered = React.Children.toArray(children).filter(Boolean)\n const result: React.ReactNode[] = []\n\n let prevWasBr = false\n let brCount = 0\n\n filtered.forEach((child) => {\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 { Indent } from './Indent.tsx'\nimport { createJSDoc } from '../utils/createJSDoc.ts'\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'\n\nimport { File } from '../components/File.tsx'\n\nimport type { FileContextProps } 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 setTimeout(() => {\n exit()\n }, 0)\n },\n }\n}\n","import { createFabric } from '@kubb/fabric-core'\nimport type { Fabric } from '@kubb/fabric-core'\nimport type { Options } from './plugins/reactPlugin.ts'\n\nimport { reactPlugin } from './plugins/reactPlugin.ts'\nimport type { FabricConfig, FabricMode } from '@kubb/fabric-core/types'\nimport { open } from './devtools.ts'\n\nexport function createReactFabric(\n config?: FabricConfig<Options & { mode?: FabricMode; devtools?: boolean }>,\n): Fabric<Options & { mode?: FabricMode; devtools?: boolean }> {\n const fabric = createFabric(config)\n\n if (config?.options?.devtools) {\n open()\n }\n\n fabric.use(reactPlugin, config?.options)\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,aAAaA,gBAA2C,OAAU;AAOxE,SAAgB,IAAqB,EAAE,MAAM,YAA0B;CACrE,MAAM,EAAE,SAASC,aAAW,YAAY;AAExC,QAAO,oBAAC,WAAW;EAAS,OAAO;GAAE;GAAM;GAAM;EAAG;GAA+B;;AAGrF,IAAI,UAAU;AACd,IAAI,cAAc;;;;AC1BlB,SAAgB,YAAY,EAAE,YAAiD;CAC7E,MAAM,mBAAmB,SAAS,OAAO,QAAQ;AAEjD,KAAI,CAAC,iBAAiB,OACpB,QAAO;AAGT,QAAO,WAAW,iBAAiB,KAAK,QAAQ,CAAC;;;;;ACsBnD,SAAgB,MAAM,EAAE,MAAM,QAAQ,WAAW,MAAM,OAAO,SAAS,YAAmB;AACxF,QACE;iDACG,MAAO,aACN,8CACG,YAAY,EAAE,wDAAU,MAAO,UAAU,CAAC,EAC3C,oBAAC,SAAK,IACL;EAEJ,aAAa,4CAAE,YAA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,KAAY,EAAE;GAAE,MAAM;GAAQ;GAAe;GAAe,CAAC;;CAGxF,WAAmB;AACjB,SAAO,kDAAkB,KAAY,EAAE,EAAE,MAAM,UAAU,CAAC;;CAE5D,gBAAwB;AACtB,SAAO,kDAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC;;CAGjE,gBAAwB;AACtB,SAAO,kDAAkB,KAAY,EAAE,EAAE,MAAM,eAAe,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import "./Fabric-B8W5_3xv.cjs";
2
- import { d as KubbNode, s as KubbElement } from "./types-C_IFxocB.cjs";
3
- import { t as JSX } from "./jsx-namespace-BwLeEI1n.cjs";
2
+ import { d as KubbNode, s as KubbElement } from "./types-kzoLNjog.cjs";
3
+ import { t as JSX } from "./jsx-namespace-c3pSYEW1.cjs";
4
4
  import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
5
5
 
6
6
  //#region src/jsx-dev-runtime.d.ts
@@ -1,6 +1,6 @@
1
1
  import "./Fabric-mFmfnVJp.js";
2
- import { d as KubbNode, s as KubbElement } from "./types-BskFKkPW.js";
3
- import { t as JSX } from "./jsx-namespace-cboHPqa0.js";
2
+ import { d as KubbNode, s as KubbElement } from "./types-DAb8l-KJ.js";
3
+ import { t as JSX } from "./jsx-namespace-Czey9R9N.js";
4
4
  import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
5
5
 
6
6
  //#region src/jsx-dev-runtime.d.ts
@@ -1,4 +1,4 @@
1
- import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-BskFKkPW.js";
1
+ import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-DAb8l-KJ.js";
2
2
  import React from "react";
3
3
 
4
4
  //#region src/jsx-namespace.d.ts
@@ -28,4 +28,4 @@ declare namespace JSX$1 {
28
28
  }
29
29
  //#endregion
30
30
  export { JSX$1 as t };
31
- //# sourceMappingURL=jsx-namespace-cboHPqa0.d.ts.map
31
+ //# sourceMappingURL=jsx-namespace-Czey9R9N.d.ts.map
@@ -1,4 +1,4 @@
1
- import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-C_IFxocB.cjs";
1
+ import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-kzoLNjog.cjs";
2
2
  import React from "react";
3
3
 
4
4
  //#region src/jsx-namespace.d.ts
@@ -28,4 +28,4 @@ declare namespace JSX$1 {
28
28
  }
29
29
  //#endregion
30
30
  export { JSX$1 as t };
31
- //# sourceMappingURL=jsx-namespace-BwLeEI1n.d.cts.map
31
+ //# sourceMappingURL=jsx-namespace-c3pSYEW1.d.cts.map
@@ -1,6 +1,6 @@
1
1
  import "./Fabric-B8W5_3xv.cjs";
2
- import { d as KubbNode, s as KubbElement } from "./types-C_IFxocB.cjs";
3
- import { t as JSX } from "./jsx-namespace-BwLeEI1n.cjs";
2
+ import { d as KubbNode, s as KubbElement } from "./types-kzoLNjog.cjs";
3
+ import { t as JSX } from "./jsx-namespace-c3pSYEW1.cjs";
4
4
  import { jsxDEV } from "react/jsx-dev-runtime";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import "./Fabric-mFmfnVJp.js";
2
- import { d as KubbNode, s as KubbElement } from "./types-BskFKkPW.js";
3
- import { t as JSX } from "./jsx-namespace-cboHPqa0.js";
2
+ import { d as KubbNode, s as KubbElement } from "./types-DAb8l-KJ.js";
3
+ import { t as JSX } from "./jsx-namespace-Czey9R9N.js";
4
4
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
5
  import { jsxDEV } from "react/jsx-dev-runtime";
6
6
 
package/dist/plugins.cjs CHANGED
@@ -1,7 +1,7 @@
1
- const require_plugins = require('./plugins-DzBEnan-.cjs');
1
+ const require_reactPlugin = require('./reactPlugin-DN7FaU4S.cjs');
2
2
  require('./jsx-runtime-CpPZNgzW.cjs');
3
3
 
4
- exports.reactPlugin = require_plugins.reactPlugin;
4
+ exports.reactPlugin = require_reactPlugin.reactPlugin;
5
5
  var __kubb_fabric_core_plugins = require("@kubb/fabric-core/plugins");
6
6
  Object.keys(__kubb_fabric_core_plugins).forEach(function (k) {
7
7
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
package/dist/plugins.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as reactPlugin } from "./plugins-CftsHDZ2.js";
1
+ import { t as reactPlugin } from "./reactPlugin-DCuv3mQy.js";
2
2
  import "./jsx-runtime-CVfJARUD.js";
3
3
 
4
4
  export * from "@kubb/fabric-core/plugins"
@@ -587,4 +587,4 @@ const reactPlugin = createPlugin({
587
587
 
588
588
  //#endregion
589
589
  export { _classPrivateFieldInitSpec as a, _classPrivateFieldGet2 as i, Runtime as n, Root as o, _classPrivateFieldSet2 as r, RootContext as s, reactPlugin as t };
590
- //# sourceMappingURL=plugins-CftsHDZ2.js.map
590
+ //# sourceMappingURL=reactPlugin-DCuv3mQy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactPlugin-DCuv3mQy.js","names":["onExit","node: TextNode","nodeNames: Array<ElementNames>","text","file: KubbFile.File"],"sources":["../src/components/Root.tsx","../src/dom.ts","../src/Renderer.ts","../src/utils/squashTextNodes.ts","../src/utils/squashExportNodes.ts","../src/utils/squashImportNodes.ts","../src/utils/squashSourceNodes.ts","../src/utils/processFiles.ts","../src/Runtime.tsx","../src/plugins/reactPlugin.ts"],"sourcesContent":["import { Component, createContext } from 'react'\n\nimport type { KubbNode } from '../types.ts'\n\ntype ErrorBoundaryProps = {\n onError: (error: Error) => void\n children?: KubbNode\n}\n\nclass ErrorBoundary extends Component<{\n onError: ErrorBoundaryProps['onError']\n children?: KubbNode\n}> {\n state = { hasError: false }\n\n static displayName = 'KubbErrorBoundary'\n static getDerivedStateFromError(_error: Error) {\n return { hasError: true }\n }\n\n componentDidCatch(error: Error) {\n if (error) {\n this.props.onError(error)\n }\n }\n\n render() {\n if (this.state.hasError) {\n return null\n }\n return this.props.children\n }\n}\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole Ink app.\n */\n readonly exit: (error?: Error) => void\n}\n\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n})\n\ntype RootProps = {\n /**\n * Exit (unmount) hook\n */\n readonly onExit: (error?: Error) => void\n /**\n * Error hook\n */\n readonly onError: (error: Error) => void\n readonly children?: KubbNode\n}\n\nexport function Root({ onError, onExit, children }: RootProps) {\n try {\n return (\n <ErrorBoundary\n onError={(error) => {\n onError(error)\n }}\n >\n <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>\n </ErrorBoundary>\n )\n } catch (_e) {\n return null\n }\n}\n\nRoot.Context = RootContext\nRoot.displayName = 'KubbRoot'\n","import type { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\nexport const createNode = (nodeName: string): DOMElement => {\n const node: DOMElement = {\n nodeName: nodeName as DOMElement['nodeName'],\n attributes: {},\n childNodes: [],\n parentNode: undefined,\n }\n\n return node\n}\n\nexport const appendChildNode = (node: DOMNode, childNode: DOMElement | DOMNode): void => {\n if (childNode.parentNode) {\n removeChildNode(childNode.parentNode, childNode)\n }\n\n if (node.nodeName !== '#text') {\n childNode.parentNode = node\n node.childNodes.push(childNode)\n }\n}\n\nexport const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode): void => {\n if (newChildNode.parentNode) {\n removeChildNode(newChildNode.parentNode, newChildNode)\n }\n\n newChildNode.parentNode = node\n\n const index = node.childNodes.indexOf(beforeChildNode)\n if (index >= 0) {\n node.childNodes.splice(index, 0, newChildNode)\n\n return\n }\n\n node.childNodes.push(newChildNode)\n}\n\nexport const removeChildNode = (node: DOMElement, removeNode: DOMNode): void => {\n removeNode.parentNode = undefined\n\n const index = node.childNodes.indexOf(removeNode)\n if (index >= 0) {\n node.childNodes.splice(index, 1)\n }\n}\n\nexport const setAttribute = (node: DOMElement, key: string, value: DOMNodeAttribute): void => {\n node.attributes[key] = value\n}\n\nexport const createTextNode = (text: string): TextNode => {\n const node: TextNode = {\n nodeName: '#text',\n nodeValue: text,\n parentNode: undefined,\n }\n\n setTextNodeValue(node, text)\n\n return node\n}\n\nexport const setTextNodeValue = (node: TextNode, text: string): void => {\n if (typeof text !== 'string') {\n text = String(text)\n }\n\n node.nodeValue = text\n}\n\nexport const nodeNames: Array<ElementNames> = ['kubb-export', 'kubb-file', 'kubb-source', 'kubb-import', 'kubb-text']\n","import Reconciler, { type ReactContext } from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants.js'\n\nimport { appendChildNode, createNode, createTextNode, insertBeforeNode, removeChildNode, setAttribute, setTextNodeValue } from './dom.ts'\nimport type { KubbNode } from './types'\nimport type { DOMElement, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\nimport { createContext } from 'react'\n\ndeclare module 'react-reconciler' {\n // @ts-expect-error custom override\n interface Reconciler {\n updateContainerSync(element: KubbNode, container: unknown, parentComponent: any, callback?: null | (() => void)): void\n flushSyncWork(): void\n createContainer(\n containerInfo: unknown,\n tag: Reconciler.RootTag,\n hydrationCallbacks: null | Reconciler.SuspenseHydrationCallbacks<any>,\n isStrictMode: boolean,\n concurrentUpdatesByDefaultOverride: null | boolean,\n identifierPrefix: string,\n onUncaughtError: (error: Error) => void,\n onCaughtError: (error: Error) => void,\n onRecoverableError: (error: Error) => void,\n transitionCallbacks: null | Reconciler.TransitionTracingCallbacks,\n ): Reconciler.OpaqueRoot\n }\n}\n\ntype Props = Record<string, unknown>\n\ntype HostContext = {\n type: ElementNames\n isFile: boolean\n isSource: boolean\n}\n\nlet currentUpdatePriority = NoEventPriority\n\n/**\n * @link https://www.npmjs.com/package/react-devtools-inline\n * @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md\n * @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples\n * @link https://github.com/vadimdemedes/ink\n * @link https://github.com/pixijs/pixi-react/tree/main/packages\n * @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts\n */\nexport const Renderer = Reconciler({\n getRootHostContext: () => ({\n type: 'kubb-root',\n isFile: false,\n isSource: false,\n }),\n prepareForCommit: () => {\n return null\n },\n preparePortalMount: () => null,\n clearContainer: () => false,\n resetAfterCommit(rootNode: DOMElement) {\n if (typeof rootNode.onRender === 'function') {\n rootNode.onRender()\n }\n },\n getChildHostContext(parentHostContext: HostContext, type: ElementNames) {\n const isInsideText = type === 'kubb-text'\n const isFile = type === 'kubb-file' || parentHostContext.isFile\n const isSource = type === 'kubb-source' || parentHostContext.isSource\n\n return { isInsideText, isFile, isSource, type }\n },\n shouldSetTextContent: () => false,\n createInstance(originalType: ElementNames, newProps: Props, _root: DOMElement) {\n const node = createNode(originalType)\n\n for (const [key, value] of Object.entries(newProps)) {\n if (key === 'children') {\n continue\n }\n\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n\n return node\n },\n createTextInstance(text: string, _root: DOMElement, hostContext: HostContext) {\n if (hostContext.isFile && !hostContext.isSource) {\n throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`)\n }\n\n return createTextNode(text)\n },\n resetTextContent() {},\n hideTextInstance(node: TextNode) {\n setTextNodeValue(node, '')\n },\n unhideTextInstance(node: TextNode, text: string) {\n setTextNodeValue(node, text)\n },\n getPublicInstance: (instance) => instance,\n appendInitialChild: appendChildNode,\n appendChild: appendChildNode,\n insertBefore: insertBeforeNode,\n finalizeInitialChildren(_node, _type, _props, _rootNode) {\n return false\n },\n supportsMutation: true,\n isPrimaryRenderer: true,\n supportsPersistence: false,\n supportsHydration: false,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n beforeActiveInstanceBlur() {},\n afterActiveInstanceBlur() {},\n detachDeletedInstance() {},\n getInstanceFromNode: () => null,\n prepareScopeUpdate() {},\n getInstanceFromScope: () => null,\n appendChildToContainer: appendChildNode,\n insertInContainerBefore: insertBeforeNode,\n removeChildFromContainer(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n commitMount() {},\n commitUpdate(node: DOMElement, _payload, _type, _oldProps: Props, newProps: Props) {\n const { props } = newProps\n\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n }\n },\n commitTextUpdate(node: TextNode, _oldText, newText) {\n setTextNodeValue(node, newText)\n },\n removeChild(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n setCurrentUpdatePriority: (newPriority: number) => {\n currentUpdatePriority = newPriority\n },\n getCurrentUpdatePriority: () => currentUpdatePriority,\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority\n }\n\n return DefaultEventPriority\n },\n maySuspendCommit() {\n return false\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NotPendingTransition: undefined,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HostTransitionContext: createContext(null) as unknown as ReactContext<unknown>,\n resetFormInstance() {},\n requestPostPaintCallback() {},\n shouldAttemptEagerTransition() {\n return false\n },\n trackSchedulerEvent() {},\n resolveEventType() {\n return null\n },\n resolveEventTimeStamp() {\n return -1.1\n },\n preloadInstance() {\n return true\n },\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady() {\n return null\n },\n})\n\nexport type { FiberRoot } from 'react-reconciler'\n","import { createImport, createExport, print } from '@kubb/fabric-core/parsers/typescript'\n\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashTextNodes(node: DOMElement): string {\n let text = ''\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n let nodeText = ''\n\n const getPrintText = (text: string): string => {\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n\n return print([\n createImport({\n name: attributes.name,\n path: attributes.path,\n root: attributes.root,\n isTypeOnly: attributes.isTypeOnly,\n }),\n ])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n if (attributes.path) {\n return print([\n createExport({\n name: attributes.name,\n path: attributes.path,\n isTypeOnly: attributes.isTypeOnly,\n asAlias: attributes.asAlias,\n }),\n ])\n }\n }\n\n if (childNode.nodeName === 'kubb-source') {\n return text\n }\n\n return text\n }\n\n if (childNode.nodeName === '#text') {\n nodeText = childNode.nodeValue\n } else {\n if (['kubb-text', 'kubb-file', 'kubb-source'].includes(childNode.nodeName)) {\n nodeText = squashTextNodes(childNode)\n }\n\n nodeText = getPrintText(nodeText)\n\n if (childNode.nodeName === 'br') {\n nodeText = '\\n'\n }\n\n // no kubb element or br\n if (![...nodeNames, 'br'].includes(childNode.nodeName)) {\n const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {\n if (typeof value === 'string') {\n return `${acc} ${key}=\"${value}\"`\n }\n\n return `${acc} ${key}={${value}}`\n }, '')\n nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`\n }\n }\n\n text += nodeText\n }\n\n return text\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashExportNodes(node: DOMElement): Set<KubbFile.ResolvedExport> {\n let exports = new Set<KubbFile.Export>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n exports = new Set([...exports, ...squashExportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n exports.add(attributes)\n }\n })\n\n return exports\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashImportNodes(node: DOMElement): Set<KubbFile.Import> {\n let imports = new Set<KubbFile.Import>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n imports = new Set([...imports, ...squashImportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n imports.add(attributes)\n }\n })\n\n return imports\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement, ElementNames } from '../types.ts'\nimport { squashTextNodes } from './squashTextNodes.ts'\n\nexport function squashSourceNodes(node: DOMElement, ignores: Array<ElementNames>): Set<KubbFile.Source> {\n let sources = new Set<KubbFile.Source>()\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && ignores.includes(childNode.nodeName)) {\n continue\n }\n\n if (childNode.nodeName === 'kubb-source') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Source>\n const value = squashTextNodes(childNode)\n\n sources.add({\n ...attributes,\n // remove end enter\n value: value.trim().replace(/^\\s+|\\s+$/g, ''),\n })\n\n continue\n }\n\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)])\n }\n }\n\n return sources\n}\n","import { nodeNames } from '../dom.ts'\nimport { squashExportNodes } from './squashExportNodes.ts'\nimport { squashImportNodes } from './squashImportNodes.ts'\nimport { squashSourceNodes } from './squashSourceNodes.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\nimport type { FileManager } from '@kubb/fabric-core'\n\nexport function processFiles(node: DOMElement, fileManager: FileManager) {\n for (let index = 0; index < node.childNodes.length; index++) {\n const childNode = node.childNodes[index]\n\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && childNode.nodeName !== 'kubb-file' && nodeNames.includes(childNode.nodeName)) {\n processFiles(childNode, fileManager)\n }\n\n if (childNode.nodeName === 'kubb-file') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File>\n\n if (attributes.baseName && attributes.path) {\n const sources = squashSourceNodes(childNode, ['kubb-export', 'kubb-import'])\n\n const file: KubbFile.File = {\n baseName: attributes.baseName,\n path: attributes.path,\n sources: [...sources],\n exports: [...squashExportNodes(childNode)],\n imports: [...squashImportNodes(childNode)],\n meta: attributes.meta || {},\n footer: attributes.footer,\n banner: attributes.banner,\n }\n\n fileManager.add(file)\n }\n }\n }\n}\n","import process from 'node:process'\nimport type { ReactNode } from 'react'\nimport { ConcurrentRoot } from 'react-reconciler/constants.js'\nimport { onExit } from 'signal-exit'\nimport { Root } from './components/Root.tsx'\nimport { createNode } from './dom.ts'\nimport type { FiberRoot } from './Renderer.ts'\nimport { Renderer } from './Renderer.ts'\nimport type { DOMElement } from './types.ts'\nimport { squashTextNodes } from './utils/squashTextNodes.ts'\nimport { processFiles } from './utils/processFiles.ts'\nimport type { FileManager } from '@kubb/fabric-core'\n\ntype Options = {\n fileManager: FileManager\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n // Ignore last render after unmounting a tree to prevent empty output before exit\n #isUnmounted: boolean\n\n exitPromise?: Promise<void>\n readonly #container: FiberRoot\n readonly #rootNode: DOMElement\n\n constructor(options: Options) {\n this.#options = options\n\n this.#rootNode = createNode('kubb-root')\n this.#rootNode.onRender = this.onRender\n this.#rootNode.onImmediateRender = this.onRender\n\n // Ignore last render after unmounting a tree to prevent empty output before exit\n this.#isUnmounted = false\n this.unmount.bind(this)\n\n const originalError = console.error\n console.error = (data: string | Error) => {\n const message = typeof data === 'string' ? data : data?.message\n\n if (message?.match(/Encountered two children with the same key/gi)) {\n return\n }\n if (message?.match(/React will try to recreat/gi)) {\n return\n }\n if (message?.match(/Each child in a list should have a unique/gi)) {\n return\n }\n if (message?.match(/The above error occurred in the <KubbErrorBoundary/gi)) {\n return\n }\n\n if (message?.match(/A React Element from an older version of React was render/gi)) {\n return\n }\n\n originalError(data)\n }\n\n // Report when an error was detected in a previous render\n // https://github.com/pmndrs/react-three-fiber/pull/2261\n const logRecoverableError =\n typeof reportError === 'function'\n ? // In modern browsers, reportError will dispatch an error event,\n // emulating an uncaught JavaScript error.\n reportError\n : // In older browsers and test environments, fallback to console.error.\n console.error\n\n const rootTag = ConcurrentRoot\n const hydrationCallbacks = null\n const isStrictMode = false\n const concurrentUpdatesByDefaultOverride = false\n const identifierPrefix = 'id'\n const onUncaughtError = logRecoverableError\n const onCaughtError = logRecoverableError\n const onRecoverableError = logRecoverableError\n const transitionCallbacks = null\n\n this.#container = Renderer.createContainer(\n this.#rootNode,\n rootTag,\n hydrationCallbacks,\n isStrictMode,\n concurrentUpdatesByDefaultOverride,\n identifierPrefix,\n onUncaughtError,\n onCaughtError,\n onRecoverableError,\n transitionCallbacks,\n )\n\n // Unmount when process exits\n this.unsubscribeExit = onExit(\n (code) => {\n this.unmount(code)\n },\n { alwaysLast: false },\n ).bind(this)\n\n Renderer.injectIntoDevTools({\n bundleType: 1, // 0 for PROD, 1 for DEV\n version: '19.1.0', // should be React version and not Kubb's custom version\n rendererPackageName: 'kubb', // package name\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n onRender: () => void = async () => {\n if (this.#isUnmounted) {\n return\n }\n\n // TODO remove to allow multiple renders\n this.fileManager.clear()\n\n processFiles(this.#rootNode, this.fileManager)\n\n if (!this.#options?.debug && !this.#options?.stdout) {\n return\n }\n\n const output = await this.#getOutput(this.#rootNode)\n\n if (this.#options?.debug) {\n console.log('Rendering: \\n')\n console.log(output)\n }\n\n if (this.#options?.stdout && process.env.NODE_ENV !== 'test') {\n this.#options.stdout.clearLine(0)\n this.#options.stdout.cursorTo(0)\n this.#options.stdout.write(output)\n }\n }\n onError(error: Error): void {\n if (process.env.NODE_ENV === 'test') {\n console.warn(error)\n }\n\n throw error\n }\n onExit(error?: Error): void {\n this.unmount(error)\n }\n\n async #getOutput(node: DOMElement): Promise<string> {\n const text = squashTextNodes(node)\n const files = this.fileManager.files\n\n return files.length\n ? [...files]\n .flatMap((file) => [...file.sources].map((item) => item.value))\n .filter(Boolean)\n .join('\\n\\n')\n : text\n }\n\n render(node: ReactNode): void {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n }\n\n async renderToString(node: ReactNode): Promise<string> {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n\n this.fileManager.clear()\n\n return this.#getOutput(this.#rootNode)\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#isUnmounted) {\n return\n }\n\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.onRender()\n this.unsubscribeExit()\n\n this.#isUnmounted = true\n\n Renderer.updateContainerSync(null, this.#container, null, null)\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { Runtime } from '../Runtime.tsx'\nimport { createElement, type ElementType } from 'react'\n\nexport type Options = {\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\n// biome-ignore lint/suspicious/noTsIgnore: production ready\n// @ts-ignore\ndeclare module '@kubb/fabric-core' {\n interface Fabric {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const reactPlugin = createPlugin<Options, ExtendOptions>({\n name: 'react',\n install() {},\n inject(app, options = {}) {\n const runtime = new Runtime({ fileManager: app.context.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await app.context.events.emit('start')\n },\n async renderToString(App) {\n await app.context.events.emit('start')\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await app.context.events.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAM,gBAAN,cAA4B,UAGzB;;;wBACD,SAAQ,EAAE,UAAU,OAAO;;CAG3B,OAAO,yBAAyB,QAAe;AAC7C,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkB,OAAc;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e,KAAK;AACxB,UAAM,IAAI,QAAQ,OAAO,KAAK,QAAQ;AACtC,WAAO,QAAQ,eAAe,cAAc,IAAI,CAAC;;GAEnD,MAAM,gBAAgB;AACpB,UAAM,QAAQ,eAAe;AAE7B,UAAM,IAAI,QAAQ,OAAO,KAAK,MAAM;;GAEvC;;CAEJ,CAAC"}
@@ -637,4 +637,4 @@ Object.defineProperty(exports, 'reactPlugin', {
637
637
  return reactPlugin;
638
638
  }
639
639
  });
640
- //# sourceMappingURL=plugins-DzBEnan-.cjs.map
640
+ //# sourceMappingURL=reactPlugin-DN7FaU4S.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactPlugin-DN7FaU4S.cjs","names":["Component","onExit","node: TextNode","nodeNames: Array<ElementNames>","NoEventPriority","DefaultEventPriority","text","exports","file: KubbFile.File","process","ConcurrentRoot"],"sources":["../src/components/Root.tsx","../src/dom.ts","../src/Renderer.ts","../src/utils/squashTextNodes.ts","../src/utils/squashExportNodes.ts","../src/utils/squashImportNodes.ts","../src/utils/squashSourceNodes.ts","../src/utils/processFiles.ts","../src/Runtime.tsx","../src/plugins/reactPlugin.ts"],"sourcesContent":["import { Component, createContext } from 'react'\n\nimport type { KubbNode } from '../types.ts'\n\ntype ErrorBoundaryProps = {\n onError: (error: Error) => void\n children?: KubbNode\n}\n\nclass ErrorBoundary extends Component<{\n onError: ErrorBoundaryProps['onError']\n children?: KubbNode\n}> {\n state = { hasError: false }\n\n static displayName = 'KubbErrorBoundary'\n static getDerivedStateFromError(_error: Error) {\n return { hasError: true }\n }\n\n componentDidCatch(error: Error) {\n if (error) {\n this.props.onError(error)\n }\n }\n\n render() {\n if (this.state.hasError) {\n return null\n }\n return this.props.children\n }\n}\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole Ink app.\n */\n readonly exit: (error?: Error) => void\n}\n\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n})\n\ntype RootProps = {\n /**\n * Exit (unmount) hook\n */\n readonly onExit: (error?: Error) => void\n /**\n * Error hook\n */\n readonly onError: (error: Error) => void\n readonly children?: KubbNode\n}\n\nexport function Root({ onError, onExit, children }: RootProps) {\n try {\n return (\n <ErrorBoundary\n onError={(error) => {\n onError(error)\n }}\n >\n <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>\n </ErrorBoundary>\n )\n } catch (_e) {\n return null\n }\n}\n\nRoot.Context = RootContext\nRoot.displayName = 'KubbRoot'\n","import type { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\nexport const createNode = (nodeName: string): DOMElement => {\n const node: DOMElement = {\n nodeName: nodeName as DOMElement['nodeName'],\n attributes: {},\n childNodes: [],\n parentNode: undefined,\n }\n\n return node\n}\n\nexport const appendChildNode = (node: DOMNode, childNode: DOMElement | DOMNode): void => {\n if (childNode.parentNode) {\n removeChildNode(childNode.parentNode, childNode)\n }\n\n if (node.nodeName !== '#text') {\n childNode.parentNode = node\n node.childNodes.push(childNode)\n }\n}\n\nexport const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode): void => {\n if (newChildNode.parentNode) {\n removeChildNode(newChildNode.parentNode, newChildNode)\n }\n\n newChildNode.parentNode = node\n\n const index = node.childNodes.indexOf(beforeChildNode)\n if (index >= 0) {\n node.childNodes.splice(index, 0, newChildNode)\n\n return\n }\n\n node.childNodes.push(newChildNode)\n}\n\nexport const removeChildNode = (node: DOMElement, removeNode: DOMNode): void => {\n removeNode.parentNode = undefined\n\n const index = node.childNodes.indexOf(removeNode)\n if (index >= 0) {\n node.childNodes.splice(index, 1)\n }\n}\n\nexport const setAttribute = (node: DOMElement, key: string, value: DOMNodeAttribute): void => {\n node.attributes[key] = value\n}\n\nexport const createTextNode = (text: string): TextNode => {\n const node: TextNode = {\n nodeName: '#text',\n nodeValue: text,\n parentNode: undefined,\n }\n\n setTextNodeValue(node, text)\n\n return node\n}\n\nexport const setTextNodeValue = (node: TextNode, text: string): void => {\n if (typeof text !== 'string') {\n text = String(text)\n }\n\n node.nodeValue = text\n}\n\nexport const nodeNames: Array<ElementNames> = ['kubb-export', 'kubb-file', 'kubb-source', 'kubb-import', 'kubb-text']\n","import Reconciler, { type ReactContext } from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants.js'\n\nimport { appendChildNode, createNode, createTextNode, insertBeforeNode, removeChildNode, setAttribute, setTextNodeValue } from './dom.ts'\nimport type { KubbNode } from './types'\nimport type { DOMElement, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\nimport { createContext } from 'react'\n\ndeclare module 'react-reconciler' {\n // @ts-expect-error custom override\n interface Reconciler {\n updateContainerSync(element: KubbNode, container: unknown, parentComponent: any, callback?: null | (() => void)): void\n flushSyncWork(): void\n createContainer(\n containerInfo: unknown,\n tag: Reconciler.RootTag,\n hydrationCallbacks: null | Reconciler.SuspenseHydrationCallbacks<any>,\n isStrictMode: boolean,\n concurrentUpdatesByDefaultOverride: null | boolean,\n identifierPrefix: string,\n onUncaughtError: (error: Error) => void,\n onCaughtError: (error: Error) => void,\n onRecoverableError: (error: Error) => void,\n transitionCallbacks: null | Reconciler.TransitionTracingCallbacks,\n ): Reconciler.OpaqueRoot\n }\n}\n\ntype Props = Record<string, unknown>\n\ntype HostContext = {\n type: ElementNames\n isFile: boolean\n isSource: boolean\n}\n\nlet currentUpdatePriority = NoEventPriority\n\n/**\n * @link https://www.npmjs.com/package/react-devtools-inline\n * @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md\n * @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples\n * @link https://github.com/vadimdemedes/ink\n * @link https://github.com/pixijs/pixi-react/tree/main/packages\n * @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts\n */\nexport const Renderer = Reconciler({\n getRootHostContext: () => ({\n type: 'kubb-root',\n isFile: false,\n isSource: false,\n }),\n prepareForCommit: () => {\n return null\n },\n preparePortalMount: () => null,\n clearContainer: () => false,\n resetAfterCommit(rootNode: DOMElement) {\n if (typeof rootNode.onRender === 'function') {\n rootNode.onRender()\n }\n },\n getChildHostContext(parentHostContext: HostContext, type: ElementNames) {\n const isInsideText = type === 'kubb-text'\n const isFile = type === 'kubb-file' || parentHostContext.isFile\n const isSource = type === 'kubb-source' || parentHostContext.isSource\n\n return { isInsideText, isFile, isSource, type }\n },\n shouldSetTextContent: () => false,\n createInstance(originalType: ElementNames, newProps: Props, _root: DOMElement) {\n const node = createNode(originalType)\n\n for (const [key, value] of Object.entries(newProps)) {\n if (key === 'children') {\n continue\n }\n\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n\n return node\n },\n createTextInstance(text: string, _root: DOMElement, hostContext: HostContext) {\n if (hostContext.isFile && !hostContext.isSource) {\n throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`)\n }\n\n return createTextNode(text)\n },\n resetTextContent() {},\n hideTextInstance(node: TextNode) {\n setTextNodeValue(node, '')\n },\n unhideTextInstance(node: TextNode, text: string) {\n setTextNodeValue(node, text)\n },\n getPublicInstance: (instance) => instance,\n appendInitialChild: appendChildNode,\n appendChild: appendChildNode,\n insertBefore: insertBeforeNode,\n finalizeInitialChildren(_node, _type, _props, _rootNode) {\n return false\n },\n supportsMutation: true,\n isPrimaryRenderer: true,\n supportsPersistence: false,\n supportsHydration: false,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n beforeActiveInstanceBlur() {},\n afterActiveInstanceBlur() {},\n detachDeletedInstance() {},\n getInstanceFromNode: () => null,\n prepareScopeUpdate() {},\n getInstanceFromScope: () => null,\n appendChildToContainer: appendChildNode,\n insertInContainerBefore: insertBeforeNode,\n removeChildFromContainer(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n commitMount() {},\n commitUpdate(node: DOMElement, _payload, _type, _oldProps: Props, newProps: Props) {\n const { props } = newProps\n\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n }\n },\n commitTextUpdate(node: TextNode, _oldText, newText) {\n setTextNodeValue(node, newText)\n },\n removeChild(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n setCurrentUpdatePriority: (newPriority: number) => {\n currentUpdatePriority = newPriority\n },\n getCurrentUpdatePriority: () => currentUpdatePriority,\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority\n }\n\n return DefaultEventPriority\n },\n maySuspendCommit() {\n return false\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NotPendingTransition: undefined,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HostTransitionContext: createContext(null) as unknown as ReactContext<unknown>,\n resetFormInstance() {},\n requestPostPaintCallback() {},\n shouldAttemptEagerTransition() {\n return false\n },\n trackSchedulerEvent() {},\n resolveEventType() {\n return null\n },\n resolveEventTimeStamp() {\n return -1.1\n },\n preloadInstance() {\n return true\n },\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady() {\n return null\n },\n})\n\nexport type { FiberRoot } from 'react-reconciler'\n","import { createImport, createExport, print } from '@kubb/fabric-core/parsers/typescript'\n\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashTextNodes(node: DOMElement): string {\n let text = ''\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n let nodeText = ''\n\n const getPrintText = (text: string): string => {\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n\n return print([\n createImport({\n name: attributes.name,\n path: attributes.path,\n root: attributes.root,\n isTypeOnly: attributes.isTypeOnly,\n }),\n ])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n if (attributes.path) {\n return print([\n createExport({\n name: attributes.name,\n path: attributes.path,\n isTypeOnly: attributes.isTypeOnly,\n asAlias: attributes.asAlias,\n }),\n ])\n }\n }\n\n if (childNode.nodeName === 'kubb-source') {\n return text\n }\n\n return text\n }\n\n if (childNode.nodeName === '#text') {\n nodeText = childNode.nodeValue\n } else {\n if (['kubb-text', 'kubb-file', 'kubb-source'].includes(childNode.nodeName)) {\n nodeText = squashTextNodes(childNode)\n }\n\n nodeText = getPrintText(nodeText)\n\n if (childNode.nodeName === 'br') {\n nodeText = '\\n'\n }\n\n // no kubb element or br\n if (![...nodeNames, 'br'].includes(childNode.nodeName)) {\n const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {\n if (typeof value === 'string') {\n return `${acc} ${key}=\"${value}\"`\n }\n\n return `${acc} ${key}={${value}}`\n }, '')\n nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`\n }\n }\n\n text += nodeText\n }\n\n return text\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashExportNodes(node: DOMElement): Set<KubbFile.ResolvedExport> {\n let exports = new Set<KubbFile.Export>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n exports = new Set([...exports, ...squashExportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n exports.add(attributes)\n }\n })\n\n return exports\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashImportNodes(node: DOMElement): Set<KubbFile.Import> {\n let imports = new Set<KubbFile.Import>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n imports = new Set([...imports, ...squashImportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n imports.add(attributes)\n }\n })\n\n return imports\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement, ElementNames } from '../types.ts'\nimport { squashTextNodes } from './squashTextNodes.ts'\n\nexport function squashSourceNodes(node: DOMElement, ignores: Array<ElementNames>): Set<KubbFile.Source> {\n let sources = new Set<KubbFile.Source>()\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && ignores.includes(childNode.nodeName)) {\n continue\n }\n\n if (childNode.nodeName === 'kubb-source') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Source>\n const value = squashTextNodes(childNode)\n\n sources.add({\n ...attributes,\n // remove end enter\n value: value.trim().replace(/^\\s+|\\s+$/g, ''),\n })\n\n continue\n }\n\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)])\n }\n }\n\n return sources\n}\n","import { nodeNames } from '../dom.ts'\nimport { squashExportNodes } from './squashExportNodes.ts'\nimport { squashImportNodes } from './squashImportNodes.ts'\nimport { squashSourceNodes } from './squashSourceNodes.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\nimport type { FileManager } from '@kubb/fabric-core'\n\nexport function processFiles(node: DOMElement, fileManager: FileManager) {\n for (let index = 0; index < node.childNodes.length; index++) {\n const childNode = node.childNodes[index]\n\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && childNode.nodeName !== 'kubb-file' && nodeNames.includes(childNode.nodeName)) {\n processFiles(childNode, fileManager)\n }\n\n if (childNode.nodeName === 'kubb-file') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File>\n\n if (attributes.baseName && attributes.path) {\n const sources = squashSourceNodes(childNode, ['kubb-export', 'kubb-import'])\n\n const file: KubbFile.File = {\n baseName: attributes.baseName,\n path: attributes.path,\n sources: [...sources],\n exports: [...squashExportNodes(childNode)],\n imports: [...squashImportNodes(childNode)],\n meta: attributes.meta || {},\n footer: attributes.footer,\n banner: attributes.banner,\n }\n\n fileManager.add(file)\n }\n }\n }\n}\n","import process from 'node:process'\nimport type { ReactNode } from 'react'\nimport { ConcurrentRoot } from 'react-reconciler/constants.js'\nimport { onExit } from 'signal-exit'\nimport { Root } from './components/Root.tsx'\nimport { createNode } from './dom.ts'\nimport type { FiberRoot } from './Renderer.ts'\nimport { Renderer } from './Renderer.ts'\nimport type { DOMElement } from './types.ts'\nimport { squashTextNodes } from './utils/squashTextNodes.ts'\nimport { processFiles } from './utils/processFiles.ts'\nimport type { FileManager } from '@kubb/fabric-core'\n\ntype Options = {\n fileManager: FileManager\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n // Ignore last render after unmounting a tree to prevent empty output before exit\n #isUnmounted: boolean\n\n exitPromise?: Promise<void>\n readonly #container: FiberRoot\n readonly #rootNode: DOMElement\n\n constructor(options: Options) {\n this.#options = options\n\n this.#rootNode = createNode('kubb-root')\n this.#rootNode.onRender = this.onRender\n this.#rootNode.onImmediateRender = this.onRender\n\n // Ignore last render after unmounting a tree to prevent empty output before exit\n this.#isUnmounted = false\n this.unmount.bind(this)\n\n const originalError = console.error\n console.error = (data: string | Error) => {\n const message = typeof data === 'string' ? data : data?.message\n\n if (message?.match(/Encountered two children with the same key/gi)) {\n return\n }\n if (message?.match(/React will try to recreat/gi)) {\n return\n }\n if (message?.match(/Each child in a list should have a unique/gi)) {\n return\n }\n if (message?.match(/The above error occurred in the <KubbErrorBoundary/gi)) {\n return\n }\n\n if (message?.match(/A React Element from an older version of React was render/gi)) {\n return\n }\n\n originalError(data)\n }\n\n // Report when an error was detected in a previous render\n // https://github.com/pmndrs/react-three-fiber/pull/2261\n const logRecoverableError =\n typeof reportError === 'function'\n ? // In modern browsers, reportError will dispatch an error event,\n // emulating an uncaught JavaScript error.\n reportError\n : // In older browsers and test environments, fallback to console.error.\n console.error\n\n const rootTag = ConcurrentRoot\n const hydrationCallbacks = null\n const isStrictMode = false\n const concurrentUpdatesByDefaultOverride = false\n const identifierPrefix = 'id'\n const onUncaughtError = logRecoverableError\n const onCaughtError = logRecoverableError\n const onRecoverableError = logRecoverableError\n const transitionCallbacks = null\n\n this.#container = Renderer.createContainer(\n this.#rootNode,\n rootTag,\n hydrationCallbacks,\n isStrictMode,\n concurrentUpdatesByDefaultOverride,\n identifierPrefix,\n onUncaughtError,\n onCaughtError,\n onRecoverableError,\n transitionCallbacks,\n )\n\n // Unmount when process exits\n this.unsubscribeExit = onExit(\n (code) => {\n this.unmount(code)\n },\n { alwaysLast: false },\n ).bind(this)\n\n Renderer.injectIntoDevTools({\n bundleType: 1, // 0 for PROD, 1 for DEV\n version: '19.1.0', // should be React version and not Kubb's custom version\n rendererPackageName: 'kubb', // package name\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n onRender: () => void = async () => {\n if (this.#isUnmounted) {\n return\n }\n\n // TODO remove to allow multiple renders\n this.fileManager.clear()\n\n processFiles(this.#rootNode, this.fileManager)\n\n if (!this.#options?.debug && !this.#options?.stdout) {\n return\n }\n\n const output = await this.#getOutput(this.#rootNode)\n\n if (this.#options?.debug) {\n console.log('Rendering: \\n')\n console.log(output)\n }\n\n if (this.#options?.stdout && process.env.NODE_ENV !== 'test') {\n this.#options.stdout.clearLine(0)\n this.#options.stdout.cursorTo(0)\n this.#options.stdout.write(output)\n }\n }\n onError(error: Error): void {\n if (process.env.NODE_ENV === 'test') {\n console.warn(error)\n }\n\n throw error\n }\n onExit(error?: Error): void {\n this.unmount(error)\n }\n\n async #getOutput(node: DOMElement): Promise<string> {\n const text = squashTextNodes(node)\n const files = this.fileManager.files\n\n return files.length\n ? [...files]\n .flatMap((file) => [...file.sources].map((item) => item.value))\n .filter(Boolean)\n .join('\\n\\n')\n : text\n }\n\n render(node: ReactNode): void {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n }\n\n async renderToString(node: ReactNode): Promise<string> {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n\n this.fileManager.clear()\n\n return this.#getOutput(this.#rootNode)\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#isUnmounted) {\n return\n }\n\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.onRender()\n this.unsubscribeExit()\n\n this.#isUnmounted = true\n\n Renderer.updateContainerSync(null, this.#container, null, null)\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { Runtime } from '../Runtime.tsx'\nimport { createElement, type ElementType } from 'react'\n\nexport type Options = {\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\n// biome-ignore lint/suspicious/noTsIgnore: production ready\n// @ts-ignore\ndeclare module '@kubb/fabric-core' {\n interface Fabric {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const reactPlugin = createPlugin<Options, ExtendOptions>({\n name: 'react',\n install() {},\n inject(app, options = {}) {\n const runtime = new Runtime({ fileManager: app.context.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await app.context.events.emit('start')\n },\n async renderToString(App) {\n await app.context.events.emit('start')\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await app.context.events.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAM,gBAAN,cAA4BA,gBAGzB;;;wBACD,SAAQ,EAAE,UAAU,OAAO;;CAG3B,OAAO,yBAAyB,QAAe;AAC7C,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkB,OAAc;AAC9B,MAAI,MACF,MAAK,MAAM,QAAQ,MAAM;;CAI7B,SAAS;AACP,MAAI,KAAK,MAAM,SACb,QAAO;AAET,SAAO,KAAK,MAAM;;;+BAfb,eAAc;AA0BvB,MAAa,uCAA8C,EACzD,YAAY,IACb,CAAC;AAcF,SAAgB,KAAK,EAAE,SAAS,kBAAQ,YAAuB;AAC7D,KAAI;AACF,SACE,2CAAC;GACC,UAAU,UAAU;AAClB,YAAQ,MAAM;;aAGhB,2CAAC,YAAY;IAAS,OAAO,EAAE,MAAMC,UAAQ;IAAG;KAAgC;IAClE;UAEX,IAAI;AACX,SAAO;;;AAIX,KA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AAM,KAAK;AAE/D,MAAI,iBAAiB,OAAO;AAC1B,QAAK,kBAAkB,MAAM;AAE7B;;AAGF,OAAK,oBAAoB;;CAG3B,MAAM,gBAA+B;AACnC,MAAI,CAAC,KAAK,YACR,MAAK,cAAc,IAAI,SAAS,SAAS,WAAW;AAClD,QAAK,qBAAqB;AAC1B,QAAK,oBAAoB;IACzB;AAGJ,SAAO,KAAK;;;AAvEd,0BAAiB,MAAmC;CAClD,MAAM,OAAO,gBAAgB,KAAK;CAClC,MAAM,QAAQ,KAAK,YAAY;AAE/B,QAAO,MAAM,SACT,CAAC,GAAG,MAAM,CACP,SAAS,SAAS,CAAC,GAAG,KAAK,QAAQ,CAAC,KAAK,SAAS,KAAK,MAAM,CAAC,CAC9D,OAAO,QAAQ,CACf,KAAK,OAAO,GACf;;;;;AClIR,MAAa,2DAAmD;CAC9D,MAAM;CACN,UAAU;CACV,OAAO,KAAK,UAAU,EAAE,EAAE;EACxB,MAAM,UAAU,IAAI,QAAQ;GAAE,aAAa,IAAI,QAAQ;GAAa,GAAG;GAAS,CAAC;AAEjF,SAAO;GACL,MAAM,OAAO,KAAK;AAChB,YAAQ,gCAAqB,IAAI,CAAC;AAClC,UAAM,IAAI,QAAQ,OAAO,KAAK,QAAQ;;GAExC,MAAM,eAAe,KAAK;AACxB,UAAM,IAAI,QAAQ,OAAO,KAAK,QAAQ;AACtC,WAAO,QAAQ,wCAA6B,IAAI,CAAC;;GAEnD,MAAM,gBAAgB;AACpB,UAAM,QAAQ,eAAe;AAE7B,UAAM,IAAI,QAAQ,OAAO,KAAK,MAAM;;GAEvC;;CAEJ,CAAC"}
@@ -3,7 +3,7 @@ import React, { JSX, Key, ReactNode } from "react";
3
3
 
4
4
  //#region ../fabric-core/src/defineFabric.d.ts
5
5
  type RootRenderFunction<TOptions extends FabricOptions> = (fabric: Fabric<TOptions>) => void | Promise<void>;
6
- type DefineFabric<TOptions extends FabricOptions> = (config?: FabricConfig<TOptions>) => Fabric;
6
+ type DefineFabric<TOptions extends FabricOptions> = (config?: FabricConfig<TOptions>) => Fabric<TOptions>;
7
7
  declare function defineFabric<TOptions extends FabricOptions>(instance?: RootRenderFunction<TOptions>): DefineFabric<TOptions>;
8
8
  //#endregion
9
9
  //#region src/utils/getFunctionParams.d.ts
@@ -106,4 +106,4 @@ type KubbExportProps = Export;
106
106
  type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
107
107
  //#endregion
108
108
  export { Param as _, JSDoc as a, DefineFabric as b, KubbExportProps as c, KubbNode as d, KubbSourceProps as f, FunctionParams as g, TextNode as h, ElementNames as i, KubbFileProps as l, LineBreakProps as m, DOMNode as n, Key as o, KubbTextProps as p, DOMNodeAttribute as r, KubbElement as s, DOMElement as t, KubbImportProps as u, Params as v, defineFabric as x, createFunctionParams as y };
109
- //# sourceMappingURL=types-BskFKkPW.d.ts.map
109
+ //# sourceMappingURL=types-DAb8l-KJ.d.ts.map
@@ -3,7 +3,7 @@ import React, { JSX, Key, ReactNode } from "react";
3
3
 
4
4
  //#region ../fabric-core/src/defineFabric.d.ts
5
5
  type RootRenderFunction<TOptions extends FabricOptions> = (fabric: Fabric<TOptions>) => void | Promise<void>;
6
- type DefineFabric<TOptions extends FabricOptions> = (config?: FabricConfig<TOptions>) => Fabric;
6
+ type DefineFabric<TOptions extends FabricOptions> = (config?: FabricConfig<TOptions>) => Fabric<TOptions>;
7
7
  declare function defineFabric<TOptions extends FabricOptions>(instance?: RootRenderFunction<TOptions>): DefineFabric<TOptions>;
8
8
  //#endregion
9
9
  //#region src/utils/getFunctionParams.d.ts
@@ -106,4 +106,4 @@ type KubbExportProps = Export;
106
106
  type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
107
107
  //#endregion
108
108
  export { Param as _, JSDoc as a, DefineFabric as b, KubbExportProps as c, KubbNode as d, KubbSourceProps as f, FunctionParams as g, TextNode as h, ElementNames as i, KubbFileProps as l, LineBreakProps as m, DOMNode as n, Key as o, KubbTextProps as p, DOMNodeAttribute as r, KubbElement as s, DOMElement as t, KubbImportProps as u, Params as v, defineFabric as x, createFunctionParams as y };
109
- //# sourceMappingURL=types-C_IFxocB.d.cts.map
109
+ //# sourceMappingURL=types-kzoLNjog.d.cts.map
package/dist/types.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import { _ as KubbFile_d_exports, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-B8W5_3xv.cjs";
2
- import { _ as Param, a as JSDoc, b as DefineFabric, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-C_IFxocB.cjs";
3
- export { DOMElement, DOMNode, DOMNodeAttribute, DefineFabric, ElementNames, FabricConfig, FabricContext, FabricMode, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
1
+ import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-B8W5_3xv.cjs";
2
+ import { _ as Param, a as JSDoc, b as DefineFabric, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-kzoLNjog.cjs";
3
+ export { DOMElement, DOMNode, DOMNodeAttribute, DefineFabric, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { _ as KubbFile_d_exports, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-mFmfnVJp.js";
2
- import { _ as Param, a as JSDoc, b as DefineFabric, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-BskFKkPW.js";
3
- export { DOMElement, DOMNode, DOMNodeAttribute, DefineFabric, ElementNames, FabricConfig, FabricContext, FabricMode, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
1
+ import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-mFmfnVJp.js";
2
+ import { _ as Param, a as JSDoc, b as DefineFabric, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-DAb8l-KJ.js";
3
+ export { DOMElement, DOMNode, DOMNodeAttribute, DefineFabric, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/react-fabric",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
4
4
  "description": "React integration for Kubb, providing JSX runtime support and React component generation capabilities for code generation plugins.",
5
5
  "keywords": [
6
6
  "react",
@@ -113,7 +113,7 @@
113
113
  "react-reconciler": "0.32.0",
114
114
  "signal-exit": "^4.1.0",
115
115
  "ws": "8.18.0",
116
- "@kubb/fabric-core": "0.2.12"
116
+ "@kubb/fabric-core": "0.2.14"
117
117
  },
118
118
  "devDependencies": {
119
119
  "@types/react": "^19.2.2",
@@ -1,10 +1,14 @@
1
1
  import { createFabric } from '@kubb/fabric-core'
2
- import { reactPlugin } from '@kubb/react-fabric/plugins'
2
+ import type { Fabric } from '@kubb/fabric-core'
3
3
  import type { Options } from './plugins/reactPlugin.ts'
4
+
5
+ import { reactPlugin } from './plugins/reactPlugin.ts'
4
6
  import type { FabricConfig, FabricMode } from '@kubb/fabric-core/types'
5
7
  import { open } from './devtools.ts'
6
8
 
7
- export function createReactFabric(config?: FabricConfig<Options & { mode?: FabricMode; devtools?: boolean }>) {
9
+ export function createReactFabric(
10
+ config?: FabricConfig<Options & { mode?: FabricMode; devtools?: boolean }>,
11
+ ): Fabric<Options & { mode?: FabricMode; devtools?: boolean }> {
8
12
  const fabric = createFabric(config)
9
13
 
10
14
  if (config?.options?.devtools) {
package/src/globals.ts CHANGED
@@ -1,6 +1,5 @@
1
- import type { KubbElement, KubbExportProps, KubbFileProps, KubbImportProps, KubbSourceProps, KubbTextProps, LineBreakProps } from './types.ts'
1
+ import type { KubbNode, KubbElement, KubbExportProps, KubbFileProps, KubbImportProps, KubbSourceProps, KubbTextProps, LineBreakProps } from './types.ts'
2
2
  import type React from 'react'
3
- import type { KubbNode } from '@kubb/react-fabric/types'
4
3
 
5
4
  declare global {
6
5
  namespace JSX {
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins-CftsHDZ2.js","names":["onExit","node: TextNode","nodeNames: Array<ElementNames>","text","file: KubbFile.File"],"sources":["../src/components/Root.tsx","../src/dom.ts","../src/Renderer.ts","../src/utils/squashTextNodes.ts","../src/utils/squashExportNodes.ts","../src/utils/squashImportNodes.ts","../src/utils/squashSourceNodes.ts","../src/utils/processFiles.ts","../src/Runtime.tsx","../src/plugins/reactPlugin.ts"],"sourcesContent":["import { Component, createContext } from 'react'\n\nimport type { KubbNode } from '../types.ts'\n\ntype ErrorBoundaryProps = {\n onError: (error: Error) => void\n children?: KubbNode\n}\n\nclass ErrorBoundary extends Component<{\n onError: ErrorBoundaryProps['onError']\n children?: KubbNode\n}> {\n state = { hasError: false }\n\n static displayName = 'KubbErrorBoundary'\n static getDerivedStateFromError(_error: Error) {\n return { hasError: true }\n }\n\n componentDidCatch(error: Error) {\n if (error) {\n this.props.onError(error)\n }\n }\n\n render() {\n if (this.state.hasError) {\n return null\n }\n return this.props.children\n }\n}\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole Ink app.\n */\n readonly exit: (error?: Error) => void\n}\n\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n})\n\ntype RootProps = {\n /**\n * Exit (unmount) hook\n */\n readonly onExit: (error?: Error) => void\n /**\n * Error hook\n */\n readonly onError: (error: Error) => void\n readonly children?: KubbNode\n}\n\nexport function Root({ onError, onExit, children }: RootProps) {\n try {\n return (\n <ErrorBoundary\n onError={(error) => {\n onError(error)\n }}\n >\n <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>\n </ErrorBoundary>\n )\n } catch (_e) {\n return null\n }\n}\n\nRoot.Context = RootContext\nRoot.displayName = 'KubbRoot'\n","import type { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\nexport const createNode = (nodeName: string): DOMElement => {\n const node: DOMElement = {\n nodeName: nodeName as DOMElement['nodeName'],\n attributes: {},\n childNodes: [],\n parentNode: undefined,\n }\n\n return node\n}\n\nexport const appendChildNode = (node: DOMNode, childNode: DOMElement | DOMNode): void => {\n if (childNode.parentNode) {\n removeChildNode(childNode.parentNode, childNode)\n }\n\n if (node.nodeName !== '#text') {\n childNode.parentNode = node\n node.childNodes.push(childNode)\n }\n}\n\nexport const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode): void => {\n if (newChildNode.parentNode) {\n removeChildNode(newChildNode.parentNode, newChildNode)\n }\n\n newChildNode.parentNode = node\n\n const index = node.childNodes.indexOf(beforeChildNode)\n if (index >= 0) {\n node.childNodes.splice(index, 0, newChildNode)\n\n return\n }\n\n node.childNodes.push(newChildNode)\n}\n\nexport const removeChildNode = (node: DOMElement, removeNode: DOMNode): void => {\n removeNode.parentNode = undefined\n\n const index = node.childNodes.indexOf(removeNode)\n if (index >= 0) {\n node.childNodes.splice(index, 1)\n }\n}\n\nexport const setAttribute = (node: DOMElement, key: string, value: DOMNodeAttribute): void => {\n node.attributes[key] = value\n}\n\nexport const createTextNode = (text: string): TextNode => {\n const node: TextNode = {\n nodeName: '#text',\n nodeValue: text,\n parentNode: undefined,\n }\n\n setTextNodeValue(node, text)\n\n return node\n}\n\nexport const setTextNodeValue = (node: TextNode, text: string): void => {\n if (typeof text !== 'string') {\n text = String(text)\n }\n\n node.nodeValue = text\n}\n\nexport const nodeNames: Array<ElementNames> = ['kubb-export', 'kubb-file', 'kubb-source', 'kubb-import', 'kubb-text']\n","import Reconciler, { type ReactContext } from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants.js'\n\nimport { appendChildNode, createNode, createTextNode, insertBeforeNode, removeChildNode, setAttribute, setTextNodeValue } from './dom.ts'\nimport type { KubbNode } from './types'\nimport type { DOMElement, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\nimport { createContext } from 'react'\n\ndeclare module 'react-reconciler' {\n // @ts-expect-error custom override\n interface Reconciler {\n updateContainerSync(element: KubbNode, container: unknown, parentComponent: any, callback?: null | (() => void)): void\n flushSyncWork(): void\n createContainer(\n containerInfo: unknown,\n tag: Reconciler.RootTag,\n hydrationCallbacks: null | Reconciler.SuspenseHydrationCallbacks<any>,\n isStrictMode: boolean,\n concurrentUpdatesByDefaultOverride: null | boolean,\n identifierPrefix: string,\n onUncaughtError: (error: Error) => void,\n onCaughtError: (error: Error) => void,\n onRecoverableError: (error: Error) => void,\n transitionCallbacks: null | Reconciler.TransitionTracingCallbacks,\n ): Reconciler.OpaqueRoot\n }\n}\n\ntype Props = Record<string, unknown>\n\ntype HostContext = {\n type: ElementNames\n isFile: boolean\n isSource: boolean\n}\n\nlet currentUpdatePriority = NoEventPriority\n\n/**\n * @link https://www.npmjs.com/package/react-devtools-inline\n * @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md\n * @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples\n * @link https://github.com/vadimdemedes/ink\n * @link https://github.com/pixijs/pixi-react/tree/main/packages\n * @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts\n */\nexport const Renderer = Reconciler({\n getRootHostContext: () => ({\n type: 'kubb-root',\n isFile: false,\n isSource: false,\n }),\n prepareForCommit: () => {\n return null\n },\n preparePortalMount: () => null,\n clearContainer: () => false,\n resetAfterCommit(rootNode: DOMElement) {\n if (typeof rootNode.onRender === 'function') {\n rootNode.onRender()\n }\n },\n getChildHostContext(parentHostContext: HostContext, type: ElementNames) {\n const isInsideText = type === 'kubb-text'\n const isFile = type === 'kubb-file' || parentHostContext.isFile\n const isSource = type === 'kubb-source' || parentHostContext.isSource\n\n return { isInsideText, isFile, isSource, type }\n },\n shouldSetTextContent: () => false,\n createInstance(originalType: ElementNames, newProps: Props, _root: DOMElement) {\n const node = createNode(originalType)\n\n for (const [key, value] of Object.entries(newProps)) {\n if (key === 'children') {\n continue\n }\n\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n\n return node\n },\n createTextInstance(text: string, _root: DOMElement, hostContext: HostContext) {\n if (hostContext.isFile && !hostContext.isSource) {\n throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`)\n }\n\n return createTextNode(text)\n },\n resetTextContent() {},\n hideTextInstance(node: TextNode) {\n setTextNodeValue(node, '')\n },\n unhideTextInstance(node: TextNode, text: string) {\n setTextNodeValue(node, text)\n },\n getPublicInstance: (instance) => instance,\n appendInitialChild: appendChildNode,\n appendChild: appendChildNode,\n insertBefore: insertBeforeNode,\n finalizeInitialChildren(_node, _type, _props, _rootNode) {\n return false\n },\n supportsMutation: true,\n isPrimaryRenderer: true,\n supportsPersistence: false,\n supportsHydration: false,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n beforeActiveInstanceBlur() {},\n afterActiveInstanceBlur() {},\n detachDeletedInstance() {},\n getInstanceFromNode: () => null,\n prepareScopeUpdate() {},\n getInstanceFromScope: () => null,\n appendChildToContainer: appendChildNode,\n insertInContainerBefore: insertBeforeNode,\n removeChildFromContainer(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n commitMount() {},\n commitUpdate(node: DOMElement, _payload, _type, _oldProps: Props, newProps: Props) {\n const { props } = newProps\n\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n }\n },\n commitTextUpdate(node: TextNode, _oldText, newText) {\n setTextNodeValue(node, newText)\n },\n removeChild(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n setCurrentUpdatePriority: (newPriority: number) => {\n currentUpdatePriority = newPriority\n },\n getCurrentUpdatePriority: () => currentUpdatePriority,\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority\n }\n\n return DefaultEventPriority\n },\n maySuspendCommit() {\n return false\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NotPendingTransition: undefined,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HostTransitionContext: createContext(null) as unknown as ReactContext<unknown>,\n resetFormInstance() {},\n requestPostPaintCallback() {},\n shouldAttemptEagerTransition() {\n return false\n },\n trackSchedulerEvent() {},\n resolveEventType() {\n return null\n },\n resolveEventTimeStamp() {\n return -1.1\n },\n preloadInstance() {\n return true\n },\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady() {\n return null\n },\n})\n\nexport type { FiberRoot } from 'react-reconciler'\n","import { createImport, createExport, print } from '@kubb/fabric-core/parsers/typescript'\n\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashTextNodes(node: DOMElement): string {\n let text = ''\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n let nodeText = ''\n\n const getPrintText = (text: string): string => {\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n\n return print([\n createImport({\n name: attributes.name,\n path: attributes.path,\n root: attributes.root,\n isTypeOnly: attributes.isTypeOnly,\n }),\n ])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n if (attributes.path) {\n return print([\n createExport({\n name: attributes.name,\n path: attributes.path,\n isTypeOnly: attributes.isTypeOnly,\n asAlias: attributes.asAlias,\n }),\n ])\n }\n }\n\n if (childNode.nodeName === 'kubb-source') {\n return text\n }\n\n return text\n }\n\n if (childNode.nodeName === '#text') {\n nodeText = childNode.nodeValue\n } else {\n if (['kubb-text', 'kubb-file', 'kubb-source'].includes(childNode.nodeName)) {\n nodeText = squashTextNodes(childNode)\n }\n\n nodeText = getPrintText(nodeText)\n\n if (childNode.nodeName === 'br') {\n nodeText = '\\n'\n }\n\n // no kubb element or br\n if (![...nodeNames, 'br'].includes(childNode.nodeName)) {\n const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {\n if (typeof value === 'string') {\n return `${acc} ${key}=\"${value}\"`\n }\n\n return `${acc} ${key}={${value}}`\n }, '')\n nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`\n }\n }\n\n text += nodeText\n }\n\n return text\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashExportNodes(node: DOMElement): Set<KubbFile.ResolvedExport> {\n let exports = new Set<KubbFile.Export>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n exports = new Set([...exports, ...squashExportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n exports.add(attributes)\n }\n })\n\n return exports\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashImportNodes(node: DOMElement): Set<KubbFile.Import> {\n let imports = new Set<KubbFile.Import>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n imports = new Set([...imports, ...squashImportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n imports.add(attributes)\n }\n })\n\n return imports\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement, ElementNames } from '../types.ts'\nimport { squashTextNodes } from './squashTextNodes.ts'\n\nexport function squashSourceNodes(node: DOMElement, ignores: Array<ElementNames>): Set<KubbFile.Source> {\n let sources = new Set<KubbFile.Source>()\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && ignores.includes(childNode.nodeName)) {\n continue\n }\n\n if (childNode.nodeName === 'kubb-source') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Source>\n const value = squashTextNodes(childNode)\n\n sources.add({\n ...attributes,\n // remove end enter\n value: value.trim().replace(/^\\s+|\\s+$/g, ''),\n })\n\n continue\n }\n\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)])\n }\n }\n\n return sources\n}\n","import { nodeNames } from '../dom.ts'\nimport { squashExportNodes } from './squashExportNodes.ts'\nimport { squashImportNodes } from './squashImportNodes.ts'\nimport { squashSourceNodes } from './squashSourceNodes.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\nimport type { FileManager } from '@kubb/fabric-core'\n\nexport function processFiles(node: DOMElement, fileManager: FileManager) {\n for (let index = 0; index < node.childNodes.length; index++) {\n const childNode = node.childNodes[index]\n\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && childNode.nodeName !== 'kubb-file' && nodeNames.includes(childNode.nodeName)) {\n processFiles(childNode, fileManager)\n }\n\n if (childNode.nodeName === 'kubb-file') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File>\n\n if (attributes.baseName && attributes.path) {\n const sources = squashSourceNodes(childNode, ['kubb-export', 'kubb-import'])\n\n const file: KubbFile.File = {\n baseName: attributes.baseName,\n path: attributes.path,\n sources: [...sources],\n exports: [...squashExportNodes(childNode)],\n imports: [...squashImportNodes(childNode)],\n meta: attributes.meta || {},\n footer: attributes.footer,\n banner: attributes.banner,\n }\n\n fileManager.add(file)\n }\n }\n }\n}\n","import process from 'node:process'\nimport type { ReactNode } from 'react'\nimport { ConcurrentRoot } from 'react-reconciler/constants.js'\nimport { onExit } from 'signal-exit'\nimport { Root } from './components/Root.tsx'\nimport { createNode } from './dom.ts'\nimport type { FiberRoot } from './Renderer.ts'\nimport { Renderer } from './Renderer.ts'\nimport type { DOMElement } from './types.ts'\nimport { squashTextNodes } from './utils/squashTextNodes.ts'\nimport { processFiles } from './utils/processFiles.ts'\nimport type { FileManager } from '@kubb/fabric-core'\n\ntype Options = {\n fileManager: FileManager\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n // Ignore last render after unmounting a tree to prevent empty output before exit\n #isUnmounted: boolean\n\n exitPromise?: Promise<void>\n readonly #container: FiberRoot\n readonly #rootNode: DOMElement\n\n constructor(options: Options) {\n this.#options = options\n\n this.#rootNode = createNode('kubb-root')\n this.#rootNode.onRender = this.onRender\n this.#rootNode.onImmediateRender = this.onRender\n\n // Ignore last render after unmounting a tree to prevent empty output before exit\n this.#isUnmounted = false\n this.unmount.bind(this)\n\n const originalError = console.error\n console.error = (data: string | Error) => {\n const message = typeof data === 'string' ? data : data?.message\n\n if (message?.match(/Encountered two children with the same key/gi)) {\n return\n }\n if (message?.match(/React will try to recreat/gi)) {\n return\n }\n if (message?.match(/Each child in a list should have a unique/gi)) {\n return\n }\n if (message?.match(/The above error occurred in the <KubbErrorBoundary/gi)) {\n return\n }\n\n if (message?.match(/A React Element from an older version of React was render/gi)) {\n return\n }\n\n originalError(data)\n }\n\n // Report when an error was detected in a previous render\n // https://github.com/pmndrs/react-three-fiber/pull/2261\n const logRecoverableError =\n typeof reportError === 'function'\n ? // In modern browsers, reportError will dispatch an error event,\n // emulating an uncaught JavaScript error.\n reportError\n : // In older browsers and test environments, fallback to console.error.\n console.error\n\n const rootTag = ConcurrentRoot\n const hydrationCallbacks = null\n const isStrictMode = false\n const concurrentUpdatesByDefaultOverride = false\n const identifierPrefix = 'id'\n const onUncaughtError = logRecoverableError\n const onCaughtError = logRecoverableError\n const onRecoverableError = logRecoverableError\n const transitionCallbacks = null\n\n this.#container = Renderer.createContainer(\n this.#rootNode,\n rootTag,\n hydrationCallbacks,\n isStrictMode,\n concurrentUpdatesByDefaultOverride,\n identifierPrefix,\n onUncaughtError,\n onCaughtError,\n onRecoverableError,\n transitionCallbacks,\n )\n\n // Unmount when process exits\n this.unsubscribeExit = onExit(\n (code) => {\n this.unmount(code)\n },\n { alwaysLast: false },\n ).bind(this)\n\n Renderer.injectIntoDevTools({\n bundleType: 1, // 0 for PROD, 1 for DEV\n version: '19.1.0', // should be React version and not Kubb's custom version\n rendererPackageName: 'kubb', // package name\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n onRender: () => void = async () => {\n if (this.#isUnmounted) {\n return\n }\n\n // TODO remove to allow multiple renders\n this.fileManager.clear()\n\n processFiles(this.#rootNode, this.fileManager)\n\n if (!this.#options?.debug && !this.#options?.stdout) {\n return\n }\n\n const output = await this.#getOutput(this.#rootNode)\n\n if (this.#options?.debug) {\n console.log('Rendering: \\n')\n console.log(output)\n }\n\n if (this.#options?.stdout && process.env.NODE_ENV !== 'test') {\n this.#options.stdout.clearLine(0)\n this.#options.stdout.cursorTo(0)\n this.#options.stdout.write(output)\n }\n }\n onError(error: Error): void {\n if (process.env.NODE_ENV === 'test') {\n console.warn(error)\n }\n\n throw error\n }\n onExit(error?: Error): void {\n this.unmount(error)\n }\n\n async #getOutput(node: DOMElement): Promise<string> {\n const text = squashTextNodes(node)\n const files = this.fileManager.files\n\n return files.length\n ? [...files]\n .flatMap((file) => [...file.sources].map((item) => item.value))\n .filter(Boolean)\n .join('\\n\\n')\n : text\n }\n\n render(node: ReactNode): void {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n }\n\n async renderToString(node: ReactNode): Promise<string> {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n\n this.fileManager.clear()\n\n return this.#getOutput(this.#rootNode)\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#isUnmounted) {\n return\n }\n\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.onRender()\n this.unsubscribeExit()\n\n this.#isUnmounted = true\n\n Renderer.updateContainerSync(null, this.#container, null, null)\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { Runtime } from '../Runtime.tsx'\nimport { createElement, type ElementType } from 'react'\n\nexport type Options = {\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\n// biome-ignore lint/suspicious/noTsIgnore: production ready\n// @ts-ignore\ndeclare module '@kubb/fabric-core' {\n interface Fabric {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const reactPlugin = createPlugin<Options, ExtendOptions>({\n name: 'react',\n install() {},\n inject(app, options = {}) {\n const runtime = new Runtime({ fileManager: app.context.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await app.context.events.emit('start')\n },\n async renderToString(App) {\n await app.context.events.emit('start')\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await app.context.events.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAM,gBAAN,cAA4B,UAGzB;;;wBACD,SAAQ,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K;AAChB,YAAQ,OAAO,cAAc,IAAI,CAAC;AAClC,UAAM,IAAI,QAAQ,OAAO,KAAK,QAAQ;;GAExC,MAAM,eAAe,KAAK;AACxB,UAAM,IAAI,QAAQ,OAAO,KAAK,QAAQ;AACtC,WAAO,QAAQ,eAAe,cAAc,IAAI,CAAC;;GAEnD,MAAM,gBAAgB;AACpB,UAAM,QAAQ,eAAe;AAE7B,UAAM,IAAI,QAAQ,OAAO,KAAK,MAAM;;GAEvC;;CAEJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins-DzBEnan-.cjs","names":["Component","onExit","node: TextNode","nodeNames: Array<ElementNames>","NoEventPriority","DefaultEventPriority","text","exports","file: KubbFile.File","process","ConcurrentRoot"],"sources":["../src/components/Root.tsx","../src/dom.ts","../src/Renderer.ts","../src/utils/squashTextNodes.ts","../src/utils/squashExportNodes.ts","../src/utils/squashImportNodes.ts","../src/utils/squashSourceNodes.ts","../src/utils/processFiles.ts","../src/Runtime.tsx","../src/plugins/reactPlugin.ts"],"sourcesContent":["import { Component, createContext } from 'react'\n\nimport type { KubbNode } from '../types.ts'\n\ntype ErrorBoundaryProps = {\n onError: (error: Error) => void\n children?: KubbNode\n}\n\nclass ErrorBoundary extends Component<{\n onError: ErrorBoundaryProps['onError']\n children?: KubbNode\n}> {\n state = { hasError: false }\n\n static displayName = 'KubbErrorBoundary'\n static getDerivedStateFromError(_error: Error) {\n return { hasError: true }\n }\n\n componentDidCatch(error: Error) {\n if (error) {\n this.props.onError(error)\n }\n }\n\n render() {\n if (this.state.hasError) {\n return null\n }\n return this.props.children\n }\n}\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole Ink app.\n */\n readonly exit: (error?: Error) => void\n}\n\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n})\n\ntype RootProps = {\n /**\n * Exit (unmount) hook\n */\n readonly onExit: (error?: Error) => void\n /**\n * Error hook\n */\n readonly onError: (error: Error) => void\n readonly children?: KubbNode\n}\n\nexport function Root({ onError, onExit, children }: RootProps) {\n try {\n return (\n <ErrorBoundary\n onError={(error) => {\n onError(error)\n }}\n >\n <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>\n </ErrorBoundary>\n )\n } catch (_e) {\n return null\n }\n}\n\nRoot.Context = RootContext\nRoot.displayName = 'KubbRoot'\n","import type { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\nexport const createNode = (nodeName: string): DOMElement => {\n const node: DOMElement = {\n nodeName: nodeName as DOMElement['nodeName'],\n attributes: {},\n childNodes: [],\n parentNode: undefined,\n }\n\n return node\n}\n\nexport const appendChildNode = (node: DOMNode, childNode: DOMElement | DOMNode): void => {\n if (childNode.parentNode) {\n removeChildNode(childNode.parentNode, childNode)\n }\n\n if (node.nodeName !== '#text') {\n childNode.parentNode = node\n node.childNodes.push(childNode)\n }\n}\n\nexport const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode): void => {\n if (newChildNode.parentNode) {\n removeChildNode(newChildNode.parentNode, newChildNode)\n }\n\n newChildNode.parentNode = node\n\n const index = node.childNodes.indexOf(beforeChildNode)\n if (index >= 0) {\n node.childNodes.splice(index, 0, newChildNode)\n\n return\n }\n\n node.childNodes.push(newChildNode)\n}\n\nexport const removeChildNode = (node: DOMElement, removeNode: DOMNode): void => {\n removeNode.parentNode = undefined\n\n const index = node.childNodes.indexOf(removeNode)\n if (index >= 0) {\n node.childNodes.splice(index, 1)\n }\n}\n\nexport const setAttribute = (node: DOMElement, key: string, value: DOMNodeAttribute): void => {\n node.attributes[key] = value\n}\n\nexport const createTextNode = (text: string): TextNode => {\n const node: TextNode = {\n nodeName: '#text',\n nodeValue: text,\n parentNode: undefined,\n }\n\n setTextNodeValue(node, text)\n\n return node\n}\n\nexport const setTextNodeValue = (node: TextNode, text: string): void => {\n if (typeof text !== 'string') {\n text = String(text)\n }\n\n node.nodeValue = text\n}\n\nexport const nodeNames: Array<ElementNames> = ['kubb-export', 'kubb-file', 'kubb-source', 'kubb-import', 'kubb-text']\n","import Reconciler, { type ReactContext } from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants.js'\n\nimport { appendChildNode, createNode, createTextNode, insertBeforeNode, removeChildNode, setAttribute, setTextNodeValue } from './dom.ts'\nimport type { KubbNode } from './types'\nimport type { DOMElement, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\nimport { createContext } from 'react'\n\ndeclare module 'react-reconciler' {\n // @ts-expect-error custom override\n interface Reconciler {\n updateContainerSync(element: KubbNode, container: unknown, parentComponent: any, callback?: null | (() => void)): void\n flushSyncWork(): void\n createContainer(\n containerInfo: unknown,\n tag: Reconciler.RootTag,\n hydrationCallbacks: null | Reconciler.SuspenseHydrationCallbacks<any>,\n isStrictMode: boolean,\n concurrentUpdatesByDefaultOverride: null | boolean,\n identifierPrefix: string,\n onUncaughtError: (error: Error) => void,\n onCaughtError: (error: Error) => void,\n onRecoverableError: (error: Error) => void,\n transitionCallbacks: null | Reconciler.TransitionTracingCallbacks,\n ): Reconciler.OpaqueRoot\n }\n}\n\ntype Props = Record<string, unknown>\n\ntype HostContext = {\n type: ElementNames\n isFile: boolean\n isSource: boolean\n}\n\nlet currentUpdatePriority = NoEventPriority\n\n/**\n * @link https://www.npmjs.com/package/react-devtools-inline\n * @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md\n * @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples\n * @link https://github.com/vadimdemedes/ink\n * @link https://github.com/pixijs/pixi-react/tree/main/packages\n * @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts\n */\nexport const Renderer = Reconciler({\n getRootHostContext: () => ({\n type: 'kubb-root',\n isFile: false,\n isSource: false,\n }),\n prepareForCommit: () => {\n return null\n },\n preparePortalMount: () => null,\n clearContainer: () => false,\n resetAfterCommit(rootNode: DOMElement) {\n if (typeof rootNode.onRender === 'function') {\n rootNode.onRender()\n }\n },\n getChildHostContext(parentHostContext: HostContext, type: ElementNames) {\n const isInsideText = type === 'kubb-text'\n const isFile = type === 'kubb-file' || parentHostContext.isFile\n const isSource = type === 'kubb-source' || parentHostContext.isSource\n\n return { isInsideText, isFile, isSource, type }\n },\n shouldSetTextContent: () => false,\n createInstance(originalType: ElementNames, newProps: Props, _root: DOMElement) {\n const node = createNode(originalType)\n\n for (const [key, value] of Object.entries(newProps)) {\n if (key === 'children') {\n continue\n }\n\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n\n return node\n },\n createTextInstance(text: string, _root: DOMElement, hostContext: HostContext) {\n if (hostContext.isFile && !hostContext.isSource) {\n throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`)\n }\n\n return createTextNode(text)\n },\n resetTextContent() {},\n hideTextInstance(node: TextNode) {\n setTextNodeValue(node, '')\n },\n unhideTextInstance(node: TextNode, text: string) {\n setTextNodeValue(node, text)\n },\n getPublicInstance: (instance) => instance,\n appendInitialChild: appendChildNode,\n appendChild: appendChildNode,\n insertBefore: insertBeforeNode,\n finalizeInitialChildren(_node, _type, _props, _rootNode) {\n return false\n },\n supportsMutation: true,\n isPrimaryRenderer: true,\n supportsPersistence: false,\n supportsHydration: false,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n beforeActiveInstanceBlur() {},\n afterActiveInstanceBlur() {},\n detachDeletedInstance() {},\n getInstanceFromNode: () => null,\n prepareScopeUpdate() {},\n getInstanceFromScope: () => null,\n appendChildToContainer: appendChildNode,\n insertInContainerBefore: insertBeforeNode,\n removeChildFromContainer(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n commitMount() {},\n commitUpdate(node: DOMElement, _payload, _type, _oldProps: Props, newProps: Props) {\n const { props } = newProps\n\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n }\n },\n commitTextUpdate(node: TextNode, _oldText, newText) {\n setTextNodeValue(node, newText)\n },\n removeChild(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n setCurrentUpdatePriority: (newPriority: number) => {\n currentUpdatePriority = newPriority\n },\n getCurrentUpdatePriority: () => currentUpdatePriority,\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority\n }\n\n return DefaultEventPriority\n },\n maySuspendCommit() {\n return false\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NotPendingTransition: undefined,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HostTransitionContext: createContext(null) as unknown as ReactContext<unknown>,\n resetFormInstance() {},\n requestPostPaintCallback() {},\n shouldAttemptEagerTransition() {\n return false\n },\n trackSchedulerEvent() {},\n resolveEventType() {\n return null\n },\n resolveEventTimeStamp() {\n return -1.1\n },\n preloadInstance() {\n return true\n },\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady() {\n return null\n },\n})\n\nexport type { FiberRoot } from 'react-reconciler'\n","import { createImport, createExport, print } from '@kubb/fabric-core/parsers/typescript'\n\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashTextNodes(node: DOMElement): string {\n let text = ''\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n let nodeText = ''\n\n const getPrintText = (text: string): string => {\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n\n return print([\n createImport({\n name: attributes.name,\n path: attributes.path,\n root: attributes.root,\n isTypeOnly: attributes.isTypeOnly,\n }),\n ])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n if (attributes.path) {\n return print([\n createExport({\n name: attributes.name,\n path: attributes.path,\n isTypeOnly: attributes.isTypeOnly,\n asAlias: attributes.asAlias,\n }),\n ])\n }\n }\n\n if (childNode.nodeName === 'kubb-source') {\n return text\n }\n\n return text\n }\n\n if (childNode.nodeName === '#text') {\n nodeText = childNode.nodeValue\n } else {\n if (['kubb-text', 'kubb-file', 'kubb-source'].includes(childNode.nodeName)) {\n nodeText = squashTextNodes(childNode)\n }\n\n nodeText = getPrintText(nodeText)\n\n if (childNode.nodeName === 'br') {\n nodeText = '\\n'\n }\n\n // no kubb element or br\n if (![...nodeNames, 'br'].includes(childNode.nodeName)) {\n const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {\n if (typeof value === 'string') {\n return `${acc} ${key}=\"${value}\"`\n }\n\n return `${acc} ${key}={${value}}`\n }, '')\n nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`\n }\n }\n\n text += nodeText\n }\n\n return text\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashExportNodes(node: DOMElement): Set<KubbFile.ResolvedExport> {\n let exports = new Set<KubbFile.Export>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n exports = new Set([...exports, ...squashExportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n exports.add(attributes)\n }\n })\n\n return exports\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashImportNodes(node: DOMElement): Set<KubbFile.Import> {\n let imports = new Set<KubbFile.Import>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n imports = new Set([...imports, ...squashImportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n imports.add(attributes)\n }\n })\n\n return imports\n}\n","import { nodeNames } from '../dom.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement, ElementNames } from '../types.ts'\nimport { squashTextNodes } from './squashTextNodes.ts'\n\nexport function squashSourceNodes(node: DOMElement, ignores: Array<ElementNames>): Set<KubbFile.Source> {\n let sources = new Set<KubbFile.Source>()\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && ignores.includes(childNode.nodeName)) {\n continue\n }\n\n if (childNode.nodeName === 'kubb-source') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Source>\n const value = squashTextNodes(childNode)\n\n sources.add({\n ...attributes,\n // remove end enter\n value: value.trim().replace(/^\\s+|\\s+$/g, ''),\n })\n\n continue\n }\n\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)])\n }\n }\n\n return sources\n}\n","import { nodeNames } from '../dom.ts'\nimport { squashExportNodes } from './squashExportNodes.ts'\nimport { squashImportNodes } from './squashImportNodes.ts'\nimport { squashSourceNodes } from './squashSourceNodes.ts'\n\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport type { DOMElement } from '../types.ts'\nimport type { FileManager } from '@kubb/fabric-core'\n\nexport function processFiles(node: DOMElement, fileManager: FileManager) {\n for (let index = 0; index < node.childNodes.length; index++) {\n const childNode = node.childNodes[index]\n\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && childNode.nodeName !== 'kubb-file' && nodeNames.includes(childNode.nodeName)) {\n processFiles(childNode, fileManager)\n }\n\n if (childNode.nodeName === 'kubb-file') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File>\n\n if (attributes.baseName && attributes.path) {\n const sources = squashSourceNodes(childNode, ['kubb-export', 'kubb-import'])\n\n const file: KubbFile.File = {\n baseName: attributes.baseName,\n path: attributes.path,\n sources: [...sources],\n exports: [...squashExportNodes(childNode)],\n imports: [...squashImportNodes(childNode)],\n meta: attributes.meta || {},\n footer: attributes.footer,\n banner: attributes.banner,\n }\n\n fileManager.add(file)\n }\n }\n }\n}\n","import process from 'node:process'\nimport type { ReactNode } from 'react'\nimport { ConcurrentRoot } from 'react-reconciler/constants.js'\nimport { onExit } from 'signal-exit'\nimport { Root } from './components/Root.tsx'\nimport { createNode } from './dom.ts'\nimport type { FiberRoot } from './Renderer.ts'\nimport { Renderer } from './Renderer.ts'\nimport type { DOMElement } from './types.ts'\nimport { squashTextNodes } from './utils/squashTextNodes.ts'\nimport { processFiles } from './utils/processFiles.ts'\nimport type { FileManager } from '@kubb/fabric-core'\n\ntype Options = {\n fileManager: FileManager\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\nexport class Runtime {\n readonly #options: Options\n // Ignore last render after unmounting a tree to prevent empty output before exit\n #isUnmounted: boolean\n\n exitPromise?: Promise<void>\n readonly #container: FiberRoot\n readonly #rootNode: DOMElement\n\n constructor(options: Options) {\n this.#options = options\n\n this.#rootNode = createNode('kubb-root')\n this.#rootNode.onRender = this.onRender\n this.#rootNode.onImmediateRender = this.onRender\n\n // Ignore last render after unmounting a tree to prevent empty output before exit\n this.#isUnmounted = false\n this.unmount.bind(this)\n\n const originalError = console.error\n console.error = (data: string | Error) => {\n const message = typeof data === 'string' ? data : data?.message\n\n if (message?.match(/Encountered two children with the same key/gi)) {\n return\n }\n if (message?.match(/React will try to recreat/gi)) {\n return\n }\n if (message?.match(/Each child in a list should have a unique/gi)) {\n return\n }\n if (message?.match(/The above error occurred in the <KubbErrorBoundary/gi)) {\n return\n }\n\n if (message?.match(/A React Element from an older version of React was render/gi)) {\n return\n }\n\n originalError(data)\n }\n\n // Report when an error was detected in a previous render\n // https://github.com/pmndrs/react-three-fiber/pull/2261\n const logRecoverableError =\n typeof reportError === 'function'\n ? // In modern browsers, reportError will dispatch an error event,\n // emulating an uncaught JavaScript error.\n reportError\n : // In older browsers and test environments, fallback to console.error.\n console.error\n\n const rootTag = ConcurrentRoot\n const hydrationCallbacks = null\n const isStrictMode = false\n const concurrentUpdatesByDefaultOverride = false\n const identifierPrefix = 'id'\n const onUncaughtError = logRecoverableError\n const onCaughtError = logRecoverableError\n const onRecoverableError = logRecoverableError\n const transitionCallbacks = null\n\n this.#container = Renderer.createContainer(\n this.#rootNode,\n rootTag,\n hydrationCallbacks,\n isStrictMode,\n concurrentUpdatesByDefaultOverride,\n identifierPrefix,\n onUncaughtError,\n onCaughtError,\n onRecoverableError,\n transitionCallbacks,\n )\n\n // Unmount when process exits\n this.unsubscribeExit = onExit(\n (code) => {\n this.unmount(code)\n },\n { alwaysLast: false },\n ).bind(this)\n\n Renderer.injectIntoDevTools({\n bundleType: 1, // 0 for PROD, 1 for DEV\n version: '19.1.0', // should be React version and not Kubb's custom version\n rendererPackageName: 'kubb', // package name\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n onRender: () => void = async () => {\n if (this.#isUnmounted) {\n return\n }\n\n // TODO remove to allow multiple renders\n this.fileManager.clear()\n\n processFiles(this.#rootNode, this.fileManager)\n\n if (!this.#options?.debug && !this.#options?.stdout) {\n return\n }\n\n const output = await this.#getOutput(this.#rootNode)\n\n if (this.#options?.debug) {\n console.log('Rendering: \\n')\n console.log(output)\n }\n\n if (this.#options?.stdout && process.env.NODE_ENV !== 'test') {\n this.#options.stdout.clearLine(0)\n this.#options.stdout.cursorTo(0)\n this.#options.stdout.write(output)\n }\n }\n onError(error: Error): void {\n if (process.env.NODE_ENV === 'test') {\n console.warn(error)\n }\n\n throw error\n }\n onExit(error?: Error): void {\n this.unmount(error)\n }\n\n async #getOutput(node: DOMElement): Promise<string> {\n const text = squashTextNodes(node)\n const files = this.fileManager.files\n\n return files.length\n ? [...files]\n .flatMap((file) => [...file.sources].map((item) => item.value))\n .filter(Boolean)\n .join('\\n\\n')\n : text\n }\n\n render(node: ReactNode): void {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n }\n\n async renderToString(node: ReactNode): Promise<string> {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n\n this.fileManager.clear()\n\n return this.#getOutput(this.#rootNode)\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#isUnmounted) {\n return\n }\n\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.onRender()\n this.unsubscribeExit()\n\n this.#isUnmounted = true\n\n Renderer.updateContainerSync(null, this.#container, null, null)\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { Runtime } from '../Runtime.tsx'\nimport { createElement, type ElementType } from 'react'\n\nexport type Options = {\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\n// biome-ignore lint/suspicious/noTsIgnore: production ready\n// @ts-ignore\ndeclare module '@kubb/fabric-core' {\n interface Fabric {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const reactPlugin = createPlugin<Options, ExtendOptions>({\n name: 'react',\n install() {},\n inject(app, options = {}) {\n const runtime = new Runtime({ fileManager: app.context.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await app.context.events.emit('start')\n },\n async renderToString(App) {\n await app.context.events.emit('start')\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await app.context.events.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAM,gBAAN,cAA4BA,gBAGzB;;;wBACD,SAAQ,EAAE,UAAU,OAAO;;CAG3B,OAAO,yBAAyB,QAAe;AAC7C,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkB,OAAc;AAC9B,MAAI,MACF,MAAK,MAAM,QAAQ,MAAM;;CAI7B,SAAS;AACP,MAAI,KAAK,MAAM,SACb,QAAO;AAET,SAAO,KAAK,MAAM;;;+BAfb,eAAc;AA0BvB,MAAa,uCAA8C,EACzD,YAAY,IACb,CAAC;AAcF,SAAgB,KAAK,EAAE,SAAS,kBAAQ,YAAuB;AAC7D,KAAI;AACF,SACE,2CAAC;GACC,UAAU,UAAU;AAClB,YAAQ,MAAM;;aAGhB,2CAAC,YAAY;IAAS,OAAO,EAAE,MAAMC,UAAQ;IAAG;KAAgC;IAClE;UAEX,IAAI;AACX,SAAO;;;AAIX,KAAK,UAAU;AACf,KAAK,cAAc;;;;ACxEnB,MAAa,cAAc,aAAiC;AAQ1D,QA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