improvements in frontend sync (WIP)

This commit is contained in:
zadam 2021-08-20 21:42:06 +02:00
parent e050e380b9
commit b99d83af50
8 changed files with 334 additions and 374 deletions

230
package-lock.json generated
View File

@ -40,7 +40,7 @@
"is-svg": "4.3.1", "is-svg": "4.3.1",
"jimp": "0.16.1", "jimp": "0.16.1",
"joplin-turndown-plugin-gfm": "1.0.12", "joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "16.7.0", "jsdom": "17.0.0",
"mime-types": "2.1.32", "mime-types": "2.1.32",
"multer": "1.4.3", "multer": "1.4.3",
"node-abi": "2.30.0", "node-abi": "2.30.0",
@ -60,7 +60,7 @@
"tmp": "^0.2.1", "tmp": "^0.2.1",
"turndown": "7.1.1", "turndown": "7.1.1",
"unescape": "1.0.1", "unescape": "1.0.1",
"ws": "8.1.0", "ws": "8.2.0",
"yauzl": "2.10.0" "yauzl": "2.10.0"
}, },
"bin": { "bin": {
@ -68,17 +68,17 @@
}, },
"devDependencies": { "devDependencies": {
"cross-env": "7.0.3", "cross-env": "7.0.3",
"electron": "13.1.9", "electron": "13.2.1",
"electron-builder": "22.11.7", "electron-builder": "22.11.7",
"electron-packager": "15.3.0", "electron-packager": "15.3.0",
"electron-rebuild": "3.1.1", "electron-rebuild": "3.2.0",
"esm": "3.2.25", "esm": "3.2.25",
"jasmine": "3.8.0", "jasmine": "3.8.0",
"jsdoc": "3.6.7", "jsdoc": "3.6.7",
"lorem-ipsum": "2.0.3", "lorem-ipsum": "2.0.3",
"rcedit": "3.0.1", "rcedit": "3.0.1",
"webpack": "5.50.0", "webpack": "5.51.1",
"webpack-cli": "4.7.2" "webpack-cli": "4.8.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"electron-installer-debian": "3.1.0" "electron-installer-debian": "3.1.0"
@ -1139,9 +1139,9 @@
} }
}, },
"node_modules/@webpack-cli/serve": { "node_modules/@webpack-cli/serve": {
"version": "1.5.1", "version": "1.5.2",
"resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.5.1.tgz", "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.5.2.tgz",
"integrity": "sha512-4vSVUiOPJLmr45S8rMGy7WDvpWxfFxfP/Qx/cxZFCfvoypTYpPPL1X8VIZMe0WTA+Jr7blUxwUSEZNkjoMTgSw==", "integrity": "sha512-vgJ5OLWadI8aKjDlOH3rb+dYyPd2GTZuQC/Tihjct6F9GpXGZINo3Y/IVuZVTM1eDQB+/AOsjPUWH/WySDaXvw==",
"dev": true, "dev": true,
"peerDependencies": { "peerDependencies": {
"webpack-cli": "4.x.x" "webpack-cli": "4.x.x"
@ -3124,9 +3124,9 @@
} }
}, },
"node_modules/cssom": { "node_modules/cssom": {
"version": "0.4.4", "version": "0.5.0",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz",
"integrity": "sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==" "integrity": "sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw=="
}, },
"node_modules/cssstyle": { "node_modules/cssstyle": {
"version": "2.3.0", "version": "2.3.0",
@ -3190,16 +3190,16 @@
} }
}, },
"node_modules/data-urls": { "node_modules/data-urls": {
"version": "2.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.0.tgz",
"integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==", "integrity": "sha512-4AefxbTTdFtxDUdh0BuMBs2qJVL25Mow2zlcuuePegQwgD6GEmQao42LLEeksOui8nL4RcNEugIpFP7eRd33xg==",
"dependencies": { "dependencies": {
"abab": "^2.0.3", "abab": "^2.0.3",
"whatwg-mimetype": "^2.3.0", "whatwg-mimetype": "^2.3.0",
"whatwg-url": "^8.0.0" "whatwg-url": "^9.0.0"
}, },
"engines": { "engines": {
"node": ">=10" "node": ">=12"
} }
}, },
"node_modules/dayjs": { "node_modules/dayjs": {
@ -3231,9 +3231,9 @@
} }
}, },
"node_modules/decimal.js": { "node_modules/decimal.js": {
"version": "10.2.1", "version": "10.3.1",
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.1.tgz", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz",
"integrity": "sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw==" "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ=="
}, },
"node_modules/decompress-response": { "node_modules/decompress-response": {
"version": "3.3.0", "version": "3.3.0",
@ -3640,9 +3640,9 @@
} }
}, },
"node_modules/electron": { "node_modules/electron": {
"version": "13.1.9", "version": "13.2.1",
"resolved": "https://registry.npmjs.org/electron/-/electron-13.1.9.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-13.2.1.tgz",
"integrity": "sha512-By4Zb72XNQLrPb70BXdIW3NtEHFwybP5DIQjohnCxOYONq5vojuHjNcTuWnBgMvwQ2qwykk6Tw5EwF2Pt0CWjA==", "integrity": "sha512-/K0Uw+o3+phbHtrVL6qDFVJqmeRF6EIPwVeUHEH5R8JNy13f4X3RouKjQzVyY/Os8fEqYHGFONWhD6q6g750HQ==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
@ -4309,9 +4309,9 @@
} }
}, },
"node_modules/electron-rebuild": { "node_modules/electron-rebuild": {
"version": "3.1.1", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/electron-rebuild/-/electron-rebuild-3.1.1.tgz", "resolved": "https://registry.npmjs.org/electron-rebuild/-/electron-rebuild-3.2.0.tgz",
"integrity": "sha512-RZwfpTKX8secCONpmQk3X0Ryf6GSEzzsqZ4RTrBoae3sMi76DI0ChG90XqdSE775Xpyts3V40VpqJHv3QUAavw==", "integrity": "sha512-iCR90cKuLZaVsVGpEPp7XASkqLiuoZfpJnBVyKXZy0e6HuE8CtNSSNskkOCzEIcxQXcQAklFr0LJUj/zeFxJMw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@malept/cross-spawn-promise": "^2.0.0", "@malept/cross-spawn-promise": "^2.0.0",
@ -6489,20 +6489,20 @@
} }
}, },
"node_modules/jsdom": { "node_modules/jsdom": {
"version": "16.7.0", "version": "17.0.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-17.0.0.tgz",
"integrity": "sha512-u9Smc2G1USStM+s/x1ru5Sxrl6mPYCbByG1U/hUmqaVsm4tbNyS7CicOSRyuGQYZhTu0h84qkZZQ/I+dzizSVw==", "integrity": "sha512-MUq4XdqwtNurZDVeKScENMPHnkgmdIvMzZ1r1NSwHkDuaqI6BouPjr+17COo4/19oLNnmdpFDPOHVpgIZmZ+VA==",
"dependencies": { "dependencies": {
"abab": "^2.0.5", "abab": "^2.0.5",
"acorn": "^8.2.4", "acorn": "^8.4.1",
"acorn-globals": "^6.0.0", "acorn-globals": "^6.0.0",
"cssom": "^0.4.4", "cssom": "^0.5.0",
"cssstyle": "^2.3.0", "cssstyle": "^2.3.0",
"data-urls": "^2.0.0", "data-urls": "^3.0.0",
"decimal.js": "^10.2.1", "decimal.js": "^10.3.1",
"domexception": "^2.0.1", "domexception": "^2.0.1",
"escodegen": "^2.0.0", "escodegen": "^2.0.0",
"form-data": "^3.0.0", "form-data": "^4.0.0",
"html-encoding-sniffer": "^2.0.1", "html-encoding-sniffer": "^2.0.1",
"http-proxy-agent": "^4.0.1", "http-proxy-agent": "^4.0.1",
"https-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.0",
@ -6517,12 +6517,12 @@
"webidl-conversions": "^6.1.0", "webidl-conversions": "^6.1.0",
"whatwg-encoding": "^1.0.5", "whatwg-encoding": "^1.0.5",
"whatwg-mimetype": "^2.3.0", "whatwg-mimetype": "^2.3.0",
"whatwg-url": "^8.5.0", "whatwg-url": "^9.0.0",
"ws": "^7.4.6", "ws": "^8.0.0",
"xml-name-validator": "^3.0.0" "xml-name-validator": "^3.0.0"
}, },
"engines": { "engines": {
"node": ">=10" "node": ">=12"
}, },
"peerDependencies": { "peerDependencies": {
"canvas": "^2.5.0" "canvas": "^2.5.0"
@ -6534,9 +6534,9 @@
} }
}, },
"node_modules/jsdom/node_modules/form-data": { "node_modules/jsdom/node_modules/form-data": {
"version": "3.0.1", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": { "dependencies": {
"asynckit": "^0.4.0", "asynckit": "^0.4.0",
"combined-stream": "^1.0.8", "combined-stream": "^1.0.8",
@ -6551,26 +6551,6 @@
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==" "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
}, },
"node_modules/jsdom/node_modules/ws": {
"version": "7.5.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.3.tgz",
"integrity": "sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==",
"engines": {
"node": ">=8.3.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/json-buffer": { "node_modules/json-buffer": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz",
@ -10178,9 +10158,9 @@
} }
}, },
"node_modules/webpack": { "node_modules/webpack": {
"version": "5.50.0", "version": "5.51.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.50.0.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.51.1.tgz",
"integrity": "sha512-hqxI7t/KVygs0WRv/kTgUW8Kl3YC81uyWQSo/7WUs5LsuRw0htH/fCwbVBGCuiX/t4s7qzjXFcf41O8Reiypag==", "integrity": "sha512-xsn3lwqEKoFvqn4JQggPSRxE4dhsRcysWTqYABAZlmavcoTmwlOb9b1N36Inbt/eIispSkuHa80/FJkDTPos1A==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",
@ -10225,15 +10205,15 @@
} }
}, },
"node_modules/webpack-cli": { "node_modules/webpack-cli": {
"version": "4.7.2", "version": "4.8.0",
"resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.7.2.tgz", "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.8.0.tgz",
"integrity": "sha512-mEoLmnmOIZQNiRl0ebnjzQ74Hk0iKS5SiEEnpq3dRezoyR3yPaeQZCMCe+db4524pj1Pd5ghZXjT41KLzIhSLw==", "integrity": "sha512-+iBSWsX16uVna5aAYN6/wjhJy1q/GKk4KjKvfg90/6hykCTSgozbfz5iRgDTSJt/LgSbYxdBX3KBHeobIs+ZEw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@discoveryjs/json-ext": "^0.5.0", "@discoveryjs/json-ext": "^0.5.0",
"@webpack-cli/configtest": "^1.0.4", "@webpack-cli/configtest": "^1.0.4",
"@webpack-cli/info": "^1.3.0", "@webpack-cli/info": "^1.3.0",
"@webpack-cli/serve": "^1.5.1", "@webpack-cli/serve": "^1.5.2",
"colorette": "^1.2.1", "colorette": "^1.2.1",
"commander": "^7.0.0", "commander": "^7.0.0",
"execa": "^5.0.0", "execa": "^5.0.0",
@ -10313,16 +10293,15 @@
"integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==" "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g=="
}, },
"node_modules/whatwg-url": { "node_modules/whatwg-url": {
"version": "8.5.0", "version": "9.1.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.5.0.tgz", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-9.1.0.tgz",
"integrity": "sha512-fy+R77xWv0AiqfLl4nuGUlQ3/6b5uNfQ4WAbGQVMYshCTCCPK9psC1nWh3XHuxGVCtlcDDQPQW1csmmIQo+fwg==", "integrity": "sha512-CQ0UcrPHyomtlOCot1TL77WyMIm/bCwrJ2D6AOKGwEczU9EpyoqAokfqrf/MioU9kHcMsmJZcg1egXix2KYEsA==",
"dependencies": { "dependencies": {
"lodash": "^4.7.0", "tr46": "^2.1.0",
"tr46": "^2.0.2",
"webidl-conversions": "^6.1.0" "webidl-conversions": "^6.1.0"
}, },
"engines": { "engines": {
"node": ">=10" "node": ">=12"
} }
}, },
"node_modules/which": { "node_modules/which": {
@ -10549,9 +10528,9 @@
} }
}, },
"node_modules/ws": { "node_modules/ws": {
"version": "8.1.0", "version": "8.2.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.1.0.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.0.tgz",
"integrity": "sha512-0UWlCD2s3RSclw8FN+D0zDTUyMO+1kHwJQQJzkgUh16S8d3NYON0AKCEQPffE0ez4JyRFu76QDA9KR5bOG/7jw==", "integrity": "sha512-uYhVJ/m9oXwEI04iIVmgLmugh2qrZihkywG9y5FfZV2ATeLIzHf93qs+tUNqlttbQK957/VX3mtwAS+UfIwA4g==",
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"
}, },
@ -11726,9 +11705,9 @@
} }
}, },
"@webpack-cli/serve": { "@webpack-cli/serve": {
"version": "1.5.1", "version": "1.5.2",
"resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.5.1.tgz", "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.5.2.tgz",
"integrity": "sha512-4vSVUiOPJLmr45S8rMGy7WDvpWxfFxfP/Qx/cxZFCfvoypTYpPPL1X8VIZMe0WTA+Jr7blUxwUSEZNkjoMTgSw==", "integrity": "sha512-vgJ5OLWadI8aKjDlOH3rb+dYyPd2GTZuQC/Tihjct6F9GpXGZINo3Y/IVuZVTM1eDQB+/AOsjPUWH/WySDaXvw==",
"dev": true, "dev": true,
"requires": {} "requires": {}
}, },
@ -13306,9 +13285,9 @@
"integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==" "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg=="
}, },
"cssom": { "cssom": {
"version": "0.4.4", "version": "0.5.0",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz",
"integrity": "sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==" "integrity": "sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw=="
}, },
"cssstyle": { "cssstyle": {
"version": "2.3.0", "version": "2.3.0",
@ -13364,13 +13343,13 @@
} }
}, },
"data-urls": { "data-urls": {
"version": "2.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.0.tgz",
"integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==", "integrity": "sha512-4AefxbTTdFtxDUdh0BuMBs2qJVL25Mow2zlcuuePegQwgD6GEmQao42LLEeksOui8nL4RcNEugIpFP7eRd33xg==",
"requires": { "requires": {
"abab": "^2.0.3", "abab": "^2.0.3",
"whatwg-mimetype": "^2.3.0", "whatwg-mimetype": "^2.3.0",
"whatwg-url": "^8.0.0" "whatwg-url": "^9.0.0"
} }
}, },
"dayjs": { "dayjs": {
@ -13400,9 +13379,9 @@
"optional": true "optional": true
}, },
"decimal.js": { "decimal.js": {
"version": "10.2.1", "version": "10.3.1",
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.1.tgz", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz",
"integrity": "sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw==" "integrity": "sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ=="
}, },
"decompress-response": { "decompress-response": {
"version": "3.3.0", "version": "3.3.0",
@ -13732,9 +13711,9 @@
} }
}, },
"electron": { "electron": {
"version": "13.1.9", "version": "13.2.1",
"resolved": "https://registry.npmjs.org/electron/-/electron-13.1.9.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-13.2.1.tgz",
"integrity": "sha512-By4Zb72XNQLrPb70BXdIW3NtEHFwybP5DIQjohnCxOYONq5vojuHjNcTuWnBgMvwQ2qwykk6Tw5EwF2Pt0CWjA==", "integrity": "sha512-/K0Uw+o3+phbHtrVL6qDFVJqmeRF6EIPwVeUHEH5R8JNy13f4X3RouKjQzVyY/Os8fEqYHGFONWhD6q6g750HQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^1.0.1", "@electron/get": "^1.0.1",
@ -14247,9 +14226,9 @@
} }
}, },
"electron-rebuild": { "electron-rebuild": {
"version": "3.1.1", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/electron-rebuild/-/electron-rebuild-3.1.1.tgz", "resolved": "https://registry.npmjs.org/electron-rebuild/-/electron-rebuild-3.2.0.tgz",
"integrity": "sha512-RZwfpTKX8secCONpmQk3X0Ryf6GSEzzsqZ4RTrBoae3sMi76DI0ChG90XqdSE775Xpyts3V40VpqJHv3QUAavw==", "integrity": "sha512-iCR90cKuLZaVsVGpEPp7XASkqLiuoZfpJnBVyKXZy0e6HuE8CtNSSNskkOCzEIcxQXcQAklFr0LJUj/zeFxJMw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@malept/cross-spawn-promise": "^2.0.0", "@malept/cross-spawn-promise": "^2.0.0",
@ -15928,20 +15907,20 @@
} }
}, },
"jsdom": { "jsdom": {
"version": "16.7.0", "version": "17.0.0",
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.7.0.tgz", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-17.0.0.tgz",
"integrity": "sha512-u9Smc2G1USStM+s/x1ru5Sxrl6mPYCbByG1U/hUmqaVsm4tbNyS7CicOSRyuGQYZhTu0h84qkZZQ/I+dzizSVw==", "integrity": "sha512-MUq4XdqwtNurZDVeKScENMPHnkgmdIvMzZ1r1NSwHkDuaqI6BouPjr+17COo4/19oLNnmdpFDPOHVpgIZmZ+VA==",
"requires": { "requires": {
"abab": "^2.0.5", "abab": "^2.0.5",
"acorn": "^8.2.4", "acorn": "^8.4.1",
"acorn-globals": "^6.0.0", "acorn-globals": "^6.0.0",
"cssom": "^0.4.4", "cssom": "^0.5.0",
"cssstyle": "^2.3.0", "cssstyle": "^2.3.0",
"data-urls": "^2.0.0", "data-urls": "^3.0.0",
"decimal.js": "^10.2.1", "decimal.js": "^10.3.1",
"domexception": "^2.0.1", "domexception": "^2.0.1",
"escodegen": "^2.0.0", "escodegen": "^2.0.0",
"form-data": "^3.0.0", "form-data": "^4.0.0",
"html-encoding-sniffer": "^2.0.1", "html-encoding-sniffer": "^2.0.1",
"http-proxy-agent": "^4.0.1", "http-proxy-agent": "^4.0.1",
"https-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.0",
@ -15956,15 +15935,15 @@
"webidl-conversions": "^6.1.0", "webidl-conversions": "^6.1.0",
"whatwg-encoding": "^1.0.5", "whatwg-encoding": "^1.0.5",
"whatwg-mimetype": "^2.3.0", "whatwg-mimetype": "^2.3.0",
"whatwg-url": "^8.5.0", "whatwg-url": "^9.0.0",
"ws": "^7.4.6", "ws": "^8.0.0",
"xml-name-validator": "^3.0.0" "xml-name-validator": "^3.0.0"
}, },
"dependencies": { "dependencies": {
"form-data": { "form-data": {
"version": "3.0.1", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"requires": { "requires": {
"asynckit": "^0.4.0", "asynckit": "^0.4.0",
"combined-stream": "^1.0.8", "combined-stream": "^1.0.8",
@ -15975,12 +15954,6 @@
"version": "6.0.1", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==" "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
},
"ws": {
"version": "7.5.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.3.tgz",
"integrity": "sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==",
"requires": {}
} }
} }
}, },
@ -18830,9 +18803,9 @@
"integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==" "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w=="
}, },
"webpack": { "webpack": {
"version": "5.50.0", "version": "5.51.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.50.0.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.51.1.tgz",
"integrity": "sha512-hqxI7t/KVygs0WRv/kTgUW8Kl3YC81uyWQSo/7WUs5LsuRw0htH/fCwbVBGCuiX/t4s7qzjXFcf41O8Reiypag==", "integrity": "sha512-xsn3lwqEKoFvqn4JQggPSRxE4dhsRcysWTqYABAZlmavcoTmwlOb9b1N36Inbt/eIispSkuHa80/FJkDTPos1A==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",
@ -18862,15 +18835,15 @@
} }
}, },
"webpack-cli": { "webpack-cli": {
"version": "4.7.2", "version": "4.8.0",
"resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.7.2.tgz", "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.8.0.tgz",
"integrity": "sha512-mEoLmnmOIZQNiRl0ebnjzQ74Hk0iKS5SiEEnpq3dRezoyR3yPaeQZCMCe+db4524pj1Pd5ghZXjT41KLzIhSLw==", "integrity": "sha512-+iBSWsX16uVna5aAYN6/wjhJy1q/GKk4KjKvfg90/6hykCTSgozbfz5iRgDTSJt/LgSbYxdBX3KBHeobIs+ZEw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@discoveryjs/json-ext": "^0.5.0", "@discoveryjs/json-ext": "^0.5.0",
"@webpack-cli/configtest": "^1.0.4", "@webpack-cli/configtest": "^1.0.4",
"@webpack-cli/info": "^1.3.0", "@webpack-cli/info": "^1.3.0",
"@webpack-cli/serve": "^1.5.1", "@webpack-cli/serve": "^1.5.2",
"colorette": "^1.2.1", "colorette": "^1.2.1",
"commander": "^7.0.0", "commander": "^7.0.0",
"execa": "^5.0.0", "execa": "^5.0.0",
@ -18920,12 +18893,11 @@
"integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==" "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g=="
}, },
"whatwg-url": { "whatwg-url": {
"version": "8.5.0", "version": "9.1.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.5.0.tgz", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-9.1.0.tgz",
"integrity": "sha512-fy+R77xWv0AiqfLl4nuGUlQ3/6b5uNfQ4WAbGQVMYshCTCCPK9psC1nWh3XHuxGVCtlcDDQPQW1csmmIQo+fwg==", "integrity": "sha512-CQ0UcrPHyomtlOCot1TL77WyMIm/bCwrJ2D6AOKGwEczU9EpyoqAokfqrf/MioU9kHcMsmJZcg1egXix2KYEsA==",
"requires": { "requires": {
"lodash": "^4.7.0", "tr46": "^2.1.0",
"tr46": "^2.0.2",
"webidl-conversions": "^6.1.0" "webidl-conversions": "^6.1.0"
} }
}, },
@ -19109,9 +19081,9 @@
} }
}, },
"ws": { "ws": {
"version": "8.1.0", "version": "8.2.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.1.0.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.0.tgz",
"integrity": "sha512-0UWlCD2s3RSclw8FN+D0zDTUyMO+1kHwJQQJzkgUh16S8d3NYON0AKCEQPffE0ez4JyRFu76QDA9KR5bOG/7jw==", "integrity": "sha512-uYhVJ/m9oXwEI04iIVmgLmugh2qrZihkywG9y5FfZV2ATeLIzHf93qs+tUNqlttbQK957/VX3mtwAS+UfIwA4g==",
"requires": {} "requires": {}
}, },
"xdg-basedir": { "xdg-basedir": {

View File

@ -56,7 +56,7 @@
"is-svg": "4.3.1", "is-svg": "4.3.1",
"jimp": "0.16.1", "jimp": "0.16.1",
"joplin-turndown-plugin-gfm": "1.0.12", "joplin-turndown-plugin-gfm": "1.0.12",
"jsdom": "16.7.0", "jsdom": "17.0.0",
"mime-types": "2.1.32", "mime-types": "2.1.32",
"multer": "1.4.3", "multer": "1.4.3",
"node-abi": "2.30.0", "node-abi": "2.30.0",
@ -76,22 +76,22 @@
"tmp": "^0.2.1", "tmp": "^0.2.1",
"turndown": "7.1.1", "turndown": "7.1.1",
"unescape": "1.0.1", "unescape": "1.0.1",
"ws": "8.1.0", "ws": "8.2.0",
"yauzl": "2.10.0" "yauzl": "2.10.0"
}, },
"devDependencies": { "devDependencies": {
"cross-env": "7.0.3", "cross-env": "7.0.3",
"electron": "13.1.9", "electron": "13.2.1",
"electron-builder": "22.11.7", "electron-builder": "22.11.7",
"electron-packager": "15.3.0", "electron-packager": "15.3.0",
"electron-rebuild": "3.1.1", "electron-rebuild": "3.2.0",
"esm": "3.2.25", "esm": "3.2.25",
"jasmine": "3.8.0", "jasmine": "3.8.0",
"jsdoc": "3.6.7", "jsdoc": "3.6.7",
"lorem-ipsum": "2.0.3", "lorem-ipsum": "2.0.3",
"rcedit": "3.0.1", "rcedit": "3.0.1",
"webpack": "5.50.0", "webpack": "5.51.1",
"webpack-cli": "4.7.2" "webpack-cli": "4.8.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"electron-installer-debian": "3.1.0" "electron-installer-debian": "3.1.0"

View File

@ -22,8 +22,6 @@ class Attribute {
this.position = row.position; this.position = row.position;
/** @param {boolean} isInheritable */ /** @param {boolean} isInheritable */
this.isInheritable = !!row.isInheritable; this.isInheritable = !!row.isInheritable;
/** @param {boolean} */
this.isDeleted = !!row.isDeleted;
} }
/** @returns {NoteShort} */ /** @returns {NoteShort} */

View File

@ -21,8 +21,6 @@ class Branch {
this.isExpanded = !!row.isExpanded; this.isExpanded = !!row.isExpanded;
/** @param {boolean} */ /** @param {boolean} */
this.fromSearchNote = !!row.fromSearchNote; this.fromSearchNote = !!row.fromSearchNote;
/** @param {boolean} */
this.isDeleted = !!row.isDeleted;
} }
/** @returns {NoteShort} */ /** @returns {NoteShort} */

