Skip to content

Commit

Permalink
add WixMap (#330)
Browse files Browse the repository at this point in the history
Co-authored-by: dorcoh-wix <[email protected]>
  • Loading branch information
gileck and dorcoh-wix authored Sep 30, 2024
1 parent 0aa1aaf commit a73b542
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/src/babelPlugin/test.compiled.carmi.js
/website/
/docs
/bytecode/bytecode-functions.js
/bytecode/bytecode-functions.js
/node_modules
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [16.x]

steps:
- uses: actions/checkout@v1
Expand Down
24 changes: 21 additions & 3 deletions src/babelPlugin/__snapshots__/macro-debug.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 21 additions & 3 deletions src/babelPlugin/__snapshots__/macro-no-current-line.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 21 additions & 3 deletions src/babelPlugin/__snapshots__/macro.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 12 additions & 1 deletion src/templates/optimizing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a73b542

Please sign in to comment.