@file-viewer/assets-wordperfect 3.0.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 +160 -0
- package/README.en.md +3 -0
- package/README.md +3 -0
- package/bin/install.mjs +7 -0
- package/file-viewer.asset-pack.json +9 -0
- package/package.json +44 -0
- package/viewer/file-viewer-asset-pack.json +48 -0
- package/viewer/vendor/wordperfect/libwpd.mjs +2 -0
- package/viewer/vendor/wordperfect/libwpd.wasm +0 -0
- package/viewer/vendor/wordperfect/wordperfect.worker.js +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
41
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
42
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
45
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
46
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work by
|
|
47
|
+
the copyright owner or by an individual or Legal Entity authorized to submit on
|
|
48
|
+
behalf of the copyright owner. For the purposes of this definition, "submitted"
|
|
49
|
+
means any form of electronic, verbal, or written communication sent to the
|
|
50
|
+
Licensor or its representatives, including but not limited to communication on
|
|
51
|
+
electronic mailing lists, source code control systems, and issue tracking systems
|
|
52
|
+
that are managed by, or on behalf of, the Licensor for the purpose of discussing
|
|
53
|
+
and improving the Work, but excluding communication that is conspicuously marked
|
|
54
|
+
or otherwise designated in writing by the copyright owner as "Not a
|
|
55
|
+
Contribution."
|
|
56
|
+
|
|
57
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
58
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
59
|
+
incorporated within the Work.
|
|
60
|
+
|
|
61
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
62
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
63
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
64
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
65
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
66
|
+
Object form.
|
|
67
|
+
|
|
68
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
|
69
|
+
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
70
|
+
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
|
71
|
+
license to make, have made, use, offer to sell, sell, import, and otherwise
|
|
72
|
+
transfer the Work, where such license applies only to those patent claims
|
|
73
|
+
licensable by such Contributor that are necessarily infringed by their
|
|
74
|
+
Contribution(s) alone or by combination of their Contribution(s) with the Work to
|
|
75
|
+
which such Contribution(s) was submitted. If You institute patent litigation
|
|
76
|
+
against any entity (including a cross-claim or counterclaim in a lawsuit)
|
|
77
|
+
alleging that the Work or a Contribution incorporated within the Work
|
|
78
|
+
constitutes direct or contributory patent infringement, then any patent licenses
|
|
79
|
+
granted to You under this License for that Work shall terminate as of the date
|
|
80
|
+
such litigation is filed.
|
|
81
|
+
|
|
82
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
83
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
84
|
+
Source or Object form, provided that You meet the following conditions:
|
|
85
|
+
|
|
86
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
87
|
+
this License; and
|
|
88
|
+
|
|
89
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
90
|
+
You changed the files; and
|
|
91
|
+
|
|
92
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
93
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
94
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
95
|
+
of the Derivative Works; and
|
|
96
|
+
|
|
97
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
98
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
99
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
100
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
101
|
+
following places: within a NOTICE text file distributed as part of the Derivative
|
|
102
|
+
Works; within the Source form or documentation, if provided along with the
|
|
103
|
+
Derivative Works; or, within a display generated by the Derivative Works, if and
|
|
104
|
+
wherever such third-party notices normally appear. The contents of the NOTICE
|
|
105
|
+
file are for informational purposes only and do not modify the License. You may
|
|
106
|
+
add Your own attribution notices within Derivative Works that You distribute,
|
|
107
|
+
alongside or as an addendum to the NOTICE text from the Work, provided that such
|
|
108
|
+
additional attribution notices cannot be construed as modifying the License.
|
|
109
|
+
|
|
110
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
111
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
112
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
113
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
114
|
+
with the conditions stated in this License.
|
|
115
|
+
|
|
116
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
117
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
118
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
119
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
120
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
121
|
+
executed with Licensor regarding such Contributions.
|
|
122
|
+
|
|
123
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
124
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
125
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
126
|
+
reproducing the content of the NOTICE file.
|
|
127
|
+
|
|
128
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
129
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
130
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
131
|
+
KIND, either express or implied, including, without limitation, any warranties or
|
|
132
|
+
conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
133
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
134
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
135
|
+
associated with Your exercise of permissions under this License.
|
|
136
|
+
|
|
137
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
138
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
139
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
140
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
141
|
+
direct, indirect, special, incidental, or consequential damages of any character
|
|
142
|
+
arising as a result of this License or out of the use or inability to use the
|
|
143
|
+
Work (including but not limited to damages for loss of goodwill, work stoppage,
|
|
144
|
+
computer failure or malfunction, or any and all other commercial damages or
|
|
145
|
+
losses), even if such Contributor has been advised of the possibility of such
|
|
146
|
+
damages.
|
|
147
|
+
|
|
148
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
149
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
150
|
+
acceptance of support, warranty, indemnity, or other liability obligations and/or
|
|
151
|
+
rights consistent with this License. However, in accepting such obligations, You
|
|
152
|
+
may act only on Your own behalf and on Your sole responsibility, not on behalf of
|
|
153
|
+
any other Contributor, and only if You agree to indemnify, defend, and hold each
|
|
154
|
+
Contributor harmless for any liability incurred by, or claims asserted against,
|
|
155
|
+
such Contributor by reason of your accepting any such warranty or additional
|
|
156
|
+
liability.
|
|
157
|
+
|
|
158
|
+
END OF TERMS AND CONDITIONS
|
|
159
|
+
|
|
160
|
+
Copyright 2026 Flyfish Viewer
|
package/README.en.md
ADDED
package/README.md
ADDED
package/bin/install.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { dirname, resolve } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { runFileViewerAssetPackCli } from '@file-viewer/asset-installer'
|
|
5
|
+
|
|
6
|
+
const outcome = await runFileViewerAssetPackCli(resolve(dirname(fileURLToPath(import.meta.url)), '..'), process.argv.slice(2))
|
|
7
|
+
process.stdout.write(outcome.help ? outcome.text : `[file-viewer] Installed @file-viewer/assets-wordperfect assets in ${outcome.result.targetDir}.\n`)
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@file-viewer/assets-wordperfect",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Independent self-hosted WordPerfect Worker/WASM runtime for opt-in File Viewer integration.",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./asset-pack": "./viewer/file-viewer-asset-pack.json",
|
|
9
|
+
"./viewer/*": "./viewer/*",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin",
|
|
14
|
+
"viewer",
|
|
15
|
+
"file-viewer.asset-pack.json",
|
|
16
|
+
"README.md",
|
|
17
|
+
"README.en.md"
|
|
18
|
+
],
|
|
19
|
+
"bin": {
|
|
20
|
+
"file-viewer-assets-wordperfect": "./bin/install.mjs"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@file-viewer/asset-installer": "3.0.0"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public",
|
|
30
|
+
"registry": "https://registry.npmjs.org/"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/flyfish-dev/file-viewer.git",
|
|
35
|
+
"directory": "packages/tools/assets-wordperfect"
|
|
36
|
+
},
|
|
37
|
+
"fileViewer": {
|
|
38
|
+
"assetPackManifest": "./file-viewer.asset-pack.json"
|
|
39
|
+
},
|
|
40
|
+
"license": "Apache-2.0",
|
|
41
|
+
"scripts": {
|
|
42
|
+
"stage-assets": "node ../../../scripts/stage-capability-asset-pack.mjs --package-dir packages/tools/assets-wordperfect"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"packageName": "@file-viewer/assets-wordperfect",
|
|
4
|
+
"packageVersion": "3.0.0",
|
|
5
|
+
"copyGroups": [
|
|
6
|
+
"office-wordperfect"
|
|
7
|
+
],
|
|
8
|
+
"receiptFilename": "file-viewer-assets-wordperfect.receipt.json",
|
|
9
|
+
"rendererAssetManifests": [
|
|
10
|
+
{
|
|
11
|
+
"rendererId": "office-wordperfect",
|
|
12
|
+
"assets": [
|
|
13
|
+
{
|
|
14
|
+
"id": "wordperfect-worker",
|
|
15
|
+
"rendererId": "office-wordperfect",
|
|
16
|
+
"kind": "worker",
|
|
17
|
+
"target": "public",
|
|
18
|
+
"required": true,
|
|
19
|
+
"defaultPath": "vendor/wordperfect/wordperfect.worker.js",
|
|
20
|
+
"packagePath": "@file-viewer/renderer-wordperfect/worker/wordperfect.worker.js",
|
|
21
|
+
"optionPath": "wordPerfect.workerUrl",
|
|
22
|
+
"description": "Module Worker for bounded WordPerfect signature detection and parsing."
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": "wordperfect-libwpd-wasm",
|
|
26
|
+
"rendererId": "office-wordperfect",
|
|
27
|
+
"kind": "wasm",
|
|
28
|
+
"target": "public",
|
|
29
|
+
"required": true,
|
|
30
|
+
"defaultPath": "vendor/wordperfect/libwpd.wasm",
|
|
31
|
+
"packagePath": "@file-viewer/renderer-wordperfect/worker/libwpd.wasm",
|
|
32
|
+
"optionPath": "wordPerfect.wasmUrl",
|
|
33
|
+
"description": "MPL-2.0 libwpd/librevenge WebAssembly parser lazy-loaded by the WordPerfect Worker."
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "wordperfect-libwpd-module",
|
|
37
|
+
"rendererId": "office-wordperfect",
|
|
38
|
+
"kind": "script",
|
|
39
|
+
"target": "public",
|
|
40
|
+
"required": true,
|
|
41
|
+
"defaultPath": "vendor/wordperfect/libwpd.mjs",
|
|
42
|
+
"packagePath": "@file-viewer/renderer-wordperfect/worker/libwpd.mjs",
|
|
43
|
+
"description": "Emscripten ES module loader for the MPL-2.0 libwpd/librevenge WebAssembly runtime."
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
async function createFileViewerLibWpd(moduleArg={}){var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("node:module");var require=createRequire(import.meta.url)}var programArgs=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}programArgs=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var isFileURI=filename=>filename.startsWith("file://");class EmscriptenEH{}class EmscriptenSjLj extends EmscriptenEH{}class CppException extends EmscriptenEH{constructor(excPtr){super();this.excPtr=excPtr}}var runtimeInitialized=false;function getMemoryBuffer(){return wasmMemory.buffer}function updateMemoryViews(){if(HEAP8?.buffer?.resizable)return;var b=getMemoryBuffer();HEAP8=new Int8Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b)}function preRun(){}function initRuntime(){runtimeInitialized=true;wasmExports["O"]()}function postRun(){}function abort(what){what=`Aborted(${what})`;err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("libwpd.wasm")}return new URL("libwpd.wasm",import.meta.url).href}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary&&!ENVIRONMENT_IS_NODE){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var HEAP8;var stackRestore=val=>__emscripten_stack_restore(val);var stackSave=()=>_emscripten_stack_get_current();var exceptionCaught=[];var uncaughtExceptionCount=0;var ___cxa_begin_catch=ptr=>{var info=new ExceptionInfo(ptr);if(!info.get_caught()){info.set_caught(true);uncaughtExceptionCount--}info.set_rethrown(false);exceptionCaught.push(info);return ___cxa_get_exception_ptr(ptr)};var exceptionLast=null;var ___cxa_end_catch=()=>{_setThrew(0,0);var info=exceptionCaught.pop();___cxa_decrement_exception_refcount(info.excPtr);exceptionLast=null};var HEAPU32;class ExceptionInfo{constructor(excPtr){this.excPtr=excPtr;this.ptr=excPtr-24}set_type(type){HEAPU32[this.ptr+4>>2]=type}get_type(){return HEAPU32[this.ptr+4>>2]}set_destructor(destructor){HEAPU32[this.ptr+8>>2]=destructor}get_destructor(){return HEAPU32[this.ptr+8>>2]}set_caught(caught){caught=caught?1:0;HEAP8[this.ptr+12]=caught}get_caught(){return HEAP8[this.ptr+12]!=0}set_rethrown(rethrown){rethrown=rethrown?1:0;HEAP8[this.ptr+13]=rethrown}get_rethrown(){return HEAP8[this.ptr+13]!=0}init(type,destructor){this.set_adjusted_ptr(0);this.set_type(type);this.set_destructor(destructor)}set_adjusted_ptr(adjustedPtr){HEAPU32[this.ptr+16>>2]=adjustedPtr}get_adjusted_ptr(){return HEAPU32[this.ptr+16>>2]}}var setTempRet0=val=>__emscripten_tempret_set(val);var findMatchingCatch=args=>{var thrown=exceptionLast?.excPtr;if(!thrown){setTempRet0(0);return 0}var info=new ExceptionInfo(thrown);info.set_adjusted_ptr(thrown);var thrownType=info.get_type();if(!thrownType){setTempRet0(0);return thrown}for(var caughtType of args){if(!caughtType||caughtType===thrownType){break}var adjusted_ptr_addr=info.ptr+16;if(___cxa_can_catch(caughtType,thrownType,adjusted_ptr_addr)){setTempRet0(caughtType);return thrown}}setTempRet0(thrownType);return thrown};var ___cxa_find_matching_catch_2=()=>findMatchingCatch([]);var ___cxa_find_matching_catch_3=arg0=>findMatchingCatch([arg0]);var ___cxa_find_matching_catch_4=(arg0,arg1)=>findMatchingCatch([arg0,arg1]);var ___cxa_find_matching_catch_6=(arg0,arg1,arg2,arg3)=>findMatchingCatch([arg0,arg1,arg2,arg3]);var ___cxa_rethrow=()=>{if(!exceptionCaught.length){abort("no exception to throw")}var info=exceptionCaught.at(-1);var ptr=info.excPtr;info.set_rethrown(true);info.set_caught(false);uncaughtExceptionCount++;___cxa_increment_exception_refcount(ptr);exceptionLast=new CppException(ptr);throw exceptionLast};var ___cxa_throw=(ptr,type,destructor)=>{var info=new ExceptionInfo(ptr);info.init(type,destructor);___cxa_increment_exception_refcount(ptr);exceptionLast=new CppException(ptr);uncaughtExceptionCount++;throw exceptionLast};var ___resumeException=ptr=>{if(!exceptionLast){exceptionLast=new CppException(ptr)}throw exceptionLast};var __abort_js=()=>abort("");var stringToUTF8Array=(str,heap,outIdx,maxBytesToWrite)=>{if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.codePointAt(i);if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;i++}}heap[outIdx]=0;return outIdx-startIdx};var HEAPU8;var stringToUTF8=(str,outPtr,maxBytesToWrite)=>stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite);var HEAP32;var __tzset_js=(timezone,daylight,std_name,dst_name)=>{var currentYear=(new Date).getFullYear();var winter=new Date(currentYear,0,1);var summer=new Date(currentYear,6,1);var winterOffset=winter.getTimezoneOffset();var summerOffset=summer.getTimezoneOffset();var stdTimezoneOffset=Math.max(winterOffset,summerOffset);HEAPU32[timezone>>2]=stdTimezoneOffset*60;HEAP32[daylight>>2]=Number(winterOffset!=summerOffset);var extractZone=timezoneOffset=>{var sign=timezoneOffset>=0?"-":"+";var absOffset=Math.abs(timezoneOffset);var hours=String(Math.floor(absOffset/60)).padStart(2,"0");var minutes=String(absOffset%60).padStart(2,"0");return`UTC${sign}${hours}${minutes}`};var winterName=extractZone(winterOffset);var summerName=extractZone(summerOffset);if(summerOffset<winterOffset){stringToUTF8(winterName,std_name,17);stringToUTF8(summerName,dst_name,17)}else{stringToUTF8(winterName,dst_name,17);stringToUTF8(summerName,std_name,17)}};var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var _llvm_eh_typeid_for=type=>type;var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};{if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"]}var _malloc,_xberg_wpd_is_supported,_xberg_wpd_extract_document,_xberg_wpd_free_string,_free,_setThrew,__emscripten_tempret_set,__emscripten_stack_restore,_emscripten_stack_get_current,___cxa_decrement_exception_refcount,___cxa_increment_exception_refcount,___cxa_can_catch,___cxa_get_exception_ptr,memory,__indirect_function_table,wasmMemory,wasmTable;function assignWasmExports(wasmExports){_malloc=Module["_malloc"]=wasmExports["P"];_xberg_wpd_is_supported=Module["_xberg_wpd_is_supported"]=wasmExports["Q"];_xberg_wpd_extract_document=Module["_xberg_wpd_extract_document"]=wasmExports["R"];_xberg_wpd_free_string=Module["_xberg_wpd_free_string"]=wasmExports["T"];_free=Module["_free"]=wasmExports["U"];_setThrew=wasmExports["V"];__emscripten_tempret_set=wasmExports["W"];__emscripten_stack_restore=wasmExports["X"];_emscripten_stack_get_current=wasmExports["Y"];___cxa_decrement_exception_refcount=wasmExports["Z"];___cxa_increment_exception_refcount=wasmExports["_"];___cxa_can_catch=wasmExports["$"];___cxa_get_exception_ptr=wasmExports["aa"];memory=wasmMemory=wasmExports["N"];__indirect_function_table=wasmTable=wasmExports["S"]}var wasmImports={m:___cxa_begin_catch,o:___cxa_end_catch,a:___cxa_find_matching_catch_2,g:___cxa_find_matching_catch_3,u:___cxa_find_matching_catch_4,r:___cxa_find_matching_catch_6,M:___cxa_rethrow,n:___cxa_throw,b:___resumeException,I:__abort_js,J:__tzset_js,H:_emscripten_resize_heap,x:invoke_di,d:invoke_ii,h:invoke_iii,A:invoke_iiidd,c:invoke_iiii,k:invoke_iiiii,w:invoke_iiiiii,v:invoke_iiiiiii,F:invoke_iiiiiiii,C:invoke_iiiiiiiiii,j:invoke_v,i:invoke_vi,E:invoke_vid,G:invoke_viddddiiii,f:invoke_vii,z:invoke_viid,D:invoke_viiddddiii,l:invoke_viidi,e:invoke_viii,t:invoke_viiii,y:invoke_viiiid,p:invoke_viiiii,s:invoke_viiiiii,B:invoke_viiiiiii,K:invoke_viiiiiiiiiii,L:invoke_viiiiiiiiiiiiiiiii,q:_llvm_eh_typeid_for};function invoke_iiii(index,a1,a2,a3){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_ii(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_vii(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_v(index){var sp=stackSave();try{getWasmTableEntry(index)()}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_vi(index,a1){var sp=stackSave();try{getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_iii(index,a1,a2){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viii(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viiii(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_iiiii(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_iiiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_di(index,a1){var sp=stackSave();try{return getWasmTableEntry(index)(a1)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_vid(index,a1,a2){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_iiiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viiiiii(index,a1,a2,a3,a4,a5,a6){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viiiii(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viidi(index,a1,a2,a3,a4){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_iiidd(index,a1,a2,a3,a4){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viiddddiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viddddiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viid(index,a1,a2,a3){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_iiiiiiii(index,a1,a2,a3,a4,a5,a6,a7){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viiiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_viiiid(index,a1,a2,a3,a4,a5){var sp=stackSave();try{getWasmTableEntry(index)(a1,a2,a3,a4,a5)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}function invoke_iiiiiiiiii(index,a1,a2,a3,a4,a5,a6,a7,a8,a9){var sp=stackSave();try{return getWasmTableEntry(index)(a1,a2,a3,a4,a5,a6,a7,a8,a9)}catch(e){stackRestore(sp);if(!(e instanceof EmscriptenEH))throw e;_setThrew(1,0)}}async function run(){preRun();if(ABORT)return;initRuntime();postRun()}var wasmExports;wasmExports=await createWasm();await run();
|
|
2
|
+
;return Module}export default createFileViewerLibWpd;
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var v=[255,87,80,67],T=128*1024*1024,S=1e5,R=n=>v.every((e,r)=>n[r]===e),D=n=>{if(n.length<8)return 0;let e=new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(4,!0);return e>=16&&e<n.length?e:Math.min(16,n.length)},M=n=>{let e=[];for(let r=0;r<n.length;r+=1){let a=n[r];if(a===10||a===13){e.push(`
|
|
2
|
+
`);continue}if(a===9){e.push(" ");continue}if(a>=32&&a<=126){e.push(String.fromCharCode(a));continue}if(a>=128&&a<=207){e.push(new TextDecoder("windows-1252").decode(Uint8Array.of(a)));continue}a>=208&&e.push(" ")}return e.join("").replace(/[\t ]+/g," ").replace(/\n{3,}/g,`
|
|
3
|
+
|
|
4
|
+
`).trim()},A=n=>{if(n.byteLength>T)throw new Error("WordPerfect file exceeds the 128 MiB safety limit.");let e=new Uint8Array(n);if(!R(e))throw new Error("The extension does not match a WordPerfect WPC signature.");let r=D(e),a=e[10]||0,g=e[12]!==0;if(g)throw new Error("Encrypted WordPerfect documents are detected but cannot be decrypted.");let d=a>=6?"wp6":a>0?"wp5":"unknown",u=M(e.slice(r)).split(/\n+/).map(l=>l.trim()).filter(Boolean).slice(0,S);if(!u.length)throw new Error("No readable text was produced by the bounded WordPerfect fallback.");return{format:"wordperfect",generation:d,documentOffset:r,encrypted:g,engine:"bounded-fallback",paragraphs:u,structuredParagraphs:u.map(l=>({kind:"paragraph",runs:[{text:l,styles:[]}]})),tables:[],headers:[],footers:[],notes:[],metadata:{},warnings:["Limited text preview: the optional libwpd/librevenge WebAssembly parser is not active."]}};var E=class{constructor(e){this.bytes=e;this.offset=0}get remaining(){return this.bytes.length-this.offset}u8(){if(this.remaining<1)throw new Error("Truncated libwpd event stream.");return this.bytes[this.offset++]}bool(){let e=this.u8();if(e!==0&&e!==1)throw new Error("Invalid boolean in libwpd event stream.");return e===1}u32(){if(this.remaining<4)throw new Error("Truncated libwpd event stream.");let e=new DataView(this.bytes.buffer,this.bytes.byteOffset+this.offset,4).getUint32(0,!0);return this.offset+=4,e}i32(){let e=this.u32();return e>2147483647?e-4294967296:e}string(){let e=this.u32();if(e>134217728||e>this.remaining)throw new Error("Invalid string length in libwpd event stream.");let r=this.offset;return this.offset+=e,new TextDecoder().decode(this.bytes.subarray(r,r+e))}},L=(n,e)=>{if(!e)return"";let r=e;for(;r<n.length&&n[r]!==0&&r-e<16384;)r+=1;return new TextDecoder().decode(n.subarray(e,r))},H=n=>n[0]!==255||n[1]!==87||n[2]!==80||n[3]!==67?"unknown":(n[10]||0)>=2?"wp6":"wp5",B=(n,e)=>{let r=new E(n);if(r.u8()!==1)throw new Error("Unsupported libwpd event-stream version.");let a=r.u32();if(a>1e6)throw new Error("libwpd metadata count exceeds the safety limit.");let g={};for(let s=0;s<a;s+=1)g[r.string()]=r.string();let d=r.u32();if(d>1e6)throw new Error("libwpd event count exceeds the safety limit.");let t=[],u=[],l=[],w=[],m=[],i=t,c={kind:"paragraph",runs:[]},h=new Set,o,W,P,y,k,x=s=>{if(!s)return;if(k){k.text+=s;return}let b={text:s,styles:[...h]};o&&/^(?:https?:|mailto:)/i.test(o)&&(b.href=o),c.runs.push(b)},p=()=>{c.runs.map(b=>b.text).join("").trim()&&i.push({...c,list:W,runs:c.runs}),c={kind:"paragraph",runs:[]},W=void 0},f=(s,b)=>{h=new Set(h),b?h.add(s):h.delete(s)};for(let s=0;s<d;s+=1){let b=r.u8();switch(b){case 0:x(r.string());break;case 1:x(" ");break;case 2:x(" ");break;case 3:x(`
|
|
5
|
+
`);break;case 4:p();break;case 5:W={ordered:r.bool(),level:r.u8(),counter:r.u32()};break;case 6:p();break;case 7:c.kind="heading",c.level=r.u8();break;case 8:f("bold",!0);break;case 9:f("bold",!1);break;case 10:f("italic",!0);break;case 11:f("italic",!1);break;case 12:f("underline",!0);break;case 13:f("underline",!1);break;case 14:f("strikethrough",!0);break;case 15:f("strikethrough",!1);break;case 16:f("superscript",!0);break;case 17:f("superscript",!1);break;case 18:f("subscript",!0);break;case 19:f("subscript",!1);break;case 20:P={rows:[]},m.push(P);break;case 21:y=[],P?.rows.push(y),r.bool();break;case 22:k={text:"",column:r.i32(),colSpan:r.u32(),rowSpan:r.u32()},y?.push(k);break;case 23:y?.push({text:"",column:r.i32(),colSpan:1,rowSpan:1,covered:!0});break;case 24:k=void 0;break;case 25:y=void 0;break;case 26:P=void 0;break;case 27:p(),i=u;break;case 28:p(),i=t;break;case 29:p(),i=l;break;case 30:p(),i=t;break;case 31:p(),i=w,r.bool();break;case 32:p(),i=t;break;case 33:p(),i=w,r.string();break;case 34:p(),i=t;break;case 35:o=r.string();break;case 36:o=void 0;break;case 37:x(`[${r.string()}]`);break;default:throw new Error(`Unknown libwpd event tag ${b}.`)}}if(p(),r.remaining!==0)throw new Error("Unexpected trailing bytes in libwpd event stream.");return{format:"wordperfect",generation:H(e),documentOffset:e.length>=8?new DataView(e.buffer,e.byteOffset+4,4).getUint32(0,!0):0,encrypted:!1,engine:"libwpd-wasm",paragraphs:t.map(s=>s.runs.map(b=>b.text).join("")),structuredParagraphs:t,tables:m,headers:u,footers:l,notes:w,metadata:g,warnings:[]}},U=async(n,e,r,a)=>{let g=await import(e),d=a;if(!d){let o=await fetch(r,{credentials:"same-origin"});if(!o.ok)throw new Error(`libwpd WebAssembly returned HTTP ${o.status}.`);d=new Uint8Array(await o.arrayBuffer())}let t=await g.default({locateFile:o=>o.endsWith(".wasm")?r:o,wasmBinary:d}),u=new Uint8Array(n),l=t._malloc(u.length),w=t._malloc(4),m=t._malloc(4),i=t._malloc(4);t.HEAPU8.set(u,l),t.HEAPU32[w>>>2]=0,t.HEAPU32[m>>>2]=0,t.HEAPU32[i>>>2]=0;let c=0,h=0;try{if(!t._xberg_wpd_is_supported(l,u.length))throw new Error("libwpd does not recognize this WordPerfect document.");let o=t._xberg_wpd_extract_document(l,u.length,w,m,i);c=t.HEAPU32[w>>>2];let W=t.HEAPU32[m>>>2];if(h=t.HEAPU32[i>>>2],o===6)throw new Error("Encrypted WordPerfect documents are detected but cannot be decrypted.");if(o!==0||!c||!W){let P=L(t.HEAPU8,h);throw new Error(`libwpd could not parse the document${P?`: ${P}`:""}.`)}return B(t.HEAPU8.slice(c,c+W),u)}finally{c&&t._xberg_wpd_free_string(c),h&&t._xberg_wpd_free_string(h),t._free(l),t._free(w),t._free(m),t._free(i)}};var _=self;_.addEventListener("message",async n=>{let{id:e,buffer:r}=n.data;try{let a=new URL("libwpd.mjs",_.location.href).href,g=n.data.wasmUrl||new URL("libwpd.wasm",_.location.href).href,d;try{d=await U(r,a,g)}catch(t){d=A(r),d.warnings.unshift(`Structured libwpd WebAssembly parsing failed: ${t instanceof Error?t.message:String(t)}`)}_.postMessage({id:e,ok:!0,document:d})}catch(a){_.postMessage({id:e,ok:!1,error:a instanceof Error?a.message:String(a)})}});
|