Sign In

@aspicio/svelte

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aspicio/svelte - npm Package Compare versions

Comparing version
0.11.1
to
0.12.0
+75
src/AspicioEmbed.svelte
<!--
Batteries-included embed: layer list + interactive preview in one
component — a thin Svelte veneer over the framework-neutral
<aspicio-embed> element from @aspicio/elements, styled like the Aspicio
demo app (blueprint grid, dark panel) unless theme="none". Pass the DXF
as `src` (text, File, Blob, ArrayBuffer) or `srcUrl`; everything else
is optional.
<AspicioEmbed srcUrl="/drawing.dxf" style="height: 480px" onloaded={...} />
`bind:this` exposes `viewer()` — the full DrawingViewer for camera control;
use AspicioPreview + AspicioLayerPanel directly when you need a custom layout.
-->
<script>
import "@aspicio/elements";
let {
/** DXF data: text, File, Blob, or ArrayBuffer. The most recently set of src/srcUrl wins. */
src = null,
/** URL to fetch a DXF from. The most recently set of src/srcUrl wins. */
srcUrl = null,
/** Viewer options, applied at creation (changing them recreates the viewer). */
options = undefined,
/** Where the layer list sits: "left" | "right" | "none". */
panel = "left",
/** Visual theme. Defaults to the Aspicio demo look. */
theme = "aspicio",
/** Inline styles applied to the inner layer panel (CSSOM values, e.g. "300px"). */
panelStyle = undefined,
/** Show the built-in Download control (SVG / PNG export). */
showDownload = true,
/** Keyboard shortcuts on the focused viewer: F fit, +/- zoom, R reset, A show all. */
shortcuts = false,
/** ({ layers, stats }) after each successful load. */
onloaded = undefined,
/** (error) when a load fails. */
onloaderror = undefined,
/** (viewer | null) when the viewer is created or the element disconnects. */
onviewerchange = undefined,
/** (layer | null) for the layer under the cursor. */
onhoverlayer = undefined,
/** Extra attributes (class, style, …) forwarded to the element. */
...rest
} = $props();
// Assigned by bind:this (compiler-generated; linter can't see it).
let el = null;
/** The live DrawingViewer instance, or null before mount / after unmount. */
export function viewer() {
return el?.viewer ?? null;
}
// panelStyle is a property-only field on the element (rich object), and
// Svelte lowercases template attribute names — assign it imperatively.
$effect(() => {
if (el) el.panelStyle = panelStyle;
});
</script>
<aspicio-embed
bind:this={el}
{src}
src-url={srcUrl}
{options}
{panel}
{theme}
no-download={!showDownload || undefined}
{shortcuts}
onloaded={(e) => onloaded?.(e.detail)}
onload-error={(e) => onloaderror?.(e.detail.error)}
onviewer-change={(e) => onviewerchange?.(e.detail.viewer)}
onhover-layer={(e) => onhoverlayer?.(e.detail.layer)}
{...rest}
></aspicio-embed>
<!--
Ready-made layer list for an embedded viewer — a thin Svelte veneer over
the framework-neutral <aspicio-layer-panel> element from
@aspicio/elements. Matches the Aspicio demo app: header with layer
count, visibility checkboxes, effective-color swatches, entity counts,
hover-to-highlight, double-click-to-solo (with a banner), canvas-hover
reverse-highlight, and a gesture-hints footer. Pass theme="none" for a
minimal list; style internals via the element's ::part() hooks and
--aspicio-* custom properties.
-->
<script>
import "@aspicio/elements";
let {
/** The viewer to control — from AspicioPreview's viewer() or onviewerchange. */
viewer = null,
/** Visual theme. Defaults to the Aspicio demo look; "none" renders a minimal list. */
theme = "aspicio",
/** Layer hovered on the canvas; its row is reverse-highlighted. */
reverseHighlightLayer = null,
/** Show the gesture-hints footer (themed mode only). */
hints = true,
/** Extra attributes (class, style, …) forwarded to the element. */
...rest
} = $props();
</script>
<aspicio-layer-panel
{viewer}
{theme}
reverse-highlight-layer={reverseHighlightLayer}
no-hints={!hints || undefined}
{...rest}
></aspicio-layer-panel>
<!--
Chrome-less embeddable DXF viewer — a thin Svelte veneer over the
framework-neutral <aspicio-preview> element from @aspicio/elements.
`bind:this` exposes `viewer()` — the full DrawingViewer for camera control,
layer toggling, and hit-testing; pair with AspicioLayerPanel for a
ready-made layer list. Providing `onhoverlayer` enables canvas
hover-picking (parity with the React and Vue bindings).
-->
<script>
import "@aspicio/elements";
let {
/** DXF data: text, File, Blob, or ArrayBuffer. The most recently set of src/srcUrl wins. */
src = null,
/** URL to fetch a DXF from. The most recently set of src/srcUrl wins. */
srcUrl = null,
/** Viewer options, applied at creation (changing them recreates the viewer). */
options = undefined,
/** Show the built-in Download control (SVG / PNG export). */
showDownload = true,
/** Keyboard shortcuts on the focused viewer: F fit, +/- zoom, R reset, A show all. */
shortcuts = false,
/** Force canvas hover-picking on/off; defaults to on when onhoverlayer is provided. */
hoverPick = undefined,
/** ({ layers, stats }) after each successful load. */
onloaded = undefined,
/** (error) when a load fails. */
onloaderror = undefined,
/** (viewer | null) when the viewer is created or the element disconnects. */
onviewerchange = undefined,
/** (layer | null) for the layer under the cursor; providing it enables picking. */
onhoverlayer = undefined,
/** Extra attributes (class, style, …) forwarded to the element. */
...rest
} = $props();
// Assigned by bind:this (compiler-generated; linter can't see it).
let el = null;
/** The live DrawingViewer instance, or null before mount / after unmount. */
export function viewer() {
return el?.viewer ?? null;
}
</script>
<aspicio-preview
bind:this={el}
{src}
src-url={srcUrl}
{options}
no-download={!showDownload || undefined}
{shortcuts}
hover-pick={(hoverPick ?? onhoverlayer != null) || undefined}
onloaded={(e) => onloaded?.(e.detail)}
onload-error={(e) => onloaderror?.(e.detail.error)}
onviewer-change={(e) => onviewerchange?.(e.detail.viewer)}
onhover-layer={(e) => onhoverlayer?.(e.detail.layer)}
{...rest}
></aspicio-preview>
/** Side-effect module: importing it registers the DXF parser (SVELTE-9). */
export {};
/**
* @aspicio/svelte/formats/dxf — teach the Svelte components to read DXF.
*
* ```js
* import "@aspicio/svelte/formats/dxf";
* ```
*
* A re-export of the elements format module: the components are veneers over
* the web components, so they share one registry. Importing this module is the
* whole API; a bundle that never imports it carries no DXF code (INV-11).
*
* Plain JS, like the rest of this package — it ships as source (SVELTE-8).
*/
import "@aspicio/elements/formats/dxf";
/** Side-effect module: importing it registers the PDF parser (SVELTE-9). */
export {};
/**
* @aspicio/svelte/formats/pdf — teach the Svelte components to read PDF.
*
* ```js
* import "@aspicio/svelte/formats/pdf";
* ```
*
* A re-export of the elements format module: the components are veneers over
* the web components, so they share one registry. Importing this module is the
* whole API; a bundle that never imports it carries no PDF code (INV-11).
*
* Plain JS, like the rest of this package — it ships as source (SVELTE-8).
*/
import "@aspicio/elements/formats/pdf";
+17
-5
{
"name": "@aspicio/svelte",
"version": "0.11.1",
"description": "Svelte 5 bindings for the Aspicio DXF viewer.",
"version": "0.12.0",
"description": "Svelte 5 bindings for the Aspicio DXF and PDF viewer.",
"homepage": "https://github.com/frontsail-ai/aspicio/tree/master/packages/svelte#readme",

@@ -17,3 +17,5 @@ "license": "MIT",

"type": "module",
"sideEffects": false,
"sideEffects": [
"./src/formats/*"
],
"svelte": "./src/index.js",

@@ -26,2 +28,12 @@ "exports": {

},
"./formats/dxf": {
"types": "./src/formats/dxf.d.ts",
"svelte": "./src/formats/dxf.js",
"default": "./src/formats/dxf.js"
},
"./formats/pdf": {
"types": "./src/formats/pdf.d.ts",
"svelte": "./src/formats/pdf.js",
"default": "./src/formats/pdf.js"
},
"./package.json": "./package.json"

@@ -37,4 +49,4 @@ },

