New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cocreate/observer

Package Overview
Dependencies
Maintainers
1
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cocreate/observer - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

8

CHANGELOG.md

@@ -0,1 +1,9 @@

## [1.2.3](https://github.com/CoCreate-app/CoCreate-observer/compare/v1.2.2...v1.2.3) (2021-06-24)
### Bug Fixes
* add method to turn on and off console.log while in development ([0b4632e](https://github.com/CoCreate-app/CoCreate-observer/commit/0b4632e734e114b116c9ab3fc3492f3789d83a1e))
* update all [@cocreate](https://github.com/cocreate) to use latest versions ([f502a11](https://github.com/CoCreate-app/CoCreate-observer/commit/f502a11b1c58bb5e20fc9ccf7a3fddf7f39e1a87))
## [1.2.2](https://github.com/CoCreate-app/CoCreate-observer/compare/v1.2.1...v1.2.2) (2021-06-23)

@@ -2,0 +10,0 @@

2

dist/CoCreate-observer.min.js

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.CoCreate=e():(t.CoCreate=t.CoCreate||{},t.CoCreate.observer=e())}(this,(function(){return(()=>{"use strict";var t={};return(()=>{var e=t;function a(t){this.callbackMap=new Map,this.callbackMap.set("ALL",{attributes:[],addedNodes:[],removedNodes:[],characterData:[],childList:[]});let[e,a]=this.runCallbackGen("attributes");this.runCallbackAtt=e,this.runCallbackAttAll=a,[e,a]=this.runCallbackGen("characterData"),this.runCallbackChar=e,this.runCallbackCharAll=a,this.runCallbackAdd=this.runCallbackExGen("addedNodes","addedNodes"),this.runCallbackRemove=this.runCallbackExGen("removedNodes","removedNodes");new MutationObserver((t=>this._callback.call(this,t))).observe(t,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0})}e.default=void 0,window.counter=0;const l=["addedNodes","removedNodes","attributes","characterData","childList"];a.prototype.init=function({observe:t=["addedNodes","attributes"],attributeFilter:e,callback:a}){if(!t||!t.every((t=>l.includes(t))))throw"please enter a valid observe";if(this.observe=t,this.callback=a,e&&e.length)for(let t of e)this._register(t.toLowerCase());else this._register("ALL")},a.prototype._register=function(t){for(let e of this.observe)"childList"!==e?this.callbackMap.has(t)?this.callbackMap.get(t)[e]?this.callbackMap.get(t)[e].push(this.callback):this.callbackMap.get(t)[e]=[this.callback]:this.callbackMap.set(t,{[e]:[this.callback]}):this.callbackMap.get("ALL").childList&&this.callbackMap.get("ALL").childList.push(this.callback)},a.prototype.uninit=function(t){for(let[e,a]of this.callbackMap.entries())a.attributes&&(a.attributes=a.attributes.filter((e=>e!==t))),a.characterData&&(a.characterData=a.characterData.filter((e=>e!==t))),a.addedNodes&&(a.addedNodes=a.addedNodes.filter((e=>e!==t))),a.removedNodes&&(a.removedNodes=a.removedNodes.filter((e=>e!==t))),a.childList&&(a.childList=a.childList.filter((e=>e!==t))),this.callbackMap.set(e,{attributes:a.attributes,characterData:a.characterData,addedNodes:a.addedNodes,removedNodes:a.removedNodes,childList:a.childList})},a.prototype._callback=function(t){for(let e of t)switch(window.counter++,e.type){case"attributes":this._attributeCallback(e);break;case"characterData":this._characterDataCallback(e);break;case"childList":this._childListCallback(e)}},a.prototype.runCallbackGen=function(t){return[function(e,a){let l=this.callbackMap.get(a);if(l&&l[t])for(let a of l[t])a(e)},function(e){for(let a of this.callbackMap.get("ALL")[t])a(e)}]},a.prototype._attributeCallback=function(t){if(!t.target.hasAttributes(t.attributeName))return;t.target.getAttribute(t.attributeName)!==t.oldValue&&(this.runCallbackAtt(t,t.attributeName),this.runCallbackAttAll(t))},a.prototype._characterDataCallback=function(t){if(t.target.data===t.oldValue)return;this.runCallbackCharAll(t);let e=t.target.parentElement;for(let a of e.attributes)this.runCallbackChar(t,a.name)},a.prototype.runCallbackExGen=function(t,e){return function a(l){for(let i of l[e]){if(i.tagName)for(let e of i.attributes||i.parentElement&&i.parentElement.attributes||[]){let a=this.callbackMap.get(e.name);if(a&&a[t])for(let e of a[t])e({type:l.type,target:i,[t]:!0})}i.children&&a.call(this,{[e]:i.children})}for(let a of this.callbackMap.get("ALL")[t])for(let i of l[e])i.tagName&&a({type:l.type,target:i,[t]:!0})}},a.prototype._childList=function(t){this.callbackMap.get("ALL").childList.forEach((e=>{e(t)}))},a.prototype._childListCallback=function(t){this._childList(t),this.runCallbackAdd(t),this.runCallbackRemove(t)},a.prototype.setInitialized=function(t,e){t["co_initialized_"+(e=e||"")]=!0},a.prototype.getInitialized=function(t,e){return!!t["co_initialized_"+(e=e||"")]};var i=new a(document.body);e.default=i})(),t=t.default})()}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.CoCreate=e():(t.CoCreate=t.CoCreate||{},t.CoCreate.observer=e())}(this,(function(){return(()=>{"use strict";var t={};return(()=>{var e=t;function a(t){this.callbackMap=new Map,this.callbackMap.set("ALL",{attributes:[],addedNodes:[],removedNodes:[],characterData:[],childList:[]});let[e,a]=this.runCallbackGen("attributes");this.runCallbackAtt=e,this.runCallbackAttAll=a,[e,a]=this.runCallbackGen("characterData"),this.runCallbackChar=e,this.runCallbackCharAll=a,this.runCallbackAdd=this.runCallbackExGen("addedNodes","addedNodes"),this.runCallbackRemove=this.runCallbackExGen("removedNodes","removedNodes");new MutationObserver((t=>this._callback.call(this,t))).observe(t,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0})}e.default=void 0,window.counter=0;const i=["addedNodes","removedNodes","attributes","characterData","childList"];a.prototype.init=function({observe:t=["addedNodes","attributes"],attributeFilter:e,callback:a}){if(!t||!t.every((t=>i.includes(t))))throw"please enter a valid observe";if(this.observe=t,this.callback=a,e&&e.length)for(let t of e)this._register(t.toLowerCase());else this._register("ALL")},a.prototype._register=function(t){for(let e of this.observe)"childList"!==e?this.callbackMap.has(t)?this.callbackMap.get(t)[e]?this.callbackMap.get(t)[e].push(this.callback):this.callbackMap.get(t)[e]=[this.callback]:this.callbackMap.set(t,{[e]:[this.callback]}):this.callbackMap.get("ALL").childList&&this.callbackMap.get("ALL").childList.push(this.callback)},a.prototype.uninit=function(t){for(let[e,a]of this.callbackMap.entries())a.attributes&&(a.attributes=a.attributes.filter((e=>e!==t))),a.characterData&&(a.characterData=a.characterData.filter((e=>e!==t))),a.addedNodes&&(a.addedNodes=a.addedNodes.filter((e=>e!==t))),a.removedNodes&&(a.removedNodes=a.removedNodes.filter((e=>e!==t))),a.childList&&(a.childList=a.childList.filter((e=>e!==t))),this.callbackMap.set(e,{attributes:a.attributes,characterData:a.characterData,addedNodes:a.addedNodes,removedNodes:a.removedNodes,childList:a.childList})},a.prototype._callback=function(t){for(let e of t)switch(window.counter++,e.type){case"attributes":this._attributeCallback(e);break;case"characterData":this._characterDataCallback(e);break;case"childList":this._childListCallback(e)}},a.prototype.runCallbackGen=function(t){return[function(e,a){let i=this.callbackMap.get(a);if(i&&i[t])for(let a of i[t])a(e)},function(e){for(let a of this.callbackMap.get("ALL")[t])a(e)}]},a.prototype._attributeCallback=function(t){if(!t.target.hasAttributes(t.attributeName))return;t.target.getAttribute(t.attributeName)!==t.oldValue&&(this.runCallbackAtt(t,t.attributeName),this.runCallbackAttAll(t))},a.prototype._characterDataCallback=function(t){if(t.target.data===t.oldValue)return;this.runCallbackCharAll(t);let e=t.target.parentElement;for(let a of e.attributes)this.runCallbackChar(t,a.name)},a.prototype.runCallbackExGen=function(t,e){return function a(i){for(let l of i[e]){if(l.tagName)for(let e of l.attributes){let a=this.callbackMap.get(e.name);if(a&&a[t])for(let e of a[t])e({type:i.type,target:l,[t]:!0})}l.children&&a.call(this,{[e]:l.children})}for(let a of this.callbackMap.get("ALL")[t])for(let l of i[e])l.tagName&&a({type:i.type,target:l,[t]:!0})}},a.prototype._childList=function(t){this.callbackMap.get("ALL").childList.forEach((e=>{e(t)}))},a.prototype._childListCallback=function(t){this._childList(t),this.runCallbackAdd(t),this.runCallbackRemove(t)},a.prototype.setInitialized=function(t,e){t["co_initialized_"+(e=e||"")]=!0},a.prototype.getInitialized=function(t,e){return!!t["co_initialized_"+(e=e||"")]};var l=new a(document.body);e.default=l})(),t=t.default})()}));
{
"name": "@cocreate/observer",
"version": "1.2.2",
"version": "1.2.3",
"description": "Register a components init function & observe selector. The init function will be fired immedietly after detection of selector.",

@@ -64,4 +64,4 @@ "keywords": [

"dependencies": {
"@cocreate/docs": "^1.0.3"
"@cocreate/docs": "latest"
}
}

@@ -0,1 +1,3 @@

// const consoleMessage = CoCreate.utils.logger(off)
// todo: run for all mutaitonList addedNodes and removed nodes match with this.mapCallback

@@ -130,3 +132,2 @@ // we should keep a binary list of attributes to do fast search and avoid a lot of querySelectorAll

default:
// code
}

@@ -133,0 +134,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc