securityos/node_modules/@monaco-editor/react/dist/index.mjs.map

1 line
31 KiB
Plaintext
Raw Permalink Normal View History

2024-09-06 15:32:35 +00:00
{"version":3,"sources":["../src/index.ts","../src/DiffEditor/index.ts","../src/DiffEditor/DiffEditor.tsx","../src/MonacoContainer/index.ts","../src/MonacoContainer/MonacoContainer.tsx","../src/MonacoContainer/styles.ts","../src/Loading/Loading.tsx","../src/Loading/styles.ts","../src/Loading/index.ts","../src/hooks/useMount/index.ts","../src/hooks/useUpdate/index.ts","../src/utils/index.ts","../src/hooks/useMonaco/index.ts","../src/Editor/index.ts","../src/Editor/Editor.tsx","../src/hooks/usePrevious/index.ts"],"sourcesContent":["import loader from '@monaco-editor/loader';\nexport { loader };\n\nimport DiffEditor from './DiffEditor';\nexport * from './DiffEditor/types';\nexport { DiffEditor };\n\nimport useMonaco from './hooks/useMonaco';\nexport { useMonaco };\n\nimport Editor from './Editor';\nexport * from './Editor/types';\nexport { Editor };\nexport default Editor;\n\n// Monaco\nimport type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';\nexport type Monaco = typeof monaco;\n\n// Default themes\nexport type Theme = 'vs-dark' | 'light';\n","import { memo } from 'react';\n\nimport DiffEditor from './DiffEditor';\n\nexport * from './types';\n\nexport default memo(DiffEditor);\n","'use client';\n\nimport React, { useState, useRef, useCallback, useEffect } from 'react';\nimport loader from '@monaco-editor/loader';\n\nimport MonacoContainer from '../MonacoContainer';\nimport useMount from '../hooks/useMount';\nimport useUpdate from '../hooks/useUpdate';\nimport { noop, getOrCreateModel } from '../utils';\nimport { type DiffEditorProps, type MonacoDiffEditor } from './types';\nimport { type Monaco } from '..';\n\nfunction DiffEditor({\n original,\n modified,\n language,\n originalLanguage,\n modifiedLanguage,\n originalModelPath,\n modifiedModelPath,\n keepCurrentOriginalModel = false,\n keepCurrentModifiedModel = false,\n theme = 'light',\n loading = 'Loading...',\n options = {},\n height = '100%',\n width = '100%',\n className,\n wrapperProps = {},\n beforeMount = noop,\n onMount = noop,\n}: DiffEditorProps) {\n const [isEditorReady, setIsEditorReady] = useState(false);\n const [isMonacoMounting, setIsMonacoMounting] = useState(true);\n const editorRef = useRef<MonacoDiffEditor | null>(null);\n const monacoRef = useRef<Monaco | null>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const onMountRef = useRef(onMount);\n const beforeMountRef = useRef(beforeMount);\n const preventCreation = useRef(false);\n\n useMount(() => {\n const cancelable = loader.init();\n\n cancelable\n .then((monaco) => (monacoRef.current = monaco) && setIsMonacoMounting(false))\n .catch(\n (error) =>\n error?.type !== 'cancelation' && console.error('Monaco initialization: error:', error),\n );\n\n return () => (editorRef.current ? disposeEditor() : cancelable.cancel());\n });\n\n useUpdate(\n () => {\n if (editorRef.current && monacoRef.current) {\n const originalEditor = editorRef.current.getOriginalEditor();\n const model = getOrCreateModel(\n monacoRef.current,\n original || '',\n originalLanguage || language || 'text',\n originalModelPath || '',\n );\n\n if (model !== originalEditor.getModel()) {\n originalEditor.setModel(model);\n }\n }\n },\n [originalModelPath],\n isEditorReady,\n );\n\n useUpdate(\n () => {\n if (editorRef.current && monacoRef.current) {\n const modifiedEditor = editorRef.current.getModifiedEditor();\n const model = getOrCreateModel(\n monacoRef.current,\n modified || '',\n modifiedLanguage || language || 'text',\n modifiedModelPath || '',\n );\n\n if (model !== modifiedEditor.getModel()) {\n modifiedEditor.setModel(model);\n }\n }\n },\n [modifiedModelPath],\n isEditorReady,\n );\n\n useUpdate(\n () => {\n const modifiedEditor = editorRef.current!.getModifiedEditor();\n if (modifiedEditor.getOption(monacoRef.curre