"dependencies": {
"@aspicio/core": "^0.11.1",
"@aspicio/elements": "^0.11.1"
"@aspicio/core": "^0.12.0",
"@aspicio/elements": "^0.12.0"
},

@@ -41,0 +53,0 @@ "devDependencies": {

+20
-10
# @aspicio/svelte
Svelte 5 bindings for the
[Aspicio](https://github.com/frontsail-ai/aspicio#readme) DXF viewer —
[Aspicio](https://github.com/frontsail-ai/aspicio#readme) DXF and PDF
viewer —
thin veneers over the framework-neutral

@@ -17,8 +18,8 @@ [`@aspicio/elements`](../elements) web components, so Svelte, React,

- `<DxfEmbed>` — batteries included: layer list + interactive preview in
- `<AspicioEmbed>` — batteries included: layer list + interactive preview in
one component.
- `<DxfPreview>` — the embeddable canvas alone: pan/zoom/rotate (mouse
- `<AspicioPreview>` — the embeddable canvas alone: pan/zoom/rotate (mouse
and multi-touch), animated fit, batched WebGL rendering. No chrome.
Providing `onhoverlayer` hit-tests the layer under the cursor.
- `<DxfLayerPanel>` — the ready-made layer list, identical to the demo
- `<AspicioLayerPanel>` — the ready-made layer list, identical to the demo
app: header with layer count, visibility checkboxes, effective-color

@@ -33,3 +34,4 @@ swatches, entity counts, hover-to-highlight, double-click-to-solo

<script>
import { DxfEmbed } from "@aspicio/svelte";
import { AspicioEmbed } from "@aspicio/svelte";
import "@aspicio/svelte/formats/dxf";

@@ -40,3 +42,3 @@ const onloaded = ({ layers, stats }) => console.log(stats.entityCount);

<!-- src also accepts File | Blob | ArrayBuffer | DXF text -->
<DxfEmbed srcUrl="/drawing.dxf" style="height: 480px" {onloaded} />
<AspicioEmbed srcUrl="/drawing.dxf" style="height: 480px" {onloaded} />
```

@@ -51,3 +53,3 @@

`bind:this` exposes `viewer()` — the complete `DxfViewer` (`fitView`,
`bind:this` exposes `viewer()` — the complete `DrawingViewer` (`fitView`,
`zoomBy`, `setLayerVisible`, `pickLayer`, `view`, `toSVG`, `toPNG`):

@@ -57,7 +59,7 @@

<script>
import { DxfEmbed } from "@aspicio/svelte";
import { AspicioEmbed } from "@aspicio/svelte";
let embed;
</script>
<DxfEmbed bind:this={embed} srcUrl="/drawing.dxf" />
<AspicioEmbed bind:this={embed} srcUrl="/drawing.dxf" />
<button onclick={() => embed.viewer()?.fitView()}>Fit</button>

@@ -68,3 +70,3 @@ ```

Compose `DxfPreview` + `DxfLayerPanel` yourself and hand the panel the
Compose `AspicioPreview` + `AspicioLayerPanel` yourself and hand the panel the
viewer from `onviewerchange`; `reverseHighlightLayer` wires canvas-hover

@@ -91,1 +93,9 @@ to the row highlight (the embed does this automatically).

full setup.
## Migrating from 0.x
Two breaking changes ship together:
1. **Formats are opted into by import.** Add `import "@aspicio/svelte/formats/dxf";` once —
without it every load fails with an error saying exactly that.
2. **Format-neutral names dropped their `Dxf` prefix**: `<DxfEmbed>` / `<DxfPreview>` / `<DxfLayerPanel>` → `<AspicioEmbed>` / `<AspicioPreview>` / `<AspicioLayerPanel>`, `DxfTheme` → `AspicioTheme`, and `DxfViewer` → `DrawingViewer`.

@@ -5,4 +5,10 @@ /**

*/
import type { DxfSource, DxfViewer, DxfViewerOptions, LayerInfo, ViewerStats } from "@aspicio/core";
import type { DxfTheme, PanelSide } from "@aspicio/elements";
import type {
DrawingSource,
DrawingViewer,
DrawingViewerOptions,
LayerInfo,
ViewerStats,
} from "@aspicio/core";
import type { AspicioTheme, PanelSide } from "@aspicio/elements";
import type { Component } from "svelte";

@@ -20,7 +26,7 @@

/** DXF data: text, File, Blob, or ArrayBuffer. The most recently set of src/srcUrl wins. */
src?: DxfSource | null;
src?: DrawingSource | null;
/** URL to fetch a DXF from. The most recently set of src/srcUrl wins. */
srcUrl?: string | null;
/** Viewer options, applied at creation (changing them recreates the viewer). */
options?: DxfViewerOptions;
options?: DrawingViewerOptions;
/** Fires after each successful load. */

@@ -31,3 +37,3 @@ onloaded?: (info: LoadedInfo) => void;

/** Fires with the viewer on creation and null on disconnect. */
onviewerchange?: (viewer: DxfViewer | null) => void;
onviewerchange?: (viewer: DrawingViewer | null) => void;
/** Layer under the cursor, or null. Providing it enables hover-picking. */

@@ -43,3 +49,3 @@ onhoverlayer?: (layer: string | null) => void;

export interface DxfPreviewProps extends SourceProps {
export interface AspicioPreviewProps extends SourceProps {
/** Force canvas hover-picking on/off; defaults to on when onhoverlayer is provided. */

@@ -49,7 +55,7 @@ hoverPick?: boolean;

export interface DxfEmbedProps extends SourceProps {
export interface AspicioEmbedProps extends SourceProps {
/** Where the layer list sits. Default: "left". */
panel?: PanelSide;
/** Visual theme. Defaults to the Aspicio demo look. */
theme?: DxfTheme;
theme?: AspicioTheme;
/** Inline styles applied to the inner layer panel (CSSOM values, e.g. "300px"). */

@@ -59,7 +65,7 @@ panelStyle?: Partial<CSSStyleDeclaration>;

export interface DxfLayerPanelProps {
/** The viewer to control — from DxfPreview's viewer() or onviewerchange. */
viewer?: DxfViewer | null;
export interface AspicioLayerPanelProps {
/** The viewer to control — from AspicioPreview's viewer() or onviewerchange. */
viewer?: DrawingViewer | null;
/** Visual theme. Defaults to the Aspicio demo look; "none" renders a minimal list. */
theme?: DxfTheme;
theme?: AspicioTheme;
/** Layer hovered on the canvas; its row is reverse-highlighted. */

@@ -74,8 +80,8 @@ reverseHighlightLayer?: string | null;

export interface ViewerHandle {
/** The live DxfViewer instance, or null before mount / after unmount. */
viewer(): DxfViewer | null;
/** The live DrawingViewer instance, or null before mount / after unmount. */
viewer(): DrawingViewer | null;
}
export declare const DxfEmbed: Component<DxfEmbedProps, ViewerHandle>;
export declare const DxfPreview: Component<DxfPreviewProps, ViewerHandle>;
export declare const DxfLayerPanel: Component<DxfLayerPanelProps>;
export declare const AspicioEmbed: Component<AspicioEmbedProps, ViewerHandle>;
export declare const AspicioPreview: Component<AspicioPreviewProps, ViewerHandle>;
export declare const AspicioLayerPanel: Component<AspicioLayerPanelProps>;
/**
* @aspicio/svelte — Svelte 5 bindings for the Aspicio DXF viewer.
*
* <DxfPreview> embeds the interactive canvas; <DxfLayerPanel> is an
* <AspicioPreview> embeds the interactive canvas; <AspicioLayerPanel> is an
* optional ready-made layer list. Compose them, or build your own chrome
* on the DxfViewer instance exposed via bind:this / onviewerchange. The
* on the DrawingViewer instance exposed via bind:this / onviewerchange. The
* components are thin veneers over the framework-neutral

@@ -15,5 +15,5 @@ * @aspicio/elements web components, so Svelte, React, Vue, and

export { default as DxfEmbed } from "./DxfEmbed.svelte";
export { default as DxfLayerPanel } from "./DxfLayerPanel.svelte";
export { default as DxfPreview } from "./DxfPreview.svelte";
export { default as AspicioEmbed } from "./AspicioEmbed.svelte";
export { default as AspicioLayerPanel } from "./AspicioLayerPanel.svelte";
export { default as AspicioPreview } from "./AspicioPreview.svelte";
export { aspicioTokens } from "@aspicio/elements";
<!--
Batteries-included embed: layer list + interactive preview in one
component — a thin Svelte veneer over the framework-neutral
<aspicio-embed> element from @aspicio/elements, styled like the Aspicio
demo app (blueprint grid, dark panel) unless theme="none". Pass the DXF
as `src` (text, File, Blob, ArrayBuffer) or `srcUrl`; everything else
is optional.
<DxfEmbed srcUrl="/drawing.dxf" style="height: 480px" onloaded={...} />
`bind:this` exposes `viewer()` — the full DxfViewer for camera control;
use DxfPreview + DxfLayerPanel directly when you need a custom layout.
-->
<script>
import "@aspicio/elements";
let {
/** DXF data: text, File, Blob, or ArrayBuffer. The most recently set of src/srcUrl wins. */
src = null,
/** URL to fetch a DXF from. The most recently set of src/srcUrl wins. */
srcUrl = null,
/** Viewer options, applied at creation (changing them recreates the viewer). */
options = undefined,
/** Where the layer list sits: "left" | "right" | "none". */
panel = "left",
/** Visual theme. Defaults to the Aspicio demo look. */
theme = "aspicio",
/** Inline styles applied to the inner layer panel (CSSOM values, e.g. "300px"). */
panelStyle = undefined,
/** Show the built-in Download control (SVG / PNG export). */
showDownload = true,
/** Keyboard shortcuts on the focused viewer: F fit, +/- zoom, R reset, A show all. */
shortcuts = false,
/** ({ layers, stats }) after each successful load. */
onloaded = undefined,
/** (error) when a load fails. */
onloaderror = undefined,
/** (viewer | null) when the viewer is created or the element disconnects. */
onviewerchange = undefined,
/** (layer | null) for the layer under the cursor. */
onhoverlayer = undefined,
/** Extra attributes (class, style, …) forwarded to the element. */
...rest
} = $props();
// Assigned by bind:this (compiler-generated; linter can't see it).
let el = null;
/** The live DxfViewer instance, or null before mount / after unmount. */
export function viewer() {
return el?.viewer ?? null;
}
// panelStyle is a property-only field on the element (rich object), and
// Svelte lowercases template attribute names — assign it imperatively.
$effect(() => {
if (el) el.panelStyle = panelStyle;
});
</script>
<aspicio-embed
bind:this={el}
{src}
src-url={srcUrl}
{options}
{panel}
{theme}
no-download={!showDownload || undefined}
{shortcuts}
onloaded={(e) => onloaded?.(e.detail)}
onload-error={(e) => onloaderror?.(e.detail.error)}
onviewer-change={(e) => onviewerchange?.(e.detail.viewer)}
onhover-layer={(e) => onhoverlayer?.(e.detail.layer)}
{...rest}
></aspicio-embed>
<!--
Ready-made layer list for an embedded viewer — a thin Svelte veneer over
the framework-neutral <aspicio-layer-panel> element from
@aspicio/elements. Matches the Aspicio demo app: header with layer
count, visibility checkboxes, effective-color swatches, entity counts,
hover-to-highlight, double-click-to-solo (with a banner), canvas-hover
reverse-highlight, and a gesture-hints footer. Pass theme="none" for a
minimal list; style internals via the element's ::part() hooks and
--aspicio-* custom properties.
-->
<script>
import "@aspicio/elements";
let {
/** The viewer to control — from DxfPreview's viewer() or onviewerchange. */
viewer = null,
/** Visual theme. Defaults to the Aspicio demo look; "none" renders a minimal list. */
theme = "aspicio",
/** Layer hovered on the canvas; its row is reverse-highlighted. */
reverseHighlightLayer = null,
/** Show the gesture-hints footer (themed mode only). */
hints = true,
/** Extra attributes (class, style, …) forwarded to the element. */
...rest
} = $props();
</script>
<aspicio-layer-panel
{viewer}
{theme}
reverse-highlight-layer={reverseHighlightLayer}
no-hints={!hints || undefined}
{...rest}
></aspicio-layer-panel>
<!--
Chrome-less embeddable DXF viewer — a thin Svelte veneer over the
framework-neutral <aspicio-preview> element from @aspicio/elements.
`bind:this` exposes `viewer()` — the full DxfViewer for camera control,
layer toggling, and hit-testing; pair with DxfLayerPanel for a
ready-made layer list. Providing `onhoverlayer` enables canvas
hover-picking (parity with the React and Vue bindings).
-->
<script>
import "@aspicio/elements";
let {
/** DXF data: text, File, Blob, or ArrayBuffer. The most recently set of src/srcUrl wins. */
src = null,
/** URL to fetch a DXF from. The most recently set of src/srcUrl wins. */
srcUrl = null,
/** Viewer options, applied at creation (changing them recreates the viewer). */
options = undefined,
/** Show the built-in Download control (SVG / PNG export). */
showDownload = true,
/** Keyboard shortcuts on the focused viewer: F fit, +/- zoom, R reset, A show all. */
shortcuts = false,
/** Force canvas hover-picking on/off; defaults to on when onhoverlayer is provided. */
hoverPick = undefined,
/** ({ layers, stats }) after each successful load. */
onloaded = undefined,
/** (error) when a load fails. */
onloaderror = undefined,
/** (viewer | null) when the viewer is created or the element disconnects. */
onviewerchange = undefined,
/** (layer | null) for the layer under the cursor; providing it enables picking. */
onhoverlayer = undefined,
/** Extra attributes (class, style, …) forwarded to the element. */
...rest
} = $props();
// Assigned by bind:this (compiler-generated; linter can't see it).
let el = null;
/** The live DxfViewer instance, or null before mount / after unmount. */
export function viewer() {
return el?.viewer ?? null;
}
</script>
<aspicio-preview
bind:this={el}
{src}
src-url={srcUrl}
{options}
no-download={!showDownload || undefined}
{shortcuts}
hover-pick={(hoverPick ?? onhoverlayer != null) || undefined}
onloaded={(e) => onloaded?.(e.detail)}
onload-error={(e) => onloaderror?.(e.detail.error)}
onviewer-change={(e) => onviewerchange?.(e.detail.viewer)}
onhover-layer={(e) => onhoverlayer?.(e.detail.layer)}
{...rest}
></aspicio-preview>