three-slicer 0.1.0 → 0.1.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.
Files changed (58) hide show
  1. package/README.md +342 -24
  2. package/components/README.md +1 -1
  3. package/components/dist/SettingsPanel.js +3 -4
  4. package/engine/index.d.ts +3 -1
  5. package/engine/src/data.js +12 -0
  6. package/engine/src/settings.js +1 -1
  7. package/engine/src/slicer.worker.js +2 -1
  8. package/engine/src/slicer_core.js +0 -0
  9. package/engine/src/slicer_core.mt.js +0 -0
  10. package/engine/src/toggle_eval.js +1 -2
  11. package/package.json +54 -26
  12. package/types/components.d.ts +19 -0
  13. package/types/data/config-schema.json.d.ts +55 -0
  14. package/types/data/invalidation-map.json.d.ts +15 -0
  15. package/types/data/toggle-rules.json.d.ts +20 -0
  16. package/types/data/ui-tree.json.d.ts +19 -0
  17. package/types/data.d.ts +17 -0
  18. package/types/gen_settings_types.mjs +70 -0
  19. package/types/settings-keys.d.ts +1704 -0
  20. package/types/settings.d.ts +19 -0
  21. package/types/toggle.d.ts +22 -0
  22. package/types/viewer-loaders.d.ts +33 -0
  23. package/types/viewer-toolpath.d.ts +105 -0
  24. package/types/viewer.d.ts +15 -0
  25. package/types/wasm.d.ts +5 -0
  26. package/types/worker.d.ts +3 -0
  27. package/viewer/README.md +1 -1
  28. package/viewer/dist/Viewport.js +674 -617
  29. package/viewer/dist/model_loaders.js +220 -108
  30. package/viewer/styles.css +2 -0
  31. package/data/config-schema-builddump.json +0 -12921
  32. package/viewer/src/Viewport.jsx +0 -1353
  33. package/viewer/src/assets/add.svg +0 -1
  34. package/viewer/src/assets/arrange.svg +0 -1
  35. package/viewer/src/assets/boolean.svg +0 -1
  36. package/viewer/src/assets/cut.svg +0 -1
  37. package/viewer/src/assets/delete.svg +0 -1
  38. package/viewer/src/assets/deleteall.svg +0 -1
  39. package/viewer/src/assets/duplicate.svg +0 -1
  40. package/viewer/src/assets/measure.svg +0 -1
  41. package/viewer/src/assets/mmu.svg +0 -1
  42. package/viewer/src/assets/move.svg +0 -1
  43. package/viewer/src/assets/negative.svg +0 -1
  44. package/viewer/src/assets/onbed.svg +0 -1
  45. package/viewer/src/assets/open.svg +0 -1
  46. package/viewer/src/assets/orient.svg +0 -1
  47. package/viewer/src/assets/paint.svg +0 -1
  48. package/viewer/src/assets/rotate.svg +0 -1
  49. package/viewer/src/assets/scale.svg +0 -1
  50. package/viewer/src/assets/seam.svg +0 -1
  51. package/viewer/src/assets/split.svg +0 -1
  52. package/viewer/src/assets/textmark.svg +0 -1
  53. package/viewer/src/assets/varlayer.svg +0 -1
  54. package/viewer/src/icons.js +0 -23
  55. package/viewer/src/make_worker.js +0 -9
  56. package/viewer/src/model_loaders.js +0 -178
  57. package/viewer/src/shadow_host.jsx +0 -30
  58. package/viewer/src/toolpath_gpu.js +0 -430
