diff --git a/.eslintignore b/.eslintignore index 691103a..70faf94 100644 --- a/.eslintignore +++ b/.eslintignore @@ -3,4 +3,5 @@ /src/babelPlugin/test.compiled.carmi.js /website/ /docs -/bytecode/bytecode-functions.js \ No newline at end of file +/bytecode/bytecode-functions.js +/node_modules \ No newline at end of file diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 7e2e4d7..bfea51f 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x, 16.x] + node-version: [16.x] steps: - uses: actions/checkout@v1 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 8472da9..89e2bc9 100644 --- a/src/templates/optimizing.js +++ b/src/templates/optimizing.js @@ -165,9 +165,20 @@ 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 = new WeakMap(); + const $invalidatedMap = getWeakMap() const $invalidatedRoots = new Set(); $invalidatedRoots.$subKeys = new Map(); $invalidatedRoots.$parentKey = null;