diff --git a/src/babelPlugin/__snapshots__/macro-debug.spec.js.snap b/src/babelPlugin/__snapshots__/macro-debug.spec.js.snap index 902d80b..68750f1 100644 --- a/src/babelPlugin/__snapshots__/macro-debug.spec.js.snap +++ b/src/babelPlugin/__snapshots__/macro-debug.spec.js.snap @@ -31,7 +31,13 @@ module.exports = function () { }if (types.some(checkType)) { return; }const asString = typeof input === 'object' ? JSON.stringify(input) : input;throw new TypeError(\`\${functionName} expects \${types.join('/')}. \${name} at \${source}: \${asString}.\${functionName}\`); - }const $res = { $model };const $listeners = new Set();const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = new WeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { + }const $res = { $model };const $listeners = new Set();function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap(); + }if (window.WixMap) { + return new window.WixMap(); + }return new WeakMap(); + }const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = getWeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { const $tracked = $targetKeySet.$tracked;if (!$tracked || !$tracked.has($targetKey)) { return; }const $trackedByKey = $tracked.get($targetKey);for (let i = 0; i < $trackedByKey.length; i += 3) { @@ -635,7 +641,13 @@ module.exports = function () { }if (types.some(checkType)) { return; }const asString = typeof input === 'object' ? JSON.stringify(input) : input;throw new TypeError(\`\${functionName} expects \${types.join('/')}. \${name} at \${source}: \${asString}.\${functionName}\`); - }const $res = { $model };const $listeners = new Set();const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = new WeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { + }const $res = { $model };const $listeners = new Set();function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap(); + }if (window.WixMap) { + return new window.WixMap(); + }return new WeakMap(); + }const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = getWeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { const $tracked = $targetKeySet.$tracked;if (!$tracked || !$tracked.has($targetKey)) { return; }const $trackedByKey = $tracked.get($targetKey);for (let i = 0; i < $trackedByKey.length; i += 3) { @@ -1241,7 +1253,13 @@ const modelBuilder = (function () { }if (types.some(checkType)) { return; }const asString = typeof input === 'object' ? JSON.stringify(input) : input;throw new TypeError(\`\${functionName} expects \${types.join('/')}. \${name} at \${source}: \${asString}.\${functionName}\`); - }const $res = { $model };const $listeners = new Set();const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = new WeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { + }const $res = { $model };const $listeners = new Set();function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap(); + }if (window.WixMap) { + return new window.WixMap(); + }return new WeakMap(); + }const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = getWeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { const $tracked = $targetKeySet.$tracked;if (!$tracked || !$tracked.has($targetKey)) { return; }const $trackedByKey = $tracked.get($targetKey);for (let i = 0; i < $trackedByKey.length; i += 3) { diff --git a/src/babelPlugin/__snapshots__/macro-no-current-line.spec.js.snap b/src/babelPlugin/__snapshots__/macro-no-current-line.spec.js.snap index d577fee..96c8958 100644 --- a/src/babelPlugin/__snapshots__/macro-no-current-line.spec.js.snap +++ b/src/babelPlugin/__snapshots__/macro-no-current-line.spec.js.snap @@ -31,7 +31,13 @@ module.exports = function () { }if (types.some(checkType)) { return; }const asString = typeof input === 'object' ? JSON.stringify(input) : input;throw new TypeError(\`\${functionName} expects \${types.join('/')}. \${name} at \${source}: \${asString}.\${functionName}\`); - }const $res = { $model };const $listeners = new Set();const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = new WeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { + }const $res = { $model };const $listeners = new Set();function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap(); + }if (window.WixMap) { + return new window.WixMap(); + }return new WeakMap(); + }const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = getWeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { const $tracked = $targetKeySet.$tracked;if (!$tracked || !$tracked.has($targetKey)) { return; }const $trackedByKey = $tracked.get($targetKey);for (let i = 0; i < $trackedByKey.length; i += 3) { @@ -635,7 +641,13 @@ module.exports = function () { }if (types.some(checkType)) { return; }const asString = typeof input === 'object' ? JSON.stringify(input) : input;throw new TypeError(\`\${functionName} expects \${types.join('/')}. \${name} at \${source}: \${asString}.\${functionName}\`); - }const $res = { $model };const $listeners = new Set();const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = new WeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { + }const $res = { $model };const $listeners = new Set();function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap(); + }if (window.WixMap) { + return new window.WixMap(); + }return new WeakMap(); + }const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = getWeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { const $tracked = $targetKeySet.$tracked;if (!$tracked || !$tracked.has($targetKey)) { return; }const $trackedByKey = $tracked.get($targetKey);for (let i = 0; i < $trackedByKey.length; i += 3) { @@ -1241,7 +1253,13 @@ const modelBuilder = (function () { }if (types.some(checkType)) { return; }const asString = typeof input === 'object' ? JSON.stringify(input) : input;throw new TypeError(\`\${functionName} expects \${types.join('/')}. \${name} at \${source}: \${asString}.\${functionName}\`); - }const $res = { $model };const $listeners = new Set();const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = new WeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { + }const $res = { $model };const $listeners = new Set();function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap(); + }if (window.WixMap) { + return new window.WixMap(); + }return new WeakMap(); + }const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = getWeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { const $tracked = $targetKeySet.$tracked;if (!$tracked || !$tracked.has($targetKey)) { return; }const $trackedByKey = $tracked.get($targetKey);for (let i = 0; i < $trackedByKey.length; i += 3) { diff --git a/src/babelPlugin/__snapshots__/macro.spec.js.snap b/src/babelPlugin/__snapshots__/macro.spec.js.snap index f8f1c75..c027c9d 100644 --- a/src/babelPlugin/__snapshots__/macro.spec.js.snap +++ b/src/babelPlugin/__snapshots__/macro.spec.js.snap @@ -31,7 +31,13 @@ module.exports = function () { }if (types.some(checkType)) { return; }const asString = typeof input === 'object' ? JSON.stringify(input) : input;throw new TypeError(\`\${functionName} expects \${types.join('/')}. \${name} at \${source}: \${asString}.\${functionName}\`); - }const $res = { $model };const $listeners = new Set();const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = new WeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { + }const $res = { $model };const $listeners = new Set();function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap(); + }if (window.WixMap) { + return new window.WixMap(); + }return new WeakMap(); + }const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = getWeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { const $tracked = $targetKeySet.$tracked;if (!$tracked || !$tracked.has($targetKey)) { return; }const $trackedByKey = $tracked.get($targetKey);for (let i = 0; i < $trackedByKey.length; i += 3) { @@ -635,7 +641,13 @@ module.exports = function () { }if (types.some(checkType)) { return; }const asString = typeof input === 'object' ? JSON.stringify(input) : input;throw new TypeError(\`\${functionName} expects \${types.join('/')}. \${name} at \${source}: \${asString}.\${functionName}\`); - }const $res = { $model };const $listeners = new Set();const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = new WeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { + }const $res = { $model };const $listeners = new Set();function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap(); + }if (window.WixMap) { + return new window.WixMap(); + }return new WeakMap(); + }const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = getWeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { const $tracked = $targetKeySet.$tracked;if (!$tracked || !$tracked.has($targetKey)) { return; }const $trackedByKey = $tracked.get($targetKey);for (let i = 0; i < $trackedByKey.length; i += 3) { @@ -1241,7 +1253,13 @@ const modelBuilder = (function () { }if (types.some(checkType)) { return; }const asString = typeof input === 'object' ? JSON.stringify(input) : input;throw new TypeError(\`\${functionName} expects \${types.join('/')}. \${name} at \${source}: \${asString}.\${functionName}\`); - }const $res = { $model };const $listeners = new Set();const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = new WeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { + }const $res = { $model };const $listeners = new Set();function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap(); + }if (window.WixMap) { + return new window.WixMap(); + }return new WeakMap(); + }const $trackingMap = new WeakMap();const $trackingWildcards = new WeakMap();const $invalidatedMap = getWeakMap();const $invalidatedRoots = new Set();$invalidatedRoots.$subKeys = new Map();$invalidatedRoots.$parentKey = null;$invalidatedRoots.$parent = null;$invalidatedRoots.$tracked = new Map();let $first = true;let $tainted = new WeakSet();$invalidatedMap.set($res, $invalidatedRoots);function untrack($targetKeySet, $targetKey) { const $tracked = $targetKeySet.$tracked;if (!$tracked || !$tracked.has($targetKey)) { return; }const $trackedByKey = $tracked.get($targetKey);for (let i = 0; i < $trackedByKey.length; i += 3) { diff --git a/src/templates/optimizing.js b/src/templates/optimizing.js index 9e7fd1d..89e2bc9 100644 --- a/src/templates/optimizing.js +++ b/src/templates/optimizing.js @@ -1,15 +1,3 @@ -function getWeakMap() { - if (typeof window !== 'undefined') { - return new WeakMap() - } - - if (window.WixMap) { - return new window.WixMap() - } - - return new WeakMap() -} - function base() { function $NAME($model, $funcLibRaw, $batchingStrategy) { let $funcLib = $funcLibRaw @@ -177,6 +165,17 @@ function base() { } function library() { + function getWeakMap() { + if (typeof window !== 'undefined') { + return new WeakMap() + } + + if (window.WixMap) { + return new window.WixMap() + } + + return new WeakMap() + } const $trackingMap = new WeakMap(); const $trackingWildcards = new WeakMap(); const $invalidatedMap = getWeakMap()