Skip to content

Commit

Permalink
refatror: import 및 export 경로 변경
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 647ae66
Author: hahnlee <[email protected]>
Date:   Wed Apr 10 18:24:33 2024 +0900

    refactor: export 수정

commit f0b062a
Author: hahnlee <[email protected]>
Date:   Wed Apr 10 18:06:07 2024 +0900

    refactor: 파일 경로 변경
  • Loading branch information
hahnlee committed Apr 10, 2024
1 parent 5f6b071 commit 73b7083
Show file tree
Hide file tree
Showing 50 changed files with 137 additions and 206 deletions.
6 changes: 3 additions & 3 deletions packages/parser/src/__tests__/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ 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', 'basicsReport.hwp')
const reportFilePath = path.join(import.meta.dirname, 'data', 'basics-report.hwp')
const reportFile = fs.readFileSync(reportFilePath)

describe('parse', () => {
Expand Down
File renamed without changes.
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
File renamed without changes.
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/fillType.js'
import { DocInfoTagID } from './constants/tagID.js'
import BinData, { BinDataCompress } from './models/binData.js'
import ByteReader from './utils/byteReader.js'
import CharShape from './models/charShape.js'
import DocInfo from './models/docInfo.js'
import FontFace from './models/fontFace.js'
import ParagraphShape from './models/paragraphShape.js'
import { getRGB, getFlag, getBitValue } from './utils/bitUtils.js'
import BorderFill from './models/borderFill.js'
import HWPRecord from './models/record.js'
import Panose from './models/panose.js'
import parseRecordTree from './parseRecord.js'
import HWPHeader from './models/header.js'

class DocInfoParser {
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 { 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'

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/lineSegment.js'
export { default as ShapePointer } from './models/shapePointer.js'
export { CharType } from './models/char.js'
export { default as TableControl, type TableColumnOption } from './models/controls/table.js'
export { default as ParagraphList } from './models/paragraphList.js'
export { CommonCtrlID } from './constants/ctrlID.js'
export { default as HWPDocument } from './models/document.js'
export { isTable, isShape, isPicture } from './utils/controlUtil.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
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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

import { getRGB } from '../utils/bitUtils.js'
import { getRGB } from '../utils/bit-utils.js'
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
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 './commonAttribute.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 '../../paragraphList.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 '../paragraphList.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
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
* limitations under the License.
*/

import CharShape from './charShape.js'
import FontFace from './fontFace.js'
import BinData from './binData.js'
import BorderFill from './borderFill.js'
import ParagraphShape from './paragraphShape.js'
import StartingIndex from './startingIndex.js'
import CaratLocation from './caratLocation.js'
import LayoutCompatibility from './layoutCompatibility.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 './docInfo.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
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
Loading

0 comments on commit 73b7083

Please sign in to comment.