@@ -0,0 +1,15 @@
1
+ // three-slicer/data/invalidation-map.json — 설정 키 변경 → 무효화되는 슬라이스 단계.
2
+ // 최상위 키 = 무효화 대상 종류(print/object/filament 등).
3
+
4
+ export interface InvalidationRule {
5
+ /** 이 규칙이 반응하는 config-schema 키들 */
6
+ keys: string[]
7
+ /** 무효화되는 단계 (예: 'psSkirtBrim', 'posSlice') */
8
+ steps: string[]
9
+ /** 단계로 표현 안 되는 특수 처리 */
10
+ special: string[]
11
+ line?: number
12
+ }
13
+
14
+ declare const invalidationMap: Record<string, InvalidationRule[]>
15
+ export default invalidationMap
@@ -0,0 +1,20 @@
1
+ // three-slicer/data/toggle-rules.json — 원본 toggle_options() 의 enable_if 조건식 추출.
2
+ // 최상위 키 = 그룹명(예: 'toggle_print_fff_options', 'TabPrinter::toggle_options').
3
+
4
+ export interface ToggleRule {
5
+ /** 원본 C++ 조건식 문자열. 평가는 three-slicer/toggle 의 evalEnableIf. */
6
+ enable_if?: string
7
+ /** 이 조건이 지배하는 config-schema 키들 */
8
+ fields?: string[]
9
+ line?: number
10
+ }
11
+
12
+ export interface ToggleGroup {
13
+ /** 로컬 변수명 → 원본 C++ 표현식(문자열). 번역은 toggle_eval.js 가 하드코딩으로 한다. */
14
+ locals: Record<string, string>
15
+ rules: ToggleRule[]
16
+ stats?: { toggle_calls_in_source: number; rules_extracted: number }
17
+ }
18
+
19
+ declare const toggles: Record<string, ToggleGroup>
20
+ export default toggles
@@ -0,0 +1,19 @@
1
+ // three-slicer/data/ui-tree.json — 원본 Tab.cpp 의 페이지/그룹 트리.
2
+ // 최상위 키 = 빌더명(예: 'TabPrint::build'), 값 = 그 빌더가 만드는 페이지들.
3
+
4
+ export interface UIGroup {
5
+ group: string
6
+ line?: number
7
+ /** config-schema 의 옵션 키들 */
8
+ options: string[]
9
+ }
10
+
11
+ export interface UIPage {
12
+ page: string
13
+ icon?: string
14
+ line?: number
15
+ groups: UIGroup[]
16
+ }
17
+
18
+ declare const uiTree: Record<string, UIPage[]>
19
+ export default uiTree
@@ -0,0 +1,17 @@
1
+ // three-slicer/data — 추출 JSON 4종. 원본 JSON 을 직접 import 하는 것보다 이쪽을 권한다:
2
+ // import attribute(`with { type: 'json' }`)가 이미 붙어 있어 Node·번들러 양쪽에서 그대로 돌아간다.
3
+ import type { ConfigOption } from './data/config-schema.json.d.ts'
4
+ import type { UIPage } from './data/ui-tree.json.d.ts'
5
+ import type { ToggleGroup } from './data/toggle-rules.json.d.ts'
6
+ import type { InvalidationRule } from './data/invalidation-map.json.d.ts'
7
+
8
+ export type { ConfigOption, UIPage, ToggleGroup, InvalidationRule }
9
+
10
+ /** 907개 옵션 정의 */
11
+ export const schema: Record<string, ConfigOption>
12
+ /** 빌더명 → 페이지 트리 */
13
+ export const uiTree: Record<string, UIPage[]>
14
+ /** 그룹명 → enable_if 규칙 */
15
+ export const toggleRules: Record<string, ToggleGroup>
16
+ /** 설정 키 변경 → 무효화 단계 */
17
+ export const invalidationMap: Record<string, InvalidationRule[]>
@@ -0,0 +1,70 @@
1
+ // config-schema.json → types/settings-keys.d.ts (SlicerSettings 인터페이스, 907키).
2
+ // 재생성: node types/gen_settings_types.mjs (수동 편집 금지 — 이 스크립트만 고칠 것)
3
+ //
4
+ // ponytail: 스키마의 coXxx 타입만 보고 매핑한다. min/max·nullable 은 타입에 반영하지 않음
5
+ // (런타임 검증이지 타입 검증이 아니고, 907키 × branded number 는 tsc 를 느리게 만든다).
6
+ import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'
7
+ import { dirname, resolve } from 'node:path'
8
+ import { fileURLToPath } from 'node:url'
9
+
10
+ const here = dirname(fileURLToPath(import.meta.url))
11
+ const schema = JSON.parse(readFileSync(resolve(here, '../data/config-schema.json'), 'utf8'))
12
+
13
+ const lit = (v) => "'" + String(v).replace(/\\/g, '\\\\').replace(/'/g, "\\'") + "'"
14
+ // enum_values 가 없는 coEnum 도 있다(70/64 불일치) → string 으로 fail-open.
15
+ const enumOf = (o) => (Array.isArray(o.enum_values) && o.enum_values.length)
16
+ ? o.enum_values.map(lit).join(' | ')
17
+ : 'string'
18
+
19
+ // 벡터형은 `T[] | T` — settingScalar() 가 둘 다 받고, UI 는 첫 원소만 편집한다(settings.js:9).
20
+ const vec = (t) => `${/\|/.test(t) ? `(${t})` : t}[] | ${/\|/.test(t) ? `(${t})` : t}`
21
+
22
+ function tsType(o) {
23
+ switch (o.type) {
24
+ case 'coBool': return 'boolean'
25
+ case 'coBools': return vec('boolean')
26
+ case 'coInt': case 'coFloat': case 'coPercent': return 'number'
27
+ case 'coInts': case 'coFloats': case 'coPercents': return vec('number')
28
+ case 'coFloatOrPercent': return 'number | string'
29
+ case 'coFloatsOrPercents': return vec('number | string')
30
+ case 'coString': return 'string'
31
+ case 'coStrings': return vec('string')
32
+ case 'coEnum': return enumOf(o)
33
+ case 'coEnums': return vec(enumOf(o))
34
+ case 'coPoint': return 'Point'
35
+ case 'coPoints': return 'Point[]'
36
+ case 'coPointsGroups': return 'Point[][]'
37
+ default: return 'unknown'
38
+ }
39
+ }
40
+
41
+ const esc = (s) => String(s).replace(/\*\//g, '*\\/')
42
+ const ident = (k) => /^[A-Za-z_$][\w$]*$/.test(k) ? k : lit(k).replace(/^'|'$/g, (m) => m === "'" ? "'" : m)
43
+
44
+ const lines = []
45
+ for (const key of Object.keys(schema).sort()) {
46
+ const o = schema[key]
47
+ const doc = [o.label, o.sidetext ? `(${o.sidetext})` : '', o.tooltip].filter(Boolean).join(' — ')
48
+ if (doc) lines.push(` /** ${esc(doc).replace(/\s*\n\s*/g, ' ')} */`)
49
+ const name = /^[A-Za-z_$][\w$]*$/.test(key) ? key : lit(key)
50
+ lines.push(` ${name}?: ${tsType(o)}`)
51
+ }
52
+
53
+ writeFileSync(resolve(here, 'settings-keys.d.ts'), `// AUTO-GENERATED by types/gen_settings_types.mjs — DO NOT EDIT.
54
+ // Source: data/config-schema.json (${Object.keys(schema).length} keys)
55
+
56
+ /** [x, y] — coPoint 계열 */
57
+ export type Point = [number, number]
58
+
59
+ /**
60
+ * 슬라이서 설정 맵. sparse — 편집한 키만 담고, 없는 키는 config-schema 의 default 가 쓰인다.
61
+ * 임의 키 확장이 필요하면 \`SlicerSettings & Record<string, unknown>\` 로 넓혀서 쓸 것.
62
+ */
63
+ export interface SlicerSettings {
64
+ ${lines.join('\n')}
65
+ }
66
+
67
+ /** config-schema 에 존재하는 설정 키 */
68
+ export type SettingKey = keyof SlicerSettings & string
69
+ `)
70
+ console.log(`settings-keys.d.ts written — ${Object.keys(schema).length} keys`)