Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@formsort/custom-question-api

Package Overview
Dependencies
Maintainers
6
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formsort/custom-question-api - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

6

CHANGELOG.md
# CHANGELOG
## 0.3.3
### Various fixes & improvements
- Don't warn about using autoHeight when autoHeight is enabled (#103) by @fzembow
## 0.3.2

@@ -3,0 +9,0 @@

7

lib/index.js

@@ -28,3 +28,3 @@ "use strict";

const { offsetHeight: height } = document.documentElement;
(0, exports.setQuestionSize)(undefined /* width */, `${height}px`);
sendResizeMessage(undefined /* width */, `${height}px`);
}

@@ -37,2 +37,6 @@ }

}
sendResizeMessage(width, height);
};
exports.setQuestionSize = setQuestionSize;
const sendResizeMessage = (width, height) => {
(0, utils_1.sendMessageToWindowParent)(custom_question_message_1.default.SET_QUESTION_SIZE_MSG, {

@@ -43,3 +47,2 @@ width,

};
exports.setQuestionSize = setQuestionSize;
const getAnswerValue = () => (0, utils_1.getValueFromWindowParent)(custom_question_message_1.default.REQUEST_ANSWER_VALUE_MSG, custom_question_message_1.default.SET_ANSWER_VALUE_MSG);

@@ -46,0 +49,0 @@ exports.getAnswerValue = getAnswerValue;

{
"name": "@formsort/custom-question-api",
"version": "0.3.2",
"version": "0.3.3",
"description": "Helpers for implementing custom questions in Formsort",

@@ -5,0 +5,0 @@ "publishConfig": {

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).formsort={})}(this,(function(e){"use strict";var t,n,r={};Object.defineProperty(r,"__esModule",{value:!0}),(n=t||(t={})).SET_QUESTION_SIZE_MSG="ƒ_sqz",n.REQUEST_ANSWER_VALUE_MSG="ƒ_rav",n.SET_ANSWER_VALUE_MSG="ƒ_sav",n.REQUEST_SEMANTIC_ANSWER_VALUE_MSG="ƒ_rsv",n.SET_SEMANTIC_ANSWER_VALUE_MSG="ƒ_ssv",n.REQUEST_ANSWERS_MSG="ƒ_ra",n.SET_ANSWERS_MSG="ƒ_sa",n.REQUEST_RESPONDER_UUID_MSG="ƒ_rru",n.SET_RESPONDER_UUID_MSG="ƒ_sru",n.CLEAR_ANSWER_VALUE_MSG="ƒ_cav",n.SET_DISABLE_BACK_NAVIGATION_MSG="ƒ_sdbn";var o,i=r.default=t,s={},u={get exports(){return s},set exports(e){s=e}},f="object"==typeof Reflect?Reflect:null,a=f&&"function"==typeof f.apply?f.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};o=f&&"function"==typeof f.ownKeys?f.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var l=Number.isNaN||function(e){return e!=e};function c(){c.init.call(this)}u.exports=c,s.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}g(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&g(e,"error",t,n)}(e,o,{once:!0})}))},c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var _=10;function v(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function p(e){return void 0===e._maxListeners?c.defaultMaxListeners:e._maxListeners}function h(e,t,n,r){var o,i,s,u;if(v(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),s=i[t]),void 0===s)s=i[t]=n,++e._eventsCount;else if("function"==typeof s?s=i[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(o=p(e))>0&&s.length>o&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return e}function E(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=E.bind(r);return o.listener=n,r.wrapFn=o,o}function S(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):m(o,o.length)}function y(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function m(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function g(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return _},set:function(e){if("number"!=typeof e||e<0||l(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");_=e}}),c.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||l(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},c.prototype.getMaxListeners=function(){return p(this)},c.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)a(u,this,t);else{var f=u.length,l=m(u,f);for(n=0;n<f;++n)a(l[n],this,t)}return!0},c.prototype.addListener=function(e,t){return h(this,e,t,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(e,t){return h(this,e,t,!0)},c.prototype.once=function(e,t){return v(t),this.on(e,d(this,e,t)),this},c.prototype.prependOnceListener=function(e,t){return v(t),this.prependListener(e,d(this,e,t)),this},c.prototype.removeListener=function(e,t){var n,r,o,i,s;if(v(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){s=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},c.prototype.listeners=function(e){return S(this,e,!0)},c.prototype.rawListeners=function(e){return S(this,e,!1)},c.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},c.prototype.listenerCount=y,c.prototype.eventNames=function(){return this._eventsCount>0?o(this._events):[]};const L=new Set([i.SET_ANSWERS_MSG,i.SET_ANSWER_VALUE_MSG,i.SET_RESPONDER_UUID_MSG,i.SET_SEMANTIC_ANSWER_VALUE_MSG]);class A extends s.EventEmitter{constructor(){super(),this.onWindowMessage=e=>{const{type:t,payload:n,requestId:r}=e.data;"string"==typeof t&&L.has(t)&&this.emit(t,n,r)},window.addEventListener("message",this.onWindowMessage)}}let w;const R=()=>(w||(w=new A),w),M=(e,t,n)=>{if(window.location===window.parent.location)throw new Error("Custom questions must run within a Formsort flow custom question to work.");window.parent.postMessage({type:e,payload:t,requestId:n},"*")},b=(e,t,n)=>{const r=Math.random().toString();return new Promise((o=>{const i=(e,n)=>{r===n&&(o(e),R().removeListener(t,i))};R().on(t,i),M(e,n,r)}))};let T;const N=e=>{for(const t of e)if(t.target===document.body){const{offsetHeight:e}=document.documentElement;U(void 0,`${e}px`)}},U=(e,t)=>{if(T)throw new Error("autoHeight is enabled. To manually size size, call setAutoHeight(false) first.");M(i.SET_QUESTION_SIZE_MSG,{width:e,height:t})};e.clearAnswerValue=()=>{M(i.CLEAR_ANSWER_VALUE_MSG)},e.getAllAnswerValues=()=>b(i.REQUEST_ANSWERS_MSG,i.SET_ANSWERS_MSG),e.getAnswerValue=()=>b(i.REQUEST_ANSWER_VALUE_MSG,i.SET_ANSWER_VALUE_MSG),e.getResponderUuid=()=>b(i.REQUEST_RESPONDER_UUID_MSG,i.SET_RESPONDER_UUID_MSG),e.getSemanticAnswerValue=e=>b(i.REQUEST_SEMANTIC_ANSWER_VALUE_MSG,i.SET_SEMANTIC_ANSWER_VALUE_MSG,e),e.setAnswerValue=e=>{M(i.SET_ANSWER_VALUE_MSG,e)},e.setAutoHeight=e=>{e?(T||(T=new ResizeObserver(N)),T.observe(document.body)):T&&(T.disconnect(),T=void 0)},e.setDisableBackNavigation=(e,t)=>{M(i.SET_DISABLE_BACK_NAVIGATION_MSG,{disable:e,beforeUnloadMessage:null==t?void 0:t.beforeUnloadMessage})},e.setQuestionSize=U,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).formsort={})}(this,(function(e){"use strict";var t,n,r={};Object.defineProperty(r,"__esModule",{value:!0}),(n=t||(t={})).SET_QUESTION_SIZE_MSG="ƒ_sqz",n.REQUEST_ANSWER_VALUE_MSG="ƒ_rav",n.SET_ANSWER_VALUE_MSG="ƒ_sav",n.REQUEST_SEMANTIC_ANSWER_VALUE_MSG="ƒ_rsv",n.SET_SEMANTIC_ANSWER_VALUE_MSG="ƒ_ssv",n.REQUEST_ANSWERS_MSG="ƒ_ra",n.SET_ANSWERS_MSG="ƒ_sa",n.REQUEST_RESPONDER_UUID_MSG="ƒ_rru",n.SET_RESPONDER_UUID_MSG="ƒ_sru",n.CLEAR_ANSWER_VALUE_MSG="ƒ_cav",n.SET_DISABLE_BACK_NAVIGATION_MSG="ƒ_sdbn";var o,i=r.default=t,s={},u={get exports(){return s},set exports(e){s=e}},f="object"==typeof Reflect?Reflect:null,a=f&&"function"==typeof f.apply?f.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};o=f&&"function"==typeof f.ownKeys?f.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var l=Number.isNaN||function(e){return e!=e};function c(){c.init.call(this)}u.exports=c,s.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}g(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&g(e,"error",t,n)}(e,o,{once:!0})}))},c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var _=10;function v(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function p(e){return void 0===e._maxListeners?c.defaultMaxListeners:e._maxListeners}function h(e,t,n,r){var o,i,s,u;if(v(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),s=i[t]),void 0===s)s=i[t]=n,++e._eventsCount;else if("function"==typeof s?s=i[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(o=p(e))>0&&s.length>o&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return e}function E(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=E.bind(r);return o.listener=n,r.wrapFn=o,o}function S(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):m(o,o.length)}function y(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function m(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function g(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return _},set:function(e){if("number"!=typeof e||e<0||l(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");_=e}}),c.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||l(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},c.prototype.getMaxListeners=function(){return p(this)},c.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)a(u,this,t);else{var f=u.length,l=m(u,f);for(n=0;n<f;++n)a(l[n],this,t)}return!0},c.prototype.addListener=function(e,t){return h(this,e,t,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(e,t){return h(this,e,t,!0)},c.prototype.once=function(e,t){return v(t),this.on(e,d(this,e,t)),this},c.prototype.prependOnceListener=function(e,t){return v(t),this.prependListener(e,d(this,e,t)),this},c.prototype.removeListener=function(e,t){var n,r,o,i,s;if(v(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){s=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},c.prototype.listeners=function(e){return S(this,e,!0)},c.prototype.rawListeners=function(e){return S(this,e,!1)},c.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},c.prototype.listenerCount=y,c.prototype.eventNames=function(){return this._eventsCount>0?o(this._events):[]};const L=new Set([i.SET_ANSWERS_MSG,i.SET_ANSWER_VALUE_MSG,i.SET_RESPONDER_UUID_MSG,i.SET_SEMANTIC_ANSWER_VALUE_MSG]);class A extends s.EventEmitter{constructor(){super(),this.onWindowMessage=e=>{const{type:t,payload:n,requestId:r}=e.data;"string"==typeof t&&L.has(t)&&this.emit(t,n,r)},window.addEventListener("message",this.onWindowMessage)}}let w;const R=()=>(w||(w=new A),w),M=(e,t,n)=>{if(window.location===window.parent.location)throw new Error("Custom questions must run within a Formsort flow custom question to work.");window.parent.postMessage({type:e,payload:t,requestId:n},"*")},b=(e,t,n)=>{const r=Math.random().toString();return new Promise((o=>{const i=(e,n)=>{r===n&&(o(e),R().removeListener(t,i))};R().on(t,i),M(e,n,r)}))};let T;const N=e=>{for(const t of e)if(t.target===document.body){const{offsetHeight:e}=document.documentElement;U(void 0,`${e}px`)}},U=(e,t)=>{M(i.SET_QUESTION_SIZE_MSG,{width:e,height:t})};e.clearAnswerValue=()=>{M(i.CLEAR_ANSWER_VALUE_MSG)},e.getAllAnswerValues=()=>b(i.REQUEST_ANSWERS_MSG,i.SET_ANSWERS_MSG),e.getAnswerValue=()=>b(i.REQUEST_ANSWER_VALUE_MSG,i.SET_ANSWER_VALUE_MSG),e.getResponderUuid=()=>b(i.REQUEST_RESPONDER_UUID_MSG,i.SET_RESPONDER_UUID_MSG),e.getSemanticAnswerValue=e=>b(i.REQUEST_SEMANTIC_ANSWER_VALUE_MSG,i.SET_SEMANTIC_ANSWER_VALUE_MSG,e),e.setAnswerValue=e=>{M(i.SET_ANSWER_VALUE_MSG,e)},e.setAutoHeight=e=>{e?(T||(T=new ResizeObserver(N)),T.observe(document.body)):T&&(T.disconnect(),T=void 0)},e.setDisableBackNavigation=(e,t)=>{M(i.SET_DISABLE_BACK_NAVIGATION_MSG,{disable:e,beforeUnloadMessage:null==t?void 0:t.beforeUnloadMessage})},e.setQuestionSize=(e,t)=>{if(T)throw new Error("autoHeight is enabled. To manually size size, call setAutoHeight(false) first.");U(e,t)},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
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