Comparing version 3.3.1 to 3.4.0
@@ -23,14 +23,17 @@ var __defProp = Object.defineProperty; | ||
var GLOBAL = typeof window === "object" ? window : typeof global === "object" ? global : {}; | ||
var Quarx = GLOBAL[TAG]; | ||
if (Quarx) { | ||
if (GLOBAL[TAG]) { | ||
console.log(`[Quarx]: WARNING!!! Another instance of Quarx is already initialized. | ||
This means code duplication and will possibly break in the future!`); | ||
} else | ||
Quarx = GLOBAL[TAG] = { | ||
GLOBAL[TAG] = { | ||
stack: [], | ||
invalidated: new Set(), | ||
pendingDispose: new Set(), | ||
sequenceNumber: 0, | ||
batchDepth: 0 | ||
sequenceNumber: 1, | ||
batchDepth: 0, | ||
debug: () => { | ||
}, | ||
error: console.error | ||
}; | ||
var Quarx = GLOBAL[TAG]; | ||
function tryCatch(fn, onError) { | ||
@@ -46,3 +49,3 @@ try { | ||
const onError = options.onError || function(e) { | ||
console.error(`[Quarx]: uncaught exception disposing ${name}:`, e); | ||
Quarx.error(`[Quarx]: uncaught exception disposing ${name}:`, e); | ||
}; | ||
@@ -53,2 +56,3 @@ const observers = new Map(); | ||
reportObserved() { | ||
Quarx.debug(`[Quarx]: ${name} observed`); | ||
const {invalidate, link} = Quarx.stack[Quarx.stack.length - 1] || {}; | ||
@@ -84,2 +88,3 @@ if (!invalidate) | ||
reportChanged() { | ||
Quarx.debug(`[Quarx]: ${name} changed`); | ||
({actualize} = Quarx.stack[Quarx.stack.length - 1] || {}); | ||
@@ -96,3 +101,3 @@ for (let invalidate of observers.keys()) | ||
const onError = options.onError || function(e) { | ||
console.error(`[Quarx]: uncaught exception in ${name}:`, e); | ||
Quarx.error(`[Quarx]: uncaught exception in ${name}:`, e); | ||
}; | ||
@@ -127,2 +132,3 @@ let dependencies = new Set(); | ||
function run() { | ||
Quarx.debug(`[Quarx]: Running ${name}`, Quarx.sequenceNumber); | ||
isRunning = true; | ||
@@ -141,2 +147,3 @@ const previousDeps = dependencies; | ||
isRunning = false; | ||
Quarx.debug(`[Quarx]: Finished ${name}`, Quarx.sequenceNumber); | ||
} | ||
@@ -164,2 +171,3 @@ function dispose() { | ||
++Quarx.sequenceNumber; | ||
Quarx.debug(`[Quarx]: Hydration ${Quarx.sequenceNumber}`); | ||
++Quarx.batchDepth; | ||
@@ -170,2 +178,3 @@ for (let run of Quarx.invalidated) | ||
collectUnobserved(); | ||
Quarx.debug(`[Quarx]: Hydration ${Quarx.sequenceNumber} END`); | ||
} | ||
@@ -257,1 +266,2 @@ function batch(fn) { | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ { | ||
"name": "quarx", | ||
"version": "3.3.1", | ||
"version": "3.4.0", | ||
"description": "Simple dependency graph engine, MobX inspired", | ||
@@ -18,3 +18,3 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "esbuild index.js --bundle --platform=node --outfile=dist/index.js", | ||
"build": "esbuild index.js --sourcemap --bundle --platform=node --outfile=dist/index.js", | ||
"test": "ava -v", | ||
@@ -21,0 +21,0 @@ "perf": "ava -v --config test.perf.config.js --node-arguments='--expose-gc'" |
@@ -5,16 +5,18 @@ const TAG = '@dmaevsky/quarx'; | ||
export let Quarx = GLOBAL[TAG]; | ||
if (Quarx) { | ||
if (GLOBAL[TAG]) { | ||
console.log(`[Quarx]: WARNING!!! Another instance of Quarx is already initialized. | ||
This means code duplication and will possibly break in the future!`); | ||
} | ||
else Quarx = GLOBAL[TAG] = { | ||
else GLOBAL[TAG] = { | ||
stack: [], | ||
invalidated: new Set(), | ||
pendingDispose: new Set(), | ||
sequenceNumber: 0, | ||
batchDepth: 0 | ||
sequenceNumber: 1, | ||
batchDepth: 0, | ||
debug: () => {}, | ||
error: console.error | ||
}; | ||
export const Quarx = GLOBAL[TAG]; | ||
function tryCatch(fn, onError) { | ||
@@ -32,3 +34,3 @@ try { | ||
const onError = options.onError || function(e) { | ||
console.error(`[Quarx]: uncaught exception disposing ${name}:`, e); | ||
Quarx.error(`[Quarx]: uncaught exception disposing ${name}:`, e); | ||
} | ||
@@ -41,3 +43,3 @@ | ||
reportObserved() { | ||
// console.debug(`[Quarx]: ${name} observed`); | ||
Quarx.debug(`[Quarx]: ${name} observed`); | ||
const { invalidate, link } = Quarx.stack[Quarx.stack.length - 1] || {}; | ||
@@ -75,3 +77,3 @@ if (!invalidate) return false; | ||
reportChanged() { | ||
// console.debug(`[Quarx]: ${name} changed`); | ||
Quarx.debug(`[Quarx]: ${name} changed`); | ||
({ actualize } = Quarx.stack[Quarx.stack.length - 1] || {}); | ||
@@ -88,3 +90,3 @@ for (let invalidate of observers.keys()) invalidate(); | ||
const onError = options.onError || function(e) { | ||
console.error(`[Quarx]: uncaught exception in ${name}:`, e); | ||
Quarx.error(`[Quarx]: uncaught exception in ${name}:`, e); | ||
} | ||
@@ -124,3 +126,3 @@ | ||
function run() { | ||
// console.debug(`[Quarx]: Running ${name}`, Quarx.sequenceNumber); | ||
Quarx.debug(`[Quarx]: Running ${name}`, Quarx.sequenceNumber); | ||
isRunning = true; | ||
@@ -145,3 +147,3 @@ | ||
isRunning = false; | ||
// console.debug(`[Quarx]: Finished ${name}`, Quarx.sequenceNumber); | ||
Quarx.debug(`[Quarx]: Finished ${name}`, Quarx.sequenceNumber); | ||
} | ||
@@ -171,3 +173,3 @@ | ||
++Quarx.sequenceNumber; | ||
// console.debug(`[Quarx]: Hydration ${Quarx.sequenceNumber}`); | ||
Quarx.debug(`[Quarx]: Hydration ${Quarx.sequenceNumber}`); | ||
@@ -180,3 +182,3 @@ ++Quarx.batchDepth; | ||
// console.debug(`[Quarx]: Hydration ${Quarx.sequenceNumber} END`); | ||
Quarx.debug(`[Quarx]: Hydration ${Quarx.sequenceNumber} END`); | ||
} | ||
@@ -183,0 +185,0 @@ |
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
31742
11
498