Comparing version 1.0.5 to 1.0.6
@@ -13,30 +13,42 @@ const hookInputSetter = (target, key) => { | ||
hookInputSetter(HTMLInputElement.prototype, "value"); | ||
hookInputSetter(HTMLInputElement.prototype, "checked"); | ||
hookInputSetter(HTMLTextAreaElement.prototype, "value"); | ||
hookInputSetter(HTMLSelectElement.prototype, "value"); | ||
const isSSR = typeof window === "undefined"; | ||
if (!isSSR) { | ||
hookInputSetter(HTMLInputElement.prototype, "value"); | ||
hookInputSetter(HTMLInputElement.prototype, "checked"); | ||
hookInputSetter(HTMLTextAreaElement.prototype, "value"); | ||
hookInputSetter(HTMLSelectElement.prototype, "value"); | ||
} | ||
const bridgedMethods = ["init", "identify", "stop", "showCode"]; | ||
const noop = () => { }; | ||
const noopModule = { | ||
init: noop, | ||
identify: noop, | ||
stop: noop, | ||
showCode: noop, | ||
}; | ||
// Create cohere or pass in previous args to init/initialize | ||
// if script is not created | ||
const Cohere = (window.Cohere = []); | ||
Cohere.invoked = true; | ||
Cohere.snippet = "0.3"; | ||
Cohere.valhook = true; | ||
Cohere.methods = bridgedMethods; | ||
Cohere.methods.forEach((method) => { | ||
Cohere[method] = (...args) => { | ||
args.unshift(method); | ||
Cohere.push(args); | ||
}; | ||
}); | ||
// Create an async script element based on your key | ||
const script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.async = true; | ||
script.src = "https://static.cohere.so/main.js"; | ||
// Insert our script before the first script element | ||
const first = document.getElementsByTagName("script")[0]; | ||
first.parentNode.insertBefore(script, first); | ||
let Cohere = isSSR ? noopModule : (window.Cohere = []); | ||
if (!isSSR) { | ||
Cohere.invoked = true; | ||
Cohere.snippet = "0.4"; | ||
Cohere.valhook = true; | ||
Cohere.methods = bridgedMethods; | ||
Cohere.methods.forEach((method) => { | ||
Cohere[method] = (...args) => { | ||
args.unshift(method); | ||
Cohere.push(args); | ||
}; | ||
}); | ||
// Create an async script element based on your key | ||
const script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.async = true; | ||
script.src = "https://static.cohere.so/main.js"; | ||
// Insert our script before the first script element | ||
const first = document.getElementsByTagName("script")[0]; | ||
first.parentNode.insertBefore(script, first); | ||
} | ||
const exportedModule = Cohere; | ||
export default exportedModule; |
@@ -15,30 +15,42 @@ 'use strict'; | ||
hookInputSetter(HTMLInputElement.prototype, "value"); | ||
hookInputSetter(HTMLInputElement.prototype, "checked"); | ||
hookInputSetter(HTMLTextAreaElement.prototype, "value"); | ||
hookInputSetter(HTMLSelectElement.prototype, "value"); | ||
const isSSR = typeof window === "undefined"; | ||
if (!isSSR) { | ||
hookInputSetter(HTMLInputElement.prototype, "value"); | ||
hookInputSetter(HTMLInputElement.prototype, "checked"); | ||
hookInputSetter(HTMLTextAreaElement.prototype, "value"); | ||
hookInputSetter(HTMLSelectElement.prototype, "value"); | ||
} | ||
const bridgedMethods = ["init", "identify", "stop", "showCode"]; | ||
const noop = () => { }; | ||
const noopModule = { | ||
init: noop, | ||
identify: noop, | ||
stop: noop, | ||
showCode: noop, | ||
}; | ||
// Create cohere or pass in previous args to init/initialize | ||
// if script is not created | ||
const Cohere = (window.Cohere = []); | ||
Cohere.invoked = true; | ||
Cohere.snippet = "0.3"; | ||
Cohere.valhook = true; | ||
Cohere.methods = bridgedMethods; | ||
Cohere.methods.forEach((method) => { | ||
Cohere[method] = (...args) => { | ||
args.unshift(method); | ||
Cohere.push(args); | ||
}; | ||
}); | ||
// Create an async script element based on your key | ||
const script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.async = true; | ||
script.src = "https://static.cohere.so/main.js"; | ||
// Insert our script before the first script element | ||
const first = document.getElementsByTagName("script")[0]; | ||
first.parentNode.insertBefore(script, first); | ||
let Cohere = isSSR ? noopModule : (window.Cohere = []); | ||
if (!isSSR) { | ||
Cohere.invoked = true; | ||
Cohere.snippet = "0.4"; | ||
Cohere.valhook = true; | ||
Cohere.methods = bridgedMethods; | ||
Cohere.methods.forEach((method) => { | ||
Cohere[method] = (...args) => { | ||
args.unshift(method); | ||
Cohere.push(args); | ||
}; | ||
}); | ||
// Create an async script element based on your key | ||
const script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.async = true; | ||
script.src = "https://static.cohere.so/main.js"; | ||
// Insert our script before the first script element | ||
const first = document.getElementsByTagName("script")[0]; | ||
first.parentNode.insertBefore(script, first); | ||
} | ||
const exportedModule = Cohere; | ||
module.exports = exportedModule; |
{ | ||
"name": "cohere-js", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Cohere.so JS SDK", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4946
118