@eventvisor/module-pixel 0.8.0 → 0.10.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 CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.10.0](https://github.com/eventvisor/eventvisor/compare/v0.9.0...v0.10.0) (2025-11-01)
7
+
8
+ **Note:** Version bump only for package @eventvisor/module-pixel
9
+
10
+
11
+
12
+
13
+
14
+ # [0.9.0](https://github.com/eventvisor/eventvisor/compare/v0.8.0...v0.9.0) (2025-11-01)
15
+
16
+
17
+ ### Features
18
+
19
+ * New Relic Browser module ([#26](https://github.com/eventvisor/eventvisor/issues/26)) ([d6ad9ed](https://github.com/eventvisor/eventvisor/commit/d6ad9edd4fd895f48070fffad4ac3f8967671229))
20
+
21
+
22
+
23
+
24
+
6
25
  # [0.8.0](https://github.com/eventvisor/eventvisor/compare/v0.7.0...v0.8.0) (2025-10-28)
7
26
 
8
27
  **Note:** Version bump only for package @eventvisor/module-pixel
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Module } from "@eventvisor/sdk";
1
+ import type { Module } from "@eventvisor/sdk";
2
2
  export type PixelModuleOptions = {
3
3
  name?: string;
4
4
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAA+B,sBAAID,IAEnCD,EAA4B,sBAAIC,GACjC,CATD,CASGK,KAAM,I,uBCNLC,EAAsB,CAAC,E,miDCG3B,6BAAkCC,GAAlC,gBAAkC,IAAAA,IAAAA,EAAA,IACxB,MAAmBA,EAAO,KAElC,MAAO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,SAACe,GACrBpC,EAAG8B,YAAYM,EAAQC,WAAU,GACnC,G,UAGN,C,GDxFoB,KAAK,EAAGjD,G","sources":["webpack://EventvisorPixelModule/webpack/universalModuleDefinition","webpack://EventvisorPixelModule/webpack/startup","webpack://EventvisorPixelModule/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventvisorPixelModule\"] = factory();\n\telse\n\t\troot[\"EventvisorPixelModule\"] = factory();\n})(this, () => {\nreturn ","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = {};\n__webpack_modules__[166](0, __webpack_exports__);\n","import { Module } from \"@eventvisor/sdk\";\n\nexport type PixelModuleOptions = {\n name?: string;\n};\n\nexport function createPixelModule(options: PixelModuleOptions = {}): Module {\n const { name = \"pixel\" } = options;\n\n return {\n name,\n\n handle: async ({ step, payload }, { logger, sourceResolver }) => {\n const { params } = step;\n\n if (!params) {\n logger.error(\"[module-pixel] No params found in step\", { step });\n\n return;\n }\n\n if (!params.snippet) {\n logger.error(\"[module-pixel] No snippet found in params\", { params });\n\n return;\n }\n\n const selector = params.selector || \"body\";\n\n const el = document.querySelector(selector);\n\n if (!el) {\n logger.error(\"[module-pixel] No element found with selector\", { selector });\n\n return;\n }\n\n let snippet = params.snippet;\n\n let variableKeys: [replace: string, source: string][] = [];\n\n try {\n variableKeys = Array.from(\n snippet.matchAll(/\\{\\{\\s*([^}]+)\\s*\\}\\}/g),\n (match: any) => match,\n );\n } catch (e) {\n logger.error(\"[module-pixel] Error parsing snippet for variable keys\", {\n snippet,\n error: e,\n });\n }\n\n if (variableKeys.length > 0) {\n for (const [replace, variableKey] of variableKeys) {\n const source = variableKey.trim();\n const variableValue = await sourceResolver.resolve(source, { payload });\n\n snippet = snippet.replace(replace, variableValue); // @TODO: /g?\n }\n }\n\n // Parse the snippet to handle both script tags and regular HTML\n const parser = new DOMParser();\n const doc = parser.parseFromString(snippet, \"text/html\");\n\n // Handle script tags separately to ensure they execute\n const scripts = doc.querySelectorAll(\"script\");\n scripts.forEach((script) => {\n const newScript = document.createElement(\"script\");\n\n // Copy all attributes from the original script\n Array.from(script.attributes).forEach((attr) => {\n newScript.setAttribute(attr.name, attr.value);\n });\n\n // Copy the script content\n newScript.textContent = script.textContent;\n\n // Append to the target element\n el.appendChild(newScript);\n });\n\n // Handle other HTML content (non-script elements)\n const otherElements = Array.from(doc.body.children).filter(\n (child) => child.tagName !== \"SCRIPT\",\n );\n otherElements.forEach((element) => {\n el.appendChild(element.cloneNode(true));\n });\n },\n };\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_exports__","options","name","handle","step","payload","logger","sourceResolver","params","error","snippet","selector","el","document","querySelector","variableKeys","Array","from","matchAll","match","e","length","replace","variableKey","source","trim","resolve","variableValue","parser","DOMParser","doc","parseFromString","querySelectorAll","forEach","script","newScript","createElement","attributes","attr","setAttribute","value","textContent","appendChild","body","children","filter","child","tagName","element","cloneNode"],"sourceRoot":""}
1
+ {"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAA+B,sBAAID,IAEnCD,EAA4B,sBAAIC,GACjC,CATD,CASGK,KAAM,I,uBCNLC,EAAsB,CAAC,E,miDCG3B,6BAAkCC,GAAlC,gBAAkC,IAAAA,IAAAA,EAAA,IACxB,MAAmBA,EAAO,KAElC,MAAO,CACLC,UAHU,IAAG,UAAO,EAKpBC,OAAQ,+CAAO,EAAmB,G,gCAAjBC,EAAI,OAAEC,EAAO,UAAMC,EAAM,SAAEC,EAAc,iB,iDAGxD,KAFQC,EAAWJ,EAAI,QA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startup","webpack://EventvisorPixelModule/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventvisorPixelModule\"] = factory();\n\telse\n\t\troot[\"EventvisorPixelModule\"] = factory();\n})(this, () => {\nreturn ","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = {};\n__webpack_modules__[166](0, __webpack_exports__);\n","import type { Module } from \"@eventvisor/sdk\";\n\nexport type PixelModuleOptions = {\n name?: string;\n};\n\nexport function createPixelModule(options: PixelModuleOptions = {}): Module {\n const { name = \"pixel\" } = options;\n\n return {\n name,\n\n handle: async ({ step, payload }, { logger, sourceResolver }) => {\n const { params } = step;\n\n if (!params) {\n logger.error(\"[module-pixel] No params found in step\", { step });\n\n return;\n }\n\n if (!params.snippet) {\n logger.error(\"[module-pixel] No snippet found in params\", { params });\n\n return;\n }\n\n const selector = params.selector || \"body\";\n\n const el = document.querySelector(selector);\n\n if (!el) {\n logger.error(\"[module-pixel] No element found with selector\", { selector });\n\n return;\n }\n\n let snippet = params.snippet;\n\n let variableKeys: [replace: string, source: string][] = [];\n\n try {\n variableKeys = Array.from(\n snippet.matchAll(/\\{\\{\\s*([^}]+)\\s*\\}\\}/g),\n (match: any) => match,\n );\n } catch (e) {\n logger.error(\"[module-pixel] Error parsing snippet for variable keys\", {\n snippet,\n error: e,\n });\n }\n\n if (variableKeys.length > 0) {\n for (const [replace, variableKey] of variableKeys) {\n const source = variableKey.trim();\n const variableValue = await sourceResolver.resolve(source, { payload });\n\n snippet = snippet.replace(replace, variableValue); // @TODO: /g?\n }\n }\n\n // Parse the snippet to handle both script tags and regular HTML\n const parser = new DOMParser();\n const doc = parser.parseFromString(snippet, \"text/html\");\n\n // Handle script tags separately to ensure they execute\n const scripts = doc.querySelectorAll(\"script\");\n scripts.forEach((script) => {\n const newScript = document.createElement(\"script\");\n\n // Copy all attributes from the original script\n Array.from(script.attributes).forEach((attr) => {\n newScript.setAttribute(attr.name, attr.value);\n });\n\n // Copy the script content\n newScript.textContent = script.textContent;\n\n // Append to the target element\n el.appendChild(newScript);\n });\n\n // Handle other HTML content (non-script elements)\n const otherElements = Array.from(doc.body.children).filter(\n (child) => child.tagName !== \"SCRIPT\",\n );\n otherElements.forEach((element) => {\n el.appendChild(element.cloneNode(true));\n });\n },\n };\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_exports__","options","name","handle","step","payload","logger","sourceResolver","params","error","snippet","selector","el","document","querySelector","variableKeys","Array","from","matchAll","match","e","length","replace","variableKey","source","trim","resolve","variableValue","parser","DOMParser","doc","parseFromString","querySelectorAll","forEach","script","newScript","createElement","attributes","attr","setAttribute","value","textContent","appendChild","body","children","filter","child","tagName","element","cloneNode"],"sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,4TCM3E,SAASI,EAAkBC,EAA8B,CAAC,GAC/D,MAAM,KAAEC,EAAO,SAAYD,EAE3B,MAAO,CACLC,OAEAC,OAAQ,OAAyD,EAAD,6BAAjD,KAAEC,EAAI,QAAEC,IAAW,OAAEC,EAAM,eAAEC,IAC1C,MAAM,OAAEC,GAAWJ,EAEnB,IAAKI,EAGH,YAFAF,EAAOG,MAAM,yCAA0C,CAAEL,SAK3D,IAAKI,EAAOE,QAGV,YAFAJ,EAAOG,MAAM,4CAA6C,CAAED,WAK9D,MAAMG,EAAWH,EAAOG,UAAY,OAE9BC,EAAKC,SAASC,cAAcH,GAElC,IAAKC,EAGH,YAFAN,EAAOG,MAAM,gDAAiD,CAAEE,aAKlE,IAAID,EAAUF,EAAOE,QAEjBK,EAAoD,GAExD,IACEA,EAAeC,MAAMC,KACnBP,EAAQQ,SAAS,0BAChBC,GAAeA,EAEpB,CAAE,MAAOC,GACPd,EAAOG,MAAM,yDAA0D,CACrEC,UACAD,MAAOW,GAEX,CAEA,GAAIL,EAAaM,OAAS,EACxB,IAAK,MAAOC,EAASC,KAAgBR,EAAc,CACjD,MAAMS,EAASD,EAAYE,OACrBC,QAAsBnB,EAAeoB,QAAQH,EAAQ,CAAEnB,YAE7DK,EAAUA,EAAQY,QAAQA,EAASI,EACrC,CAIF,MACME,GADS,IAAIC,WACAC,gBAAgBpB,EAAS,aAG5BkB,EAAIG,iBAAiB,UAC7BC,QAASC,IACf,MAAMC,EAAYrB,SAASsB,cAAc,UAGzCnB,MAAMC,KAAKgB,EAAOG,YAAYJ,QAASK,IACrCH,EAAUI,aAAaD,EAAKnC,KAAMmC,EAAKE,SAIzCL,EAAUM,YAAcP,EAAOO,YAG/B5B,EAAG6B,YAAYP,KAIKlB,MAAMC,KAAKW,EAAIc,KAAKC,UAAUC,OACjDC,GAA4B,WAAlBA,EAAMC,SAELd,QAASe,IACrBnC,EAAG6B,YAAYM,EAAQC,WAAU,KAErC,GAEJ,C","sources":["webpack://@eventvisor/module-pixel/webpack/bootstrap","webpack://@eventvisor/module-pixel/webpack/runtime/define property getters","webpack://@eventvisor/module-pixel/webpack/runtime/hasOwnProperty shorthand","webpack://@eventvisor/module-pixel/./src/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { Module } from \"@eventvisor/sdk\";\n\nexport type PixelModuleOptions = {\n name?: string;\n};\n\nexport function createPixelModule(options: PixelModuleOptions = {}): Module {\n const { name = \"pixel\" } = options;\n\n return {\n name,\n\n handle: async ({ step, payload }, { logger, sourceResolver }) => {\n const { params } = step;\n\n if (!params) {\n logger.error(\"[module-pixel] No params found in step\", { step });\n\n return;\n }\n\n if (!params.snippet) {\n logger.error(\"[module-pixel] No snippet found in params\", { params });\n\n return;\n }\n\n const selector = params.selector || \"body\";\n\n const el = document.querySelector(selector);\n\n if (!el) {\n logger.error(\"[module-pixel] No element found with selector\", { selector });\n\n return;\n }\n\n let snippet = params.snippet;\n\n let variableKeys: [replace: string, source: string][] = [];\n\n try {\n variableKeys = Array.from(\n snippet.matchAll(/\\{\\{\\s*([^}]+)\\s*\\}\\}/g),\n (match: any) => match,\n );\n } catch (e) {\n logger.error(\"[module-pixel] Error parsing snippet for variable keys\", {\n snippet,\n error: e,\n });\n }\n\n if (variableKeys.length > 0) {\n for (const [replace, variableKey] of variableKeys) {\n const source = variableKey.trim();\n const variableValue = await sourceResolver.resolve(source, { payload });\n\n snippet = snippet.replace(replace, variableValue); // @TODO: /g?\n }\n }\n\n // Parse the snippet to handle both script tags and regular HTML\n const parser = new DOMParser();\n const doc = parser.parseFromString(snippet, \"text/html\");\n\n // Handle script tags separately to ensure they execute\n const scripts = doc.querySelectorAll(\"script\");\n scripts.forEach((script) => {\n const newScript = document.createElement(\"script\");\n\n // Copy all attributes from the original script\n Array.from(script.attributes).forEach((attr) => {\n newScript.setAttribute(attr.name, attr.value);\n });\n\n // Copy the script content\n newScript.textContent = script.textContent;\n\n // Append to the target element\n el.appendChild(newScript);\n });\n\n // Handle other HTML content (non-script elements)\n const otherElements = Array.from(doc.body.children).filter(\n (child) => child.tagName !== \"SCRIPT\",\n );\n otherElements.forEach((element) => {\n el.appendChild(element.cloneNode(true));\n });\n },\n };\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","createPixelModule","options","name","handle","step","payload","logger","sourceResolver","params","error","snippet","selector","el","document","querySelector","variableKeys","Array","from","matchAll","match","e","length","replace","variableKey","source","trim","variableValue","resolve","doc","DOMParser","parseFromString","querySelectorAll","forEach","script","newScript","createElement","attributes","attr","setAttribute","value","textContent","appendChild","body","children","filter","child","tagName","element","cloneNode"],"sourceRoot":""}
1
+ {"version":3,"file":"index.mjs","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,4TCM3E,SAASI,EAAkBC,EAA8B,CAAC,GAC/D,MAAM,KAAEC,EAAO,SAAYD,EAE3B,MAAO,CACLC,OAEAC,OAAQ,OAAyD,EAAD,6BAAjD,KAAEC,EAAI,QAAEC,IAAW,OAAEC,EAAM,eAAEC,IAC1C,MAAM,OAAEC,GAAWJ,EAEnB,IAAKI,EAGH,YAFAF,EAAOG,MAAM,yCAA0C,CAAEL,SAK3D,IAAKI,EAAOE,QAGV,YAFAJ,EAAOG,MAAM,4CAA6C,CAAED,WAK9D,MAAMG,EAAWH,EAAOG,UAAY,OAE9BC,EAAKC,SAASC,cAAcH,GAElC,IAAKC,EAGH,YAFAN,EAAOG,MAAM,gDAAiD,CAAEE,aAKlE,IAAID,EAAUF,EAAOE,QAEjBK,EAAoD,GAExD,IACEA,EAAeC,MAAMC,KACnBP,EAAQQ,SAAS,0BAChBC,GAAeA,EAEpB,CAAE,MAAOC,GACPd,EAAOG,MAAM,yDAA0D,CACrEC,UACAD,MAAOW,GAEX,CAEA,GAAIL,EAAaM,OAAS,EACxB,IAAK,MAAOC,EAASC,KAAgBR,EAAc,CACjD,MAAMS,EAASD,EAAYE,OACrBC,QAAsBnB,EAAeoB,QAAQH,EAAQ,CAAEnB,YAE7DK,EAAUA,EAAQY,QAAQA,EAASI,EACrC,CAIF,MACME,GADS,IAAIC,WACAC,gBAAgBpB,EAAS,aAG5BkB,EAAIG,iBAAiB,UAC7BC,QAASC,IACf,MAAMC,EAAYrB,SAASsB,cAAc,UAGzCnB,MAAMC,KAAKgB,EAAOG,YAAYJ,QAASK,IACrCH,EAAUI,aAAaD,EAAKnC,KAAMmC,EAAKE,SAIzCL,EAAUM,YAAcP,EAAOO,YAG/B5B,EAAG6B,YAAYP,KAIKlB,MAAMC,KAAKW,EAAIc,KAAKC,UAAUC,OACjDC,GAA4B,WAAlBA,EAAMC,SAELd,QAASe,IACrBnC,EAAG6B,YAAYM,EAAQC,WAAU,KAErC,GAEJ,C","sources":["webpack://@eventvisor/module-pixel/webpack/bootstrap","webpack://@eventvisor/module-pixel/webpack/runtime/define property getters","webpack://@eventvisor/module-pixel/webpack/runtime/hasOwnProperty shorthand","webpack://@eventvisor/module-pixel/./src/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import type { Module } from \"@eventvisor/sdk\";\n\nexport type PixelModuleOptions = {\n name?: string;\n};\n\nexport function createPixelModule(options: PixelModuleOptions = {}): Module {\n const { name = \"pixel\" } = options;\n\n return {\n name,\n\n handle: async ({ step, payload }, { logger, sourceResolver }) => {\n const { params } = step;\n\n if (!params) {\n logger.error(\"[module-pixel] No params found in step\", { step });\n\n return;\n }\n\n if (!params.snippet) {\n logger.error(\"[module-pixel] No snippet found in params\", { params });\n\n return;\n }\n\n const selector = params.selector || \"body\";\n\n const el = document.querySelector(selector);\n\n if (!el) {\n logger.error(\"[module-pixel] No element found with selector\", { selector });\n\n return;\n }\n\n let snippet = params.snippet;\n\n let variableKeys: [replace: string, source: string][] = [];\n\n try {\n variableKeys = Array.from(\n snippet.matchAll(/\\{\\{\\s*([^}]+)\\s*\\}\\}/g),\n (match: any) => match,\n );\n } catch (e) {\n logger.error(\"[module-pixel] Error parsing snippet for variable keys\", {\n snippet,\n error: e,\n });\n }\n\n if (variableKeys.length > 0) {\n for (const [replace, variableKey] of variableKeys) {\n const source = variableKey.trim();\n const variableValue = await sourceResolver.resolve(source, { payload });\n\n snippet = snippet.replace(replace, variableValue); // @TODO: /g?\n }\n }\n\n // Parse the snippet to handle both script tags and regular HTML\n const parser = new DOMParser();\n const doc = parser.parseFromString(snippet, \"text/html\");\n\n // Handle script tags separately to ensure they execute\n const scripts = doc.querySelectorAll(\"script\");\n scripts.forEach((script) => {\n const newScript = document.createElement(\"script\");\n\n // Copy all attributes from the original script\n Array.from(script.attributes).forEach((attr) => {\n newScript.setAttribute(attr.name, attr.value);\n });\n\n // Copy the script content\n newScript.textContent = script.textContent;\n\n // Append to the target element\n el.appendChild(newScript);\n });\n\n // Handle other HTML content (non-script elements)\n const otherElements = Array.from(doc.body.children).filter(\n (child) => child.tagName !== \"SCRIPT\",\n );\n otherElements.forEach((element) => {\n el.appendChild(element.cloneNode(true));\n });\n },\n };\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","createPixelModule","options","name","handle","step","payload","logger","sourceResolver","params","error","snippet","selector","el","document","querySelector","variableKeys","Array","from","matchAll","match","e","length","replace","variableKey","source","trim","variableValue","resolve","doc","DOMParser","parseFromString","querySelectorAll","forEach","script","newScript","createElement","attributes","attr","setAttribute","value","textContent","appendChild","body","children","filter","child","tagName","element","cloneNode"],"sourceRoot":""}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Module } from "@eventvisor/sdk";
1
+ import type { Module } from "@eventvisor/sdk";
2
2
  export type PixelModuleOptions = {
3
3
  name?: string;
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventvisor/module-pixel",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Eventvisor pixel module",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.mjs",
@@ -38,8 +38,8 @@
38
38
  "url": "https://github.com/eventvisor/eventvisor/issues"
39
39
  },
40
40
  "devDependencies": {
41
- "@eventvisor/sdk": "0.8.0"
41
+ "@eventvisor/sdk": "0.10.0"
42
42
  },
43
43
  "license": "MIT",
44
- "gitHead": "576d9aad61a71d542a0c574b1cd343c1f78ec9ca"
44
+ "gitHead": "7f0d14c5ee3b2727deb93aead60f108d068da406"
45
45
  }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Module } from "@eventvisor/sdk";
1
+ import type { Module } from "@eventvisor/sdk";
2
2
 
3
3
  export type PixelModuleOptions = {
4
4
  name?: string;