@atproto/common 0.3.4 → 0.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atproto/common
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2169](https://github.com/bluesky-social/atproto/pull/2169) [`f689bd51a`](https://github.com/bluesky-social/atproto/commit/f689bd51a2f4e02d4eca40eb2568a1fcb95494e9) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Build system rework, stop bundling dependencies.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`f689bd51a`](https://github.com/bluesky-social/atproto/commit/f689bd51a2f4e02d4eca40eb2568a1fcb95494e9)]:
12
+ - @atproto/common-web@0.3.0
13
+
3
14
  ## 0.3.4
4
15
 
5
16
  ### Patch Changes
package/dist/buffers.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  /// <reference types="node" />
2
2
  export declare function ui8ToBuffer(bytes: Uint8Array): Buffer;
3
3
  export declare function ui8ToArrayBuffer(bytes: Uint8Array): ArrayBuffer;
4
+ //# sourceMappingURL=buffers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffers.d.ts","sourceRoot":"","sources":["../src/buffers.ts"],"names":[],"mappings":";AAAA,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAErD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAK/D"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ui8ToArrayBuffer = exports.ui8ToBuffer = void 0;
4
+ function ui8ToBuffer(bytes) {
5
+ return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
6
+ }
7
+ exports.ui8ToBuffer = ui8ToBuffer;
8
+ function ui8ToArrayBuffer(bytes) {
9
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteLength + bytes.byteOffset);
10
+ }
11
+ exports.ui8ToArrayBuffer = ui8ToArrayBuffer;
12
+ //# sourceMappingURL=buffers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffers.js","sourceRoot":"","sources":["../src/buffers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,KAAiB;IAC3C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;AACtE,CAAC;AAFD,kCAEC;AAED,SAAgB,gBAAgB,CAAC,KAAiB;IAChD,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CACvB,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CACpC,CAAA;AACH,CAAC;AALD,4CAKC"}
package/dist/dates.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export declare function toSimplifiedISOSafe(dateStr: string): string;
2
+ //# sourceMappingURL=dates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dates.d.ts","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":"AAIA,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,UAWlD"}
package/dist/dates.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toSimplifiedISOSafe = void 0;
4
+ const iso_datestring_validator_1 = require("iso-datestring-validator");
5
+ // Normalize date strings to simplified ISO so that the lexical sort preserves temporal sort.
6
+ // Rather than failing on an invalid date format, returns valid unix epoch.
7
+ function toSimplifiedISOSafe(dateStr) {
8
+ const date = new Date(dateStr);
9
+ if (isNaN(date.getTime())) {
10
+ return new Date(0).toISOString();
11
+ }
12
+ const iso = date.toISOString();
13
+ if (!(0, iso_datestring_validator_1.isValidISODateString)(iso)) {
14
+ // Occurs in rare cases, e.g. where resulting UTC year is negative. These also don't preserve lexical sort.
15
+ return new Date(0).toISOString();
16
+ }
17
+ return iso; // YYYY-MM-DDTHH:mm:ss.sssZ
18
+ }
19
+ exports.toSimplifiedISOSafe = toSimplifiedISOSafe;
20
+ //# sourceMappingURL=dates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dates.js","sourceRoot":"","sources":["../src/dates.ts"],"names":[],"mappings":";;;AAAA,uEAA+D;AAE/D,6FAA6F;AAC7F,2EAA2E;AAC3E,SAAgB,mBAAmB,CAAC,OAAe;IACjD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAA;IAC9B,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAClC,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IAC9B,IAAI,CAAC,IAAA,+CAAoB,EAAC,GAAG,CAAC,EAAE,CAAC;QAC/B,2GAA2G;QAC3G,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;IAClC,CAAC;IACD,OAAO,GAAG,CAAA,CAAC,2BAA2B;AACxC,CAAC;AAXD,kDAWC"}
package/dist/env.d.ts CHANGED
@@ -2,3 +2,4 @@ export declare const envInt: (name: string) => number | undefined;
2
2
  export declare const envStr: (name: string) => string | undefined;
3
3
  export declare const envBool: (name: string) => boolean | undefined;
4
4
  export declare const envList: (name: string) => string[];
