@dittolive/ditto 4.4.0 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/node/ditto.cjs.js +84 -4
- package/node/ditto.darwin-arm64.node +0 -0
- package/node/ditto.darwin-x64.node +0 -0
- package/node/ditto.linux-arm.node +0 -0
- package/node/ditto.linux-x64.node +0 -0
- package/node/ditto.win32-x64.node +0 -0
- package/node/transports.darwin-arm64.node +0 -0
- package/node/transports.darwin-x64.node +0 -0
- package/package.json +1 -1
- package/types/ditto.d.ts +2 -1
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
package/README.md
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*Ditto is a cross platform SDK that allows mobile, web, and IoT apps to sync
|
|
4
4
|
with and even without connectivity.*
|
|
5
5
|
|
|
6
|
-
Version: **4.4.
|
|
6
|
+
Version: **4.4.1**
|
|
7
7
|
|
|
8
8
|
Please visit [ditto.live](https://ditto.live) for more info as well as the
|
|
9
|
-
[API Reference](https://software.ditto.live/js/Ditto/4.4.
|
|
9
|
+
[API Reference](https://software.ditto.live/js/Ditto/4.4.1/api-reference/) for this particular version.
|
|
10
10
|
|
|
11
11
|
--------------------------------------------------------------------------------
|
|
12
12
|
|
package/node/ditto.cjs.js
CHANGED
|
@@ -1521,7 +1521,7 @@ function awdlDestroy(awdl) {
|
|
|
1521
1521
|
|
|
1522
1522
|
// NOTE: this is patched up with the actual build version by Jake task
|
|
1523
1523
|
// build:package and has to be a valid semantic version as defined here: https://semver.org.
|
|
1524
|
-
const fullBuildVersionString = '4.4.
|
|
1524
|
+
const fullBuildVersionString = '4.4.1';
|
|
1525
1525
|
|
|
1526
1526
|
//
|
|
1527
1527
|
// Copyright © 2021 DittoLive Incorporated. All rights reserved.
|
|
@@ -7908,7 +7908,8 @@ class Ditto {
|
|
|
7908
7908
|
* `offlinePlayground` with `appID` being the empty string `''`.
|
|
7909
7909
|
*
|
|
7910
7910
|
* @param persistenceDirectory optional string containing a directory path
|
|
7911
|
-
* that Ditto will use for persistence. Defaults to `"ditto"`.
|
|
7911
|
+
* that Ditto will use for persistence. Defaults to `"ditto"`. On Windows,
|
|
7912
|
+
* the path will be automatically normalized.
|
|
7912
7913
|
*
|
|
7913
7914
|
* @see {@link Ditto.identity}
|
|
7914
7915
|
* @see {@link Ditto.persistenceDirectory}
|
|
@@ -8152,11 +8153,42 @@ class Ditto {
|
|
|
8152
8153
|
}
|
|
8153
8154
|
{
|
|
8154
8155
|
const fs = require('fs');
|
|
8156
|
+
const path = require('path');
|
|
8157
|
+
if (process.platform === 'win32') {
|
|
8158
|
+
// Normalize the path on Windows to prevent issues with its max path
|
|
8159
|
+
// length. Windows has a hard limit at 260 characters for file paths
|
|
8160
|
+
// [1]. When this limit is exceeded reads and writes may fail.
|
|
8161
|
+
//
|
|
8162
|
+
// [1]: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation
|
|
8163
|
+
validatedPath = `\\\\?\\${path.resolve(validatedPath)}`;
|
|
8164
|
+
}
|
|
8165
|
+
const absolutePath = path.resolve(validatedPath);
|
|
8166
|
+
// We check if the directory exists before creating it to be able to
|
|
8167
|
+
// provide a more helpful error message in case the directory is not
|
|
8168
|
+
// writable.
|
|
8169
|
+
let isDirectoryExisting = false;
|
|
8155
8170
|
try {
|
|
8156
|
-
fs.
|
|
8171
|
+
fs.statSync(absolutePath);
|
|
8172
|
+
isDirectoryExisting = true;
|
|
8157
8173
|
}
|
|
8158
8174
|
catch (error) {
|
|
8159
|
-
|
|
8175
|
+
// On Windows, permissions can prevent us from checking if the directory
|
|
8176
|
+
// exists: https://github.com/nodejs/node/issues/35853
|
|
8177
|
+
if (error.code === 'EPERM') {
|
|
8178
|
+
throw new Error(`Missing read or write permissions for the persistence directory path '${absolutePath}'. Please update the permissions or use a different path.`);
|
|
8179
|
+
}
|
|
8180
|
+
}
|
|
8181
|
+
if (!isDirectoryExisting) {
|
|
8182
|
+
try {
|
|
8183
|
+
fs.mkdirSync(absolutePath, { recursive: true });
|
|
8184
|
+
}
|
|
8185
|
+
catch (error) {
|
|
8186
|
+
throw new Error(`Failed to create persistence directory at path '${absolutePath}'.\n\n${error}`);
|
|
8187
|
+
}
|
|
8188
|
+
}
|
|
8189
|
+
// Caveat: It is still possible that these permissions are revoked during runtime.
|
|
8190
|
+
if (!isDirectoryWritable(absolutePath)) {
|
|
8191
|
+
throw new Error(`Missing read or write permissions for the persistence directory path '${absolutePath}'. Please update the permissions or use a different path.`);
|
|
8160
8192
|
}
|
|
8161
8193
|
}
|
|
8162
8194
|
return validatedPath;
|
|
@@ -8535,6 +8567,54 @@ const disableDeadlockTimeoutWhenDebugging = () => {
|
|
|
8535
8567
|
}
|
|
8536
8568
|
}
|
|
8537
8569
|
};
|
|
8570
|
+
/**
|
|
8571
|
+
* Return true if we have read and write permissions for the given directory.
|
|
8572
|
+
*
|
|
8573
|
+
* Always returns `true` in the browser.
|
|
8574
|
+
*
|
|
8575
|
+
* Uses `fs.accessSync()` on all platforms except Windows, where ACLs are not
|
|
8576
|
+
* checked by that method [1]. On Windows, we try writing and removing a temp
|
|
8577
|
+
* file to the given path instead.
|
|
8578
|
+
*
|
|
8579
|
+
* [1]:
|
|
8580
|
+
* https://nodejs.org/docs/latest-v18.x/api/fs.html#fsaccesspath-mode-callback
|
|
8581
|
+
*
|
|
8582
|
+
* @internal
|
|
8583
|
+
*/
|
|
8584
|
+
const isDirectoryWritable = (directoryPath) => {
|
|
8585
|
+
{
|
|
8586
|
+
const fs = require('fs');
|
|
8587
|
+
const path = require('path');
|
|
8588
|
+
if (process.platform === 'win32') {
|
|
8589
|
+
const persistenceDirectory = path.resolve(directoryPath);
|
|
8590
|
+
const testFilePath = path.join(persistenceDirectory, 'ditto-permissions-test.txt');
|
|
8591
|
+
const testFileContents = 'permissions test';
|
|
8592
|
+
try {
|
|
8593
|
+
fs.writeFileSync(testFilePath, testFileContents);
|
|
8594
|
+
const fileContents = fs.readFileSync(testFilePath, 'utf8');
|
|
8595
|
+
if (fileContents !== testFileContents) {
|
|
8596
|
+
Logger.debug(`Failed to read back test file contents, expected '${testFileContents}' but got '${fileContents}'`);
|
|
8597
|
+
return false;
|
|
8598
|
+
}
|
|
8599
|
+
fs.unlinkSync(testFilePath);
|
|
8600
|
+
}
|
|
8601
|
+
catch (error) {
|
|
8602
|
+
Logger.debug(`Failed to access persistence directory: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
8603
|
+
return false;
|
|
8604
|
+
}
|
|
8605
|
+
}
|
|
8606
|
+
else {
|
|
8607
|
+
try {
|
|
8608
|
+
fs.accessSync(directoryPath, fs.constants.W_OK | fs.constants.R_OK);
|
|
8609
|
+
}
|
|
8610
|
+
catch (error) {
|
|
8611
|
+
Logger.debug(`Failed to access persistence directory: ${error === null || error === void 0 ? void 0 : error.message}`);
|
|
8612
|
+
return false;
|
|
8613
|
+
}
|
|
8614
|
+
}
|
|
8615
|
+
}
|
|
8616
|
+
return true;
|
|
8617
|
+
};
|
|
8538
8618
|
|
|
8539
8619
|
/**
|
|
8540
8620
|
* Get a count of bridged objects binned by bridge type.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dittolive/ditto",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "Ditto is a cross-platform embeddable NoSQL database that can sync with or without an internet connection.",
|
|
5
5
|
"homepage": "https://ditto.live",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/types/ditto.d.ts
CHANGED
|
@@ -1970,7 +1970,8 @@ declare class Ditto {
|
|
|
1970
1970
|
* `offlinePlayground` with `appID` being the empty string `''`.
|
|
1971
1971
|
*
|
|
1972
1972
|
* @param persistenceDirectory optional string containing a directory path
|
|
1973
|
-
* that Ditto will use for persistence. Defaults to `"ditto"`.
|
|
1973
|
+
* that Ditto will use for persistence. Defaults to `"ditto"`. On Windows,
|
|
1974
|
+
* the path will be automatically normalized.
|
|
1974
1975
|
*
|
|
1975
1976
|
* @see {@link Ditto.identity}
|
|
1976
1977
|
* @see {@link Ditto.persistenceDirectory}
|