@openpawlabs/diy-guides-ui 1.7.5 → 1.9.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.
Files changed (34) hide show
  1. package/README.md +23 -1
  2. package/bin/diy-guide-images.mjs +317 -0
  3. package/dist/components/GuideLayout/GuideLayout.d.ts.map +1 -1
  4. package/dist/components/GuideLayout/GuideLayout.stories.d.ts.map +1 -1
  5. package/dist/components/GuideResponsiveImage/GuideResponsiveImage.d.ts +23 -0
  6. package/dist/components/GuideResponsiveImage/GuideResponsiveImage.d.ts.map +1 -0
  7. package/dist/components/GuideStep/GuideStep.d.ts +4 -1
  8. package/dist/components/GuideStep/GuideStep.d.ts.map +1 -1
  9. package/dist/components/GuideStep/GuideStep.stories.d.ts.map +1 -1
  10. package/dist/components/MediaFigure/MediaCropEditor.d.ts +9 -7
  11. package/dist/components/MediaFigure/MediaCropEditor.d.ts.map +1 -1
  12. package/dist/components/MediaFigure/MediaFigure.d.ts +6 -4
  13. package/dist/components/MediaFigure/MediaFigure.d.ts.map +1 -1
  14. package/dist/components/MediaFigure/MediaFigure.stories.d.ts.map +1 -1
  15. package/dist/components/MediaFigure/MediaFigureClipFrame.d.ts +13 -1
  16. package/dist/components/MediaFigure/MediaFigureClipFrame.d.ts.map +1 -1
  17. package/dist/components/MediaFigure/MediaFigureThumbnail.d.ts +2 -2
  18. package/dist/components/MediaFigure/MediaFigureThumbnail.d.ts.map +1 -1
  19. package/dist/components/ToolList/ToolList.d.ts.map +1 -1
  20. package/dist/context/guideImageVariants.d.ts +16 -0
  21. package/dist/context/guideImageVariants.d.ts.map +1 -0
  22. package/dist/diy-guides-ui.cjs +6 -6
  23. package/dist/diy-guides-ui.cjs.map +1 -1
  24. package/dist/diy-guides-ui.js +3603 -3377
  25. package/dist/diy-guides-ui.js.map +1 -1
  26. package/dist/index.d.ts +7 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/utils/guideImageSources.d.ts +73 -0
  29. package/dist/utils/guideImageSources.d.ts.map +1 -0
  30. package/dist/utils/guideImageSources.test.d.ts +2 -0
  31. package/dist/utils/guideImageSources.test.d.ts.map +1 -0
  32. package/dist/utils/mediaCrop.d.ts +40 -13
  33. package/dist/utils/mediaCrop.d.ts.map +1 -1
  34. package/package.json +17 -3
package/dist/index.d.ts CHANGED
@@ -7,7 +7,13 @@ export { Callout } from "./components/Callout";
7
7
  export type { CalloutProps } from "./components/Callout";
8
8
  export { MediaFigure, mediaFigureType, MediaFigureThumbnail, MediaCropEditor, } from "./components/MediaFigure";
9
9
  export type { MediaFigureProps, MediaFigureThumbnailProps, MediaCropEditorProps, MediaAnnotation, MediaAnnotationEditing, AnnotationTool, MediaDisplayRegion, PointAnnotation, CircleAnnotation, RectangleAnnotation, } from "./components/MediaFigure";