5
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,SAAU,MAAM,KAAG,MAAM,GAAG,SAG9C,CAAA;AAED,eAAO,MAAM,MAAM,SAAU,MAAM,KAAG,MAAM,GAAG,SAI9C,CAAA;AAED,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,OAAO,GAAG,SAKhD,CAAA;AAED,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAM,EAI5C,CAAA"}
package/dist/env.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.envList = exports.envBool = exports.envStr = exports.envInt = void 0;
4
+ const common_web_1 = require("@atproto/common-web");
5
+ const envInt = (name) => {
6
+ const str = process.env[name];
7
+ return (0, common_web_1.parseIntWithFallback)(str, undefined);
8
+ };
9
+ exports.envInt = envInt;
10
+ const envStr = (name) => {
11
+ const str = process.env[name];
12
+ if (str === undefined || str.length === 0)
13
+ return undefined;
14
+ return str;
15
+ };
16
+ exports.envStr = envStr;
17
+ const envBool = (name) => {
18
+ const str = process.env[name];
19
+ if (str === 'true' || str === '1')
20
+ return true;
21
+ if (str === 'false' || str === '0')
22
+ return false;
23
+ return undefined;
24
+ };
25
+ exports.envBool = envBool;
26
+ const envList = (name) => {
27
+ const str = process.env[name];
28
+ if (str === undefined || str.length === 0)
29
+ return [];
30
+ return str.split(',');
31
+ };
32
+ exports.envList = envList;
33
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":";;;AAAA,oDAA0D;AAEnD,MAAM,MAAM,GAAG,CAAC,IAAY,EAAsB,EAAE;IACzD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC7B,OAAO,IAAA,iCAAoB,EAAC,GAAG,EAAE,SAAS,CAAC,CAAA;AAC7C,CAAC,CAAA;AAHY,QAAA,MAAM,UAGlB;AAEM,MAAM,MAAM,GAAG,CAAC,IAAY,EAAsB,EAAE;IACzD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC7B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAC3D,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAJY,QAAA,MAAM,UAIlB;AAEM,MAAM,OAAO,GAAG,CAAC,IAAY,EAAuB,EAAE;IAC3D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC7B,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IAC9C,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,GAAG;QAAE,OAAO,KAAK,CAAA;IAChD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AALY,QAAA,OAAO,WAKnB;AAEM,MAAM,OAAO,GAAG,CAAC,IAAY,EAAY,EAAE;IAChD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC7B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACpD,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AACvB,CAAC,CAAA;AAJY,QAAA,OAAO,WAInB"}
package/dist/fs.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export declare const fileExists: (location: string) => Promise<boolean>;
2
2
  export declare const readIfExists: (filepath: string) => Promise<Uint8Array | undefined>;
3
3
  export declare const rmIfExists: (filepath: string, recursive?: boolean) => Promise<void>;
4
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,aAAoB,MAAM,KAAG,QAAQ,OAAO,CAUlE,CAAA;AAED,eAAO,MAAM,YAAY,aACb,MAAM,KACf,QAAQ,UAAU,GAAG,SAAS,CAShC,CAAA;AAED,eAAO,MAAM,UAAU,aACX,MAAM,0BAEf,QAAQ,IAAI,CASd,CAAA"}
package/dist/fs.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.rmIfExists = exports.readIfExists = exports.fileExists = void 0;
7
+ const common_web_1 = require("@atproto/common-web");
8
+ const fs_1 = require("fs");
9
+ const promises_1 = __importDefault(require("fs/promises"));
10
+ const fileExists = async (location) => {
11
+ try {
12
+ await promises_1.default.access(location, fs_1.constants.F_OK);
13
+ return true;
14
+ }
15
+ catch (err) {
16
+ if ((0, common_web_1.isErrnoException)(err) && err.code === 'ENOENT') {
17
+ return false;
18
+ }
19
+ throw err;
20
+ }
21
+ };
22
+ exports.fileExists = fileExists;
23
+ const readIfExists = async (filepath) => {
24
+ try {
25
+ return await promises_1.default.readFile(filepath);
26
+ }
27
+ catch (err) {
28
+ if ((0, common_web_1.isErrnoException)(err) && err.code === 'ENOENT') {
29
+ return;
30
+ }
31
+ throw err;
32
+ }
33
+ };
34
+ exports.readIfExists = readIfExists;
35
+ const rmIfExists = async (filepath, recursive = false) => {
36
+ try {
37
+ await promises_1.default.rm(filepath, { recursive });
38
+ }
39
+ catch (err) {
40
+ if ((0, common_web_1.isErrnoException)(err) && err.code === 'ENOENT') {
41
+ return;
42
+ }
43
+ throw err;
44
+ }
45
+ };
46
+ exports.rmIfExists = rmIfExists;
47
+ //# sourceMappingURL=fs.js.map
package/dist/fs.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsD;AACtD,2BAA8B;AAC9B,2DAA4B;AAErB,MAAM,UAAU,GAAG,KAAK,EAAE,QAAgB,EAAoB,EAAE;IACrE,IAAI,CAAC;QACH,MAAM,kBAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,cAAS,CAAC,IAAI,CAAC,CAAA;QACzC,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,IAAA,6BAAgB,EAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACnD,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC,CAAA;AAVY,QAAA,UAAU,cAUtB;AAEM,MAAM,YAAY,GAAG,KAAK,EAC/B,QAAgB,EACiB,EAAE;IACnC,IAAI,CAAC;QACH,OAAO,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,IAAA,6BAAgB,EAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACnD,OAAM;QACR,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC,CAAA;AAXY,QAAA,YAAY,gBAWxB;AAEM,MAAM,UAAU,GAAG,KAAK,EAC7B,QAAgB,EAChB,SAAS,GAAG,KAAK,EACF,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,kBAAE,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,CAAC,CAAA;IACtC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,IAAA,6BAAgB,EAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACnD,OAAM;QACR,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC,CAAA;AAZY,QAAA,UAAU,cAYtB"}
package/dist/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from './ipld-multi';
7
7
  export * from './logger';
8
8
  export * from './streams';
9
9
  export * from './buffers';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,MAAM,CAAA;AACpB,cAAc,QAAQ,CAAA;AACtB,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA"}