@l1yp/file-viewer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/dist/FileViewer.js +7 -0
- package/dist/FileViewer.vue.d.ts +37 -0
- package/dist/FileViewer.vue_vue_type_script_setup_true_lang.js +103 -0
- package/dist/_virtual/_plugin-vue_export-helper.js +8 -0
- package/dist/components/AppxViewer.js +7 -0
- package/dist/components/AppxViewer.vue.d.ts +18 -0
- package/dist/components/AppxViewer.vue_vue_type_script_setup_true_lang.js +174 -0
- package/dist/components/ArchiveBrowser.js +7 -0
- package/dist/components/ArchiveBrowser.vue.d.ts +18 -0
- package/dist/components/ArchiveBrowser.vue_vue_type_script_setup_true_lang.js +279 -0
- package/dist/components/AudioViewer.js +7 -0
- package/dist/components/AudioViewer.vue.d.ts +21 -0
- package/dist/components/AudioViewer.vue_vue_type_script_setup_true_lang.js +201 -0
- package/dist/components/BinObjBrowser.js +7 -0
- package/dist/components/BinObjBrowser.vue.d.ts +19 -0
- package/dist/components/BinObjBrowser.vue_vue_type_script_setup_true_lang.js +141 -0
- package/dist/components/CertViewer.js +7 -0
- package/dist/components/CertViewer.vue.d.ts +17 -0
- package/dist/components/CertViewer.vue_vue_type_script_setup_true_lang.js +251 -0
- package/dist/components/ClassViewer.js +7 -0
- package/dist/components/ClassViewer.vue.d.ts +15 -0
- package/dist/components/ClassViewer.vue_vue_type_script_setup_true_lang.js +164 -0
- package/dist/components/CodeBlock.js +7 -0
- package/dist/components/CodeBlock.vue.d.ts +17 -0
- package/dist/components/CodeBlock.vue_vue_type_script_setup_true_lang.js +79 -0
- package/dist/components/CodeView.js +7 -0
- package/dist/components/CodeView.vue.d.ts +21 -0
- package/dist/components/CodeView.vue_vue_type_script_setup_true_lang.js +180 -0
- package/dist/components/CsvViewer.js +7 -0
- package/dist/components/CsvViewer.vue.d.ts +26 -0
- package/dist/components/CsvViewer.vue_vue_type_script_setup_true_lang.js +187 -0
- package/dist/components/DicomViewer.js +7 -0
- package/dist/components/DicomViewer.vue.d.ts +30 -0
- package/dist/components/DicomViewer.vue_vue_type_script_setup_true_lang.js +362 -0
- package/dist/components/DocxViewer.js +7 -0
- package/dist/components/DocxViewer.vue.d.ts +19 -0
- package/dist/components/DocxViewer.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/components/DrawioViewer.js +7 -0
- package/dist/components/DrawioViewer.vue.d.ts +16 -0
- package/dist/components/DrawioViewer.vue_vue_type_script_setup_true_lang.js +38 -0
- package/dist/components/DxfViewer.js +7 -0
- package/dist/components/DxfViewer.vue.d.ts +14 -0
- package/dist/components/DxfViewer.vue_vue_type_script_setup_true_lang.js +239 -0
- package/dist/components/EbookViewer.js +7 -0
- package/dist/components/EbookViewer.vue.d.ts +22 -0
- package/dist/components/EbookViewer.vue_vue_type_script_setup_true_lang.js +170 -0
- package/dist/components/EmlViewer.js +7 -0
- package/dist/components/EmlViewer.vue.d.ts +21 -0
- package/dist/components/EmlViewer.vue_vue_type_script_setup_true_lang.js +193 -0
- package/dist/components/EplViewer.js +7 -0
- package/dist/components/EplViewer.vue.d.ts +19 -0
- package/dist/components/EplViewer.vue_vue_type_script_setup_true_lang.js +201 -0
- package/dist/components/FileViewerBody.js +7 -0
- package/dist/components/FileViewerBody.vue.d.ts +47 -0
- package/dist/components/FileViewerBody.vue_vue_type_script_setup_true_lang.js +599 -0
- package/dist/components/FileViewerPanel.js +7 -0
- package/dist/components/FileViewerPanel.vue.d.ts +3 -0
- package/dist/components/FileViewerPanel.vue_vue_type_script_setup_true_lang.js +207 -0
- package/dist/components/FontViewer.js +7 -0
- package/dist/components/FontViewer.vue.d.ts +17 -0
- package/dist/components/FontViewer.vue_vue_type_script_setup_true_lang.js +120 -0
- package/dist/components/FrontmatterCard.js +7 -0
- package/dist/components/FrontmatterCard.vue.d.ts +11 -0
- package/dist/components/FrontmatterCard.vue_vue_type_script_setup_true_lang.js +30 -0
- package/dist/components/GeoViewer.js +7 -0
- package/dist/components/GeoViewer.vue.d.ts +17 -0
- package/dist/components/GeoViewer.vue_vue_type_script_setup_true_lang.js +255 -0
- package/dist/components/HarViewer.js +7 -0
- package/dist/components/HarViewer.vue.d.ts +20 -0
- package/dist/components/HarViewer.vue_vue_type_script_setup_true_lang.js +322 -0
- package/dist/components/HexViewer.js +7 -0
- package/dist/components/HexViewer.vue.d.ts +22 -0
- package/dist/components/HexViewer.vue_vue_type_script_setup_true_lang.js +121 -0
- package/dist/components/HprofViewer.js +7 -0
- package/dist/components/HprofViewer.vue.d.ts +27 -0
- package/dist/components/HprofViewer.vue_vue_type_script_setup_true_lang.js +561 -0
- package/dist/components/ImageLightbox.js +7 -0
- package/dist/components/ImageLightbox.vue.d.ts +3 -0
- package/dist/components/ImageLightbox.vue_vue_type_script_setup_true_lang.js +86 -0
- package/dist/components/InlineText.d.ts +29 -0
- package/dist/components/InlineText.js +21 -0
- package/dist/components/JksViewer.js +7 -0
- package/dist/components/JksViewer.vue.d.ts +22 -0
- package/dist/components/JksViewer.vue_vue_type_script_setup_true_lang.js +353 -0
- package/dist/components/JsonlViewer.js +7 -0
- package/dist/components/JsonlViewer.vue.d.ts +15 -0
- package/dist/components/JsonlViewer.vue_vue_type_script_setup_true_lang.js +103 -0
- package/dist/components/LogViewer.js +7 -0
- package/dist/components/LogViewer.vue.d.ts +29 -0
- package/dist/components/LogViewer.vue_vue_type_script_setup_true_lang.js +670 -0
- package/dist/components/LrcViewer.js +7 -0
- package/dist/components/LrcViewer.vue.d.ts +17 -0
- package/dist/components/LrcViewer.vue_vue_type_script_setup_true_lang.js +106 -0
- package/dist/components/MarkdownTable.js +7 -0
- package/dist/components/MarkdownTable.vue.d.ts +19 -0
- package/dist/components/MarkdownTable.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/components/MarkdownText.d.ts +30 -0
- package/dist/components/MarkdownText.js +21 -0
- package/dist/components/MhtViewer.js +7 -0
- package/dist/components/MhtViewer.vue.d.ts +22 -0
- package/dist/components/MhtViewer.vue_vue_type_script_setup_true_lang.js +112 -0
- package/dist/components/MindMapView.js +7 -0
- package/dist/components/MindMapView.vue.d.ts +23 -0
- package/dist/components/MindMapView.vue_vue_type_script_setup_true_lang.js +337 -0
- package/dist/components/MissingDependency.js +7 -0
- package/dist/components/MissingDependency.vue.d.ts +17 -0
- package/dist/components/MissingDependency.vue_vue_type_script_setup_true_lang.js +37 -0
- package/dist/components/ModelViewer.js +7 -0
- package/dist/components/ModelViewer.vue.d.ts +18 -0
- package/dist/components/ModelViewer.vue_vue_type_script_setup_true_lang.js +157 -0
- package/dist/components/MsiViewer.js +7 -0
- package/dist/components/MsiViewer.vue.d.ts +19 -0
- package/dist/components/MsiViewer.vue_vue_type_script_setup_true_lang.js +136 -0
- package/dist/components/NotebookViewer.js +7 -0
- package/dist/components/NotebookViewer.vue.d.ts +20 -0
- package/dist/components/NotebookViewer.vue_vue_type_script_setup_true_lang.js +125 -0
- package/dist/components/PdfViewer.js +7 -0
- package/dist/components/PdfViewer.vue.d.ts +19 -0
- package/dist/components/PdfViewer.vue_vue_type_script_setup_true_lang.js +114 -0
- package/dist/components/PptxViewer.js +7 -0
- package/dist/components/PptxViewer.vue.d.ts +20 -0
- package/dist/components/PptxViewer.vue_vue_type_script_setup_true_lang.js +73 -0
- package/dist/components/PsdViewer.js +7 -0
- package/dist/components/PsdViewer.vue.d.ts +15 -0
- package/dist/components/PsdViewer.vue_vue_type_script_setup_true_lang.js +218 -0
- package/dist/components/QmcAudioViewer.js +7 -0
- package/dist/components/QmcAudioViewer.vue.d.ts +18 -0
- package/dist/components/QmcAudioViewer.vue_vue_type_script_setup_true_lang.js +92 -0
- package/dist/components/RasterViewer.js +7 -0
- package/dist/components/RasterViewer.vue.d.ts +21 -0
- package/dist/components/RasterViewer.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/components/RtfViewer.js +7 -0
- package/dist/components/RtfViewer.vue.d.ts +21 -0
- package/dist/components/RtfViewer.vue_vue_type_script_setup_true_lang.js +66 -0
- package/dist/components/SevenZipBrowser.js +7 -0
- package/dist/components/SevenZipBrowser.vue.d.ts +13 -0
- package/dist/components/SevenZipBrowser.vue_vue_type_script_setup_true_lang.js +366 -0
- package/dist/components/SqliteViewer.js +7 -0
- package/dist/components/SqliteViewer.vue.d.ts +18 -0
- package/dist/components/SqliteViewer.vue_vue_type_script_setup_true_lang.js +186 -0
- package/dist/components/SubtitleViewer.js +7 -0
- package/dist/components/SubtitleViewer.vue.d.ts +15 -0
- package/dist/components/SubtitleViewer.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/XlsxChart.js +7 -0
- package/dist/components/XlsxChart.vue.d.ts +14 -0
- package/dist/components/XlsxChart.vue_vue_type_script_setup_true_lang.js +240 -0
- package/dist/components/XlsxViewer.js +7 -0
- package/dist/components/XlsxViewer.vue.d.ts +22 -0
- package/dist/components/XlsxViewer.vue_vue_type_script_setup_true_lang.js +814 -0
- package/dist/components/XmindViewer.js +7 -0
- package/dist/components/XmindViewer.vue.d.ts +13 -0
- package/dist/components/XmindViewer.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/components/ZipBrowser.js +7 -0
- package/dist/components/ZipBrowser.vue.d.ts +14 -0
- package/dist/components/ZipBrowser.vue_vue_type_script_setup_true_lang.js +326 -0
- package/dist/components/ZoomImage.js +7 -0
- package/dist/components/ZoomImage.vue.d.ts +29 -0
- package/dist/components/ZoomImage.vue_vue_type_script_setup_true_lang.js +147 -0
- package/dist/components/epl/EplCodeBlock.js +7 -0
- package/dist/components/epl/EplCodeBlock.vue.d.ts +15 -0
- package/dist/components/epl/EplCodeBlock.vue_vue_type_script_setup_true_lang.js +72 -0
- package/dist/components/epl/EplDoc.js +7 -0
- package/dist/components/epl/EplDoc.vue.d.ts +19 -0
- package/dist/components/epl/EplDoc.vue_vue_type_script_setup_true_lang.js +327 -0
- package/dist/components/epl/EplMethod.js +7 -0
- package/dist/components/epl/EplMethod.vue.d.ts +14 -0
- package/dist/components/epl/EplMethod.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/components/epl/EplResource.js +7 -0
- package/dist/components/epl/EplResource.vue.d.ts +15 -0
- package/dist/components/epl/EplResource.vue_vue_type_script_setup_true_lang.js +204 -0
- package/dist/components/epl/EplTree.js +7 -0
- package/dist/components/epl/EplTree.vue.d.ts +27 -0
- package/dist/components/epl/EplTree.vue_vue_type_script_setup_true_lang.js +123 -0
- package/dist/components/epl/EplVarTable.js +7 -0
- package/dist/components/epl/EplVarTable.vue.d.ts +21 -0
- package/dist/components/epl/EplVarTable.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/components/epl/docTypes.d.ts +12 -0
- package/dist/components/epl/numbering.d.ts +21 -0
- package/dist/components/epl/numbering.js +14 -0
- package/dist/components/icons/Icon.js +7 -0
- package/dist/components/icons/Icon.vue.d.ts +14 -0
- package/dist/components/icons/Icon.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/components/icons/iconPaths.d.ts +60 -0
- package/dist/components/icons/iconPaths.js +54 -0
- package/dist/components/optionalViewer.d.ts +14 -0
- package/dist/components/optionalViewer.js +37 -0
- package/dist/components/ui/ClampBlock.d.ts +82 -0
- package/dist/components/ui/ClampBlock.js +63 -0
- package/dist/composables/useFileViewer.d.ts +428 -0
- package/dist/composables/useFileViewer.js +27 -0
- package/dist/composables/useLightbox.d.ts +33 -0
- package/dist/composables/useLightbox.js +17 -0
- package/dist/composables/useLogRules.d.ts +47 -0
- package/dist/composables/useLogRules.js +74 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +30 -0
- package/dist/lib/aes.d.ts +25 -0
- package/dist/lib/aes.js +99 -0
- package/dist/lib/appx.d.ts +66 -0
- package/dist/lib/appx.js +112 -0
- package/dist/lib/archive.d.ts +29 -0
- package/dist/lib/asn1.d.ts +47 -0
- package/dist/lib/asn1.js +122 -0
- package/dist/lib/binobj.d.ts +69 -0
- package/dist/lib/binobj.js +430 -0
- package/dist/lib/brotli.d.ts +14 -0
- package/dist/lib/brotli.js +16 -0
- package/dist/lib/bzip2.d.ts +14 -0
- package/dist/lib/bzip2.js +161 -0
- package/dist/lib/classfile.d.ts +72 -0
- package/dist/lib/classfile.js +210 -0
- package/dist/lib/codePreview.d.ts +22 -0
- package/dist/lib/codePreview.js +27 -0
- package/dist/lib/codefold.d.ts +14 -0
- package/dist/lib/codefold.js +30 -0
- package/dist/lib/codeformat.d.ts +21 -0
- package/dist/lib/codeformat.js +130 -0
- package/dist/lib/csv.d.ts +19 -0
- package/dist/lib/csv.js +74 -0
- package/dist/lib/des.d.ts +17 -0
- package/dist/lib/des.js +928 -0
- package/dist/lib/diagram.d.ts +5 -0
- package/dist/lib/diagram.js +479 -0
- package/dist/lib/dicom.d.ts +69 -0
- package/dist/lib/dicom.js +442 -0
- package/dist/lib/dicomCodecs.d.ts +28 -0
- package/dist/lib/dicomCodecs.js +156 -0
- package/dist/lib/dicomRender.d.ts +46 -0
- package/dist/lib/dicomRender.js +114 -0
- package/dist/lib/dxf.d.ts +86 -0
- package/dist/lib/dxf.js +399 -0
- package/dist/lib/eml.d.ts +40 -0
- package/dist/lib/eml.js +46 -0
- package/dist/lib/encoding.d.ts +28 -0
- package/dist/lib/encoding.js +44 -0
- package/dist/lib/epl/code/ast.d.ts +150 -0
- package/dist/lib/epl/code/codeDataParser.d.ts +3 -0
- package/dist/lib/epl/code/codeDataParser.js +330 -0
- package/dist/lib/epl/code/codeLines.d.ts +20 -0
- package/dist/lib/epl/code/codeLines.js +191 -0
- package/dist/lib/epl/code/structures.d.ts +86 -0
- package/dist/lib/epl/code/textCode.d.ts +29 -0
- package/dist/lib/epl/code/textCode.js +150 -0
- package/dist/lib/epl/code/variable.d.ts +25 -0
- package/dist/lib/epl/eplDocument.d.ts +21 -0
- package/dist/lib/epl/eplDocument.js +36 -0
- package/dist/lib/epl/imageList.d.ts +28 -0
- package/dist/lib/epl/imageList.js +66 -0
- package/dist/lib/epl/index.d.ts +53 -0
- package/dist/lib/epl/index.js +45 -0
- package/dist/lib/epl/io/binaryReader.d.ts +56 -0
- package/dist/lib/epl/io/binaryReader.js +119 -0
- package/dist/lib/epl/io/encoding.d.ts +16 -0
- package/dist/lib/epl/io/encoding.js +27 -0
- package/dist/lib/epl/model/eplSystemId.d.ts +64 -0
- package/dist/lib/epl/model/eplSystemId.js +16 -0
- package/dist/lib/epl/model/section.d.ts +46 -0
- package/dist/lib/epl/names/eplLibData.js +39 -0
- package/dist/lib/epl/names/idToNameMap.d.ts +33 -0
- package/dist/lib/epl/names/idToNameMap.js +130 -0
- package/dist/lib/epl/names/libNameProvider.d.ts +15 -0
- package/dist/lib/epl/names/libNameProvider.js +18 -0
- package/dist/lib/epl/program.d.ts +120 -0
- package/dist/lib/epl/program.js +134 -0
- package/dist/lib/epl/projectFileReader.d.ts +23 -0
- package/dist/lib/epl/projectFileReader.js +65 -0
- package/dist/lib/epl/sections/code.d.ts +20 -0
- package/dist/lib/epl/sections/esystemInfo.d.ts +14 -0
- package/dist/lib/epl/sections/losable.d.ts +11 -0
- package/dist/lib/epl/sections/projectConfig.d.ts +23 -0
- package/dist/lib/epl/sections/resource.d.ts +57 -0
- package/dist/lib/fb2.d.ts +14 -0
- package/dist/lib/fb2.js +62 -0
- package/dist/lib/fileType.d.ts +315 -0
- package/dist/lib/fileType.js +800 -0
- package/dist/lib/fonts.d.ts +8 -0
- package/dist/lib/fonts.js +4 -0
- package/dist/lib/format.d.ts +16 -0
- package/dist/lib/format.js +38 -0
- package/dist/lib/frontmatter.d.ts +13 -0
- package/dist/lib/frontmatter.js +23 -0
- package/dist/lib/geo.d.ts +30 -0
- package/dist/lib/geo.js +235 -0
- package/dist/lib/har.d.ts +171 -0
- package/dist/lib/har.js +397 -0
- package/dist/lib/highlight.d.ts +18 -0
- package/dist/lib/highlight.js +34 -0
- package/dist/lib/highlightLangs.d.ts +15 -0
- package/dist/lib/highlightLangs.js +93 -0
- package/dist/lib/hprof.d.ts +211 -0
- package/dist/lib/hprof.js +709 -0
- package/dist/lib/ipynb.d.ts +48 -0
- package/dist/lib/ipynb.js +130 -0
- package/dist/lib/jks.d.ts +86 -0
- package/dist/lib/jks.js +167 -0
- package/dist/lib/jsonl.d.ts +29 -0
- package/dist/lib/jsonl.js +24 -0
- package/dist/lib/lrc.d.ts +32 -0
- package/dist/lib/lrc.js +84 -0
- package/dist/lib/lzma.d.ts +70 -0
- package/dist/lib/lzma.js +204 -0
- package/dist/lib/markdown/blocks.d.ts +9 -0
- package/dist/lib/markdown/blocks.js +221 -0
- package/dist/lib/markdown/index.d.ts +3 -0
- package/dist/lib/markdown/inline.d.ts +33 -0
- package/dist/lib/markdown/inline.js +84 -0
- package/dist/lib/markdown/math.d.ts +5 -0
- package/dist/lib/markdown/math.js +25 -0
- package/dist/lib/markdown/segmentize.d.ts +11 -0
- package/dist/lib/markdown/segmentize.js +28 -0
- package/dist/lib/markdown/styles.d.ts +26 -0
- package/dist/lib/markdown/styles.js +135 -0
- package/dist/lib/mht.d.ts +51 -0
- package/dist/lib/mht.js +122 -0
- package/dist/lib/midi.d.ts +28 -0
- package/dist/lib/midi.js +84 -0
- package/dist/lib/mime.d.ts +82 -0
- package/dist/lib/mime.js +151 -0
- package/dist/lib/mindmap.d.ts +51 -0
- package/dist/lib/mindmap.js +113 -0
- package/dist/lib/mobi.d.ts +15 -0
- package/dist/lib/mobi.js +68 -0
- package/dist/lib/msi.d.ts +50 -0
- package/dist/lib/msi.js +332 -0
- package/dist/lib/optionalDep.d.ts +26 -0
- package/dist/lib/optionalDep.js +20 -0
- package/dist/lib/pkcs12.d.ts +56 -0
- package/dist/lib/pkcs12.js +356 -0
- package/dist/lib/qmc.d.ts +50 -0
- package/dist/lib/qmc.js +213 -0
- package/dist/lib/rar.d.ts +16 -0
- package/dist/lib/rar.js +40 -0
- package/dist/lib/rawPreview.d.ts +12 -0
- package/dist/lib/rawPreview.js +54 -0
- package/dist/lib/rc2.d.ts +12 -0
- package/dist/lib/rc2.js +298 -0
- package/dist/lib/resolveInput.d.ts +22 -0
- package/dist/lib/resolveInput.js +55 -0
- package/dist/lib/rtf.d.ts +53 -0
- package/dist/lib/rtf.js +413 -0
- package/dist/lib/sevenZip.d.ts +82 -0
- package/dist/lib/sevenZip.js +395 -0
- package/dist/lib/sha1.d.ts +24 -0
- package/dist/lib/sha1.js +53 -0
- package/dist/lib/sha256.d.ts +21 -0
- package/dist/lib/sha256.js +119 -0
- package/dist/lib/speechAudio.d.ts +36 -0
- package/dist/lib/speechAudio.js +85 -0
- package/dist/lib/sqlite.d.ts +38 -0
- package/dist/lib/sqlite.js +104 -0
- package/dist/lib/subtitle.d.ts +26 -0
- package/dist/lib/subtitle.js +99 -0
- package/dist/lib/tarball.d.ts +20 -0
- package/dist/lib/tarball.js +248 -0
- package/dist/lib/viewerFormats.d.ts +35 -0
- package/dist/lib/viewerFormats.js +83 -0
- package/dist/lib/viewerKind.d.ts +36 -0
- package/dist/lib/viewerKind.js +233 -0
- package/dist/lib/x509.d.ts +68 -0
- package/dist/lib/x509.js +267 -0
- package/dist/lib/xlsx.d.ts +55 -0
- package/dist/lib/xlsx.js +321 -0
- package/dist/lib/xlsxCharts.d.ts +34 -0
- package/dist/lib/xlsxCharts.js +152 -0
- package/dist/lib/xmind.d.ts +6 -0
- package/dist/lib/xmind.js +124 -0
- package/dist/lib/zip.d.ts +56 -0
- package/dist/lib/zip.js +169 -0
- package/dist/style.css +2 -0
- package/dist/types.d.ts +42 -0
- package/package.json +128 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand-rolled, zero-dependency Jupyter Notebook (.ipynb) parser for the side viewer.
|
|
3
|
+
*
|
|
4
|
+
* A notebook is JSON: a list of cells (markdown / code / raw), each code cell carrying its outputs. This
|
|
5
|
+
* flattens that into a render-ready shape the viewer can walk — markdown reuses the app's markdown engine,
|
|
6
|
+
* code reuses highlight.js, and each output is reduced to one best-fit representation (richest mime wins,
|
|
7
|
+
* mirroring Jupyter's own display priority). nbformat 4 is the target; v3 (worksheets + inline output keys)
|
|
8
|
+
* is tolerated as a best-effort fallback.
|
|
9
|
+
*
|
|
10
|
+
* Rich HTML output is hostile markup (it comes from arbitrary kernels) — the viewer renders it in a fully
|
|
11
|
+
* sandboxed, script-disabled iframe, so this parser only carries the raw string; it never trusts it.
|
|
12
|
+
*/
|
|
13
|
+
export type NbOutput = {
|
|
14
|
+
kind: 'stream';
|
|
15
|
+
text: string;
|
|
16
|
+
isError: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'text';
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
kind: 'json';
|
|
22
|
+
text: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'markdown';
|
|
25
|
+
text: string;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'html';
|
|
28
|
+
html: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'image';
|
|
31
|
+
src: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'error';
|
|
34
|
+
text: string;
|
|
35
|
+
};
|
|
36
|
+
export interface NbCell {
|
|
37
|
+
type: 'markdown' | 'code' | 'raw';
|
|
38
|
+
source: string;
|
|
39
|
+
executionCount: number | null;
|
|
40
|
+
outputs: NbOutput[];
|
|
41
|
+
}
|
|
42
|
+
export interface ParsedNotebook {
|
|
43
|
+
cells: NbCell[];
|
|
44
|
+
language: string;
|
|
45
|
+
nbformat: number;
|
|
46
|
+
}
|
|
47
|
+
/** Parse .ipynb source text into a flat, render-ready cell list. Throws on non-notebook JSON. */
|
|
48
|
+
export declare function parseNotebook(text: string): ParsedNotebook;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
//#region src/lib/ipynb.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return Array.isArray(e) ? e.map((e) => typeof e == "string" ? e : "").join("") : typeof e == "string" ? e : "";
|
|
4
|
+
}
|
|
5
|
+
var t = "\x1B";
|
|
6
|
+
function n(e) {
|
|
7
|
+
let n = "";
|
|
8
|
+
for (let r = 0; r < e.length; r++) {
|
|
9
|
+
if (e[r] !== t) {
|
|
10
|
+
n += e[r];
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (r++, e[r] === "[") for (r++; r < e.length && !/[A-Za-z]/.test(e[r]);) r++;
|
|
14
|
+
}
|
|
15
|
+
return n;
|
|
16
|
+
}
|
|
17
|
+
function r(e) {
|
|
18
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
19
|
+
}
|
|
20
|
+
function i(e) {
|
|
21
|
+
if (r(e.data)) return e.data;
|
|
22
|
+
let t = {};
|
|
23
|
+
return e.png && (t["image/png"] = e.png), e.jpeg && (t["image/jpeg"] = e.jpeg), e.gif && (t["image/gif"] = e.gif), e.svg && (t["image/svg+xml"] = e.svg), e.html && (t["text/html"] = e.html), e.latex && (t["text/latex"] = e.latex), e.text && (t["text/plain"] = e.text), t;
|
|
24
|
+
}
|
|
25
|
+
function a(t) {
|
|
26
|
+
let n = (e) => t[e] != null, r = (n) => e(t[n]);
|
|
27
|
+
if (n("text/html")) return {
|
|
28
|
+
kind: "html",
|
|
29
|
+
html: r("text/html")
|
|
30
|
+
};
|
|
31
|
+
if (n("image/svg+xml")) return {
|
|
32
|
+
kind: "image",
|
|
33
|
+
src: `data:image/svg+xml,${encodeURIComponent(r("image/svg+xml"))}`
|
|
34
|
+
};
|
|
35
|
+
for (let e of [
|
|
36
|
+
"image/png",
|
|
37
|
+
"image/jpeg",
|
|
38
|
+
"image/gif"
|
|
39
|
+
]) if (n(e)) return {
|
|
40
|
+
kind: "image",
|
|
41
|
+
src: `data:${e};base64,${r(e).replace(/\s+/g, "")}`
|
|
42
|
+
};
|
|
43
|
+
if (n("text/markdown")) return {
|
|
44
|
+
kind: "markdown",
|
|
45
|
+
text: r("text/markdown")
|
|
46
|
+
};
|
|
47
|
+
if (n("text/latex")) return {
|
|
48
|
+
kind: "text",
|
|
49
|
+
text: r("text/latex")
|
|
50
|
+
};
|
|
51
|
+
if (n("application/json")) try {
|
|
52
|
+
return {
|
|
53
|
+
kind: "json",
|
|
54
|
+
text: JSON.stringify(t["application/json"], null, 2)
|
|
55
|
+
};
|
|
56
|
+
} catch {
|
|
57
|
+
return {
|
|
58
|
+
kind: "text",
|
|
59
|
+
text: r("application/json")
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
kind: "text",
|
|
64
|
+
text: r("text/plain")
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function o(t) {
|
|
68
|
+
let r = String(t.output_type ?? "");
|
|
69
|
+
if (r === "stream") return {
|
|
70
|
+
kind: "stream",
|
|
71
|
+
text: e(t.text),
|
|
72
|
+
isError: t.name === "stderr"
|
|
73
|
+
};
|
|
74
|
+
if (r === "error" || r === "pyerr") {
|
|
75
|
+
let e = Array.isArray(t.traceback) ? t.traceback.join("\n") : "", r = `${t.ename ?? "Error"}: ${t.evalue ?? ""}`.trim();
|
|
76
|
+
return {
|
|
77
|
+
kind: "error",
|
|
78
|
+
text: n(e) || r
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return r === "execute_result" || r === "display_data" || r === "pyout" ? a(i(t)) : null;
|
|
82
|
+
}
|
|
83
|
+
function s(e) {
|
|
84
|
+
let t = r(e.language_info) ? e.language_info : {}, n = r(e.kernelspec) ? e.kernelspec : {}, i = String(t.name ?? n.language ?? "").toLowerCase();
|
|
85
|
+
return !i || i === "ipython" ? "python" : i;
|
|
86
|
+
}
|
|
87
|
+
function c(t) {
|
|
88
|
+
let n = JSON.parse(t), i = r(n.metadata) ? n.metadata : {}, a = Array.isArray(n.cells) ? n.cells : Array.isArray(n.worksheets) ? n.worksheets.flatMap((e) => r(e) && Array.isArray(e.cells) ? e.cells : []) : [];
|
|
89
|
+
if (!Array.isArray(n.cells) && !Array.isArray(n.worksheets)) throw Error("不是有效的 Jupyter Notebook(缺少 cells)");
|
|
90
|
+
let c = [];
|
|
91
|
+
for (let t of a) {
|
|
92
|
+
if (!r(t)) continue;
|
|
93
|
+
let n = String(t.cell_type ?? ""), i = e(t.source ?? t.input);
|
|
94
|
+
if (n === "code") {
|
|
95
|
+
let e = Array.isArray(t.outputs) ? t.outputs : [], n = [];
|
|
96
|
+
for (let t of e) {
|
|
97
|
+
if (!r(t)) continue;
|
|
98
|
+
let e = o(t);
|
|
99
|
+
e && n.push(e);
|
|
100
|
+
}
|
|
101
|
+
let a = t.execution_count ?? t.prompt_number;
|
|
102
|
+
c.push({
|
|
103
|
+
type: "code",
|
|
104
|
+
source: i,
|
|
105
|
+
executionCount: typeof a == "number" ? a : null,
|
|
106
|
+
outputs: n
|
|
107
|
+
});
|
|
108
|
+
} else if (n === "markdown" || n === "heading") {
|
|
109
|
+
let e = typeof t.level == "number" ? "#".repeat(Math.min(6, t.level)) + " " : "";
|
|
110
|
+
c.push({
|
|
111
|
+
type: "markdown",
|
|
112
|
+
source: e + i,
|
|
113
|
+
executionCount: null,
|
|
114
|
+
outputs: []
|
|
115
|
+
});
|
|
116
|
+
} else c.push({
|
|
117
|
+
type: "raw",
|
|
118
|
+
source: i,
|
|
119
|
+
executionCount: null,
|
|
120
|
+
outputs: []
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
cells: c,
|
|
125
|
+
language: s(i),
|
|
126
|
+
nbformat: typeof n.nbformat == "number" ? n.nbformat : 4
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { c as parseNotebook };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zero-dependency reader for Java keystores — JKS (`0xFEEDFEED`) and JCEKS (`0xCECECECE`) — for the keystore
|
|
3
|
+
* viewer (JksViewer.vue). It parses the proprietary Sun on-disk format (magic / version / entry list / trailing
|
|
4
|
+
* SHA-1 MAC) into an inventory of aliases, entry kinds, creation dates and certificate chains, and — given the
|
|
5
|
+
* password — verifies store integrity and decrypts JKS private keys.
|
|
6
|
+
*
|
|
7
|
+
* What it can do, entirely in-browser and READ-ONLY:
|
|
8
|
+
* - list every entry (private-key / trusted-cert), its alias + creation time, and each entry's X.509 chain
|
|
9
|
+
* (certificates are stored UNENCRYPTED, so they always parse — see lib/x509.ts for the field extraction);
|
|
10
|
+
* - verify the store password via the format's keyed MAC — SHA1(passwordUtf16BE ‖ "Mighty Aphrodite" ‖ body);
|
|
11
|
+
* - decrypt a JKS private key with Sun's KeyProtector (OID 1.3.6.1.4.1.42.2.17.1.1): a SHA-1 keystream XOR
|
|
12
|
+
* with a trailing SHA-1 check digest that doubles as the password check. On success the plaintext is a DER
|
|
13
|
+
* PKCS#8 PrivateKeyInfo, from which we surface the key algorithm / size.
|
|
14
|
+
*
|
|
15
|
+
* Scope: JCEKS trusted certs + integrity parse the same way, but JCEKS private keys use PBEWithMD5AndTripleDES
|
|
16
|
+
* (a different, heavier scheme) — reported as unsupported rather than decrypted. A JCEKS *secret-key* entry is a
|
|
17
|
+
* Java-serialized object with no length prefix we can skip, so hitting one stops the entry walk (already-parsed
|
|
18
|
+
* entries are kept, with a note). PKCS#12 keystores (`.p12`/`.pfx`) are a different format entirely — handled by
|
|
19
|
+
* the certificate viewer, not here.
|
|
20
|
+
*/
|
|
21
|
+
export declare const JKS_MAGIC = 4277010157;
|
|
22
|
+
export declare const JCEKS_MAGIC = 3469659854;
|
|
23
|
+
export type JksStoreType = 'jks' | 'jceks';
|
|
24
|
+
export type JksEntryType = 'privateKey' | 'trustedCert' | 'secretKey';
|
|
25
|
+
export interface JksCertRef {
|
|
26
|
+
/** Certificate type as stored (almost always `X.509`). */
|
|
27
|
+
type: string;
|
|
28
|
+
der: Uint8Array;
|
|
29
|
+
}
|
|
30
|
+
export interface JksEntry {
|
|
31
|
+
type: JksEntryType;
|
|
32
|
+
alias: string;
|
|
33
|
+
/** Creation time (epoch ms); 0 when unknown. */
|
|
34
|
+
createdMs: number;
|
|
35
|
+
/** Trusted-cert: one cert. Private-key: the (possibly empty) chain. Secret-key: none. */
|
|
36
|
+
certs: JksCertRef[];
|
|
37
|
+
/** Private-key entries only: the DER EncryptedPrivateKeyInfo (decrypt with {@link decryptPrivateKey}). */
|
|
38
|
+
encryptedKey?: Uint8Array;
|
|
39
|
+
}
|
|
40
|
+
export interface JksStore {
|
|
41
|
+
storeType: JksStoreType;
|
|
42
|
+
version: number;
|
|
43
|
+
entries: JksEntry[];
|
|
44
|
+
/** Bytes covered by the integrity MAC — everything except the trailing 20-byte digest. */
|
|
45
|
+
macData: Uint8Array;
|
|
46
|
+
/** The trailing 20-byte stored SHA-1 digest (or empty if the file is too short to hold one). */
|
|
47
|
+
storedDigest: Uint8Array;
|
|
48
|
+
/** Set when the entry walk stopped early (e.g. an unskippable JCEKS secret-key entry). */
|
|
49
|
+
truncatedNote?: string;
|
|
50
|
+
}
|
|
51
|
+
export declare class JksError extends Error {
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Parse a JKS/JCEKS keystore from its raw bytes. Certificates and the entry inventory come out regardless of
|
|
55
|
+
* any password (they're stored in the clear); use {@link verifyStorePassword} / {@link decryptPrivateKey} for
|
|
56
|
+
* the password-gated parts. Throws {@link JksError} for a bad magic / version / truncated stream.
|
|
57
|
+
*/
|
|
58
|
+
export declare function readJks(buf: ArrayBuffer): JksStore;
|
|
59
|
+
/**
|
|
60
|
+
* Verify the store-integrity MAC with a candidate password: SHA1(passwordUtf16BE ‖ "Mighty Aphrodite" ‖ body)
|
|
61
|
+
* must equal the stored trailing digest. Also confirms the store password (keytool defaults it equal to each
|
|
62
|
+
* key password). Returns false for an empty password or a store with no digest.
|
|
63
|
+
*/
|
|
64
|
+
export declare function verifyStorePassword(store: JksStore, password: string): boolean;
|
|
65
|
+
/** Friendly description of a decrypted PKCS#8 private key. */
|
|
66
|
+
export interface KeyInfo {
|
|
67
|
+
/** DER PKCS#8 PrivateKeyInfo (the decrypted plaintext). */
|
|
68
|
+
pkcs8: Uint8Array;
|
|
69
|
+
algorithm: string;
|
|
70
|
+
bits?: number;
|
|
71
|
+
curve?: string;
|
|
72
|
+
}
|
|
73
|
+
export type KeyDecryptResult = {
|
|
74
|
+
ok: true;
|
|
75
|
+
key: KeyInfo;
|
|
76
|
+
} | {
|
|
77
|
+
ok: false;
|
|
78
|
+
reason: 'wrong-password' | 'unsupported' | 'malformed';
|
|
79
|
+
detail?: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Decrypt a JKS private key (the DER EncryptedPrivateKeyInfo from {@link JksEntry.encryptedKey}) with Sun's
|
|
83
|
+
* KeyProtector. The password is verified by the format's own trailing SHA-1 check digest, so a wrong password
|
|
84
|
+
* yields `wrong-password` (never garbage). Non-JKS protection (e.g. JCEKS PBEWithMD5AndTripleDES) → `unsupported`.
|
|
85
|
+
*/
|
|
86
|
+
export declare function decryptPrivateKey(encryptedKey: Uint8Array, password: string): KeyDecryptResult;
|
package/dist/lib/jks.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Sha1 as e } from "./sha1.js";
|
|
2
|
+
import { decodeAsn1 as t, oidToString as n } from "./asn1.js";
|
|
3
|
+
import { describePrivateKey as r } from "./x509.js";
|
|
4
|
+
//#region src/lib/jks.ts
|
|
5
|
+
var i = 4277010157, a = 3469659854, o = "1.3.6.1.4.1.42.2.17.1.1", s = "1.3.6.1.4.1.42.2.19.1", c = /* @__PURE__ */ new TextEncoder().encode("Mighty Aphrodite"), l = 20, u = 20, d = class extends Error {};
|
|
6
|
+
function f(e, t, n) {
|
|
7
|
+
let r = "", i = t, a = t + n;
|
|
8
|
+
for (; i < a;) {
|
|
9
|
+
let t = e[i];
|
|
10
|
+
if (t < 128 && t !== 0) r += String.fromCharCode(t), i += 1;
|
|
11
|
+
else if ((t & 224) == 192) {
|
|
12
|
+
let n = e[i + 1] ?? 0;
|
|
13
|
+
r += String.fromCharCode((t & 31) << 6 | n & 63), i += 2;
|
|
14
|
+
} else if ((t & 240) == 224) {
|
|
15
|
+
let n = e[i + 1] ?? 0, a = e[i + 2] ?? 0;
|
|
16
|
+
r += String.fromCharCode((t & 15) << 12 | (n & 63) << 6 | a & 63), i += 3;
|
|
17
|
+
} else r += String.fromCharCode(t), i += 1;
|
|
18
|
+
}
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
function p(e) {
|
|
22
|
+
let t = new Uint8Array(e.length * 2);
|
|
23
|
+
for (let n = 0; n < e.length; n++) {
|
|
24
|
+
let r = e.charCodeAt(n);
|
|
25
|
+
t[2 * n] = r >>> 8 & 255, t[2 * n + 1] = r & 255;
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
function m(e, t) {
|
|
30
|
+
if (e.length !== t.length) return !1;
|
|
31
|
+
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
32
|
+
return !0;
|
|
33
|
+
}
|
|
34
|
+
function h(e) {
|
|
35
|
+
let t = new Uint8Array(e);
|
|
36
|
+
if (t.length < 8) throw new d("文件过小,不是有效的 keystore");
|
|
37
|
+
let n = new DataView(e), r = 0, i = n.getUint32(r);
|
|
38
|
+
r += 4;
|
|
39
|
+
let a;
|
|
40
|
+
if (i === 4277010157) a = "jks";
|
|
41
|
+
else if (i === 3469659854) a = "jceks";
|
|
42
|
+
else throw new d(`文件头不匹配(magic=0x${i.toString(16).padStart(8, "0")})—— 不是 JKS/JCEKS keystore(PKCS#12 的 .p12/.pfx 请用证书查看器打开)`);
|
|
43
|
+
let o = n.getUint32(r);
|
|
44
|
+
if (r += 4, o !== 1 && o !== 2) throw new d(`不支持的 keystore 版本 ${o}`);
|
|
45
|
+
let s = n.getUint32(r);
|
|
46
|
+
if (r += 4, s > 1e6) throw new d(`条目数异常(${s})`);
|
|
47
|
+
let c = () => {
|
|
48
|
+
if (r + 2 > t.length) throw new d("数据被截断");
|
|
49
|
+
let e = n.getUint16(r);
|
|
50
|
+
if (r += 2, r + e > t.length) throw new d("数据被截断");
|
|
51
|
+
let i = f(t, r, e);
|
|
52
|
+
return r += e, i;
|
|
53
|
+
}, l = () => {
|
|
54
|
+
if (r + 4 > t.length) throw new d("数据被截断");
|
|
55
|
+
let e = n.getUint32(r);
|
|
56
|
+
return r += 4, e;
|
|
57
|
+
}, u = () => {
|
|
58
|
+
if (r + 8 > t.length) throw new d("数据被截断");
|
|
59
|
+
let e = Number(n.getBigUint64(r));
|
|
60
|
+
return r += 8, e;
|
|
61
|
+
}, p = (e) => {
|
|
62
|
+
if (e < 0 || r + e > t.length) throw new d("数据被截断");
|
|
63
|
+
let n = t.slice(r, r + e);
|
|
64
|
+
return r += e, n;
|
|
65
|
+
}, m = [], h;
|
|
66
|
+
for (let e = 0; e < s; e++) {
|
|
67
|
+
let t = l();
|
|
68
|
+
if (t === 1) {
|
|
69
|
+
let e = c(), t = u(), n = p(l()), r = l(), i = [];
|
|
70
|
+
for (let e = 0; e < r; e++) {
|
|
71
|
+
let e = o === 2 ? c() : "X.509", t = l();
|
|
72
|
+
i.push({
|
|
73
|
+
type: e,
|
|
74
|
+
der: p(t)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
m.push({
|
|
78
|
+
type: "privateKey",
|
|
79
|
+
alias: e,
|
|
80
|
+
createdMs: t,
|
|
81
|
+
certs: i,
|
|
82
|
+
encryptedKey: n
|
|
83
|
+
});
|
|
84
|
+
} else if (t === 2) {
|
|
85
|
+
let e = c(), t = u(), n = o === 2 ? c() : "X.509", r = p(l());
|
|
86
|
+
m.push({
|
|
87
|
+
type: "trustedCert",
|
|
88
|
+
alias: e,
|
|
89
|
+
createdMs: t,
|
|
90
|
+
certs: [{
|
|
91
|
+
type: n,
|
|
92
|
+
der: r
|
|
93
|
+
}]
|
|
94
|
+
});
|
|
95
|
+
} else if (t === 3 && a === "jceks") {
|
|
96
|
+
let e = c();
|
|
97
|
+
m.push({
|
|
98
|
+
type: "secretKey",
|
|
99
|
+
alias: e,
|
|
100
|
+
createdMs: 0,
|
|
101
|
+
certs: []
|
|
102
|
+
}), h = `含 JCEKS 密钥条目「${e}」(Java 序列化对象,无法在浏览器内跳过其字节),其后的条目未继续解析。`;
|
|
103
|
+
break;
|
|
104
|
+
} else throw new d(`未知条目类型 tag=${t}(第 ${e + 1} 项,偏移 ${r - 4})`);
|
|
105
|
+
}
|
|
106
|
+
let g = t.length, _ = g >= 20;
|
|
107
|
+
return {
|
|
108
|
+
storeType: a,
|
|
109
|
+
version: o,
|
|
110
|
+
entries: m,
|
|
111
|
+
macData: _ ? t.slice(0, g - 20) : t.slice(),
|
|
112
|
+
storedDigest: _ ? t.slice(g - 20) : new Uint8Array(),
|
|
113
|
+
truncatedNote: h
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function g(t, n) {
|
|
117
|
+
if (!n || t.storedDigest.length !== u) return !1;
|
|
118
|
+
let r = new e();
|
|
119
|
+
return r.update(p(n)), r.update(c), r.update(t.macData), m(r.digest(), t.storedDigest);
|
|
120
|
+
}
|
|
121
|
+
function _(i, a) {
|
|
122
|
+
let c = "", d = null;
|
|
123
|
+
try {
|
|
124
|
+
let e = t(i)[0], r = (e?.children[0])?.children[0];
|
|
125
|
+
c = r ? n(r.content) : "";
|
|
126
|
+
let a = e?.children[1];
|
|
127
|
+
a && (d = a.content);
|
|
128
|
+
} catch {
|
|
129
|
+
return {
|
|
130
|
+
ok: !1,
|
|
131
|
+
reason: "malformed"
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (!d) return {
|
|
135
|
+
ok: !1,
|
|
136
|
+
reason: "malformed"
|
|
137
|
+
};
|
|
138
|
+
if (c !== o) return {
|
|
139
|
+
ok: !1,
|
|
140
|
+
reason: "unsupported",
|
|
141
|
+
detail: c === s ? "PBEWithMD5AndTripleDES (JCEKS)" : c || "未知算法"
|
|
142
|
+
};
|
|
143
|
+
if (d.length < 40) return {
|
|
144
|
+
ok: !1,
|
|
145
|
+
reason: "malformed"
|
|
146
|
+
};
|
|
147
|
+
let f = p(a), h = d.subarray(0, l), g = d.length - l - u, _ = d.subarray(l, l + g), v = d.subarray(l + g), y = new Uint8Array(g), b = h, x = 0, S = Math.ceil(g / u);
|
|
148
|
+
for (let t = 0; t < S; t++) {
|
|
149
|
+
let t = new e();
|
|
150
|
+
t.update(f), t.update(b), b = t.digest(), y.set(b.subarray(0, Math.min(u, g - x)), x), x += u;
|
|
151
|
+
}
|
|
152
|
+
let C = new Uint8Array(g);
|
|
153
|
+
for (let e = 0; e < g; e++) C[e] = _[e] ^ y[e];
|
|
154
|
+
let w = new e();
|
|
155
|
+
return w.update(f), w.update(C), m(w.digest(), v) ? {
|
|
156
|
+
ok: !0,
|
|
157
|
+
key: {
|
|
158
|
+
pkcs8: C,
|
|
159
|
+
...r(C)
|
|
160
|
+
}
|
|
161
|
+
} : {
|
|
162
|
+
ok: !1,
|
|
163
|
+
reason: "wrong-password"
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
export { a as JCEKS_MAGIC, i as JKS_MAGIC, d as JksError, _ as decryptPrivateKey, h as readJks, g as verifyStorePassword };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Lines / NDJSON (`.jsonl` / `.ndjson`) parser — one JSON value per physical line.
|
|
3
|
+
*
|
|
4
|
+
* Hand-rolled (no dependency, like the other in-browser parsers): split on newlines, skip blank lines, and
|
|
5
|
+
* `JSON.parse` each remaining line independently. A line that isn't valid JSON is kept as an error record
|
|
6
|
+
* (with its raw text) rather than aborting the whole file — JSONL is often produced incrementally / by logs,
|
|
7
|
+
* so a single malformed line shouldn't blank the preview.
|
|
8
|
+
*
|
|
9
|
+
* Used by JsonlViewer (the side viewer's render mode): the record LIST shows a truncated one-line preview per
|
|
10
|
+
* row, and a row expands to its pretty-printed value on demand — so a huge file stays responsive (the full
|
|
11
|
+
* value of a record is only built when that row is opened).
|
|
12
|
+
*/
|
|
13
|
+
export interface JsonlRecord {
|
|
14
|
+
/** 1-based physical line number in the file (blank lines are skipped, so numbers may have gaps). */
|
|
15
|
+
line: number;
|
|
16
|
+
/** The raw line text (trailing CR stripped) — shown verbatim for error rows. */
|
|
17
|
+
raw: string;
|
|
18
|
+
/** Parsed JSON value when the line is valid JSON; undefined when {@link error} is set. */
|
|
19
|
+
value?: unknown;
|
|
20
|
+
/** Parse error message when the line isn't valid JSON. */
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface JsonlDoc {
|
|
24
|
+
records: JsonlRecord[];
|
|
25
|
+
/** How many records failed to parse (valid + invalid = records.length). */
|
|
26
|
+
errorCount: number;
|
|
27
|
+
}
|
|
28
|
+
/** Parse JSONL/NDJSON text into per-line records. Blank/whitespace-only lines are skipped (not recorded). */
|
|
29
|
+
export declare function parseJsonl(text: string): JsonlDoc;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/lib/jsonl.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = [], n = 0, r = e.split("\n");
|
|
4
|
+
for (let e = 0; e < r.length; e++) {
|
|
5
|
+
let i = r[e].replace(/\r$/, "");
|
|
6
|
+
if (i.trim() === "") continue;
|
|
7
|
+
let a = {
|
|
8
|
+
line: e + 1,
|
|
9
|
+
raw: i
|
|
10
|
+
};
|
|
11
|
+
try {
|
|
12
|
+
a.value = JSON.parse(i);
|
|
13
|
+
} catch (e) {
|
|
14
|
+
a.error = e instanceof Error ? e.message : String(e), n++;
|
|
15
|
+
}
|
|
16
|
+
t.push(a);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
records: t,
|
|
20
|
+
errorCount: n
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { e as parseJsonl };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRC 歌词解析(手写、零依赖)。
|
|
3
|
+
*
|
|
4
|
+
* LRC 是行式歌词格式:元信息标签 `[ti:标题] [ar:歌手] [al:专辑] [by:制作] [offset:毫秒]`,加上带时间戳的
|
|
5
|
+
* 正文行 `[mm:ss.xx]歌词`。一行可带多个时间戳(`[t1][t2]同一句`),表示这句在多处重复出现。
|
|
6
|
+
*
|
|
7
|
+
* QQ 音乐导出的 .lrc 常见两个坑,这里都处理:
|
|
8
|
+
* - 文本里混入 HTML 数字实体(如 `최` 表示某个 Unicode 码点),需要解码还原;
|
|
9
|
+
* - 文件多为 **GBK** 编码(解码交由 {@link decodeTextSniff} 在读盘时完成,本模块只吃已解码的字符串)。
|
|
10
|
+
*
|
|
11
|
+
* 仅做解析,渲染在 LrcViewer.vue。无时间戳的纯文本歌词也能正常显示(hasTimings=false)。
|
|
12
|
+
*/
|
|
13
|
+
export interface LrcLine {
|
|
14
|
+
/** 该行时间戳(毫秒),已叠加全局 offset;纯文本行为 null。 */
|
|
15
|
+
timeMs: number | null;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ParsedLrc {
|
|
19
|
+
tags: Record<string, string>;
|
|
20
|
+
title?: string;
|
|
21
|
+
artist?: string;
|
|
22
|
+
album?: string;
|
|
23
|
+
by?: string;
|
|
24
|
+
/** `[offset:n]` 毫秒(正值表示歌词提前),已并入每行 timeMs。 */
|
|
25
|
+
offsetMs: number;
|
|
26
|
+
/** 按时间升序的歌词行(含解析出的纯文本行,timeMs=null 排在最前、保持原序)。 */
|
|
27
|
+
lines: LrcLine[];
|
|
28
|
+
/** 是否解析到任何带时间戳的行。 */
|
|
29
|
+
hasTimings: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** 解析 LRC 文本(已是正确编码的字符串)。 */
|
|
32
|
+
export declare function parseLrc(text: string): ParsedLrc;
|
package/dist/lib/lrc.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/lib/lrc.ts
|
|
2
|
+
var e = {
|
|
3
|
+
amp: "&",
|
|
4
|
+
lt: "<",
|
|
5
|
+
gt: ">",
|
|
6
|
+
quot: "\"",
|
|
7
|
+
apos: "'",
|
|
8
|
+
nbsp: "\xA0"
|
|
9
|
+
};
|
|
10
|
+
function t(t) {
|
|
11
|
+
return t.includes("&") ? t.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (t, n) => {
|
|
12
|
+
if (n[0] === "#") {
|
|
13
|
+
let e = n[1] === "x" || n[1] === "X" ? parseInt(n.slice(2), 16) : parseInt(n.slice(1), 10);
|
|
14
|
+
if (Number.isFinite(e) && e >= 0 && e <= 1114111) try {
|
|
15
|
+
return String.fromCodePoint(e);
|
|
16
|
+
} catch {
|
|
17
|
+
return t;
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
}
|
|
21
|
+
return e[n.toLowerCase()] ?? t;
|
|
22
|
+
}) : t;
|
|
23
|
+
}
|
|
24
|
+
var n = new Set([
|
|
25
|
+
"ti",
|
|
26
|
+
"ar",
|
|
27
|
+
"al",
|
|
28
|
+
"by",
|
|
29
|
+
"offset",
|
|
30
|
+
"length",
|
|
31
|
+
"re",
|
|
32
|
+
"ve",
|
|
33
|
+
"au",
|
|
34
|
+
"la"
|
|
35
|
+
]), r = /\[(\d{1,3}):(\d{1,2})(?:[.:](\d{1,3}))?\]/g;
|
|
36
|
+
function i(e) {
|
|
37
|
+
let i = {}, a = [], o = [], s = 0;
|
|
38
|
+
for (let c of e.split(/\r\n|\r|\n/)) {
|
|
39
|
+
let e = c;
|
|
40
|
+
r.lastIndex = 0;
|
|
41
|
+
let l = [], u = 0, d;
|
|
42
|
+
for (; (d = r.exec(e)) !== null && d.index === u;) {
|
|
43
|
+
let e = parseInt(d[1], 10), t = parseInt(d[2], 10), n = d[3] ? d[3] : "", r = 0;
|
|
44
|
+
n.length === 1 ? r = parseInt(n, 10) * 100 : n.length === 2 ? r = parseInt(n, 10) * 10 : n.length >= 3 && (r = parseInt(n.slice(0, 3), 10)), l.push(e * 6e4 + t * 1e3 + r), u = d.index + d[0].length;
|
|
45
|
+
}
|
|
46
|
+
if (l.length > 0) {
|
|
47
|
+
let n = t(e.slice(u).trim());
|
|
48
|
+
for (let e of l) a.push({
|
|
49
|
+
timeMs: e,
|
|
50
|
+
text: n
|
|
51
|
+
});
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
let f = /^\[([a-zA-Z]+):(.*)\]\s*$/.exec(e.trim());
|
|
55
|
+
if (f && n.has(f[1].toLowerCase())) {
|
|
56
|
+
let e = f[1].toLowerCase(), n = t(f[2].trim());
|
|
57
|
+
if (i[e] = n, e === "offset") {
|
|
58
|
+
let e = parseInt(n, 10);
|
|
59
|
+
Number.isFinite(e) && (s = e);
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
let p = t(e.trim());
|
|
64
|
+
p && o.push({
|
|
65
|
+
timeMs: null,
|
|
66
|
+
text: p
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (s !== 0) for (let e of a) e.timeMs != null && (e.timeMs -= s);
|
|
70
|
+
a.sort((e, t) => (e.timeMs ?? 0) - (t.timeMs ?? 0));
|
|
71
|
+
let c = a.length > 0 ? a : o;
|
|
72
|
+
return {
|
|
73
|
+
tags: i,
|
|
74
|
+
title: i.ti,
|
|
75
|
+
artist: i.ar,
|
|
76
|
+
album: i.al,
|
|
77
|
+
by: i.by,
|
|
78
|
+
offsetMs: s,
|
|
79
|
+
lines: c,
|
|
80
|
+
hasTimings: a.length > 0
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { i as parseLrc };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal in-browser LZMA / LZMA2 decoder — no dependency, no WASM.
|
|
3
|
+
*
|
|
4
|
+
* Browsers ship a native inflate (DecompressionStream) for ZIP's DEFLATE, but nothing for LZMA — the
|
|
5
|
+
* codec 7z archives use. So unlike {@link lib/zip.ts}, the 7z reader ({@link lib/sevenZip.ts}) has to
|
|
6
|
+
* carry its own decompressor. This is a straight port of Igor Pavlov's reference LZMA decoder (the one
|
|
7
|
+
* in the LZMA SDK / the format spec): a range decoder, the bit-tree / length / distance sub-decoders,
|
|
8
|
+
* and the literal/match main loop. It decodes into a caller-provided linear output buffer (the total
|
|
9
|
+
* unpacked size is always known up front from the 7z folder metadata), which doubles as the LZ window.
|
|
10
|
+
*
|
|
11
|
+
* Three entry points, all synchronous (pure arithmetic, no async primitive needed):
|
|
12
|
+
* - {@link lzmaDecode} raw LZMA1 stream (7z coder 03 01 01), 5-byte props.
|
|
13
|
+
* - {@link lzma2Decode} LZMA2 chunk stream (7z coder 21), 1-byte props.
|
|
14
|
+
* - {@link bcjX86Decode} the x86 BCJ branch filter's decode pass (7z coder 03 03 01 03).
|
|
15
|
+
*
|
|
16
|
+
* Encrypted / unusual coders are the 7z reader's concern; here we only fail (throw) on a malformed
|
|
17
|
+
* stream or an unsupported LZMA2 control byte.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* The LZMA decoder state. Holds the adaptive probability models, the `state` machine value and the four
|
|
21
|
+
* recent match distances — all of which LZMA2 keeps alive (and selectively resets) across chunks, so this
|
|
22
|
+
* is a reusable object rather than a one-shot function.
|
|
23
|
+
*/
|
|
24
|
+
export declare class LzmaState {
|
|
25
|
+
lc: number;
|
|
26
|
+
lp: number;
|
|
27
|
+
pb: number;
|
|
28
|
+
private literal;
|
|
29
|
+
private readonly isMatch;
|
|
30
|
+
private readonly isRep;
|
|
31
|
+
private readonly isRepG0;
|
|
32
|
+
private readonly isRepG1;
|
|
33
|
+
private readonly isRepG2;
|
|
34
|
+
private readonly isRep0Long;
|
|
35
|
+
private readonly posSlot;
|
|
36
|
+
private readonly specPos;
|
|
37
|
+
private readonly align;
|
|
38
|
+
private readonly lenCoder;
|
|
39
|
+
private readonly repLenCoder;
|
|
40
|
+
state: number;
|
|
41
|
+
rep0: number;
|
|
42
|
+
rep1: number;
|
|
43
|
+
rep2: number;
|
|
44
|
+
rep3: number;
|
|
45
|
+
/** Apply the lc/lp/pb properties byte (0..224) and size the literal table accordingly. */
|
|
46
|
+
setProps(d: number): void;
|
|
47
|
+
/** Reset all probability models and the state machine (a "reset state" in LZMA2 terms). */
|
|
48
|
+
resetState(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Decode bytes into `out[outPos .. limit)` using `input` as the range-coded source. `dictStart` is the
|
|
51
|
+
* output offset of the current dictionary's start (for LZMA1 it's `outPos`; for LZMA2 it moves on a dict
|
|
52
|
+
* reset) — it anchors the position counter that drives posState and bounds back-references. Returns the
|
|
53
|
+
* new output position (== limit on success).
|
|
54
|
+
*/
|
|
55
|
+
decode(input: Uint8Array, inStart: number, out: Uint8Array, outPos: number, limit: number, dictStart: number): number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Decode a raw LZMA1 stream (7z coder 03 01 01). `props` is the 5-byte property block (lc/lp/pb byte +
|
|
59
|
+
* little-endian dict size, which we ignore — the linear output buffer is the window). Decodes exactly
|
|
60
|
+
* `outSize` bytes.
|
|
61
|
+
*/
|
|
62
|
+
export declare function lzmaDecode(input: Uint8Array, props: Uint8Array, outSize: number): Uint8Array;
|
|
63
|
+
/**
|
|
64
|
+
* Decode an LZMA2 stream (7z coder 21). LZMA2 frames a sequence of chunks — each either an uncompressed
|
|
65
|
+
* block or an independently range-coded LZMA block — over a shared, selectively-reset dictionary and
|
|
66
|
+
* decoder state. `props` (1 byte, dict-size code) is unused here. Decodes exactly `outSize` bytes.
|
|
67
|
+
*/
|
|
68
|
+
export declare function lzma2Decode(input: Uint8Array, _props: Uint8Array, outSize: number): Uint8Array;
|
|
69
|
+
/** Apply the x86 BCJ decode pass in place (7z coder 03 03 01 03), with `ip` the stream start address (0). */
|
|
70
|
+
export declare function bcjX86Decode(data: Uint8Array, ip?: number): void;
|