zelos-recad 0.1.0 → 0.2.0
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/README.md +18 -5
- package/UPSTREAM-LICENSE +21 -21
- package/build-info.json +26 -0
- package/mcp/index.js +2 -1
- package/package.json +22 -10
- package/protocol/src/bundle.d.ts +7 -1
- package/protocol/src/contracts.d.ts +18 -6
- package/protocol/src/contracts.js +20 -7
- package/protocol/src/native-evidence.d.ts +20 -0
- package/service/app.js +4 -2
- package/service/options.d.ts +2 -1
- package/service/options.js +2 -1
- package/shared/build-identity.d.mts +6 -0
- package/shared/build-identity.mjs +63 -0
- package/shared/client.d.mts +1 -0
- package/shared/client.mjs +9 -0
- package/shared/command.d.mts +1 -0
- package/shared/command.mjs +22 -4
- package/shared/contracts/src/paths.d.ts +3 -0
- package/shared/contracts/src/paths.js +31 -0
- package/shared/mcp.d.mts +1 -0
- package/shared/service-storage/src/capacity.d.ts +36 -0
- package/shared/service-storage/src/capacity.js +71 -0
- package/shared/service-storage/src/consumption.d.ts +15 -0
- package/shared/service-storage/src/consumption.js +27 -0
- package/shared/service-storage/src/documents.d.ts +43 -0
- package/shared/service-storage/src/documents.js +210 -0
- package/shared/service-storage/src/downloads.d.ts +10 -0
- package/shared/service-storage/src/downloads.js +58 -0
- package/shared/service-storage/src/files.d.ts +18 -0
- package/shared/service-storage/src/files.js +118 -0
- package/shared/service-storage/src/footprint.d.ts +14 -0
- package/shared/service-storage/src/footprint.js +72 -0
- package/shared/service-storage/src/process-temp.d.ts +22 -0
- package/shared/service-storage/src/process-temp.js +181 -0
- package/shared/service-storage/src/quota.d.ts +30 -0
- package/shared/service-storage/src/quota.js +166 -0
- package/shared/service-storage/src/retention.d.ts +38 -0
- package/shared/service-storage/src/retention.js +148 -0
- package/shared/service-storage/src/staging.d.ts +15 -0
- package/shared/service-storage/src/staging.js +116 -0
- package/source/README.md +1 -3
- package/source/mcp/index.ts +2 -1
- package/source/package.json +4 -2
- package/source/protocol/src/contracts.ts +20 -7
- package/source/protocol/src/native-evidence.ts +21 -0
- package/source/rebuild.mjs +12 -4
- package/source/service/app.ts +6 -2
- package/source/service/options.ts +3 -2
- package/source/shared/build-identity.d.mts +6 -0
- package/source/shared/build-identity.mjs +63 -0
- package/source/shared/client.d.mts +1 -0
- package/source/shared/client.mjs +9 -0
- package/source/shared/command.d.mts +1 -0
- package/source/shared/command.mjs +22 -4
- package/source/shared/contracts/src/paths.ts +33 -0
- package/source/shared/mcp.d.mts +1 -0
- package/source/shared/service-storage/src/capacity.ts +101 -0
- package/source/shared/service-storage/src/consumption.ts +45 -0
- package/source/shared/service-storage/src/documents.ts +262 -0
- package/source/shared/service-storage/src/downloads.ts +62 -0
- package/source/shared/service-storage/src/files.ts +135 -0
- package/source/shared/service-storage/src/footprint.ts +78 -0
- package/source/shared/service-storage/src/process-temp.ts +205 -0
- package/source/shared/service-storage/src/quota.ts +198 -0
- package/source/shared/service-storage/src/retention.ts +180 -0
- package/source/shared/service-storage/src/staging.ts +106 -0
- package/source/src/application-objects.ts +2 -2
- package/source/src/assets.ts +15 -0
- package/source/src/block-clip.ts +1 -1
- package/source/src/block-metadata.ts +12 -5
- package/source/src/build-info.ts +15 -0
- package/source/src/cad-engine.ts +18 -8
- package/source/src/command.ts +2 -2
- package/source/src/constraints.ts +2 -2
- package/source/src/conversion.ts +2 -0
- package/source/src/dwg-fallback.ts +2 -0
- package/source/src/dwg.ts +7 -0
- package/source/src/dxf-export.ts +3 -3
- package/source/src/dxf.ts +7 -4
- package/source/src/native-evidence.ts +33 -1
- package/source/src/native-segmented-path.ts +22 -35
- package/source/src/point-dictionaries.ts +65 -0
- package/source/src/readback.ts +7 -6
- package/source/src/reader.ts +19 -10
- package/source/src/render-operation.ts +39 -7
- package/source/src/runner.ts +5 -4
- package/source/src/runtime/documents.ts +23 -142
- package/source/src/runtime/index.ts +71 -17
- package/source/src/runtime/jobs.ts +176 -153
- package/source/src/runtime/managed-worker.ts +37 -0
- package/source/src/runtime/storage-policy.ts +39 -0
- package/source/src/runtime/storage.ts +9 -44
- package/source/src/source-scene.ts +125 -23
- package/source/src/text/glyphs.ts +63 -0
- package/source/src/text/ink-bounds.ts +7 -36
- package/source/src/text/scene-geometry.ts +92 -0
- package/source/src/text/source-fonts.ts +31 -0
- package/source/src/vendor-object-data.ts +265 -0
- package/source/src/xref.ts +4 -3
- package/source/tsconfig.json +4 -2
- package/src/application-objects.js +2 -2
- package/src/assets.d.ts +9 -0
- package/src/assets.js +14 -0
- package/src/block-clip.js +1 -1
- package/src/block-metadata.js +11 -5
- package/src/build-info.d.ts +2 -0
- package/src/build-info.js +14 -0
- package/src/cad-engine.js +19 -8
- package/src/command.js +2 -2
- package/src/constraints.js +2 -2
- package/src/conversion.d.ts +2 -0
- package/src/conversion.js +2 -0
- package/src/dwg-fallback.d.ts +1 -0
- package/src/dwg-fallback.js +2 -0
- package/src/dwg.d.ts +3 -0
- package/src/dwg.js +7 -0
- package/src/dxf-export.js +3 -3
- package/src/dxf.d.ts +14 -1
- package/src/dxf.js +7 -3
- package/src/native-evidence.d.ts +33 -1
- package/src/native-evidence.js +33 -0
- package/src/native-segmented-path.js +1 -3
- package/src/point-dictionaries.d.ts +12 -0
- package/src/point-dictionaries.js +88 -0
- package/src/readback.d.ts +12 -4
- package/src/readback.js +7 -6
- package/src/reader.d.ts +12 -1
- package/src/reader.js +22 -11
- package/src/render-operation.js +36 -7
- package/src/runner.js +5 -4
- package/src/runtime/documents.d.ts +8 -20
- package/src/runtime/documents.js +17 -116
- package/src/runtime/index.d.ts +41 -4
- package/src/runtime/index.js +72 -18
- package/src/runtime/jobs.d.ts +21 -2
- package/src/runtime/jobs.js +120 -100
- package/src/runtime/managed-worker.d.ts +8 -0
- package/src/runtime/managed-worker.js +29 -0
- package/src/runtime/storage-policy.d.ts +25 -0
- package/src/runtime/storage-policy.js +29 -0
- package/src/runtime/storage.d.ts +1 -7
- package/src/runtime/storage.js +1 -38
- package/src/source-scene.d.ts +4 -2
- package/src/source-scene.js +136 -20
- package/src/text/glyphs.d.ts +12 -0
- package/src/text/glyphs.js +53 -0
- package/src/text/ink-bounds.d.ts +2 -1
- package/src/text/ink-bounds.js +6 -34
- package/src/text/scene-geometry.d.ts +21 -0
- package/src/text/scene-geometry.js +70 -0
- package/src/text/source-fonts.d.ts +7 -0
- package/src/text/source-fonts.js +30 -0
- package/src/vendor-object-data.d.ts +19 -0
- package/src/vendor-object-data.js +241 -0
- package/src/xref.js +3 -3
- package/vendor/libredwg/COPYING +674 -674
- package/vendor/libredwg/Dockerfile +2 -0
- package/vendor/libredwg/README.md +41 -28
- package/vendor/libredwg/build-local.sh +1 -1
- package/vendor/libredwg/libredwg-web.wasm +0 -0
- package/vendor/libredwg/manifest.json +5 -3
- package/vendor/libredwg/opaque-object-binding.patch +29 -0
- package/vendor/libredwg/rebuild.mjs +2 -1
- package/source/service/README.md +0 -152
- package/source/src/text/UPSTREAM.md +0 -26
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { existsSync, lstatSync, readFileSync, readdirSync } from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import {
|
|
4
|
+
atomicJson,
|
|
5
|
+
checkedId,
|
|
6
|
+
directoryBytes,
|
|
7
|
+
idPattern,
|
|
8
|
+
removeJob,
|
|
9
|
+
StorageError,
|
|
10
|
+
} from './files.ts'
|
|
11
|
+
import { DownloadLeases } from './downloads.ts'
|
|
12
|
+
import { sweepProcessTemporary } from './process-temp.ts'
|
|
13
|
+
import { consumptionHash, type Consumption, type ConsumptionReceipt } from './consumption.ts'
|
|
14
|
+
|
|
15
|
+
export const DEFAULT_RETENTION_MS = 2 * 86400000
|
|
16
|
+
export interface RetainedJob {
|
|
17
|
+
id: string
|
|
18
|
+
status: string
|
|
19
|
+
endedAt?: string
|
|
20
|
+
consumed?: Consumption
|
|
21
|
+
}
|
|
22
|
+
export interface RetentionOptions {
|
|
23
|
+
retentionMs?: number
|
|
24
|
+
maxStorageBytes?: number
|
|
25
|
+
downloadGraceMs?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** One cleanup algorithm for both services; persistent tombstones also resume partial deletions. */
|
|
29
|
+
export class JobRetention<J extends RetainedJob> {
|
|
30
|
+
readonly downloads = new DownloadLeases()
|
|
31
|
+
constructor(
|
|
32
|
+
private context: {
|
|
33
|
+
data: string
|
|
34
|
+
options: RetentionOptions
|
|
35
|
+
jobs: Map<string, J>
|
|
36
|
+
running: (id: string) => boolean
|
|
37
|
+
receipt: (job: J, now: number) => object
|
|
38
|
+
consumption: (job: J) => ConsumptionReceipt
|
|
39
|
+
warn: (id: string, error: unknown) => void
|
|
40
|
+
temporaryWorkspaces?: (job: J) => string[]
|
|
41
|
+
},
|
|
42
|
+
) {}
|
|
43
|
+
private protected(id: string) {
|
|
44
|
+
return this.context.running(id) || this.downloads.has(id)
|
|
45
|
+
}
|
|
46
|
+
private checkedConsumption(job: J) {
|
|
47
|
+
if (
|
|
48
|
+
job.consumed &&
|
|
49
|
+
(!Number.isFinite(Date.parse(job.consumed.at)) ||
|
|
50
|
+
job.consumed.sha256 !== consumptionHash(this.context.consumption(job)))
|
|
51
|
+
)
|
|
52
|
+
throw new StorageError('CONSUMPTION_CHANGED', '已保存消费回执与任务记录不一致', 409)
|
|
53
|
+
return job.consumed
|
|
54
|
+
}
|
|
55
|
+
consume(id: string, raw: unknown) {
|
|
56
|
+
checkedId(id)
|
|
57
|
+
const { data, jobs } = this.context,
|
|
58
|
+
sha256 = consumptionHash(raw)
|
|
59
|
+
const marker = path.join(data, '.retired', id + '.json')
|
|
60
|
+
if (existsSync(marker)) {
|
|
61
|
+
if (lstatSync(marker).isSymbolicLink())
|
|
62
|
+
throw new StorageError('STORAGE_LINK', '回收凭据包含链接')
|
|
63
|
+
const retired = JSON.parse(readFileSync(marker, 'utf8'))
|
|
64
|
+
if (
|
|
65
|
+
retired.id !== id ||
|
|
66
|
+
retired.consumed?.sha256 !== sha256 ||
|
|
67
|
+
!Number.isFinite(Date.parse(retired.consumed?.at))
|
|
68
|
+
)
|
|
69
|
+
throw new StorageError('CONSUMPTION_CONFLICT', '消费回执与已回收成果不一致', 409)
|
|
70
|
+
return { id, consumedAt: retired.consumed.at }
|
|
71
|
+
}
|
|
72
|
+
const job = jobs.get(id)
|
|
73
|
+
if (!job) throw new StorageError('NOT_FOUND', '任务不存在', 404)
|
|
74
|
+
if (!job.endedAt || ['queued', 'running'].includes(job.status) || this.context.running(id))
|
|
75
|
+
throw new StorageError('CONSUMPTION_PENDING', '任务仍在执行,请在成果保存后提交回执', 409)
|
|
76
|
+
if (consumptionHash(this.context.consumption(job)) !== sha256)
|
|
77
|
+
throw new StorageError('CONSUMPTION_CONFLICT', '消费回执与终态成果不一致', 409)
|
|
78
|
+
const consumed = this.checkedConsumption(job) ?? { at: new Date().toISOString(), sha256 }
|
|
79
|
+
// Persist before acknowledging; a disk failure leaves the original job available for download.
|
|
80
|
+
if (!job.consumed) {
|
|
81
|
+
atomicJson(path.join(data, id, 'job.json'), { ...job, consumed })
|
|
82
|
+
job.consumed = consumed
|
|
83
|
+
}
|
|
84
|
+
this.cleanup()
|
|
85
|
+
return { id, consumedAt: consumed.at }
|
|
86
|
+
}
|
|
87
|
+
cleanup(now = Date.now()) {
|
|
88
|
+
const { data, jobs, options, warn } = this.context,
|
|
89
|
+
removed: string[] = []
|
|
90
|
+
for (const job of jobs.values()) {
|
|
91
|
+
if (['queued', 'running'].includes(job.status) || this.protected(job.id)) continue
|
|
92
|
+
for (const workspace of this.context.temporaryWorkspaces?.(job) ?? [
|
|
93
|
+
path.join(data, job.id),
|
|
94
|
+
]) {
|
|
95
|
+
try {
|
|
96
|
+
sweepProcessTemporary(workspace, (_id, error) => warn(job.id, error))
|
|
97
|
+
} catch (error) {
|
|
98
|
+
warn(job.id, error)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const markerRoot = path.join(data, '.retired')
|
|
103
|
+
const remove = (id: string) => {
|
|
104
|
+
const directory = path.join(data, checkedId(id))
|
|
105
|
+
if (existsSync(directory)) removeJob(data, id)
|
|
106
|
+
jobs.delete(id)
|
|
107
|
+
removed.push(id)
|
|
108
|
+
}
|
|
109
|
+
// A previous rm may have removed job.json before failing. The tombstone is sufficient ownership.
|
|
110
|
+
try {
|
|
111
|
+
for (const name of readdirSync(markerRoot)) {
|
|
112
|
+
const id = name.slice(0, -5)
|
|
113
|
+
if (
|
|
114
|
+
!name.endsWith('.json') ||
|
|
115
|
+
!idPattern.test(id) ||
|
|
116
|
+
this.protected(id) ||
|
|
117
|
+
!existsSync(path.join(data, id))
|
|
118
|
+
)
|
|
119
|
+
continue
|
|
120
|
+
try {
|
|
121
|
+
const file = path.join(markerRoot, name)
|
|
122
|
+
if (lstatSync(file).isSymbolicLink() || JSON.parse(readFileSync(file, 'utf8')).id !== id)
|
|
123
|
+
continue
|
|
124
|
+
remove(id)
|
|
125
|
+
} catch (error) {
|
|
126
|
+
warn(id, error)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} catch (error) {
|
|
130
|
+
warn('.retired', error)
|
|
131
|
+
}
|
|
132
|
+
let bytes: number | undefined
|
|
133
|
+
if (options.maxStorageBytes) {
|
|
134
|
+
try {
|
|
135
|
+
bytes = directoryBytes(data)
|
|
136
|
+
} catch (error) {
|
|
137
|
+
warn('.', error)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const candidates = [...jobs.values()]
|
|
141
|
+
.filter(
|
|
142
|
+
(job) =>
|
|
143
|
+
['succeeded', 'failed', 'cancelled', 'interrupted'].includes(job.status) &&
|
|
144
|
+
!this.protected(job.id) &&
|
|
145
|
+
job.endedAt &&
|
|
146
|
+
Number.isFinite(Date.parse(job.endedAt)) &&
|
|
147
|
+
(job.consumed || now - Date.parse(job.endedAt) >= (options.downloadGraceMs ?? 3600000)),
|
|
148
|
+
)
|
|
149
|
+
.sort((a, b) => a.endedAt!.localeCompare(b.endedAt!))
|
|
150
|
+
for (const job of candidates) {
|
|
151
|
+
try {
|
|
152
|
+
this.checkedConsumption(job)
|
|
153
|
+
} catch (error) {
|
|
154
|
+
warn(job.id, error)
|
|
155
|
+
continue
|
|
156
|
+
}
|
|
157
|
+
const expired =
|
|
158
|
+
now - Date.parse(job.endedAt!) >= (options.retentionMs ?? DEFAULT_RETENTION_MS)
|
|
159
|
+
if (
|
|
160
|
+
!job.consumed &&
|
|
161
|
+
!expired &&
|
|
162
|
+
!(options.maxStorageBytes && bytes !== undefined && bytes > options.maxStorageBytes)
|
|
163
|
+
)
|
|
164
|
+
continue
|
|
165
|
+
try {
|
|
166
|
+
directoryBytes(path.join(data, job.id))
|
|
167
|
+
atomicJson(path.join(markerRoot, job.id + '.json'), {
|
|
168
|
+
...this.context.receipt(job, now),
|
|
169
|
+
consumed: job.consumed,
|
|
170
|
+
})
|
|
171
|
+
remove(job.id)
|
|
172
|
+
// A removed source link may still be retained by another job or document.
|
|
173
|
+
if (bytes !== undefined) bytes = directoryBytes(data)
|
|
174
|
+
} catch (error) {
|
|
175
|
+
warn(job.id, error)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return { removed }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, rmSync } from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { atomicJson, checkedId, dataRoot, idPattern, removeJob, StorageError } from './files.ts'
|
|
4
|
+
|
|
5
|
+
function identity(folder: string) {
|
|
6
|
+
const stat = lstatSync(folder, { bigint: true })
|
|
7
|
+
if (stat.isSymbolicLink() || !stat.isDirectory())
|
|
8
|
+
throw new StorageError('STORAGE_LINK', '待提交路径需要普通目录')
|
|
9
|
+
return `${stat.dev}:${stat.ino}:${stat.birthtimeNs}`
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Durable ownership for a UUID directory before its commit receipt exists. */
|
|
13
|
+
export class StagedDirectories {
|
|
14
|
+
private active = new Set<string>()
|
|
15
|
+
constructor(
|
|
16
|
+
private root: string,
|
|
17
|
+
private markers: string,
|
|
18
|
+
private receipt: string | undefined,
|
|
19
|
+
private warn: (id: string, error: unknown) => void,
|
|
20
|
+
) {
|
|
21
|
+
this.root = dataRoot(root)
|
|
22
|
+
this.markers = dataRoot(markers)
|
|
23
|
+
}
|
|
24
|
+
begin(id: string) {
|
|
25
|
+
checkedId(id)
|
|
26
|
+
const folder = path.join(this.root, id),
|
|
27
|
+
marker = path.join(this.markers, id + '.json')
|
|
28
|
+
if (existsSync(folder) || existsSync(marker))
|
|
29
|
+
throw new StorageError('STORAGE_CONFLICT', '待提交目录已存在,请检查存储诊断', 409)
|
|
30
|
+
atomicJson(marker, { id })
|
|
31
|
+
this.active.add(id)
|
|
32
|
+
let owned: string | undefined
|
|
33
|
+
try {
|
|
34
|
+
mkdirSync(folder)
|
|
35
|
+
owned = identity(folder)
|
|
36
|
+
atomicJson(marker, { id, identity: owned })
|
|
37
|
+
} catch (error) {
|
|
38
|
+
this.active.delete(id)
|
|
39
|
+
try {
|
|
40
|
+
if (owned && identity(folder) === owned) removeJob(this.root, id)
|
|
41
|
+
if (!existsSync(folder)) rmSync(marker, { force: true })
|
|
42
|
+
} catch (cleanupError) {
|
|
43
|
+
this.warn(id, cleanupError)
|
|
44
|
+
}
|
|
45
|
+
this.warn(id, error)
|
|
46
|
+
throw error
|
|
47
|
+
}
|
|
48
|
+
let committed = false
|
|
49
|
+
return {
|
|
50
|
+
retire: () => {
|
|
51
|
+
atomicJson(marker, { id, identity: owned, cleanupReady: true })
|
|
52
|
+
},
|
|
53
|
+
commit: () => {
|
|
54
|
+
committed = true
|
|
55
|
+
},
|
|
56
|
+
close: () => {
|
|
57
|
+
this.active.delete(id)
|
|
58
|
+
try {
|
|
59
|
+
if (existsSync(folder) && identity(folder) !== owned)
|
|
60
|
+
throw new StorageError('STORAGE_CHANGED', '待提交目录身份已变化')
|
|
61
|
+
if (!committed && existsSync(folder)) removeJob(this.root, id)
|
|
62
|
+
rmSync(marker, { force: true })
|
|
63
|
+
} catch (error) {
|
|
64
|
+
this.warn(id, error)
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
cleanup(readyOnly = false) {
|
|
70
|
+
let names: string[]
|
|
71
|
+
try {
|
|
72
|
+
names = readdirSync(this.markers)
|
|
73
|
+
} catch (error) {
|
|
74
|
+
this.warn('.', error)
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
for (const name of names) {
|
|
78
|
+
const id = name.slice(0, -5)
|
|
79
|
+
if (!name.endsWith('.json') || !idPattern.test(id) || this.active.has(id)) continue
|
|
80
|
+
try {
|
|
81
|
+
const marker = path.join(this.markers, name),
|
|
82
|
+
folder = path.join(this.root, id)
|
|
83
|
+
if (lstatSync(marker).isSymbolicLink())
|
|
84
|
+
throw new StorageError('STORAGE_LINK', '待提交凭据包含链接')
|
|
85
|
+
const owner = JSON.parse(readFileSync(marker, 'utf8'))
|
|
86
|
+
if (readyOnly && owner.cleanupReady !== true) continue
|
|
87
|
+
if (owner.id !== id) throw new StorageError('STORAGE_CHANGED', '待提交目录的拥有者凭据无效')
|
|
88
|
+
if (existsSync(folder)) {
|
|
89
|
+
const receipt = this.receipt && path.join(folder, this.receipt)
|
|
90
|
+
if (identity(folder) !== owner.identity)
|
|
91
|
+
throw new StorageError('STORAGE_CHANGED', '待提交目录身份已变化')
|
|
92
|
+
if (receipt && existsSync(receipt)) {
|
|
93
|
+
if (
|
|
94
|
+
lstatSync(receipt).isSymbolicLink() ||
|
|
95
|
+
JSON.parse(readFileSync(receipt, 'utf8')).id !== id
|
|
96
|
+
)
|
|
97
|
+
throw new StorageError('STORAGE_CHANGED', '提交记录与目录身份不一致')
|
|
98
|
+
} else removeJob(this.root, id)
|
|
99
|
+
}
|
|
100
|
+
rmSync(marker)
|
|
101
|
+
} catch (error) {
|
|
102
|
+
this.warn(id, error)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
2
|
import { CadError } from './contracts.ts'
|
|
3
3
|
|
|
4
4
|
/** Retain application data without executing AutoLISP. Tianzheng configuration
|
|
@@ -38,7 +38,7 @@ export function captureApplicationObjects(module: any, pointer: number, sourceSh
|
|
|
38
38
|
...record,
|
|
39
39
|
sourceSha256,
|
|
40
40
|
executed: false,
|
|
41
|
-
rawSha256: sha256(Buffer.from(record.rawHex, 'hex')),
|
|
41
|
+
rawSha256: createHash('sha256').update(Buffer.from(record.rawHex, 'hex')).digest('hex'),
|
|
42
42
|
}
|
|
43
43
|
})
|
|
44
44
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import { moduleRoot } from './runtime-paths.ts'
|
|
3
|
+
export { getRecadBuildInfo } from './build-info.ts'
|
|
4
|
+
|
|
5
|
+
/** Installed resource locations; callers keep their data and Python environment outside the package. */
|
|
6
|
+
export function getRecadAssets() {
|
|
7
|
+
const fontsDir = path.join(moduleRoot, 'assets', 'fonts')
|
|
8
|
+
return {
|
|
9
|
+
fontsDir,
|
|
10
|
+
fontManifest: path.join(fontsDir, 'manifest.json'),
|
|
11
|
+
substitutions: path.join(fontsDir, 'substitutions.json'),
|
|
12
|
+
requirements: path.join(moduleRoot, 'requirements.txt'),
|
|
13
|
+
decoderManifest: path.join(moduleRoot, 'vendor', 'libredwg', 'manifest.json'),
|
|
14
|
+
}
|
|
15
|
+
}
|
package/source/src/block-clip.ts
CHANGED
|
@@ -248,7 +248,7 @@ export function adaptBlockClips(
|
|
|
248
248
|
if (entity.dxfTypeName !== 'INSERT' || !extended.has(id)) continue
|
|
249
249
|
const raw = clips.get(id)
|
|
250
250
|
const passive = metadata.get(id)
|
|
251
|
-
if (passive && readback)
|
|
251
|
+
if (passive && readback && (passive.records.length || passive.savedRepresentation || passive.filter))
|
|
252
252
|
throw new CadError(
|
|
253
253
|
'READBACK_BLOCK_METADATA',
|
|
254
254
|
'最终交付不能保留尚无法独立重放的业务扩展记录:' + id,
|
|
@@ -62,7 +62,7 @@ function classify(inserts: Map<string, string>, objects: Entry[]) {
|
|
|
62
62
|
root.type !== 'DICTIONARY' ||
|
|
63
63
|
key(root.owner) !== key(handle) ||
|
|
64
64
|
root.extension ||
|
|
65
|
-
!root.entries
|
|
65
|
+
!Array.isArray(root.entries) ||
|
|
66
66
|
root.entries.length > 128
|
|
67
67
|
)
|
|
68
68
|
continue
|
|
@@ -85,9 +85,9 @@ function classify(inserts: Map<string, string>, objects: Entry[]) {
|
|
|
85
85
|
continue
|
|
86
86
|
}
|
|
87
87
|
if (
|
|
88
|
-
(!metadataNames.has(name) && record?.type !== 'VLO-VL') ||
|
|
88
|
+
(!metadataNames.has(name) && record?.type !== 'VLO-VL' && !(name==='YJINFO'&&record?.type==='CCYjInfoRec')) ||
|
|
89
89
|
!record ||
|
|
90
|
-
!['XRECORD', 'VLO-VL'].includes(record.type) ||
|
|
90
|
+
!['XRECORD', 'VLO-VL','CCYjInfoRec'].includes(record.type) ||
|
|
91
91
|
key(record.owner) !== key(dictionary) ||
|
|
92
92
|
record.extension ||
|
|
93
93
|
!Array.isArray(record.data) ||
|
|
@@ -127,7 +127,8 @@ function classify(inserts: Map<string, string>, objects: Entry[]) {
|
|
|
127
127
|
if (filter) filters.set(key(handle), filter)
|
|
128
128
|
// A filter must still be validated independently, even with known siblings.
|
|
129
129
|
// Only wholly passive dictionaries can authorize an INSERT without a clip.
|
|
130
|
-
if (records.length
|
|
130
|
+
if (records.length || root.entries.length === 0)
|
|
131
|
+
metadata.set(key(handle), { dictionary: key(dictionary), records, filter })
|
|
131
132
|
}
|
|
132
133
|
return { metadata, filters }
|
|
133
134
|
}
|
|
@@ -139,6 +140,10 @@ export function dwgBlockMetadata(
|
|
|
139
140
|
useSavedRepresentation = false,
|
|
140
141
|
) {
|
|
141
142
|
const objects: Entry[] = [
|
|
143
|
+
...applicationObjects.filter(r=>r.type==='CCYjInfoRec'&&r.disposition==='retained-data'&&r.decoded?.format==='cc-yj-info/1').map(r=>({
|
|
144
|
+
type:r.type,handle:r.handle,owner:r.owner,extension:r.extension!=='0',
|
|
145
|
+
data:r.decoded.fields.map((field:any)=>({code:typeof field.value==='string'?1:90,value:field.value})),
|
|
146
|
+
})),
|
|
142
147
|
...applicationObjects
|
|
143
148
|
.filter((r) => r.type === 'VLO-VL' && r.disposition === 'retained-data')
|
|
144
149
|
.map((r) => ({
|
|
@@ -261,7 +266,9 @@ export function dxfBlockMetadata(records: DxfRecord[]) {
|
|
|
261
266
|
: 'INVALID',
|
|
262
267
|
] as [string, string],
|
|
263
268
|
]
|
|
264
|
-
: []
|
|
269
|
+
: [350, 360].includes(p.code) && r.pairs[i - 1]?.code !== 3
|
|
270
|
+
? [['INVALID', p.value] as [string, string]]
|
|
271
|
+
: [],
|
|
265
272
|
)
|
|
266
273
|
: undefined,
|
|
267
274
|
data: data?.map(({ code, value }) => ({ code, value })),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { buildIdentity, type BuildIdentity } from '../shared/build-identity.mjs'
|
|
4
|
+
import { moduleRoot } from './runtime-paths.ts'
|
|
5
|
+
|
|
6
|
+
let cached: Readonly<BuildIdentity> | undefined
|
|
7
|
+
export function getRecadBuildInfo(): Readonly<BuildIdentity> {
|
|
8
|
+
if (!cached) {
|
|
9
|
+
const file = path.join(moduleRoot, 'build-info.json')
|
|
10
|
+
const value: BuildIdentity = existsSync(file) ? JSON.parse(readFileSync(file, 'utf8')) : buildIdentity(moduleRoot)
|
|
11
|
+
Object.freeze(value.dependencies)
|
|
12
|
+
cached = Object.freeze(value)
|
|
13
|
+
}
|
|
14
|
+
return cached
|
|
15
|
+
}
|
package/source/src/cad-engine.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { adaptEmbeddedMText } from './embedded-mtext.ts'
|
|
|
20
20
|
import { hashFile, writeJson } from './io.ts'
|
|
21
21
|
import { renderCad } from './render-operation.ts'
|
|
22
22
|
import type { CadRunOptions } from './cad-options.ts'
|
|
23
|
+
import { getRecadBuildInfo } from './build-info.ts'
|
|
23
24
|
|
|
24
25
|
// Deliberately conservative until entity-specific visual regression coverage grows.
|
|
25
26
|
const supported = new Set([
|
|
@@ -51,7 +52,7 @@ export async function runCad(options: CadRunOptions) {
|
|
|
51
52
|
const started = performance.now()
|
|
52
53
|
const request = requestSchema.parse(options.request)
|
|
53
54
|
const recover = options.recovery === 'best-effort' && request.operation !== 'readback'
|
|
54
|
-
const drawing = await readDrawing(options.source, recover, request.operation === 'scene')
|
|
55
|
+
const drawing = await readDrawing(options.source, recover, request.operation === 'scene', request.operation === 'source-records')
|
|
55
56
|
if (request.operation === 'layouts') {
|
|
56
57
|
const db = drawing.db
|
|
57
58
|
const spaces = drawingSpaces(db)
|
|
@@ -60,6 +61,7 @@ export async function runCad(options: CadRunOptions) {
|
|
|
60
61
|
format: 'XDTrace.RecadResult',
|
|
61
62
|
version: 1,
|
|
62
63
|
operation: 'layouts',
|
|
64
|
+
build: getRecadBuildInfo(),
|
|
63
65
|
status: 'inspected',
|
|
64
66
|
sourceSha256: drawing.sourceSha256,
|
|
65
67
|
spaces,
|
|
@@ -226,6 +228,7 @@ export async function runCad(options: CadRunOptions) {
|
|
|
226
228
|
.filter(([handle]) => activeHandles.has(handle))
|
|
227
229
|
.map(([handle, data]) => ({ handle, ...data })),
|
|
228
230
|
engine: capabilities.dependencies,
|
|
231
|
+
build: getRecadBuildInfo(),
|
|
229
232
|
runtime: { node: process.version, platform: process.platform },
|
|
230
233
|
layout: selection.selected.name,
|
|
231
234
|
spaces: selection.spaces,
|
|
@@ -270,7 +273,7 @@ export async function runCad(options: CadRunOptions) {
|
|
|
270
273
|
omissions: [
|
|
271
274
|
...unsupportedOmissions,
|
|
272
275
|
...drawing.decodeIssues
|
|
273
|
-
.filter((r) => r.quarantined)
|
|
276
|
+
.filter((r) => r.quarantined && !r.retainedApplicationData)
|
|
274
277
|
.map((r) => ({
|
|
275
278
|
...r,
|
|
276
279
|
sourceSha256,
|
|
@@ -312,19 +315,26 @@ export async function runCad(options: CadRunOptions) {
|
|
|
312
315
|
artifacts: [],
|
|
313
316
|
verification: { independentCadVerification: false, productionReplacementReady: false },
|
|
314
317
|
}
|
|
315
|
-
if (request.operation === 'readback') {
|
|
316
|
-
if (isDwg) throw new CadError('READBACK_FORMAT', '最终交付核验要求 DXF 输入')
|
|
317
|
-
if (missing.length || warnings.length)
|
|
318
|
+
if (request.operation === 'readback' || request.operation === 'source-records') {
|
|
319
|
+
if (isDwg && request.operation === 'readback') throw new CadError('READBACK_FORMAT', '最终交付核验要求 DXF 输入')
|
|
320
|
+
if ((request.operation === 'readback' ? missing : relevantMissing).length || warnings.length)
|
|
318
321
|
throw new CadError('READBACK_LOSS', '独立重读存在未读取或未支持内容', { missing, warnings })
|
|
319
322
|
for (const style of db.tables.textStyleTable.newIterator()) {
|
|
320
323
|
const font = dxf?.styleFonts.get(String(style.objectId).toUpperCase())
|
|
321
324
|
if (font !== undefined) style.fileName = font
|
|
322
325
|
// DXF STYLE reader stores code 50 in degrees; its writer expects radians.
|
|
323
|
-
style.obliquingAngle = (style.obliquingAngle * Math.PI) / 180
|
|
326
|
+
if (!isDwg) style.obliquingAngle = (style.obliquingAngle * Math.PI) / 180
|
|
324
327
|
}
|
|
325
|
-
adaptTextMasks(records, dxf
|
|
328
|
+
if (dxf) adaptTextMasks(records, dxf.mtext)
|
|
326
329
|
const file = path.join(options.output, 'readback.json')
|
|
327
|
-
writeJson(file,
|
|
330
|
+
writeJson(file, {
|
|
331
|
+
...readbackSnapshot(db, sourceSha256, dxf?.textSize ?? 2.5,
|
|
332
|
+
request.operation === 'source-records' ? { block: model, blocks: scope.blocks, layout: selection.selected.name } : undefined),
|
|
333
|
+
...(request.operation === 'source-records' && drawing.applicationObjects.length
|
|
334
|
+
? { applicationObjects: drawing.applicationObjects, blockMetadata: report.blockMetadata } : {}),
|
|
335
|
+
...(request.operation === 'source-records' && drawing.pointDictionaries.length
|
|
336
|
+
? { pointDictionaries: drawing.pointDictionaries } : {}),
|
|
337
|
+
})
|
|
328
338
|
report.status = 'readback'
|
|
329
339
|
report.artifacts.push({
|
|
330
340
|
name: 'readback.json',
|
package/source/src/command.ts
CHANGED
|
@@ -8,11 +8,11 @@ import { prepareRecadRuntime } from './setup.ts'
|
|
|
8
8
|
import { mkdir } from 'node:fs/promises'
|
|
9
9
|
|
|
10
10
|
await runDocumentCommand({
|
|
11
|
-
engine: 'recad', startMcp: startRecadMcp,
|
|
11
|
+
engine: 'recad', defaultPorts: { serve: 18771, mcp: 18773 }, startMcp: startRecadMcp,
|
|
12
12
|
async serve(options) {
|
|
13
13
|
if (!['127.0.0.1', 'localhost', '::1'].includes(options.host!) && !options.token) throw new Error('Set RECAD_TOKEN for external listening')
|
|
14
14
|
const app = createRecadApp({ ...await recadOptions(options), token: options.token })
|
|
15
|
-
try { const address = await app.listen({ host: options.host, port: options.port
|
|
15
|
+
try { const address = await app.listen({ host: options.host, port: options.port! }); return { address, close: () => app.close() } }
|
|
16
16
|
catch (error) { await app.close(); throw error }
|
|
17
17
|
},
|
|
18
18
|
async doctor(options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
2
|
import { CadError } from './contracts.ts'
|
|
3
3
|
|
|
4
4
|
/** These graphs describe the saved entities. We retain and check the graph;
|
|
@@ -77,7 +77,7 @@ export function captureConstraintGroups(
|
|
|
77
77
|
evaluation: 'saved-geometry' as const,
|
|
78
78
|
solverExecuted: false as const,
|
|
79
79
|
requiresEvaluation: group.geometryStatus !== 0,
|
|
80
|
-
rawSha256: sha256(Buffer.from(group.rawHex, 'hex')),
|
|
80
|
+
rawSha256: createHash('sha256').update(Buffer.from(group.rawHex, 'hex')).digest('hex'),
|
|
81
81
|
}
|
|
82
82
|
})
|
|
83
83
|
}
|
|
@@ -7,7 +7,9 @@ export const drawingArtifacts = [
|
|
|
7
7
|
'print-plan.json',
|
|
8
8
|
'readback.json',
|
|
9
9
|
'scene.json',
|
|
10
|
+
'font-resources.json',
|
|
10
11
|
]
|
|
12
|
+
export const isDrawingArtifact = (name:string) => drawingArtifacts.includes(name) || /^font-[a-f0-9]{64}\.(ttf|otf|shx)$/.test(name)
|
|
11
13
|
export interface ArtifactReceipt {
|
|
12
14
|
name: string
|
|
13
15
|
sha256: string
|
package/source/src/dwg.ts
CHANGED
|
@@ -158,6 +158,13 @@ export function convertDwgWithArrays(lib: any, pointer: number, quarantined: any
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
/** R14 and earlier have no layer plotflag field. The decoder's zero-filled
|
|
162
|
+
* slot is not an authored no-plot decision; that flag was introduced in R2000. */
|
|
163
|
+
export function normalizeDwgLayerPlotFlags(model:any,version:string){
|
|
164
|
+
if(/^AC10\d{2}$/.test(version)&&Number(version.slice(2))<1015)
|
|
165
|
+
for(const layer of model.tables.LAYER.entries)layer.plotFlag=1
|
|
166
|
+
}
|
|
167
|
+
|
|
161
168
|
/** The pinned JS converter exposes DWG lineweight enum indices, whereas the
|
|
162
169
|
* data model expects DXF hundredths of a millimetre (and negative sentinels). */
|
|
163
170
|
export function normalizeDwgLineweights(model: any) {
|
package/source/src/dxf-export.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'
|
|
2
|
-
import {
|
|
2
|
+
import { createHash } from 'node:crypto'
|
|
3
3
|
import { CadError, CAD_INPUT_LIMITS } from './contracts.ts'
|
|
4
4
|
import { createDwgDecoder, dwgErrorFlags, readDwgBytes } from './dwg.ts'
|
|
5
5
|
import { captureConstraintGroups } from './constraints.ts'
|
|
@@ -355,7 +355,7 @@ export async function createNativeDxfCandidate(
|
|
|
355
355
|
const { lib, module, manifest } = await createDwgDecoder()
|
|
356
356
|
const buffer = Uint8Array.from(bytes).buffer
|
|
357
357
|
const decoded = readDwgBytes(lib, buffer, module, false)
|
|
358
|
-
const sourceSha256 = sha256(bytes)
|
|
358
|
+
const sourceSha256 = createHash('sha256').update(bytes).digest('hex')
|
|
359
359
|
const decode = {
|
|
360
360
|
code: decoded.error,
|
|
361
361
|
flags: dwgErrorFlags(decoded.error),
|
|
@@ -400,7 +400,7 @@ export async function createNativeDxfCandidate(
|
|
|
400
400
|
report: {
|
|
401
401
|
status: decode.code ? 'diagnostic-only' : 'candidate',
|
|
402
402
|
sourceSha256,
|
|
403
|
-
outputSha256: sha256(normalized.bytes),
|
|
403
|
+
outputSha256: createHash('sha256').update(normalized.bytes).digest('hex'),
|
|
404
404
|
decoderRevision: manifest.revision,
|
|
405
405
|
decode,
|
|
406
406
|
constraintGroups,
|
package/source/src/dxf.ts
CHANGED
|
@@ -7,13 +7,13 @@ import type { RasterSource } from './raster-image.ts'
|
|
|
7
7
|
import { binaryDxfSentinel, binaryDxfToText } from './binary-dxf.ts'
|
|
8
8
|
import type { LegacyColumns } from './legacy-columns.ts'
|
|
9
9
|
|
|
10
|
-
type Pair = { code: number; value: string; line: number }
|
|
10
|
+
type Pair = { code: number; value: string; line: number; rawValue?:string }
|
|
11
11
|
type Record = { type: string; pairs: Pair[]; section: string }
|
|
12
12
|
const structural = new Set(['BLOCK', 'ENDBLK', 'SEQEND', 'VERTEX'])
|
|
13
13
|
|
|
14
14
|
/** Validate the DXF envelope and retain source fields omitted by the upstream
|
|
15
15
|
* reader. Changes are confined to its in-memory adapter copy. */
|
|
16
|
-
export function inspectDxf(bytes: Buffer) {
|
|
16
|
+
export function inspectDxf(bytes: Buffer, retainPointDictionaries = false) {
|
|
17
17
|
const binary = bytes.subarray(0, 22).equals(binaryDxfSentinel)
|
|
18
18
|
const binaryLegacy = binary && bytes[22] === 0 && bytes[23] !== 0
|
|
19
19
|
if (binary) bytes = binaryDxfToText(bytes)
|
|
@@ -37,7 +37,7 @@ export function inspectDxf(bytes: Buffer) {
|
|
|
37
37
|
records.push(current)
|
|
38
38
|
}
|
|
39
39
|
if (code === 2 && current?.type === 'SECTION') section = value
|
|
40
|
-
current?.pairs.push({ code, value, line: i + 1 })
|
|
40
|
+
current?.pairs.push({ code, value, line: i + 1,...(retainPointDictionaries&&['POINT','DICTIONARY','XRECORD'].includes(current.type)?{rawValue:lines[i+1]!}:{}) })
|
|
41
41
|
}
|
|
42
42
|
if (!records.some((r) => r.type === 'SECTION') || records.at(-1)?.type !== 'EOF')
|
|
43
43
|
throw new CadError('INVALID_DXF', 'DXF 缺少 SECTION 或 EOF')
|
|
@@ -57,10 +57,12 @@ export function inspectDxf(bytes: Buffer) {
|
|
|
57
57
|
// Keep segments as raw bytes for envelope edits, while retained metadata uses
|
|
58
58
|
// the same declared text encoding as the CAD reader (including legacy GBK).
|
|
59
59
|
for (const record of records)
|
|
60
|
-
for (const pair of record.pairs)
|
|
60
|
+
for (const pair of record.pairs){
|
|
61
61
|
pair.value = iconv
|
|
62
62
|
.decode(Buffer.from(pair.value, 'latin1'), encoding)
|
|
63
63
|
.replace(/\\U\+([0-9a-f]{4})/gi, (_, n) => String.fromCharCode(parseInt(n, 16)))
|
|
64
|
+
if(pair.rawValue!==undefined)pair.rawValue=iconv.decode(Buffer.from(pair.rawValue,'latin1'),encoding).replace(/\\U\+([0-9a-f]{4})/gi,(_,n)=>String.fromCharCode(parseInt(n,16)))
|
|
65
|
+
}
|
|
64
66
|
const legacyR12 = versionIndex >= 0 && header!.pairs[versionIndex + 1]?.value === 'AC1009'
|
|
65
67
|
const pairOf = (r: Record, code: number) => {
|
|
66
68
|
let applicationDepth = 0
|
|
@@ -260,6 +262,7 @@ export function inspectDxf(bytes: Buffer) {
|
|
|
260
262
|
throw new CadError('INVALID_DXF', 'DXF 包含重复图元句柄')
|
|
261
263
|
const blockExtensions = dxfBlockMetadata(records)
|
|
262
264
|
return {
|
|
265
|
+
pointDictionaryRecords: retainPointDictionaries ? records.filter(r=>['POINT','DICTIONARY','XRECORD'].includes(r.type)) : undefined,
|
|
263
266
|
blockMetadata: blockExtensions.metadata,
|
|
264
267
|
blockClips: captureDxfBlockClips(records, blockExtensions.filters),
|
|
265
268
|
xrefSettings: (() => {
|
|
@@ -8,6 +8,38 @@ export interface NativeCapture {
|
|
|
8
8
|
documents: CadNativeDocument[]
|
|
9
9
|
references: Map<object, string>
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
/** Keep every record in referenced blocks, including hidden INSERTs/attributes,
|
|
13
|
+
* then follow definition references. Geometry records and private payloads stay intact. */
|
|
14
|
+
export function sceneNativeDocuments(documents: CadNativeDocument[], instanceRecordIds: string[]) {
|
|
15
|
+
const byBlock = new Map<string, CadNativeRecord[]>(), owners = new Map<string, string>()
|
|
16
|
+
for (const doc of documents) for (const record of doc.records) {
|
|
17
|
+
const block = record.sourceSha256 + ':' + record.blockHandle
|
|
18
|
+
if (!byBlock.has(block)) byBlock.set(block, [])
|
|
19
|
+
byBlock.get(block)!.push(record)
|
|
20
|
+
owners.set(record.id, block)
|
|
21
|
+
}
|
|
22
|
+
const selected = new Set<string>(), pending = instanceRecordIds.map(id => owners.get(id) || id)
|
|
23
|
+
while (pending.length) {
|
|
24
|
+
const id = pending.pop()!
|
|
25
|
+
if (selected.has(id)) continue
|
|
26
|
+
selected.add(id)
|
|
27
|
+
for (const record of byBlock.get(id) || [])
|
|
28
|
+
if (record.insert?.definitionId) pending.push(record.insert.definitionId)
|
|
29
|
+
}
|
|
30
|
+
return documents.map(doc => {
|
|
31
|
+
const records = doc.records.filter(record => selected.has(record.sourceSha256 + ':' + record.blockHandle)),
|
|
32
|
+
blocks = doc.blocks.filter(block => selected.has(block.id))
|
|
33
|
+
return { ...doc, records, blocks,
|
|
34
|
+
selection: { basis: 'scene-referenced-block-closure' as const,
|
|
35
|
+
parsedRecords: doc.records.length, parsedBlocks: doc.blocks.length,
|
|
36
|
+
excludedRecords: doc.records.length - records.length, excludedBlocks: doc.blocks.length - blocks.length },
|
|
37
|
+
coverage: { ...doc.coverage, records: records.length,
|
|
38
|
+
attributes: records.filter(record => record.entityType === 'ATTRIB').length,
|
|
39
|
+
xdataPartialRecords: records.filter(record => record.xdataStatus === 'partial').length },
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
}
|
|
11
43
|
const handle = (v: unknown) => String(v || '').toUpperCase()
|
|
12
44
|
const point = (v: any) =>
|
|
13
45
|
v && [v.x, v.y, v.z ?? 0].every(Number.isFinite) ? [v.x, v.y, v.z ?? 0] : null
|
|
@@ -99,7 +131,7 @@ export function captureNativeEvidence(
|
|
|
99
131
|
const segmentedPath = nativeSegmentedPath(e)
|
|
100
132
|
if (segmentedPath) r.segmentedPath = segmentedPath
|
|
101
133
|
} catch (error) {
|
|
102
|
-
issues.push({
|
|
134
|
+
issues.push({code:'NATIVE_LINEAR_PATH_READ',handle:h,reason:String(error)})
|
|
103
135
|
}
|
|
104
136
|
if (['ATTRIB', 'ATTDEF'].includes(e.dxfTypeName))
|
|
105
137
|
r.attribute = {
|