Skip to content

Commit

Permalink
refactor: export 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hahnlee committed Apr 10, 2024
1 parent f0b062a commit 647ae66
Show file tree
Hide file tree
Showing 45 changed files with 126 additions and 195 deletions.
4 changes: 2 additions & 2 deletions packages/parser/src/__tests__/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { describe, it } from 'node:test'
import * as fs from 'fs'
import * as path from 'path'

import HWPDocument from '../models/document.js'
import HWPVersion from '../models/version.js'
import { HWPDocument } from '../models/document.js'
import { HWPVersion } from '../models/version.js'
import { parse } from '../parse.js'

const reportFilePath = path.join(import.meta.dirname, 'data', 'basics-report.hwp')
Expand Down
4 changes: 1 addition & 3 deletions packages/parser/src/constants/fill-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
* limitations under the License.
*/

enum FillType {
export enum FillType {
None = 0x00000000,
Single = 0x00000001,
Image = 0x00000002,
Gradation = 0x00000004,
}

export default FillType
28 changes: 13 additions & 15 deletions packages/parser/src/doc-info-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
import { CFB$Container, find } from 'cfb'
import { inflate } from 'pako'

import FillType from './constants/fill-type.js'
import { FillType } from './constants/fill-type.js'
import { DocInfoTagID } from './constants/tag-id.js'
import BinData, { BinDataCompress } from './models/bin-data.js'
import ByteReader from './utils/byte-reader.js'
import CharShape from './models/char-shape.js'
import DocInfo from './models/doc-info.js'
import FontFace from './models/font-face.js'
import ParagraphShape from './models/paragraph-shape.js'
import { BinData, BinDataCompress } from './models/bin-data.js'
import { ByteReader } from './utils/byte-reader.js'
import { CharShape } from './models/char-shape.js'
import { DocInfo } from './models/doc-info.js'
import { FontFace } from './models/font-face.js'
import { ParagraphShape } from './models/paragraph-shape.js'
import { getRGB, getFlag, getBitValue } from './utils/bit-utils.js'
import BorderFill from './models/border-fill.js'
import HWPRecord from './models/record.js'
import Panose from './models/panose.js'
import parseRecordTree from './parse-record.js'
import HWPHeader from './models/header.js'
import { BorderFill } from './models/border-fill.js'
import { HWPRecord } from './models/record.js'
import { Panose } from './models/panose.js'
import { parseRecordTree } from './parse-record.js'
import { HWPHeader } from './models/header.js'

class DocInfoParser {
export class DocInfoParser {
private record: HWPRecord

private result = new DocInfo()
Expand Down Expand Up @@ -315,5 +315,3 @@ class DocInfoParser {
return this.result
}
}

export default DocInfoParser
26 changes: 13 additions & 13 deletions packages/parser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
*/

// FIXME: (@hanlee) export 고치기
export { type Control } from './models/controls/index.js'
export { type ShapeControls } from './models/controls/shapes/index.js'
export { default as Section } from './models/section.js'
export { default as Paragraph } from './models/paragraph.js'
export { default as LineSegment } from './models/line-segment.js'
export { default as ShapePointer } from './models/shape-pointer.js'
export { CharType } from './models/char.js'
export { default as TableControl, type TableColumnOption } from './models/controls/table.js'
export { default as ParagraphList } from './models/paragraph-list.js'
export { CommonCtrlID } from './constants/ctrl-id.js'
export { default as HWPDocument } from './models/document.js'
export { isTable, isShape, isPicture } from './utils/control-util.js'
export { type RGB } from './types/color.js'
export * from './models/controls/index.js'
export * from './models/controls/shapes/index.js'
export * from './models/section.js'
export * from './models/paragraph.js'
export * from './models/line-segment.js'
export * from './models/shape-pointer.js'
export * from './models/char.js'
export * from './models/controls/table.js'
export * from './models/paragraph-list.js'
export * from './constants/ctrl-id.js'
export * from './models/document.js'
export * from './utils/control-util.js'
export * from './types/color.js'

export * from './parse.js'
3 changes: 2 additions & 1 deletion packages/parser/src/models/__tests__/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
import * as assert from 'node:assert'
import { describe, it } from 'node:test'
import HWPVersion from '../version.js'

import { HWPVersion } from '../version.js'

describe('HWPVersion', () => {
it('should make correct version string', () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/parser/src/models/bin-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface BinProperties {
status: BinDataStatus
}

class BinData {
export class BinData {
properties: BinProperties

extension: string
Expand All @@ -52,5 +52,3 @@ class BinData {
this.payload = payload
}
}

export default BinData
4 changes: 1 addition & 3 deletions packages/parser/src/models/border-fill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface BorderFillStyle {
bottom: BorerStyle
}

class BorderFill {
export class BorderFill {
// TODO: (@hahnlee) getter & setter 만들기
attribute: number

Expand All @@ -46,5 +46,3 @@ class BorderFill {
this.style = style
}
}

export default BorderFill
4 changes: 1 addition & 3 deletions packages/parser/src/models/carat-location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
* limitations under the License.
*/

class CaratLocation {
export class CaratLocation {
listId : number = 0

paragraphId: number = 0

// 문단 내에서의 글자 단위 위치
charIndex: number = 0
}

export default CaratLocation
4 changes: 1 addition & 3 deletions packages/parser/src/models/char-shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { RGB } from '../types/color.js'

type SupportedLocaleOptions = [number, number, number, number, number, number, number]

class CharShape {
export class CharShape {
fontId: SupportedLocaleOptions

fontScale: SupportedLocaleOptions
Expand Down Expand Up @@ -80,5 +80,3 @@ class CharShape {
this.shadowColor = getRGB(shadowColor)
}
}

export default CharShape
4 changes: 1 addition & 3 deletions packages/parser/src/models/char.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export enum CharType {
Extened,
}

class HWPChar {
export class HWPChar {
type: CharType

value: number | string
Expand All @@ -30,5 +30,3 @@ class HWPChar {
this.value = value
}
}

export default HWPChar
2 changes: 1 addition & 1 deletion packages/parser/src/models/controls/column.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export enum ColumnDirection {
Justify,
}

export default class ColumnControl implements BaseControl {
export class ColumnControl implements BaseControl {
id: number = 0

type: ColumnType = ColumnType.Normal
Expand Down
4 changes: 1 addition & 3 deletions packages/parser/src/models/controls/common-attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export enum ObjectType {
Equation,
}

class CommonAttribute {
export class CommonAttribute {
isTextLike: boolean = false

isApplyLineSpace: boolean = false
Expand Down Expand Up @@ -183,5 +183,3 @@ class CommonAttribute {
return null
}
}

export default CommonAttribute
6 changes: 2 additions & 4 deletions packages/parser/src/models/controls/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import CommonAttribute from './common-attribute.js'
import { CommonAttribute } from './common-attribute.js'
import { BaseControl } from './base.js'

class CommonControl implements BaseControl {
export class CommonControl implements BaseControl {
id: number = 0

attribute = new CommonAttribute()
Expand All @@ -38,5 +38,3 @@ class CommonControl implements BaseControl {

split: number = 0
}

export default CommonControl
4 changes: 2 additions & 2 deletions packages/parser/src/models/controls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type TableControl from './table.js'
import type { TableControl } from './table.js'
import type { ShapeControls } from './shapes/index.js'
import type { BaseControl } from './base.js'
import type ColumnControl from './column.js'
import type { ColumnControl } from './column.js'

export type Control = (
BaseControl |
Expand Down
4 changes: 2 additions & 2 deletions packages/parser/src/models/controls/shapes/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type ShapeControl from './shape.js'
import type Picture from './picture.js'
import { type ShapeControl } from './shape.js'
import { type Picture } from './picture.js'

export type PictureControl = ShapeControl<Picture>

Expand Down
4 changes: 1 addition & 3 deletions packages/parser/src/models/controls/shapes/picture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

interface Picture {
export interface Picture {
binID: number
}

export default Picture
8 changes: 3 additions & 5 deletions packages/parser/src/models/controls/shapes/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
* limitations under the License.
*/

import ParagraphList from '../../paragraph-list.js'
import CommonControl from '../common.js'
import { ParagraphList } from '../../paragraph-list.js'
import { CommonControl } from '../common.js'

class ShapeControl<P> extends CommonControl {
export class ShapeControl<P> extends CommonControl {
type: number = 0

info: P | null = null

content: ParagraphList<null>[] = []
}

export default ShapeControl
8 changes: 3 additions & 5 deletions packages/parser/src/models/controls/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import ParagraphList from '../paragraph-list.js'
import CommonControl from './common.js'
import { ParagraphList } from '../paragraph-list.js'
import { CommonControl } from './common.js'

export interface TableColumnOption {
column: number
Expand All @@ -28,7 +28,7 @@ export interface TableColumnOption {
borderFillID?: number
}

class TableControl extends CommonControl {
export class TableControl extends CommonControl {
// TODO: (@hahnlee) setter 만들기
tableAttribute: number = 0

Expand All @@ -48,5 +48,3 @@ class TableControl extends CommonControl {
this.content[row].push(list)
}
}

export default TableControl
22 changes: 10 additions & 12 deletions packages/parser/src/models/doc-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
* limitations under the License.
*/

import CharShape from './char-shape.js'
import FontFace from './font-face.js'
import BinData from './bin-data.js'
import BorderFill from './border-fill.js'
import ParagraphShape from './paragraph-shape.js'
import StartingIndex from './starting-index.js'
import CaratLocation from './carat-location.js'
import LayoutCompatibility from './layout-compatibility.js'

class DocInfo {
import { CharShape } from './char-shape.js'
import { FontFace } from './font-face.js'
import { BinData } from './bin-data.js'
import { BorderFill } from './border-fill.js'
import { ParagraphShape } from './paragraph-shape.js'
import { StartingIndex } from './starting-index.js'
import { CaratLocation } from './carat-location.js'
import { LayoutCompatibility } from './layout-compatibility.js'

export class DocInfo {
sectionSize: number = 0

charShapes: CharShape[] = []
Expand All @@ -48,5 +48,3 @@ class DocInfo {
return this.charShapes[index]
}
}

export default DocInfo
10 changes: 4 additions & 6 deletions packages/parser/src/models/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* limitations under the License.
*/

import DocInfo from './doc-info.js'
import HWPHeader from './header.js'
import Section from './section.js'
import { DocInfo } from './doc-info.js'
import { HWPHeader } from './header.js'
import { Section } from './section.js'

class HWPDocument {
export class HWPDocument {
header: HWPHeader

info: DocInfo
Expand All @@ -35,5 +35,3 @@ class HWPDocument {
this.sections = sections
}
}

export default HWPDocument
6 changes: 2 additions & 4 deletions packages/parser/src/models/font-face.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

import Panose from './panose.js'
import { Panose } from './panose.js'

class FontFace {
export class FontFace {
name: string = ''

alternative: string = ''
Expand Down Expand Up @@ -44,5 +44,3 @@ class FontFace {
return result.join(',')
}
}

export default FontFace
6 changes: 2 additions & 4 deletions packages/parser/src/models/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import HWPVersion from './version.js'
import { HWPVersion } from './version.js'

interface Properties {
/** 압축 여부 */
Expand Down Expand Up @@ -75,7 +75,7 @@ interface Properties {
/**
* @see https://github.com/hahnlee/hwp.js/blob/master/docs/hwp/5.0/FileHeader.md
*/
class HWPHeader {
export class HWPHeader {
version: HWPVersion

signature: string
Expand All @@ -88,5 +88,3 @@ class HWPHeader {
this.properties = properties
}
}

export default HWPHeader
Loading

0 comments on commit 647ae66

Please sign in to comment.