@things-factory/board-import 10.0.0-beta.72 → 10.0.0-beta.74
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/dist-server/service/converters/generic-to.d.ts +7 -21
- package/dist-server/service/converters/generic-to.js +14 -24
- package/dist-server/service/converters/generic-to.js.map +1 -1
- package/dist-server/service/index.d.ts +2 -2
- package/dist-server/service/index.js +1 -2
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/service/converters/generic-to.test.ts +14 -54
- package/server/service/converters/generic-to.ts +14 -60
- package/server/service/index.ts +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/board-import",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.74",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"things-factory": true,
|
|
6
6
|
"author": "heartyoh",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"@things-factory/shell": "^10.0.0-beta.72",
|
|
32
32
|
"dxf-parser": "^1.1.2"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "589dd8dab5bb2db400e5f10a1f455c3fb69bf9f4"
|
|
35
35
|
}
|
|
@@ -6,14 +6,27 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import {
|
|
8
8
|
convertPlaceholderTo,
|
|
9
|
-
attachGlbToPlaceholder,
|
|
10
9
|
isPlaceholderType,
|
|
11
10
|
CORE_PLACEHOLDER_TYPES
|
|
12
11
|
} from './generic-to'
|
|
12
|
+
import { GENERIC_OBJECT_TYPE } from '../pipeline/stage2-mapping'
|
|
13
13
|
|
|
14
14
|
// 호출자가 도메인 추상까지 인정하는 경우의 fixtures.
|
|
15
15
|
const EXTRA = ['GenericTransport', 'GenericFacility'] as const
|
|
16
16
|
|
|
17
|
+
// ── 계약 어설션 ─────────────────────────────────────────────────────
|
|
18
|
+
// things-scene 의 CORE_PLACEHOLDER_TYPES 와 mirror. client/server 경계로
|
|
19
|
+
// 직접 import 불가 — 이 테스트가 양쪽 값 일치를 보증.
|
|
20
|
+
describe('CORE_PLACEHOLDER_TYPES contract', () => {
|
|
21
|
+
test('GENERIC_OBJECT_TYPE 은 반드시 placeholder 고정', () => {
|
|
22
|
+
expect(GENERIC_OBJECT_TYPE).toBe('placeholder')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('CORE_PLACEHOLDER_TYPES 는 [placeholder] 고정 — things-scene 과 동기화', () => {
|
|
26
|
+
expect(Array.from(CORE_PLACEHOLDER_TYPES)).toEqual(['placeholder'])
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
17
30
|
describe('isPlaceholderType', () => {
|
|
18
31
|
test('코어 type 들은 인정', () => {
|
|
19
32
|
for (const t of CORE_PLACEHOLDER_TYPES) {
|
|
@@ -90,56 +103,3 @@ describe('convertPlaceholderTo', () => {
|
|
|
90
103
|
})
|
|
91
104
|
})
|
|
92
105
|
|
|
93
|
-
describe('attachGlbToPlaceholder', () => {
|
|
94
|
-
const base = {
|
|
95
|
-
type: 'placeholder',
|
|
96
|
-
id: 'a',
|
|
97
|
-
left: 0,
|
|
98
|
-
top: 0,
|
|
99
|
-
width: 100,
|
|
100
|
-
height: 100
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
test('placeholder 는 type 유지 + src set', () => {
|
|
104
|
-
const r = attachGlbToPlaceholder(base as any, { src: '/glb/foo.glb' }) as any
|
|
105
|
-
expect(r.type).toBe('placeholder')
|
|
106
|
-
expect(r.src).toBe('/glb/foo.glb')
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test('autoFit 옵션 전파', () => {
|
|
110
|
-
const r = attachGlbToPlaceholder(base as any, {
|
|
111
|
-
src: '/glb/foo.glb',
|
|
112
|
-
autoFit: true
|
|
113
|
-
}) as any
|
|
114
|
-
expect(r.autoFit).toBe(true)
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
test('convertedFrom 메타 없음', () => {
|
|
118
|
-
const r = attachGlbToPlaceholder(base as any, { src: '/glb/foo.glb' }) as any
|
|
119
|
-
expect(r.convertedFrom).toBeUndefined()
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
test('도메인 추상 (extraPlaceholderTypes) 은 type 유지', () => {
|
|
123
|
-
const tx = { ...base, type: 'GenericTransport' }
|
|
124
|
-
const r = attachGlbToPlaceholder(tx as any, {
|
|
125
|
-
src: '/glb/forklift.glb',
|
|
126
|
-
extraPlaceholderTypes: ['GenericTransport']
|
|
127
|
-
}) as any
|
|
128
|
-
expect(r.type).toBe('GenericTransport')
|
|
129
|
-
expect(r.src).toBe('/glb/forklift.glb')
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
test('명시 toType 지정 시 그것으로', () => {
|
|
133
|
-
const r = attachGlbToPlaceholder(base as any, {
|
|
134
|
-
src: '/glb/foo.glb',
|
|
135
|
-
toType: 'gltf-object'
|
|
136
|
-
}) as any
|
|
137
|
-
expect(r.type).toBe('gltf-object')
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
test('placeholder 가 아닌 type 은 throw', () => {
|
|
141
|
-
expect(() =>
|
|
142
|
-
attachGlbToPlaceholder({ type: 'rect', id: 'x' } as any, { src: '/glb/foo.glb' })
|
|
143
|
-
).toThrow(/not a generic placeholder/)
|
|
144
|
-
})
|
|
145
|
-
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generic placeholder → 도메인 컴포넌트 변환.
|
|
3
3
|
*
|
|
4
|
-
* Import 시 매칭되지 않은 entity 는
|
|
5
|
-
* 모델러 UI 에서 "Convert to ..." 액션으로
|
|
6
|
-
* morph 한다. `placeholder` 는 GltfComponent mixin 을 갖고 있어 GLB attach 시 type 유지.
|
|
4
|
+
* Import 시 매칭되지 않은 entity 는 `placeholder` 타입으로 보드에 배치된다.
|
|
5
|
+
* 사용자가 사후에 모델러 UI 에서 "Convert to ..." 액션으로 도메인 컴포넌트로 변환.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
* - `placeholder` — 도메인 비종속
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* 아키텍처 원칙:
|
|
8
|
+
* - `placeholder` — 도메인 비종속 임시 추상. 다른 type 으로 변환하는 기능만.
|
|
9
|
+
* GLB 지원 없음 (GltfComponent mixin 제거됨).
|
|
10
|
+
* - 도메인 generic 추상 (GenericTransport, GenericFacility 등) — 영구 도메인 추상.
|
|
11
|
+
* GLB 바디를 직접 채우는 방식으로 사용. 변환 대상 아님.
|
|
12
12
|
*
|
|
13
13
|
* 변환 시:
|
|
14
14
|
* - 좌표/크기/회전 보존
|
|
@@ -32,7 +32,13 @@ export interface ConvertOptions {
|
|
|
32
32
|
extraPlaceholderTypes?: ReadonlyArray<string>
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* things-scene 코어가 등록한 도메인 비종속 placeholder type.
|
|
37
|
+
*
|
|
38
|
+
* @sync things-scene/src/components/generic-placeholders.ts CORE_PLACEHOLDER_TYPES
|
|
39
|
+
* client/server 경계로 직접 import 불가 — 값을 바꾸면 양쪽 동시 수정 필수.
|
|
40
|
+
* 계약은 generic-to.test.ts 의 'CORE_PLACEHOLDER_TYPES contract' 어설션으로 보증.
|
|
41
|
+
*/
|
|
36
42
|
export const CORE_PLACEHOLDER_TYPES = [GENERIC_OBJECT_TYPE] as const
|
|
37
43
|
|
|
38
44
|
export function isPlaceholderType(
|
|
@@ -98,58 +104,6 @@ export function convertPlaceholderTo(
|
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
|
|
101
|
-
/**
|
|
102
|
-
* Generic placeholder 에 GLB 를 attach 해 GLB 기반 컴포넌트로 morph.
|
|
103
|
-
*
|
|
104
|
-
* morph 정책:
|
|
105
|
-
* - `placeholder` — type 유지 (GltfComponent mixin 이 있어 GLB 직접 수용).
|
|
106
|
-
* - 도메인 추상 (`GenericTransport`, `GenericFacility` 등) — type 유지 + src set.
|
|
107
|
-
* 호출자가 toType 명시 가능 (예: 'GenericTransport'). 미지정이면 placeholder type 유지.
|
|
108
|
-
*/
|
|
109
|
-
export interface AttachGlbOptions extends ConvertOptions {
|
|
110
|
-
/** GLB 파일 URL 또는 Attachment src. */
|
|
111
|
-
src: string
|
|
112
|
-
/** 자동으로 모델 크기에 맞춰 width/height/depth 보정 (gltf-object autoFit). */
|
|
113
|
-
autoFit?: boolean
|
|
114
|
-
/**
|
|
115
|
-
* 명시 변환 type — 도메인 추상 (`GenericTransport` 등) 으로 morph 시 지정.
|
|
116
|
-
* 미지정 시: placeholder type 유지 (placeholder 는 GltfComponent mixin 으로 GLB 직접 수용).
|
|
117
|
-
*/
|
|
118
|
-
toType?: string
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function attachGlbToPlaceholder(
|
|
122
|
-
placeholder: BoardComponent,
|
|
123
|
-
options: AttachGlbOptions
|
|
124
|
-
): BoardComponent {
|
|
125
|
-
const extra = options.extraPlaceholderTypes ?? []
|
|
126
|
-
if (!isPlaceholderType(placeholder.type, extra)) {
|
|
127
|
-
throw new Error(
|
|
128
|
-
`Source component is not a generic placeholder (type=${placeholder.type}). Cannot attach GLB.`
|
|
129
|
-
)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const {
|
|
133
|
-
strokeStyle: _strokeStyle,
|
|
134
|
-
strokeDashArray: _strokeDashArray,
|
|
135
|
-
fillStyle: _fillStyle,
|
|
136
|
-
label: _label,
|
|
137
|
-
placeholderLabel: _placeholderLabel,
|
|
138
|
-
placeholderHint: _placeholderHint,
|
|
139
|
-
...preservedState
|
|
140
|
-
} = placeholder as any
|
|
141
|
-
|
|
142
|
-
// morph 후 type 결정 — placeholder 는 GltfComponent mixin 보유, 도메인 추상도 type 유지
|
|
143
|
-
const nextType = options.toType ?? placeholder.type
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
...preservedState,
|
|
147
|
-
type: nextType,
|
|
148
|
-
src: options.src,
|
|
149
|
-
...(options.autoFit ? { autoFit: true } : {})
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
107
|
// ── Backward-compat alias — 기존 호출처 호환 ──────────────────────
|
|
154
108
|
|
|
155
109
|
/**
|
package/server/service/index.ts
CHANGED
|
@@ -28,11 +28,10 @@ export type { BindingOptions } from './pipeline/stage4-binding'
|
|
|
28
28
|
export {
|
|
29
29
|
convertGenericTo, // deprecated alias — keep for backward-compat
|
|
30
30
|
convertPlaceholderTo,
|
|
31
|
-
attachGlbToPlaceholder,
|
|
32
31
|
isPlaceholderType,
|
|
33
32
|
CORE_PLACEHOLDER_TYPES
|
|
34
33
|
} from './converters/generic-to'
|
|
35
|
-
export type { ConvertOptions
|
|
34
|
+
export type { ConvertOptions } from './converters/generic-to'
|
|
36
35
|
|
|
37
36
|
// Adapters
|
|
38
37
|
export { DxfAdapter } from './adapters/dxf-adapter'
|