@kubb/react-fabric 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/{Fabric-nxgJyzWH.d.cts → Fabric-BF1akKIl.d.cts} +3 -3
  2. package/dist/{Fabric-DwVGMumV.d.ts → Fabric-E6DCwBtT.d.ts} +3 -3
  3. package/dist/{KubbFile-bFdmEsQz.d.ts → KubbFile-D4gyyfL-.d.ts} +1 -1
  4. package/dist/{KubbFile-DHCtBOpy.d.cts → KubbFile-FGXV713i.d.cts} +1 -1
  5. package/dist/{chunk-9mlisOrp.js → chunk-BEV-X5tz.js} +4 -5
  6. package/dist/{chunk-BaqVhFee.cjs → chunk-CUT6urMc.cjs} +0 -16
  7. package/dist/{devtools-D7cmED8s.js → devtools-Cb1pMQYm.js} +2 -3
  8. package/dist/{devtools-D7cmED8s.js.map → devtools-Cb1pMQYm.js.map} +1 -1
  9. package/dist/{devtools-CYVZyenT.cjs → devtools-D4p2T_2t.cjs} +3 -3
  10. package/dist/{devtools-CYVZyenT.cjs.map → devtools-D4p2T_2t.cjs.map} +1 -1
  11. package/dist/devtools.cjs +1 -1
  12. package/dist/devtools.js +1 -1
  13. package/dist/globals-C_mBzXoD.d.ts +26 -0
  14. package/dist/globals-DHvLS0j3.d.cts +26 -0
  15. package/dist/globals.d.cts +3 -3
  16. package/dist/globals.d.ts +3 -3
  17. package/dist/index.cjs +110 -79
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +18 -20
  20. package/dist/index.d.ts +18 -20
  21. package/dist/index.js +61 -72
  22. package/dist/index.js.map +1 -1
  23. package/dist/jsx-dev-runtime.cjs +15 -7
  24. package/dist/jsx-dev-runtime.d.cts +5 -0
  25. package/dist/jsx-dev-runtime.d.ts +5 -0
  26. package/dist/jsx-dev-runtime.js +2 -4
  27. package/dist/jsx-namespace-Cu6WTmTt.d.cts +27 -0
  28. package/dist/jsx-namespace-ghArQSma.d.ts +27 -0
  29. package/dist/jsx-runtime.cjs +21 -7
  30. package/dist/jsx-runtime.d.cts +5 -14
  31. package/dist/jsx-runtime.d.ts +5 -14
  32. package/dist/jsx-runtime.js +2 -4
  33. package/dist/parsers.d.cts +2 -2
  34. package/dist/parsers.d.ts +2 -2
  35. package/dist/plugins-9oisj5ko.cjs +640 -0
  36. package/dist/plugins-9oisj5ko.cjs.map +1 -0
  37. package/dist/plugins-DYBs1Uhp.js +590 -0
  38. package/dist/plugins-DYBs1Uhp.js.map +1 -0
  39. package/dist/plugins.cjs +1 -2
  40. package/dist/plugins.d.cts +3 -3
  41. package/dist/plugins.d.ts +3 -3
  42. package/dist/plugins.js +1 -2
  43. package/dist/{reactPlugin-DyvfLVFa.d.ts → reactPlugin-B3xiMbv8.d.ts} +2 -2
  44. package/dist/{reactPlugin-CLgWWifj.d.cts → reactPlugin-DpMLHD7t.d.cts} +2 -2
  45. package/dist/{types-DoYRYV1C.d.cts → types-C9HPr_ft.d.cts} +21 -3
  46. package/dist/{types-BnXxcIyv.d.ts → types-P2Lm1k_W.d.ts} +21 -3
  47. package/dist/types.d.cts +3 -2
  48. package/dist/types.d.ts +3 -2
  49. package/package.json +7 -4
  50. package/src/globals.ts +17 -43
  51. package/src/index.ts +2 -11
  52. package/src/jsx-dev-runtime.ts +3 -0
  53. package/src/jsx-namespace.d.ts +27 -0
  54. package/src/jsx-runtime.ts +2 -7
  55. package/src/types.ts +24 -0
  56. package/dist/backend-BwCrJwGY.cjs +0 -11364
  57. package/dist/backend-BwCrJwGY.cjs.map +0 -1
  58. package/dist/backend-U2f8IEJ7.js +0 -11361
  59. package/dist/backend-U2f8IEJ7.js.map +0 -1
  60. package/dist/globals-1MFa0Fvg.d.ts +0 -52
  61. package/dist/globals-C7dPa-nz.d.cts +0 -52
  62. package/dist/jsx-runtime-8_h1Kd4b.cjs +0 -36
  63. package/dist/jsx-runtime-8_h1Kd4b.cjs.map +0 -1
  64. package/dist/jsx-runtime-BJX2mL7C.js +0 -13
  65. package/dist/jsx-runtime-BJX2mL7C.js.map +0 -1
  66. package/dist/jsx-runtime-C9xQ4GQD.js +0 -1338
  67. package/dist/jsx-runtime-C9xQ4GQD.js.map +0 -1
  68. package/dist/jsx-runtime-CSnwG7o6.cjs +0 -1349
  69. package/dist/jsx-runtime-CSnwG7o6.cjs.map +0 -1
  70. package/dist/plugins-BQE1GnQ7.cjs +0 -15554
  71. package/dist/plugins-BQE1GnQ7.cjs.map +0 -1
  72. package/dist/plugins-BVFjgEC2.js +0 -15509
  73. package/dist/plugins-BVFjgEC2.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins-9oisj5ko.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'\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'\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;AAC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AE/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"}
