@locator/shared
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -5,3 +5,3 @@ import { isValidRenderer } from "./isValidRenderer"; | ||
vscode: { | ||
url: "vscode://file/${projectPath}${filePath}:${line}:${column}", | ||
url: "vscode://file${projectPath}${filePath}:${line}:${column}", | ||
label: "VSCode", | ||
@@ -8,0 +8,0 @@ }, |
@@ -5,3 +5,3 @@ import { isValidRenderer } from "./isValidRenderer"; | ||
vscode: { | ||
url: "vscode://file/${projectPath}${filePath}:${line}:${column}", | ||
url: "vscode://file${projectPath}${filePath}:${line}:${column}", | ||
label: "VSCode", | ||
@@ -8,0 +8,0 @@ }, |
@@ -0,2 +1,19 @@ | ||
let reported = false; | ||
function reportNoLocalStorate() { | ||
if (!reported) { | ||
console.warn(`[LocatorJS]: No local storage available. Please check your browser settings.`); | ||
reported = true; | ||
} | ||
} | ||
function hasLocalStorage() { | ||
if (typeof localStorage === "undefined" || localStorage == null) { | ||
reportNoLocalStorate(); | ||
return false; | ||
} | ||
return true; | ||
} | ||
export function getStoredOptions() { | ||
if (!hasLocalStorage()) { | ||
return {}; | ||
} | ||
const options = {}; | ||
@@ -40,8 +57,17 @@ const storedOptions = localStorage.getItem("LOCATOR_OPTIONS"); | ||
export function setStoredOptions(options) { | ||
if (!hasLocalStorage()) { | ||
return; | ||
} | ||
localStorage.setItem("LOCATOR_OPTIONS", JSON.stringify(options)); | ||
} | ||
export function cleanOptions() { | ||
if (!hasLocalStorage()) { | ||
return; | ||
} | ||
localStorage.removeItem("LOCATOR_OPTIONS"); | ||
} | ||
export function listenOnOptionsChanges(fn) { | ||
if (!hasLocalStorage()) { | ||
return; | ||
} | ||
let currentRawData = localStorage.getItem("LOCATOR_OPTIONS"); | ||
@@ -48,0 +74,0 @@ addEventListener("storage", (event) => { |
{ | ||
"name": "@locator/shared", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"main": "./dist/index.js", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "f07290a1f717c558d7d9a55ac7e74d186d866f65", | ||
"gitHead": "2cb469ec8aa6d278f540b7b9da6650d2f0d84ca5", | ||
"files": [ | ||
@@ -22,0 +22,0 @@ "dist", |
@@ -16,3 +16,3 @@ import { isValidRenderer } from "./isValidRenderer"; | ||
vscode: { | ||
url: "vscode://file/${projectPath}${filePath}:${line}:${column}", | ||
url: "vscode://file${projectPath}${filePath}:${line}:${column}", | ||
label: "VSCode", | ||
@@ -19,0 +19,0 @@ }, |
@@ -15,3 +15,25 @@ export type ProjectOptions = { | ||
export function getStoredOptions() { | ||
let reported = false; | ||
function reportNoLocalStorate() { | ||
if (!reported) { | ||
console.warn( | ||
`[LocatorJS]: No local storage available. Please check your browser settings.` | ||
); | ||
reported = true; | ||
} | ||
} | ||
function hasLocalStorage() { | ||
if (typeof localStorage === "undefined" || localStorage == null) { | ||
reportNoLocalStorate(); | ||
return false; | ||
} | ||
return true; | ||
} | ||
export function getStoredOptions(): ProjectOptions { | ||
if (!hasLocalStorage()) { | ||
return {}; | ||
} | ||
const options: ProjectOptions = {}; | ||
@@ -59,2 +81,5 @@ const storedOptions = localStorage.getItem("LOCATOR_OPTIONS"); | ||
export function setStoredOptions(options: ProjectOptions) { | ||
if (!hasLocalStorage()) { | ||
return; | ||
} | ||
localStorage.setItem("LOCATOR_OPTIONS", JSON.stringify(options)); | ||
@@ -64,2 +89,5 @@ } | ||
export function cleanOptions() { | ||
if (!hasLocalStorage()) { | ||
return; | ||
} | ||
localStorage.removeItem("LOCATOR_OPTIONS"); | ||
@@ -69,2 +97,5 @@ } | ||
export function listenOnOptionsChanges(fn: (options: ProjectOptions) => void) { | ||
if (!hasLocalStorage()) { | ||
return; | ||
} | ||
let currentRawData = localStorage.getItem("LOCATOR_OPTIONS"); | ||
@@ -71,0 +102,0 @@ addEventListener("storage", (event) => { |
50766
1654