10
- export { DISPLAY_REGION_ASPECT, MIN_REGION_WIDTH, displayRegionHeight, centeredDisplayRegion, clampDisplayRegion, } from "./utils/mediaCrop";
10
+ export { DISPLAY_REGION_ASPECT, MIN_REGION_WIDTH, displayRegionHeight, displayRegionHeightPercent, displayRegionFromPixels, displayRegionToPixels, isLegacyPixelDisplayRegion, normalizeDisplayRegion, centeredDisplayRegion, clampDisplayRegion, } from "./utils/mediaCrop";
11
+ export { GUIDE_IMAGE_VARIANT_WIDTHS, GUIDE_IMAGE_VARIANT_FORMAT, GUIDE_IMAGE_THUMBNAILS_DIR, GUIDE_IMAGE_VARIANTS_FILENAME, GUIDE_IMAGE_VARIANTS_PATH, guideImageBasename, guideImageVariantUrl, guideImageVariantWidths, resolveGuideImageSrcSet, } from "./utils/guideImageSources";
12
+ export type { GuideImageVariantWidth, GuideImageVariantEntry, GuideImageVariantsManifest, GuideImageRole, GuideImageSrcSet, } from "./utils/guideImageSources";
13
+ export { GuideImageVariantsProvider, useGuideImageVariants, } from "./context/guideImageVariants";
14
+ export type { GuideImageVariantsProviderProps } from "./context/guideImageVariants";
15
+ export { GuideResponsiveImage, useGuideImagePreferredSrc, } from "./components/GuideResponsiveImage/GuideResponsiveImage";
16
+ export type { GuideResponsiveImageProps } from "./components/GuideResponsiveImage/GuideResponsiveImage";
11
17
  export { ToolList } from "./components/ToolList";
12
18
  export type { ToolListProps, ToolListItemProps } from "./components/ToolList";
13
19
  export { LinkButton } from "./components/LinkButton";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAG5B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EACL,KAAK,WAAW,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,YAAY,EACV,oBAAoB,EACpB,UAAU,GACX,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EACL,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,gBAAgB,EAChB,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC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jB,iBAAiB,EACjB,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EACV,kBAAkB,EAClB,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,KAAK,gBAAgB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,kCAAkC,EAClC,mCAAmC,EACnC,+BAA+B,EAC/B,4BAA4B,EAC5B,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+
