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.
Files changed (42) hide show
  1. package/ .npmignore +4 -1
  2. package/README.md +44 -7
  3. package/dist/index.d.mts +46 -16
  4. package/dist/index.d.ts +46 -16
  5. package/dist/index.js +3964 -1227
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +3964 -1227
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +2 -1
  10. package/playground/index.html +346 -0
  11. package/playground/main.ts +302 -0
  12. package/playground/vite.config.ts +16 -0
  13. package/src/contract/decoder.ts +1 -0
  14. package/src/contract/encoder.ts +6 -1
  15. package/src/core/BaseDecoder.ts +118 -0
  16. package/src/core/BaseEncoder.ts +146 -0
  17. package/src/decoders/docx/DocxDecoder.ts +743 -151
  18. package/src/decoders/html/HtmlDecoder.ts +366 -0
  19. package/src/decoders/hwp/HwpScanner.ts +478 -193
  20. package/src/decoders/hwpx/HwpxDecoder.ts +796 -297
  21. package/src/decoders/md/MdDecoder.ts +4 -4
  22. package/src/encoders/docx/DocxEncoder.ts +549 -240
  23. package/src/encoders/html/HtmlEncoder.ts +17 -19
  24. package/src/encoders/hwp/HwpEncoder.ts +1643 -890
  25. package/src/encoders/hwpx/HwpxEncoder.ts +1626 -472
  26. package/src/encoders/hwpx/constants.ts +148 -0
  27. package/src/encoders/hwpx/utils.ts +198 -0
  28. package/src/encoders/md/MdEncoder.ts +20 -15
  29. package/src/model/builders.ts +4 -4
  30. package/src/model/doc-props.ts +24 -10
  31. package/src/model/doc-tree.ts +13 -5
  32. package/src/pipeline/Pipeline.ts +7 -3
  33. package/src/pipeline/registry.ts +13 -2
  34. package/src/safety/StyleBridge.ts +51 -6
  35. package/src/toolkit/ArchiveKit.ts +56 -0
  36. package/src/toolkit/StyleMapper.ts +221 -0
  37. package/src/toolkit/UnitConverter.ts +138 -0
  38. package/src/toolkit/XmlKit.ts +0 -5
  39. package/hwp-analyze.ts +0 -90
  40. package/inspect-doc.ts +0 -57
  41. package/output_test.hwp +0 -0
  42. package/test-docx-to-hwp.ts +0 -45
@@ -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);