@maqiuyao/dxf-viewer 0.2.5 → 0.2.7

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.
@@ -53,6 +53,11 @@ export interface ModelConfig {
53
53
  * Source url of the model
54
54
  */
55
55
  src: string;
56
+ /**
57
+ * 下载 src 时附带的自定义 HTTP 请求头,如 { Authorization: "Bearer xxx" }。
58
+ * 未指定时使用 viewer.setRequestHeaders() 设置的全局默认请求头。
59
+ */
60
+ headers?: Record<string, string>;
56
61
  /**
57
62
  * Used to distinguish format, because it may be hard to know the format by src!
58
63
  * @internal
@@ -190,6 +190,10 @@ export interface DxfLoaderConfig {
190
190
  * File encoding, can be used by dxf. Common encoding include "UTF-8", "gb2312", etc.
191
191
  */
192
192
  encoding?: string;
193
+ /**
194
+ * Custom HTTP request headers (e.g. auth token) attached when downloading the dxf file.
195
+ */
196
+ requestHeaders?: Record<string, string>;
193
197
  /**
194
198
  * Apply this color to everything in this model.
195
199
  * Color value between 0 and 1.
@@ -307,11 +311,6 @@ export declare class DxfLoader extends THREE.Loader {
307
311
  */
308
312
  private entityHandlesWithRenderOrder;
309
313
  private addViewport;
310
- /**
311
- * 说明:该静态属性在 bundle 中只被读取、从未被赋值(原始拼写可能有误),
312
- * 运行时恒为 undefined;此处按原样保留。
313
- */
314
- private static readonly REQUWSTHEADER?;
315
314
  /**
316
315
  * 说明:以下静态字段在 bundle 中于类定义之后统一赋值,此处以字段初始化器的形式等价还原。
317
316
  */
@@ -217,6 +217,8 @@ export declare class Viewer2d extends BaseViewer {
217
217
  private clickHighlightList?;
218
218
  /** 是否启用点击实体高亮,默认关闭 */
219
219
  private _enableClickHighlight;
220
+ /** 全局默认请求头(如认证 token),loadModel 未显式传 headers 时使用 */
221
+ private requestHeaders?;
220
222
  /** 打印截图进行中:临时强制显示所有图符/文字,避免低缩放时被"视觉过小"逻辑隐藏 */
221
223
  private _printCaptureMode;
222
224
  constructor(viewerCfg: Viewer2dConfig);
@@ -249,6 +251,16 @@ export declare class Viewer2d extends BaseViewer {
249
251
  * 清除实体点击高亮。
250
252
  */
251
253
  clearClickHighlight(): void;
254
+ /**
255
+ * 设置后续所有 loadModel 下载 src 时附带的默认 HTTP 请求头(如认证 token)。
256
+ * 传入 undefined 可清除。按次在 modelCfg.headers 中指定的请求头优先级更高。
257
+ * @example
258
+ * ```typescript
259
+ * viewer.setRequestHeaders({ Authorization: "Bearer " + token });
260
+ * await viewer.loadModel({ modelId: "a", src: "https://host/a.dxf" });
261
+ * ```
262
+ */
263
+ setRequestHeaders(headers: Record<string, string> | undefined): void;
252
264
  protected handleMouseClick(e: EventInfo): void;
253
265
  private setDefaultBackground;
254
266
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maqiuyao/dxf-viewer",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "基于 three.js 的 DXF 图纸 2D/3D 查看与对比库(Viewer2d / DxfCompareHelper)",
5
5
  "type": "module",
6
6
  "main": "./dist/dxf-viewer.cjs",