3
+ * Responsive guide image helpers: variant URL convention + manifest lookup.
4
+
5
+ *
6
+
7
+ * Generated files live under `images/thumbnails/` as `{stem}.w{width}.avif`.
8
+
9
+ * Publishers write `images/thumbnails/variants.json` via the `diy-guide-images`
10
+
11
+ * CLI; without a manifest the UI falls back to a single `src` (no speculative
12
+
13
+ * srcset).
14
+
15
+ */
16
+ export declare const GUIDE_IMAGE_VARIANT_WIDTHS: readonly [240, 480, 800, 1600];
17
+ export type GuideImageVariantWidth = (typeof GUIDE_IMAGE_VARIANT_WIDTHS)[number];
18
+ export declare const GUIDE_IMAGE_VARIANT_FORMAT = "avif";
19
+ /** Directory under `images/` that holds generated AVIF variants + the manifest. */
20
+ export declare const GUIDE_IMAGE_THUMBNAILS_DIR = "thumbnails";
21
+ export declare const GUIDE_IMAGE_VARIANTS_FILENAME = "variants.json";
22
+ /** Relative path from a guide folder: `images/thumbnails/variants.json`. */
23
+ export declare const GUIDE_IMAGE_VARIANTS_PATH = "images/thumbnails/variants.json";
24
+ /** Per-file entry inside {@link GuideImageVariantsManifest}. */
25
+ export interface GuideImageVariantEntry {
26
+ /** Intrinsic width of the canonical source. */
27
+ width: number;
28
+ /** Intrinsic height of the canonical source. */
29
+ height: number;
30
+ /** Generated AVIF widths that exist on disk (subset of {@link GUIDE_IMAGE_VARIANT_WIDTHS}). */
31
+ variants: number[];
32
+ }
33
+ /** Written under `images/thumbnails/` by `diy-guide-images`. */
34
+ export interface GuideImageVariantsManifest {
35
+ version: 1;
36
+ format: typeof GUIDE_IMAGE_VARIANT_FORMAT;
37
+ widths: readonly number[];
38
+ /** Keyed by basename of the canonical file (e.g. `img-4614.webp`). */
39
+ images: Record<string, GuideImageVariantEntry>;
40
+ }
41
+ /** Display roles used to pick default `sizes` and preferred widths. */
42
+ export type GuideImageRole = "thumb" | "catalog" | "display" | "hero";
43
+ /** Basename of a guide image URL or relative path (`./images/foo.webp` → `foo.webp`). */
44
+ export declare function guideImageBasename(src: string): string;
45
+ /**
46
+
47
+ * Build a variant URL under `…/thumbnails/{stem}.w{width}.avif`, preserving
48
+
49
+ * query/hash on the original `src`.
50
+
51
+ */
52
+ export declare function guideImageVariantUrl(src: string, width: number): string;
53
+ /** Look up generated widths for `src` from a manifest, or `null` when unknown. */
54
+ export declare function guideImageVariantWidths(src: string, manifest: GuideImageVariantsManifest | null | undefined): number[] | null;
55
+ export interface GuideImageSrcSet {
56
+ /** Canonical source — always used as `<img src>` fallback / lightbox. */
57
+ src: string;
58
+ /** AVIF srcset string, or `undefined` when no variants are known. */
59
+ srcSet?: string;
60
+ /** Default `sizes` for the role. */
61
+ sizes: string;
62
+ /** Preferred single-width URL for places that only need one small file. */
63
+ preferredSrc: string;
64
+ }
65
+ /**
66
+
67
+ * Resolve srcset / sizes for a guide image. Without a manifest (or entry),
68
+
69
+ * returns the canonical `src` only — never invents URLs that may 404.
70
+
71
+ */
72
+ export declare function resolveGuideImageSrcSet(src: string, role: GuideImageRole, manifest?: GuideImageVariantsManifest | null): GuideImageSrcSet;
73
+ //# sourceMappingURL=guideImageSources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guideImageSources.d.ts","sourceRoot":"","sources":["../../src/utils/guideImageSources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,eAAO,MAAM,0BAA0B,gCAAiC,CAAC;AAIzE,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAIjF,eAAO,MAAM,0BAA0B,SAAS,CAAC;AAIjD,mFAAmF;AAEnF,eAAO,MAAM,0BAA0B,eAAe,CAAC;AAIvD,eAAO,MAAM,6BAA6B,kBAAkB,CAAC;AAI7D,4EAA4E;AAE5E,eAAO,MAAM,yBAAyB,oCAA0E,CAAC;AAIjH,gEAAgE;AAEhE,MAAM,WAAW,sBAAsB;IAErC,+CAA+C;IAE/C,KAAK,EAAE,MAAM,CAAC;IAEd,gDAAgD;IAEhD,MAAM,EAAE,MAAM,CAAC;IAEf,+FAA+F;IAE/F,QAAQ,EAAE,MAAM,EAAE,CAAC;CAEpB;AAID,gEAAgE;AAEhE,MAAM,WAAW,0BAA0B;IAEzC,OAAO,EAAE,CAAC,CAAC;IAEX,MAAM,EAAE,OAAO,0BAA0B,CAAC;IAE1C,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAE1B,sEAAsE;IAEtE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;CAEhD;AAID,uEAAuE;AAEvE,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAgCtE,yFAAyF;AAEzF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAoBtD;AAID;;;;;;GAMG;AAEH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAcvE;AAID,kFAAkF;AAElF,wBAAgB,uBAAuB,CAErC,GAAG,EAAE,MAAM,EAEX,QAAQ,EAAE,0BAA0B,GAAG,IAAI,GAAG,SAAS,GAEtD,MAAM,EAAE,GAAG,IAAI,CAkBjB;AAID,MAAM,WAAW,gBAAgB;IAE/B,yEAAyE;IAEzE,GAAG,EAAE,MAAM,CAAC;IAEZ,qEAAqE;IAErE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,oCAAoC;IAEpC,KAAK,EAAE,MAAM,CAAC;IAEd,2EAA2E;IAE3E,YAAY,EAAE,MAAM,CAAC;CAEtB;AAID;;;;;;GAMG;AAEH,wBAAgB,uBAAuB,CAErC,GAAG,EAAE,MAAM,EAEX,IAAI,EAAE,cAAc,EAEpB,QAAQ,CAAC,EAAE,0BAA0B,GAAG,IAAI,GAE3C,gBAAgB,CAsClB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=guideImageSources.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guideImageSources.test.d.ts","sourceRoot":"","sources":["../../src/utils/guideImageSources.test.ts"],"names":[],"mappings":""}
@@ -1,32 +1,59 @@
1
1
  import type { CSSProperties } from "react";
