@rubin-epo/epo-widget-lib 0.6.10 → 0.6.12-rc.1
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/dist/ColorTool.cjs +1 -1
- package/dist/ColorTool.js +1 -1
- package/dist/ColorToolServer.cjs +1 -1
- package/dist/ColorToolServer.d.ts +2 -2
- package/dist/ColorToolServer.js +12 -19
- package/dist/localeStrings/es/epo-widget-lib.json +1 -1
- package/dist/widgets/ColorTool/Actions/Reset/index.cjs +1 -1
- package/dist/widgets/ColorTool/Actions/Reset/index.js +1 -1
- package/dist/widgets/ColorTool/Actions/index.cjs +1 -1
- package/dist/widgets/ColorTool/Actions/index.js +1 -1
- package/dist/widgets/ColorTool/CompositeRender/index.cjs +1 -1
- package/dist/widgets/ColorTool/CompositeRender/index.js +1 -1
- package/dist/widgets/ColorTool/FilterControls/FilterControls.cjs +1 -1
- package/dist/widgets/ColorTool/FilterControls/FilterControls.js +1 -1
- package/dist/widgets/ColorTool/ImageComposite/ImageComposite.cjs +1 -1
- package/dist/widgets/ColorTool/ImageComposite/ImageComposite.js +1 -1
- package/dist/widgets/ColorTool/OffscreenFilter/index.cjs +1 -1
- package/dist/widgets/ColorTool/OffscreenFilter/index.js +12 -13
- package/dist/widgets/ColorTool/lib/canvas.cjs +1 -0
- package/dist/widgets/ColorTool/lib/canvas.d.ts +5 -0
- package/dist/widgets/ColorTool/lib/canvas.js +18 -0
- package/dist/widgets/ColorTool/lib/canvas.test.d.ts +1 -0
- package/dist/widgets/ColorTool/{server.d.ts → lib/server.d.ts} +1 -1
- package/dist/widgets/ColorTool/lib/utils.cjs +1 -0
- package/dist/widgets/ColorTool/{utilities.d.ts → lib/utils.d.ts} +1 -6
- package/dist/widgets/ColorTool/lib/utils.js +35 -0
- package/package.json +1 -1
- package/dist/widgets/ColorTool/utilities.cjs +0 -1
- package/dist/widgets/ColorTool/utilities.js +0 -47
package/dist/ColorTool.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),m=require("react"),O=require("react-i18next"),W=require("./widgets/ColorTool/
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),m=require("react"),O=require("react-i18next"),W=require("./widgets/ColorTool/lib/utils.cjs"),l=require("./widgets/ColorTool/styles.cjs"),H=require("@rubin-epo/epo-react-lib/SelectListbox"),R=require("./widgets/ColorTool/Actions/index.cjs"),y=require("./widgets/ColorTool/ImageComposite/ImageComposite.cjs"),$=require("./widgets/ColorTool/FilterControls/FilterControls.cjs"),v=o=>o&&o.__esModule?o:{default:o},N=v(H),p=({data:o,objectOptions:T=[],selectedData:d,colorOptions:L=[],selectionCallback:r,isDisabled:u=!1,isDisplayOnly:C=!1,className:x,config:S={actions:["reset"],width:600,height:600,hideSubtitle:!1}})=>{const _={actions:["reset"],width:600,height:600,hideSubtitle:!1},h=m.useRef(null),{t:s}=O.useTranslation(),{filters:i,name:n}=d,{actions:q,width:a,height:c,hideSubtitle:F}={..._,...S};if(C)return e.jsx(y.default,{ref:h,filters:i,width:a,height:c,selectedObjectName:n,className:x});const w=t=>{const{label:f}=t,{filters:b}=d,M=b.map(g=>g.label===f?t:g);return r&&r({...d,filters:M})},I=t=>{if(t)return r&&r({name:t,filters:W.getDataFiltersByName(o,t)})},j=o.length>1,B=s("colorTool.actions.select_an_object");return e.jsx(l.WidgetContainer,{className:x,children:e.jsxs(l.WidgetLayout,{style:{"--image-width":typeof a=="number"?`${a}px`:a,"--image-height":typeof c=="number"?`${c}px`:c},children:[n&&j&&e.jsx(l.Title,{children:!F&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:s("colorTool.labels.object")}),e.jsx("dd",{children:n})]})}),e.jsxs(l.ControlsContainer,{children:[i&&e.jsxs(e.Fragment,{children:[e.jsx(l.ToolsHeader,{id:"filterLabel",children:s("colorTool.labels.filter")}),e.jsx(l.ToolsHeader,{id:"colorLabel",children:s("colorTool.labels.color")}),e.jsx(l.ToolsHeader,{id:"intensityLabel",children:s("colorTool.labels.color_intensity")})]}),i&&i.map(t=>{const{label:f,isDisabled:b}=t;return m.createElement($.default,{filter:t,colorOptions:L,key:`filter-${f}`,isDisabled:u||b,onChangeFilterCallback:w,buttonLabelledById:"filterLabel",selectLabelledById:"colorLabel",sliderLabelledById:"intensityLabel"})})]}),e.jsx(y.default,{ref:h,filters:i,width:a,height:c,selectedObjectName:n,children:j&&e.jsx(l.SelectionContainer,{children:e.jsx(N.default,{id:"astroObjectSelector",placeholder:B,options:T,onChangeCallback:I,value:n,isDisabled:u,width:"100%",maxWidth:"100%"})})}),e.jsx(R.default,{actions:q,canvas:h.current,selectedData:d,isDisabled:u,selectionCallback:r})]})})};p.displayName="Widgets.ColorTool";exports.default=p;
|
package/dist/ColorTool.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as c, Fragment as L } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as $, createElement as N } from "react";
|
|
3
3
|
import { useTranslation as R } from "react-i18next";
|
|
4
|
-
import { getDataFiltersByName as A } from "./widgets/ColorTool/
|
|
4
|
+
import { getDataFiltersByName as A } from "./widgets/ColorTool/lib/utils.js";
|
|
5
5
|
import { WidgetContainer as E, WidgetLayout as H, Title as M, ControlsContainer as P, ToolsHeader as b, SelectionContainer as q } from "./widgets/ColorTool/styles.js";
|
|
6
6
|
import v from "@rubin-epo/epo-react-lib/SelectListbox";
|
|
7
7
|
import z from "./widgets/ColorTool/Actions/index.js";
|
package/dist/ColorToolServer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("skia-canvas"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("skia-canvas"),o=require("./widgets/ColorTool/lib/canvas.cjs");async function d(n=[],a=600,e=600){const s=n.filter(({active:r})=>r),l=await Promise.all(s.map(async({image:r,color:m="transparent",brightness:g=1})=>{const C=await c.loadImage(r),v=new c.Canvas(a,e),t=v.getContext("2d");return t.clearRect(0,0,a,e),t.filter=o.getFilters({brightness:g,contrast:1.3}),t.drawImage(C,0,0,a,e),o.updateColor(t,m,a,e),v})),u=new c.Canvas(a,e),i=u.getContext("2d");return o.mergeCanvases(i,l,a,e),u}const f=async(n=[],a="png",e=600,s=600)=>(await d(n,e,s)).toDataURL(a,{matte:"#000000"});exports.default=f;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './widgets/ColorTool/server'
|
|
2
|
-
import _default from './widgets/ColorTool/server'
|
|
1
|
+
export * from './widgets/ColorTool/lib/server'
|
|
2
|
+
import _default from './widgets/ColorTool/lib/server'
|
|
3
3
|
export default _default
|
package/dist/ColorToolServer.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getFilters as C } from "./widgets/ColorTool/
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
async function y(e = [], a = 600, t = 600) {
|
|
11
|
-
const n = e.filter(({ active: c }) => c), s = await Promise.all(
|
|
12
|
-
n.map(
|
|
13
|
-
async ({ image: c, color: p = "transparent", brightness: g }) => {
|
|
14
|
-
const l = new i(a, t), r = l.getContext("2d"), f = await v(c);
|
|
15
|
-
return r.drawImage(f, 0, 0, a, t), r.globalCompositeOperation = "multiply", r.filter = C({ brightness: g, contrast: 1.3 }), u(r, p, a, t), l;
|
|
1
|
+
import { loadImage as p, Canvas as l } from "skia-canvas";
|
|
2
|
+
import { getFilters as u, updateColor as C, mergeCanvases as x } from "./widgets/ColorTool/lib/canvas.js";
|
|
3
|
+
async function d(n = [], a = 600, t = 600) {
|
|
4
|
+
const s = n.filter(({ active: r }) => r), c = await Promise.all(
|
|
5
|
+
s.map(
|
|
6
|
+
async ({ image: r, color: v = "transparent", brightness: f = 1 }) => {
|
|
7
|
+
const i = await p(r), m = new l(a, t), e = m.getContext("2d");
|
|
8
|
+
return e.clearRect(0, 0, a, t), e.filter = u({ brightness: f, contrast: 1.3 }), e.drawImage(i, 0, 0, a, t), C(e, v, a, t), m;
|
|
16
9
|
}
|
|
17
10
|
)
|
|
18
|
-
), o = new
|
|
19
|
-
return
|
|
11
|
+
), o = new l(a, t), g = o.getContext("2d");
|
|
12
|
+
return x(g, c, a, t), o;
|
|
20
13
|
}
|
|
21
|
-
const
|
|
14
|
+
const y = async (n = [], a = "png", t = 600, s = 600) => (await d(n, t, s)).toDataURL(a, { matte: "#000000" });
|
|
22
15
|
export {
|
|
23
|
-
|
|
16
|
+
y as default
|
|
24
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),i=require("@rubin-epo/epo-react-lib/Button"),a=require("../../lib/utils.cjs"),c=t=>t&&t.__esModule?t:{default:t},d=c(i),f=t=>t.map(e=>{const{defaultValue:s,min:o,max:u}=e,l=s||1;return{...e,active:!1,color:"",brightness:a.getBrightnessValue(o,u,l),value:l}}),n=({isDisabled:t,selectedData:e,onResetCallback:s,children:o})=>{const{filters:u}=e;return r.jsx(d.default,{style:{"--button-text-align":"left"},disabled:t,icon:"RotateLeftWithCenter",onClick:()=>s&&s({...e,filters:f(u)}),isBlock:!0,children:o})};n.displayName="Widgets.ColorTool.Reset";const g=n;exports.default=g;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import a from "@rubin-epo/epo-react-lib/Button";
|
|
3
|
-
import { getBrightnessValue as m } from "../../
|
|
3
|
+
import { getBrightnessValue as m } from "../../lib/utils.js";
|
|
4
4
|
const u = (o) => o.map((t) => {
|
|
5
5
|
const { defaultValue: e, min: s, max: r } = t, i = e || 1;
|
|
6
6
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),f=require("./Reset/index.cjs"),m=require("./Export/index.cjs"),q=require("./styles.cjs"),A=require("react-i18next"),b=require("../
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),f=require("./Reset/index.cjs"),m=require("./Export/index.cjs"),q=require("./styles.cjs"),A=require("react-i18next"),b=require("../lib/utils.cjs"),i=({actions:c,isDisabled:l,selectedData:e,selectionCallback:s,canvas:u})=>{const{t:r}=A.useTranslation(),{name:a}=e,n=l||!b.areActionsActive(e);return t.jsx(q.Actions,{children:c.map((d,o)=>{switch(d){case"reset":return t.jsx(f.default,{isDisabled:n,selectedData:e,onResetCallback:x=>s&&s(x),children:r("colorTool.actions.reset")},o);case"export":return t.jsx(m.default,{isDisabled:n,canvas:u,filename:a,children:r("colorTool.actions.export")},o);case"save":return null;default:return null}})})};i.displayName="Widgets.ColorTool.Actions";const j=i;exports.default=j;
|
|
@@ -3,7 +3,7 @@ import f from "./Reset/index.js";
|
|
|
3
3
|
import d from "./Export/index.js";
|
|
4
4
|
import { Actions as A } from "./styles.js";
|
|
5
5
|
import { useTranslation as x } from "react-i18next";
|
|
6
|
-
import { areActionsActive as h } from "../
|
|
6
|
+
import { areActionsActive as h } from "../lib/utils.js";
|
|
7
7
|
const i = ({
|
|
8
8
|
actions: c,
|
|
9
9
|
isDisabled: a,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("react/jsx-runtime"),m=require("react"),g=require("../
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("react/jsx-runtime"),m=require("react"),g=require("../lib/canvas.cjs"),C=require("./styles.cjs"),c=m.forwardRef(({layers:s=[],renderLayers:a=[],width:t,height:o},e)=>{var n;const r=(n=e==null?void 0:e.current)==null?void 0:n.getContext("2d"),l=s.filter((u,i)=>u&&a[i]);return r&&(r.clearRect(0,0,t,o),g.mergeCanvases(r,l,t,o)),s.length>0?d.jsx(C.Image,{ref:e,role:"img",width:t,height:o}):null});c.displayName="Widgets.ColorTool.CompositeRenderer";const R=c;exports.default=R;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as p } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as d } from "react";
|
|
3
|
-
import { mergeCanvases as C } from "../
|
|
3
|
+
import { mergeCanvases as C } from "../lib/canvas.js";
|
|
4
4
|
import { Image as R } from "./styles.js";
|
|
5
5
|
const s = d(
|
|
6
6
|
({ layers: m = [], renderLayers: a = [], width: e, height: r }, o) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),q=require("@rubin-epo/epo-react-lib/SelectListbox"),S=require("../
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),q=require("@rubin-epo/epo-react-lib/SelectListbox"),S=require("../lib/utils.cjs"),T=require("react-i18next"),l=require("./styles.cjs"),f=e=>e&&e.__esModule?e:{default:e},I=f(q),d=({filter:e,colorOptions:a,isDisabled:r,onChangeFilterCallback:t,buttonLabelledById:u,selectLabelledById:h,sliderLabelledById:x})=>{const{t:b}=T.useTranslation(),{label:i,color:c="",value:g,active:n,min:m,max:j}=e,_=()=>t&&t({...e,active:!n}),p=o=>o&&t&&t({...e,color:o}),y=o=>t&&t({...e,brightness:S.getBrightnessValue(m,j,o),value:o}),v=b("colorTool.actions.select_filter");return s.jsxs(l.FilterContainer,{disabled:r,children:[s.jsxs(l.FilterLabel,{children:[s.jsx(l.HiddenCheckbox,{checked:n,type:"checkbox",onChange:_,"aria-describedby":u}),s.jsx(l.FilterToggle,{as:"span",children:i})]}),s.jsx(I.default,{placeholder:v,value:c,options:a,onChangeCallback:p,width:"100%",maxWidth:"100%",labelledById:h,isDisabled:!n||r}),s.jsx(l.Slider,{min:1,max:100,onChangeCallback:y,isDisabled:!n||r,labelledbyId:x,value:g,label:i,color:c})]})};d.displayName="Widgets.ColorTool.FilterControls";const B=d;exports.default=B;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as d, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import B from "@rubin-epo/epo-react-lib/SelectListbox";
|
|
3
|
-
import { getBrightnessValue as C } from "../
|
|
3
|
+
import { getBrightnessValue as C } from "../lib/utils.js";
|
|
4
4
|
import { useTranslation as I } from "react-i18next";
|
|
5
5
|
import { FilterContainer as j, FilterLabel as L, HiddenCheckbox as S, FilterToggle as W, Slider as w } from "./styles.js";
|
|
6
6
|
const a = ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),o=require("react"),k=require("@rubin-epo/epo-react-lib/CircularLoader"),A=require("../OffscreenFilter/index.cjs"),m=require("./styles.cjs"),F=require("../
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),o=require("react"),k=require("@rubin-epo/epo-react-lib/CircularLoader"),A=require("../OffscreenFilter/index.cjs"),m=require("./styles.cjs"),F=require("../lib/utils.cjs"),M=require("../CompositeRender/index.cjs"),R=e=>e&&e.__esModule?e:{default:e},D=R(k),C=o.forwardRef(({filters:e,width:i=600,height:l=600,selectedObjectName:r,className:p,children:y},b)=>{const c=o.useRef([]),[f,x]=o.useState(r),[a,u]=o.useState(0),d=F.isFilterActive(e),L=e.filter(t=>!t.isDisabled).length,g=a<L;r!==f&&(x(r),u(0));const j=o.useCallback(()=>u(t=>t+1),[a,e]),q=(t,n)=>{c.current[t]=n};return s.jsxs(m.ImageContainer,{className:p,style:{"--image-container-opacity":a&&d?1:.1},children:[!a&&d&&s.jsx(D.default,{isVisible:g}),s.jsxs(m.LoadingContainer,{style:{"--loading-opacity":g?0:1},children:[e&&e.map((t,n)=>{const{label:_,image:v,color:I,brightness:h}=t;return s.jsx(A.default,{onChangeCallback:S=>q(n,S),url:v,color:I,width:i,height:l,filters:{brightness:h,contrast:1.3},onLoadCallback:j},_)}),s.jsx(M.default,{layers:c.current,renderLayers:e.map(({active:t})=>t),width:i,height:l,ref:b})]}),y]})});C.displayName="Widgets.ColorTool.ImageComposite";const P=C;exports.default=P;
|
|
@@ -3,7 +3,7 @@ import { forwardRef as j, useRef as D, useState as g, useCallback as O } from "r
|
|
|
3
3
|
import P from "@rubin-epo/epo-react-lib/CircularLoader";
|
|
4
4
|
import S from "../OffscreenFilter/index.js";
|
|
5
5
|
import { ImageContainer as T, LoadingContainer as V } from "./styles.js";
|
|
6
|
-
import { isFilterActive as W } from "../
|
|
6
|
+
import { isFilterActive as W } from "../lib/utils.js";
|
|
7
7
|
import $ from "../CompositeRender/index.js";
|
|
8
8
|
const C = j(
|
|
9
9
|
({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("react/jsx-runtime")
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("react/jsx-runtime"),v=require("../../../hooks/useImage.cjs"),o=require("../lib/canvas.cjs"),c=({width:t=600,height:s=600,url:l,color:u="transparent",filters:i={brightness:1},onLoadCallback:f,onChangeCallback:a,debug:d=!1})=>{const[n,m]=v.default({url:l,crossOrigin:"anonymous",onLoadCallback:f}),r=document.createElement("canvas"),e=r.getContext("2d");return e&&n&&m==="loaded"&&(e.canvas.width=t,e.canvas.height=s,e.clearRect(0,0,t,s),e.filter=o.getFilters(i),e.drawImage(n,0,0,t,s),o.updateColor(e,u,t,s),a&&a(r)),d?g.jsx("img",{src:r.toDataURL()}):null};c.displayName="Widgets.ColorTool.OffscreenFilter";const O=c;exports.default=O;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import "
|
|
3
|
-
import
|
|
4
|
-
import { getFilters as g, updateColor as O } from "../utilities.js";
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import p from "../../../hooks/useImage.js";
|
|
3
|
+
import { getFilters as g, updateColor as v } from "../lib/canvas.js";
|
|
5
4
|
const n = ({
|
|
6
5
|
width: t = 600,
|
|
7
6
|
height: r = 600,
|
|
@@ -10,19 +9,19 @@ const n = ({
|
|
|
10
9
|
filters: m = {
|
|
11
10
|
brightness: 1
|
|
12
11
|
},
|
|
13
|
-
onLoadCallback:
|
|
14
|
-
onChangeCallback:
|
|
15
|
-
debug:
|
|
12
|
+
onLoadCallback: f,
|
|
13
|
+
onChangeCallback: a,
|
|
14
|
+
debug: i = !1
|
|
16
15
|
}) => {
|
|
17
|
-
const [
|
|
16
|
+
const [o, u] = p({
|
|
18
17
|
url: c,
|
|
19
18
|
crossOrigin: "anonymous",
|
|
20
|
-
onLoadCallback:
|
|
21
|
-
}),
|
|
22
|
-
return e &&
|
|
19
|
+
onLoadCallback: f
|
|
20
|
+
}), s = document.createElement("canvas"), e = s.getContext("2d");
|
|
21
|
+
return e && o && u === "loaded" && (e.canvas.width = t, e.canvas.height = r, e.clearRect(0, 0, t, r), e.filter = g(m), e.drawImage(o, 0, 0, t, r), v(e, l, t, r), a && a(s)), i ? /* @__PURE__ */ d("img", { src: s.toDataURL() }) : null;
|
|
23
22
|
};
|
|
24
23
|
n.displayName = "Widgets.ColorTool.OffscreenFilter";
|
|
25
|
-
const
|
|
24
|
+
const y = n;
|
|
26
25
|
export {
|
|
27
|
-
|
|
26
|
+
y as default
|
|
28
27
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("context-filter-polyfill");const a=require("./utils.cjs"),l=e=>{e.globalCompositeOperation="source-over"},i=e=>Object.keys(e).reduce((r,o,t)=>e[o]!==void 0?r+=`${t>0?" ":""}${o}(${e[o]*100}%)`:"",""),n=(e,r,o,t)=>{e.globalCompositeOperation="multiply";const s=a.isStyleSupported("color",r)?r:"transparent";e.fillStyle=s,e.fillRect(0,0,o,t),l(e)},u=(e,r=[],o,t)=>{e.globalCompositeOperation="screen",r.forEach(s=>{e.drawImage(s,0,0,o,t)}),l(e)};exports.getFilters=i;exports.mergeCanvases=u;exports.updateColor=n;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getFilters: (filters: {
|
|
2
|
+
[key: string]: number | undefined;
|
|
3
|
+
}) => string;
|
|
4
|
+
export declare const updateColor: (ctx: CanvasRenderingContext2D, color: string, width: number, height: number) => void;
|
|
5
|
+
export declare const mergeCanvases: (ctx: CanvasRenderingContext2D, layers: HTMLCanvasElement[] | undefined, width: number, height: number) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "context-filter-polyfill";
|
|
2
|
+
import { isStyleSupported as l } from "./utils.js";
|
|
3
|
+
const a = (o) => {
|
|
4
|
+
o.globalCompositeOperation = "source-over";
|
|
5
|
+
}, i = (o) => Object.keys(o).reduce((r, e, t) => o[e] !== void 0 ? r += `${t > 0 ? " " : ""}${e}(${o[e] * 100}%)` : "", ""), m = (o, r, e, t) => {
|
|
6
|
+
o.globalCompositeOperation = "multiply";
|
|
7
|
+
const s = l("color", r) ? r : "transparent";
|
|
8
|
+
o.fillStyle = s, o.fillRect(0, 0, e, t), a(o);
|
|
9
|
+
}, u = (o, r = [], e, t) => {
|
|
10
|
+
o.globalCompositeOperation = "screen", r.forEach((s) => {
|
|
11
|
+
o.drawImage(s, 0, 0, e, t);
|
|
12
|
+
}), a(o);
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
i as getFilters,
|
|
16
|
+
u as mergeCanvases,
|
|
17
|
+
m as updateColor
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExportFormat } from "skia-canvas";
|
|
2
|
-
import { ImageFilter } from "
|
|
2
|
+
import { ImageFilter } from "../ColorTool";
|
|
3
3
|
/** server safe renderer */
|
|
4
4
|
declare const getFilteredImageBase64: (filters?: Array<ImageFilter>, format?: ExportFormat, width?: number, height?: number) => Promise<string>;
|
|
5
5
|
export default getFilteredImageBase64;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("lodash/flattenDeep");require("lodash/find");const S=require("lodash/isEmpty"),u=e=>e&&e.__esModule?e:{default:e},y=u(m),g=u(S),a=(e,t,n)=>(t-e)*(n/100)+e,l=e=>e.some(t=>t.active),c=e=>e.filters.map(t=>{const{value:n,defaultValue:r,defaultColor:s,min:o,max:i,color:d}=t,p=n||r||1,f=s||d;return{...t,brightness:a(o,i,p),color:f}}),w=(e,t)=>y.default(e.map(r=>r.objects.filter(s=>s.name===t).map(c))),C=e=>g.default(e)?!1:l(e.filters);function D(e,t){if(t=arguments.length===2?t:"inherit",typeof window<"u"){if("CSS"in window&&"supports"in window.CSS)return window.CSS.supports(e,t);if("supportsCSS"in window)return window.supportsCSS(e,t)}if(typeof document>"u")return!0;const n=e.replace(/-([a-z]|[0-9])/gi,function(o,i){return(i+"").toUpperCase()}),r=document.createElement("div"),s=n in r.style;return r.style.cssText=e+":"+t,s&&r.style[n]!==""}exports.areActionsActive=C;exports.getBrightnessValue=a;exports.getDataFiltersByName=w;exports.isFilterActive=l;exports.isStyleSupported=D;exports.updateFilters=c;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AstroCategory, AstroObject, ImageFilter } from "
|
|
1
|
+
import { AstroCategory, AstroObject, ImageFilter } from "../ColorTool";
|
|
2
2
|
/** calculates a value that can be used in the CSS {@link https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/brightness brightness filter } */
|
|
3
3
|
export declare const getBrightnessValue: (min: number, max: number, value: number) => number;
|
|
4
4
|
export declare const isFilterActive: (filters: ImageFilter[]) => boolean;
|
|
@@ -20,8 +20,3 @@ export declare const getDataFiltersByName: (data: AstroCategory[], name: string)
|
|
|
20
20
|
export declare const getCategoryName: (data: AstroCategory[], objectName: string) => string | null;
|
|
21
21
|
export declare const areActionsActive: (data: AstroObject) => boolean;
|
|
22
22
|
export declare function isStyleSupported(prop: string, value: string): boolean;
|
|
23
|
-
export declare const getFilters: (filters: {
|
|
24
|
-
[key: string]: number | undefined;
|
|
25
|
-
}) => string;
|
|
26
|
-
export declare const updateColor: (ctx: CanvasRenderingContext2D, color: string, canvasWidth: number, canvasHeight: number) => void;
|
|
27
|
-
export declare const mergeCanvases: (context: CanvasRenderingContext2D, layers: HTMLCanvasElement[] | undefined, width: number, height: number, globalCompositeOperation?: GlobalCompositeOperation) => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import l from "lodash/flattenDeep";
|
|
2
|
+
import "lodash/find";
|
|
3
|
+
import p from "lodash/isEmpty";
|
|
4
|
+
const d = (t, e, n) => (e - t) * (n / 100) + t, f = (t) => t.some((e) => e.active), m = (t) => t.filters.map((e) => {
|
|
5
|
+
const { value: n, defaultValue: r, defaultColor: s, min: i, max: o, color: u } = e, c = n || r || 1, a = s || u;
|
|
6
|
+
return {
|
|
7
|
+
...e,
|
|
8
|
+
brightness: d(i, o, c),
|
|
9
|
+
color: a
|
|
10
|
+
};
|
|
11
|
+
}), C = (t, e) => l(
|
|
12
|
+
t.map((r) => r.objects.filter((s) => s.name === e).map(m))
|
|
13
|
+
), g = (t) => p(t) ? !1 : f(t.filters);
|
|
14
|
+
function h(t, e) {
|
|
15
|
+
if (e = arguments.length === 2 ? e : "inherit", typeof window < "u") {
|
|
16
|
+
if ("CSS" in window && "supports" in window.CSS)
|
|
17
|
+
return window.CSS.supports(t, e);
|
|
18
|
+
if ("supportsCSS" in window)
|
|
19
|
+
return window.supportsCSS(t, e);
|
|
20
|
+
}
|
|
21
|
+
if (typeof document > "u")
|
|
22
|
+
return !0;
|
|
23
|
+
const n = t.replace(/-([a-z]|[0-9])/gi, function(i, o) {
|
|
24
|
+
return (o + "").toUpperCase();
|
|
25
|
+
}), r = document.createElement("div"), s = n in r.style;
|
|
26
|
+
return r.style.cssText = t + ":" + e, s && r.style[n] !== "";
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
g as areActionsActive,
|
|
30
|
+
d as getBrightnessValue,
|
|
31
|
+
C as getDataFiltersByName,
|
|
32
|
+
f as isFilterActive,
|
|
33
|
+
h as isStyleSupported,
|
|
34
|
+
m as updateFilters
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("context-filter-polyfill");const g=require("lodash/flattenDeep");require("lodash/find");const S=require("lodash/isEmpty"),a=e=>e&&e.__esModule?e:{default:e},y=a(g),C=a(S),l=(e,t,r)=>(t-e)*(r/100)+e,u=e=>e.some(t=>t.active),c=e=>e.filters.map(t=>{const{value:r,defaultValue:s,defaultColor:n,min:o,max:i,color:p}=t,f=r||s||1,m=n||p;return{...t,brightness:l(o,i,f),color:m}}),w=(e,t)=>y.default(e.map(s=>s.objects.filter(n=>n.name===t).map(c))),F=e=>C.default(e)?!1:u(e.filters);function d(e,t){if(t=arguments.length===2?t:"inherit",typeof window<"u"){if("CSS"in window&&"supports"in window.CSS)return window.CSS.supports(e,t);if("supportsCSS"in window)return window.supportsCSS(e,t)}if(typeof document>"u")return!0;const r=e.replace(/-([a-z]|[0-9])/gi,function(o,i){return(i+"").toUpperCase()}),s=document.createElement("div"),n=r in s.style;return s.style.cssText=e+":"+t,n&&s.style[r]!==""}const D=e=>Object.keys(e).reduce((t,r,s)=>t+=`${s>0?" ":""}${r}(${e[r]})`,""),_=(e,t,r,s)=>{const n=d("color",t)?t:"transparent";e.fillStyle=n,e.fillRect(0,0,r,s)},b=(e,t=[],r,s,n="screen")=>{e.globalCompositeOperation=n,t.forEach(o=>{e.drawImage(o,0,0,r,s)})};exports.areActionsActive=F;exports.getBrightnessValue=l;exports.getDataFiltersByName=w;exports.getFilters=D;exports.isFilterActive=u;exports.isStyleSupported=d;exports.mergeCanvases=b;exports.updateColor=_;exports.updateFilters=c;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import "context-filter-polyfill";
|
|
2
|
-
import u from "lodash/flattenDeep";
|
|
3
|
-
import "lodash/find";
|
|
4
|
-
import p from "lodash/isEmpty";
|
|
5
|
-
const d = (e, t, r) => (t - e) * (r / 100) + e, f = (e) => e.some((t) => t.active), m = (e) => e.filters.map((t) => {
|
|
6
|
-
const { value: r, defaultValue: n, defaultColor: o, min: s, max: i, color: a } = t, c = r || n || 1, l = o || a;
|
|
7
|
-
return {
|
|
8
|
-
...t,
|
|
9
|
-
brightness: d(s, i, c),
|
|
10
|
-
color: l
|
|
11
|
-
};
|
|
12
|
-
}), h = (e, t) => u(
|
|
13
|
-
e.map((n) => n.objects.filter((o) => o.name === t).map(m))
|
|
14
|
-
), b = (e) => p(e) ? !1 : f(e.filters);
|
|
15
|
-
function w(e, t) {
|
|
16
|
-
if (t = arguments.length === 2 ? t : "inherit", typeof window < "u") {
|
|
17
|
-
if ("CSS" in window && "supports" in window.CSS)
|
|
18
|
-
return window.CSS.supports(e, t);
|
|
19
|
-
if ("supportsCSS" in window)
|
|
20
|
-
return window.supportsCSS(e, t);
|
|
21
|
-
}
|
|
22
|
-
if (typeof document > "u")
|
|
23
|
-
return !0;
|
|
24
|
-
const r = e.replace(/-([a-z]|[0-9])/gi, function(s, i) {
|
|
25
|
-
return (i + "").toUpperCase();
|
|
26
|
-
}), n = document.createElement("div"), o = r in n.style;
|
|
27
|
-
return n.style.cssText = e + ":" + t, o && n.style[r] !== "";
|
|
28
|
-
}
|
|
29
|
-
const D = (e) => Object.keys(e).reduce((t, r, n) => t += `${n > 0 ? " " : ""}${r}(${e[r]})`, ""), F = (e, t, r, n) => {
|
|
30
|
-
const o = w("color", t) ? t : "transparent";
|
|
31
|
-
e.fillStyle = o, e.fillRect(0, 0, r, n);
|
|
32
|
-
}, A = (e, t = [], r, n, o = "screen") => {
|
|
33
|
-
e.globalCompositeOperation = o, t.forEach((s) => {
|
|
34
|
-
e.drawImage(s, 0, 0, r, n);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
b as areActionsActive,
|
|
39
|
-
d as getBrightnessValue,
|
|
40
|
-
h as getDataFiltersByName,
|
|
41
|
-
D as getFilters,
|
|
42
|
-
f as isFilterActive,
|
|
43
|
-
w as isStyleSupported,
|
|
44
|
-
A as mergeCanvases,
|
|
45
|
-
F as updateColor,
|
|
46
|
-
m as updateFilters
|
|
47
|
-
};
|