hwpkit-dev 0.0.1
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 +11 -0
- package/README.md +223 -0
- package/dist/index.d.mts +313 -0
- package/dist/index.d.ts +317 -0
- package/dist/index.js +3546 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3479 -0
- package/dist/index.mjs.map +1 -0
- package/license.md +136 -0
- package/package.json +45 -0
- package/src/contract/decoder.ts +7 -0
- package/src/contract/encoder.ts +7 -0
- package/src/contract/result.ts +21 -0
- package/src/decoders/docx/DocxDecoder.ts +986 -0
- package/src/decoders/hwp/HwpScanner.ts +809 -0
- package/src/decoders/hwpx/HwpxDecoder.ts +759 -0
- package/src/decoders/md/MdDecoder.ts +180 -0
- package/src/encoders/docx/DocxEncoder.ts +710 -0
- package/src/encoders/hwp/HwpEncoder.ts +711 -0
- package/src/encoders/hwpx/HwpxEncoder.ts +770 -0
- package/src/encoders/md/MdEncoder.ts +108 -0
- package/src/index.ts +47 -0
- package/src/model/builders.ts +66 -0
- package/src/model/doc-props.ts +138 -0
- package/src/model/doc-tree.ts +90 -0
- package/src/pipeline/Pipeline.ts +71 -0
- package/src/pipeline/registry.ts +18 -0
- package/src/safety/ShieldedParser.ts +91 -0
- package/src/safety/StyleBridge.ts +106 -0
- package/src/toolkit/ArchiveKit.ts +150 -0
- package/src/toolkit/BinaryKit.ts +187 -0
- package/src/toolkit/TextKit.ts +57 -0
- package/src/toolkit/XmlKit.ts +91 -0
- package/src/walk/TreeWalker.ts +42 -0
- package/src/walk/tree-ops.ts +26 -0
- package/tsconfig.json +23 -0
- package/tsup.config.ts +12 -0
package/license.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
```
|
|
2
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
3
|
+
Version 2.1, February 1999
|
|
4
|
+
```
|
|
5
|
+
|
|
6
|
+
Copyright (C) 2026 INMD1
|
|
7
|
+
|
|
8
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
9
|
+
of this license document, but changing it is not allowed.
|
|
10
|
+
|
|
11
|
+
[This LGPL license applies to the project **hwpkit** developed by **INMD1**.]
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
### Preamble
|
|
16
|
+
|
|
17
|
+
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU Lesser General Public Licenses are intended to guarantee your freedom to share and change free software—to make sure the software is free for all its users.
|
|
18
|
+
|
|
19
|
+
This license, the Lesser General Public License, applies to some specially designated software packages—typically libraries—of the Free Software Foundation and other authors who decide to use it. You can use it too.
|
|
20
|
+
|
|
21
|
+
When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software and use pieces of it in new free programs, and that you are informed that you can do these things.
|
|
22
|
+
|
|
23
|
+
To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it.
|
|
24
|
+
|
|
25
|
+
For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files so that users can relink them with the library after making changes.
|
|
26
|
+
|
|
27
|
+
We protect your rights with a two-step method:
|
|
28
|
+
(1) we copyright the library, and
|
|
29
|
+
(2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
34
|
+
|
|
35
|
+
**0. Definitions.**
|
|
36
|
+
This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder saying it may be distributed under the terms of this Lesser General Public License.
|
|
37
|
+
|
|
38
|
+
"Library" refers to any such software library or work.
|
|
39
|
+
"Work based on the Library" means either the Library or any derivative work under copyright law.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
**1. You may copy and distribute verbatim copies of the Library's complete source code** as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
**2. You may modify your copy or copies of the Library** or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications provided that you also meet all of these conditions:
|
|
48
|
+
|
|
49
|
+
* a) The modified work must itself be a software library.
|
|
50
|
+
* b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change.
|
|
51
|
+
* c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License.
|
|
52
|
+
* d) If a facility refers to a function or table supplied by an application program, the facility must still operate if the application does not supply it.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
**3. You may opt to apply the terms of the ordinary GNU General Public License** instead of this License to a given copy of the Library.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
**4. You may copy and distribute the Library (or a portion or derivative of it) in object code or executable form** under the terms of Sections 1 and 2 provided that you accompany it with the complete corresponding machine-readable source code.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
**5. A program that contains no derivative of any portion of the Library** but is designed to work with the Library by being compiled or linked with it is called a "work that uses the Library". Such a work is not a derivative work of the Library, and therefore falls outside the scope of this License.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
**6. As an exception**, you may combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer’s own use and reverse engineering for debugging such modifications.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
**7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License**, and distribute such a combined library.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
**8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License.** Any attempt otherwise is void and will automatically terminate your rights under this License.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
**9. You are not required to accept this License**, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
**10. Each time you redistribute the Library**, the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
**11. If, as a consequence of a court judgment or allegation of patent infringement**, conditions are imposed on you that contradict the conditions of this License, they do not excuse you from the conditions of this License.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
**12. If the distribution and/or use of the Library is restricted in certain countries** either by patents or by copyrighted interfaces, the original copyright holder may add an explicit geographical distribution limitation.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
**13. The Free Software Foundation may publish revised and/or new versions** of the Lesser General Public License from time to time.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
**14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible**, write to the author to ask for permission.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## NO WARRANTY
|
|
105
|
+
|
|
106
|
+
**15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY** for the Library, to the extent permitted by applicable law.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
**16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING** will any copyright holder be liable for damages arising out of the use or inability to use the Library.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## END OF TERMS AND CONDITIONS
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### How to Apply These Terms to Your New Libraries
|
|
119
|
+
|
|
120
|
+
To apply these terms to your own library, attach the following notices:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
TO — Copyright (C) 2026 INMD1
|
|
124
|
+
|
|
125
|
+
This library is free software; you can redistribute it and/or
|
|
126
|
+
modify it under the terms of the GNU Lesser General Public
|
|
127
|
+
License as published by the Free Software Foundation; either
|
|
128
|
+
version 2.1 of the License, or (at your option) any later version.
|
|
129
|
+
|
|
130
|
+
This library is distributed in the hope that it will be useful,
|
|
131
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
132
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
133
|
+
See the GNU Lesser General Public License for more details.
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hwpkit-dev",
|
|
3
|
+
"description": "HWP/HWPX/DOCX/MD 양방향 문서 변환 라이브러리",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "INMD1",
|
|
7
|
+
"email": "lyw514549@gmail.com",
|
|
8
|
+
"github": "https://github.com/INMD1"
|
|
9
|
+
},
|
|
10
|
+
"license": "LGPL-2.1",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/INMD1/hwpkit.git"
|
|
14
|
+
},
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"module": "dist/index.mjs",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"dev": "tsup --watch",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"playground": "vite --config playground/vite.config.ts"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"pako": "^2.1.0",
|
|
35
|
+
"saxes": "^6.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20.11.24",
|
|
39
|
+
"@types/pako": "^2.0.3",
|
|
40
|
+
"tsup": "^8.0.0",
|
|
41
|
+
"typescript": "^5.5.0",
|
|
42
|
+
"vite": "^5.4.21",
|
|
43
|
+
"vitest": "^2.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type Outcome<T> = Ok<T> | Fail;
|
|
2
|
+
|
|
3
|
+
export interface Ok<T> {
|
|
4
|
+
ok: true;
|
|
5
|
+
data: T;
|
|
6
|
+
warns: string[];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Fail {
|
|
10
|
+
ok: false;
|
|
11
|
+
error: string;
|
|
12
|
+
warns: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function succeed<T>(data: T, warns: string[] = []): Ok<T> {
|
|
16
|
+
return { ok: true, data, warns };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function fail(error: string, warns: string[] = []): Fail {
|
|
20
|
+
return { ok: false, error, warns };
|
|
21
|
+
}
|