2
- /** Top-left and width of a 4:3 crop rect in intrinsic source pixels. Height is derived. */
2
+ /**
3
+ * Top-left and width of a 4:3 crop rect as **percentages of the source image**
4
+ * (0–100). Height is derived from the 4:3 aspect against the source’s pixel size.
5
+ * Distinct from annotation coordinates, which are percentages of the visible frame.
6
+ */
3
7
  export interface MediaDisplayRegion {
4
- /** Left edge in pixels from the source left. */
8
+ /** Left edge as a percentage (0–100) of the source width. */
9
+ x: number;
10
+ /** Top edge as a percentage (0–100) of the source height. */
11
+ y: number;
12
+ /** Width as a percentage (0–100) of the source width; height is 4:3-derived. */
13
+ width: number;
14
+ }
15
+ /** Pixel region used only for migration from legacy authored crops. */
16
+ export interface MediaDisplayRegionPixels {
5
17
  x: number;
6
- /** Top edge in pixels from the source top. */
7
18
  y: number;
8
- /** Width in source pixels; height is computed as `round(width × 3 / 4)`. */
9
19
  width: number;
10
20
  }
11
21
  export declare const DISPLAY_REGION_ASPECT: number;
12
- /** Smallest selectable region width, in source pixels, so a crop never collapses. */
22
+ /**
23
+ * Smallest selectable region width in source pixels (converted to % per source).
24
+ * Keeps a crop from collapsing to a point.
25
+ */
13
26
  export declare const MIN_REGION_WIDTH = 16;
14
- /** Height in source pixels for a 4:3 region with the given width. */
15
- export declare function displayRegionHeight(width: number): number;
27
+ /** 4:3 height in source pixels for a pixel width. */
28
+ export declare function displayRegionHeight(widthPx: number): number;
29
+ /** 4:3 height as a percentage of source height for a width percentage. */
30
+ export declare function displayRegionHeightPercent(widthPercent: number, sourceWidth: number, sourceHeight: number): number;
31
+ /**
32
+ * True when a region still looks like legacy **source-pixel** coordinates
33
+ * (any axis above 100). Percentage regions always stay within 0–100.
34
+ */
35
+ export declare function isLegacyPixelDisplayRegion(region: MediaDisplayRegion): boolean;
36
+ /** Convert a legacy pixel region into source percentages. */
37
+ export declare function displayRegionFromPixels(region: MediaDisplayRegionPixels, sourceWidth: number, sourceHeight: number): MediaDisplayRegion;
38
+ /** Convert a percentage region back to source pixels (for tooling / migration). */
39
+ export declare function displayRegionToPixels(region: MediaDisplayRegion, sourceWidth: number, sourceHeight: number): MediaDisplayRegionPixels;
40
+ /**
41
+ * Normalize an incoming region: convert legacy pixel coords when detected, then
42
+ * clamp into a valid percentage box for the source.
43
+ */
44
+ export declare function normalizeDisplayRegion(region: MediaDisplayRegion, sourceWidth: number, sourceHeight: number): MediaDisplayRegion;
16
45
  /**
17
- * Snap a region to integer source pixels and keep its 4:3 box fully inside the
18
- * source: width is bounded by both axes, then `x` / `y` are pinned so the derived
19
- * height fits. Use it to sanitize any externally supplied or in-progress region.
46
+ * Snap a percentage region and keep its 4:3 box fully inside the source.
20
47
  */
