@slates/provider-handler 1.0.0-rc.24 → 1.0.0-rc.26
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/dist/index.cjs +16 -1
- package/dist/index.module.js +16 -1
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/pQueue.test.ts +18 -0
- package/src/pQueue.ts +18 -0
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,22 @@ module.exports = __toCommonJS(index_exports);
|
|
|
36
36
|
var import_error4 = require("@lowerdeck/error");
|
|
37
37
|
var import_proto = require("@slates/proto");
|
|
38
38
|
var import_provider2 = require("@slates/provider");
|
|
39
|
+
|
|
40
|
+
// src/pQueue.ts
|
|
39
41
|
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
42
|
+
var resolveDefaultExport = (value) => {
|
|
43
|
+
let current = value;
|
|
44
|
+
for (let i = 0; i < 4; i++) {
|
|
45
|
+
if (typeof current === "function") return current;
|
|
46
|
+
if (current && typeof current === "object" && "default" in current) {
|
|
47
|
+
current = current.default;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
throw new TypeError("Module export is not a constructor");
|
|
53
|
+
};
|
|
54
|
+
var PQueue = resolveDefaultExport(import_p_queue.default);
|
|
40
55
|
|
|
41
56
|
// src/spec.ts
|
|
42
57
|
var import_error2 = require("@lowerdeck/error");
|
|
@@ -258,7 +273,7 @@ var routeAttachmentsThroughDirectUpload = async (attachments, live) => {
|
|
|
258
273
|
if (!attachments || attachments.length === 0 || !live) return attachments;
|
|
259
274
|
let contentEntries = attachments.map((attachment, index) => ({ attachment, index })).filter((entry) => entry.attachment.content.type === "content");
|
|
260
275
|
if (contentEntries.length === 0) return attachments;
|
|
261
|
-
let queue = new
|
|
276
|
+
let queue = new PQueue({ concurrency: 10 });
|
|
262
277
|
let replacements = /* @__PURE__ */ new Map();
|
|
263
278
|
await Promise.all(
|
|
264
279
|
contentEntries.map(
|
package/dist/index.module.js
CHANGED
|
@@ -12,7 +12,22 @@ import {
|
|
|
12
12
|
SlatePublicContext,
|
|
13
13
|
uploadAttachmentDirect
|
|
14
14
|
} from "@slates/provider";
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
// src/pQueue.ts
|
|
17
|
+
import PQueueImport from "p-queue";
|
|
18
|
+
var resolveDefaultExport = (value) => {
|
|
19
|
+
let current = value;
|
|
20
|
+
for (let i = 0; i < 4; i++) {
|
|
21
|
+
if (typeof current === "function") return current;
|
|
22
|
+
if (current && typeof current === "object" && "default" in current) {
|
|
23
|
+
current = current.default;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
throw new TypeError("Module export is not a constructor");
|
|
29
|
+
};
|
|
30
|
+
var PQueue = resolveDefaultExport(PQueueImport);
|
|
16
31
|
|
|
17
32
|
// src/spec.ts
|
|
18
33
|
import { badRequestError, notFoundError, ServiceError as ServiceError2 } from "@lowerdeck/error";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slates/provider-handler",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.26",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@lowerdeck/error": "^1.1.0",
|
|
35
35
|
"@slates/proto": "1.0.0-rc.16",
|
|
36
|
-
"@slates/provider": "1.0.0-rc.
|
|
36
|
+
"@slates/provider": "1.0.0-rc.20",
|
|
37
37
|
"p-queue": "^6.6.2",
|
|
38
38
|
"zod": "^4.2.1"
|
|
39
39
|
},
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { resolveDefaultExport } from './pQueue';
|
|
3
|
+
|
|
4
|
+
class Example {
|
|
5
|
+
value: number;
|
|
6
|
+
constructor(value: number) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe('resolveDefaultExport', () => {
|
|
12
|
+
it('unwraps nested CJS default exports from bundlers', () => {
|
|
13
|
+
expect(resolveDefaultExport<typeof Example>({ default: { default: Example } })).toBe(
|
|
14
|
+
Example
|
|
15
|
+
);
|
|
16
|
+
expect(new (resolveDefaultExport<typeof Example>({ default: Example }))(3).value).toBe(3);
|
|
17
|
+
});
|
|
18
|
+
});
|
package/src/pQueue.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import PQueueImport from 'p-queue';
|
|
2
|
+
|
|
3
|
+
export let resolveDefaultExport = <T>(value: unknown): T => {
|
|
4
|
+
let current = value;
|
|
5
|
+
|
|
6
|
+
for (let i = 0; i < 4; i++) {
|
|
7
|
+
if (typeof current === 'function') return current as T;
|
|
8
|
+
if (current && typeof current === 'object' && 'default' in current) {
|
|
9
|
+
current = (current as { default: unknown }).default;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
throw new TypeError('Module export is not a constructor');
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export let PQueue = resolveDefaultExport<typeof PQueueImport>(PQueueImport);
|