@burdenoff/website-sdk 2026.828.6 → 2026.828.7

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/dist/index.mjs CHANGED
@@ -5966,20 +5966,18 @@ function getRecognitionCtor() {
5966
5966
  var MIC_DENIED_MESSAGE = "Microphone access was blocked. Allow it in your browser's site settings to dictate.";
5967
5967
  async function ensureMicrophoneAccess() {
5968
5968
  const media = typeof navigator === "undefined" ? void 0 : navigator.mediaDevices;
5969
- if (!media?.getUserMedia) return { ok: true };
5969
+ if (!media?.getUserMedia) return { ok: true, confirmed: false };
5970
5970
  try {
5971
5971
  const status = await navigator.permissions?.query({
5972
5972
  name: "microphone"
5973
5973
  });
5974
- if (status?.state === "granted") return { ok: true };
5975
- if (status?.state === "denied")
5976
- return { ok: false, message: MIC_DENIED_MESSAGE };
5974
+ if (status?.state === "granted") return { ok: true, confirmed: true };
5977
5975
  } catch {
5978
5976
  }
5979
5977
  try {
5980
5978
  const stream = await media.getUserMedia({ audio: true });
5981
5979
  for (const track of stream.getTracks()) track.stop();
5982
- return { ok: true };
5980
+ return { ok: true, confirmed: true };
5983
5981
  } catch (error) {
5984
5982
  const name = typeof error === "object" && error !== null && "name" in error ? String(error.name) : "";
5985
5983
  if (name === "NotAllowedError" || name === "SecurityError") {
@@ -6022,6 +6020,7 @@ function useSpeechInput({
6022
6020
  const [error, setError] = useState(null);
6023
6021
  const recognitionRef = useRef(null);
6024
6022
  const startTokenRef = useRef(0);
6023
+ const micConfirmedRef = useRef(false);
6025
6024
  const beginRecognitionRef = useRef(null);
6026
6025
  const beginRecognition = useCallback(
6027
6026
  (Ctor, token) => {
@@ -6056,6 +6055,7 @@ function useSpeechInput({
6056
6055
  const token = startTokenRef.current;
6057
6056
  void ensureMicrophoneAccess().then((access) => {
6058
6057
  if (token !== startTokenRef.current) return;
6058
+ micConfirmedRef.current = access.ok && access.confirmed;
6059
6059
  if (!access.ok) {
6060
6060
  setListening(false);
6061
6061
  setError(access.message);
@@ -6091,7 +6091,7 @@ function useSpeechInput({
6091
6091
  if (settled.trim() !== "") finalRef.current(settled);
6092
6092
  };
6093
6093
  recognition.onerror = (event) => {
6094
- const message = describeError(event.error);
6094
+ const message = micConfirmedRef.current && (event.error === "not-allowed" || event.error === "service-not-allowed") ? "Dictation isn't available in this browser. You can type instead." : describeError(event.error);
6095
6095
  setListening(false);
6096
6096
  setInterim("");
6097
6097
  if (message !== "") {