@@ -0,0 +1,590 @@
1
+ import { Component, createContext, createElement } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createPlugin } from "@kubb/fabric-core/plugins";
4
+ import process from "node:process";
5
+ import { ConcurrentRoot, DefaultEventPriority, NoEventPriority } from "react-reconciler/constants";
6
+ import { onExit } from "signal-exit";
7
+ import Reconciler from "react-reconciler";
8
+ import { createExport, createImport, print } from "@kubb/fabric-core/parsers/typescript";
9
+
10
+ //#region \0@oxc-project+runtime@0.95.0/helpers/typeof.js
11
+ function _typeof(o) {
12
+ "@babel/helpers - typeof";
13
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
14
+ return typeof o$1;
15
+ } : function(o$1) {
16
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
17
+ }, _typeof(o);
18
+ }
19
+
20
+ //#endregion
21
+ //#region \0@oxc-project+runtime@0.95.0/helpers/toPrimitive.js
22
+ function toPrimitive(t, r) {
23
+ if ("object" != _typeof(t) || !t) return t;
24
+ var e = t[Symbol.toPrimitive];
25
+ if (void 0 !== e) {
26
+ var i = e.call(t, r || "default");
27
+ if ("object" != _typeof(i)) return i;
28
+ throw new TypeError("@@toPrimitive must return a primitive value.");
29
+ }
30
+ return ("string" === r ? String : Number)(t);
31
+ }
32
+
33
+ //#endregion
34
+ //#region \0@oxc-project+runtime@0.95.0/helpers/toPropertyKey.js
35
+ function toPropertyKey(t) {
36
+ var i = toPrimitive(t, "string");
37
+ return "symbol" == _typeof(i) ? i : i + "";
38
+ }
39
+
40
+ //#endregion
41
+ //#region \0@oxc-project+runtime@0.95.0/helpers/defineProperty.js
42
+ function _defineProperty(e, r, t) {
43
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
44
+ value: t,
45
+ enumerable: !0,
46
+ configurable: !0,
47
+ writable: !0
48
+ }) : e[r] = t, e;
49
+ }
50
+
51
+ //#endregion
52
+ //#region src/components/Root.tsx
53
+ var ErrorBoundary = class extends Component {
54
+ constructor(..._args) {
55
+ super(..._args);
56
+ _defineProperty(this, "state", { hasError: false });
57
+ }
58
+ static getDerivedStateFromError(_error) {
59
+ return { hasError: true };
60
+ }
61
+ componentDidCatch(error) {
62
+ if (error) this.props.onError(error);
63
+ }
64
+ render() {
65
+ if (this.state.hasError) return null;
66
+ return this.props.children;
67
+ }
68
+ };
69
+ _defineProperty(ErrorBoundary, "displayName", "KubbErrorBoundary");
70
+ const RootContext = createContext({ exit: () => {} });
71
+ function Root({ onError, onExit: onExit$1, children }) {
72
+ try {
73
+ return /* @__PURE__ */ jsx(ErrorBoundary, {
74
+ onError: (error) => {
75
+ onError(error);
76
+ },
77
+ children: /* @__PURE__ */ jsx(RootContext.Provider, {
78
+ value: { exit: onExit$1 },
79
+ children
80
+ })
81
+ });
82
+ } catch (_e) {
83
+ return null;
84
+ }
85
+ }
86
+ Root.Context = RootContext;
87
+ Root.displayName = "KubbRoot";
88
+
89
+ //#endregion
90
+ //#region src/dom.ts
91
+ const createNode = (nodeName) => {
92
+ return {
93
+ nodeName,
94
+ attributes: {},
95
+ childNodes: [],
96
+ parentNode: void 0
97
+ };
98
+ };
99
+ const appendChildNode = (node, childNode) => {
100
+ if (childNode.parentNode) removeChildNode(childNode.parentNode, childNode);
101
+ if (node.nodeName !== "#text") {
102
+ childNode.parentNode = node;
103
+ node.childNodes.push(childNode);
104
+ }
105
+ };
106
+ const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
107
+ if (newChildNode.parentNode) removeChildNode(newChildNode.parentNode, newChildNode);
108
+ newChildNode.parentNode = node;
109
+ const index = node.childNodes.indexOf(beforeChildNode);
110
+ if (index >= 0) {
111
+ node.childNodes.splice(index, 0, newChildNode);
112
+ return;
113
+ }
114
+ node.childNodes.push(newChildNode);
115
+ };
116
+ const removeChildNode = (node, removeNode) => {
117
+ removeNode.parentNode = void 0;
118
+ const index = node.childNodes.indexOf(removeNode);
119
+ if (index >= 0) node.childNodes.splice(index, 1);
120
+ };
121
+ const setAttribute = (node, key, value) => {
122
+ node.attributes[key] = value;
123
+ };
124
+ const createTextNode = (text) => {
125
+ const node = {
126
+ nodeName: "#text",
127
+ nodeValue: text,
128
+ parentNode: void 0
129
+ };
130
+ setTextNodeValue(node, text);
131
+ return node;
132
+ };
133
+ const setTextNodeValue = (node, text) => {
134
+ if (typeof text !== "string") text = String(text);
135
+ node.nodeValue = text;
136
+ };
137
+ const nodeNames = [
138
+ "kubb-export",
139
+ "kubb-file",
140
+ "kubb-source",
141
+ "kubb-import",
142
+ "kubb-text"
143
+ ];
144
+
145
+ //#endregion
146
+ //#region src/Renderer.ts
147
+ let currentUpdatePriority = NoEventPriority;
148
+ /**
149
+ * @link https://www.npmjs.com/package/react-devtools-inline
150
+ * @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md
151
+ * @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples
152
+ * @link https://github.com/vadimdemedes/ink
153
+ * @link https://github.com/pixijs/pixi-react/tree/main/packages
154
+ * @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts
155
+ */
156
+ const Renderer = Reconciler({
157
+ getRootHostContext: () => ({
158
+ type: "kubb-root",
159
+ isFile: false,
160
+ isSource: false
161
+ }),
162
+ prepareForCommit: () => {
163
+ return null;
164
+ },
165
+ preparePortalMount: () => null,
166
+ clearContainer: () => false,
167
+ resetAfterCommit(rootNode) {
168
+ if (typeof rootNode.onRender === "function") rootNode.onRender();
169
+ },
170
+ getChildHostContext(parentHostContext, type) {
171
+ return {
172
+ isInsideText: type === "kubb-text",
173
+ isFile: type === "kubb-file" || parentHostContext.isFile,
174
+ isSource: type === "kubb-source" || parentHostContext.isSource,
175
+ type
176
+ };
177
+ },
178
+ shouldSetTextContent: () => false,
179
+ createInstance(originalType, newProps, _root) {
180
+ const node = createNode(originalType);
181
+ for (const [key, value] of Object.entries(newProps)) {
182
+ if (key === "children") continue;
183
+ setAttribute(node, key, value);
184
+ }
185
+ return node;
186
+ },
187
+ createTextInstance(text, _root, hostContext) {
188
+ if (hostContext.isFile && !hostContext.isSource) throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`);
189
+ return createTextNode(text);
190
+ },
191
+ resetTextContent() {},
192
+ hideTextInstance(node) {
193
+ setTextNodeValue(node, "");
194
+ },
195
+ unhideTextInstance(node, text) {
196
+ setTextNodeValue(node, text);
197
+ },
198
+ getPublicInstance: (instance) => instance,
199
+ appendInitialChild: appendChildNode,
200
+ appendChild: appendChildNode,
201
+ insertBefore: insertBeforeNode,
202
+ finalizeInitialChildren(_node, _type, _props, _rootNode$1) {
203
+ return false;
204
+ },
205
+ supportsMutation: true,
206
+ isPrimaryRenderer: true,
207
+ supportsPersistence: false,
208
+ supportsHydration: false,
209
+ scheduleTimeout: setTimeout,
210
+ cancelTimeout: clearTimeout,
211
+ noTimeout: -1,
212
+ beforeActiveInstanceBlur() {},
213
+ afterActiveInstanceBlur() {},
214
+ detachDeletedInstance() {},
215
+ getInstanceFromNode: () => null,
216
+ prepareScopeUpdate() {},
217
+ getInstanceFromScope: () => null,
218
+ appendChildToContainer: appendChildNode,
219
+ insertInContainerBefore: insertBeforeNode,
220
+ removeChildFromContainer(node, removeNode) {
221
+ removeChildNode(node, removeNode);
222
+ },
223
+ commitMount() {},
224
+ commitUpdate(node, _payload, _type, _oldProps, newProps) {
225
+ const { props } = newProps;
226
+ if (props) for (const [key, value] of Object.entries(props)) setAttribute(node, key, value);
227
+ },
228
+ commitTextUpdate(node, _oldText, newText) {
229
+ setTextNodeValue(node, newText);
230
+ },
231
+ removeChild(node, removeNode) {
232
+ removeChildNode(node, removeNode);
233
+ },
234
+ setCurrentUpdatePriority: (newPriority) => {
235
+ currentUpdatePriority = newPriority;
236
+ },
237
+ getCurrentUpdatePriority: () => currentUpdatePriority,
238
+ resolveUpdatePriority() {
239
+ if (currentUpdatePriority !== NoEventPriority) return currentUpdatePriority;
240
+ return DefaultEventPriority;
241
+ },
242
+ maySuspendCommit() {
243
+ return false;
244
+ },
245
+ NotPendingTransition: void 0,
246
+ HostTransitionContext: createContext(null),
247
+ resetFormInstance() {},
248
+ requestPostPaintCallback() {},
249
+ shouldAttemptEagerTransition() {
250
+ return false;
251
+ },
252
+ trackSchedulerEvent() {},
253
+ resolveEventType() {
254
+ return null;
255
+ },
256
+ resolveEventTimeStamp() {
257
+ return -1.1;
258
+ },
259
+ preloadInstance() {
260
+ return true;
261
+ },
262
+ startSuspendingCommit() {},
263
+ suspendInstance() {},
264
+ waitForCommitToBeReady() {
265
+ return null;
266
+ }
267
+ });
268
+
269
+ //#endregion
270
+ //#region src/utils/squashTextNodes.ts
271
+ function squashTextNodes(node) {
272
+ let text = "";
273
+ for (const childNode of node.childNodes) {
274
+ if (!childNode) continue;
275
+ let nodeText = "";
276
+ const getPrintText = (text$1) => {
277
+ if (childNode.nodeName === "kubb-import") {
278
+ const attributes = childNode.attributes;
279
+ return print([createImport({
280
+ name: attributes.name,
281
+ path: attributes.path,
282
+ root: attributes.root,
283
+ isTypeOnly: attributes.isTypeOnly
284
+ })]);
285
+ }
286
+ if (childNode.nodeName === "kubb-export") {
287
+ const attributes = childNode.attributes;
288
+ if (attributes.path) return print([createExport({
289
+ name: attributes.name,
290
+ path: attributes.path,
291
+ isTypeOnly: attributes.isTypeOnly,
292
+ asAlias: attributes.asAlias
293
+ })]);
294
+ }
295
+ if (childNode.nodeName === "kubb-source") return text$1;
296
+ return text$1;
297
+ };
298
+ if (childNode.nodeName === "#text") nodeText = childNode.nodeValue;
299
+ else {
300
+ if ([
301
+ "kubb-text",
302
+ "kubb-file",
303
+ "kubb-source"
304
+ ].includes(childNode.nodeName)) nodeText = squashTextNodes(childNode);
305
+ nodeText = getPrintText(nodeText);
306
+ if (childNode.nodeName === "br") nodeText = "\n";
307
+ if (![...nodeNames, "br"].includes(childNode.nodeName)) {
308
+ const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {
309
+ if (typeof value === "string") return `${acc} ${key}="${value}"`;
310
+ return `${acc} ${key}={${value}}`;
311
+ }, "");
312
+ nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`;
313
+ }
314
+ }
315
+ text += nodeText;
316
+ }
317
+ return text;
318
+ }
319
+
320
+ //#endregion
321
+ //#region src/utils/squashExportNodes.ts
322
+ function squashExportNodes(node) {
323
+ let exports = /* @__PURE__ */ new Set();
324
+ node.childNodes.filter(Boolean).forEach((childNode) => {
325
+ if (childNode.nodeName !== "#text" && nodeNames.includes(childNode.nodeName)) exports = new Set([...exports, ...squashExportNodes(childNode)]);
326
+ if (childNode.nodeName === "kubb-export") {
327
+ const attributes = childNode.attributes;
328
+ exports.add(attributes);
329
+ }
330
+ });
331
+ return exports;
332
+ }
333
+
334
+ //#endregion
335
+ //#region src/utils/squashImportNodes.ts
336
+ function squashImportNodes(node) {
337
+ let imports = /* @__PURE__ */ new Set();
338
+ node.childNodes.filter(Boolean).forEach((childNode) => {
339
+ if (childNode.nodeName !== "#text" && nodeNames.includes(childNode.nodeName)) imports = new Set([...imports, ...squashImportNodes(childNode)]);
340
+ if (childNode.nodeName === "kubb-import") {
341
+ const attributes = childNode.attributes;
342
+ imports.add(attributes);
343
+ }
344
+ });
345
+ return imports;
346
+ }
347
+
348
+ //#endregion
349
+ //#region src/utils/squashSourceNodes.ts
350
+ function squashSourceNodes(node, ignores) {
351
+ let sources = /* @__PURE__ */ new Set();
352
+ for (const childNode of node.childNodes) {
353
+ if (!childNode) continue;
354
+ if (childNode.nodeName !== "#text" && ignores.includes(childNode.nodeName)) continue;
355
+ if (childNode.nodeName === "kubb-source") {
356
+ const attributes = childNode.attributes;
357
+ const value = squashTextNodes(childNode);
358
+ sources.add({
359
+ ...attributes,
360
+ value: value.trim().replace(/^\s+|\s+$/g, "")
361
+ });
362
+ continue;
363
+ }
364
+ if (childNode.nodeName !== "#text" && nodeNames.includes(childNode.nodeName)) sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)]);
365
+ }
366
+ return sources;
367
+ }
368
+
369
+ //#endregion
370
+ //#region src/utils/processFiles.ts
371
+ function processFiles(node, fileManager) {
372
+ for (let index = 0; index < node.childNodes.length; index++) {
373
+ const childNode = node.childNodes[index];
374
+ if (!childNode) continue;
375
+ if (childNode.nodeName !== "#text" && childNode.nodeName !== "kubb-file" && nodeNames.includes(childNode.nodeName)) processFiles(childNode, fileManager);
376
+ if (childNode.nodeName === "kubb-file") {
377
+ const attributes = childNode.attributes;
378
+ if (attributes.baseName && attributes.path) {
379
+ const sources = squashSourceNodes(childNode, ["kubb-export", "kubb-import"]);
380
+ const file = {
381
+ baseName: attributes.baseName,
382
+ path: attributes.path,
383
+ sources: [...sources],
384
+ exports: [...squashExportNodes(childNode)],
385
+ imports: [...squashImportNodes(childNode)],
386
+ meta: attributes.meta || {},
387
+ footer: attributes.footer,
388
+ banner: attributes.banner
389
+ };
390
+ fileManager.add(file);
391
+ }
392
+ }
393
+ }
394
+ }
395
+
396
+ //#endregion
397
+ //#region \0@oxc-project+runtime@0.95.0/helpers/checkPrivateRedeclaration.js
398
+ function _checkPrivateRedeclaration(e, t) {
399
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
400
+ }
401
+
402
+ //#endregion
403
+ //#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateMethodInitSpec.js
404
+ function _classPrivateMethodInitSpec(e, a) {
405
+ _checkPrivateRedeclaration(e, a), a.add(e);
406
+ }
407
+
408
+ //#endregion
409
+ //#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateFieldInitSpec.js
410
+ function _classPrivateFieldInitSpec(e, t, a) {
411
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
412
+ }
413
+
414
+ //#endregion
415
+ //#region \0@oxc-project+runtime@0.95.0/helpers/assertClassBrand.js
416
+ function _assertClassBrand(e, t, n) {
417
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
418
+ throw new TypeError("Private element is not present on this object");
419
+ }
420
+
421
+ //#endregion
422
+ //#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateFieldGet2.js
423
+ function _classPrivateFieldGet2(s, a) {
424
+ return s.get(_assertClassBrand(s, a));
425
+ }
426
+
427
+ //#endregion
428
+ //#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateFieldSet2.js
429
+ function _classPrivateFieldSet2(s, a, r) {
430
+ return s.set(_assertClassBrand(s, a), r), r;
431
+ }
432
+
433
+ //#endregion
434
+ //#region src/Runtime.tsx
435
+ var _options = /* @__PURE__ */ new WeakMap();
436
+ var _isUnmounted = /* @__PURE__ */ new WeakMap();
437
+ var _container = /* @__PURE__ */ new WeakMap();
438
+ var _rootNode = /* @__PURE__ */ new WeakMap();
439
+ var _Runtime_brand = /* @__PURE__ */ new WeakSet();
440
+ var Runtime = class {
441
+ constructor(options) {
442
+ _classPrivateMethodInitSpec(this, _Runtime_brand);
443
+ _classPrivateFieldInitSpec(this, _options, void 0);
444
+ _classPrivateFieldInitSpec(this, _isUnmounted, void 0);
445
+ _defineProperty(this, "exitPromise", void 0);
446
+ _classPrivateFieldInitSpec(this, _container, void 0);
447
+ _classPrivateFieldInitSpec(this, _rootNode, void 0);
448
+ _defineProperty(this, "resolveExitPromise", () => {});
449
+ _defineProperty(this, "rejectExitPromise", () => {});
450
+ _defineProperty(this, "unsubscribeExit", () => {});
451
+ _defineProperty(this, "onRender", async () => {
452
+ var _classPrivateFieldGet2$1, _classPrivateFieldGet3, _classPrivateFieldGet4, _classPrivateFieldGet5;
453
+ if (_classPrivateFieldGet2(_isUnmounted, this)) return;
454
+ this.fileManager.clear();
455
+ processFiles(_classPrivateFieldGet2(_rootNode, this), this.fileManager);
456
+ if (!((_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.debug) && !((_classPrivateFieldGet3 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.stdout)) return;
457
+ const output = await _assertClassBrand(_Runtime_brand, this, _getOutput).call(this, _classPrivateFieldGet2(_rootNode, this));
458
+ if ((_classPrivateFieldGet4 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.debug) {
459
+ console.log("Rendering: \n");
460
+ console.log(output);
461
+ }
462
+ if (((_classPrivateFieldGet5 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.stdout) && process.env.NODE_ENV !== "test") {
463
+ _classPrivateFieldGet2(_options, this).stdout.clearLine(0);
464
+ _classPrivateFieldGet2(_options, this).stdout.cursorTo(0);
465
+ _classPrivateFieldGet2(_options, this).stdout.write(output);
466
+ }
467
+ });
468
+ _classPrivateFieldSet2(_options, this, options);
469
+ _classPrivateFieldSet2(_rootNode, this, createNode("kubb-root"));
470
+ _classPrivateFieldGet2(_rootNode, this).onRender = this.onRender;
471
+ _classPrivateFieldGet2(_rootNode, this).onImmediateRender = this.onRender;
472
+ _classPrivateFieldSet2(_isUnmounted, this, false);
473
+ this.unmount.bind(this);
474
+ const originalError = console.error;
475
+ console.error = (data) => {
476
+ const message = typeof data === "string" ? data : data === null || data === void 0 ? void 0 : data.message;
477
+ if (message === null || message === void 0 ? void 0 : message.match(/Encountered two children with the same key/gi)) return;
478
+ if (message === null || message === void 0 ? void 0 : message.match(/React will try to recreat/gi)) return;
479
+ if (message === null || message === void 0 ? void 0 : message.match(/Each child in a list should have a unique/gi)) return;
480
+ if (message === null || message === void 0 ? void 0 : message.match(/The above error occurred in the <KubbErrorBoundary/gi)) return;
481
+ if (message === null || message === void 0 ? void 0 : message.match(/A React Element from an older version of React was render/gi)) return;
482
+ originalError(data);
483
+ };
484
+ const logRecoverableError = typeof reportError === "function" ? reportError : console.error;
485
+ const rootTag = ConcurrentRoot;
486
+ const hydrationCallbacks = null;
487
+ const isStrictMode = false;
488
+ const concurrentUpdatesByDefaultOverride = false;
489
+ const identifierPrefix = "id";
490
+ const onUncaughtError = logRecoverableError;
491
+ const onCaughtError = logRecoverableError;
492
+ const onRecoverableError = logRecoverableError;
493
+ _classPrivateFieldSet2(_container, this, Renderer.createContainer(_classPrivateFieldGet2(_rootNode, this), rootTag, hydrationCallbacks, isStrictMode, concurrentUpdatesByDefaultOverride, identifierPrefix, onUncaughtError, onCaughtError, onRecoverableError, null));
494
+ this.unsubscribeExit = onExit((code) => {
495
+ this.unmount(code);
496
+ }, { alwaysLast: false }).bind(this);
497
+ Renderer.injectIntoDevTools({
498
+ bundleType: 1,
499
+ version: "19.1.0",
500
+ rendererPackageName: "kubb"
501
+ });
502
+ }
503
+ get fileManager() {
504
+ return _classPrivateFieldGet2(_options, this).fileManager;
505
+ }
506
+ onError(error) {
507
+ if (process.env.NODE_ENV === "test") console.warn(error);
508
+ throw error;
509
+ }
510
+ onExit(error) {
511
+ this.unmount(error);
512
+ }
513
+ render(node) {
514
+ const element = /* @__PURE__ */ jsx(Root, {
515
+ onExit: this.onExit.bind(this),
516
+ onError: this.onError.bind(this),
517
+ children: node
518
+ });
519
+ Renderer.updateContainerSync(element, _classPrivateFieldGet2(_container, this), null, null);
520
+ Renderer.flushSyncWork();
521
+ }
522
+ async renderToString(node) {
523
+ const element = /* @__PURE__ */ jsx(Root, {
524
+ onExit: this.onExit.bind(this),
525
+ onError: this.onError.bind(this),
526
+ children: node
527
+ });
528
+ Renderer.updateContainerSync(element, _classPrivateFieldGet2(_container, this), null, null);
529
+ Renderer.flushSyncWork();
530
+ this.fileManager.clear();
531
+ return _assertClassBrand(_Runtime_brand, this, _getOutput).call(this, _classPrivateFieldGet2(_rootNode, this));
532
+ }
533
+ unmount(error) {
534
+ var _classPrivateFieldGet6;
535
+ if (_classPrivateFieldGet2(_isUnmounted, this)) return;
536
+ if ((_classPrivateFieldGet6 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet6 === void 0 ? void 0 : _classPrivateFieldGet6.debug) console.log("Unmount", error);
537
+ this.onRender();
538
+ this.unsubscribeExit();
539
+ _classPrivateFieldSet2(_isUnmounted, this, true);
540
+ Renderer.updateContainerSync(null, _classPrivateFieldGet2(_container, this), null, null);
541
+ if (error instanceof Error) {
542
+ this.rejectExitPromise(error);
543
+ return;
544
+ }
545
+ this.resolveExitPromise();
546
+ }
547
+ async waitUntilExit() {
548
+ if (!this.exitPromise) this.exitPromise = new Promise((resolve, reject) => {
549
+ this.resolveExitPromise = resolve;
550
+ this.rejectExitPromise = reject;
551
+ });
552
+ return this.exitPromise;
553
+ }
554
+ };
555
+ async function _getOutput(node) {
556
+ const text = squashTextNodes(node);
557
+ const files = this.fileManager.files;
558
+ return files.length ? [...files].flatMap((file) => [...file.sources].map((item) => item.value)).filter(Boolean).join("\n\n") : text;
559
+ }
560
+
561
+ //#endregion
562
+ //#region src/plugins/reactPlugin.ts
563
+ const reactPlugin = createPlugin({
564
+ name: "react",
565
+ install() {},
566
+ inject(app, options = {}) {
567
+ const runtime = new Runtime({
568
+ fileManager: app.context.fileManager,
569
+ ...options
570
+ });
571
+ return {
572
+ async render(App) {
573
+ runtime.render(createElement(App));
574
+ await app.context.events.emit("start");
575
+ },
576
+ async renderToString(App) {
577
+ await app.context.events.emit("start");
578
+ return runtime.renderToString(createElement(App));
579
+ },
580
+ async waitUntilExit() {
581
+ await runtime.waitUntilExit();
582
+ await app.context.events.emit("end");
583
+ }
584
+ };
585
+ }
586
+ });
587
+
588
+ //#endregion
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-DYBs1Uhp.js.map