21
48
  export declare function clampDisplayRegion(region: MediaDisplayRegion, sourceWidth: number, sourceHeight: number): MediaDisplayRegion;
22
49
  /**
23
50
  * Largest centered 4:3 region for a source — the rect the fixed frame shows when
24
- * no `displayRegion` is set. Used as the starting selection in the crop editor so
25
- * opening it mirrors the current center-crop.
51
+ * no `displayRegion` is set. Used as the starting selection in the crop editor.
26
52
  */
27
53
  export declare function centeredDisplayRegion(sourceWidth: number, sourceHeight: number): MediaDisplayRegion;
28
54
  /**
29
- * CSS styles to show a 4:3 source-pixel region scaled to fill a 4:3 frame.
55
+ * CSS styles to show a 4:3 source region (percentages) scaled to fill a 4:3 frame.
56
+ * Accepts legacy pixel regions and converts them when any axis is above 100.
30
57
  * Returns `null` when the region is invalid for the given source dimensions.
31
58
  */
32
59
  export declare function getDisplayRegionStyles(region: MediaDisplayRegion, sourceWidth: number, sourceHeight: number, frameWidth: number, frameHeight: number): CSSProperties | null;
@@ -1 +1 @@
1
- {"version":3,"file":"mediaCrop.d.ts","sourceRoot":"","sources":["../../src/utils/mediaCrop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,2FAA2F;AAC3F,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,CAAC,EAAE,MAAM,CAAC;IACV,8CAA8C;IAC9C,CAAC,EAAE,MAAM,CAAC;IACV,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAKD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,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AAM,EACnB,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAapB;AAED,mFAAmF;AACnF,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,wBAAwB,CAM1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAKpB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAUpB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAepB;AAgBD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,aAAa,GAAG,IAAI,CA4BtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpawlabs/diy-guides-ui",
3
- "version": "1.7.5",
3
+ "version": "1.9.0",
4
4
  "description": "React UI library for building open-source, iFixit-style step-by-step diy guides",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -8,6 +8,9 @@
8
8
  "main": "./dist/diy-guides-ui.cjs",
9
9
  "module": "./dist/diy-guides-ui.js",
10
10
  "types": "./dist/index.d.ts",
11
+ "bin": {
12
+ "diy-guide-images": "./bin/diy-guide-images.mjs"
13
+ },
11
14
  "exports": {
12
15
  ".": {
13
16
  "import": {
@@ -22,7 +25,8 @@
22
25
  "./styles": "./dist/style.css"
23
26
  },
24
27
  "files": [
25
- "dist"
28
+ "dist",
29
+ "bin"
26
30
  ],
27
31
  "sideEffects": [
28
32
  "**/*.css"
@@ -40,9 +44,16 @@
40
44
  "peerDependencies": {
41
45
  "online-3d-viewer": "^0.18.0",
42
46
  "react": "^18.0.0 || ^19.0.0",
43
- "react-dom": "^18.0.0 || ^19.0.0"
47
+ "react-dom": "^18.0.0 || ^19.0.0",
48
+ "sharp": "^0.34.2"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "sharp": {
52
+ "optional": true
53
+ }
44
54
  },
45
55
  "devDependencies": {
56
+ "sharp": "^0.34.2",
46
57
  "@eslint/js": "^9.28.0",
47
58
  "@heroui/react": "^3.0.0",
48
59
  "@heroui/styles": "^3.0.0",
@@ -77,6 +88,9 @@
77
88
  "publishConfig": {
78
89
  "access": "public"
79
90
  },
91
+ "pnpm": {
92
+ "onlyBuiltDependencies": ["sharp", "esbuild"]
93
+ },
80
94
  "dependencies": {
81
95
  "online-3d-viewer": "^0.18.0"
82
96
  }