View File

@ -61,8 +61,6 @@ class NoteShort {
this.type = row.type; this.type = row.type;
/** @param {string} content-type, e.g. "application/json" */ /** @param {string} content-type, e.g. "application/json" */
this.mime = row.mime; this.mime = row.mime;
/** @param {boolean} */
this.isDeleted = !!row.isDeleted;
} }
addParent(parentNoteId, branchId) { addParent(parentNoteId, branchId) {

View File

@ -0,0 +1,210 @@
import LoadResults from "./load_results.js";
import froca from "./froca.js";
import options from "./options.js";
import noteAttributeCache from "./note_attribute_cache.js";
import Branch from "../entities/branch.js";
import Attribute from "../entities/attribute.js";
async function processEntityChanges(entityChanges) {
const loadResults = new LoadResults(entityChanges);
for (const ec of entityChanges) {
try {
if (ec.entityName === 'notes') {
processNoteChange(loadResults, ec);
} else if (ec.entityName === 'branches') {
processBranchChange(loadResults, ec);
} else if (ec.entityName === 'attributes') {
processAttributeChange(loadResults, ec);
} else if (ec.entityName === 'note_reordering') {
processNoteReordering(loadResults, ec);
} else if (ec.entityName === 'note_contents') {
delete froca.noteComplementPromises[ec.entityId];
loadResults.addNoteContent(ec.entityId, ec.sourceId);
} else if (ec.entityName === 'note_revisions') {
loadResults.addNoteRevision(ec.entityId, ec.noteId, ec.sourceId);
} else if (ec.entityName === 'options') {
if (ec.entity.name === 'openTabs') {
continue; // only noise
}
options.set(ec.entity.name, ec.entity.value);
loadResults.addOption(ec.entity.name);
}
else {
throw new Error(`Unknown entityName ${ec.entityName}`);
}
}
catch (e) {
throw new Error(`Can't process entity ${JSON.stringify(ec)} with error ${e.message} ${e.stack}`);
}
}
const missingNoteIds = [];
for (const {entityName, entity} of entityChanges) {
if (!entity) { // if erased
continue;
}
if (entityName === 'branches' && !(entity.parentNoteId in froca.notes)) {
missingNoteIds.push(entity.parentNoteId);
}
else if (entityName === 'attributes'
&& entity.type === 'relation'
&& entity.name === 'template'
&& !(entity.value in froca.notes)) {
missingNoteIds.push(entity.value);
}
}
if (missingNoteIds.length > 0) {
await froca.reloadNotes(missingNoteIds);
}
if (!loadResults.isEmpty()) {
if (loadResults.hasAttributeRelatedChanges()) {
noteAttributeCache.invalidate();
}
const appContext = (await import("./app_context.js")).default;
await appContext.triggerEvent('entitiesReloaded', {loadResults});
}
}
function processNoteChange(loadResults, ec) {
const note = froca.notes[ec.entityId];
if (!note) {
return;
}
if (ec.isErased || ec.entity?.isDeleted) {
delete froca.notes[ec.entityId];
return;
}
note.update(ec.entity);
loadResults.addNote(ec.entityId, ec.sourceId);
}
function processBranchChange(loadResults, ec) {
let branch = froca.branches[ec.entityId];
if (ec.isErased || ec.entity?.isDeleted) {
if (branch) {
const childNote = froca.notes[branch.noteId];
const parentNote = froca.notes[branch.parentNoteId];
if (childNote) {
childNote.parents = childNote.parents.filter(parentNoteId => parentNoteId !== branch.parentNoteId);
delete childNote.parentToBranch[branch.parentNoteId];
}
if (parentNote) {
parentNote.children = parentNote.children.filter(childNoteId => childNoteId !== branch.noteId);
delete parentNote.childToBranch[branch.noteId];
}
delete froca.branches[ec.entityId];
}
return;
}
const childNote = froca.notes[ec.entity.noteId];
const parentNote = froca.notes[ec.entity.parentNoteId];
if (branch) {
branch.update(ec.entity);
}
else if (childNote || parentNote) {
froca.branches[branch.branchId] = branch = new Branch(froca, ec.entity);
}
loadResults.addBranch(ec.entityId, ec.sourceId);
if (childNote) {
childNote.addParent(branch.parentNoteId, branch.branchId);
}
if (parentNote) {
parentNote.addChild(branch.noteId, branch.branchId);
}
}
function processNoteReordering(loadResults, ec) {
const parentNoteIdsToSort = new Set();
for (const branchId in ec.positions) {
const branch = froca.branches[branchId];
if (branch) {
branch.notePosition = ec.positions[branchId];
parentNoteIdsToSort.add(branch.parentNoteId);
}
}
for (const parentNoteId of parentNoteIdsToSort) {
const parentNote = froca.notes[parentNoteId];
if (parentNote) {
parentNote.sortChildren();
}
}
loadResults.addNoteReordering(ec.entityId, ec.sourceId);
}
function processAttributeChange(loadResults, ec) {
let attribute = froca.attributes[ec.entityId];
if (ec.isErased || ec.entity?.isDeleted) {
if (attribute) {
const sourceNote = froca.notes[attribute.noteId];
const targetNote = attribute.type === 'relation' && froca.notes[attribute.value];
if (sourceNote) {
sourceNote.attributes = sourceNote.attributes.filter(attributeId => attributeId !== attribute.attributeId);
}
if (targetNote) {
targetNote.targetRelations = targetNote.targetRelations.filter(attributeId => attributeId !== attribute.attributeId);
}
delete froca.attributes[ec.entityId];
}
return;
}
const sourceNote = froca.notes[ec.entity.noteId];
const targetNote = ec.entity.type === 'relation' && froca.notes[ec.entity.value];
if (attribute) {
attribute.update(ec.entity);
loadResults.addAttribute(ec.entityId, ec.sourceId);
} else if (sourceNote || targetNote) {
attribute = new Attribute(froca, ec.entity);
froca.attributes[attribute.attributeId] = attribute;
loadResults.addAttribute(ec.entityId, ec.sourceId);
if (sourceNote && !sourceNote.attributes.includes(attribute.attributeId)) {
sourceNote.attributes.push(attribute.attributeId);
}
if (targetNote && !targetNote.targetRelations.includes(attribute.attributeId)) {
targetNote.targetRelations.push(attribute.attributeId);
}
}
}
export default {
processEntityChanges
}

View File

@ -1,6 +1,13 @@
export default class LoadResults { export default class LoadResults {
constructor(froca) { constructor(entityChanges) {
this.froca = froca; this.entities = {};
for (const {entityId, entityName, entity} of entityChanges) {
if (entity) {
this.entities[entityName] = this.entities[entityName] || [];
this.entities[entityName][entityId] = entity;
}
}
this.noteIdToSourceId = {}; this.noteIdToSourceId = {};
this.sourceIdToNoteIds = {}; this.sourceIdToNoteIds = {};
@ -18,6 +25,10 @@ export default class LoadResults {
this.options = []; this.options = [];
} }
getEntity(entityName, entityId) {
return this.entities[entityName]?.[entityId];
}
addNote(noteId, sourceId) { addNote(noteId, sourceId) {
this.noteIdToSourceId[noteId] = this.noteIdToSourceId[noteId] || []; this.noteIdToSourceId[noteId] = this.noteIdToSourceId[noteId] || [];
@ -38,7 +49,7 @@ export default class LoadResults {
getBranches() { getBranches() {
return this.branches return this.branches
.map(row => this.froca.branches[row.branchId]) .map(row => this.getEntity("branches", row.branchId))
.filter(branch => !!branch); .filter(branch => !!branch);
} }
@ -58,7 +69,7 @@ export default class LoadResults {
getAttributes(sourceId = 'none') { getAttributes(sourceId = 'none') {
return this.attributes return this.attributes
.filter(row => row.sourceId !== sourceId) .filter(row => row.sourceId !== sourceId)
.map(row => this.froca.attributes[row.attributeId]) .map(row => this.getEntity("attributes", row.attributeId))
.filter(attr => !!attr); .filter(attr => !!attr);
} }

View File

@ -1,12 +1,8 @@
import utils from './utils.js'; import utils from './utils.js';
import toastService from "./toast.js"; import toastService from "./toast.js";
import server from "./server.js"; import server from "./server.js";
import LoadResults from "./load_results.js";
import Branch from "../entities/branch.js";
import Attribute from "../entities/attribute.js";
import options from "./options.js"; import options from "./options.js";
import froca from "./froca.js"; import frocaUpdater from "./froca_updater.js";
import noteAttributeCache from "./note_attribute_cache.js";
const messageHandlers = []; const messageHandlers = [];
@ -145,7 +141,7 @@ async function consumeFrontendUpdateData() {
const nonProcessedEntityChanges = allEntityChanges.filter(ec => !processedEntityChangeIds.has(ec.id)); const nonProcessedEntityChanges = allEntityChanges.filter(ec => !processedEntityChangeIds.has(ec.id));
try { try {
await utils.timeLimit(processEntityChanges(nonProcessedEntityChanges), 30000); await utils.timeLimit(frocaUpdater.processEntityChanges(nonProcessedEntityChanges), 30000);
} }
catch (e) { catch (e) {
logError(`Encountered error ${e.message}: ${e.stack}, reloading frontend.`); logError(`Encountered error ${e.message}: ${e.stack}, reloading frontend.`);
@ -212,229 +208,6 @@ setTimeout(() => {
setInterval(sendPing, 1000); setInterval(sendPing, 1000);
}, 0); }, 0);
async function processEntityChanges(entityChanges) {
const loadResults = new LoadResults(froca);
for (const ec of entityChanges.filter(ec => ec.entityName === 'notes')) {
try {
processNoteChange(loadResults, ec);
}
catch (e) {
throw new Error(`Can't process note ${JSON.stringify(ec)} with error ${e.message} ${e.stack}`);
}
}
for (const ec of entityChanges.filter(ec => ec.entityName === 'branches')) {
try {
processBranchChange(loadResults, ec);
}
catch (e) {
throw new Error(`Can't process branch ${JSON.stringify(ec)} with error ${e.message} ${e.stack}`);
}
}
for (const ec of entityChanges.filter(ec => ec.entityName === 'note_reordering')) {
try {
processNoteReordering(loadResults, ec);
}
catch (e) {
throw new Error(`Can't process note reordering ${JSON.stringify(ec)} with error ${e.message} ${e.stack}`);
}
}
// missing reloading the relation target note
for (const ec of entityChanges.filter(ec => ec.entityName === 'attributes')) {
try {
processAttributeChange(loadResults, ec);
}
catch (e) {
throw new Error(`Can't process attribute ${JSON.stringify(ec)} with error ${e.message} ${e.stack}`);
}
}
for (const ec of entityChanges.filter(ec => ec.entityName === 'note_contents')) {
delete froca.noteComplementPromises[ec.entityId];
loadResults.addNoteContent(ec.entityId, ec.sourceId);
}
for (const ec of entityChanges.filter(ec => ec.entityName === 'note_revisions')) {
loadResults.addNoteRevision(ec.entityId, ec.noteId, ec.sourceId);
}
for (const ec of entityChanges.filter(ec => ec.entityName === 'options')) {
if (ec.entity.name === 'openTabs') {
continue; // only noise
}
options.set(ec.entity.name, ec.entity.value);
loadResults.addOption(ec.entity.name);
}
const missingNoteIds = [];
for (const {entityName, entity} of entityChanges) {
if (!entity) { // if erased
continue;
}
if (entityName === 'branches' && !(entity.parentNoteId in froca.notes)) {
missingNoteIds.push(entity.parentNoteId);
}
else if (entityName === 'attributes'
&& entity.type === 'relation'
&& entity.name === 'template'
&& !(entity.value in froca.notes)) {
missingNoteIds.push(entity.value);
}
}
if (missingNoteIds.length > 0) {
await froca.reloadNotes(missingNoteIds);
}
if (!loadResults.isEmpty()) {
if (loadResults.hasAttributeRelatedChanges()) {
noteAttributeCache.invalidate();
}
const appContext = (await import("./app_context.js")).default;
await appContext.triggerEvent('entitiesReloaded', {loadResults});
}
}
function processNoteChange(loadResults, ec) {
const note = froca.notes[ec.entityId];
if (!note) {
return;
}
if (ec.isErased || (ec.entity && ec.isDeleted)) {
delete froca.notes[ec.entityId];
return;
}
note.update(ec.entity);
loadResults.addNote(ec.entityId, ec.sourceId);
}
function processBranchChange(loadResults, ec) {
let branch = froca.branches[ec.entityId];
if (ec.isErased || ec.entity?.isDeleted) {
if (branch) {
const childNote = froca.notes[branch.noteId];
const parentNote = froca.notes[branch.parentNoteId];
if (childNote) {
childNote.parents = childNote.parents.filter(parentNoteId => parentNoteId !== branch.parentNoteId);
delete childNote.parentToBranch[branch.parentNoteId];
}
if (parentNote) {
parentNote.children = parentNote.children.filter(childNoteId => childNoteId !== branch.noteId);
delete parentNote.childToBranch[branch.noteId];
}
delete froca.branches[ec.entityId];
}
return;
}
const childNote = froca.notes[ec.entity.noteId];
const parentNote = froca.notes[ec.entity.parentNoteId];
if (branch) {
branch.update(ec.entity);
}
else if (childNote || parentNote) {
froca.branches[branch.branchId] = branch = new Branch(froca, ec.entity);
}
loadResults.addBranch(ec.entityId, ec.sourceId);
if (childNote) {
childNote.addParent(branch.parentNoteId, branch.branchId);
}
if (parentNote) {
parentNote.addChild(branch.noteId, branch.branchId);
}
}
function processNoteReordering(loadResults, ec) {
const parentNoteIdsToSort = new Set();
for (const branchId in ec.positions) {
const branch = froca.branches[branchId];
if (branch) {
branch.notePosition = ec.positions[branchId];
parentNoteIdsToSort.add(branch.parentNoteId);
}
}
for (const parentNoteId of parentNoteIdsToSort) {
const parentNote = froca.notes[parentNoteId];
if (parentNote) {
parentNote.sortChildren();
}
}
loadResults.addNoteReordering(ec.entityId, ec.sourceId);
}
function processAttributeChange(loadResults, ec) {
let attribute = froca.attributes[ec.entityId];
if (ec.isErased || ec.entity?.isDeleted) {
if (attribute) {
const sourceNote = froca.notes[attribute.noteId];
const targetNote = attribute.type === 'relation' && froca.notes[attribute.value];
if (sourceNote) {
sourceNote.attributes = sourceNote.attributes.filter(attributeId => attributeId !== attribute.attributeId);
}
if (targetNote) {
targetNote.targetRelations = targetNote.targetRelations.filter(attributeId => attributeId !== attribute.attributeId);
}
delete froca.attributes[ec.entityId];
}
return;
}
const sourceNote = froca.notes[ec.entity.noteId];
const targetNote = ec.entity.type === 'relation' && froca.notes[ec.entity.value];
if (attribute) {
attribute.update(ec.entity);
loadResults.addAttribute(ec.entityId, ec.sourceId);
} else if (sourceNote || targetNote) {
attribute = new Attribute(froca, ec.entity);
froca.attributes[attribute.attributeId] = attribute;
loadResults.addAttribute(ec.entityId, ec.sourceId);
if (sourceNote && !sourceNote.attributes.includes(attribute.attributeId)) {
sourceNote.attributes.push(attribute.attributeId);
}
if (targetNote && !targetNote.targetRelations.includes(attribute.attributeId)) {
targetNote.targetRelations.push(attribute.attributeId);
}
}
}
export default { export default {
logError, logError,
subscribeToMessages, subscribeToMessages,