@inploi/plugin-collaborate 0.0.19 → 1.0.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/cdn/index.js +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +6 -5
package/cdn/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This is an inploi sdk script. Learn more at https://inploi.com
|
|
2
2
|
|
|
3
|
-
"use strict";(()=>{var P=Object.defineProperty;var
|
|
3
|
+
"use strict";(()=>{var P=Object.defineProperty;var m=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var y=(e,t,n)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))_.call(t,n)&&y(e,n,t[n]);if(m)for(var n of m(t))x.call(t,n)&&y(e,n,t[n]);return e};var E=e=>e;var j=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var O="isdk_session";var A=new RegExp(`${O}=([^;]+)`);var D={pathname:"/log",method:"POST",schema:{response:f(),searchParams:f()}};function f(){return{"~standard":{vendor:"inploi",version:1,validate:e=>({value:e})}}}var w={outBrackets:[":","/"],inBrackets:["(",")",".",",","_","%","+"]},R=e=>{let t=!1,n="",r="",i=o=>r==="\\"?o:`\\${o}`;for(let o of e)o==="["?(t=!0,n+=i(o)):o==="]"?(t=!1,n+=i(o)):t===!0&&w.inBrackets.includes(o)||t===!1&&w.outBrackets.includes(o)?n+=i(o):n+=o,r=o;return n};var C=e=>{var r,i,o,c,d,s,a,p;if(((r=e.element)==null?void 0:r.getAttribute("id"))!==null&&!((i=e.id)!=null&&i.length))return e.id=`#${(o=e.element)==null?void 0:o.getAttribute("id")}`,e;if(e.element&&e.element.className.length>0&&!((c=e.classes)!=null&&c.length))return e.classes=`.${R(e.element.className).split(" ").join(".")}`,e;let t=[e.classes,e.id].filter(Boolean).join("")||((d=e.element)==null?void 0:d.tagName),n=(s=e.element)==null?void 0:s.parentElement;if(n){let l=Array.from(n.children).findIndex(S=>S===e.element);return{element:(a=e.element)==null?void 0:a.parentElement,children:[`${t}:nth-child(${l+1})`,...(p=e.children)!=null?p:[]]}}throw new Error("Unable to uniquely identify selector: not unique enough")},h=(e,t,n)=>{let r=i=>{var d;let o=C(i),c=[[o.classes,o.id].filter(Boolean).join(""),...(d=o.children)!=null?d:[]].filter(Boolean).join(">");try{let s=t.querySelectorAll(c);return s.length>1&&s.length<100?r(o):s.length===1?c:null}catch(s){if(s instanceof DOMException)return n.warn("Invalid selector",c),null;throw s}};return r({element:e,children:[]})};var u=e=>{window.parent.postMessage(b({source:"inploi-collaborate"},e),"*")};var I=e=>e.data.source==="inploi-collaborate";var g=e=>{let t=e.getBoundingClientRect();return{_brand:"pin",x:window.scrollX+t.x,y:window.scrollY+t.y,width:t.width,height:t.height}},T=(e,t)=>{let n={};for(let r of e)try{let i=document.querySelector(r);n[r]=i?g(i):null}catch(i){i instanceof DOMException&&(t.warn(`Failed to get selector rect for ${r}`,i),n[r]=null)}return n};function L(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>e(...r),t)}}var k=({logger:e,signal:t})=>{let n=[],r;u({type:"READY"}),e.info("Collaborate bridge: Ready");let i=L(()=>{u({type:"SELECTOR_RECTS",selectorRects:T(n,e)})},50),o=()=>{r&&u({type:"HOVER_ELEMENT",rect:g(r)})},c=d=>{if(I(d)===!1)return;let s=d.data;switch(s.type){case"WATCH_SELECTORS":{n=s.selectors,i();break}case"MOUSE_POSITION":{let a=document.elementsFromPoint(s.x,s.y)[0];if(a===r)return;r=a,o();break}case"DROP_PIN":{let a=document.elementsFromPoint(s.x,s.y)[0];if(!a)return;let p=h(a,document.body,e);if(!p)return;let l=a.getBoundingClientRect();u({type:"PIN_POSITION",pin:{rect:g(a),selector:p,xPercent:(s.x-l.x)/l.width,yPercent:(s.y-l.y)/l.height}});break}case"SETUP_EVENT_HANDLERS":{e.info("Collaborate bridge: Setting up event handlers"),window.addEventListener("beforeunload",()=>{u({type:"DISPOSE"})}),u({type:"RESIZE",scrollHeight:document.body.scrollHeight}),window.addEventListener("resize",()=>{i(),u({type:"RESIZE",scrollHeight:document.body.scrollHeight})},{signal:t}),document.body.addEventListener("click",a=>{if(a.preventDefault(),a.stopPropagation(),!r)return;let p=h(r,document.body,e);if(!p)return;let l=r.getBoundingClientRect();o(),u({type:"PIN_POSITION",pin:{rect:g(r),selector:p,xPercent:(a.clientX-l.x)/l.width,yPercent:(a.clientY-l.y)/l.height}})},{signal:t}),e.info("Collaborate bridge: Event handlers set up");break}case"SCROLL":window.scrollTo({left:s.scrollX,top:s.scrollY,behavior:"instant"}),i();break;default:}};window.addEventListener("message",c,{signal:t}),t==null||t.addEventListener("abort",()=>{e.info("Collaborate bridge: disposing"),u({type:"DISPOSE"}),window.removeEventListener("message",c)})},v=()=>E(({logger:e})=>({setupBridge:t=>k({logger:e,signal:t==null?void 0:t.signal})}));if(!window.inploi)throw new Error("Please insert the SDK script tag above the plugins.");window.inploi.collaboratePlugin=v;})();
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inploi/plugin-collaborate",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,18 +17,19 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@inploi/sdk": "
|
|
20
|
+
"@inploi/sdk": ">=1.15.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@happy-dom/global-registrator": "^13.6.2",
|
|
24
|
-
"@types/bun": "^1.
|
|
24
|
+
"@types/bun": "^1.2.5",
|
|
25
25
|
"eslint": "^7.32.0",
|
|
26
26
|
"happy-dom": "^12.6.0",
|
|
27
27
|
"tsup": "^7.2.0",
|
|
28
|
+
"concurrently": "9.1.2",
|
|
28
29
|
"eslint-config-custom": "0.1.0",
|
|
29
30
|
"tsconfig": "0.1.0",
|
|
30
|
-
"@inploi/sdk": "1.
|
|
31
|
-
"@inploi/core": "1.
|
|
31
|
+
"@inploi/sdk": "1.15.0",
|
|
32
|
+
"@inploi/core": "1.16.0"
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
|
34
35
|
"build:npm": "tsup --dts --dts-resolve",
|