hwpkit-dev 0.0.2 ā 0.0.5
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/ .npmignore +4 -1
- package/README.md +44 -7
- package/dist/index.d.mts +46 -16
- package/dist/index.d.ts +46 -16
- package/dist/index.js +3964 -1227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3964 -1227
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/playground/index.html +346 -0
- package/playground/main.ts +302 -0
- package/playground/vite.config.ts +16 -0
- package/src/contract/decoder.ts +1 -0
- package/src/contract/encoder.ts +6 -1
- package/src/core/BaseDecoder.ts +118 -0
- package/src/core/BaseEncoder.ts +146 -0
- package/src/decoders/docx/DocxDecoder.ts +743 -151
- package/src/decoders/html/HtmlDecoder.ts +366 -0
- package/src/decoders/hwp/HwpScanner.ts +478 -193
- package/src/decoders/hwpx/HwpxDecoder.ts +796 -297
- package/src/decoders/md/MdDecoder.ts +4 -4
- package/src/encoders/docx/DocxEncoder.ts +549 -240
- package/src/encoders/html/HtmlEncoder.ts +17 -19
- package/src/encoders/hwp/HwpEncoder.ts +1643 -890
- package/src/encoders/hwpx/HwpxEncoder.ts +1626 -472
- package/src/encoders/hwpx/constants.ts +148 -0
- package/src/encoders/hwpx/utils.ts +198 -0
- package/src/encoders/md/MdEncoder.ts +20 -15
- package/src/model/builders.ts +4 -4
- package/src/model/doc-props.ts +24 -10
- package/src/model/doc-tree.ts +13 -5
- package/src/pipeline/Pipeline.ts +7 -3
- package/src/pipeline/registry.ts +13 -2
- package/src/safety/StyleBridge.ts +51 -6
- package/src/toolkit/ArchiveKit.ts +56 -0
- package/src/toolkit/StyleMapper.ts +221 -0
- package/src/toolkit/UnitConverter.ts +138 -0
- package/src/toolkit/XmlKit.ts +0 -5
- package/hwp-analyze.ts +0 -90
- package/inspect-doc.ts +0 -57
- package/output_test.hwp +0 -0
- package/test-docx-to-hwp.ts +0 -45
package/test-docx-to-hwp.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Pipeline } from './src/index';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
|
|
4
|
-
async function testDocxToHwp() {
|
|
5
|
-
const inputPath = './data/sample/sample4_input.docx';
|
|
6
|
-
console.log(`\nš Testing DOCX ā HWP conversion from: ${inputPath}`);
|
|
7
|
-
const data = fs.readFileSync(inputPath);
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
const pipeline = Pipeline.open(data, 'docx');
|
|
11
|
-
|
|
12
|
-
console.log('Attempting to convert to HWP...');
|
|
13
|
-
const result = await pipeline.to('hwp');
|
|
14
|
-
|
|
15
|
-
if (result.ok) {
|
|
16
|
-
console.log(`ā
Success! HWP output: ${result.data.length} bytes`);
|
|
17
|
-
|
|
18
|
-
// Save to file for verification
|
|
19
|
-
fs.writeFileSync('./output_test.hwp', result.data);
|
|
20
|
-
console.log('Saved to: ./output_test.hwp');
|
|
21
|
-
|
|
22
|
-
// Verify by converting back to MD
|
|
23
|
-
console.log('\n--- Verifying by converting back to MD ---');
|
|
24
|
-
const verifyPipeline = Pipeline.open(result.data, 'hwp');
|
|
25
|
-
const mdResult = await verifyPipeline.to('md');
|
|
26
|
-
if (mdResult.ok) {
|
|
27
|
-
const mdText = new TextDecoder().decode(mdResult.data);
|
|
28
|
-
console.log(`Verification MD output: ${mdText.length} bytes`);
|
|
29
|
-
console.log('First 500 chars:', mdText.substring(0, 500));
|
|
30
|
-
} else {
|
|
31
|
-
console.log(`Verification failed: ${mdResult.error}`);
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
console.log(`ā Failed: ${result.error}`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return result.ok;
|
|
38
|
-
} catch (e: any) {
|
|
39
|
-
console.error(`ā EXCEPTION: ${e.message}`);
|
|
40
|
-
console.error(e.stack);
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
testDocxToHwp().catch(console.error);
|