fabric 6.0.2 → 6.2.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.
- package/CHANGELOG.md +15 -0
- package/dist/index.js +250 -101
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +250 -101
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +250 -101
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +250 -101
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/ClassRegistry.d.ts +1 -0
- package/dist/src/ClassRegistry.d.ts.map +1 -1
- package/dist/src/ClassRegistry.min.mjs +1 -1
- package/dist/src/ClassRegistry.min.mjs.map +1 -1
- package/dist/src/ClassRegistry.mjs +3 -0
- package/dist/src/ClassRegistry.mjs.map +1 -1
- package/dist/src/Collection.d.ts +3 -3
- package/dist/src/Collection.d.ts.map +1 -1
- package/dist/src/EventTypeDefs.d.ts +19 -11
- package/dist/src/EventTypeDefs.d.ts.map +1 -1
- package/dist/src/LayoutManager/LayoutManager.d.ts.map +1 -1
- package/dist/src/LayoutManager/LayoutManager.min.mjs +1 -1
- package/dist/src/LayoutManager/LayoutManager.min.mjs.map +1 -1
- package/dist/src/LayoutManager/LayoutManager.mjs +2 -2
- package/dist/src/LayoutManager/LayoutManager.mjs.map +1 -1
- package/dist/src/Shadow.d.ts.map +1 -1
- package/dist/src/Shadow.min.mjs +1 -1
- package/dist/src/Shadow.min.mjs.map +1 -1
- package/dist/src/Shadow.mjs +1 -5
- package/dist/src/Shadow.mjs.map +1 -1
- package/dist/src/canvas/DOMManagers/util.d.ts.map +1 -1
- package/dist/src/canvas/DOMManagers/util.min.mjs +1 -1
- package/dist/src/canvas/DOMManagers/util.min.mjs.map +1 -1
- package/dist/src/canvas/DOMManagers/util.mjs +9 -15
- package/dist/src/canvas/DOMManagers/util.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.d.ts.map +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.mjs +3 -0
- package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.d.ts +20 -24
- package/dist/src/canvas/StaticCanvas.d.ts.map +1 -1
- package/dist/src/color/util.d.ts.map +1 -1
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.min.mjs +1 -1
- package/dist/src/constants.min.mjs.map +1 -1
- package/dist/src/constants.mjs +2 -1
- package/dist/src/constants.mjs.map +1 -1
- package/dist/src/controls/controlRendering.d.ts +1 -1
- package/dist/src/controls/controlRendering.d.ts.map +1 -1
- package/dist/src/controls/controlRendering.min.mjs.map +1 -1
- package/dist/src/controls/controlRendering.mjs.map +1 -1
- package/dist/src/controls/fireEvent.d.ts +2 -2
- package/dist/src/controls/fireEvent.d.ts.map +1 -1
- package/dist/src/controls/fireEvent.min.mjs.map +1 -1
- package/dist/src/controls/fireEvent.mjs.map +1 -1
- package/dist/src/controls/index.d.ts +1 -0
- package/dist/src/controls/index.d.ts.map +1 -1
- package/dist/src/controls/index.min.mjs +1 -1
- package/dist/src/controls/index.mjs +1 -0
- package/dist/src/controls/index.mjs.map +1 -1
- package/dist/src/controls/pathControl.d.ts +12 -0
- package/dist/src/controls/pathControl.d.ts.map +1 -0
- package/dist/src/controls/pathControl.min.mjs +2 -0
- package/dist/src/controls/pathControl.min.mjs.map +1 -0
- package/dist/src/controls/pathControl.mjs +156 -0
- package/dist/src/controls/pathControl.mjs.map +1 -0
- package/dist/src/controls/polyControl.d.ts.map +1 -1
- package/dist/src/controls/polyControl.min.mjs +1 -1
- package/dist/src/controls/polyControl.min.mjs.map +1 -1
- package/dist/src/controls/polyControl.mjs +1 -9
- package/dist/src/controls/polyControl.mjs.map +1 -1
- package/dist/src/controls/util.d.ts +1 -1
- package/dist/src/controls/wrapWithFireEvent.d.ts +5 -3
- package/dist/src/controls/wrapWithFireEvent.d.ts.map +1 -1
- package/dist/src/controls/wrapWithFireEvent.min.mjs +1 -1
- package/dist/src/controls/wrapWithFireEvent.min.mjs.map +1 -1
- package/dist/src/controls/wrapWithFireEvent.mjs +7 -4
- package/dist/src/controls/wrapWithFireEvent.mjs.map +1 -1
- package/dist/src/controls/wrapWithFixedAnchor.d.ts.map +1 -1
- package/dist/src/env/index.d.ts.map +1 -1
- package/dist/src/env/node.d.ts.map +1 -1
- package/dist/src/filters/BaseFilter.d.ts.map +1 -1
- package/dist/src/filters/BaseFilter.min.mjs.map +1 -1
- package/dist/src/filters/BaseFilter.mjs +0 -1
- package/dist/src/filters/BaseFilter.mjs.map +1 -1
- package/dist/src/filters/ColorMatrix.d.ts.map +1 -1
- package/dist/src/filters/ColorMatrixFilters.d.ts +8 -96
- package/dist/src/filters/ColorMatrixFilters.d.ts.map +1 -1
- package/dist/src/filters/Convolute.d.ts +2 -1
- package/dist/src/filters/Convolute.d.ts.map +1 -1
- package/dist/src/filters/shaders/baseFilter.d.ts +1 -1
- package/dist/src/filters/shaders/baseFilter.d.ts.map +1 -1
- package/dist/src/filters/utils.d.ts.map +1 -1
- package/dist/src/parser/normalizeAttr.d.ts.map +1 -1
- package/dist/src/parser/parseStyleString.d.ts.map +1 -1
- package/dist/src/parser/parseStyleString.min.mjs +1 -1
- package/dist/src/parser/parseStyleString.min.mjs.map +1 -1
- package/dist/src/parser/parseStyleString.mjs +1 -0
- package/dist/src/parser/parseStyleString.mjs.map +1 -1
- package/dist/src/parser/parseUseDirectives.d.ts.map +1 -1
- package/dist/src/parser/parseUseDirectives.min.mjs +1 -1
- package/dist/src/parser/parseUseDirectives.min.mjs.map +1 -1
- package/dist/src/parser/parseUseDirectives.mjs +61 -43
- package/dist/src/parser/parseUseDirectives.mjs.map +1 -1
- package/dist/src/shapes/Group.d.ts +20 -20
- package/dist/src/shapes/Group.d.ts.map +1 -1
- package/dist/src/shapes/IText/DraggableTextDelegate.d.ts.map +1 -1
- package/dist/src/shapes/IText/ITextBehavior.d.ts.map +1 -1
- package/dist/src/shapes/IText/ITextBehavior.min.mjs.map +1 -1
- package/dist/src/shapes/IText/ITextBehavior.mjs +0 -1
- package/dist/src/shapes/IText/ITextBehavior.mjs.map +1 -1
- package/dist/src/shapes/Image.d.ts.map +1 -1
- package/dist/src/shapes/Image.min.mjs.map +1 -1
- package/dist/src/shapes/Image.mjs +0 -2
- package/dist/src/shapes/Image.mjs.map +1 -1
- package/dist/src/shapes/Path.d.ts +9 -9
- package/dist/src/shapes/Path.d.ts.map +1 -1
- package/dist/src/shapes/Polyline.d.ts +1 -1
- package/dist/src/shapes/Rect.d.ts +1 -1
- package/dist/src/shapes/Text/Text.d.ts +1 -1
- package/dist/src/shapes/Text/Text.d.ts.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.d.ts.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.min.mjs.map +1 -1
- package/dist/src/shapes/Text/TextSVGExportMixin.mjs +0 -2
- package/dist/src/shapes/Text/TextSVGExportMixin.mjs.map +1 -1
- package/dist/src/shapes/Textbox.d.ts.map +1 -1
- package/dist/src/shapes/Textbox.min.mjs.map +1 -1
- package/dist/src/shapes/Textbox.mjs +0 -2
- package/dist/src/shapes/Textbox.mjs.map +1 -1
- package/dist/src/util/applyMixins.d.ts.map +1 -1
- package/dist/src/util/dom_misc.d.ts.map +1 -1
- package/dist/src/util/dom_misc.min.mjs +1 -1
- package/dist/src/util/dom_misc.min.mjs.map +1 -1
- package/dist/src/util/dom_misc.mjs +7 -9
- package/dist/src/util/dom_misc.mjs.map +1 -1
- package/dist/src/util/internals/cloneDeep.d.ts.map +1 -1
- package/dist/src/util/internals/console.d.ts +1 -1
- package/dist/src/util/internals/findRight.d.ts.map +1 -1
- package/dist/src/util/internals/removeFromArray.d.ts.map +1 -1
- package/dist/src/util/misc/dom.d.ts.map +1 -1
- package/dist/src/util/misc/groupSVGElements.d.ts.map +1 -1
- package/dist/src/util/misc/matrix.d.ts.map +1 -1
- package/dist/src/util/misc/objectEnlive.d.ts +1 -1
- package/dist/src/util/misc/objectEnlive.d.ts.map +1 -1
- package/dist/src/util/misc/objectEnlive.min.mjs +1 -1
- package/dist/src/util/misc/objectEnlive.min.mjs.map +1 -1
- package/dist/src/util/misc/objectEnlive.mjs +7 -11
- package/dist/src/util/misc/objectEnlive.mjs.map +1 -1
- package/dist/src/util/misc/objectTransforms.d.ts.map +1 -1
- package/dist/src/util/misc/pick.d.ts.map +1 -1
- package/dist/src/util/misc/planeChange.d.ts.map +1 -1
- package/dist/src/util/misc/svgParsing.d.ts.map +1 -1
- package/dist/src/util/misc/textStyles.d.ts.map +1 -1
- package/dist/src/util/path/index.d.ts +0 -1
- package/dist/src/util/path/index.d.ts.map +1 -1
- package/dist/src/util/path/index.min.mjs +1 -1
- package/dist/src/util/path/index.min.mjs.map +1 -1
- package/dist/src/util/path/index.mjs +1 -2
- package/dist/src/util/path/index.mjs.map +1 -1
- package/dist/src/util/path/typedefs.d.ts +1 -0
- package/dist/src/util/path/typedefs.d.ts.map +1 -1
- package/dist/src/util/typeAssertions.d.ts +2 -2
- package/dist/src/util/typeAssertions.d.ts.map +1 -1
- package/lib/aligning_guidelines.js +76 -1
- package/lib/centering_guidelines.js +3 -1
- package/package.json +3 -3
- package/src/ClassRegistry.spec.ts +39 -0
- package/src/ClassRegistry.ts +4 -0
- package/src/EventTypeDefs.ts +22 -10
- package/src/LayoutManager/ActiveSelectionLayoutManager.spec.ts +1 -0
- package/src/LayoutManager/LayoutManager.spec.ts +1 -0
- package/src/LayoutManager/LayoutManager.ts +2 -0
- package/src/Shadow.ts +1 -6
- package/src/canvas/DOMManagers/util.ts +11 -15
- package/src/canvas/SelectableCanvas.spec.ts +18 -0
- package/src/canvas/SelectableCanvas.ts +3 -0
- package/src/constants.ts +1 -0
- package/src/controls/controlRendering.ts +4 -2
- package/src/controls/fireEvent.ts +2 -2
- package/src/controls/index.ts +1 -0
- package/src/controls/pathControl.spec.ts +75 -0
- package/src/controls/pathControl.ts +293 -0
- package/src/controls/polyControl.ts +1 -1
- package/src/controls/wrapWithFireEvent.ts +14 -5
- package/src/filters/BaseFilter.ts +1 -2
- package/src/parser/parseStyleString.ts +1 -0
- package/src/parser/parseUseDirectives.test.ts +113 -0
- package/src/parser/parseUseDirectives.ts +64 -58
- package/src/shapes/IText/ITextBehavior.ts +4 -2
- package/src/shapes/Image.ts +0 -2
- package/src/shapes/Text/TextSVGExportMixin.ts +0 -2
- package/src/shapes/Textbox.ts +0 -2
- package/src/util/dom_misc.ts +17 -10
- package/src/util/misc/objectEnlive.spec.ts +68 -0
- package/src/util/misc/objectEnlive.ts +7 -13
- package/src/util/path/__snapshots__/index.spec.ts.snap +327 -0
- package/src/util/path/index.spec.ts +13 -2
- package/src/util/path/index.ts +2 -4
- package/src/util/path/typedefs.ts +2 -0
- package/.gitmodules +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapWithFireEvent.min.mjs","sources":["../../../src/controls/wrapWithFireEvent.ts"],"sourcesContent":["import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {
|
|
1
|
+
{"version":3,"file":"wrapWithFireEvent.min.mjs","sources":["../../../src/controls/wrapWithFireEvent.ts"],"sourcesContent":["import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler<T>} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler<T>} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record<string, never>\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler<T>,\n extraEventInfo?: P\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler<T>;\n};\n"],"names":["wrapWithFireEvent","eventName","actionHandler","extraEventInfo","eventData","transform","x","y","actionPerformed","fireEvent","_objectSpread","commonEventInfo"],"mappings":"kLAeO,MAAMA,EAAoBA,CAI/BC,EACAC,EACAC,IAEQ,CAACC,EAAWC,EAAWC,EAAGC,KAChC,MAAMC,EAAkBN,EAAcE,EAAWC,EAAWC,EAAGC,GAO/D,OANIC,GACFC,EAAUR,EAASS,EAAAA,EAAA,CAAA,EACdC,EAAgBP,EAAWC,EAAWC,EAAGC,IACzCJ,IAGAK,CAAe"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import { objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.mjs';
|
|
1
2
|
import { fireEvent } from './fireEvent.mjs';
|
|
2
3
|
import { commonEventInfo } from './util.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Wrap an action handler with firing an event if the action is performed
|
|
6
|
-
* @param {
|
|
7
|
-
* @
|
|
7
|
+
* @param {TModificationEvents} eventName the event we want to fire
|
|
8
|
+
* @param {TransformActionHandler<T>} actionHandler the function to wrap
|
|
9
|
+
* @param {object} extraEventInfo extra information to pas to the event handler
|
|
10
|
+
* @return {TransformActionHandler<T>} a function with an action handler signature
|
|
8
11
|
*/
|
|
9
|
-
const wrapWithFireEvent = (eventName, actionHandler) => {
|
|
12
|
+
const wrapWithFireEvent = (eventName, actionHandler, extraEventInfo) => {
|
|
10
13
|
return (eventData, transform, x, y) => {
|
|
11
14
|
const actionPerformed = actionHandler(eventData, transform, x, y);
|
|
12
15
|
if (actionPerformed) {
|
|
13
|
-
fireEvent(eventName, commonEventInfo(eventData, transform, x, y));
|
|
16
|
+
fireEvent(eventName, _objectSpread2(_objectSpread2({}, commonEventInfo(eventData, transform, x, y)), extraEventInfo));
|
|
14
17
|
}
|
|
15
18
|
return actionPerformed;
|
|
16
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapWithFireEvent.mjs","sources":["../../../src/controls/wrapWithFireEvent.ts"],"sourcesContent":["import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {
|
|
1
|
+
{"version":3,"file":"wrapWithFireEvent.mjs","sources":["../../../src/controls/wrapWithFireEvent.ts"],"sourcesContent":["import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler<T>} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler<T>} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record<string, never>\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler<T>,\n extraEventInfo?: P\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler<T>;\n};\n"],"names":["wrapWithFireEvent","eventName","actionHandler","extraEventInfo","eventData","transform","x","y","actionPerformed","fireEvent","_objectSpread","commonEventInfo"],"mappings":";;;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,iBAAiB,GAAGA,CAI/BC,SAA8B,EAC9BC,aAAwC,EACxCC,cAAkB,KACf;EACH,OAAQ,CAACC,SAAS,EAAEC,SAAS,EAAEC,CAAC,EAAEC,CAAC,KAAK;IACtC,MAAMC,eAAe,GAAGN,aAAa,CAACE,SAAS,EAAEC,SAAS,EAAEC,CAAC,EAAEC,CAAC,CAAC,CAAA;AACjE,IAAA,IAAIC,eAAe,EAAE;MACnBC,SAAS,CAACR,SAAS,EAAAS,cAAA,CAAAA,cAAA,CAAA,EAAA,EACdC,eAAe,CAACP,SAAS,EAAEC,SAAS,EAAEC,CAAC,EAAEC,CAAC,CAAC,CAC3CJ,EAAAA,cAAc,CAClB,CAAC,CAAA;AACJ,KAAA;AACA,IAAA,OAAOK,eAAe,CAAA;GACvB,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapWithFixedAnchor.d.ts","sourceRoot":"","sources":["../../../src/controls/wrapWithFixedAnchor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,EACrD,aAAa,EAAE,sBAAsB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"wrapWithFixedAnchor.d.ts","sourceRoot":"","sources":["../../../src/controls/wrapWithFixedAnchor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,EACrD,aAAa,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAelC,sBAAsB,CAAC,CAAC,CAAC,CAChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/env/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,UAAW,UAAU,SAEvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,kBAAuC,CAAC;AAE3D,eAAO,MAAM,iBAAiB,QAAO,QAA6B,CAAC;AAEnE,eAAO,MAAM,eAAe,QAAO,CAAC,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/env/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,MAAM,UAAW,UAAU,SAEvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,kBAAuC,CAAC;AAE3D,eAAO,MAAM,iBAAiB,QAAO,QAA6B,CAAC;AAEnE,eAAO,MAAM,eAAe,QAAO,CAAC,MAAM,GAAG,OAAO,UAAU,CAAC,GAAG,SACjD,CAAC;AAElB;;GAEG;AACH,eAAO,MAAM,mBAAmB,cAC4C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/env/node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKnD,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,SAAS,CAAC;AAiB1D,eAAO,MAAM,aAAa,aAAc,iBAAiB,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/env/node.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKnD,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,SAAS,CAAC;AAiB1D,eAAO,MAAM,aAAa,aAAc,iBAAiB,KAEf,UACzC,CAAC;AAEF,eAAO,MAAM,OAAO,YAAa,OAAO,SAUvC,CAAC;AAEF,eAAO,MAAM,MAAM,QAAO,UASzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseFilter.d.ts","sourceRoot":"","sources":["../../../src/filters/BaseFilter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAOpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7C,qBAAa,UAAU,CACrB,IAAI,SAAS,MAAM,EACnB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM;IAE7C;;;;OAIG;IACH,IAAI,IAAI,IAAI,IAAI,CAEf;IAED;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,SAAgB;IAE3B;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAM;IAEvC,OAAe,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjD;;;OAGG;gBACS,EACV,IAAI,EACJ,GAAG,OAAO,EACX,GAAE;QAAE,IAAI,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAQlE,SAAS,CAAC,iBAAiB,IAAI,MAAM;IAIrC,eAAe,IAAI,MAAM;IAIzB;;;;;;OAMG;IACH,aAAa,C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mjs","sources":["../../../src/filters/BaseFilter.ts"],"sourcesContent":["import { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record<string, any> = object\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record<string, unknown>;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial<OwnProps> & Record<string, any> = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource()\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision)\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error'\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader\n )}`\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader\n )}`\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter<string>)\n .uniformLocations;\n\n const uniformLocations: Record<string, WebGLUniformLocation | null> = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i]\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record<string, number>,\n aPositionData: Float32Array\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const helpLayer = createCanvasElement();\n helpLayer.width = options.sourceWidth;\n helpLayer.height = options.sourceHeight;\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & OwnProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults\n ) as (keyof OwnProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce<OwnProps>((acc, key) => {\n //@ts-expect-error TS doesn't get i want an object that looks like this\n acc[key] = this[key as keyof this];\n return acc;\n }, {} as OwnProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record<string, any>,\n options: Abortable\n ): Promise<BaseFilter<string, object>> {\n return new this(filterOptions);\n }\n}\n"],"names":["regex","RegExp","highPsourceCode","BaseFilter","type","this","constructor","options","_objectWithoutProperties","arguments","length","undefined","_excluded","Object","assign","defaults","getFragmentSource","identityFragmentShader","getVertexSource","vertexSource","createProgram","gl","fragmentSource","WebGLProbe","GLPrecision","getEnv","replace","vertexShader","createShader","VERTEX_SHADER","fragmentShader","FRAGMENT_SHADER","program","FabricError","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","concat","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","aPosition","getAttribLocation","locations","i","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","context","passes","width","destinationWidth","height","destinationHeight","sourceWidth","sourceHeight","deleteTexture","targetTexture","filterBackend","createTexture","framebufferTexture2D","FRAMEBUFFER","COLOR_ATTACHMENT0","TEXTURE_2D","bindFramebuffer","finish","_swapTextures","pass","temp","sourceTexture","isNeutralState","applyTo","isWebGLPipelineState","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","key","programCache","shader","originalTexture","bindTexture","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","texture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","createHelpLayer","helpLayer","createCanvasElement","toObject","defaultKeys","keys","_objectSpread","reduce","acc","toJSON","fromObject","_ref2","_excluded2","_defineProperty"],"mappings":"+eAkBMA,EAAQ,IAAIC,OAAOC,EAAiB,KAEnC,MAAMC,EASX,QAAIC,GACF,OAAQC,KAAKC,YAAkCF,IACjD,CAwBAE,WAAAA,GAGoE,IAD/DC,EAAOC,EACwDC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAJ,CAAA,EADpDG,GAEVC,OAAOC,OACLT,KACCA,KAAKC,YAAkCS,SACxCR,EAEJ,CAEUS,iBAAAA,GACR,OAAOC,CACT,CAEAC,eAAAA,GACE,OAAOC,CACT,CASAC,aAAAA,CACEC,GAGA,IAFAC,EAAsBb,UAAAC,eAAAC,IAAAF,UAAA,GAAAA,UAAG,GAAAJ,KAAKW,oBAC9BG,EAAoBV,UAAAC,eAAAC,IAAAF,UAAA,GAAAA,UAAG,GAAAJ,KAAKa,kBAE5B,MACEK,YAAYC,YAAEA,EAAc,UAC1BC,IACgB,UAAhBD,IACFF,EAAiBA,EAAeI,QAC9B1B,EACAE,EAAgBwB,QAAQ,QAASF,KAGrC,MAAMG,EAAeN,EAAGO,aAAaP,EAAGQ,eAClCC,EAAiBT,EAAGO,aAAaP,EAAGU,iBACpCC,EAAUX,EAAGD,gBAEnB,IAAKO,IAAiBG,IAAmBE,EACvC,MAAM,IAAIC,EACR,qDAKJ,GAFAZ,EAAGa,aAAaP,EAAcR,GAC9BE,EAAGc,cAAcR,IACZN,EAAGe,mBAAmBT,EAAcN,E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P,CAMAC,MAAAA,GAEE,OAAOvH,KAAKiH,UACd,CAEA,uBAAaO,CAAUC,EAErBvH,GAEA,OAAO,IAAIF,KAHaG,EAAAsH,EAAAC,GAI1B,EACDC,EAvYY7H,EAAU,OAoBP,cAEd6H,EAtBW7H,EAAU,mBA2Be"}
|
|
1
|
+
{"version":3,"file":"BaseFilter.min.mjs","sources":["../../../src/filters/BaseFilter.ts"],"sourcesContent":["import { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record<string, any> = object\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record<string, unknown>;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial<OwnProps> & Record<string, any> = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource()\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision)\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error'\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader\n )}`\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader\n )}`\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter<string>)\n .uniformLocations;\n\n const uniformLocations: Record<string, WebGLUniformLocation | null> = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i]\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record<string, number>,\n aPositionData: Float32Array\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const helpLayer = createCanvasElement();\n helpLayer.width = options.sourceWidth;\n helpLayer.height = options.sourceHeight;\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & OwnProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults\n ) as (keyof OwnProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce<OwnProps>((acc, key) => {\n acc[key] = this[key as keyof this] as unknown as typeof acc[typeof key];\n return acc;\n }, {} as OwnProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record<string, any>,\n options: Abortable\n ): Promise<BaseFilter<string, object>> {\n return new this(filterOptions);\n }\n}\n"],"names":["regex","RegExp","highPsourceCode","BaseFilter","type","this","constructor","options","_objectWithoutProperties","arguments","length","undefined","_excluded","Object","assign","defaults","getFragmentSource","identityFragmentShader","getVertexSource","vertexSource","createProgram","gl","fragmentSource","WebGLProbe","GLPrecision","getEnv","replace","vertexShader","createShader","VERTEX_SHADER","fragmentShader","FRAGMENT_SHADER","program","FabricError","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","concat","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","aPosition","getAttribLocation","locations","i","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","context","passes","width","destinationWidth","height","destinationHeight","sourceWidth","sourceHeight","deleteTexture","targetTexture","filterBackend","createTexture","framebufferTexture2D","FRAMEBUFFER","COLOR_ATTACHMENT0","TEXTURE_2D","bindFramebuffer","finish","_swapTextures","pass","temp","sourceTexture","isNeutralState","applyTo","isWebGLPipelineState","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","key","programCache","shader","originalTexture","bindTexture","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","texture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","createHelpLayer","helpLayer","createCanvasElement","toObject","defaultKeys","keys","_objectSpread","reduce","acc","toJSON","fromObject","_ref2","_excluded2","_defineProperty"],"mappings":"+eAkBMA,EAAQ,IAAIC,OAAOC,EAAiB,KAEnC,MAAMC,EASX,QAAIC,GACF,OAAQC,KAAKC,YAAkCF,IACjD,CAwBAE,WAAAA,GAGoE,IAD/DC,EAAOC,EACwDC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAJ,CAAA,EADpDG,GAEVC,OAAOC,OACLT,KACCA,KAAKC,YAAkCS,SACxCR,EAEJ,CAEUS,iBAAAA,GACR,OAAOC,CACT,CAEAC,eAAAA,GACE,OAAOC,CACT,CASAC,aAAAA,CACEC,GAGA,IAFAC,EAAsBb,UAAAC,eAAAC,IAAAF,UAAA,GAAAA,UAAG,GAAAJ,KAAKW,oBAC9BG,EAAoBV,UAAAC,eAAAC,IAAAF,UAAA,GAAAA,UAAG,GAAAJ,KAAKa,kBAE5B,MACEK,YAAYC,YAAEA,EAAc,UAC1BC,IACgB,UAAhBD,IACFF,EAAiBA,EAAeI,QAC9B1B,EACAE,EAAgBwB,QAAQ,QAASF,KAGrC,MAAMG,EAAeN,EAAGO,aAAaP,EAAGQ,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B,CACF,CAMAE,QAAAA,GACE,MAAMC,EAAc1G,OAAO2G,KACxBnH,KAAKC,YAAkCS,UAG1C,OAAA0G,EAAA,CACErH,KAAMC,KAAKD,MACRmH,EAAYG,QAAiB,CAACC,EAAKzB,KACpCyB,EAAIzB,GAAO7F,KAAK6F,GACTyB,IACN,CAAA,GAEP,CAMAC,MAAAA,GAEE,OAAOvH,KAAKiH,UACd,CAEA,uBAAaO,CAAUC,EAErBvH,GAEA,OAAO,IAAIF,KAHaG,EAAAsH,EAAAC,GAI1B,EACDC,EAtYY7H,EAAU,OAoBP,cAEd6H,EAtBW7H,EAAU,mBA2Be"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseFilter.mjs","sources":["../../../src/filters/BaseFilter.ts"],"sourcesContent":["import { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record<string, any> = object\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record<string, unknown>;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial<OwnProps> & Record<string, any> = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource()\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision)\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error'\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader\n )}`\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader\n )}`\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter<string>)\n .uniformLocations;\n\n const uniformLocations: Record<string, WebGLUniformLocation | null> = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i]\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record<string, number>,\n aPositionData: Float32Array\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const helpLayer = createCanvasElement();\n helpLayer.width = options.sourceWidth;\n helpLayer.height = options.sourceHeight;\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & OwnProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults\n ) as (keyof OwnProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce<OwnProps>((acc, key) => {\n //@ts-expect-error TS doesn't get i want an object that looks like this\n acc[key] = this[key as keyof this];\n return acc;\n }, {} as OwnProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record<string, any>,\n options: Abortable\n ): Promise<BaseFilter<string, object>> {\n return new this(filterOptions);\n }\n}\n"],"names":["regex","RegExp","highPsourceCode","BaseFilter","type","constructor","_ref","arguments","length","undefined","options","_objectWithoutProperties","_excluded","Object","assign","defaults","getFragmentSource","identityFragmentShader","getVertexSource","vertexSource","createProgram","gl","fragmentSource","WebGLProbe","GLPrecision","getEnv","replace","vertexShader","createShader","VERTEX_SHADER","fragmentShader","FRAGMENT_SHADER","program","FabricError","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","concat","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","aPosition","getAttribLocation","locations","i","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","context","passes","width","destinationWidth","height","destinationHeight","sourceWidth","sourceHeight","deleteTexture","targetTexture","filterBackend","createTexture","framebufferTexture2D","FRAMEBUFFER","COLOR_ATTACHMENT0","TEXTURE_2D","bindFramebuffer","finish","_swapTextures","pass","temp","sourceTexture","isNeutralState","applyTo","isWebGLPipelineState","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","key","programCache","shader","originalTexture","bindTexture","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","texture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","createHelpLayer","helpLayer","createCanvasElement","toObject","defaultKeys","keys","_objectSpread","reduce","acc","toJSON","fromObject","_ref2","filterOptions","_excluded2","_defineProperty"],"mappings":";;;;;;;;;AAkBA,MAAMA,KAAK,GAAG,IAAIC,MAAM,CAACC,eAAe,EAAE,GAAG,CAAC,CAAA;AAEvC,MAAMC,UAAU,CAGrB;AACA;AACF;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAS;AACf,IAAA,OAAQ,IAAI,CAACC,WAAW,CAAuBD,IAAI,CAAA;AACrD,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;;AAYE;AACF;AACA;AACA;AACEC,EAAAA,WAAWA,GAGyD;AAAA,IAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAA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xB,GAAA;AAEA,EAAA,aAAaO,UAAUA,CAAAC,KAAA,EAErBpH,OAAkB,EACmB;IAFrC,IAAWqH,aAAa,GAAApH,wBAAA,CAAAmH,KAAA,EAAAE,UAAA,EAAA;AAGxB,IAAA,OAAO,IAAI,IAAI,CAACD,aAAa,CAAC,CAAA;AAChC,GAAA;AACF,CAAA;AAACE,eAAA,CAvYY9H,UAAU,EAAA,MAAA,EAoBP,YAAY,CAAA,CAAA;AAE1B;AACF;AACA;AACA;AACA;AAJE8H,eAAA,CAtBW9H,UAAU,EAAA,kBAAA,EA2Be,EAAE,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"BaseFilter.mjs","sources":["../../../src/filters/BaseFilter.ts"],"sourcesContent":["import { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record<string, any> = object\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record<string, unknown>;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial<OwnProps> & Record<string, any> = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource()\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision)\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error'\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader\n )}`\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader\n )}`\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter<string>)\n .uniformLocations;\n\n const uniformLocations: Record<string, WebGLUniformLocation | null> = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i]\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record<string, number>,\n aPositionData: Float32Array\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const helpLayer = createCanvasElement();\n helpLayer.width = options.sourceWidth;\n helpLayer.height = options.sourceHeight;\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & OwnProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults\n ) as (keyof OwnProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce<OwnProps>((acc, key) => {\n acc[key] = this[key as keyof this] as unknown as typeof acc[typeof key];\n return acc;\n }, {} as OwnProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record<string, any>,\n options: Abortable\n ): Promise<BaseFilter<string, object>> {\n return new this(filterOptions);\n }\n}\n"],"names":["regex","RegExp","highPsourceCode","BaseFilter","type","constructor","_ref","arguments","length","undefined","options","_objectWithoutProperties","_excluded","Object","assign","defaults","getFragmentSource","identityFragmentShader","getVertexSource","vertexSource","createProgram","gl","fragmentSource","WebGLProbe","GLPrecision","getEnv","replace","vertexShader","createShader","VERTEX_SHADER","fragmentShader","FRAGMENT_SHADER","program","FabricError","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","concat","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","aPosition","getAttribLocation","locations","i","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","context","passes","width","destinationWidth","height","destinationHeight","sourceWidth","sourceHeight","deleteTexture","targetTexture","filterBackend","createTexture","framebufferTexture2D","FRAMEBUFFER","COLOR_ATTACHMENT0","TEXTURE_2D","bindFramebuffer","finish","_swapTextures","pass","temp","sourceTexture","isNeutralState","applyTo","isWebGLPipelineState","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","key","programCache","shader","originalTexture","bindTexture","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","texture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","createHelpLayer","helpLayer","createCanvasElement","toObject","defaultKeys","keys","_objectSpread","reduce","acc","toJSON","fromObject","_ref2","filterOptions","_excluded2","_defineProperty"],"mappings":";;;;;;;;;AAkBA,MAAMA,KAAK,GAAG,IAAIC,MAAM,CAACC,eAAe,EAAE,GAAG,CAAC,CAAA;AAEvC,MAAMC,UAAU,CAGrB;AACA;AACF;AACA;AACA;AACA;EACE,IAAIC,IAAIA,GAAS;AACf,IAAA,OAAQ,IAAI,CAACC,WAAW,CAAuBD,IAAI,CAAA;AACrD,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;;AAYE;AACF;AACA;AACA;AACEC,EAAAA,WAAWA,GAGyD;AAAA,IAAA,IAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAJ,EAA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;IACH,eAAe,CACb,EAAE,EAAE,qBAAqB,EACzB,gBAAgB,EAAE,wBAAwB;IA0B5C,QAAQ
|
|
1
|
+
{"version":3,"file":"ColorMatrix.d.ts","sourceRoot":"","sources":["../../../src/filters/ColorMatrix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAIpB,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,mBAGtC,CAAC;AAEF;;;;;;;;;;;;;;;KAeK;AACL,qBAAa,WAAW,CACtB,IAAI,SAAS,MAAM,GAAG,aAAa,EACnC,QAAQ,SAAS,MAAM,GAAG,mBAAmB,CAC7C,SAAQ,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC;IAClC;;;;;;;OAOG;IACK,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAE9C;;;;;OAKG;IACK,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAEtD,MAAM,CAAC,IAAI,SAAiB;IAE5B,MAAM,CAAC,QAAQ,sBAA4B;IAE3C,MAAM,CAAC,gBAAgB,WAAkC;IAEzD,iBAAiB,IAAI,MAAM;IAI3B;;;;;OAKG;IACH,SAAS,CAAC,OAAO,EAAE,gBAAgB;IA0BnC;;;;;OAKG;IACH,eAAe,CACb,EAAE,EAAE,qBAAqB,EACzB,gBAAgB,EAAE,wBAAwB;IA0B5C,QAAQ;;;gBAGwB,eAAe;;CAGhD"}
|
|
@@ -3,101 +3,13 @@ import type { TMatColorMatrix } from './typedefs';
|
|
|
3
3
|
type FixedFiltersOwnProps = {
|
|
4
4
|
colorsOnly: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare function createColorMatrixFilter(key: string, matrix: TMatColorMatrix):
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
uniformLocations: string[];
|
|
16
|
-
fromObject({ type, ...filterOptions }: Record<string, any>, options: import("../typedefs").Abortable): Promise<import("./BaseFilter").BaseFilter<string, object>>;
|
|
17
|
-
};
|
|
18
|
-
export declare const Brownie: {
|
|
19
|
-
new ({ type, ...options }?: {
|
|
20
|
-
type?: undefined;
|
|
21
|
-
} & Partial<FixedFiltersOwnProps> & Record<string, any>): ColorMatrix<string, FixedFiltersOwnProps>;
|
|
22
|
-
type: string;
|
|
23
|
-
defaults: {
|
|
24
|
-
matrix: TMatColorMatrix;
|
|
25
|
-
colorsOnly: boolean;
|
|
26
|
-
};
|
|
27
|
-
uniformLocations: string[];
|
|
28
|
-
fromObject({ type, ...filterOptions }: Record<string, any>, options: import("../typedefs").Abortable): Promise<import("./BaseFilter").BaseFilter<string, object>>;
|
|
29
|
-
};
|
|
30
|
-
export declare const Vintage: {
|
|
31
|
-
new ({ type, ...options }?: {
|
|
32
|
-
type?: undefined;
|
|
33
|
-
} & Partial<FixedFiltersOwnProps> & Record<string, any>): ColorMatrix<string, FixedFiltersOwnProps>;
|
|
34
|
-
type: string;
|
|
35
|
-
defaults: {
|
|
36
|
-
matrix: TMatColorMatrix;
|
|
37
|
-
colorsOnly: boolean;
|
|
38
|
-
};
|
|
39
|
-
uniformLocations: string[];
|
|
40
|
-
fromObject({ type, ...filterOptions }: Record<string, any>, options: import("../typedefs").Abortable): Promise<import("./BaseFilter").BaseFilter<string, object>>;
|
|
41
|
-
};
|
|
42
|
-
export declare const Kodachrome: {
|
|
43
|
-
new ({ type, ...options }?: {
|
|
44
|
-
type?: undefined;
|
|
45
|
-
} & Partial<FixedFiltersOwnProps> & Record<string, any>): ColorMatrix<string, FixedFiltersOwnProps>;
|
|
46
|
-
type: string;
|
|
47
|
-
defaults: {
|
|
48
|
-
matrix: TMatColorMatrix;
|
|
49
|
-
colorsOnly: boolean;
|
|
50
|
-
};
|
|
51
|
-
uniformLocations: string[];
|
|
52
|
-
fromObject({ type, ...filterOptions }: Record<string, any>, options: import("../typedefs").Abortable): Promise<import("./BaseFilter").BaseFilter<string, object>>;
|
|
53
|
-
};
|
|
54
|
-
export declare const Technicolor: {
|
|
55
|
-
new ({ type, ...options }?: {
|
|
56
|
-
type?: undefined;
|
|
57
|
-
} & Partial<FixedFiltersOwnProps> & Record<string, any>): ColorMatrix<string, FixedFiltersOwnProps>;
|
|
58
|
-
type: string;
|
|
59
|
-
defaults: {
|
|
60
|
-
matrix: TMatColorMatrix;
|
|
61
|
-
colorsOnly: boolean;
|
|
62
|
-
};
|
|
63
|
-
uniformLocations: string[];
|
|
64
|
-
fromObject({ type, ...filterOptions }: Record<string, any>, options: import("../typedefs").Abortable): Promise<import("./BaseFilter").BaseFilter<string, object>>;
|
|
65
|
-
};
|
|
66
|
-
export declare const Polaroid: {
|
|
67
|
-
new ({ type, ...options }?: {
|
|
68
|
-
type?: undefined;
|
|
69
|
-
} & Partial<FixedFiltersOwnProps> & Record<string, any>): ColorMatrix<string, FixedFiltersOwnProps>;
|
|
70
|
-
type: string;
|
|
71
|
-
defaults: {
|
|
72
|
-
matrix: TMatColorMatrix;
|
|
73
|
-
colorsOnly: boolean;
|
|
74
|
-
};
|
|
75
|
-
uniformLocations: string[];
|
|
76
|
-
fromObject({ type, ...filterOptions }: Record<string, any>, options: import("../typedefs").Abortable): Promise<import("./BaseFilter").BaseFilter<string, object>>;
|
|
77
|
-
};
|
|
78
|
-
export declare const Sepia: {
|
|
79
|
-
new ({ type, ...options }?: {
|
|
80
|
-
type?: undefined;
|
|
81
|
-
} & Partial<FixedFiltersOwnProps> & Record<string, any>): ColorMatrix<string, FixedFiltersOwnProps>;
|
|
82
|
-
type: string;
|
|
83
|
-
defaults: {
|
|
84
|
-
matrix: TMatColorMatrix;
|
|
85
|
-
colorsOnly: boolean;
|
|
86
|
-
};
|
|
87
|
-
uniformLocations: string[];
|
|
88
|
-
fromObject({ type, ...filterOptions }: Record<string, any>, options: import("../typedefs").Abortable): Promise<import("./BaseFilter").BaseFilter<string, object>>;
|
|
89
|
-
};
|
|
90
|
-
export declare const BlackWhite: {
|
|
91
|
-
new ({ type, ...options }?: {
|
|
92
|
-
type?: undefined;
|
|
93
|
-
} & Partial<FixedFiltersOwnProps> & Record<string, any>): ColorMatrix<string, FixedFiltersOwnProps>;
|
|
94
|
-
type: string;
|
|
95
|
-
defaults: {
|
|
96
|
-
matrix: TMatColorMatrix;
|
|
97
|
-
colorsOnly: boolean;
|
|
98
|
-
};
|
|
99
|
-
uniformLocations: string[];
|
|
100
|
-
fromObject({ type, ...filterOptions }: Record<string, any>, options: import("../typedefs").Abortable): Promise<import("./BaseFilter").BaseFilter<string, object>>;
|
|
101
|
-
};
|
|
6
|
+
export declare function createColorMatrixFilter(key: string, matrix: TMatColorMatrix): typeof ColorMatrix<typeof key, FixedFiltersOwnProps>;
|
|
7
|
+
export declare const Brownie: typeof ColorMatrix<string, FixedFiltersOwnProps>;
|
|
8
|
+
export declare const Vintage: typeof ColorMatrix<string, FixedFiltersOwnProps>;
|
|
9
|
+
export declare const Kodachrome: typeof ColorMatrix<string, FixedFiltersOwnProps>;
|
|
10
|
+
export declare const Technicolor: typeof ColorMatrix<string, FixedFiltersOwnProps>;
|
|
11
|
+
export declare const Polaroid: typeof ColorMatrix<string, FixedFiltersOwnProps>;
|
|
12
|
+
export declare const Sepia: typeof ColorMatrix<string, FixedFiltersOwnProps>;
|
|
13
|
+
export declare const BlackWhite: typeof ColorMatrix<string, FixedFiltersOwnProps>;
|
|
102
14
|
export {};
|
|
103
15
|
//# sourceMappingURL=ColorMatrixFilters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorMatrixFilters.d.ts","sourceRoot":"","sources":["../../../src/filters/ColorMatrixFilters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,KAAK,oBAAoB,GAAG;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe
|
|
1
|
+
{"version":3,"file":"ColorMatrixFilters.d.ts","sourceRoot":"","sources":["../../../src/filters/ColorMatrixFilters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,KAAK,oBAAoB,GAAG;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAevD,OAAO,WAAW,CAAC,OAAO,GAAG,EAAE,oBAAoB,CAAC,CACxE;AAED,eAAO,MAAM,OAAO,EAHC,OAAO,WAAW,SAAa,oBAAoB,CASvE,CAAC;AAEF,eAAO,MAAM,OAAO,EAXC,OAAO,WAAW,SAAa,oBAAoB,CAiBvE,CAAC;AAEF,eAAO,MAAM,UAAU,EAnBF,OAAO,WAAW,SAAa,oBAAoB,CAyBvE,CAAC;AAEF,eAAO,MAAM,WAAW,EA3BH,OAAO,WAAW,SAAa,oBAAoB,CAiCvE,CAAC;AAEF,eAAO,MAAM,QAAQ,EAnCA,OAAO,WAAW,SAAa,oBAAoB,CAyCvE,CAAC;AAEF,eAAO,MAAM,KAAK,EA3CG,OAAO,WAAW,SAAa,oBAAoB,CAiDvE,CAAC;AAEF,eAAO,MAAM,UAAU,EAnDF,OAAO,WAAW,SAAa,oBAAoB,CAyDvE,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseFilter } from './BaseFilter';
|
|
2
2
|
import type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';
|
|
3
|
+
import { fragmentSource } from './shaders/convolute';
|
|
3
4
|
export type ConvoluteOwnProps = {
|
|
4
5
|
opaque: boolean;
|
|
5
6
|
matrix: number[];
|
|
@@ -51,7 +52,7 @@ export declare class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps
|
|
|
51
52
|
static type: string;
|
|
52
53
|
static defaults: ConvoluteOwnProps;
|
|
53
54
|
static uniformLocations: string[];
|
|
54
|
-
getCacheKey():
|
|
55
|
+
getCacheKey(): keyof typeof fragmentSource;
|
|
55
56
|
getFragmentSource(): string;
|
|
56
57
|
/**
|
|
57
58
|
* Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Convolute.d.ts","sourceRoot":"","sources":["../../../src/filters/Convolute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Convolute.d.ts","sourceRoot":"","sources":["../../../src/filters/Convolute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,iBAGpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,SAAU,SAAQ,UAAU,CAAC,WAAW,EAAE,iBAAiB,CAAC;IAI/D,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAKpC,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAE5C,MAAM,CAAC,IAAI,SAAe;IAE1B,MAAM,CAAC,QAAQ,oBAA0B;IAEzC,MAAM,CAAC,gBAAgB,WAAgD;IAEvE,WAAW,IAGH,MAAM,OAAO,cAAc;IAGnC,iBAAiB;IAIjB;;;;;OAKG;IACH,SAAS,CAAC,OAAO,EAAE,gBAAgB;IA2DnC;;;;;OAKG;IACH,eAAe,CACb,EAAE,EAAE,qBAAqB,EACzB,gBAAgB,EAAE,wBAAwB;IAK5C;;;OAGG;IACH,QAAQ;;;;;CAOT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const highPsourceCode = "precision highp float";
|
|
2
|
-
export declare const identityFragmentShader
|
|
2
|
+
export declare const identityFragmentShader = "\n precision highp float;\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }";
|
|
3
3
|
export declare const vertexSource = "\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n void main() {\n vTexCoord = aPosition;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }";
|
|
4
4
|
//# sourceMappingURL=baseFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseFilter.d.ts","sourceRoot":"","sources":["../../../../src/filters/shaders/baseFilter.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,0BAA0B,CAAC;AAEvD,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"baseFilter.d.ts","sourceRoot":"","sources":["../../../../src/filters/shaders/baseFilter.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,0BAA0B,CAAC;AAEvD,eAAO,MAAM,sBAAsB,+KAM7B,CAAC;AAEP,eAAO,MAAM,YAAY,qLAMnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/filters/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAExE,eAAO,MAAM,oBAAoB,YACtB,mBAAmB,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/filters/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAExE,eAAO,MAAM,oBAAoB,YACtB,mBAAmB,GAAG,gBAAgB,KAC9C,OAAO,IAAI,mBAEb,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,UAAU,MAAM,KAAG,OAoChE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeAttr.d.ts","sourceRoot":"","sources":["../../../src/parser/normalizeAttr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,aAAa,SAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"normalizeAttr.d.ts","sourceRoot":"","sources":["../../../src/parser/normalizeAttr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,aAAa,SAClB,MAAM,OAAO,aAAa,GAAG,MAAM,KACxC,MAAmE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseStyleString.d.ts","sourceRoot":"","sources":["../../../src/parser/parseStyleString.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,IAAI,
|
|
1
|
+
{"version":3,"file":"parseStyleString.d.ts","sourceRoot":"","sources":["../../../src/parser/parseStyleString.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC1B,IAAI,CASN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t,
|
|
1
|
+
function t(t,r){t.replace(/;\s*$/,"").split(";").forEach((t=>{if(!t)return;const[e,i]=t.split(":");r[e.trim().toLowerCase()]=i.trim()}))}export{t as parseStyleString};
|
|
2
2
|
//# sourceMappingURL=parseStyleString.min.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseStyleString.min.mjs","sources":["../../../src/parser/parseStyleString.ts"],"sourcesContent":["/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record<string, any>\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n"],"names":["parseStyleString","style","oStyle","replace","split","forEach","chunk","attr","value","trim","toLowerCase"],"mappings":"AAMO,SAASA,EACdC,EACAC,GAEAD,EACGE,QAAQ,QAAS,IACjBC,MAAM,KACNC,SAASC,IACR,MAAOC,EAAMC,GAASF,EAAMF,MAAM,KAClCF,EAAOK,EAAKE,OAAOC,eAAiBF,EAAMC,MAAM,GAEtD"}
|
|
1
|
+
{"version":3,"file":"parseStyleString.min.mjs","sources":["../../../src/parser/parseStyleString.ts"],"sourcesContent":["/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record<string, any>\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n"],"names":["parseStyleString","style","oStyle","replace","split","forEach","chunk","attr","value","trim","toLowerCase"],"mappings":"AAMO,SAASA,EACdC,EACAC,GAEAD,EACGE,QAAQ,QAAS,IACjBC,MAAM,KACNC,SAASC,IACR,IAAKA,EAAO,OACZ,MAAOC,EAAMC,GAASF,EAAMF,MAAM,KAClCF,EAAOK,EAAKE,OAAOC,eAAiBF,EAAMC,MAAM,GAEtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseStyleString.mjs","sources":["../../../src/parser/parseStyleString.ts"],"sourcesContent":["/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record<string, any>\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n"],"names":["parseStyleString","style","oStyle","replace","split","forEach","chunk","attr","value","trim","toLowerCase"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAC9BC,KAAa,EACbC,MAA2B,EACrB;AACND,EAAAA,KAAK,CACFE,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CACpBC,KAAK,CAAC,GAAG,CAAC,CACVC,OAAO,CAAEC,KAAK,IAAK;IAClB,MAAM,CAACC,IAAI,EAAEC,KAAK,CAAC,GAAGF,KAAK,CAACF,KAAK,CAAC,GAAG,CAAC,CAAA;AACtCF,IAAAA,MAAM,CAACK,IAAI,CAACE,IAAI,EAAE,CAACC,WAAW,EAAE,CAAC,GAAGF,KAAK,CAACC,IAAI,EAAE,CAAA;AAClD,GAAC,CAAC,CAAA;AACN;;;;"}
|
|
1
|
+
{"version":3,"file":"parseStyleString.mjs","sources":["../../../src/parser/parseStyleString.ts"],"sourcesContent":["/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record<string, any>\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n"],"names":["parseStyleString","style","oStyle","replace","split","forEach","chunk","attr","value","trim","toLowerCase"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAgBA,CAC9BC,KAAa,EACbC,MAA2B,EACrB;AACND,EAAAA,KAAK,CACFE,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CACpBC,KAAK,CAAC,GAAG,CAAC,CACVC,OAAO,CAAEC,KAAK,IAAK;IAClB,IAAI,CAACA,KAAK,EAAE,OAAA;IACZ,MAAM,CAACC,IAAI,EAAEC,KAAK,CAAC,GAAGF,KAAK,CAACF,KAAK,CAAC,GAAG,CAAC,CAAA;AACtCF,IAAAA,MAAM,CAACK,IAAI,CAACE,IAAI,EAAE,CAACC,WAAW,EAAE,CAAC,GAAGF,KAAK,CAACC,IAAI,EAAE,CAAA;AAClD,GAAC,CAAC,CAAA;AACN;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseUseDirectives.d.ts","sourceRoot":"","sources":["../../../src/parser/parseUseDirectives.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parseUseDirectives.d.ts","sourceRoot":"","sources":["../../../src/parser/parseUseDirectives.ts"],"names":[],"mappings":"AAKA,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,QAAQ,QAqF/C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{svgNS as t}from"./constants.min.mjs";import{getMultipleNodes as e}from"./getMultipleNodes.min.mjs";import{applyViewboxTransform as n}from"./applyViewboxTransform.min.mjs";function r(r){const
|
|
1
|
+
import{svgNS as t}from"./constants.min.mjs";import{getMultipleNodes as e}from"./getMultipleNodes.min.mjs";import{applyViewboxTransform as n}from"./applyViewboxTransform.min.mjs";import{parseStyleString as o}from"./parseStyleString.min.mjs";function r(r){const s=e(r,["use","svg:use"]),i=["x","y","xlink:href","href","transform"];for(const e of s){const s=e.attributes,c={};for(const t of s)t.value&&(c[t.name]=t.value);const a=(c["xlink:href"]||c.href||"").slice(1);if(""===a)return;const f=r.getElementById(a);if(null===f)return;let m=f.cloneNode(!0);const l=m.attributes,u={};for(const t of l)t.value&&(u[t.name]=t.value);const{x:p=0,y:b=0,transform:d=""}=c,j="".concat(d," ").concat(u.transform||""," translate(").concat(p,", ").concat(b,")");if(n(m),/^svg$/i.test(m.nodeName)){const e=m.ownerDocument.createElementNS(t,"g");Object.entries(u).forEach((n=>{let[o,r]=n;return e.setAttributeNS(t,o,r)})),e.append(...m.childNodes),m=e}for(const t of s){if(!t)continue;const{name:e,value:n}=t;if(!i.includes(e))if("style"===e){const t={};o(n,t),Object.entries(u).forEach((e=>{let[n,o]=e;t[n]=o})),o(u.style||"",t);const r=Object.entries(t).map((t=>t.join(":"))).join(";");m.setAttribute(e,r)}else!u[e]&&m.setAttribute(e,n)}m.setAttribute("transform",j),m.setAttribute("instantiated_by_use","1"),m.removeAttribute("id"),e.parentNode.replaceChild(m,e)}}export{r as parseUseDirectives};
|
|
2
2
|
//# sourceMappingURL=parseUseDirectives.min.mjs.map
|