@l1yp/file-viewer 0.1.5 → 0.1.6
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/README.md +55 -6
- package/dist/assets/step.worker-CfDTYOf_.js.map +1 -0
- package/dist/components/CertViewer.js +1 -1
- package/dist/components/CertViewer.js.map +1 -1
- package/dist/components/CertViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/DocxNavigationPane.js +1 -1
- package/dist/components/DocxNavigationPane.js.map +1 -1
- package/dist/components/DocxNavigationPane.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/DocxViewer.js +1 -1
- package/dist/components/DocxViewer.js.map +1 -1
- package/dist/components/DocxViewer.vue.d.ts +1 -1
- package/dist/components/DocxViewer.vue_vue_type_script_setup_true_lang.js +80 -78
- package/dist/components/DocxViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/EplViewer.js +1 -1
- package/dist/components/EplViewer.js.map +1 -1
- package/dist/components/EplViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/FileViewerBody.js +1 -1
- package/dist/components/FileViewerBody.js.map +1 -1
- package/dist/components/FileViewerBody.vue_vue_type_script_setup_true_lang.js +265 -257
- package/dist/components/FileViewerBody.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/FileViewerPanel.js +1 -1
- package/dist/components/FileViewerPanel.js.map +1 -1
- package/dist/components/FileViewerPanel.vue.d.ts +6 -1
- package/dist/components/FileViewerPanel.vue_vue_type_script_setup_true_lang.js +42 -40
- package/dist/components/FileViewerPanel.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/HarViewer.js +1 -1
- package/dist/components/HarViewer.js.map +1 -1
- package/dist/components/HarViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/JksViewer.js +1 -1
- package/dist/components/JksViewer.js.map +1 -1
- package/dist/components/JksViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ModelViewModes.js +9 -0
- package/dist/components/ModelViewModes.js.map +1 -0
- package/dist/components/ModelViewModes.vue.d.ts +11 -0
- package/dist/components/ModelViewModes.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/components/ModelViewModes.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/ModelViewer.js +1 -1
- package/dist/components/ModelViewer.js.map +1 -1
- package/dist/components/ModelViewer.vue.d.ts +2 -1
- package/dist/components/ModelViewer.vue_vue_type_script_setup_true_lang.js +183 -96
- package/dist/components/ModelViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/PdfNavigationPane.js +1 -1
- package/dist/components/PdfNavigationPane.js.map +1 -1
- package/dist/components/PdfNavigationPane.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/PdfViewer.js +1 -1
- package/dist/components/PdfViewer.js.map +1 -1
- package/dist/components/PdfViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/PptxNavigationPane.js +1 -1
- package/dist/components/PptxNavigationPane.js.map +1 -1
- package/dist/components/PptxNavigationPane.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/PsdViewer.js +1 -1
- package/dist/components/PsdViewer.js.map +1 -1
- package/dist/components/PsdViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/SqliteViewer.js +1 -1
- package/dist/components/SqliteViewer.js.map +1 -1
- package/dist/components/SqliteViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ViewerLoadError.js +9 -0
- package/dist/components/ViewerLoadError.js.map +1 -0
- package/dist/components/ViewerLoadError.vue.d.ts +17 -0
- package/dist/components/ViewerLoadError.vue_vue_type_script_setup_true_lang.js +58 -0
- package/dist/components/ViewerLoadError.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/XlsxChart.js +1 -1
- package/dist/components/XlsxChart.js.map +1 -1
- package/dist/components/XlsxChart.vue_vue_type_script_setup_true_lang.js +9 -9
- package/dist/components/XlsxChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/XlsxImageLayer.js +9 -0
- package/dist/components/XlsxImageLayer.js.map +1 -0
- package/dist/components/XlsxImageLayer.vue.d.ts +9 -0
- package/dist/components/XlsxImageLayer.vue_vue_type_script_setup_true_lang.js +46 -0
- package/dist/components/XlsxImageLayer.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/XlsxViewer.js +1 -1
- package/dist/components/XlsxViewer.js.map +1 -1
- package/dist/components/XlsxViewer.vue_vue_type_script_setup_true_lang.js +230 -216
- package/dist/components/XlsxViewer.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/epl/EplResource.js +1 -1
- package/dist/components/epl/EplResource.js.map +1 -1
- package/dist/components/epl/EplResource.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/optionalViewer.d.ts +3 -2
- package/dist/components/optionalViewer.js +6 -3
- package/dist/components/optionalViewer.js.map +1 -1
- package/dist/composables/useFileViewer.d.ts +11 -3
- package/dist/composables/useFileViewer.js.map +1 -1
- package/dist/composables/useTeleportTheme.d.ts +7 -0
- package/dist/composables/useTeleportTheme.js +42 -0
- package/dist/composables/useTeleportTheme.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +29 -28
- package/dist/lib/docxTheme.d.ts +6 -0
- package/dist/lib/docxTheme.js +64 -0
- package/dist/lib/docxTheme.js.map +1 -0
- package/dist/lib/epl/code/structures.js +82 -0
- package/dist/lib/epl/code/structures.js.map +1 -0
- package/dist/lib/epl/code/variable.js +16 -0
- package/dist/lib/epl/code/variable.js.map +1 -0
- package/dist/lib/epl/eplDocument.js +28 -22
- package/dist/lib/epl/eplDocument.js.map +1 -1
- package/dist/lib/epl/index.d.ts +2 -1
- package/dist/lib/epl/index.js.map +1 -1
- package/dist/lib/epl/sections/code.js +37 -0
- package/dist/lib/epl/sections/code.js.map +1 -0
- package/dist/lib/epl/sections/esystemInfo.js +29 -0
- package/dist/lib/epl/sections/esystemInfo.js.map +1 -0
- package/dist/lib/epl/sections/losable.js +33 -0
- package/dist/lib/epl/sections/losable.js.map +1 -0
- package/dist/lib/epl/sections/projectConfig.js +39 -0
- package/dist/lib/epl/sections/projectConfig.js.map +1 -0
- package/dist/lib/epl/sections/resource.js +84 -0
- package/dist/lib/epl/sections/resource.js.map +1 -0
- package/dist/lib/fileType.d.ts +3 -1
- package/dist/lib/fileType.js +150 -137
- package/dist/lib/fileType.js.map +1 -1
- package/dist/lib/modelAppearance.d.ts +7 -0
- package/dist/lib/modelAppearance.js +41 -0
- package/dist/lib/modelAppearance.js.map +1 -0
- package/dist/lib/step.d.ts +10 -0
- package/dist/lib/step.js +35 -0
- package/dist/lib/step.js.map +1 -0
- package/dist/lib/step.worker.d.ts +1 -0
- package/dist/lib/step.worker.js +18 -0
- package/dist/lib/step.worker.js.map +1 -0
- package/dist/lib/stepObject.d.ts +4 -0
- package/dist/lib/stepObject.js +52 -0
- package/dist/lib/stepObject.js.map +1 -0
- package/dist/lib/stepTypes.d.ts +60 -0
- package/dist/lib/viewerKind.js +10 -5
- package/dist/lib/viewerKind.js.map +1 -1
- package/dist/lib/xlsx.d.ts +1 -1
- package/dist/lib/xlsx.js +106 -89
- package/dist/lib/xlsx.js.map +1 -1
- package/dist/lib/xlsxCharts.js +71 -119
- package/dist/lib/xlsxCharts.js.map +1 -1
- package/dist/lib/xlsxImages.d.ts +43 -0
- package/dist/lib/xlsxImages.js +114 -0
- package/dist/lib/xlsxImages.js.map +1 -0
- package/dist/lib/xlsxParts.d.ts +17 -0
- package/dist/lib/xlsxParts.js +86 -0
- package/dist/lib/xlsxParts.js.map +1 -0
- package/dist/style.css +1 -1
- package/package.json +8 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from "./
|
|
1
|
+
import e from "./ViewerLoadError.js";
|
|
2
2
|
import { defineAsyncComponent as t, defineComponent as n, h as r } from "vue";
|
|
3
3
|
//#region src/components/optionalViewer.ts
|
|
4
4
|
function i(i, a, o) {
|
|
@@ -6,8 +6,9 @@ function i(i, a, o) {
|
|
|
6
6
|
return t({
|
|
7
7
|
loader: i,
|
|
8
8
|
errorComponent: n({
|
|
9
|
-
name: "
|
|
9
|
+
name: "ViewerUnavailable",
|
|
10
10
|
props: {
|
|
11
|
+
error: { default: void 0 },
|
|
11
12
|
url: {
|
|
12
13
|
type: String,
|
|
13
14
|
default: ""
|
|
@@ -22,10 +23,12 @@ function i(i, a, o) {
|
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
setup: (t) => () => r(e, {
|
|
26
|
+
error: t.error,
|
|
25
27
|
pkg: s,
|
|
26
28
|
label: o,
|
|
27
29
|
downloadUrl: t.url,
|
|
28
|
-
downloadName: t.name
|
|
30
|
+
downloadName: t.name,
|
|
31
|
+
onRetry: () => window.location.reload()
|
|
29
32
|
})
|
|
30
33
|
}),
|
|
31
34
|
onError(e, t, n) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optionalViewer.js","names":[],"sources":["../../src/components/optionalViewer.ts"],"sourcesContent":["import { defineAsyncComponent, defineComponent, h, type Component } from 'vue'\nimport
|
|
1
|
+
{"version":3,"file":"optionalViewer.js","names":[],"sources":["../../src/components/optionalViewer.ts"],"sourcesContent":["import { defineAsyncComponent, defineComponent, h, type Component } from 'vue'\nimport ViewerLoadError from '@/components/ViewerLoadError.vue'\n\n/**\n * Wrap a heavy viewer's async loader so that, when its OPTIONAL peer dependency isn't installed in the\n * consumer's app, an explicit resolution error shows an installation card instead of a blank error.\n * Other failures (network/cache/runtime errors) retain their actual cause in {@link ViewerLoadError}.\n * The dep is `external` in the library build, so a\n * viewer that statically imports it fails to evaluate its chunk when the dep is absent — which lands here.\n *\n * The error component receives the SAME props the viewer was given (`url`/`name`/`size`), so the card can keep\n * the file downloadable. Only for viewers whose dep is imported STATICALLY (pdf/docx/xlsx/pptx/sqlite/model/\n * dicom); viewers that import their engine dynamically at runtime (geo/raster/ebook) handle absence themselves.\n */\nexport function optionalViewer(\n loader: () => Promise<Component | { default: Component }>,\n deps: string | string[],\n label: string,\n): Component {\n const pkg = Array.isArray(deps) ? deps : [deps]\n return defineAsyncComponent({\n loader: loader as () => Promise<Component>,\n errorComponent: defineComponent({\n name: 'ViewerUnavailable',\n props: {\n error: { default: undefined },\n url: { type: String, default: '' },\n name: { type: String, default: '' },\n size: { type: Number, default: undefined },\n },\n setup: (props) => () =>\n h(ViewerLoadError, {\n error: props.error,\n pkg,\n label,\n downloadUrl: props.url,\n downloadName: props.name,\n onRetry: () => window.location.reload(),\n }),\n }),\n // Don't retry a stale module URL automatically. The error card explains the failure and offers reload.\n onError(_error, _retry, fail) {\n fail()\n },\n })\n}\n"],"mappings":";;;AAcA,SAAgB,EACd,GACA,GACA,GACW;CACX,IAAM,IAAM,MAAM,QAAQ,CAAI,IAAI,IAAO,CAAC,CAAI;CAC9C,OAAO,EAAqB;EAClB;EACR,gBAAgB,EAAgB;GAC9B,MAAM;GACN,OAAO;IACL,OAAO,EAAE,SAAS,KAAA,EAAU;IAC5B,KAAK;KAAE,MAAM;KAAQ,SAAS;IAAG;IACjC,MAAM;KAAE,MAAM;KAAQ,SAAS;IAAG;IAClC,MAAM;KAAE,MAAM;KAAQ,SAAS,KAAA;IAAU;GAC3C;GACA,QAAQ,YACN,EAAE,GAAiB;IACjB,OAAO,EAAM;IACb;IACA;IACA,aAAa,EAAM;IACnB,cAAc,EAAM;IACpB,eAAe,OAAO,SAAS,OAAO;GACxC,CAAC;EACL,CAAC;EAED,QAAQ,GAAQ,GAAQ,GAAM;GAC5B,EAAK;EACP;CACF,CAAC;AACH"}
|
|
@@ -78,8 +78,10 @@ export interface ViewerFile {
|
|
|
78
78
|
lrc?: boolean;
|
|
79
79
|
/** Large text / `.log`: the panel hands the URL to the in-browser streaming log viewer (virtual-scrolled). */
|
|
80
80
|
log?: boolean;
|
|
81
|
-
/** 3D model (.stl/.obj/.ply/.glb/.gltf):
|
|
81
|
+
/** 3D model (.stl/.obj/.ply/.glb/.gltf/.stp/.step): rendered in-browser with three.js. */
|
|
82
82
|
model?: boolean;
|
|
83
|
+
/** STEP detected from MIME or a different detectName; independent of the display caption. */
|
|
84
|
+
modelFormat?: 'step';
|
|
83
85
|
/** Decoding image (TIFF/PSD/HEIC/RAW): the panel hands the URL + kind to the in-browser raster viewer. */
|
|
84
86
|
raster?: 'tiff' | 'psd' | 'heic' | 'raw';
|
|
85
87
|
/** E-book (EPUB/FB2/MOBI/DjVu): the panel hands the URL + kind to the in-browser e-book reader. */
|
|
@@ -224,9 +226,12 @@ export declare function useFileViewer(): {
|
|
|
224
226
|
/** Large text / `.log`: the panel hands the URL to the in-browser streaming log viewer (virtual-scrolled). */
|
|
225
227
|
| undefined;
|
|
226
228
|
log?: boolean
|
|
227
|
-
/** 3D model (.stl/.obj/.ply/.glb/.gltf):
|
|
229
|
+
/** 3D model (.stl/.obj/.ply/.glb/.gltf/.stp/.step): rendered in-browser with three.js. */
|
|
228
230
|
| undefined;
|
|
229
231
|
model?: boolean
|
|
232
|
+
/** STEP detected from MIME or a different detectName; independent of the display caption. */
|
|
233
|
+
| undefined;
|
|
234
|
+
modelFormat?: "step"
|
|
230
235
|
/** Decoding image (TIFF/PSD/HEIC/RAW): the panel hands the URL + kind to the in-browser raster viewer. */
|
|
231
236
|
| undefined;
|
|
232
237
|
raster?: "tiff" | "psd" | "heic" | "raw"
|
|
@@ -377,9 +382,12 @@ export declare function useFileViewer(): {
|
|
|
377
382
|
/** Large text / `.log`: the panel hands the URL to the in-browser streaming log viewer (virtual-scrolled). */
|
|
378
383
|
| undefined;
|
|
379
384
|
log?: boolean
|
|
380
|
-
/** 3D model (.stl/.obj/.ply/.glb/.gltf):
|
|
385
|
+
/** 3D model (.stl/.obj/.ply/.glb/.gltf/.stp/.step): rendered in-browser with three.js. */
|
|
381
386
|
| undefined;
|
|
382
387
|
model?: boolean
|
|
388
|
+
/** STEP detected from MIME or a different detectName; independent of the display caption. */
|
|
389
|
+
| undefined;
|
|
390
|
+
modelFormat?: "step"
|
|
383
391
|
/** Decoding image (TIFF/PSD/HEIC/RAW): the panel hands the URL + kind to the in-browser raster viewer. */
|
|
384
392
|
| undefined;
|
|
385
393
|
raster?: "tiff" | "psd" | "heic" | "raw"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileViewer.js","names":[],"sources":["../../src/composables/useFileViewer.ts"],"sourcesContent":["import { computed, ref } from 'vue'\n\n/** A file opened in the side viewer: its display name, fetch/download URL, and highlight language. */\nexport interface ViewerFile {\n name: string\n /** Download endpoint URL — fetched as text and reused by the download button. Omit when `content` is set. */\n url?: string\n /** highlight.js language id, '' for plain text, or 'markdown' (the panel renders markdown instead of highlighting). */\n lang: string\n /** HTML document: the panel offers a render/source toggle, rendering the markup in a sandboxed iframe. */\n html?: boolean\n /** SVG document: the panel offers a render/source toggle — render shows the picture, source the XML. */\n svg?: boolean\n /** ZIP archive: the panel fetches the bytes and hands them to the in-browser archive browser. */\n zip?: boolean\n /** 7z archive: the panel fetches the bytes and hands them to the in-browser 7z browser. */\n sevenZip?: boolean\n /**\n * tar-family ('tar': tar/gz/tgz/xz/txz/bz2/tbz2) or rar ('rar') archive: the panel hands the URL + this\n * kind to the generic in-browser ArchiveBrowser, which decompresses the bytes and browses the entries.\n */\n archive?: 'tar' | 'rar'\n /** Native binary object (.so/.dll): the panel hands the URL to the in-browser symbol browser. */\n binobj?: boolean\n /** E-language (.e/.ec) project: the panel hands the URL to the in-browser EPL viewer (parse + decompile). */\n epl?: boolean\n /** DICOM (.dcm) medical image: the panel hands the URL to the in-browser DICOM viewer. */\n dicom?: boolean\n /** Word (.docx) document: the panel hands the URL to the in-browser Word viewer (docx-preview). */\n docx?: boolean\n /** Excel (.xlsx/.xlsm) workbook: the panel hands the URL to the in-browser spreadsheet viewer (exceljs). */\n xlsx?: boolean\n /** PowerPoint (.pptx/.pptm/.ppsx) deck: the panel hands the URL to the in-browser slide viewer (pptx-renderer). */\n pptx?: boolean\n /** Rich Text (.rtf) document: the panel hands the URL to the in-browser rich-text viewer (hand-rolled RTF parser). */\n rtf?: boolean\n /** PDF (.pdf) document: the panel hands the URL to the in-browser PDF viewer (pdfjs-dist). */\n pdf?: boolean\n /** OPML / FreeMind (.opml/.mm) outline: the panel fetches the text and renders it as an interactive mind map. */\n mindmap?: boolean\n /** XMind workbook (.xmind): the panel hands the URL to the in-browser XMind viewer (unzip → mind-map tree). */\n xmind?: boolean\n /** Email (.eml) message: the panel hands the URL to the in-browser email viewer (MIME parser). */\n eml?: boolean\n /** Web archive (.mht/.mhtml): the panel hands the URL to the in-browser web-archive viewer (MIME parser). */\n mht?: boolean\n /** HAR (.har) capture: the panel hands the URL to the in-browser HAR viewer (hand-rolled JSON parser). */\n har?: boolean\n /** SQLite database (.sqlite/.db/…): the panel hands the URL to the in-browser SQLite viewer (sql.js). */\n sqlite?: boolean\n /** Certificate / key (.pem/.crt/.der/.csr/.p12/…): the panel hands the URL to the in-browser cert viewer (ASN.1/X.509). */\n cert?: boolean\n /** Keystore (.jks/.keystore/.jceks + PKCS#12 .p12/.pfx): the panel hands the URL to the in-browser keystore viewer (sniffs format, parse + password decrypt). */\n jks?: boolean\n /** Subtitle (.srt/.vtt/.ass/.ssa): the panel renders the fetched text as a parsed cue list (render/source toggle). */\n subtitle?: boolean\n /** CSV / TSV (.csv/.tsv): the panel renders the fetched text as a parsed table (render/source toggle). */\n csv?: boolean\n /** JSON Lines (.jsonl/.ndjson): the panel renders the fetched text as a record list — truncated rows, click to expand (render/source toggle). */\n jsonl?: boolean\n /** Java bytecode (.class): the panel hands the URL to the in-browser class viewer (parse structure → fields/methods). */\n javaClass?: boolean\n /** JVM heap dump (.hprof): the panel hands the URL to the in-browser HPROF viewer (stream-parse → class histogram + per-class object drill-in). */\n hprof?: boolean\n /** Windows Installer (.msi/.msp/.msm): the panel hands the URL to the in-browser MSI viewer (OLE compound file → product identity + summary). */\n msi?: boolean\n /** Windows app package (.appx/.msix/.appxbundle/.msixbundle): the panel hands the URL to the in-browser APPX viewer (unzip manifest → identity/deps/capabilities). */\n appx?: boolean\n /** Font (.ttf/.otf/.woff/.woff2): the panel hands the URL to the in-browser font specimen (FontFace API). */\n font?: boolean\n /** Jupyter Notebook (.ipynb): the panel hands the URL to the in-browser notebook viewer (hand-rolled JSON parser). */\n ipynb?: boolean\n /** Geodata (.geojson/.kml/.gpx): the panel renders the fetched text as an offline SVG map (render/source toggle). */\n geo?: boolean\n /** Audio (mp3/wav/flac/ogg/m4a/aac/opus, or .mid): the panel hands the URL to the in-browser audio player. */\n audio?: boolean\n /** QQ Music encrypted audio (.mflac/.mgg/…): the panel hands the URL to the QMC player (decrypts in-browser, then plays). */\n qmc?: boolean\n /** LRC lyrics (.lrc): the panel hands the URL to the lyrics viewer (self-fetches + sniffs GBK, then renders synced lines). */\n lrc?: boolean\n /** Large text / `.log`: the panel hands the URL to the in-browser streaming log viewer (virtual-scrolled). */\n log?: boolean\n /** 3D model (.stl/.obj/.ply/.glb/.gltf):
|
|
1
|
+
{"version":3,"file":"useFileViewer.js","names":[],"sources":["../../src/composables/useFileViewer.ts"],"sourcesContent":["import { computed, ref } from 'vue'\n\n/** A file opened in the side viewer: its display name, fetch/download URL, and highlight language. */\nexport interface ViewerFile {\n name: string\n /** Download endpoint URL — fetched as text and reused by the download button. Omit when `content` is set. */\n url?: string\n /** highlight.js language id, '' for plain text, or 'markdown' (the panel renders markdown instead of highlighting). */\n lang: string\n /** HTML document: the panel offers a render/source toggle, rendering the markup in a sandboxed iframe. */\n html?: boolean\n /** SVG document: the panel offers a render/source toggle — render shows the picture, source the XML. */\n svg?: boolean\n /** ZIP archive: the panel fetches the bytes and hands them to the in-browser archive browser. */\n zip?: boolean\n /** 7z archive: the panel fetches the bytes and hands them to the in-browser 7z browser. */\n sevenZip?: boolean\n /**\n * tar-family ('tar': tar/gz/tgz/xz/txz/bz2/tbz2) or rar ('rar') archive: the panel hands the URL + this\n * kind to the generic in-browser ArchiveBrowser, which decompresses the bytes and browses the entries.\n */\n archive?: 'tar' | 'rar'\n /** Native binary object (.so/.dll): the panel hands the URL to the in-browser symbol browser. */\n binobj?: boolean\n /** E-language (.e/.ec) project: the panel hands the URL to the in-browser EPL viewer (parse + decompile). */\n epl?: boolean\n /** DICOM (.dcm) medical image: the panel hands the URL to the in-browser DICOM viewer. */\n dicom?: boolean\n /** Word (.docx) document: the panel hands the URL to the in-browser Word viewer (docx-preview). */\n docx?: boolean\n /** Excel (.xlsx/.xlsm) workbook: the panel hands the URL to the in-browser spreadsheet viewer (exceljs). */\n xlsx?: boolean\n /** PowerPoint (.pptx/.pptm/.ppsx) deck: the panel hands the URL to the in-browser slide viewer (pptx-renderer). */\n pptx?: boolean\n /** Rich Text (.rtf) document: the panel hands the URL to the in-browser rich-text viewer (hand-rolled RTF parser). */\n rtf?: boolean\n /** PDF (.pdf) document: the panel hands the URL to the in-browser PDF viewer (pdfjs-dist). */\n pdf?: boolean\n /** OPML / FreeMind (.opml/.mm) outline: the panel fetches the text and renders it as an interactive mind map. */\n mindmap?: boolean\n /** XMind workbook (.xmind): the panel hands the URL to the in-browser XMind viewer (unzip → mind-map tree). */\n xmind?: boolean\n /** Email (.eml) message: the panel hands the URL to the in-browser email viewer (MIME parser). */\n eml?: boolean\n /** Web archive (.mht/.mhtml): the panel hands the URL to the in-browser web-archive viewer (MIME parser). */\n mht?: boolean\n /** HAR (.har) capture: the panel hands the URL to the in-browser HAR viewer (hand-rolled JSON parser). */\n har?: boolean\n /** SQLite database (.sqlite/.db/…): the panel hands the URL to the in-browser SQLite viewer (sql.js). */\n sqlite?: boolean\n /** Certificate / key (.pem/.crt/.der/.csr/.p12/…): the panel hands the URL to the in-browser cert viewer (ASN.1/X.509). */\n cert?: boolean\n /** Keystore (.jks/.keystore/.jceks + PKCS#12 .p12/.pfx): the panel hands the URL to the in-browser keystore viewer (sniffs format, parse + password decrypt). */\n jks?: boolean\n /** Subtitle (.srt/.vtt/.ass/.ssa): the panel renders the fetched text as a parsed cue list (render/source toggle). */\n subtitle?: boolean\n /** CSV / TSV (.csv/.tsv): the panel renders the fetched text as a parsed table (render/source toggle). */\n csv?: boolean\n /** JSON Lines (.jsonl/.ndjson): the panel renders the fetched text as a record list — truncated rows, click to expand (render/source toggle). */\n jsonl?: boolean\n /** Java bytecode (.class): the panel hands the URL to the in-browser class viewer (parse structure → fields/methods). */\n javaClass?: boolean\n /** JVM heap dump (.hprof): the panel hands the URL to the in-browser HPROF viewer (stream-parse → class histogram + per-class object drill-in). */\n hprof?: boolean\n /** Windows Installer (.msi/.msp/.msm): the panel hands the URL to the in-browser MSI viewer (OLE compound file → product identity + summary). */\n msi?: boolean\n /** Windows app package (.appx/.msix/.appxbundle/.msixbundle): the panel hands the URL to the in-browser APPX viewer (unzip manifest → identity/deps/capabilities). */\n appx?: boolean\n /** Font (.ttf/.otf/.woff/.woff2): the panel hands the URL to the in-browser font specimen (FontFace API). */\n font?: boolean\n /** Jupyter Notebook (.ipynb): the panel hands the URL to the in-browser notebook viewer (hand-rolled JSON parser). */\n ipynb?: boolean\n /** Geodata (.geojson/.kml/.gpx): the panel renders the fetched text as an offline SVG map (render/source toggle). */\n geo?: boolean\n /** Audio (mp3/wav/flac/ogg/m4a/aac/opus, or .mid): the panel hands the URL to the in-browser audio player. */\n audio?: boolean\n /** QQ Music encrypted audio (.mflac/.mgg/…): the panel hands the URL to the QMC player (decrypts in-browser, then plays). */\n qmc?: boolean\n /** LRC lyrics (.lrc): the panel hands the URL to the lyrics viewer (self-fetches + sniffs GBK, then renders synced lines). */\n lrc?: boolean\n /** Large text / `.log`: the panel hands the URL to the in-browser streaming log viewer (virtual-scrolled). */\n log?: boolean\n /** 3D model (.stl/.obj/.ply/.glb/.gltf/.stp/.step): rendered in-browser with three.js. */\n model?: boolean\n /** STEP detected from MIME or a different detectName; independent of the display caption. */\n modelFormat?: 'step'\n /** Decoding image (TIFF/PSD/HEIC/RAW): the panel hands the URL + kind to the in-browser raster viewer. */\n raster?: 'tiff' | 'psd' | 'heic' | 'raw'\n /** E-book (EPUB/FB2/MOBI/DjVu): the panel hands the URL + kind to the in-browser e-book reader. */\n ebook?: 'epub' | 'fb2' | 'mobi' | 'djvu'\n /** Diagram (.drawio/.excalidraw): the panel renders the fetched text as an SVG (render/source toggle). */\n diagram?: 'drawio' | 'excalidraw'\n /** DXF (.dxf) CAD drawing: the panel hands the URL to the in-browser DXF viewer (parse → SVG, pan/zoom/layers). */\n dxf?: boolean\n /**\n * Raster image (png/jpg/…/svg-as-picture): rendered inline as a zoomable picture. The main FileChip flow\n * routes images to the LIGHTBOX, so this is set only for archive entries (browsed inside the side viewer,\n * where there is no lightbox) — see classifyViewerFile.\n */\n image?: boolean\n /** Video (mp4/webm/…): rendered inline with a native <video> player. Like {@link image}, set only for archive entries. */\n video?: boolean\n /** Unpreviewable binary: the body shows a \"can't preview — download\" card. Set only for archive entries with no matching viewer. */\n binary?: boolean\n /**\n * Hex dump: the panel hands the URL to the in-browser hex viewer (offset + raw bytes + ASCII gutter). Never\n * auto-detected — set only when the user picks \"十六进制\" from the unpreviewable-binary card's \"open with\"\n * chooser (any bytes can be inspected this way), see FileViewerBody.\n */\n hex?: boolean\n /** File size in bytes (from the manifest) when known — drives the symbol browser's large-file gate. */\n size?: number\n /** Inline text to render directly (e.g. a loaded skill's SKILL.md) — when set, the panel skips fetching. */\n content?: string\n}\n\n// Module-level singleton: a file chip (deep in the message tree) opens the viewer, and the panel\n// (mounted by DetailView) reads the same ref. The detail view closes it on navigation/unmount.\nconst current = ref<ViewerFile | null>(null)\n\n// Shared panel width (px), driven by the drag splitter. DetailView feeds it into `--fv-width` so the\n// conversation column reflows and the panel resizes together; the panel reads it for the drag baseline.\nconst MIN_WIDTH = 360\nconst MAX_WIDTH = 760\n\n// Open at the viewer's original responsive width — clamp(360, 42vw, 760) — so it starts wide; the\n// drag splitter adjusts from there. (No window under SSR: fall back to a sensible fixed default.)\nfunction defaultWidth(): number {\n if (typeof window === 'undefined') return 680\n return Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, Math.round(window.innerWidth * 0.42)))\n}\nconst width = ref(defaultWidth())\n\n/** Clamp to a sane range: never narrower than MIN_WIDTH, and always leave ~320px for the conversation. */\nfunction setWidth(px: number): void {\n const max = typeof window !== 'undefined' ? Math.max(MIN_WIDTH, window.innerWidth - 320) : 900\n width.value = Math.min(max, Math.max(MIN_WIDTH, Math.round(px)))\n}\n\nexport function useFileViewer() {\n return {\n current,\n width,\n setWidth,\n isOpen: computed(() => current.value !== null),\n open(file: ViewerFile): void {\n current.value = file\n },\n close(): void {\n current.value = null\n },\n }\n}\n"],"mappings":";;AAsHA,IAAM,IAAU,EAAuB,IAAI,GAIrC,IAAY,KACZ,IAAY;AAIlB,SAAS,IAAuB;CAE9B,OADI,OAAO,SAAW,MAAoB,MACnC,KAAK,IAAI,GAAW,KAAK,IAAI,GAAW,KAAK,MAAM,OAAO,aAAa,GAAI,CAAC,CAAC;AACtF;AACA,IAAM,IAAQ,EAAI,EAAa,CAAC;AAGhC,SAAS,EAAS,GAAkB;CAClC,IAAM,IAAM,OAAO,SAAW,MAAc,KAAK,IAAI,GAAW,OAAO,aAAa,GAAG,IAAI;CAC3F,EAAM,QAAQ,KAAK,IAAI,GAAK,KAAK,IAAI,GAAW,KAAK,MAAM,CAAE,CAAC,CAAC;AACjE;AAEA,SAAgB,IAAgB;CAC9B,OAAO;EACL;EACA;EACA;EACA,QAAQ,QAAe,EAAQ,UAAU,IAAI;EAC7C,KAAK,GAAwB;GAC3B,EAAQ,QAAQ;EAClB;EACA,QAAc;GACZ,EAAQ,QAAQ;EAClB;CACF;AACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
/** Keep a body-mounted overlay in the originating viewer's theme, including host CSS overrides. */
|
|
3
|
+
export declare function useTeleportTheme(source: Readonly<Ref<HTMLElement | null>>, open: Ref<boolean>): Readonly<Ref<{
|
|
4
|
+
readonly [x: string]: string;
|
|
5
|
+
}, {
|
|
6
|
+
readonly [x: string]: string;
|
|
7
|
+
}>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { readonly as e, shallowRef as t, watch as n } from "vue";
|
|
2
|
+
//#region src/composables/useTeleportTheme.ts
|
|
3
|
+
var r = [
|
|
4
|
+
"--text",
|
|
5
|
+
"--muted",
|
|
6
|
+
"--surface",
|
|
7
|
+
"--border-2",
|
|
8
|
+
"--accent",
|
|
9
|
+
"--shadow",
|
|
10
|
+
"--font-sans"
|
|
11
|
+
];
|
|
12
|
+
function i(i, a) {
|
|
13
|
+
let o = t({});
|
|
14
|
+
return n([i, a], ([e, t], n, i) => {
|
|
15
|
+
if (!e || !t) return;
|
|
16
|
+
let a = () => {
|
|
17
|
+
let t = getComputedStyle(e);
|
|
18
|
+
o.value = Object.fromEntries([["color-scheme", t.colorScheme], ...r.map((e) => [e, t.getPropertyValue(e)])]);
|
|
19
|
+
};
|
|
20
|
+
a();
|
|
21
|
+
let s = new MutationObserver(a);
|
|
22
|
+
for (let t = e; t; t = t.parentElement) s.observe(t, {
|
|
23
|
+
attributes: !0,
|
|
24
|
+
attributeFilter: [
|
|
25
|
+
"class",
|
|
26
|
+
"style",
|
|
27
|
+
"data-theme"
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
let c = window.matchMedia("(prefers-color-scheme: dark)");
|
|
31
|
+
c.addEventListener("change", a), i(() => {
|
|
32
|
+
s.disconnect(), c.removeEventListener("change", a);
|
|
33
|
+
});
|
|
34
|
+
}, {
|
|
35
|
+
immediate: !0,
|
|
36
|
+
flush: "post"
|
|
37
|
+
}), e(o);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { i as useTeleportTheme };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=useTeleportTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTeleportTheme.js","names":[],"sources":["../../src/composables/useTeleportTheme.ts"],"sourcesContent":["import { readonly, shallowRef, watch, type Ref } from 'vue'\n\n// Only the fullscreen toolbar's presentation crosses the Teleport boundary. Document bytes stay untouched.\nconst TOKENS = [\n '--text',\n '--muted',\n '--surface',\n '--border-2',\n '--accent',\n '--shadow',\n '--font-sans',\n] as const\n\n/** Keep a body-mounted overlay in the originating viewer's theme, including host CSS overrides. */\nexport function useTeleportTheme(source: Readonly<Ref<HTMLElement | null>>, open: Ref<boolean>) {\n const style = shallowRef<Record<string, string>>({})\n\n watch(\n [source, open],\n ([element, active], _, onCleanup) => {\n if (!element || !active) return\n const sync = () => {\n const computed = getComputedStyle(element)\n style.value = Object.fromEntries([\n ['color-scheme', computed.colorScheme],\n ...TOKENS.map((token) => [token, computed.getPropertyValue(token)]),\n ])\n }\n sync()\n\n // Observe only this ancestor chain; unrelated page mutations do not trigger style reads.\n const observer = new MutationObserver(sync)\n for (\n let ancestor: HTMLElement | null = element;\n ancestor;\n ancestor = ancestor.parentElement\n ) {\n observer.observe(ancestor, {\n attributes: true,\n attributeFilter: ['class', 'style', 'data-theme'],\n })\n }\n const media = window.matchMedia('(prefers-color-scheme: dark)')\n media.addEventListener('change', sync)\n onCleanup(() => {\n observer.disconnect()\n media.removeEventListener('change', sync)\n })\n },\n { immediate: true, flush: 'post' },\n )\n\n return readonly(style)\n}\n"],"mappings":";;AAGA,IAAM,IAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAGA,SAAgB,EAAiB,GAA2C,GAAoB;CAC9F,IAAM,IAAQ,EAAmC,CAAC,CAAC;CAqCnD,OAnCA,EACE,CAAC,GAAQ,CAAI,IACZ,CAAC,GAAS,IAAS,GAAG,MAAc;EACnC,IAAI,CAAC,KAAW,CAAC,GAAQ;EACzB,IAAM,UAAa;GACjB,IAAM,IAAW,iBAAiB,CAAO;GACzC,EAAM,QAAQ,OAAO,YAAY,CAC/B,CAAC,gBAAgB,EAAS,WAAW,GACrC,GAAG,EAAO,KAAK,MAAU,CAAC,GAAO,EAAS,iBAAiB,CAAK,CAAC,CAAC,CACpE,CAAC;EACH;EACA,EAAK;EAGL,IAAM,IAAW,IAAI,iBAAiB,CAAI;EAC1C,KACE,IAAI,IAA+B,GACnC,GACA,IAAW,EAAS,eAEpB,EAAS,QAAQ,GAAU;GACzB,YAAY;GACZ,iBAAiB;IAAC;IAAS;IAAS;GAAY;EAClD,CAAC;EAEH,IAAM,IAAQ,OAAO,WAAW,8BAA8B;EAE9D,AADA,EAAM,iBAAiB,UAAU,CAAI,GACrC,QAAgB;GAEd,AADA,EAAS,WAAW,GACpB,EAAM,oBAAoB,UAAU,CAAI;EAC1C,CAAC;CACH,GACA;EAAE,WAAW;EAAM,OAAO;CAAO,CACnC,GAEO,EAAS,CAAK;AACvB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* shell consumes — so that shell imports them from here instead of keeping its own copies.
|
|
14
14
|
*/
|
|
15
15
|
import './styles/theme.css';
|
|
16
|
+
import './styles/highlight.css';
|
|
16
17
|
export { default as FileViewer } from './FileViewer.vue';
|
|
17
18
|
export { default as FileViewerPanel } from './components/FileViewerPanel.vue';
|
|
18
19
|
export { default as FileViewerBody } from './components/FileViewerBody.vue';
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
+
/* empty css */
|
|
2
3
|
import { resolveInput as e } from "./lib/resolveInput.js";
|
|
3
|
-
import { LARGE_TEXT_BYTES as t, ebookKind as n, fileExt as r, hljsLang as i, isAppxFile as a, isAudioFile as o, isBinaryObjFile as s, isCertFile as c, isCsvFile as l, isDicomFile as u, isDocxFile as d, isDxfFile as f, isEmlFile as p, isEplFile as m, isFontFile as h, isGeoFile as g, isHarFile as _, isHprofFile as v, isHtmlFile as y, isImageFile as b, isJavaClassFile as x, isJksFile as S, isJsonlFile as C, isLogFile as w, isLrcFile as T, isMhtFile as E, isMindMapFile as D, isModelFile as O, isMsiFile as k, isNotebookFile as A, isPdfFile as j, isPptxFile as M, isQmcAudioFile as N, isRarFile as P, isRtfFile as F, isSevenZipFile as I, isSqliteFile as L,
|
|
4
|
-
import { isDiagramFile as
|
|
5
|
-
import { canToggleView as
|
|
6
|
-
import
|
|
7
|
-
import { formatBytes as
|
|
8
|
-
import { FILL_ICONS as
|
|
9
|
-
import
|
|
10
|
-
import { useFileViewer as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { useLightbox as
|
|
14
|
-
import { MONO as
|
|
15
|
-
import { inline as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { md as
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import { isMissingModule as
|
|
26
|
-
import { segmentize as
|
|
27
|
-
import { ZipEncryptedError as
|
|
28
|
-
import { QmcError as
|
|
29
|
-
import { Sha1 as
|
|
30
|
-
export {
|
|
4
|
+
import { LARGE_TEXT_BYTES as t, ebookKind as n, fileExt as r, hljsLang as i, isAppxFile as a, isAudioFile as o, isBinaryObjFile as s, isCertFile as c, isCsvFile as l, isDicomFile as u, isDocxFile as d, isDxfFile as f, isEmlFile as p, isEplFile as m, isFontFile as h, isGeoFile as g, isHarFile as _, isHprofFile as v, isHtmlFile as y, isImageFile as b, isJavaClassFile as x, isJksFile as S, isJsonlFile as C, isLogFile as w, isLrcFile as T, isMhtFile as E, isMindMapFile as D, isModelFile as O, isMsiFile as k, isNotebookFile as A, isPdfFile as j, isPptxFile as M, isQmcAudioFile as N, isRarFile as P, isRtfFile as F, isSevenZipFile as I, isSqliteFile as L, isStepFile as R, isSubtitleFile as z, isSvgFile as B, isTarballFile as V, isTextFile as H, isVideoFile as U, isXlsxFile as W, isXmindFile as G, isZipFile as K, rasterImageKind as q } from "./lib/fileType.js";
|
|
5
|
+
import { isDiagramFile as J, renderDiagram as Y } from "./lib/diagram.js";
|
|
6
|
+
import { canToggleView as X, classifyViewerFile as Z, mediaMimeForName as Q, skipsTextLoad as $ } from "./lib/viewerKind.js";
|
|
7
|
+
import ee from "./components/MissingDependency.js";
|
|
8
|
+
import { formatBytes as te, formatDateTime as ne, formatDuration as re, formatSizeCoarse as ie } from "./lib/format.js";
|
|
9
|
+
import { FILL_ICONS as ae, STROKE_ICONS as oe } from "./components/icons/iconPaths.js";
|
|
10
|
+
import se from "./components/icons/Icon.js";
|
|
11
|
+
import { useFileViewer as ce } from "./composables/useFileViewer.js";
|
|
12
|
+
import le from "./components/ui/ClampBlock.js";
|
|
13
|
+
import ue from "./components/CodeBlock.js";
|
|
14
|
+
import { useLightbox as de } from "./composables/useLightbox.js";
|
|
15
|
+
import { MONO as fe, SANS as pe, SERIF as me } from "./lib/fonts.js";
|
|
16
|
+
import { inline as he, renderInline as ge } from "./lib/markdown/inline.js";
|
|
17
|
+
import _e from "./components/InlineText.js";
|
|
18
|
+
import ve from "./components/MarkdownTable.js";
|
|
19
|
+
import { md as ye, mdNodes as be } from "./lib/markdown/blocks.js";
|
|
20
|
+
import xe from "./components/MarkdownText.js";
|
|
21
|
+
import Se from "./components/FileViewerBody.js";
|
|
22
|
+
import Ce from "./FileViewer.js";
|
|
23
|
+
import we from "./components/FileViewerPanel.js";
|
|
24
|
+
import Te from "./components/ImageLightbox.js";
|
|
25
|
+
import Ee from "./components/MindMapView.js";
|
|
26
|
+
import { isMissingModule as De, loadOptionalDep as Oe } from "./lib/optionalDep.js";
|
|
27
|
+
import { segmentize as ke } from "./lib/markdown/segmentize.js";
|
|
28
|
+
import { ZipEncryptedError as Ae, ZipPasswordError as je, extractZipEntry as Me, readZip as Ne, zipSupported as Pe } from "./lib/zip.js";
|
|
29
|
+
import { QmcError as Fe, decryptEKey as Ie, decryptQmc as Le, parseFooter as Re } from "./lib/qmc.js";
|
|
30
|
+
import { Sha1 as ze, sha1 as Be } from "./lib/sha1.js";
|
|
31
|
+
export { le as ClampBlock, ue as CodeBlock, ae as FILL_ICONS, Ce as FileViewer, Se as FileViewerBody, we as FileViewerPanel, se as Icon, Te as ImageLightbox, _e as InlineText, t as LARGE_TEXT_BYTES, fe as MONO, ve as MarkdownTable, xe as MarkdownText, Ee as MindMapView, ee as MissingDependency, Fe as QmcError, pe as SANS, me as SERIF, oe as STROKE_ICONS, ze as Sha1, Ae as ZipEncryptedError, je as ZipPasswordError, X as canToggleView, Z as classifyViewerFile, Ie as decryptEKey, Le as decryptQmc, n as ebookKind, Me as extractZipEntry, r as fileExt, te as formatBytes, ne as formatDateTime, re as formatDuration, ie as formatSizeCoarse, i as hljsLang, he as inline, a as isAppxFile, o as isAudioFile, s as isBinaryObjFile, c as isCertFile, l as isCsvFile, J as isDiagramFile, u as isDicomFile, d as isDocxFile, f as isDxfFile, p as isEmlFile, m as isEplFile, h as isFontFile, g as isGeoFile, _ as isHarFile, v as isHprofFile, y as isHtmlFile, b as isImageFile, x as isJavaClassFile, S as isJksFile, C as isJsonlFile, w as isLogFile, T as isLrcFile, E as isMhtFile, D as isMindMapFile, De as isMissingModule, O as isModelFile, k as isMsiFile, A as isNotebookFile, j as isPdfFile, M as isPptxFile, N as isQmcAudioFile, P as isRarFile, F as isRtfFile, I as isSevenZipFile, L as isSqliteFile, R as isStepFile, z as isSubtitleFile, B as isSvgFile, V as isTarballFile, H as isTextFile, U as isVideoFile, W as isXlsxFile, G as isXmindFile, K as isZipFile, Oe as loadOptionalDep, ye as md, be as mdNodes, Q as mediaMimeForName, Re as parseFooter, q as rasterImageKind, Ne as readZip, Y as renderDiagram, ge as renderInline, e as resolveInput, ke as segmentize, Be as sha1, $ as skipsTextLoad, ce as useFileViewer, de as useLightbox, Pe as zipSupported };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapt simple black-on-white Word pages once after rendering. CSS variables handle subsequent theme
|
|
3
|
+
* changes without re-parsing or replacing the document. Pages with authored colors, shading or complex
|
|
4
|
+
* drawings stay intact: a partial override could make their foreground/background combinations unreadable.
|
|
5
|
+
*/
|
|
6
|
+
export declare function applyDocxReadingTheme(root: HTMLElement): void;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//#region src/lib/docxTheme.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = /^rgb\((\d+), (\d+), (\d+)\)$/.exec(e);
|
|
4
|
+
if (!(!t || t[1] !== t[2] || t[2] !== t[3])) return Number(t[1]);
|
|
5
|
+
}
|
|
6
|
+
var t = "rgba(0, 0, 0, 0)", n = [
|
|
7
|
+
"top",
|
|
8
|
+
"right",
|
|
9
|
+
"bottom",
|
|
10
|
+
"left"
|
|
11
|
+
];
|
|
12
|
+
function r(r) {
|
|
13
|
+
let i = r.ownerDocument.defaultView;
|
|
14
|
+
if (i) for (let a of r.querySelectorAll(".docx-wrapper > section.docx")) {
|
|
15
|
+
if (a.querySelector("svg, canvas, iframe, object, embed, video, math")) continue;
|
|
16
|
+
let r = [], o = !0;
|
|
17
|
+
for (let s of [a, ...a.querySelectorAll("*")]) {
|
|
18
|
+
if (s.tagName === "STYLE" || s.tagName === "SCRIPT") continue;
|
|
19
|
+
let c = i.getComputedStyle(s), l = e(c.color), u = e(c.backgroundColor);
|
|
20
|
+
if (l === void 0 && c.color !== t || l !== void 0 && l > 128 || u !== 255 && c.backgroundColor !== t || c.backgroundImage !== "none" || c.boxShadow !== "none" && s !== a) {
|
|
21
|
+
o = !1;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
let d = {};
|
|
25
|
+
if (l !== void 0 && (d.color = l === 0 ? "var(--text)" : "var(--muted)"), u === 255 && (d["background-color"] = "var(--surface)"), s.tagName === "IMG" && (d["background-color"] = "#fff"), ["::before", "::after"].some((e) => {
|
|
26
|
+
let t = i.getComputedStyle(s, e).content;
|
|
27
|
+
return t !== "none" && t !== "normal";
|
|
28
|
+
})) {
|
|
29
|
+
o = !1;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
if (c.textDecorationLine !== "none") {
|
|
33
|
+
if (e(c.textDecorationColor) === void 0) {
|
|
34
|
+
o = !1;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
d["text-decoration-color"] = "currentColor";
|
|
38
|
+
}
|
|
39
|
+
for (let r of n) {
|
|
40
|
+
let n = c.getPropertyValue(`border-${r}-color`);
|
|
41
|
+
if (!(c.getPropertyValue(`border-${r}-style`) === "none" || n === t)) {
|
|
42
|
+
if (e(n) === void 0) {
|
|
43
|
+
o = !1;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
d[`border-${r}-color`] = "var(--border-2)";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!o) break;
|
|
50
|
+
r.push({
|
|
51
|
+
element: s,
|
|
52
|
+
values: d
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (o) {
|
|
56
|
+
for (let { element: e, values: t } of r) for (let [n, r] of Object.entries(t)) e.style.setProperty(n, r);
|
|
57
|
+
a.dataset.fvReadingTheme = "adaptive";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { r as applyDocxReadingTheme };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=docxTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docxTheme.js","names":[],"sources":["../../src/lib/docxTheme.ts"],"sourcesContent":["/** Restrict recoloring to opaque sRGB grays; unknown color spaces retain their authored appearance. */\nfunction grayChannel(color: string): number | undefined {\n const match = /^rgb\\((\\d+), (\\d+), (\\d+)\\)$/.exec(color)\n if (!match || match[1] !== match[2] || match[2] !== match[3]) return undefined\n return Number(match[1])\n}\n\nconst TRANSPARENT = 'rgba(0, 0, 0, 0)'\nconst SIDES = ['top', 'right', 'bottom', 'left'] as const\n\n/**\n * Adapt simple black-on-white Word pages once after rendering. CSS variables handle subsequent theme\n * changes without re-parsing or replacing the document. Pages with authored colors, shading or complex\n * drawings stay intact: a partial override could make their foreground/background combinations unreadable.\n */\nexport function applyDocxReadingTheme(root: HTMLElement): void {\n const view = root.ownerDocument.defaultView\n if (!view) return\n\n for (const page of root.querySelectorAll<HTMLElement>('.docx-wrapper > section.docx')) {\n if (page.querySelector('svg, canvas, iframe, object, embed, video, math')) continue\n const changes: Array<{ element: HTMLElement; values: Record<string, string> }> = []\n let compatible = true\n for (const element of [page, ...page.querySelectorAll<HTMLElement>('*')]) {\n if (element.tagName === 'STYLE' || element.tagName === 'SCRIPT') continue\n const style = view.getComputedStyle(element)\n const foreground = grayChannel(style.color)\n const background = grayChannel(style.backgroundColor)\n if (\n (foreground === undefined && style.color !== TRANSPARENT) ||\n (foreground !== undefined && foreground > 128) ||\n (background !== 255 && style.backgroundColor !== TRANSPARENT) ||\n style.backgroundImage !== 'none' ||\n (style.boxShadow !== 'none' && element !== page)\n ) {\n compatible = false\n break\n }\n\n const values: Record<string, string> = {}\n if (foreground !== undefined) values.color = foreground === 0 ? 'var(--text)' : 'var(--muted)'\n if (background === 255) values['background-color'] = 'var(--surface)'\n // Transparent image pixels originally sat on white paper; preserve that composite in dark mode.\n if (element.tagName === 'IMG') values['background-color'] = '#fff'\n // Generated bullets/fields may have their own CSS colors, outside the ordinary DOM style tree.\n if (\n ['::before', '::after'].some((pseudo) => {\n const content = view.getComputedStyle(element, pseudo).content\n return content !== 'none' && content !== 'normal'\n })\n ) {\n compatible = false\n break\n }\n if (style.textDecorationLine !== 'none') {\n if (grayChannel(style.textDecorationColor) === undefined) {\n compatible = false\n break\n }\n values['text-decoration-color'] = 'currentColor'\n }\n for (const side of SIDES) {\n const color = style.getPropertyValue(`border-${side}-color`)\n if (style.getPropertyValue(`border-${side}-style`) === 'none' || color === TRANSPARENT)\n continue\n if (grayChannel(color) === undefined) {\n compatible = false\n break\n }\n values[`border-${side}-color`] = 'var(--border-2)'\n }\n if (!compatible) break\n changes.push({ element, values })\n }\n if (!compatible) continue\n // Apply only after the entire page passes, avoiding mixed original/themed foregrounds on one page.\n for (const { element, values } of changes) {\n for (const [property, value] of Object.entries(values))\n element.style.setProperty(property, value)\n }\n page.dataset.fvReadingTheme = 'adaptive'\n }\n}\n"],"mappings":";AACA,SAAS,EAAY,GAAmC;CACtD,IAAM,IAAQ,+BAA+B,KAAK,CAAK;CACnD,OAAC,KAAS,EAAM,OAAO,EAAM,MAAM,EAAM,OAAO,EAAM,KAC1D,OAAO,OAAO,EAAM,EAAE;AACxB;AAEA,IAAM,IAAc,oBACd,IAAQ;CAAC;CAAO;CAAS;CAAU;AAAM;AAO/C,SAAgB,EAAsB,GAAyB;CAC7D,IAAM,IAAO,EAAK,cAAc;CAC3B,OAEL,KAAK,IAAM,KAAQ,EAAK,iBAA8B,8BAA8B,GAAG;EACrF,IAAI,EAAK,cAAc,iDAAiD,GAAG;EAC3E,IAAM,IAA2E,CAAC,GAC9E,IAAa;EACjB,KAAK,IAAM,KAAW,CAAC,GAAM,GAAG,EAAK,iBAA8B,GAAG,CAAC,GAAG;GACxE,IAAI,EAAQ,YAAY,WAAW,EAAQ,YAAY,UAAU;GACjE,IAAM,IAAQ,EAAK,iBAAiB,CAAO,GACrC,IAAa,EAAY,EAAM,KAAK,GACpC,IAAa,EAAY,EAAM,eAAe;GACpD,IACG,MAAe,KAAA,KAAa,EAAM,UAAU,KAC5C,MAAe,KAAA,KAAa,IAAa,OACzC,MAAe,OAAO,EAAM,oBAAoB,KACjD,EAAM,oBAAoB,UACzB,EAAM,cAAc,UAAU,MAAY,GAC3C;IACA,IAAa;IACb;GACF;GAEA,IAAM,IAAiC,CAAC;GAMxC,IALI,MAAe,KAAA,MAAW,EAAO,QAAQ,MAAe,IAAI,gBAAgB,iBAC5E,MAAe,QAAK,EAAO,sBAAsB,mBAEjD,EAAQ,YAAY,UAAO,EAAO,sBAAsB,SAG1D,CAAC,YAAY,SAAS,CAAC,CAAC,MAAM,MAAW;IACvC,IAAM,IAAU,EAAK,iBAAiB,GAAS,CAAM,CAAC,CAAC;IACvD,OAAO,MAAY,UAAU,MAAY;GAC3C,CAAC,GACD;IACA,IAAa;IACb;GACF;GACA,IAAI,EAAM,uBAAuB,QAAQ;IACvC,IAAI,EAAY,EAAM,mBAAmB,MAAM,KAAA,GAAW;KACxD,IAAa;KACb;IACF;IACA,EAAO,2BAA2B;GACpC;GACA,KAAK,IAAM,KAAQ,GAAO;IACxB,IAAM,IAAQ,EAAM,iBAAiB,UAAU,EAAK,OAAO;IACvD,QAAM,iBAAiB,UAAU,EAAK,OAAO,MAAM,UAAU,MAAU,IAE3E;SAAI,EAAY,CAAK,MAAM,KAAA,GAAW;MACpC,IAAa;MACb;KACF;KACA,EAAO,UAAU,EAAK,WAAW;IADjC;GAEF;GACA,IAAI,CAAC,GAAY;GACjB,EAAQ,KAAK;IAAE;IAAS;GAAO,CAAC;EAClC;EACK,OAEL;QAAK,IAAM,EAAE,YAAS,eAAY,GAChC,KAAK,IAAM,CAAC,GAAU,MAAU,OAAO,QAAQ,CAAM,GACnD,EAAQ,MAAM,YAAY,GAAU,CAAK;GAE7C,EAAK,QAAQ,iBAAiB;EAFe;CAG/C;AACF"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { readVariables as e } from "./variable.js";
|
|
2
|
+
//#region src/lib/epl/code/structures.ts
|
|
3
|
+
function t(e) {
|
|
4
|
+
return e.readStringsWithMfcStyleCountPrefix().map((e) => {
|
|
5
|
+
let t = e.split("\r");
|
|
6
|
+
return {
|
|
7
|
+
fileName: t[0] ?? "",
|
|
8
|
+
guidString: t[1] ?? "",
|
|
9
|
+
version: [parseInt(t[2] ?? "0", 10) || 0, parseInt(t[3] ?? "0", 10) || 0],
|
|
10
|
+
name: t[4] ?? "",
|
|
11
|
+
minRequiredCmd: 0,
|
|
12
|
+
minRequiredDataType: 0,
|
|
13
|
+
minRequiredConstant: 0
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function n(e, t, n, r) {
|
|
18
|
+
for (let i = 0; i < e.length; i++) e[i].minRequiredCmd = t && i < t.length ? t[i] : 0, e[i].minRequiredDataType = n && i < n.length ? n[i] : 0, e[i].minRequiredConstant = r && i < r.length ? r[i] : 0;
|
|
19
|
+
}
|
|
20
|
+
function r(t) {
|
|
21
|
+
return t.readBlocksWithIdAndMemoryAddress((t, n, r) => ({
|
|
22
|
+
id: n,
|
|
23
|
+
memoryAddress: r,
|
|
24
|
+
form: t.readInt32(),
|
|
25
|
+
baseClass: t.readInt32(),
|
|
26
|
+
name: t.readStringWithLengthPrefix(),
|
|
27
|
+
comment: t.readStringWithLengthPrefix(),
|
|
28
|
+
methods: t.readInt32sWithByteSizePrefix(),
|
|
29
|
+
variables: e(t, "classMember")
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
function i(t) {
|
|
33
|
+
return t.readBlocksWithIdAndMemoryAddress((t, n, r) => ({
|
|
34
|
+
id: n,
|
|
35
|
+
memoryAddress: r,
|
|
36
|
+
classId: t.readInt32(),
|
|
37
|
+
flags: t.readInt32(),
|
|
38
|
+
returnDataType: t.readInt32(),
|
|
39
|
+
name: t.readStringWithLengthPrefix(),
|
|
40
|
+
comment: t.readStringWithLengthPrefix(),
|
|
41
|
+
variables: e(t, "local"),
|
|
42
|
+
parameters: e(t, "methodParameter"),
|
|
43
|
+
codeData: {
|
|
44
|
+
lineOffset: t.readBytesWithLengthPrefix(),
|
|
45
|
+
blockOffset: t.readBytesWithLengthPrefix(),
|
|
46
|
+
methodReference: t.readBytesWithLengthPrefix(),
|
|
47
|
+
variableReference: t.readBytesWithLengthPrefix(),
|
|
48
|
+
constantReference: t.readBytesWithLengthPrefix(),
|
|
49
|
+
expressionData: t.readBytesWithLengthPrefix()
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
function a(t) {
|
|
54
|
+
return t.readBlocksWithIdAndMemoryAddress((t, n, r) => ({
|
|
55
|
+
id: n,
|
|
56
|
+
memoryAddress: r,
|
|
57
|
+
flags: t.readInt32(),
|
|
58
|
+
name: t.readStringWithLengthPrefix(),
|
|
59
|
+
comment: t.readStringWithLengthPrefix(),
|
|
60
|
+
members: e(t, "structMember")
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
function o(t) {
|
|
64
|
+
return t.readBlocksWithIdAndMemoryAddress((t, n, r) => {
|
|
65
|
+
let i = t.readInt32(), a = t.readInt32(), o = t.readStringWithLengthPrefix(), s = t.readStringWithLengthPrefix(), c = t.readStringWithLengthPrefix();
|
|
66
|
+
return {
|
|
67
|
+
id: n,
|
|
68
|
+
memoryAddress: r,
|
|
69
|
+
flags: i,
|
|
70
|
+
returnDataType: a,
|
|
71
|
+
name: o,
|
|
72
|
+
comment: s,
|
|
73
|
+
entryPoint: t.readStringWithLengthPrefix(),
|
|
74
|
+
libraryName: c,
|
|
75
|
+
parameters: e(t, "dllParameter")
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { n as applyCompatibilityInfo, r as readClasses, o as readDllDeclares, t as readLibraries, i as readMethods, a as readStructs };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=structures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structures.js","names":[],"sources":["../../../../src/lib/epl/code/structures.ts"],"sourcesContent":["/**\n * Code-section structures — ports of `ClassInfo.cs`, `MethodInfo.cs` (+ `MethodCodeData`), `StructInfo.cs`,\n * `DllDeclareInfo.cs`, `LibraryRefInfo.cs`.\n *\n * Classes / methods / structs / DLL declares are read via the id+memory-address block table (no per-block\n * length); their variable lists reuse {@link readVariables}. The reads run in C# source order — kept here as\n * explicit statement sequences (not object literals) so the cursor advances identically.\n */\nimport type { BinaryReader } from '../io/binaryReader'\nimport { type EplVariable, readVariables } from './variable'\n\n// ── library references ──────────────────────────────────────────────────────────────────────────\nexport interface LibraryRefInfo {\n fileName: string\n /** Raw GUID string, kept verbatim for faithful round-trip. */\n guidString: string\n version: [number, number]\n name: string\n /** Min command count for the支持库版本检查 (filled by {@link applyCompatibilityInfo}). */\n minRequiredCmd: number\n minRequiredDataType: number\n minRequiredConstant: number\n}\n\n/** Read the library list: MFC-count-prefixed strings, each `fileName\\rguid\\rmajor\\rminor\\rname`. */\nexport function readLibraries(r: BinaryReader): LibraryRefInfo[] {\n return r.readStringsWithMfcStyleCountPrefix().map((x) => {\n const a = x.split('\\r')\n return {\n fileName: a[0] ?? '',\n guidString: a[1] ?? '',\n version: [parseInt(a[2] ?? '0', 10) || 0, parseInt(a[3] ?? '0', 10) || 0],\n name: a[4] ?? '',\n minRequiredCmd: 0,\n minRequiredDataType: 0,\n minRequiredConstant: 0,\n }\n })\n}\n\n/** Attach the per-library min-required counts read separately in the code-section header. */\nexport function applyCompatibilityInfo(\n infos: LibraryRefInfo[],\n minRequiredCmds: number[] | null,\n minRequiredDataTypes: number[] | null,\n minRequiredConstants: number[] | null,\n): void {\n for (let i = 0; i < infos.length; i++) {\n infos[i].minRequiredCmd = minRequiredCmds && i < minRequiredCmds.length ? minRequiredCmds[i] : 0\n infos[i].minRequiredDataType =\n minRequiredDataTypes && i < minRequiredDataTypes.length ? minRequiredDataTypes[i] : 0\n infos[i].minRequiredConstant =\n minRequiredConstants && i < minRequiredConstants.length ? minRequiredConstants[i] : 0\n }\n}\n\n// ── classes (程序集) ────────────────────────────────────────────────────────────────────────────\nexport interface ClassInfo {\n id: number\n memoryAddress: number\n /** Associated form Id for a window class; 0 otherwise. */\n form: number\n baseClass: number\n name: string\n comment: string\n /** Ids of the methods that belong to this class. */\n methods: number[]\n /** Class member variables. */\n variables: EplVariable[]\n}\n\nexport function readClasses(r: BinaryReader): ClassInfo[] {\n return r.readBlocksWithIdAndMemoryAddress((reader, id, memoryAddress) => {\n const form = reader.readInt32()\n const baseClass = reader.readInt32()\n const name = reader.readStringWithLengthPrefix()\n const comment = reader.readStringWithLengthPrefix()\n const methods = reader.readInt32sWithByteSizePrefix() // C#: ReadInt32s(ReadInt32() / 4)\n const variables = readVariables(reader, 'classMember')\n return { id, memoryAddress, form, baseClass, name, comment, methods, variables }\n })\n}\n\n// ── methods (子程序) ────────────────────────────────────────────────────────────────────────────\n/** The six raw byte-blobs holding a method's compiled code (parsed by the code-data parser later). */\nexport interface MethodCodeData {\n lineOffset: Uint8Array\n blockOffset: Uint8Array\n methodReference: Uint8Array\n variableReference: Uint8Array\n constantReference: Uint8Array\n /** The bytecode-like expression stream — decompiled to statements by CodeDataParser. */\n expressionData: Uint8Array\n}\n\nexport interface MethodInfo {\n id: number\n memoryAddress: number\n /** Owning class Id. */\n classId: number\n flags: number\n returnDataType: number\n name: string\n comment: string\n /** Local variables. */\n variables: EplVariable[]\n /** Parameters. */\n parameters: EplVariable[]\n codeData: MethodCodeData\n}\n\nexport function readMethods(r: BinaryReader): MethodInfo[] {\n return r.readBlocksWithIdAndMemoryAddress((reader, id, memoryAddress) => {\n const classId = reader.readInt32()\n const flags = reader.readInt32()\n const returnDataType = reader.readInt32()\n const name = reader.readStringWithLengthPrefix()\n const comment = reader.readStringWithLengthPrefix()\n const variables = readVariables(reader, 'local')\n const parameters = readVariables(reader, 'methodParameter')\n const codeData: MethodCodeData = {\n lineOffset: reader.readBytesWithLengthPrefix(),\n blockOffset: reader.readBytesWithLengthPrefix(),\n methodReference: reader.readBytesWithLengthPrefix(),\n variableReference: reader.readBytesWithLengthPrefix(),\n constantReference: reader.readBytesWithLengthPrefix(),\n expressionData: reader.readBytesWithLengthPrefix(),\n }\n return {\n id,\n memoryAddress,\n classId,\n flags,\n returnDataType,\n name,\n comment,\n variables,\n parameters,\n codeData,\n }\n })\n}\n\n// ── structs (数据类型) ──────────────────────────────────────────────────────────────────────────\nexport interface StructInfo {\n id: number\n memoryAddress: number\n flags: number\n name: string\n comment: string\n members: EplVariable[]\n}\n\nexport function readStructs(r: BinaryReader): StructInfo[] {\n return r.readBlocksWithIdAndMemoryAddress((reader, id, memoryAddress) => {\n const flags = reader.readInt32()\n const name = reader.readStringWithLengthPrefix()\n const comment = reader.readStringWithLengthPrefix()\n const members = readVariables(reader, 'structMember')\n return { id, memoryAddress, flags, name, comment, members }\n })\n}\n\n// ── DLL declares (DLL命令) ──────────────────────────────────────────────────────────────────────\nexport interface DllDeclareInfo {\n id: number\n memoryAddress: number\n flags: number\n returnDataType: number\n name: string\n comment: string\n entryPoint: string\n libraryName: string\n parameters: EplVariable[]\n}\n\nexport function readDllDeclares(r: BinaryReader): DllDeclareInfo[] {\n return r.readBlocksWithIdAndMemoryAddress((reader, id, memoryAddress) => {\n const flags = reader.readInt32()\n const returnDataType = reader.readInt32()\n const name = reader.readStringWithLengthPrefix()\n const comment = reader.readStringWithLengthPrefix()\n const libraryName = reader.readStringWithLengthPrefix()\n const entryPoint = reader.readStringWithLengthPrefix()\n const parameters = readVariables(reader, 'dllParameter')\n return {\n id,\n memoryAddress,\n flags,\n returnDataType,\n name,\n comment,\n entryPoint,\n libraryName,\n parameters,\n }\n })\n}\n"],"mappings":";;AAyBA,SAAgB,EAAc,GAAmC;CAC/D,OAAO,EAAE,mCAAmC,CAAC,CAAC,KAAK,MAAM;EACvD,IAAM,IAAI,EAAE,MAAM,IAAI;EACtB,OAAO;GACL,UAAU,EAAE,MAAM;GAClB,YAAY,EAAE,MAAM;GACpB,SAAS,CAAC,SAAS,EAAE,MAAM,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,MAAM,KAAK,EAAE,KAAK,CAAC;GACxE,MAAM,EAAE,MAAM;GACd,gBAAgB;GAChB,qBAAqB;GACrB,qBAAqB;EACvB;CACF,CAAC;AACH;AAGA,SAAgB,EACd,GACA,GACA,GACA,GACM;CACN,KAAK,IAAI,IAAI,GAAG,IAAI,EAAM,QAAQ,KAIhC,AAHA,EAAM,EAAE,CAAC,iBAAiB,KAAmB,IAAI,EAAgB,SAAS,EAAgB,KAAK,GAC/F,EAAM,EAAE,CAAC,sBACP,KAAwB,IAAI,EAAqB,SAAS,EAAqB,KAAK,GACtF,EAAM,EAAE,CAAC,sBACP,KAAwB,IAAI,EAAqB,SAAS,EAAqB,KAAK;AAE1F;AAiBA,SAAgB,EAAY,GAA8B;CACxD,OAAO,EAAE,kCAAkC,GAAQ,GAAI,OAO9C;EAAE;EAAI;EAAe,MANf,EAAO,UAMQ;EAAM,WALhB,EAAO,UAKS;EAAW,MAJhC,EAAO,2BAIyB;EAAM,SAHnC,EAAO,2BAG4B;EAAS,SAF5C,EAAO,6BAEqC;EAAS,WADnD,EAAc,GAAQ,aAC6B;CAAU,EAChF;AACH;AA8BA,SAAgB,EAAY,GAA+B;CACzD,OAAO,EAAE,kCAAkC,GAAQ,GAAI,OAgB9C;EACL;EACA;EACA,SAlBc,EAAO,UAkBrB;EACA,OAlBY,EAAO,UAkBnB;EACA,gBAlBqB,EAAO,UAkB5B;EACA,MAlBW,EAAO,2BAkBlB;EACA,SAlBc,EAAO,2BAkBrB;EACA,WAlBgB,EAAc,GAAQ,OAkBtC;EACA,YAlBiB,EAAc,GAAQ,iBAkBvC;EACA,UAAA;GAjBA,YAAY,EAAO,0BAA0B;GAC7C,aAAa,EAAO,0BAA0B;GAC9C,iBAAiB,EAAO,0BAA0B;GAClD,mBAAmB,EAAO,0BAA0B;GACpD,mBAAmB,EAAO,0BAA0B;GACpD,gBAAgB,EAAO,0BAA0B;EAYjD;CACF,EACD;AACH;AAYA,SAAgB,EAAY,GAA+B;CACzD,OAAO,EAAE,kCAAkC,GAAQ,GAAI,OAK9C;EAAE;EAAI;EAAe,OAJd,EAAO,UAIO;EAAO,MAHtB,EAAO,2BAGe;EAAM,SAFzB,EAAO,2BAEkB;EAAS,SADlC,EAAc,GAAQ,cACY;CAAQ,EAC3D;AACH;AAeA,SAAgB,EAAgB,GAAmC;CACjE,OAAO,EAAE,kCAAkC,GAAQ,GAAI,MAAkB;EACvE,IAAM,IAAQ,EAAO,UAAU,GACzB,IAAiB,EAAO,UAAU,GAClC,IAAO,EAAO,2BAA2B,GACzC,IAAU,EAAO,2BAA2B,GAC5C,IAAc,EAAO,2BAA2B;EAGtD,OAAO;GACL;GACA;GACA;GACA;GACA;GACA;GACA,YATiB,EAAO,2BASxB;GACA;GACA,YAViB,EAAc,GAAQ,cAUvC;EACF;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/lib/epl/code/variable.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
return e.readBlocksWithIdAndOffest((e, n) => ({
|
|
4
|
+
kind: t,
|
|
5
|
+
id: n,
|
|
6
|
+
dataType: e.readInt32(),
|
|
7
|
+
flags: e.readInt16(),
|
|
8
|
+
uBound: e.readInt32sWithFixedLength(e.readByte()),
|
|
9
|
+
name: e.readCStyleString(),
|
|
10
|
+
comment: e.readCStyleString()
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { e as readVariables };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.js","names":[],"sources":["../../../../src/lib/epl/code/variable.ts"],"sourcesContent":["/**\n * Variable info — port of `VariableInfo/AbstractVariableInfo.cs` (+ its subtypes Global/Local/Class/\n * StructMember/MethodParameter/DllParameter).\n *\n * All variable kinds share ONE binary layout (read via the id+offset block table): dataType(int32),\n * flags(int16), uBound(int32[readByte]), name(CString), comment(CString). The subtypes differ only in how\n * their `flags` bits are interpreted and which keyword they emit as text — captured here by {@link EplVarKind}\n * and resolved in the name/text layer, so the structural read stays uniform.\n */\nimport type { BinaryReader } from '../io/binaryReader'\n\n/** Which variable list a row came from — drives the text keyword + flag-bit meaning later. */\nexport type EplVarKind =\n | 'global'\n | 'local'\n | 'classMember'\n | 'structMember'\n | 'methodParameter'\n | 'dllParameter'\n\nexport interface EplVariable {\n kind: EplVarKind\n id: number\n /** Data-type Id (a system DATATYPE_*, a struct/class Id, or a library data type). */\n dataType: number\n flags: number\n /** Array dimensions (UBound): length 0 ⇒ scalar; `[0]` ⇒ dynamic array; otherwise fixed bounds. */\n uBound: number[]\n name: string\n comment: string\n}\n\n/** Read a variable block table (C# AbstractVariableInfo.ReadVariables) tagging each row with `kind`. */\nexport function readVariables(r: BinaryReader, kind: EplVarKind): EplVariable[] {\n return r.readBlocksWithIdAndOffest((reader, id) => {\n const dataType = reader.readInt32()\n const flags = reader.readInt16()\n const uBound = reader.readInt32sWithFixedLength(reader.readByte())\n const name = reader.readCStyleString()\n const comment = reader.readCStyleString()\n return { kind, id, dataType, flags, uBound, name, comment }\n })\n}\n"],"mappings":";AAiCA,SAAgB,EAAc,GAAiB,GAAiC;CAC9E,OAAO,EAAE,2BAA2B,GAAQ,OAMnC;EAAE;EAAM;EAAI,UALF,EAAO,UAKL;EAAU,OAJf,EAAO,UAIQ;EAAO,QAHrB,EAAO,0BAA0B,EAAO,SAAS,CAG5B;EAAQ,MAF/B,EAAO,iBAEwB;EAAM,SADlC,EAAO,iBAC2B;CAAQ,EAC3D;AACH"}
|
|
@@ -1,38 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decoderForLanguage as e, gbk as t } from "./io/encoding.js";
|
|
2
|
+
import { ProjectFileReader as n } from "./projectFileReader.js";
|
|
3
|
+
import { CodeSectionKey as r } from "./sections/code.js";
|
|
4
|
+
import { ESystemInfoKey as i } from "./sections/esystemInfo.js";
|
|
5
|
+
import { ProjectConfigKey as a } from "./sections/projectConfig.js";
|
|
6
|
+
import { LosableSectionKey as o } from "./sections/losable.js";
|
|
7
|
+
import { ResourceSectionKey as s } from "./sections/resource.js";
|
|
2
8
|
//#region src/lib/epl/eplDocument.ts
|
|
3
|
-
var
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
+
var c = 117469977, l = new Map([
|
|
10
|
+
[i.key, i],
|
|
11
|
+
[a.key, a],
|
|
12
|
+
[r.key, r],
|
|
13
|
+
[s.key, s],
|
|
14
|
+
[o.key, o]
|
|
9
15
|
]);
|
|
10
|
-
function
|
|
11
|
-
let i = new
|
|
16
|
+
function u(r) {
|
|
17
|
+
let i = new n(r), a = t(), o = [];
|
|
12
18
|
for (; !i.isFinish;) {
|
|
13
|
-
let
|
|
14
|
-
if (
|
|
15
|
-
let
|
|
16
|
-
if (
|
|
17
|
-
let
|
|
19
|
+
let t = i.readSection();
|
|
20
|
+
if (t.key === c) break;
|
|
21
|
+
let n = l.get(t.key), r;
|
|
22
|
+
if (n) {
|
|
23
|
+
let e = {
|
|
18
24
|
dec: a,
|
|
19
25
|
cryptEC: i.cryptEC
|
|
20
26
|
};
|
|
21
|
-
|
|
22
|
-
} else
|
|
27
|
+
r = n.parse(t.data, e);
|
|
28
|
+
} else r = {
|
|
23
29
|
kind: "general",
|
|
24
|
-
sectionKey:
|
|
25
|
-
sectionName:
|
|
26
|
-
isOptional:
|
|
27
|
-
data:
|
|
30
|
+
sectionKey: t.key,
|
|
31
|
+
sectionName: t.name,
|
|
32
|
+
isOptional: t.isOptional,
|
|
33
|
+
data: t.data
|
|
28
34
|
};
|
|
29
|
-
|
|
35
|
+
r.kind === "systemInfo" && (a = e(r.language)), o.push(r);
|
|
30
36
|
}
|
|
31
37
|
let s = { sections: o };
|
|
32
38
|
for (let e of o) e.kind === "systemInfo" ? s.systemInfo = e : e.kind === "projectConfig" ? s.projectConfig = e : e.kind === "code" ? s.code = e : e.kind === "resource" ? s.resource = e : e.kind === "losable" && (s.losable = e);
|
|
33
39
|
return s;
|
|
34
40
|
}
|
|
35
41
|
//#endregion
|
|
36
|
-
export {
|
|
42
|
+
export { u as loadEpl };
|
|
37
43
|
|
|
38
44
|
//# sourceMappingURL=eplDocument.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eplDocument.js","names":[],"sources":["../../../src/lib/epl/eplDocument.ts"],"sourcesContent":["/**\n * Top-level loader — port of `EplDocument.Load`.\n *\n * Drives {@link ProjectFileReader} section-by-section: a registered {@link SectionType} parses known keys,\n * everything else becomes a {@link GeneralSection}. When the system-info section is seen, its codepage takes\n * over for the rest of the document. The end-of-file section is consumed but not added to the list.\n *\n * `EplSection` is the discriminated union the UI consumes (narrow on `kind`). The registry grows as more\n * section milestones land.\n */\nimport { decoderForLanguage, gbk } from './io/encoding'\nimport type { GeneralSection, ParserContext, SectionType } from './model/section'\nimport { EplEncryptedError, NotEplFileError, ProjectFileReader } from './projectFileReader'\nimport { CodeSectionKey, type CodeSection } from './sections/code'\nimport { ESystemInfoKey, type ESystemInfoSection } from './sections/esystemInfo'\nimport { ProjectConfigKey, type ProjectConfigSection } from './sections/projectConfig'\nimport { LosableSectionKey, type LosableSection } from './sections/losable'\nimport { ResourceSectionKey, type ResourceSection } from './sections/resource'\n\nexport type EplSection =\n | ESystemInfoSection\n | ProjectConfigSection\n | CodeSection\n | ResourceSection\n | LosableSection\n | GeneralSection\n\nconst KEY_END = 0x07007319\n\n/** key → parser registry (mirrors C# PredefinedSections.Keys). Grows as more section milestones land. */\nconst PREDEFINED = new Map<number, SectionType>([\n [ESystemInfoKey.key, ESystemInfoKey],\n [ProjectConfigKey.key, ProjectConfigKey],\n [CodeSectionKey.key, CodeSectionKey],\n [ResourceSectionKey.key, ResourceSectionKey],\n [LosableSectionKey.key, LosableSectionKey],\n])\n\nexport interface EplDocument {\n /** All parsed sections in file order (end-of-file section excluded). */\n sections: EplSection[]\n /** Convenience handles for the common sections (filled after parsing). */\n systemInfo?: ESystemInfoSection\n projectConfig?: ProjectConfigSection\n code?: CodeSection\n resource?: ResourceSection\n losable?: LosableSection\n}\n\n/** Parse a `.e`/`.ec` byte buffer into its sections. Throws {@link EplEncryptedError} / {@link NotEplFileError}. */\nexport function loadEpl(bytes: Uint8Array): EplDocument {\n const reader = new ProjectFileReader(bytes)\n let dec = gbk()\n const sections: EplSection[] = []\n while (!reader.isFinish) {\n const raw = reader.readSection()\n if (raw.key === KEY_END) break // end-of-file section: consumed, not listed\n const type = PREDEFINED.get(raw.key)\n let section: EplSection\n if (type) {\n const ctx: ParserContext = { dec, cryptEC: reader.cryptEC }\n section = type.parse(raw.data, ctx) as EplSection\n } else {\n section = {\n kind: 'general',\n sectionKey: raw.key,\n sectionName: raw.name,\n isOptional: raw.isOptional,\n data: raw.data,\n }\n }\n // The system-info section dictates the codepage for everything that follows it.\n if (section.kind === 'systemInfo') dec = decoderForLanguage(section.language)\n sections.push(section)\n }\n\n const doc: EplDocument = { sections }\n for (const s of sections) {\n if (s.kind === 'systemInfo') doc.systemInfo = s\n else if (s.kind === 'projectConfig') doc.projectConfig = s\n else if (s.kind === 'code') doc.code = s\n else if (s.kind === 'resource') doc.resource = s\n else if (s.kind === 'losable') doc.losable = s\n }\n return doc\n}\n\nexport { EplEncryptedError, NotEplFileError }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"eplDocument.js","names":[],"sources":["../../../src/lib/epl/eplDocument.ts"],"sourcesContent":["/**\n * Top-level loader — port of `EplDocument.Load`.\n *\n * Drives {@link ProjectFileReader} section-by-section: a registered {@link SectionType} parses known keys,\n * everything else becomes a {@link GeneralSection}. When the system-info section is seen, its codepage takes\n * over for the rest of the document. The end-of-file section is consumed but not added to the list.\n *\n * `EplSection` is the discriminated union the UI consumes (narrow on `kind`). The registry grows as more\n * section milestones land.\n */\nimport { decoderForLanguage, gbk } from './io/encoding'\nimport type { GeneralSection, ParserContext, SectionType } from './model/section'\nimport { EplEncryptedError, NotEplFileError, ProjectFileReader } from './projectFileReader'\nimport { CodeSectionKey, type CodeSection } from './sections/code'\nimport { ESystemInfoKey, type ESystemInfoSection } from './sections/esystemInfo'\nimport { ProjectConfigKey, type ProjectConfigSection } from './sections/projectConfig'\nimport { LosableSectionKey, type LosableSection } from './sections/losable'\nimport { ResourceSectionKey, type ResourceSection } from './sections/resource'\n\nexport type EplSection =\n | ESystemInfoSection\n | ProjectConfigSection\n | CodeSection\n | ResourceSection\n | LosableSection\n | GeneralSection\n\nconst KEY_END = 0x07007319\n\n/** key → parser registry (mirrors C# PredefinedSections.Keys). Grows as more section milestones land. */\nconst PREDEFINED = new Map<number, SectionType>([\n [ESystemInfoKey.key, ESystemInfoKey],\n [ProjectConfigKey.key, ProjectConfigKey],\n [CodeSectionKey.key, CodeSectionKey],\n [ResourceSectionKey.key, ResourceSectionKey],\n [LosableSectionKey.key, LosableSectionKey],\n])\n\nexport interface EplDocument {\n /** All parsed sections in file order (end-of-file section excluded). */\n sections: EplSection[]\n /** Convenience handles for the common sections (filled after parsing). */\n systemInfo?: ESystemInfoSection\n projectConfig?: ProjectConfigSection\n code?: CodeSection\n resource?: ResourceSection\n losable?: LosableSection\n}\n\n/** Parse a `.e`/`.ec` byte buffer into its sections. Throws {@link EplEncryptedError} / {@link NotEplFileError}. */\nexport function loadEpl(bytes: Uint8Array): EplDocument {\n const reader = new ProjectFileReader(bytes)\n let dec = gbk()\n const sections: EplSection[] = []\n while (!reader.isFinish) {\n const raw = reader.readSection()\n if (raw.key === KEY_END) break // end-of-file section: consumed, not listed\n const type = PREDEFINED.get(raw.key)\n let section: EplSection\n if (type) {\n const ctx: ParserContext = { dec, cryptEC: reader.cryptEC }\n section = type.parse(raw.data, ctx) as EplSection\n } else {\n section = {\n kind: 'general',\n sectionKey: raw.key,\n sectionName: raw.name,\n isOptional: raw.isOptional,\n data: raw.data,\n }\n }\n // The system-info section dictates the codepage for everything that follows it.\n if (section.kind === 'systemInfo') dec = decoderForLanguage(section.language)\n sections.push(section)\n }\n\n const doc: EplDocument = { sections }\n for (const s of sections) {\n if (s.kind === 'systemInfo') doc.systemInfo = s\n else if (s.kind === 'projectConfig') doc.projectConfig = s\n else if (s.kind === 'code') doc.code = s\n else if (s.kind === 'resource') doc.resource = s\n else if (s.kind === 'losable') doc.losable = s\n }\n return doc\n}\n\nexport { EplEncryptedError, NotEplFileError }\n"],"mappings":";;;;;;;;AA2BA,IAAM,IAAU,WAGV,IAAa,IAAI,IAAyB;CAC9C,CAAC,EAAe,KAAK,CAAc;CACnC,CAAC,EAAiB,KAAK,CAAgB;CACvC,CAAC,EAAe,KAAK,CAAc;CACnC,CAAC,EAAmB,KAAK,CAAkB;CAC3C,CAAC,EAAkB,KAAK,CAAiB;AAC3C,CAAC;AAcD,SAAgB,EAAQ,GAAgC;CACtD,IAAM,IAAS,IAAI,EAAkB,CAAK,GACtC,IAAM,EAAI,GACR,IAAyB,CAAC;CAChC,OAAO,CAAC,EAAO,WAAU;EACvB,IAAM,IAAM,EAAO,YAAY;EAC/B,IAAI,EAAI,QAAQ,GAAS;EACzB,IAAM,IAAO,EAAW,IAAI,EAAI,GAAG,GAC/B;EACJ,IAAI,GAAM;GACR,IAAM,IAAqB;IAAE;IAAK,SAAS,EAAO;GAAQ;GAC1D,IAAU,EAAK,MAAM,EAAI,MAAM,CAAG;EACpC,OACE,IAAU;GACR,MAAM;GACN,YAAY,EAAI;GAChB,aAAa,EAAI;GACjB,YAAY,EAAI;GAChB,MAAM,EAAI;EACZ;EAIF,AADI,EAAQ,SAAS,iBAAc,IAAM,EAAmB,EAAQ,QAAQ,IAC5E,EAAS,KAAK,CAAO;CACvB;CAEA,IAAM,IAAmB,EAAE,YAAS;CACpC,KAAK,IAAM,KAAK,GACd,AAAI,EAAE,SAAS,eAAc,EAAI,aAAa,IACrC,EAAE,SAAS,kBAAiB,EAAI,gBAAgB,IAChD,EAAE,SAAS,SAAQ,EAAI,OAAO,IAC9B,EAAE,SAAS,aAAY,EAAI,WAAW,IACtC,EAAE,SAAS,cAAW,EAAI,UAAU;CAE/C,OAAO;AACT"}
|
package/dist/lib/epl/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* {@link EplEncryptedError} for encrypted files and {@link NotEplFileError} when the bytes aren't a project
|
|
8
8
|
* file — the viewer turns those into friendly messages.
|
|
9
9
|
*/
|
|
10
|
-
import { loadEpl, type EplDocument
|
|
10
|
+
import { loadEpl, type EplDocument } from './eplDocument';
|
|
11
|
+
import { EplEncryptedError, NotEplFileError } from './projectFileReader';
|
|
11
12
|
import { type EplProgram } from './program';
|
|
12
13
|
export interface EplLibrary {
|
|
13
14
|
name: string;
|