@rubin-epo/epo-widget-lib 0.9.1 → 0.9.2

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.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react"),_=require("lodash/isEqual"),q=require("../../../hooks/usePrevious.cjs"),f=require("../lib/canvas.cjs"),w=t=>t&&t.__esModule?t:{default:t},S=w(_),b=({images:t,filters:i})=>{const g=q.default(t),[v,d]=l.useState(0),[n,m]=l.useState(),I=n==null?void 0:n.some(({complete:s})=>!s),u=v!==t.length&&I;return l.useLayoutEffect(()=>{S.default(g,t)||(d(0),m(t.map(({url:s,width:o,height:c})=>{const e=new Image(o,c);return e.onload=()=>{d(a=>a+1)},e.src=s,e})))},[t]),u?[[],!!u]:[[...n||[]].map((s,o)=>{if(!i[o].active)return;const c=document.createElement("canvas"),e=c.getContext("2d");if(e){const{width:a,height:r}=s,{color:h="transparent",brightness:p}=i[o];e.canvas.width=a,e.canvas.height=r,e.clearRect(0,0,a,r),e.filter=f.getFilters({brightness:p,contrast:1.3}),e.drawImage(s,0,0,a,r),f.updateColor(e,h,a,r)}return c}).filter(s=>!!s),!!u]},y=b;exports.default=y;
1
+ "use client";"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react"),_=require("lodash/isEqual"),q=require("../../../hooks/usePrevious.cjs"),f=require("../lib/canvas.cjs"),w=t=>t&&t.__esModule?t:{default:t},y=w(_),S=({images:t,filters:l})=>{const g=q.default(t),[v,d]=i.useState(0),[n,m]=i.useState(),I=n==null?void 0:n.some(({complete:s})=>!s),u=v!==t.length&&I;return i.useLayoutEffect(()=>{y.default(g,t)||(d(0),m(t.map(({url:s,width:o,height:r})=>{const e=new Image(o,r);return e.crossOrigin="anonymous",e.onload=()=>{d(a=>a+1)},e.src=s,e})))},[t]),u?[[],!!u]:[[...n||[]].map((s,o)=>{if(!l[o].active)return;const r=document.createElement("canvas"),e=r.getContext("2d");if(e){const{width:a,height:c}=s,{color:h="transparent",brightness:p}=l[o];e.canvas.width=a,e.canvas.height=c,e.clearRect(0,0,a,c),e.filter=f.getFilters({brightness:p,contrast:1.3}),e.drawImage(s,0,0,a,c),f.updateColor(e,h,a,c)}return r}).filter(s=>!!s),!!u]},b=S;exports.default=b;
@@ -2,32 +2,32 @@
2
2
  import { useState as d, useLayoutEffect as h } from "react";
3
3
  import w from "lodash/isEqual";
4
4
  import x from "../../../hooks/usePrevious.js";
5
- import { getFilters as F, updateColor as L } from "../lib/canvas.js";
6
- const y = ({
5
+ import { getFilters as y, updateColor as F } from "../lib/canvas.js";
6
+ const L = ({
7
7
  images: s,
8
8
  filters: u
9
9
  }) => {
10
- const l = x(s), [f, m] = d(0), [a, g] = d(), p = a == null ? void 0 : a.some(({ complete: e }) => !e), i = f !== s.length && p;
10
+ const l = x(s), [f, m] = d(0), [n, g] = d(), p = n == null ? void 0 : n.some(({ complete: e }) => !e), i = f !== s.length && p;
11
11
  return h(() => {
12
12
  w(l, s) || (m(0), g(
13
- s.map(({ url: e, width: n, height: r }) => {
14
- const t = new Image(n, r);
15
- return t.onload = () => {
13
+ s.map(({ url: e, width: a, height: r }) => {
14
+ const t = new Image(a, r);
15
+ return t.crossOrigin = "anonymous", t.onload = () => {
16
16
  m((o) => o + 1);
17
17
  }, t.src = e, t;
18
18
  })
19
19
  ));
20
- }, [s]), i ? [[], !!i] : [[...a || []].map((e, n) => {
21
- if (!u[n].active)
20
+ }, [s]), i ? [[], !!i] : [[...n || []].map((e, a) => {
21
+ if (!u[a].active)
22
22
  return;
23
23
  const r = document.createElement("canvas"), t = r.getContext("2d");
24
24
  if (t) {
25
- const { width: o, height: c } = e, { color: v = "transparent", brightness: I } = u[n];
26
- t.canvas.width = o, t.canvas.height = c, t.clearRect(0, 0, o, c), t.filter = F({ brightness: I, contrast: 1.3 }), t.drawImage(e, 0, 0, o, c), L(t, v, o, c);
25
+ const { width: o, height: c } = e, { color: v = "transparent", brightness: I } = u[a];
26
+ t.canvas.width = o, t.canvas.height = c, t.clearRect(0, 0, o, c), t.filter = y({ brightness: I, contrast: 1.3 }), t.drawImage(e, 0, 0, o, c), F(t, v, o, c);
27
27
  }
28
28
  return r;
29
29
  }).filter((e) => !!e), !!i];
30
- }, R = y;
30
+ }, P = L;
31
31
  export {
32
- R as default
32
+ P as default
33
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubin-epo/epo-widget-lib",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Rubin Observatory Education & Public Outreach team React scientific and educational widgets.",
5
5
  "author": "Rubin EPO",
6
6
  "license": "MIT",